]>
Commit | Line | Data |
---|---|---|
3cbfba02 DW |
1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r | |
4 | \r\r | |
5 | This program and the accompanying materials are licensed and made available under\r\r | |
6 | the terms and conditions of the BSD License that accompanies this distribution. \r\r | |
7 | The full text of the license may be found at \r\r | |
8 | http://opensource.org/licenses/bsd-license.php. \r\r | |
9 | \r\r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r\r | |
12 | \r\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #ifndef __I2C_BUS_H__\r | |
17 | #define __I2C_BUS_H__\r | |
18 | \r | |
19 | #include <Protocol/I2cHostMcg.h>\r | |
20 | \r | |
21 | //\r | |
22 | // I2C bus protocol\r | |
23 | //\r | |
24 | typedef struct _EFI_I2C_BUS_PROTOCOL EFI_I2C_BUS_PROTOCOL;\r | |
25 | \r | |
26 | /**\r | |
27 | Perform an I2C operation on the device\r | |
28 | \r | |
29 | This routine must be called at or below TPL_NOTIFY. For synchronous\r | |
30 | requests this routine must be called at or below TPL_CALLBACK.\r | |
31 | \r | |
32 | N.B. The typical consumers of this API are the third party I2C\r | |
33 | drivers. Extreme care must be taken by other consumers of this\r | |
34 | API to prevent confusing the third party I2C drivers due to a\r | |
35 | state change at the I2C device which the third party I2C drivers\r | |
36 | did not initiate. I2C platform drivers may use this API within\r | |
37 | these guidelines.\r | |
38 | \r | |
39 | This routine queues an operation to the I2C controller for execution\r | |
40 | on the I2C bus.\r | |
41 | \r | |
42 | As an upper layer driver writer, the following need to be provided\r | |
43 | to the platform vendor:\r | |
44 | \r | |
45 | 1. ACPI CID value or string - this is used to connect the upper layer\r | |
46 | driver to the device.\r | |
47 | 2. Slave address array guidance when the I2C device uses more than one\r | |
48 | slave address. This is used to access the blocks of hardware within\r | |
49 | the I2C device.\r | |
50 | \r | |
51 | @param[in] This Address of an EFI_I2C_BUS_PROTOCOL\r | |
52 | structure\r | |
53 | @param[in] SlaveAddressIndex Index into an array of slave addresses for\r | |
54 | the I2C device. The values in the array are\r | |
55 | specified by the board designer, with the\r | |
56 | I2C device driver writer providing the slave\r | |
57 | address order.\r | |
58 | \r | |
59 | For devices that have a single slave address,\r | |
60 | this value must be zero. If the I2C device\r | |
61 | uses more than one slave address then the third\r | |
62 | party (upper level) I2C driver writer needs to\r | |
63 | specify the order of entries in the slave address\r | |
64 | array.\r | |
65 | \r | |
66 | \ref ThirdPartyI2cDrivers "Third Party I2C Drivers"\r | |
67 | section in I2cMaster.h.\r | |
68 | @param[in] Event Event to set for asynchronous operations,\r | |
69 | NULL for synchronous operations\r | |
70 | @param[in] RequestPacket Address of an EFI_I2C_REQUEST_PACKET\r | |
71 | structure describing the I2C operation\r | |
72 | @param[out] I2cStatus Optional buffer to receive the I2C operation\r | |
73 | completion status\r | |
74 | \r | |
75 | @retval EFI_SUCCESS The operation completed successfully.\r | |
76 | @retval EFI_ABORTED The request did not complete because the driver\r | |
77 | was shutdown.\r | |
78 | @retval EFI_ACCESS_DENIED Invalid SlaveAddressIndex value\r | |
79 | @retval EFI_BAD_BUFFER_SIZE The WriteBytes or ReadBytes buffer size is too large.\r | |
80 | @retval EFI_DEVICE_ERROR There was an I2C error (NACK) during the operation.\r | |
81 | This could indicate the slave device is not present.\r | |
82 | @retval EFI_INVALID_PARAMETER RequestPacket is NULL\r | |
83 | @retval EFI_INVALID_PARAMETER TPL is too high\r | |
84 | @retval EFI_NO_RESPONSE The I2C device is not responding to the\r | |
85 | slave address. EFI_DEVICE_ERROR may also be\r | |
86 | returned if the controller can not distinguish\r | |
87 | when the NACK occurred.\r | |
88 | @retval EFI_NOT_FOUND I2C slave address exceeds maximum address\r | |
89 | @retval EFI_NOT_READY I2C bus is busy or operation pending, wait for\r | |
90 | the event and then read status pointed to by\r | |
91 | the request packet.\r | |
92 | @retval EFI_OUT_OF_RESOURCES Insufficient memory for I2C operation\r | |
93 | @retval EFI_TIMEOUT The transaction did not complete within an internally\r | |
94 | specified timeout period.\r | |
95 | \r | |
96 | **/\r | |
97 | typedef\r | |
98 | EFI_STATUS\r | |
99 | (EFIAPI *EFI_I2C_BUS_START_REQUEST) (\r | |
100 | IN CONST EFI_I2C_BUS_PROTOCOL *This,\r | |
101 | IN UINTN SlaveAddressIndex,\r | |
102 | IN EFI_EVENT Event OPTIONAL,\r | |
103 | IN CONST EFI_I2C_REQUEST_PACKET *RequestPacket,\r | |
104 | OUT EFI_STATUS *I2cStatus OPTIONAL\r | |
105 | );\r | |
106 | \r | |
107 | //\r | |
108 | // The I2C bus protocol enables access to a specific device on the I2C bus.\r | |
109 | //\r | |
110 | // Each I2C device is described as an ACPI node (HID, UID and CID) within the\r | |
111 | // platform layer. The I2C bus protocol enumerates the I2C devices in the\r | |
112 | // platform and creates a unique handle and device path for each I2C device.\r | |
113 | //\r | |
114 | // I2C slave addressing is abstracted to validate addresses and limit operation\r | |
115 | // to the specified I2C device. The third party providing the I2C device support\r | |
116 | // provides an ordered list of slave addresses for the I2C device to the team\r | |
117 | // building the platform layer. The platform team must preserve the order of the\r | |
118 | // supplied list. SlaveAddressCount is the number of entries in this list or\r | |
119 | // array within the platform layer. The third party device support references\r | |
120 | // a slave address using an index into the list or array in the range of zero\r | |
121 | // to SlaveAddressCount - 1.\r | |
122 | //\r | |
123 | struct _EFI_I2C_BUS_PROTOCOL {\r | |
124 | //\r | |
125 | // Start an I2C operation on the bus\r | |
126 | //\r | |
127 | EFI_I2C_BUS_START_REQUEST StartRequest;\r | |
128 | \r | |
129 | //\r | |
130 | // The maximum number of slave addresses for the I2C device. The caller may\r | |
131 | // validate this value as a check on the platform layer's configuration. Slave\r | |
132 | // address selection uses an index value in the range of zero to SlaveAddressCount - 1.\r | |
133 | //\r | |
134 | UINTN SlaveAddressCount;\r | |
135 | \r | |
136 | //\r | |
137 | // Hardware revision - Matches the ACPI _HRV value\r | |
138 | //\r | |
139 | // The HardwareRevision value allows a single driver to support multiple hardware\r | |
140 | // revisions and implement the necessary workarounds for limitations within the\r | |
141 | // hardware.\r | |
142 | //\r | |
143 | UINT32 HardwareRevision;\r | |
144 | \r | |
145 | //\r | |
146 | // The maximum number of bytes the I2C host controller\r | |
147 | // is able to receive from the I2C bus.\r | |
148 | ///\r | |
149 | UINT32 MaximumReceiveBytes;\r | |
150 | \r | |
151 | //\r | |
152 | // The maximum number of bytes the I2C host controller\r | |
153 | // is able to send on the I2C bus.\r | |
154 | //\r | |
155 | UINT32 MaximumTransmitBytes;\r | |
156 | \r | |
157 | //\r | |
158 | // The maximum number of bytes in the I2C bus transaction.\r | |
159 | //\r | |
160 | UINT32 MaximumTotalBytes;\r | |
161 | };\r | |
162 | \r | |
163 | //\r | |
164 | // GUID for the I2C bus protocol\r | |
165 | //\r | |
166 | extern EFI_GUID gEfiI2cBusProtocolGuid;\r | |
167 | \r | |
168 | #endif // __I2C_BUS_H__\r |