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