]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/Library/S3SmbusLib.h
MdePkg: Add S3 library interfaces and base implementations
[mirror_edk2.git] / MdePkg / Include / Library / S3SmbusLib.h
diff --git a/MdePkg/Include/Library/S3SmbusLib.h b/MdePkg/Include/Library/S3SmbusLib.h
new file mode 100644 (file)
index 0000000..f7a1e24
--- /dev/null
@@ -0,0 +1,455 @@
+/** @file\r
+  Smbus Library Services that conduct SMBus transactions and enable the operatation\r
+  to be replayed during an S3 resume. This library class maps directly on top\r
+  of the SmbusLib class.\r
+\r
+  Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions\r
+  of the BSD License which accompanies this distribution.  The\r
+  full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __S3_SMBUS_LIB_H__\r
+#define __S3_SMBUS_LIB_H__\r
+\r
+/**\r
+  Executes an SMBUS quick read command, and saves the value in the S3 script to be replayed\r
+  on S3 resume.\r
+\r
+  Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address field of SmBusAddress is required.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If PEC is set in SmBusAddress, then ASSERT().\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param[in]  SmBusAddress   The address that encodes the SMBUS Slave Address,\r
+                             SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param[out] Status         The return status for the executed command.\r
+                             This is an optional parameter and may be NULL.\r
+                             RETURN_SUCCESS             The SMBUS command was executed.\r
+                             RETURN_TIMEOUT             A timeout occurred while executing the SMBUS command.\r
+                             RETURN_DEVICE_ERROR The request was not completed because a failure\r
+                              was recorded in the Host Status Register bit.  Device errors are a result\r
+                              of a transaction collision, illegal command field, unclaimed cycle\r
+                              (host initiated), or bus error (collision).\r
+                             RETURN_UNSUPPORTED        The SMBus operation is not supported.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+S3SmBusQuickRead (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT RETURN_STATUS  *Status       OPTIONAL\r
+  );\r
+\r
+/**\r
+  Executes an SMBUS quick write command, and saves the value in the S3 script to be replayed\r
+  on S3 resume.\r
+\r
+  Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address field of SmBusAddress is required.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If PEC is set in SmBusAddress, then ASSERT().\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param[in]  SmBusAddress   The address that encodes the SMBUS Slave Address,\r
+                             SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param[out] Status         The return status for the executed command.\r
+                             This is an optional parameter and may be NULL.\r
+                             RETURN_SUCCESS            The SMBUS command was executed.\r
+                             RETURN_TIMEOUT            A timeout occurred while executing the SMBUS command.\r
+                             RETURN_DEVICE_ERROR The request was not completed because a failure\r
+                             was recorded in the Host Status Register bit.  Device errors are a result\r
+                             of a transaction collision, illegal command field, unclaimed cycle\r
+                             (host initiated), or bus error (collision).\r
+                             RETURN_UNSUPPORTED        The SMBus operation is not supported.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+S3SmBusQuickWrite (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT RETURN_STATUS  *Status       OPTIONAL\r
+  );\r
+\r
+/**\r
+  Executes an SMBUS receive byte command, and saves the value in the S3 script to be replayed\r
+  on S3 resume.\r
+\r
+  Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address field of SmBusAddress is required.\r
+  The byte received from the SMBUS is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param[in]  SmBusAddress   The address that encodes the SMBUS Slave Address,\r
+                             SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param[out] Status         The return status for the executed command.\r
+                             This is an optional parameter and may be NULL.\r
+                             RETURN_SUCCESS            The SMBUS command was executed.\r
+                             RETURN_TIMEOUT            A timeout occurred while executing the SMBUS command.\r
+                             RETURN_DEVICE_ERROR The request was not completed because a failure\r
+                             was recorded in the Host Status Register bit.  Device errors are a result\r
+                             of a transaction collision, illegal command field, unclaimed cycle\r
+                             (host initiated), or bus error (collision).\r
+                             RETURN_CRC_ERROR  The checksum is not correct (PEC is incorrect).\r
+                             RETURN_UNSUPPORTED        The SMBus operation is not supported.\r
+\r
+  @return   The byte received from the SMBUS.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+S3SmBusReceiveByte (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  );\r
+\r
+/**\r
+  Executes an SMBUS send byte command, and saves the value in the S3 script to be replayed\r
+  on S3 resume.\r
+\r
+  Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.\r
+  The byte specified by Value is sent.\r
+  Only the SMBUS slave address field of SmBusAddress is required.  Value is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Command in SmBusAddress is not zero, then ASSERT().\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param[in]  SmBusAddress   The address that encodes the SMBUS Slave Address,\r
+                             SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param[in]  Value          The 8-bit value to send.\r
+  @param[out] Status         The return status for the executed command.\r
+                             This is an optional parameter and may be NULL.\r
+                             RETURN_SUCCESS The SMBUS command was executed.\r
+                             RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+                             RETURN_DEVICE_ERROR  The request was not completed because a failure\r
+                             was recorded in the Host Status Register bit.  Device errors are a result\r
+                             of a transaction collision, illegal command field, unclaimed cycle\r
+                             (host initiated), or bus errors (collisions).\r
+                             RETURN_CRC_ERROR  The checksum is not correct (PEC is incorrect).\r
+                             RETURN_UNSUPPORTED  The SMBus operation is not supported.\r
+\r
+  @return   The parameter of Value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+S3SmBusSendByte (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT8          Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  );\r
+\r
+/**\r
+  Executes an SMBUS read data byte command, and saves the value in the S3 script to be replayed\r
+  on S3 resume.\r
+\r
+  Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  The 8-bit value read from the SMBUS is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param[in]  SmBusAddress   The address that encodes the SMBUS Slave Address,\r
+                             SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param[out] Status         The return status for the executed command.\r
+                             This is an optional parameter and may be NULL.\r
+                             RETURN_SUCCESS The SMBUS command was executed.\r
+                             RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+                             RETURN_DEVICE_ERROR  The request was not completed because a failure\r
+                             was recorded in the Host Status Register bit.  Device errors are a result\r
+                             of a transaction collision, illegal command field, unclaimed cycle\r
+                             (host initiated), or bus error (collision).\r
+                             RETURN_CRC_ERROR  The checksum is not correct (PEC is incorrect).\r
+                             RETURN_UNSUPPORTED  The SMBus operation is not supported.\r
+\r
+  @return   The byte read from the SMBUS.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+S3SmBusReadDataByte (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  );\r
+\r
+/**\r
+  Executes an SMBUS write data byte command, and saves the value in the S3 script to be replayed\r
+  on S3 resume.\r
+\r
+  Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.\r
+  The 8-bit value specified by Value is written.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  Value is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param[in]  SmBusAddress   The address that encodes the SMBUS Slave Address,\r
+                             SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param[in]  Value          The 8-bit value to write.\r
+  @param[out] Status         The return status for the executed command.\r
+                             This is an optional parameter and may be NULL.\r
+                             RETURN_SUCCESS The SMBUS command was executed.\r
+                             RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+                             RETURN_DEVICE_ERROR  The request was not completed because a failure\r
+                             was recorded in the Host Status Register bit.  Device errors are a result\r
+                             of a transaction collision, illegal command field, unclaimed cycle\r
+                             (host initiated), or bus error (collision).\r
+                             RETURN_CRC_ERROR  The checksum is not correct (PEC is incorrect).\r
+                             RETURN_UNSUPPORTED  The SMBus operation is not supported.\r
+\r
+  @return   The parameter of Value.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+S3SmBusWriteDataByte (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT8          Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  );\r
+\r
+/**\r
+  Executes an SMBUS read data word command, and saves the value in the S3 script to be replayed\r
+  on S3 resume.\r
+\r
+  Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  The 16-bit value read from the SMBUS is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param[in]  SmBusAddress   The address that encodes the SMBUS Slave Address,\r
+                             SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param[out] Status         The return status for the executed command.\r
+                             This is an optional parameter and may be NULL.\r
+                             RETURN_SUCCESS The SMBUS command was executed.\r
+                             RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+                             RETURN_DEVICE_ERROR  The request was not completed because a failure\r
+                             was recorded in the Host Status Register bit.  Device errors are a result\r
+                             of a transaction collision, illegal command field, unclaimed cycle\r
+                             (host initiated), or bus error (collision).\r
+                             RETURN_CRC_ERROR  The checksum is not correct (PEC is incorrect).\r
+                             RETURN_UNSUPPORTED  The SMBus operation is not supported.\r
+\r
+  @return   The byte read from the SMBUS.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+S3SmBusReadDataWord (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  );\r
+\r
+/**\r
+  Executes an SMBUS write data word command, and saves the value in the S3 script to be replayed\r
+  on S3 resume.\r
+\r
+  Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.\r
+  The 16-bit value specified by Value is written.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  Value is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param[in]  SmBusAddress   The address that encodes the SMBUS Slave Address,\r
+                             SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param[in]  Value          The 16-bit value to write.\r
+  @param[out] Status         The return status for the executed command.\r
+                             This is an optional parameter and may be NULL.\r
+                             RETURN_SUCCESS The SMBUS command was executed.\r
+                             RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+                             RETURN_DEVICE_ERROR  The request was not completed because a failure\r
+                             was recorded in the Host Status Register bit.  Device errors are a result\r
+                             of a transaction collision, illegal command field, unclaimed cycle\r
+                             (host initiated), or bus error (collision).\r
+                             RETURN_CRC_ERROR  The checksum is not correct (PEC is incorrect).\r
+                             RETURN_UNSUPPORTED  The SMBus operation is not supported.\r
+\r
+  @return   The parameter of Value.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+S3SmBusWriteDataWord (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT16         Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  );\r
+\r
+/**\r
+  Executes an SMBUS process call command, and saves the value in the S3 script to be replayed\r
+  on S3 resume.\r
+\r
+  Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.\r
+  The 16-bit value specified by Value is written.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  The 16-bit value returned by the process call command is returned.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param[in]  SmBusAddress   The address that encodes the SMBUS Slave Address,\r
+                             SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param[in]  Value          The 16-bit value to write.\r
+  @param[out] Status         The return status for the executed command.\r
+                             This is an optional parameter and may be NULL.\r
+                             RETURN_SUCCESS The SMBUS command was executed.\r
+                             RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+                             RETURN_DEVICE_ERROR  The request was not completed because a failure\r
+                             was recorded in the Host Status Register bit.  Device errors are a result\r
+                             of a transaction collision, illegal command field, unclaimed cycle\r
+                             (host initiated), or bus error (collision).\r
+                             RETURN_CRC_ERROR  The checksum is not correct (PEC is incorrect).\r
+                             RETURN_UNSUPPORTED  The SMBus operation is not supported.\r
+\r
+  @return   The 16-bit value returned by the process call command.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+S3SmBusProcessCall (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  UINT16         Value,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  );\r
+\r
+/**\r
+  Executes an SMBUS read block command, and saves the value in the S3 script to be replayed\r
+  on S3 resume.\r
+\r
+  Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.\r
+  Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.\r
+  Bytes are read from the SMBUS and stored in Buffer.\r
+  The number of bytes read is returned, and will never return a value larger than 32-bytes.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.\r
+  SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r
+  If Length in SmBusAddress is not zero, then ASSERT().\r
+  If Buffer is NULL, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param[in]  SmBusAddress   The address that encodes the SMBUS Slave Address,\r
+                             SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param[out] Buffer         The pointer to the buffer to store the bytes read from the SMBUS.\r
+  @param[out] Status         The return status for the executed command.\r
+                             This is an optional parameter and may be NULL.\r
+                             RETURN_SUCCESS The SMBUS command was executed.\r
+                             RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+                             RETURN_DEVICE_ERROR  The request was not completed because a failure\r
+                             was recorded in the Host Status Register bit.  Device errors are a result\r
+                             of a transaction collision, illegal command field, unclaimed cycle\r
+                             (host initiated), or bus error (collision).\r
+                             RETURN_CRC_ERROR  The checksum is not correct (PEC is incorrect).\r
+                             RETURN_UNSUPPORTED  The SMBus operation is not supported.\r
+\r
+  @return   The number of bytes read.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+S3SmBusReadBlock (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT VOID           *Buffer,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  );\r
+\r
+/**\r
+  Executes an SMBUS write block command, and saves the value in the S3 script to be replayed\r
+  on S3 resume.\r
+\r
+  Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.\r
+  The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r
+  Bytes are written to the SMBUS from Buffer.\r
+  The number of bytes written is returned, and will never return a value larger than 32-bytes.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r
+  If Buffer is NULL, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param[in]  SmBusAddress   The address that encodes the SMBUS Slave Address,\r
+                             SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param[out] Buffer         The pointer to the buffer to store the bytes read from the SMBUS.\r
+  @param[out] Status         The return status for the executed command.\r
+                             This is an optional parameter and may be NULL.\r
+                             RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+                             RETURN_DEVICE_ERROR  The request was not completed because a failure\r
+                             was recorded in the Host Status Register bit.  Device errors are a result\r
+                             of a transaction collision, illegal command field, unclaimed cycle\r
+                             (host initiated), or bus error (collision).\r
+                             RETURN_CRC_ERROR  The checksum is not correct (PEC is incorrect).\r
+                             RETURN_UNSUPPORTED  The SMBus operation is not supported.\r
+\r
+  @return   The number of bytes written.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+S3SmBusWriteBlock (\r
+  IN  UINTN          SmBusAddress,\r
+  OUT VOID           *Buffer,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  );\r
+\r
+/**\r
+  Executes an SMBUS block process call command, and saves the value in the S3 script to be replayed\r
+  on S3 resume.\r
+\r
+  Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.\r
+  The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.\r
+  Bytes are written to the SMBUS from WriteBuffer.  Bytes are then read from the SMBUS into ReadBuffer.\r
+  If Status is not NULL, then the status of the executed command is returned in Status.\r
+  It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.\r
+  SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.\r
+  If Length in SmBusAddress is zero or greater than 32, then ASSERT().\r
+  If WriteBuffer is NULL, then ASSERT().\r
+  If ReadBuffer is NULL, then ASSERT().\r
+  If any reserved bits of SmBusAddress are set, then ASSERT().\r
+\r
+  @param[in]  SmBusAddress   The address that encodes the SMBUS Slave Address,\r
+                             SMBUS Command, SMBUS Data Length, and PEC.\r
+  @param[in]  WriteBuffer    The pointer to the buffer of bytes to write to the SMBUS.\r
+  @param[out] ReadBuffer     The pointer to the buffer of bytes to read from the SMBUS.\r
+  @param[out] Status         The return status for the executed command.\r
+                             This is an optional parameter and may be NULL.\r
+                             RETURN_TIMEOUT A timeout occurred while executing the SMBUS command.\r
+                             RETURN_DEVICE_ERROR  The request was not completed because a failure\r
+                             was recorded in the Host Status Register bit.  Device errors are a result\r
+                             of a transaction collision, illegal command field, unclaimed cycle\r
+                             (host initiated), or bus error (collision).\r
+                             RETURN_CRC_ERROR  The checksum is not correct (PEC is incorrect).\r
+                             RETURN_UNSUPPORTED  The SMBus operation is not supported.\r
+\r
+  @return   The number of bytes written.\r
+\r
+**/\r
+UINTN\r
+EFIAPI\r
+S3SmBusBlockProcessCall (\r
+  IN  UINTN          SmBusAddress,\r
+  IN  VOID           *WriteBuffer,\r
+  OUT VOID           *ReadBuffer,\r
+  OUT RETURN_STATUS  *Status        OPTIONAL\r
+  );\r
+\r
+#endif\r