2 Base SMBUS library implementation built upon I/O library.
4 Copyright (c) 2006, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 Module Name: SmbusLib.c
17 #include "SmbusLibRegisters.h"
19 #define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress) (((SmBusAddress) >> 1) & 0x7f)
20 #define SMBUS_LIB_COMMAND(SmBusAddress) (((SmBusAddress) >> 8) & 0xff)
21 #define SMBUS_LIB_LENGTH(SmBusAddress) (((SmBusAddress) >> 16) & 0x1f)
22 #define SMBUS_LIB_PEC(SmBusAddress) ((BOOLEAN) (((SmBusAddress) & SMBUS_LIB_PEC_BIT) != 0))
23 #define SMBUS_LIB_RESEARVED(SmBusAddress) ((SmBusAddress) & ~(((1 << 21) - 2) | SMBUS_LIB_PEC_BIT))
28 #define ICH_SMBUS_BASE_ADDRESS 0xEFA0
31 Reads an 8-bit SMBUS register on ICH.
33 This internal function reads an SMBUS register specified by Offset.
35 @param Offset The offset of SMBUS register.
37 @return The value read.
41 InternalSmBusIoRead8 (
45 return IoRead8 (ICH_SMBUS_BASE_ADDRESS
+ Offset
);
49 Writes an 8-bit SMBUS register on ICH.
51 This internal function writes an SMBUS register specified by Offset.
53 @param Offset The offset of SMBUS register.
54 @param Value The value to write to SMBUS register.
56 @return The value written the SMBUS register.
60 InternalSmBusIoWrite8 (
65 return IoWrite8 (ICH_SMBUS_BASE_ADDRESS
+ Offset
, Value
);
69 Acquires the ownership of SMBUS.
71 This internal function reads the host state register.
72 If the SMBUS is not available, RETURN_TIMEOUT is returned;
73 Otherwise, it performs some basic initializations and returns
76 @retval RETURN_SUCCESS The SMBUS command was executed successfully.
77 @retval RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.
81 InternalSmBusAcquire (
87 HostStatus
= InternalSmBusIoRead8 (SMBUS_R_HST_STS
);
88 if ((HostStatus
& SMBUS_B_INUSE_STS
) != 0) {
89 return RETURN_TIMEOUT
;
90 } else if ((HostStatus
& SMBUS_B_HOST_BUSY
) != 0) {
92 // Clear Status Register and exit
94 InternalSmBusIoWrite8 (SMBUS_R_HST_STS
, SMBUS_B_HSTS_ALL
);
95 return RETURN_TIMEOUT
;
98 // Clear byte pointer of 32-byte buffer.
100 InternalSmBusIoRead8 (SMBUS_R_HST_CTL
);
102 // Clear BYTE_DONE status
104 InternalSmBusIoWrite8 (SMBUS_R_HST_STS
, SMBUS_B_BYTE_DONE_STS
);
106 return RETURN_SUCCESS
;
110 Waits until the completion of SMBUS transaction.
112 This internal function waits until the transaction of SMBUS is over
113 by polling the INTR bit of Host status register.
114 If the SMBUS is not available, RETURN_TIMEOUT is returned;
115 Otherwise, it performs some basic initializations and returns
118 @retval RETURN_SUCCESS The SMBUS command was executed successfully.
119 @retval RETURN_CRC_ERROR The checksum is not correct (PEC is incorrect).
120 @retval RETURN_DEVICE_ERROR The request was not completed because a failure reflected
121 in the Host Status Register bit. Device errors are
122 a result of a transaction collision, illegal command field,
123 unclaimed cycle (host initiated), or bus errors (collisions).
132 UINT8 AuxiliaryStatus
;
138 // Poll INTR bit of host status register.
140 HostStatus
= InternalSmBusIoRead8 (SMBUS_R_HST_STS
);
141 } while ((HostStatus
& (SMBUS_B_INTR
| SMBUS_B_ERROR
| SMBUS_B_BYTE_DONE_STS
)) == 0);
143 if ((HostStatus
& SMBUS_B_ERROR
) == 0) {
144 return RETURN_SUCCESS
;
147 // Clear error bits of host status register
149 InternalSmBusIoWrite8 (SMBUS_R_HST_STS
, SMBUS_B_ERROR
);
151 // Read auxiliary status register to judge CRC error.
153 AuxiliaryStatus
= InternalSmBusIoRead8 (SMBUS_R_AUX_STS
);
154 if ((AuxiliaryStatus
& SMBUS_B_CRCE
) != 0) {
155 return RETURN_CRC_ERROR
;
158 return RETURN_DEVICE_ERROR
;
162 Executes an SMBUS quick read/write command.
164 This internal function executes an SMBUS quick read/write command
165 on the SMBUS device specified by SmBusAddress.
166 Only the SMBUS slave address field of SmBusAddress is required.
167 If Status is not NULL, then the status of the executed command is returned in Status.
169 @param SmBusAddress Address that encodes the SMBUS Slave Address,
170 SMBUS Command, SMBUS Data Length, and PEC.
171 @param Status Return status for the executed command.
172 This is an optional parameter and may be NULL.
178 IN UINTN SmBusAddress
,
179 OUT RETURN_STATUS
*Status OPTIONAL
182 RETURN_STATUS ReturnStatus
;
184 ReturnStatus
= InternalSmBusAcquire ();
185 if (RETURN_ERROR (ReturnStatus
)) {
190 // Set Command register
192 InternalSmBusIoWrite8 (SMBUS_R_HST_CMD
, 0);
194 // Set Auxiliary Control register
196 InternalSmBusIoWrite8 (SMBUS_R_AUX_CTL
, 0);
198 // Set SMBus slave address for the device to send/receive from
200 InternalSmBusIoWrite8 (SMBUS_R_XMIT_SLVA
, (UINT8
) SmBusAddress
);
202 // Set Control Register (Initiate Operation, Interrupt disabled)
204 InternalSmBusIoWrite8 (SMBUS_R_HST_CTL
, SMBUS_V_SMB_CMD_QUICK
+ SMBUS_B_START
);
209 ReturnStatus
= InternalSmBusWait ();
212 // Clear status register and exit
214 InternalSmBusIoWrite8 (SMBUS_R_HST_STS
, SMBUS_B_HSTS_ALL
);;
217 if (Status
!= NULL
) {
218 *Status
= ReturnStatus
;
223 Executes an SMBUS quick read command.
225 Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.
226 Only the SMBUS slave address field of SmBusAddress is required.
227 If Status is not NULL, then the status of the executed command is returned in Status.
228 If PEC is set in SmBusAddress, then ASSERT().
229 If Command in SmBusAddress is not zero, then ASSERT().
230 If Length in SmBusAddress is not zero, then ASSERT().
231 If any reserved bits of SmBusAddress are set, then ASSERT().
233 @param SmBusAddress Address that encodes the SMBUS Slave Address,
234 SMBUS Command, SMBUS Data Length, and PEC.
235 @param Status Return status for the executed command.
236 This is an optional parameter and may be NULL.
242 IN UINTN SmBusAddress
,
243 OUT RETURN_STATUS
*Status OPTIONAL
246 ASSERT (!SMBUS_LIB_PEC (SmBusAddress
));
247 ASSERT (SMBUS_LIB_COMMAND (SmBusAddress
) == 0);
248 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
249 ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress
) == 0);
251 InternalSmBusQuick (SmBusAddress
| SMBUS_B_READ
, Status
);
255 Executes an SMBUS quick write command.
257 Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.
258 Only the SMBUS slave address field of SmBusAddress is required.
259 If Status is not NULL, then the status of the executed command is returned in Status.
260 If PEC is set in SmBusAddress, then ASSERT().
261 If Command in SmBusAddress is not zero, then ASSERT().
262 If Length in SmBusAddress is not zero, then ASSERT().
263 If any reserved bits of SmBusAddress are set, then ASSERT().
265 @param SmBusAddress Address that encodes the SMBUS Slave Address,
266 SMBUS Command, SMBUS Data Length, and PEC.
267 @param Status Return status for the executed command.
268 This is an optional parameter and may be NULL.
274 IN UINTN SmBusAddress
,
275 OUT RETURN_STATUS
*Status OPTIONAL
278 ASSERT (!SMBUS_LIB_PEC (SmBusAddress
));
279 ASSERT (SMBUS_LIB_COMMAND (SmBusAddress
) == 0);
280 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
281 ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress
) == 0);
283 InternalSmBusQuick (SmBusAddress
| SMBUS_B_WRITE
, Status
);
287 Executes an SMBUS byte or word command.
289 This internal function executes an .
290 Only the SMBUS slave address field of SmBusAddress is required.
291 If Status is not NULL, then the status of the executed command is returned in Status.
293 @param HostControl The value of Host Control Register to set.
294 @param SmBusAddress Address that encodes the SMBUS Slave Address,
295 SMBUS Command, SMBUS Data Length, and PEC.
296 @param Value The byte/word write to the SMBUS.
297 @param Status Return status for the executed command.
298 This is an optional parameter and may be NULL.
300 @return The byte/word read from the SMBUS.
304 InternalSmBusByteWord (
305 IN UINT8 HostControl
,
306 IN UINTN SmBusAddress
,
308 OUT RETURN_STATUS
*Status
311 RETURN_STATUS ReturnStatus
;
312 UINT8 AuxiliaryControl
;
314 ReturnStatus
= InternalSmBusAcquire ();
315 if (RETURN_ERROR (ReturnStatus
)) {
319 AuxiliaryControl
= 0;
320 if (SMBUS_LIB_PEC (SmBusAddress
)) {
321 AuxiliaryControl
|= SMBUS_B_AAC
;
322 HostControl
|= SMBUS_B_PEC_EN
;
326 // Set commond register
328 InternalSmBusIoWrite8 (SMBUS_R_HST_CMD
, (UINT8
) SMBUS_LIB_COMMAND (SmBusAddress
));
330 InternalSmBusIoWrite8 (SMBUS_R_HST_D0
, (UINT8
) Value
);
331 InternalSmBusIoWrite8 (SMBUS_R_HST_D1
, (UINT8
) (Value
>> 8));
334 // Set Auxiliary Control Regiester.
336 InternalSmBusIoWrite8 (SMBUS_R_AUX_CTL
, AuxiliaryControl
);
338 // Set SMBus slave address for the device to send/receive from.
340 InternalSmBusIoWrite8 (SMBUS_R_XMIT_SLVA
, (UINT8
) SmBusAddress
);
342 // Set Control Register (Initiate Operation, Interrupt disabled)
344 InternalSmBusIoWrite8 (SMBUS_R_HST_CTL
, HostControl
+ SMBUS_B_START
);
349 ReturnStatus
= InternalSmBusWait ();
351 Value
= InternalSmBusIoRead8 (SMBUS_R_HST_D1
) << 8;
352 Value
|= InternalSmBusIoRead8 (SMBUS_R_HST_D0
);
355 // Clear status register and exit
357 InternalSmBusIoWrite8 (SMBUS_R_HST_STS
, SMBUS_B_HSTS_ALL
);;
360 if (Status
!= NULL
) {
361 *Status
= ReturnStatus
;
368 Executes an SMBUS receive byte command.
370 Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.
371 Only the SMBUS slave address field of SmBusAddress is required.
372 The byte received from the SMBUS is returned.
373 If Status is not NULL, then the status of the executed command is returned in Status.
374 If Command in SmBusAddress is not zero, then ASSERT().
375 If Length in SmBusAddress is not zero, then ASSERT().
376 If any reserved bits of SmBusAddress are set, then ASSERT().
378 @param SmBusAddress Address that encodes the SMBUS Slave Address,
379 SMBUS Command, SMBUS Data Length, and PEC.
380 @param Status Return status for the executed command.
381 This is an optional parameter and may be NULL.
383 @return The byte received from the SMBUS.
389 IN UINTN SmBusAddress
,
390 OUT RETURN_STATUS
*Status OPTIONAL
393 ASSERT (SMBUS_LIB_COMMAND (SmBusAddress
) == 0);
394 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
395 ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress
) == 0);
397 return (UINT8
) InternalSmBusByteWord (
398 SMBUS_V_SMB_CMD_BYTE
,
399 SmBusAddress
| SMBUS_B_READ
,
406 Executes an SMBUS send byte command.
408 Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.
409 The byte specified by Value is sent.
410 Only the SMBUS slave address field of SmBusAddress is required. Value is returned.
411 If Status is not NULL, then the status of the executed command is returned in Status.
412 If Command in SmBusAddress is not zero, then ASSERT().
413 If Length in SmBusAddress is not zero, 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 Value The 8-bit value to send.
419 @param Status Return status for the executed command.
420 This is an optional parameter and may be NULL.
422 @return The parameter of Value.
428 IN UINTN SmBusAddress
,
430 OUT RETURN_STATUS
*Status OPTIONAL
433 ASSERT (SMBUS_LIB_COMMAND (SmBusAddress
) == 0);
434 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
435 ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress
) == 0);
437 return (UINT8
) InternalSmBusByteWord (
438 SMBUS_V_SMB_CMD_BYTE
,
439 SmBusAddress
| SMBUS_B_WRITE
,
446 Executes an SMBUS read data byte command.
448 Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.
449 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
450 The 8-bit value read from the SMBUS is returned.
451 If Status is not NULL, then the status of the executed command is returned in Status.
452 If Length in SmBusAddress is not zero, then ASSERT().
453 If any reserved bits of SmBusAddress are set, then ASSERT().
455 @param SmBusAddress Address that encodes the SMBUS Slave Address,
456 SMBUS Command, SMBUS Data Length, and PEC.
457 @param Status Return status for the executed command.
458 This is an optional parameter and may be NULL.
460 @return The byte read from the SMBUS.
466 IN UINTN SmBusAddress
,
467 OUT RETURN_STATUS
*Status OPTIONAL
470 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
471 ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress
) == 0);
473 return (UINT8
) InternalSmBusByteWord (
474 SMBUS_V_SMB_CMD_BYTE_DATA
,
475 SmBusAddress
| SMBUS_B_READ
,
482 Executes an SMBUS write data byte command.
484 Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.
485 The 8-bit value specified by Value is written.
486 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
488 If Status is not NULL, then the status of the executed command is returned in Status.
489 If Length in SmBusAddress is not zero, then ASSERT().
490 If any reserved bits of SmBusAddress are set, then ASSERT().
492 @param SmBusAddress Address that encodes the SMBUS Slave Address,
493 SMBUS Command, SMBUS Data Length, and PEC.
494 @param Value The 8-bit value to write.
495 @param Status Return status for the executed command.
496 This is an optional parameter and may be NULL.
498 @return The parameter of Value.
504 IN UINTN SmBusAddress
,
506 OUT RETURN_STATUS
*Status OPTIONAL
509 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
510 ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress
) == 0);
512 return (UINT8
) InternalSmBusByteWord (
513 SMBUS_V_SMB_CMD_BYTE_DATA
,
514 SmBusAddress
| SMBUS_B_WRITE
,
521 Executes an SMBUS read data word command.
523 Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.
524 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
525 The 16-bit value read from the SMBUS is returned.
526 If Status is not NULL, then the status of the executed command is returned in Status.
527 If Length in SmBusAddress is not zero, then ASSERT().
528 If any reserved bits of SmBusAddress are set, then ASSERT().
530 @param SmBusAddress Address that encodes the SMBUS Slave Address,
531 SMBUS Command, SMBUS Data Length, and PEC.
532 @param Status Return status for the executed command.
533 This is an optional parameter and may be NULL.
535 @return The byte read from the SMBUS.
541 IN UINTN SmBusAddress
,
542 OUT RETURN_STATUS
*Status OPTIONAL
545 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
546 ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress
) == 0);
548 return InternalSmBusByteWord (
549 SMBUS_V_SMB_CMD_WORD_DATA
,
550 SmBusAddress
| SMBUS_B_READ
,
557 Executes an SMBUS write data word command.
559 Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.
560 The 16-bit value specified by Value is written.
561 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
563 If Status is not NULL, then the status of the executed command is returned in Status.
564 If Length in SmBusAddress is not zero, then ASSERT().
565 If any reserved bits of SmBusAddress are set, then ASSERT().
567 @param SmBusAddress Address that encodes the SMBUS Slave Address,
568 SMBUS Command, SMBUS Data Length, and PEC.
569 @param Value The 16-bit value to write.
570 @param Status Return status for the executed command.
571 This is an optional parameter and may be NULL.
573 @return The parameter of Value.
579 IN UINTN SmBusAddress
,
581 OUT RETURN_STATUS
*Status OPTIONAL
584 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
585 ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress
) == 0);
587 return InternalSmBusByteWord (
588 SMBUS_V_SMB_CMD_WORD_DATA
,
589 SmBusAddress
| SMBUS_B_WRITE
,
596 Executes an SMBUS process call command.
598 Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.
599 The 16-bit value specified by Value is written.
600 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
601 The 16-bit value returned by the process call command is returned.
602 If Status is not NULL, then the status of the executed command is returned in Status.
603 If Length in SmBusAddress is not zero, then ASSERT().
604 If any reserved bits of SmBusAddress are set, then ASSERT().
606 @param SmBusAddress Address that encodes the SMBUS Slave Address,
607 SMBUS Command, SMBUS Data Length, and PEC.
608 @param Value The 16-bit value to write.
609 @param Status Return status for the executed command.
610 This is an optional parameter and may be NULL.
612 @return The 16-bit value returned by the process call command.
618 IN UINTN SmBusAddress
,
620 OUT RETURN_STATUS
*Status OPTIONAL
623 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
624 ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress
) == 0);
626 return InternalSmBusByteWord (
627 SMBUS_V_SMB_CMD_PROCESS_CALL
,
628 SmBusAddress
| SMBUS_B_WRITE
,
635 Executes an SMBUS block command.
637 Executes an SMBUS block read, block write and block write-block read command
638 on the SMBUS device specified by SmBusAddress.
639 Bytes are read from the SMBUS and stored in Buffer.
640 The number of bytes read is returned, and will never return a value larger than 32-bytes.
641 If Status is not NULL, then the status of the executed command is returned in Status.
642 It is the caller¡¯s responsibility to make sure Buffer is large enough for the total number of bytes read.
643 SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
645 @param HostControl The value of Host Control Register to set.
646 @param SmBusAddress Address that encodes the SMBUS Slave Address,
647 SMBUS Command, SMBUS Data Length, and PEC.
648 @param OutBuffer Pointer to the buffer of bytes to write to the SMBUS.
649 @param InBuffer Pointer to the buffer of bytes to read from the SMBUS.
650 @param Status Return status for the executed command.
651 This is an optional parameter and may be NULL.
653 @return The number of bytes read from the SMBUS.
658 IN UINT8 HostControl
,
659 IN UINTN SmBusAddress
,
662 OUT RETURN_STATUS
*Status
665 RETURN_STATUS ReturnStatus
;
668 UINT8 AuxiliaryControl
;
670 BytesCount
= SMBUS_LIB_LENGTH (SmBusAddress
) + 1;
672 ReturnStatus
= InternalSmBusAcquire ();
673 if (RETURN_ERROR (ReturnStatus
)) {
677 AuxiliaryControl
= SMBUS_B_E32B
;
678 if (SMBUS_LIB_PEC (SmBusAddress
)) {
679 AuxiliaryControl
|= SMBUS_B_AAC
;
680 HostControl
|= SMBUS_B_PEC_EN
;
683 InternalSmBusIoWrite8 (SMBUS_R_HST_CMD
, (UINT8
) SMBUS_LIB_COMMAND (SmBusAddress
));
685 InternalSmBusIoWrite8 (SMBUS_R_HST_D0
, (UINT8
) BytesCount
);
687 if (OutBuffer
!= NULL
) {
688 for (Index
= 0; Index
< BytesCount
; Index
++) {
689 InternalSmBusIoWrite8 (SMBUS_R_HOST_BLOCK_DB
, OutBuffer
[Index
]);
693 // Set Auxiliary Control Regiester.
695 InternalSmBusIoWrite8 (SMBUS_R_AUX_CTL
, AuxiliaryControl
);
697 // Set SMBus slave address for the device to send/receive from
699 InternalSmBusIoWrite8 (SMBUS_R_XMIT_SLVA
, (UINT8
) SmBusAddress
);
701 // Set Control Register (Initiate Operation, Interrupt disabled)
703 InternalSmBusIoWrite8 (SMBUS_R_HST_CTL
, HostControl
+ SMBUS_B_START
);
708 ReturnStatus
= InternalSmBusWait ();
709 if (RETURN_ERROR (ReturnStatus
)) {
713 BytesCount
= InternalSmBusIoRead8 (SMBUS_R_HST_D0
);
714 if (InBuffer
!= NULL
) {
715 for (Index
= 0; Index
< BytesCount
; Index
++) {
716 InBuffer
[Index
] = InternalSmBusIoRead8 (SMBUS_R_HOST_BLOCK_DB
);
721 // Clear status register and exit
723 InternalSmBusIoWrite8 (SMBUS_R_HST_STS
, SMBUS_B_HSTS_ALL
);
726 if (Status
!= NULL
) {
727 *Status
= ReturnStatus
;
734 Executes an SMBUS read block command.
736 Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.
737 Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
738 Bytes are read from the SMBUS and stored in Buffer.
739 The number of bytes read is returned, and will never return a value larger than 32-bytes.
740 If Status is not NULL, then the status of the executed command is returned in Status.
741 It is the caller¡¯s responsibility to make sure Buffer is large enough for the total number of bytes read.
742 SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
743 If Length in SmBusAddress is not zero, then ASSERT().
744 If Buffer is NULL, then ASSERT().
745 If any reserved bits of SmBusAddress are set, then ASSERT().
747 @param SmBusAddress Address that encodes the SMBUS Slave Address,
748 SMBUS Command, SMBUS Data Length, and PEC.
749 @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
750 @param Status Return status for the executed command.
751 This is an optional parameter and may be NULL.
753 @return The number of bytes read.
759 IN UINTN SmBusAddress
,
761 OUT RETURN_STATUS
*Status OPTIONAL
764 ASSERT (Buffer
!= NULL
);
765 ASSERT (SMBUS_LIB_LENGTH (SmBusAddress
) == 0);
766 ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress
) == 0);
768 return InternalSmBusBlock (
769 SMBUS_V_SMB_CMD_BLOCK
,
770 SmBusAddress
| SMBUS_B_READ
,
778 Executes an SMBUS write block command.
780 Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.
781 The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
782 Bytes are written to the SMBUS from Buffer.
783 The number of bytes written is returned, and will never return a value larger than 32-bytes.
784 If Status is not NULL, then the status of the executed command is returned in Status.
785 If Length in SmBusAddress is zero or greater than 32, then ASSERT().
786 If Buffer is NULL, then ASSERT().
787 If any reserved bits of SmBusAddress are set, then ASSERT().
789 @param SmBusAddress Address that encodes the SMBUS Slave Address,
790 SMBUS Command, SMBUS Data Length, and PEC.
791 @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
792 @param Status Return status for the executed command.
793 This is an optional parameter and may be NULL.
795 @return The number of bytes written.
801 IN UINTN SmBusAddress
,
803 OUT RETURN_STATUS
*Status OPTIONAL
806 ASSERT (Buffer
!= NULL
);
807 ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress
) == 0);
809 return InternalSmBusBlock (
810 SMBUS_V_SMB_CMD_BLOCK
,
811 SmBusAddress
| SMBUS_B_WRITE
,
819 Executes an SMBUS block process call command.
821 Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.
822 The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
823 Bytes are written to the SMBUS from OutBuffer. Bytes are then read from the SMBUS into InBuffer.
824 If Status is not NULL, then the status of the executed command is returned in Status.
825 It is the caller¡¯s responsibility to make sure InBuffer is large enough for the total number of bytes read.
826 SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
827 If OutBuffer is NULL, then ASSERT().
828 If InBuffer is NULL, then ASSERT().
829 If any reserved bits of SmBusAddress are set, then ASSERT().
831 @param SmBusAddress Address that encodes the SMBUS Slave Address,
832 SMBUS Command, SMBUS Data Length, and PEC.
833 @param OutBuffer Pointer to the buffer of bytes to write to the SMBUS.
834 @param InBuffer Pointer to the buffer of bytes to read from the SMBUS.
835 @param Status Return status for the executed command.
836 This is an optional parameter and may be NULL.
838 @return The number of bytes written.
843 SmBusBlockProcessCall (
844 IN UINTN SmBusAddress
,
847 OUT RETURN_STATUS
*Status OPTIONAL
850 ASSERT (InBuffer
!= NULL
);
851 ASSERT (OutBuffer
!= NULL
);
852 ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress
) == 0);
854 return InternalSmBusBlock (
855 SMBUS_V_SMB_CMD_BLOCK_PROCESS
,
856 SmBusAddress
| SMBUS_B_WRITE
,