]> git.proxmox.com Git - mirror_edk2.git/blame - QuarkSocPkg/QuarkSouthCluster/Include/Library/I2cLib.h
QuarkSocPkg: Add new package for Quark SoC X1000
[mirror_edk2.git] / QuarkSocPkg / QuarkSouthCluster / Include / Library / I2cLib.h
CommitLineData
9b6bbcdb
MK
1/** @file\r
2\r
3Intel I2C library implementation built upon I/O library\r
4\r
5\r
6Copyright (c) 2013-2015 Intel Corporation.\r
7\r
8This program and the accompanying materials\r
9are licensed and made available under the terms and conditions of the BSD License\r
10which accompanies this distribution. The full text of the license may be found at\r
11http://opensource.org/licenses/bsd-license.php\r
12\r
13THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15\r
16**/\r
17\r
18#ifndef _I2C_LIB_H_\r
19#define _I2C_LIB_H_\r
20\r
21#include "I2cRegs.h"\r
22\r
23/**\r
24\r
25 The I2cWriteByte() function is a wrapper function for the WriteByte() function.\r
26 Provides a standard way to execute a standard single byte write to an IC2 device\r
27 (without accessing sub-addresses), as defined in the I2C Specification.\r
28\r
29 @param SlaveAddress The I2C slave address of the device\r
30 with which to communicate.\r
31\r
32 @param AddrMode I2C Addressing Mode: 7-bit or 10-bit address.\r
33\r
34 @param Buffer Contains the value of byte data to execute to the\r
35 I2C slave device.\r
36\r
37\r
38 @retval EFI_SUCCESS Transfer success.\r
39 @retval EFI_INVALID_PARAMETER This or Buffer pointers are invalid.\r
40 @retval EFI_TIMEOUT Timeout while waiting xfer.\r
41 @retval EFI_ABORTED Controller aborted xfer.\r
42 @retval EFI_DEVICE_ERROR Device error detected by controller.\r
43\r
44**/\r
45EFI_STATUS\r
46EFIAPI\r
47I2cWriteByte (\r
48 IN EFI_I2C_DEVICE_ADDRESS SlaveAddress,\r
49 IN EFI_I2C_ADDR_MODE AddrMode,\r
50 IN OUT VOID *Buffer\r
51 );\r
52\r
53/**\r
54\r
55 The I2cReadByte() function is a wrapper function for the ReadByte() function.\r
56 Provides a standard way to execute a standard single byte read to an I2C device\r
57 (without accessing sub-addresses), as defined in the I2C Specification.\r
58\r
59 @param SlaveAddress The I2C slave address of the device\r
60 with which to communicate.\r
61\r
62 @param AddrMode I2C Addressing Mode: 7-bit or 10-bit address.\r
63\r
64 @param Buffer Contains the value of byte data read from the\r
65 I2C slave device.\r
66\r
67\r
68 @retval EFI_SUCCESS Transfer success.\r
69 @retval EFI_INVALID_PARAMETER This or Buffer pointers are invalid.\r
70 @retval EFI_TIMEOUT Timeout while waiting xfer.\r
71 @retval EFI_ABORTED Controller aborted xfer.\r
72 @retval EFI_DEVICE_ERROR Device error detected by controller.\r
73\r
74**/\r
75EFI_STATUS\r
76EFIAPI\r
77I2cReadByte (\r
78 IN EFI_I2C_DEVICE_ADDRESS SlaveAddress,\r
79 IN EFI_I2C_ADDR_MODE AddrMode,\r
80 IN OUT VOID *Buffer\r
81 );\r
82\r
83/**\r
84\r
85 The I2cWriteMultipleByte() function is a wrapper function for the WriteMultipleByte()\r
86 function. Provides a standard way to execute multiple byte writes to an I2C device (e.g. when\r
87 accessing sub-addresses or writing block of data), as defined in the I2C Specification.\r
88\r
89 @param SlaveAddress The I2C slave address of the device\r
90 with which to communicate.\r
91\r
92 @param AddrMode I2C Addressing Mode: 7-bit or 10-bit address.\r
93\r
94 @param Length No. of bytes to be written.\r
95\r
96 @param Buffer Contains the value of byte to be written to the\r
97 I2C slave device.\r
98\r
99 @retval EFI_SUCCESS Transfer success.\r
100 @retval EFI_INVALID_PARAMETER This, Length or Buffer pointers are invalid.\r
101 @retval EFI_UNSUPPORTED Unsupported input param.\r
102 @retval EFI_TIMEOUT Timeout while waiting xfer.\r
103 @retval EFI_ABORTED Controller aborted xfer.\r
104 @retval EFI_DEVICE_ERROR Device error detected by controller.\r
105\r
106**/\r
107EFI_STATUS\r
108EFIAPI\r
109I2cWriteMultipleByte (\r
110 IN EFI_I2C_DEVICE_ADDRESS SlaveAddress,\r
111 IN EFI_I2C_ADDR_MODE AddrMode,\r
112 IN UINTN *Length,\r
113 IN OUT VOID *Buffer\r
114 );\r
115\r
116/**\r
117\r
118 The I2cReadMultipleByte() function is a wrapper function for the ReadMultipleByte\r
119 function. Provides a standard way to execute multiple byte writes to an IC2 device\r
120 (e.g. when accessing sub-addresses or when reading block of data), as defined\r
121 in the I2C Specification (I2C combined write/read protocol).\r
122\r
123 @param SlaveAddress The I2C slave address of the device\r
124 with which to communicate.\r
125\r
126 @param AddrMode I2C Addressing Mode: 7-bit or 10-bit address.\r
127\r
128 @param WriteLength No. of bytes to be written. In this case data\r
129 written typically contains sub-address or sub-addresses\r
130 in Hi-Lo format, that need to be read (I2C combined\r
131 write/read protocol).\r
132\r
133 @param ReadLength No. of bytes to be read from I2C slave device.\r
134 need to be read.\r
135\r
136 @param Buffer Contains the value of byte data read from the\r
137 I2C slave device.\r
138\r
139 @retval EFI_SUCCESS Transfer success.\r
140 @retval EFI_INVALID_PARAMETER This, WriteLength, ReadLength or Buffer\r
141 pointers are invalid.\r
142 @retval EFI_UNSUPPORTED Unsupported input param.\r
143 @retval EFI_TIMEOUT Timeout while waiting xfer.\r
144 @retval EFI_ABORTED Controller aborted xfer.\r
145 @retval EFI_DEVICE_ERROR Device error detected by controller.\r
146\r
147**/\r
148EFI_STATUS\r
149EFIAPI\r
150I2cReadMultipleByte (\r
151 IN EFI_I2C_DEVICE_ADDRESS SlaveAddress,\r
152 IN EFI_I2C_ADDR_MODE AddrMode,\r
153 IN UINTN *WriteLength,\r
154 IN UINTN *ReadLength,\r
155 IN OUT VOID *Buffer\r
156 );\r
157\r
158#endif\r