]>
git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.c
2 Null implementation of SmBusLib class library.
4 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Library/SmbusLib.h>
11 #include <Library/DebugLib.h>
14 Executes an SMBUS quick read command.
16 Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.
17 Only the SMBUS slave address field of SmBusAddress is required.
18 If Status is not NULL, then the status of the executed command is returned in Status.
19 If PEC is set in SmBusAddress, then ASSERT().
20 If Command in SmBusAddress is not zero, then ASSERT().
21 If Length in SmBusAddress is not zero, then ASSERT().
22 If any reserved bits of SmBusAddress are set, then ASSERT().
24 @param SmBusAddress Address that encodes the SMBUS Slave Address,
25 SMBUS Command, SMBUS Data Length, and PEC.
26 @param Status Return status for the executed command.
27 This is an optional parameter and may be NULL.
28 RETURN_SUCCESS The SMBUS command was executed.
29 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
30 RETURN_DEVICE_ERROR The request was not completed because a failure
31 reflected in the Host Status Register bit. Device errors are a result
32 of a transaction collision, illegal command field, unclaimed cycle
33 (host initiated), or bus errors (collisions).
34 RETURN_UNSUPPORTED The SMBus operation is not supported.
40 IN UINTN SmBusAddress
,
41 OUT RETURN_STATUS
*Status OPTIONAL
44 ASSERT (!SMBUS_LIB_PEC (SmBusAddress
));
45 ASSERT (SMBUS_LIB_COMMAND (SmBusAddress
) == 0);
46 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
47 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
49 *Status
= RETURN_UNSUPPORTED
;
54 Executes an SMBUS quick write command.
56 Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.
57 Only the SMBUS slave address field of SmBusAddress is required.
58 If Status is not NULL, then the status of the executed command is returned in Status.
59 If PEC is set in SmBusAddress, then ASSERT().
60 If Command in SmBusAddress is not zero, then ASSERT().
61 If Length in SmBusAddress is not zero, then ASSERT().
62 If any reserved bits of SmBusAddress are set, then ASSERT().
64 @param SmBusAddress Address that encodes the SMBUS Slave Address,
65 SMBUS Command, SMBUS Data Length, and PEC.
66 @param Status Return status for the executed command.
67 This is an optional parameter and may be NULL.
68 RETURN_SUCCESS The SMBUS command was executed.
69 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
70 RETURN_DEVICE_ERROR The request was not completed because a failure
71 reflected in the Host Status Register bit. Device errors are a result
72 of a transaction collision, illegal command field, unclaimed cycle
73 (host initiated), or bus errors (collisions).
74 RETURN_UNSUPPORTED The SMBus operation is not supported.
80 IN UINTN SmBusAddress
,
81 OUT RETURN_STATUS
*Status OPTIONAL
84 ASSERT (!SMBUS_LIB_PEC (SmBusAddress
));
85 ASSERT (SMBUS_LIB_COMMAND (SmBusAddress
) == 0);
86 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
87 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
89 *Status
= RETURN_UNSUPPORTED
;
94 Executes an SMBUS receive byte command.
96 Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.
97 Only the SMBUS slave address field of SmBusAddress is required.
98 The byte received from the SMBUS is returned.
99 If Status is not NULL, then the status of the executed command is returned in Status.
100 If Command in SmBusAddress is not zero, then ASSERT().
101 If Length in SmBusAddress is not zero, then ASSERT().
102 If any reserved bits of SmBusAddress are set, then ASSERT().
104 @param SmBusAddress Address that encodes the SMBUS Slave Address,
105 SMBUS Command, SMBUS Data Length, and PEC.
106 @param Status Return status for the executed command.
107 This is an optional parameter and may be NULL.
108 RETURN_SUCCESS The SMBUS command was executed.
109 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
110 RETURN_DEVICE_ERROR The request was not completed because a failure
111 reflected in the Host Status Register bit. Device errors are a result
112 of a transaction collision, illegal command field, unclaimed cycle
113 (host initiated), or bus errors (collisions).
114 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
115 RETURN_UNSUPPORTED The SMBus operation is not supported.
117 @return The byte received from the SMBUS.
123 IN UINTN SmBusAddress
,
124 OUT RETURN_STATUS
*Status OPTIONAL
127 ASSERT (SMBUS_LIB_COMMAND (SmBusAddress
) == 0);
128 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
129 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
130 if (Status
!= NULL
) {
131 *Status
= RETURN_UNSUPPORTED
;
138 Executes an SMBUS send byte command.
140 Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.
141 The byte specified by Value is sent.
142 Only the SMBUS slave address field of SmBusAddress is required. Value is returned.
143 If Status is not NULL, then the status of the executed command is returned in Status.
144 If Command in SmBusAddress is not zero, then ASSERT().
145 If Length in SmBusAddress is not zero, then ASSERT().
146 If any reserved bits of SmBusAddress are set, then ASSERT().
148 @param SmBusAddress Address that encodes the SMBUS Slave Address,
149 SMBUS Command, SMBUS Data Length, and PEC.
150 @param Value The 8-bit value to send.
151 @param Status Return status for the executed command.
152 This is an optional parameter and may be NULL.
153 RETURN_SUCCESS The SMBUS command was executed.
154 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
155 RETURN_DEVICE_ERROR The request was not completed because a failure
156 reflected in the Host Status Register bit. Device errors are a result
157 of a transaction collision, illegal command field, unclaimed cycle
158 (host initiated), or bus errors (collisions).
159 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
160 RETURN_UNSUPPORTED The SMBus operation is not supported.
162 @return The parameter of Value.
168 IN UINTN SmBusAddress
,
170 OUT RETURN_STATUS
*Status OPTIONAL
173 ASSERT (SMBUS_LIB_COMMAND (SmBusAddress
) == 0);
174 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
175 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
176 if (Status
!= NULL
) {
177 *Status
= RETURN_UNSUPPORTED
;
184 Executes an SMBUS read data byte command.
186 Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.
187 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
188 The 8-bit value read from the SMBUS is returned.
189 If Status is not NULL, then the status of the executed command is returned in Status.
190 If Length in SmBusAddress is not zero, then ASSERT().
191 If any reserved bits of SmBusAddress are set, then ASSERT().
193 @param SmBusAddress Address that encodes the SMBUS Slave Address,
194 SMBUS Command, SMBUS Data Length, and PEC.
195 @param Status Return status for the executed command.
196 This is an optional parameter and may be NULL.
197 RETURN_SUCCESS The SMBUS command was executed.
198 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
199 RETURN_DEVICE_ERROR The request was not completed because a failure
200 reflected in the Host Status Register bit. Device errors are a result
201 of a transaction collision, illegal command field, unclaimed cycle
202 (host initiated), or bus errors (collisions).
203 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
204 RETURN_UNSUPPORTED The SMBus operation is not supported.
206 @return The byte read from the SMBUS.
212 IN UINTN SmBusAddress
,
213 OUT RETURN_STATUS
*Status OPTIONAL
216 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
217 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
218 if (Status
!= NULL
) {
219 *Status
= RETURN_UNSUPPORTED
;
226 Executes an SMBUS write data byte command.
228 Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.
229 The 8-bit value specified by Value is written.
230 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
232 If Status is not NULL, then the status of the executed command is returned in Status.
233 If Length in SmBusAddress is not zero, then ASSERT().
234 If any reserved bits of SmBusAddress are set, then ASSERT().
236 @param SmBusAddress Address that encodes the SMBUS Slave Address,
237 SMBUS Command, SMBUS Data Length, and PEC.
238 @param Value The 8-bit value to write.
239 @param Status Return status for the executed command.
240 This is an optional parameter and may be NULL.
241 RETURN_SUCCESS The SMBUS command was executed.
242 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
243 RETURN_DEVICE_ERROR The request was not completed because a failure
244 reflected in the Host Status Register bit. Device errors are a result
245 of a transaction collision, illegal command field, unclaimed cycle
246 (host initiated), or bus errors (collisions).
247 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
248 RETURN_UNSUPPORTED The SMBus operation is not supported.
250 @return The parameter of Value.
256 IN UINTN SmBusAddress
,
258 OUT RETURN_STATUS
*Status OPTIONAL
261 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
262 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
263 if (Status
!= NULL
) {
264 *Status
= RETURN_UNSUPPORTED
;
271 Executes an SMBUS read data word command.
273 Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.
274 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
275 The 16-bit value read from the SMBUS is returned.
276 If Status is not NULL, then the status of the executed command is returned in Status.
277 If Length in SmBusAddress is not zero, then ASSERT().
278 If any reserved bits of SmBusAddress are set, then ASSERT().
280 @param SmBusAddress Address that encodes the SMBUS Slave Address,
281 SMBUS Command, SMBUS Data Length, and PEC.
282 @param Status Return status for the executed command.
283 This is an optional parameter and may be NULL.
284 RETURN_SUCCESS The SMBUS command was executed.
285 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
286 RETURN_DEVICE_ERROR The request was not completed because a failure
287 reflected in the Host Status Register bit. Device errors are a result
288 of a transaction collision, illegal command field, unclaimed cycle
289 (host initiated), or bus errors (collisions).
290 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
291 RETURN_UNSUPPORTED The SMBus operation is not supported.
293 @return The byte read from the SMBUS.
299 IN UINTN SmBusAddress
,
300 OUT RETURN_STATUS
*Status OPTIONAL
303 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
304 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
305 if (Status
!= NULL
) {
306 *Status
= RETURN_UNSUPPORTED
;
313 Executes an SMBUS write data word command.
315 Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.
316 The 16-bit value specified by Value is written.
317 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
319 If Status is not NULL, then the status of the executed command is returned in Status.
320 If Length in SmBusAddress is not zero, then ASSERT().
321 If any reserved bits of SmBusAddress are set, then ASSERT().
323 @param SmBusAddress Address that encodes the SMBUS Slave Address,
324 SMBUS Command, SMBUS Data Length, and PEC.
325 @param Value The 16-bit value to write.
326 @param Status Return status for the executed command.
327 This is an optional parameter and may be NULL.
328 RETURN_SUCCESS The SMBUS command was executed.
329 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
330 RETURN_DEVICE_ERROR The request was not completed because a failure
331 reflected in the Host Status Register bit. Device errors are a result
332 of a transaction collision, illegal command field, unclaimed cycle
333 (host initiated), or bus errors (collisions).
334 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
335 RETURN_UNSUPPORTED The SMBus operation is not supported.
337 @return The parameter of Value.
343 IN UINTN SmBusAddress
,
345 OUT RETURN_STATUS
*Status OPTIONAL
348 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
349 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
350 if (Status
!= NULL
) {
351 *Status
= RETURN_UNSUPPORTED
;
358 Executes an SMBUS process call command.
360 Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.
361 The 16-bit value specified by Value is written.
362 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
363 The 16-bit value returned by the process call command is returned.
364 If Status is not NULL, then the status of the executed command is returned in Status.
365 If Length in SmBusAddress is not zero, then ASSERT().
366 If any reserved bits of SmBusAddress are set, then ASSERT().
368 @param SmBusAddress Address that encodes the SMBUS Slave Address,
369 SMBUS Command, SMBUS Data Length, and PEC.
370 @param Value The 16-bit value to write.
371 @param Status Return status for the executed command.
372 This is an optional parameter and may be NULL.
373 RETURN_SUCCESS The SMBUS command was executed.
374 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
375 RETURN_DEVICE_ERROR The request was not completed because a failure
376 reflected in the Host Status Register bit. Device errors are a result
377 of a transaction collision, illegal command field, unclaimed cycle
378 (host initiated), or bus errors (collisions).
379 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
380 RETURN_UNSUPPORTED The SMBus operation is not supported.
382 @return The 16-bit value returned by the process call command.
388 IN UINTN SmBusAddress
,
390 OUT RETURN_STATUS
*Status OPTIONAL
393 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
394 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
395 if (Status
!= NULL
) {
396 *Status
= RETURN_UNSUPPORTED
;
403 Executes an SMBUS read block command.
405 Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.
406 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
407 Bytes are read from the SMBUS and stored in Buffer.
408 The number of bytes read is returned, and will never return a value larger than 32-bytes.
409 If Status is not NULL, then the status of the executed command is returned in Status.
410 It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
411 SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
412 If Length in SmBusAddress is not zero, then ASSERT().
413 If Buffer is NULL, then ASSERT().
414 If any reserved bits of SmBusAddress are set, then ASSERT().
416 @param SmBusAddress Address that encodes the SMBUS Slave Address,
417 SMBUS Command, SMBUS Data Length, and PEC.
418 @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
419 @param Status Return status for the executed command.
420 This is an optional parameter and may be NULL.
421 RETURN_SUCCESS The SMBUS command was executed.
422 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
423 RETURN_DEVICE_ERROR The request was not completed because a failure
424 reflected in the Host Status Register bit. Device errors are a result
425 of a transaction collision, illegal command field, unclaimed cycle
426 (host initiated), or bus errors (collisions).
427 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
428 RETURN_UNSUPPORTED The SMBus operation is not supported.
430 @return The number of bytes read.
436 IN UINTN SmBusAddress
,
438 OUT RETURN_STATUS
*Status OPTIONAL
441 ASSERT (Buffer
!= NULL
);
442 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
443 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
444 if (Status
!= NULL
) {
445 *Status
= RETURN_UNSUPPORTED
;
452 Executes an SMBUS write block command.
454 Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.
455 The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
456 Bytes are written to the SMBUS from Buffer.
457 The number of bytes written is returned, and will never return a value larger than 32-bytes.
458 If Status is not NULL, then the status of the executed command is returned in Status.
459 If Length in SmBusAddress is zero or greater than 32, then ASSERT().
460 If Buffer is NULL, then ASSERT().
461 If any reserved bits of SmBusAddress are set, then ASSERT().
463 @param SmBusAddress Address that encodes the SMBUS Slave Address,
464 SMBUS Command, SMBUS Data Length, and PEC.
465 @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
466 @param Status Return status for the executed command.
467 This is an optional parameter and may be NULL.
468 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
469 RETURN_DEVICE_ERROR The request was not completed because a failure
470 reflected in the Host Status Register bit. Device errors are a result
471 of a transaction collision, illegal command field, unclaimed cycle
472 (host initiated), or bus errors (collisions).
473 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
474 RETURN_UNSUPPORTED The SMBus operation is not supported.
476 @return The number of bytes written.
482 IN UINTN SmBusAddress
,
484 OUT RETURN_STATUS
*Status OPTIONAL
487 ASSERT (Buffer
!= NULL
);
488 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) >= 1);
489 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) <= 32);
490 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
491 if (Status
!= NULL
) {
492 *Status
= RETURN_UNSUPPORTED
;
499 Executes an SMBUS block process call command.
501 Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.
502 The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
503 Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer.
504 If Status is not NULL, then the status of the executed command is returned in Status.
505 It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.
506 SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
507 If Length in SmBusAddress is zero or greater than 32, then ASSERT().
508 If WriteBuffer is NULL, then ASSERT().
509 If ReadBuffer is NULL, then ASSERT().
510 If any reserved bits of SmBusAddress are set, then ASSERT().
512 @param SmBusAddress Address that encodes the SMBUS Slave Address,
513 SMBUS Command, SMBUS Data Length, and PEC.
514 @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS.
515 @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS.
516 @param Status Return status for the executed command.
517 This is an optional parameter and may be NULL.
518 RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
519 RETURN_DEVICE_ERROR The request was not completed because a failure
520 reflected in the Host Status Register bit. Device errors are a result
521 of a transaction collision, illegal command field, unclaimed cycle
522 (host initiated), or bus errors (collisions).
523 RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect)
524 RETURN_UNSUPPORTED The SMBus operation is not supported.
526 @return The number of bytes written.
531 SmBusBlockProcessCall (
532 IN UINTN SmBusAddress
,
533 IN VOID
*WriteBuffer
,
534 OUT VOID
*ReadBuffer
,
535 OUT RETURN_STATUS
*Status OPTIONAL
538 ASSERT (WriteBuffer
!= NULL
);
539 ASSERT (ReadBuffer
!= NULL
);
540 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) >= 1);
541 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) <= 32);
542 ASSERT (SMBUS_LIB_RESERVED (SmBusAddress
) == 0);
543 if (Status
!= NULL
) {
544 *Status
= RETURN_UNSUPPORTED
;