MdePkg, MdeModulePkg: Remove EFI_ABORTED from I2C protocols per PI spec 1.4.
[mirror_edk2.git] / MdePkg / Include / Protocol / I2cIo.h
CommitLineData
4006b0b5
EL
1/** @file\r
2 I2C I/O Protocol as defined in the PI 1.3 specification.\r
3\r
4 The EFI I2C I/O protocol enables the user to manipulate a single \r
5 I2C device independent of the host controller and I2C design.\r
6\r
1d956501 7 Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>\r
4006b0b5
EL
8 This program and the accompanying materials \r
9 are licensed and made available under the terms and conditions of the BSD License \r
10 which accompanies this distribution. The full text of the license may be found at \r
11 http://opensource.org/licenses/bsd-license.php \r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
15\r
16 @par Revision Reference:\r
17 This protocol is from PI Version 1.3.\r
18\r
19**/\r
20\r
21#ifndef __I2C_IO_H__\r
22#define __I2C_IO_H__\r
23\r
24#include <Pi/PiI2c.h>\r
25\r
26#define EFI_I2C_IO_PROTOCOL_GUID { 0xb60a3e6b, 0x18c4, 0x46e5, { 0xa2, 0x9a, 0xc9, 0xa1, 0x06, 0x65, 0xa2, 0x8e }}\r
27\r
28///\r
29/// I2C I/O protocol\r
30///\r
31/// The I2C IO protocol enables access to a specific device on the I2C\r
32/// bus.\r
33///\r
34/// Each I2C device is identified uniquely in the system by the tuple\r
35/// DeviceGuid:DeviceIndex. The DeviceGuid represents the manufacture\r
36/// and part number and is provided by the silicon vendor or the third\r
37/// party I2C device driver writer. The DeviceIndex identifies the part\r
38/// within the system by using a unique number and is created by the\r
39/// board designer or the writer of the EFI_I2C_ENUMERATE_PROTOCOL.\r
40///\r
41/// I2C slave addressing is abstracted to validate addresses and limit\r
42/// operation to the specified I2C device. The third party providing\r
43/// the I2C device support provides an ordered list of slave addresses\r
44/// for the I2C device required to implement the EFI_I2C_ENUMERATE_PROTOCOL.\r
45/// The order of the list must be preserved.\r
46///\r
47typedef struct _EFI_I2C_IO_PROTOCOL EFI_I2C_IO_PROTOCOL;\r
48\r
49\r
50/**\r
51 Queue an I2C transaction for execution on the I2C device.\r
52\r
53 This routine must be called at or below TPL_NOTIFY. For synchronous\r
54 requests this routine must be called at or below TPL_CALLBACK.\r
55\r
56 This routine queues an I2C transaction to the I2C controller for\r
57 execution on the I2C bus.\r
58\r
59 When Event is NULL, QueueRequest() operates synchronously and returns\r
60 the I2C completion status as its return value.\r
61\r
62 When Event is not NULL, QueueRequest() synchronously returns EFI_SUCCESS\r
63 indicating that the asynchronous I2C transaction was queued. The values\r
64 above are returned in the buffer pointed to by I2cStatus upon the\r
65 completion of the I2C transaction when I2cStatus is not NULL.\r
66\r
67 The upper layer driver writer provides the following to the platform\r
68 vendor:\r
69 \r
70 1. Vendor specific GUID for the I2C part\r
71 2. Guidance on proper construction of the slave address array when the\r
72 I2C device uses more than one slave address. The I2C bus protocol\r
73 uses the SlaveAddressIndex to perform relative to physical address\r
74 translation to access the blocks of hardware within the I2C device.\r
75\r
76 @param[in] This Pointer to an EFI_I2C_IO_PROTOCOL structure.\r
77 @param[in] SlaveAddressIndex Index value into an array of slave addresses\r
78 for the I2C device. The values in the array\r
79 are specified by the board designer, with the\r
80 third party I2C device driver writer providing\r
81 the slave address order.\r
82\r
83 For devices that have a single slave address,\r
84 this value must be zero. If the I2C device\r
85 uses more than one slave address then the\r
86 third party (upper level) I2C driver writer\r
87 needs to specify the order of entries in the\r
88 slave address array.\r
89\r
90 \ref ThirdPartyI2cDrivers "Third Party I2C\r
91 Drivers" section in I2cMaster.h.\r
92 @param[in] Event Event to signal for asynchronous transactions,\r
93 NULL for synchronous transactions\r
94 @param[in] RequestPacket Pointer to an EFI_I2C_REQUEST_PACKET structure\r
95 describing the I2C transaction\r
96 @param[out] I2cStatus Optional buffer to receive the I2C transaction\r
97 completion status\r
98\r
99 @retval EFI_SUCCESS The asynchronous transaction was successfully\r
100 queued when Event is not NULL.\r
101 @retval EFI_SUCCESS The transaction completed successfully when\r
102 Event is NULL.\r
4006b0b5
EL
103 @retval EFI_BAD_BUFFER_SIZE The RequestPacket->LengthInBytes value is too\r
104 large.\r
105 @retval EFI_DEVICE_ERROR There was an I2C error (NACK) during the\r
106 transaction.\r
c3afcf3a 107 @retval EFI_INVALID_PARAMETER RequestPacket is NULL.\r
4006b0b5
EL
108 @retval EFI_NO_MAPPING The EFI_I2C_HOST_PROTOCOL could not set the\r
109 bus configuration required to access this I2C\r
110 device.\r
111 @retval EFI_NO_RESPONSE The I2C device is not responding to the slave\r
112 address selected by SlaveAddressIndex.\r
113 EFI_DEVICE_ERROR will be returned if the\r
114 controller cannot distinguish when the NACK\r
115 occurred.\r
116 @retval EFI_OUT_OF_RESOURCES Insufficient memory for I2C transaction\r
117 @retval EFI_UNSUPPORTED The controller does not support the requested\r
118 transaction.\r
119\r
120**/\r
121typedef\r
122EFI_STATUS\r
123(EFIAPI *EFI_I2C_IO_PROTOCOL_QUEUE_REQUEST) (\r
124 IN CONST EFI_I2C_IO_PROTOCOL *This,\r
125 IN UINTN SlaveAddressIndex,\r
126 IN EFI_EVENT Event OPTIONAL,\r
127 IN EFI_I2C_REQUEST_PACKET *RequestPacket,\r
128 OUT EFI_STATUS *I2cStatus OPTIONAL\r
129 );\r
130\r
131///\r
132/// I2C I/O protocol\r
133///\r
134struct _EFI_I2C_IO_PROTOCOL {\r
135 ///\r
136 /// Queue an I2C transaction for execution on the I2C device.\r
137 ///\r
138 EFI_I2C_IO_PROTOCOL_QUEUE_REQUEST QueueRequest;\r
139\r
140 ///\r
141 /// Unique value assigned by the silicon manufacture or the third\r
142 /// party I2C driver writer for the I2C part. This value logically\r
143 /// combines both the manufacture name and the I2C part number into\r
144 /// a single value specified as a GUID.\r
145 ///\r
146 CONST EFI_GUID *DeviceGuid;\r
147\r
148 ///\r
149 /// Unique ID of the I2C part within the system\r
150 ///\r
151 UINT32 DeviceIndex;\r
152\r
153 ///\r
154 /// Hardware revision - ACPI _HRV value. See the Advanced Configuration\r
155 /// and Power Interface Specification, Revision 5.0 for the field format\r
156 /// and the Plug and play support for I2C web-page for restriction on values.\r
157 ///\r
158 UINT32 HardwareRevision;\r
159\r
160 ///\r
161 /// Pointer to an EFI_I2C_CONTROLLER_CAPABILITIES data structure containing\r
162 /// the capabilities of the I2C host controller.\r
163 ///\r
164 CONST EFI_I2C_CONTROLLER_CAPABILITIES *I2cControllerCapabilities;\r
165};\r
166\r
167///\r
168/// Reference to variable defined in the .DEC file\r
169///\r
170extern EFI_GUID gEfiI2cIoProtocolGuid;\r
171\r
172#endif // __I2C_IO_H__\r