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