]>
Commit | Line | Data |
---|---|---|
9b6bbcdb MK |
1 | /** @file\r |
2 | Header file for the defintions used in SMBus DXE driver.\r | |
3 | \r | |
4 | Copyright (c) 2013-2015 Intel Corporation.\r | |
5 | \r | |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | \r | |
17 | #ifndef _DXE_QNC_SMBUS_H_\r | |
18 | #define _DXE_QNC_SMBUS_H_\r | |
19 | #include "CommonHeader.h"\r | |
20 | \r | |
21 | #include "QNCSmbus.h"\r | |
22 | \r | |
23 | #define MAX_SMBUS_DEVICES 107 // Max number of SMBus devices (7 bit\r | |
24 | // address yields 128 combinations but 21\r | |
25 | // of those are reserved)\r | |
26 | \r | |
27 | #define MICROSECOND 10\r | |
28 | #define MILLISECOND (1000 * MICROSECOND)\r | |
29 | #define ONESECOND (1000 * MILLISECOND)\r | |
30 | \r | |
31 | #define STALL_TIME 1000000 // 1,000,000 microseconds = 1 second\r | |
32 | #define BUS_TRIES 3 // How many times to retry on Bus Errors\r | |
33 | #define SMBUS_NUM_RESERVED 21 // Number of device addresses that are\r | |
34 | // reserved by the SMBus spec.\r | |
35 | #define SMBUS_ADDRESS_ARP 0xC2 >> 1\r | |
36 | #define SMBUS_DATA_PREPARE_TO_ARP 0x01\r | |
37 | #define SMBUS_DATA_RESET_DEVICE 0x02\r | |
38 | #define SMBUS_DATA_GET_UDID_GENERAL 0x03\r | |
39 | #define SMBUS_DATA_ASSIGN_ADDRESS 0x04\r | |
40 | #define SMBUS_GET_UDID_LENGTH 17 // 16 byte UDID + 1 byte address\r | |
41 | \r | |
42 | /**\r | |
43 | Executes an SMBus operation to an SMBus controller. Returns when either the command has been\r | |
44 | executed or an error is encountered in doing the operation.\r | |
45 | \r | |
46 | The Execute() function provides a standard way to execute an operation as defined in the System\r | |
47 | Management Bus (SMBus) Specification. The resulting transaction will be either that the SMBus\r | |
48 | slave devices accept this transaction or that this function returns with error.\r | |
49 | \r | |
50 | @param This A pointer to the EFI_SMBUS_HC_PROTOCOL instance.\r | |
51 | @param SlaveAddress The SMBus slave address of the device with which to communicate.\r | |
52 | @param Command This command is transmitted by the SMBus host controller to the\r | |
53 | SMBus slave device and the interpretation is SMBus slave device\r | |
54 | specific. It can mean the offset to a list of functions inside an\r | |
55 | SMBus slave device. Not all operations or slave devices support\r | |
56 | this command's registers.\r | |
57 | @param Operation Signifies which particular SMBus hardware protocol instance that\r | |
58 | it will use to execute the SMBus transactions. This SMBus\r | |
59 | hardware protocol is defined by the SMBus Specification and is\r | |
60 | not related to EFI.\r | |
61 | @param PecCheck Defines if Packet Error Code (PEC) checking is required for this\r | |
62 | operation.\r | |
63 | @param Length Signifies the number of bytes that this operation will do. The\r | |
64 | maximum number of bytes can be revision specific and operation\r | |
65 | specific. This field will contain the actual number of bytes that\r | |
66 | are executed for this operation. Not all operations require this\r | |
67 | argument.\r | |
68 | @param Buffer Contains the value of data to execute to the SMBus slave device.\r | |
69 | Not all operations require this argument. The length of this\r | |
70 | buffer is identified by Length.\r | |
71 | \r | |
72 | @retval EFI_SUCCESS The last data that was returned from the access matched the poll\r | |
73 | exit criteria.\r | |
74 | @retval EFI_CRC_ERROR Checksum is not correct (PEC is incorrect).\r | |
75 | @retval EFI_TIMEOUT Timeout expired before the operation was completed. Timeout is\r | |
76 | determined by the SMBus host controller device.\r | |
77 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r | |
78 | @retval EFI_DEVICE_ERROR The request was not completed because a failure that was\r | |
79 | reflected in the Host Status Register bit. Device errors are a\r | |
80 | result of a transaction collision, illegal command field,\r | |
81 | unclaimed cycle (host initiated), or bus errors (collisions).\r | |
82 | @retval EFI_INVALID_PARAMETER Operation is not defined in EFI_SMBUS_OPERATION.\r | |
83 | @retval EFI_INVALID_PARAMETER Length/Buffer is NULL for operations except for EfiSmbusQuickRead\r | |
84 | and EfiSmbusQuickWrite. Length is outside the range of valid\r | |
85 | values.\r | |
86 | @retval EFI_UNSUPPORTED The SMBus operation or PEC is not supported.\r | |
87 | @retval EFI_BUFFER_TOO_SMALL Buffer is not sufficient for this operation.\r | |
88 | \r | |
89 | **/\r | |
90 | EFI_STATUS\r | |
91 | EFIAPI\r | |
92 | SmbusExecute (\r | |
93 | IN CONST EFI_SMBUS_HC_PROTOCOL *This,\r | |
94 | IN CONST EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,\r | |
95 | IN CONST EFI_SMBUS_DEVICE_COMMAND Command,\r | |
96 | IN CONST EFI_SMBUS_OPERATION Operation,\r | |
97 | IN CONST BOOLEAN PecCheck,\r | |
98 | IN OUT UINTN *Length,\r | |
99 | IN OUT VOID *Buffer\r | |
100 | );\r | |
101 | \r | |
102 | /**\r | |
103 | Sets the SMBus slave device addresses for the device with a given unique ID or enumerates the\r | |
104 | entire bus.\r | |
105 | \r | |
106 | The ArpDevice() function provides a standard way for a device driver to enumerate the entire\r | |
107 | SMBus or specific devices on the bus.\r | |
108 | \r | |
109 | @param This A pointer to the EFI_SMBUS_HC_PROTOCOL instance.\r | |
110 | @param ArpAll A Boolean expression that indicates if the host drivers need to\r | |
111 | enumerate all the devices or enumerate only the device that is\r | |
112 | identified by SmbusUdid. If ArpAll is TRUE, SmbusUdid and\r | |
113 | SlaveAddress are optional. If ArpAll is FALSE, ArpDevice will\r | |
114 | enumerate SmbusUdid and the address will be at SlaveAddress.\r | |
115 | @param SmbusUdid The Unique Device Identifier (UDID) that is associated with this\r | |
116 | device.\r | |
117 | @param SlaveAddress The SMBus slave address that is associated with an SMBus UDID.\r | |
118 | \r | |
119 | @retval EFI_SUCCESS The last data that was returned from the access matched the poll\r | |
120 | exit criteria.\r | |
121 | @retval EFI_CRC_ERROR Checksum is not correct (PEC is incorrect).\r | |
122 | @retval EFI_TIMEOUT Timeout expired before the operation was completed. Timeout is\r | |
123 | determined by the SMBus host controller device.\r | |
124 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r | |
125 | @retval EFI_DEVICE_ERROR The request was not completed because a failure that was\r | |
126 | reflected in the Host Status Register bit. Device errors are a\r | |
127 | result of a transaction collision, illegal command field,\r | |
128 | unclaimed cycle (host initiated), or bus errors (collisions).\r | |
129 | @retval EFI_UNSUPPORTED The corresponding operation is not supported.\r | |
130 | \r | |
131 | **/\r | |
132 | EFI_STATUS\r | |
133 | EFIAPI\r | |
134 | SmbusArpDevice (\r | |
135 | IN CONST EFI_SMBUS_HC_PROTOCOL *This,\r | |
136 | IN BOOLEAN ArpAll,\r | |
137 | IN EFI_SMBUS_UDID *SmbusUdid, OPTIONAL\r | |
138 | IN OUT EFI_SMBUS_DEVICE_ADDRESS *SlaveAddress OPTIONAL\r | |
139 | );\r | |
140 | \r | |
141 | /**\r | |
142 | Returns a pointer to the Address Resolution Protocol (ARP) map that contains the ID/address pair\r | |
143 | of the slave devices that were enumerated by the SMBus host controller driver.\r | |
144 | \r | |
145 | The GetArpMap() function returns the mapping of all the SMBus devices that were enumerated by the\r | |
146 | SMBus host driver.\r | |
147 | \r | |
148 | @param This A pointer to the EFI_SMBUS_HC_PROTOCOL instance.\r | |
149 | @param Length Size of the buffer that contains the SMBus device map.\r | |
150 | @param SmbusDeviceMap The pointer to the device map as enumerated by the SMBus\r | |
151 | controller driver.\r | |
152 | \r | |
153 | @retval EFI_SUCCESS The SMBus returned the current device map.\r | |
154 | @retval EFI_UNSUPPORTED The corresponding operation is not supported.\r | |
155 | \r | |
156 | **/\r | |
157 | EFI_STATUS\r | |
158 | EFIAPI\r | |
159 | SmbusGetArpMap (\r | |
160 | IN CONST EFI_SMBUS_HC_PROTOCOL *This,\r | |
161 | IN OUT UINTN *Length,\r | |
162 | IN OUT EFI_SMBUS_DEVICE_MAP **SmbusDeviceMap\r | |
163 | );\r | |
164 | \r | |
165 | /**\r | |
166 | Allows a device driver to register for a callback when the bus driver detects a state that it\r | |
167 | needs to propagate to other drivers that are registered for a callback.\r | |
168 | \r | |
169 | The Notify() function registers all the callback functions to allow the bus driver to call these\r | |
170 | functions when the SlaveAddress/Data pair happens.\r | |
171 | If NotifyFunction is NULL, then ASSERT ().\r | |
172 | \r | |
173 | @param This A pointer to the EFI_SMBUS_HC_PROTOCOL instance.\r | |
174 | @param SlaveAddress The SMBUS hardware address to which the SMBUS device is\r | |
175 | preassigned or allocated.\r | |
176 | @param Data Data of the SMBus host notify command that the caller wants to be\r | |
177 | called.\r | |
178 | @param NotifyFunction The function to call when the bus driver detects the SlaveAddress\r | |
179 | and Data pair.\r | |
180 | \r | |
181 | @retval EFI_SUCCESS NotifyFunction was registered.\r | |
182 | @retval EFI_UNSUPPORTED The corresponding operation is not supported.\r | |
183 | \r | |
184 | **/\r | |
185 | EFI_STATUS\r | |
186 | EFIAPI\r | |
187 | SmbusNotify (\r | |
188 | IN CONST EFI_SMBUS_HC_PROTOCOL *This,\r | |
189 | IN CONST EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,\r | |
190 | IN CONST UINTN Data,\r | |
191 | IN CONST EFI_SMBUS_NOTIFY_FUNCTION NotifyFunction\r | |
192 | );\r | |
193 | \r | |
194 | /**\r | |
195 | Entry point to the DXE Driver that produces the SMBus Host Controller Protocol.\r | |
196 | \r | |
197 | @param ImageHandle ImageHandle of the loaded driver.\r | |
198 | @param SystemTable Pointer to the EFI System Table.\r | |
199 | \r | |
200 | @retval EFI_SUCCESS The entry point of SMBus DXE driver is executed successfully.\r | |
201 | @retval !EFI_SUCESS Some error occurs in the entry point of SMBus DXE driver.\r | |
202 | \r | |
203 | **/\r | |
204 | EFI_STATUS\r | |
205 | EFIAPI\r | |
206 | InitializeQNCSmbus (\r | |
207 | IN EFI_HANDLE ImageHandle,\r | |
208 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
209 | );\r | |
210 | \r | |
211 | #endif\r |