]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/I2cHost.h
Add I2C related definition in PI 1.3 spec.
[mirror_edk2.git] / MdePkg / Include / Protocol / I2cHost.h
CommitLineData
4006b0b5
EL
1/** @file\r
2 I2C Host Protocol as defined in the PI 1.3 specification.\r
3\r
4 This protocol provides callers with the ability to do I/O transactions \r
5 to all of the devices on the I2C bus.\r
6\r
7 Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>\r
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_HOST_H__\r
22#define __I2C_HOST_H__\r
23\r
24#include <Pi/PiI2c.h>\r
25\r
26#define EFI_I2C_HOST_PROTOCOL_GUID { 0xa5aab9e3, 0xc727, 0x48cd, { 0x8b, 0xbf, 0x42, 0x72, 0x33, 0x85, 0x49, 0x48 }}\r
27\r
28///\r
29/// I2C Host Protocol\r
30///\r
31/// The I2C bus driver uses the services of the EFI_I2C_HOST_PROTOCOL\r
32/// to produce an instance of the EFI_I2C_IO_PROTOCOL for each I2C\r
33/// device on an I2C bus.\r
34///\r
35/// The EFI_I2C_HOST_PROTOCOL exposes an asynchronous interface to\r
36/// callers to perform transactions to any device on the I2C bus.\r
37/// Internally, the I2C host protocol manages the flow of the I2C\r
38/// transactions to the host controller, keeping them in FIFO order.\r
39/// Prior to each transaction, the I2C host protocol ensures that the\r
40/// switches and multiplexers are properly configured. The I2C host\r
41/// protocol then starts the transaction on the host controller using\r
42/// the EFI_I2C_MASTER_PROTOCOL.\r
43///\r
44typedef struct _EFI_I2C_HOST_PROTOCOL EFI_I2C_HOST_PROTOCOL;\r
45\r
46\r
47/**\r
48 Queue an I2C transaction for execution on the I2C controller.\r
49\r
50 This routine must be called at or below TPL_NOTIFY. For\r
51 synchronous requests this routine must be called at or below\r
52 TPL_CALLBACK.\r
53 \r
54 The I2C host protocol uses the concept of I2C bus configurations\r
55 to describe the I2C bus. An I2C bus configuration is defined as\r
56 a unique setting of the multiplexers and switches in the I2C bus\r
57 which enable access to one or more I2C devices. When using a\r
58 switch to divide a bus, due to bus frequency differences, the\r
59 I2C bus configuration management protocol defines an I2C bus\r
60 configuration for the I2C devices on each side of the switch.\r
61 When using a multiplexer, the I2C bus configuration management\r
62 defines an I2C bus configuration for each of the selector values\r
63 required to control the multiplexer. See Figure 1 in the I2C -bus\r
64 specification and user manual for a complex I2C bus configuration.\r
65\r
66 The I2C host protocol processes all transactions in FIFO order.\r
67 Prior to performing the transaction, the I2C host protocol calls\r
68 EnableI2cBusConfiguration to reconfigure the switches and\r
69 multiplexers in the I2C bus enabling access to the specified I2C\r
70 device. The EnableI2cBusConfiguration also selects the I2C bus\r
71 frequency for the I2C device. After the I2C bus is configured,\r
72 the I2C host protocol calls the I2C master protocol to start the\r
73 I2C transaction.\r
74\r
75 If the I2C host protocol has pending I2C transactions queued when\r
76 the driver binding Stop() routine is called then the I2C host\r
77 protocol completes all of the pending I2C transactions by returning\r
78 EFI_ABORTED status. This notifies the upper layers allowing them\r
79 to take corrective action or prepare to stop.\r
80\r
81 When Event is NULL, QueueRequest() operates synchronously and\r
82 returns the I2C completion status as its return value.\r
83\r
84 When Event is not NULL, QueueRequest() synchronously returns\r
85 EFI_SUCCESS indicating that the asynchronously I2C transaction was\r
86 queued. The values above are returned in the buffer pointed to by\r
87 I2cStatus upon the completion of the I2C transaction when I2cStatus\r
88 is not NULL.\r
89\r
90 @param[in] This Pointer to an EFI_I2C_HOST_PROTOCOL structure.\r
91 @param[in] I2cBusConfiguration I2C bus configuration to access the I2C\r
92 device\r
93 @param[in] SlaveAddress Address of the device on the I2C bus. Set\r
94 the I2C_ADDRESSING_10_BIT when using 10-bit\r
95 addresses, clear this bit for 7-bit addressing.\r
96 Bits 0-6 are used for 7-bit I2C slave addresses\r
97 and bits 0-9 are used for 10-bit I2C slave\r
98 addresses.\r
99 @param[in] Event Event to signal for asynchronous transactions,\r
100 NULL for synchronous transactions\r
101 @param[in] RequestPacket Pointer to an EFI_I2C_REQUEST_PACKET structure\r
102 describing the I2C transaction\r
103 @param[out] I2cStatus Optional buffer to receive the I2C transaction\r
104 completion status\r
105\r
106 @retval EFI_SUCCESS The asynchronous transaction was successfully\r
107 queued when Event is not NULL.\r
108 @retval EFI_SUCCESS The transaction completed successfully when\r
109 Event is NULL.\r
110 @retval EFI_ABORTED The request did not complete because the\r
111 driver binding Stop() routine was called.\r
112 @retval EFI_BAD_BUFFER_SIZE The RequestPacket->LengthInBytes value is\r
113 too large.\r
114 @retval EFI_DEVICE_ERROR There was an I2C error (NACK) during the\r
115 transaction.\r
116 @retval EFI_INVALID_PARAMETER RequestPacket is NULL\r
117 @retval EFI_NOT_FOUND Reserved bit set in the SlaveAddress parameter\r
118 @retval EFI_NO_MAPPING Invalid I2cBusConfiguration value\r
119 @retval EFI_NO_RESPONSE The I2C device is not responding to the slave\r
120 address. EFI_DEVICE_ERROR will be returned\r
121 if the controller cannot distinguish when the\r
122 NACK occurred.\r
123 @retval EFI_OUT_OF_RESOURCES Insufficient memory for I2C transaction\r
124 @retval EFI_UNSUPPORTED The controller does not support the requested\r
125 transaction.\r
126\r
127**/\r
128typedef\r
129EFI_STATUS\r
130(EFIAPI *EFI_I2C_HOST_PROTOCOL_QUEUE_REQUEST) (\r
131 IN CONST EFI_I2C_HOST_PROTOCOL *This,\r
132 IN UINTN I2cBusConfiguration,\r
133 IN UINTN SlaveAddress,\r
134 IN EFI_EVENT Event OPTIONAL,\r
135 IN EFI_I2C_REQUEST_PACKET *RequestPacket,\r
136 OUT EFI_STATUS *I2cStatus OPTIONAL\r
137 );\r
138\r
139///\r
140/// I2C Host Protocol\r
141///\r
142struct _EFI_I2C_HOST_PROTOCOL {\r
143 ///\r
144 /// Queue an I2C transaction for execution on the I2C bus\r
145 ///\r
146 EFI_I2C_HOST_PROTOCOL_QUEUE_REQUEST QueueRequest;\r
147\r
148 ///\r
149 /// Pointer to an EFI_I2C_CONTROLLER_CAPABILITIES data structure\r
150 /// containing the capabilities of the I2C host controller.\r
151 ///\r
152 CONST EFI_I2C_CONTROLLER_CAPABILITIES *I2cControllerCapabilities;\r
153};\r
154\r
155///\r
156/// Reference to variable defined in the .DEC file\r
157///\r
158extern EFI_GUID gEfiI2cHostProtocolGuid;\r
159\r
160#endif // __I2C_HOST_H__\r