]>
Commit | Line | Data |
---|---|---|
fb3df220 | 1 | /** @file\r |
50a64e5b | 2 | Provides library functions to access SMBUS devices. Libraries of this class\r |
3 | must be ported to a specific SMBUS controller.\r | |
fb3df220 | 4 | \r |
9df063a0 HT |
5 | Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r |
6 | This program and the accompanying materials\r | |
50a64e5b | 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 | |
fb3df220 | 10 | \r |
50a64e5b | 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 | |
fb3df220 | 13 | \r |
fb3df220 | 14 | **/\r |
15 | \r | |
16 | #ifndef __SMBUS_LIB__\r | |
17 | #define __SMBUS_LIB__\r | |
18 | \r | |
fb3df220 | 19 | /**\r |
20 | Macro that converts SMBUS slave address, SMBUS command, SMBUS data length,\r | |
21 | and PEC to a value that can be passed to the SMBUS Library functions.\r | |
22 | \r | |
23 | Computes an address that is compatible with the SMBUS Library functions.\r | |
24 | The unused upper bits of SlaveAddress, Command, and Length are stripped\r | |
25 | prior to the generation of the address.\r | |
26 | \r | |
27 | @param SlaveAddress SMBUS Slave Address. Range 0..127.\r | |
28 | @param Command SMBUS Command. Range 0..255.\r | |
29 | @param Length SMBUS Data Length. Range 0..32.\r | |
30 | @param Pec TRUE if Packet Error Checking is enabled. Otherwise FALSE.\r | |
31 | \r | |
32 | **/\r | |
33 | #define SMBUS_LIB_ADDRESS(SlaveAddress,Command,Length,Pec) \\r | |
e60d361d | 34 | ( ((Pec) ? BIT22: 0) | \\r |
fb3df220 | 35 | (((SlaveAddress) & 0x7f) << 1) | \\r |
36 | (((Command) & 0xff) << 8) | \\r | |
37 | (((Length) & 0x3f) << 16) \\r | |
38 | )\r | |
39 | \r | |
2d8debe7 | 40 | /**\r |
41 | Macro that returns the SMBUS Slave Address value from an SmBusAddress Parameter value.\r | |
42 | \r | |
43 | @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC \r | |
44 | **/\r | |
45 | #define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress) (((SmBusAddress) >> 1) & 0x7f)\r | |
46 | \r | |
47 | /**\r | |
48 | Macro that returns the SMBUS Command value from an SmBusAddress Parameter value.\r | |
49 | \r | |
50 | @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC\r | |
51 | **/\r | |
52 | #define SMBUS_LIB_COMMAND(SmBusAddress) (((SmBusAddress) >> 8) & 0xff)\r | |
53 | \r | |
54 | /**\r | |
55 | Macro that returns the SMBUS Data Length value from an SmBusAddress Parameter value.\r | |
56 | \r | |
57 | @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC \r | |
58 | **/\r | |
59 | #define SMBUS_LIB_LENGTH(SmBusAddress) (((SmBusAddress) >> 16) & 0x3f)\r | |
60 | \r | |
61 | /**\r | |
62 | Macro that returns the SMBUS PEC value from an SmBusAddress Parameter value.\r | |
63 | \r | |
64 | @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC \r | |
65 | **/\r | |
66 | #define SMBUS_LIB_PEC(SmBusAddress) ((BOOLEAN) (((SmBusAddress) & BIT22) != 0))\r | |
67 | \r | |
68 | /**\r | |
69 | Macro that returns the set of reserved bits from an SmBusAddress Parameter value.\r | |
70 | \r | |
71 | @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC \r | |
72 | **/\r | |
e38fc273 | 73 | #define SMBUS_LIB_RESERVED(SmBusAddress) ((SmBusAddress) & ~(BIT23 - 2))\r |
2d8debe7 | 74 | \r |
fb3df220 | 75 | /**\r |
76 | Executes an SMBUS quick read command.\r | |
77 | \r | |
78 | Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.\r | |
79 | Only the SMBUS slave address field of SmBusAddress is required.\r | |
80 | If Status is not NULL, then the status of the executed command is returned in Status.\r | |
81 | If PEC is set in SmBusAddress, then ASSERT().\r | |
82 | If Command in SmBusAddress is not zero, then ASSERT().\r | |
83 | If Length in SmBusAddress is not zero, then ASSERT().\r | |
84 | If any reserved bits of SmBusAddress are set, then ASSERT().\r | |
85 | \r | |
e38fc273 | 86 | @param SmBusAddress Address that encodes the SMBUS Slave Address,\r |
87 | SMBUS Command, SMBUS Data Length, and PEC.\r | |
88 | @param Status Return status for the executed command.\r | |
89 | This is an optional parameter and may be NULL.\r | |
90 | RETURN_SUCCESS The SMBUS command was executed.\r | |
91 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r | |
92 | RETURN_DEVICE_ERROR The request was not completed because a failure\r | |
93 | reflected in the Host Status Register bit. Device errors are a result\r | |
94 | of a transaction collision, illegal command field, unclaimed cycle\r | |
95 | (host initiated), or bus errors (collisions).\r | |
96 | RETURN_UNSUPPORTED The SMBus operation is not supported.\r | |
fb3df220 | 97 | \r |
98 | **/\r | |
99 | VOID\r | |
100 | EFIAPI\r | |
101 | SmBusQuickRead (\r | |
102 | IN UINTN SmBusAddress,\r | |
103 | OUT RETURN_STATUS *Status OPTIONAL\r | |
dca1cc59 | 104 | );\r |
fb3df220 | 105 | \r |
106 | /**\r | |
107 | Executes an SMBUS quick write command.\r | |
108 | \r | |
109 | Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.\r | |
110 | Only the SMBUS slave address field of SmBusAddress is required.\r | |
111 | If Status is not NULL, then the status of the executed command is returned in Status.\r | |
112 | If PEC is set in SmBusAddress, then ASSERT().\r | |
113 | If Command in SmBusAddress is not zero, then ASSERT().\r | |
114 | If Length in SmBusAddress is not zero, then ASSERT().\r | |
115 | If any reserved bits of SmBusAddress are set, then ASSERT().\r | |
116 | \r | |
e38fc273 | 117 | @param SmBusAddress Address that encodes the SMBUS Slave Address,\r |
118 | SMBUS Command, SMBUS Data Length, and PEC.\r | |
119 | @param Status Return status for the executed command.\r | |
120 | This is an optional parameter and may be NULL.\r | |
121 | RETURN_SUCCESS The SMBUS command was executed.\r | |
122 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r | |
123 | RETURN_DEVICE_ERROR The request was not completed because a failure\r | |
124 | reflected in the Host Status Register bit. Device errors are a result\r | |
125 | of a transaction collision, illegal command field, unclaimed cycle\r | |
126 | (host initiated), or bus errors (collisions).\r | |
127 | RETURN_UNSUPPORTED The SMBus operation is not supported.\r | |
fb3df220 | 128 | \r |
129 | **/\r | |
130 | VOID\r | |
131 | EFIAPI\r | |
132 | SmBusQuickWrite (\r | |
133 | IN UINTN SmBusAddress,\r | |
134 | OUT RETURN_STATUS *Status OPTIONAL\r | |
dca1cc59 | 135 | );\r |
fb3df220 | 136 | \r |
137 | /**\r | |
138 | Executes an SMBUS receive byte command.\r | |
139 | \r | |
140 | Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.\r | |
141 | Only the SMBUS slave address field of SmBusAddress is required.\r | |
142 | The byte received from the SMBUS is returned.\r | |
143 | If Status is not NULL, then the status of the executed command is returned in Status.\r | |
144 | If Command in SmBusAddress is not zero, then ASSERT().\r | |
145 | If Length in SmBusAddress is not zero, then ASSERT().\r | |
146 | If any reserved bits of SmBusAddress are set, then ASSERT().\r | |
147 | \r | |
e38fc273 | 148 | @param SmBusAddress Address that encodes the SMBUS Slave Address,\r |
149 | SMBUS Command, SMBUS Data Length, and PEC.\r | |
150 | @param Status Return status for the executed command.\r | |
151 | This is an optional parameter and may be NULL.\r | |
152 | RETURN_SUCCESS The SMBUS command was executed.\r | |
153 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r | |
154 | RETURN_DEVICE_ERROR The request was not completed because a failure\r | |
155 | reflected in the Host Status Register bit. Device errors are a result\r | |
156 | of a transaction collision, illegal command field, unclaimed cycle\r | |
157 | (host initiated), or bus errors (collisions).\r | |
158 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r | |
159 | RETURN_UNSUPPORTED The SMBus operation is not supported.\r | |
fb3df220 | 160 | \r |
161 | @return The byte received from the SMBUS.\r | |
162 | \r | |
163 | **/\r | |
164 | UINT8\r | |
165 | EFIAPI\r | |
166 | SmBusReceiveByte (\r | |
167 | IN UINTN SmBusAddress,\r | |
168 | OUT RETURN_STATUS *Status OPTIONAL\r | |
dca1cc59 | 169 | );\r |
fb3df220 | 170 | \r |
171 | /**\r | |
172 | Executes an SMBUS send byte command.\r | |
173 | \r | |
174 | Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.\r | |
175 | The byte specified by Value is sent.\r | |
176 | Only the SMBUS slave address field of SmBusAddress is required. Value is returned.\r | |
177 | If Status is not NULL, then the status of the executed command is returned in Status.\r | |
178 | If Command in SmBusAddress is not zero, then ASSERT().\r | |
179 | If Length in SmBusAddress is not zero, then ASSERT().\r | |
180 | If any reserved bits of SmBusAddress are set, then ASSERT().\r | |
181 | \r | |
e38fc273 | 182 | @param SmBusAddress Address that encodes the SMBUS Slave Address,\r |
183 | SMBUS Command, SMBUS Data Length, and PEC.\r | |
184 | @param Value The 8-bit value to send.\r | |
185 | @param Status Return status for the executed command.\r | |
186 | This is an optional parameter and may be NULL.\r | |
187 | RETURN_SUCCESS The SMBUS command was executed.\r | |
188 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r | |
189 | RETURN_DEVICE_ERROR The request was not completed because a failure\r | |
190 | reflected in the Host Status Register bit. Device errors are a result\r | |
191 | of a transaction collision, illegal command field, unclaimed cycle\r | |
192 | (host initiated), or bus errors (collisions).\r | |
193 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r | |
194 | RETURN_UNSUPPORTED The SMBus operation is not supported.\r | |
fb3df220 | 195 | \r |
196 | @return The parameter of Value.\r | |
197 | \r | |
198 | **/\r | |
199 | UINT8\r | |
200 | EFIAPI\r | |
201 | SmBusSendByte (\r | |
202 | IN UINTN SmBusAddress,\r | |
203 | IN UINT8 Value,\r | |
204 | OUT RETURN_STATUS *Status OPTIONAL\r | |
dca1cc59 | 205 | );\r |
fb3df220 | 206 | \r |
207 | /**\r | |
208 | Executes an SMBUS read data byte command.\r | |
209 | \r | |
210 | Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.\r | |
211 | Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r | |
212 | The 8-bit value read from the SMBUS is returned.\r | |
213 | If Status is not NULL, then the status of the executed command is returned in Status.\r | |
214 | If Length in SmBusAddress is not zero, then ASSERT().\r | |
215 | If any reserved bits of SmBusAddress are set, then ASSERT().\r | |
216 | \r | |
217 | @param SmBusAddress Address that encodes the SMBUS Slave Address,\r | |
218 | SMBUS Command, SMBUS Data Length, and PEC.\r | |
e38fc273 | 219 | @param Status Return status for the executed command.\r |
220 | This is an optional parameter and may be NULL.\r | |
221 | RETURN_SUCCESS The SMBUS command was executed.\r | |
222 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r | |
223 | RETURN_DEVICE_ERROR The request was not completed because a failure\r | |
224 | reflected in the Host Status Register bit. Device errors are a result\r | |
225 | of a transaction collision, illegal command field, unclaimed cycle\r | |
226 | (host initiated), or bus errors (collisions).\r | |
227 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r | |
228 | RETURN_UNSUPPORTED The SMBus operation is not supported.\r | |
fb3df220 | 229 | \r |
230 | @return The byte read from the SMBUS.\r | |
231 | \r | |
232 | **/\r | |
233 | UINT8\r | |
234 | EFIAPI\r | |
235 | SmBusReadDataByte (\r | |
236 | IN UINTN SmBusAddress,\r | |
237 | OUT RETURN_STATUS *Status OPTIONAL\r | |
dca1cc59 | 238 | );\r |
fb3df220 | 239 | \r |
240 | /**\r | |
241 | Executes an SMBUS write data byte command.\r | |
242 | \r | |
243 | Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.\r | |
244 | The 8-bit value specified by Value is written.\r | |
245 | Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r | |
246 | Value is returned.\r | |
247 | If Status is not NULL, then the status of the executed command is returned in Status.\r | |
248 | If Length in SmBusAddress is not zero, then ASSERT().\r | |
249 | If any reserved bits of SmBusAddress are set, then ASSERT().\r | |
250 | \r | |
e38fc273 | 251 | @param SmBusAddress Address that encodes the SMBUS Slave Address,\r |
252 | SMBUS Command, SMBUS Data Length, and PEC.\r | |
253 | @param Value The 8-bit value to write.\r | |
254 | @param Status Return status for the executed command.\r | |
255 | This is an optional parameter and may be NULL.\r | |
256 | RETURN_SUCCESS The SMBUS command was executed.\r | |
257 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r | |
258 | RETURN_DEVICE_ERROR The request was not completed because a failure\r | |
259 | reflected in the Host Status Register bit. Device errors are a result\r | |
260 | of a transaction collision, illegal command field, unclaimed cycle\r | |
261 | (host initiated), or bus errors (collisions).\r | |
262 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r | |
263 | RETURN_UNSUPPORTED The SMBus operation is not supported.\r | |
fb3df220 | 264 | \r |
265 | @return The parameter of Value.\r | |
266 | \r | |
267 | **/\r | |
268 | UINT8\r | |
269 | EFIAPI\r | |
270 | SmBusWriteDataByte (\r | |
271 | IN UINTN SmBusAddress,\r | |
272 | IN UINT8 Value,\r | |
273 | OUT RETURN_STATUS *Status OPTIONAL\r | |
dca1cc59 | 274 | );\r |
fb3df220 | 275 | \r |
276 | /**\r | |
277 | Executes an SMBUS read data word command.\r | |
278 | \r | |
279 | Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.\r | |
280 | Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r | |
281 | The 16-bit value read from the SMBUS is returned.\r | |
282 | If Status is not NULL, then the status of the executed command is returned in Status.\r | |
283 | If Length in SmBusAddress is not zero, then ASSERT().\r | |
284 | If any reserved bits of SmBusAddress are set, then ASSERT().\r | |
285 | \r | |
e38fc273 | 286 | @param SmBusAddress Address that encodes the SMBUS Slave Address,\r |
287 | SMBUS Command, SMBUS Data Length, and PEC.\r | |
288 | @param Status Return status for the executed command.\r | |
289 | This is an optional parameter and may be NULL.\r | |
290 | RETURN_SUCCESS The SMBUS command was executed.\r | |
291 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r | |
292 | RETURN_DEVICE_ERROR The request was not completed because a failure\r | |
293 | reflected in the Host Status Register bit. Device errors are a result\r | |
294 | of a transaction collision, illegal command field, unclaimed cycle\r | |
295 | (host initiated), or bus errors (collisions).\r | |
296 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r | |
297 | RETURN_UNSUPPORTED The SMBus operation is not supported.\r | |
fb3df220 | 298 | \r |
299 | @return The byte read from the SMBUS.\r | |
300 | \r | |
301 | **/\r | |
302 | UINT16\r | |
303 | EFIAPI\r | |
304 | SmBusReadDataWord (\r | |
305 | IN UINTN SmBusAddress,\r | |
306 | OUT RETURN_STATUS *Status OPTIONAL\r | |
dca1cc59 | 307 | );\r |
fb3df220 | 308 | \r |
309 | /**\r | |
310 | Executes an SMBUS write data word command.\r | |
311 | \r | |
312 | Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.\r | |
313 | The 16-bit value specified by Value is written.\r | |
314 | Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r | |
315 | Value is returned.\r | |
316 | If Status is not NULL, then the status of the executed command is returned in Status.\r | |
317 | If Length in SmBusAddress is not zero, then ASSERT().\r | |
318 | If any reserved bits of SmBusAddress are set, then ASSERT().\r | |
319 | \r | |
e38fc273 | 320 | @param SmBusAddress Address that encodes the SMBUS Slave Address,\r |
321 | SMBUS Command, SMBUS Data Length, and PEC.\r | |
322 | @param Value The 16-bit value to write.\r | |
323 | @param Status Return status for the executed command.\r | |
324 | This is an optional parameter and may be NULL.\r | |
325 | RETURN_SUCCESS The SMBUS command was executed.\r | |
326 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r | |
327 | RETURN_DEVICE_ERROR The request was not completed because a failure\r | |
328 | reflected in the Host Status Register bit. Device errors are a result\r | |
329 | of a transaction collision, illegal command field, unclaimed cycle\r | |
330 | (host initiated), or bus errors (collisions).\r | |
331 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r | |
332 | RETURN_UNSUPPORTED The SMBus operation is not supported.\r | |
fb3df220 | 333 | \r |
334 | @return The parameter of Value.\r | |
335 | \r | |
336 | **/\r | |
337 | UINT16\r | |
338 | EFIAPI\r | |
339 | SmBusWriteDataWord (\r | |
340 | IN UINTN SmBusAddress,\r | |
341 | IN UINT16 Value,\r | |
342 | OUT RETURN_STATUS *Status OPTIONAL\r | |
dca1cc59 | 343 | );\r |
fb3df220 | 344 | \r |
345 | /**\r | |
346 | Executes an SMBUS process call command.\r | |
347 | \r | |
348 | Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.\r | |
349 | The 16-bit value specified by Value is written.\r | |
350 | Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r | |
351 | The 16-bit value returned by the process call command is returned.\r | |
352 | If Status is not NULL, then the status of the executed command is returned in Status.\r | |
353 | If Length in SmBusAddress is not zero, then ASSERT().\r | |
354 | If any reserved bits of SmBusAddress are set, then ASSERT().\r | |
355 | \r | |
e38fc273 | 356 | @param SmBusAddress Address that encodes the SMBUS Slave Address,\r |
357 | SMBUS Command, SMBUS Data Length, and PEC.\r | |
358 | @param Value The 16-bit value to write.\r | |
359 | @param Status Return status for the executed command.\r | |
360 | This is an optional parameter and may be NULL.\r | |
361 | RETURN_SUCCESS The SMBUS command was executed.\r | |
362 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r | |
363 | RETURN_DEVICE_ERROR The request was not completed because a failure\r | |
364 | reflected in the Host Status Register bit. Device errors are a result\r | |
365 | of a transaction collision, illegal command field, unclaimed cycle\r | |
366 | (host initiated), or bus errors (collisions).\r | |
367 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r | |
368 | RETURN_UNSUPPORTED The SMBus operation is not supported.\r | |
fb3df220 | 369 | \r |
370 | @return The 16-bit value returned by the process call command.\r | |
371 | \r | |
372 | **/\r | |
373 | UINT16\r | |
374 | EFIAPI\r | |
375 | SmBusProcessCall (\r | |
376 | IN UINTN SmBusAddress,\r | |
377 | IN UINT16 Value,\r | |
378 | OUT RETURN_STATUS *Status OPTIONAL\r | |
dca1cc59 | 379 | );\r |
fb3df220 | 380 | \r |
381 | /**\r | |
382 | Executes an SMBUS read block command.\r | |
383 | \r | |
384 | Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.\r | |
385 | Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r | |
386 | Bytes are read from the SMBUS and stored in Buffer.\r | |
387 | The number of bytes read is returned, and will never return a value larger than 32-bytes.\r | |
388 | If Status is not NULL, then the status of the executed command is returned in Status.\r | |
389 | It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.\r | |
390 | SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r | |
391 | If Length in SmBusAddress is not zero, then ASSERT().\r | |
392 | If Buffer is NULL, then ASSERT().\r | |
393 | If any reserved bits of SmBusAddress are set, then ASSERT().\r | |
394 | \r | |
e38fc273 | 395 | @param SmBusAddress Address that encodes the SMBUS Slave Address,\r |
396 | SMBUS Command, SMBUS Data Length, and PEC.\r | |
397 | @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.\r | |
398 | @param Status Return status for the executed command.\r | |
399 | This is an optional parameter and may be NULL.\r | |
400 | RETURN_SUCCESS The SMBUS command was executed.\r | |
401 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r | |
402 | RETURN_DEVICE_ERROR The request was not completed because a failure\r | |
403 | reflected in the Host Status Register bit. Device errors are a result\r | |
404 | of a transaction collision, illegal command field, unclaimed cycle\r | |
405 | (host initiated), or bus errors (collisions).\r | |
406 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r | |
407 | RETURN_UNSUPPORTED The SMBus operation is not supported.\r | |
fb3df220 | 408 | \r |
409 | @return The number of bytes read.\r | |
410 | \r | |
411 | **/\r | |
412 | UINTN\r | |
413 | EFIAPI\r | |
414 | SmBusReadBlock (\r | |
415 | IN UINTN SmBusAddress,\r | |
416 | OUT VOID *Buffer,\r | |
417 | OUT RETURN_STATUS *Status OPTIONAL\r | |
dca1cc59 | 418 | );\r |
fb3df220 | 419 | \r |
420 | /**\r | |
421 | Executes an SMBUS write block command.\r | |
422 | \r | |
423 | Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.\r | |
424 | The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r | |
425 | Bytes are written to the SMBUS from Buffer.\r | |
426 | The number of bytes written is returned, and will never return a value larger than 32-bytes.\r | |
427 | If Status is not NULL, then the status of the executed command is returned in Status. \r | |
428 | If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r | |
429 | If Buffer is NULL, then ASSERT().\r | |
430 | If any reserved bits of SmBusAddress are set, then ASSERT().\r | |
431 | \r | |
e38fc273 | 432 | @param SmBusAddress Address that encodes the SMBUS Slave Address,\r |
415f6ade | 433 | SMBUS Command, SMBUS Data Length, and PEC.\r |
e38fc273 | 434 | @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.\r |
435 | @param Status Return status for the executed command.\r | |
436 | This is an optional parameter and may be NULL.\r | |
437 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r | |
438 | RETURN_DEVICE_ERROR The request was not completed because a failure\r | |
439 | reflected in the Host Status Register bit. Device errors are a result\r | |
440 | of a transaction collision, illegal command field, unclaimed cycle\r | |
441 | (host initiated), or bus errors (collisions).\r | |
442 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r | |
443 | RETURN_UNSUPPORTED The SMBus operation is not supported.\r | |
fb3df220 | 444 | \r |
445 | @return The number of bytes written.\r | |
446 | \r | |
447 | **/\r | |
448 | UINTN\r | |
449 | EFIAPI\r | |
450 | SmBusWriteBlock (\r | |
451 | IN UINTN SmBusAddress,\r | |
452 | OUT VOID *Buffer,\r | |
453 | OUT RETURN_STATUS *Status OPTIONAL\r | |
dca1cc59 | 454 | );\r |
fb3df220 | 455 | \r |
456 | /**\r | |
457 | Executes an SMBUS block process call command.\r | |
458 | \r | |
459 | Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.\r | |
460 | The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r | |
461 | Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer.\r | |
462 | If Status is not NULL, then the status of the executed command is returned in Status.\r | |
463 | It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.\r | |
464 | SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r | |
465 | If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r | |
466 | If WriteBuffer is NULL, then ASSERT().\r | |
467 | If ReadBuffer is NULL, then ASSERT().\r | |
468 | If any reserved bits of SmBusAddress are set, then ASSERT().\r | |
469 | \r | |
e38fc273 | 470 | @param SmBusAddress Address that encodes the SMBUS Slave Address,\r |
471 | SMBUS Command, SMBUS Data Length, and PEC.\r | |
472 | @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS.\r | |
473 | @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS.\r | |
474 | @param Status Return status for the executed command.\r | |
475 | This is an optional parameter and may be NULL.\r | |
476 | RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r | |
477 | RETURN_DEVICE_ERROR The request was not completed because a failure\r | |
478 | reflected in the Host Status Register bit. Device errors are a result\r | |
479 | of a transaction collision, illegal command field, unclaimed cycle\r | |
480 | (host initiated), or bus errors (collisions).\r | |
481 | RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)\r | |
482 | RETURN_UNSUPPORTED The SMBus operation is not supported.\r | |
fb3df220 | 483 | \r |
484 | @return The number of bytes written.\r | |
485 | \r | |
486 | **/\r | |
487 | UINTN\r | |
488 | EFIAPI\r | |
489 | SmBusBlockProcessCall (\r | |
490 | IN UINTN SmBusAddress,\r | |
491 | IN VOID *WriteBuffer,\r | |
492 | OUT VOID *ReadBuffer,\r | |
493 | OUT RETURN_STATUS *Status OPTIONAL\r | |
dca1cc59 | 494 | );\r |
fb3df220 | 495 | \r |
496 | \r | |
497 | #endif\r |