]> git.proxmox.com Git - mirror_edk2.git/blobdiff - QuarkSocPkg/QuarkSouthCluster/Include/Library/I2cLib.h
QuarkSocPkg: Add new package for Quark SoC X1000
[mirror_edk2.git] / QuarkSocPkg / QuarkSouthCluster / Include / Library / I2cLib.h
diff --git a/QuarkSocPkg/QuarkSouthCluster/Include/Library/I2cLib.h b/QuarkSocPkg/QuarkSouthCluster/Include/Library/I2cLib.h
new file mode 100644 (file)
index 0000000..b494a3b
--- /dev/null
@@ -0,0 +1,158 @@
+/** @file\r
+\r
+Intel I2C library implementation built upon I/O library\r
+\r
+\r
+Copyright (c) 2013-2015 Intel Corporation.\r
+\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The 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 _I2C_LIB_H_\r
+#define _I2C_LIB_H_\r
+\r
+#include "I2cRegs.h"\r
+\r
+/**\r
+\r
+  The I2cWriteByte() function is a wrapper function for the WriteByte() function.\r
+  Provides a standard way to execute a standard single byte write to an IC2 device\r
+  (without accessing sub-addresses), as defined in the I2C Specification.\r
+\r
+  @param SlaveAddress The I2C slave address of the device\r
+                      with which to communicate.\r
+\r
+  @param AddrMode     I2C Addressing Mode: 7-bit or 10-bit address.\r
+\r
+  @param Buffer       Contains the value of byte data to execute to the\r
+                      I2C slave device.\r
+\r
+\r
+  @retval EFI_SUCCESS           Transfer success.\r
+  @retval EFI_INVALID_PARAMETER  This or Buffer pointers are invalid.\r
+  @retval EFI_TIMEOUT           Timeout while waiting xfer.\r
+  @retval EFI_ABORTED           Controller aborted xfer.\r
+  @retval EFI_DEVICE_ERROR      Device error detected by controller.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+I2cWriteByte (\r
+  IN        EFI_I2C_DEVICE_ADDRESS  SlaveAddress,\r
+  IN        EFI_I2C_ADDR_MODE       AddrMode,\r
+  IN OUT VOID                       *Buffer\r
+  );\r
+\r
+/**\r
+\r
+  The I2cReadByte() function is a wrapper function for the ReadByte() function.\r
+  Provides a standard way to execute a standard single byte read to an I2C device\r
+  (without accessing sub-addresses), as defined in the I2C Specification.\r
+\r
+  @param SlaveAddress The I2C slave address of the device\r
+                      with which to communicate.\r
+\r
+  @param AddrMode     I2C Addressing Mode: 7-bit or 10-bit address.\r
+\r
+  @param Buffer       Contains the value of byte data read from the\r
+                      I2C slave device.\r
+\r
+\r
+  @retval EFI_SUCCESS           Transfer success.\r
+  @retval EFI_INVALID_PARAMETER This or Buffer pointers are invalid.\r
+  @retval EFI_TIMEOUT           Timeout while waiting xfer.\r
+  @retval EFI_ABORTED           Controller aborted xfer.\r
+  @retval EFI_DEVICE_ERROR      Device error detected by controller.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+I2cReadByte (\r
+  IN        EFI_I2C_DEVICE_ADDRESS  SlaveAddress,\r
+  IN        EFI_I2C_ADDR_MODE       AddrMode,\r
+  IN OUT VOID                       *Buffer\r
+  );\r
+\r
+/**\r
+\r
+  The I2cWriteMultipleByte() function is a wrapper function for the WriteMultipleByte()\r
+  function. Provides a standard way to execute multiple byte writes to an I2C device (e.g. when\r
+  accessing sub-addresses or writing block of data), as defined in the I2C Specification.\r
+\r
+  @param SlaveAddress The I2C slave address of the device\r
+                      with which to communicate.\r
+\r
+  @param AddrMode     I2C Addressing Mode: 7-bit or 10-bit address.\r
+\r
+  @param Length       No. of bytes to be written.\r
+\r
+  @param Buffer       Contains the value of byte to be written to the\r
+                      I2C slave device.\r
+\r
+  @retval EFI_SUCCESS            Transfer success.\r
+  @retval EFI_INVALID_PARAMETER  This, Length or Buffer pointers are invalid.\r
+  @retval EFI_UNSUPPORTED        Unsupported input param.\r
+  @retval EFI_TIMEOUT            Timeout while waiting xfer.\r
+  @retval EFI_ABORTED            Controller aborted xfer.\r
+  @retval EFI_DEVICE_ERROR       Device error detected by controller.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+I2cWriteMultipleByte (\r
+  IN        EFI_I2C_DEVICE_ADDRESS  SlaveAddress,\r
+  IN        EFI_I2C_ADDR_MODE       AddrMode,\r
+  IN UINTN                          *Length,\r
+  IN OUT VOID                       *Buffer\r
+  );\r
+\r
+/**\r
+\r
+  The I2cReadMultipleByte() function is a wrapper function for the ReadMultipleByte\r
+  function. Provides a standard way to execute multiple byte writes to an IC2 device\r
+  (e.g. when accessing sub-addresses or when reading block of data), as defined\r
+  in the I2C Specification (I2C combined write/read protocol).\r
+\r
+  @param SlaveAddress The I2C slave address of the device\r
+                      with which to communicate.\r
+\r
+  @param AddrMode     I2C Addressing Mode: 7-bit or 10-bit address.\r
+\r
+  @param WriteLength  No. of bytes to be written. In this case data\r
+                      written typically contains sub-address or sub-addresses\r
+                      in Hi-Lo format, that need to be read (I2C combined\r
+                      write/read protocol).\r
+\r
+  @param ReadLength   No. of bytes to be read from I2C slave device.\r
+                      need to be read.\r
+\r
+  @param Buffer       Contains the value of byte data read from the\r
+                      I2C slave device.\r
+\r
+  @retval EFI_SUCCESS            Transfer success.\r
+  @retval EFI_INVALID_PARAMETER  This, WriteLength, ReadLength or Buffer\r
+                                 pointers are invalid.\r
+  @retval EFI_UNSUPPORTED        Unsupported input param.\r
+  @retval EFI_TIMEOUT            Timeout while waiting xfer.\r
+  @retval EFI_ABORTED            Controller aborted xfer.\r
+  @retval EFI_DEVICE_ERROR       Device error detected by controller.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+I2cReadMultipleByte (\r
+  IN        EFI_I2C_DEVICE_ADDRESS  SlaveAddress,\r
+  IN        EFI_I2C_ADDR_MODE       AddrMode,\r
+  IN UINTN                          *WriteLength,\r
+  IN UINTN                          *ReadLength,\r
+  IN OUT VOID                       *Buffer\r
+  );\r
+\r
+#endif\r