TianoCore EDK2 master
Loading...
Searching...
No Matches
I2cDxe.h
Go to the documentation of this file.
1
12#ifndef __I2C_DXE_H__
13#define __I2C_DXE_H__
14
15#include <Uefi.h>
17#include <Library/DebugLib.h>
20#include <Library/TimerLib.h>
23#include <Library/UefiLib.h>
24
27#include <Protocol/I2cHost.h>
28#include <Protocol/I2cIo.h>
29#include <Protocol/I2cMaster.h>
32
33#define I2C_DEVICE_SIGNATURE SIGNATURE_32 ('I', '2', 'C', 'D')
34#define I2C_HOST_SIGNATURE SIGNATURE_32 ('I', '2', 'C', 'H')
35#define I2C_REQUEST_SIGNATURE SIGNATURE_32 ('I', '2', 'C', 'R')
36
37//
38// Synchronize access to the list of requests
39//
40#define TPL_I2C_SYNC TPL_NOTIFY
41
42//
43// I2C bus context
44//
45typedef struct {
46 EFI_I2C_ENUMERATE_PROTOCOL *I2cEnumerate;
47 EFI_I2C_HOST_PROTOCOL *I2cHost;
48 EFI_HANDLE Controller;
49 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
50 EFI_HANDLE DriverBindingHandle;
52
53//
54// I2C device context
55//
56typedef struct {
57 //
58 // Structure identification
59 //
60 UINT32 Signature;
61
62 //
63 // I2c device handle
64 //
65 EFI_HANDLE Handle;
66
67 //
68 // Upper level API to support the I2C device I/O
69 //
71
72 //
73 // Device path for this device
74 //
75 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
76
77 //
78 // Platform specific data for this device
79 //
80 CONST EFI_I2C_DEVICE *I2cDevice;
81
82 //
83 // Context for the common I/O support including the
84 // lower level API to the host controller.
85 //
86 I2C_BUS_CONTEXT *I2cBusContext;
88
89#define I2C_DEVICE_CONTEXT_FROM_PROTOCOL(a) CR (a, I2C_DEVICE_CONTEXT, I2cIo, I2C_DEVICE_SIGNATURE)
90
91//
92// I2C Request
93//
94typedef struct {
95 //
96 // Signature
97 //
98 UINT32 Signature;
99
100 //
101 // Next request in the pending request list
102 //
103 LIST_ENTRY Link;
104
105 //
106 // I2C bus configuration for the operation
107 //
108 UINTN I2cBusConfiguration;
109
110 //
111 // I2C slave address for the operation
112 //
113 UINTN SlaveAddress;
114
115 //
116 // Event to set for asynchronous operations, NULL for
117 // synchronous operations
118 //
119 EFI_EVENT Event;
120
121 //
122 // I2C operation description
123 //
124 EFI_I2C_REQUEST_PACKET *RequestPacket;
125
126 //
127 // Optional buffer to receive the I2C operation completion status
128 //
129 EFI_STATUS *Status;
131
132#define I2C_REQUEST_FROM_ENTRY(a) CR (a, I2C_REQUEST, Link, I2C_REQUEST_SIGNATURE);
133
134//
135// I2C host context
136//
137typedef struct {
138 //
139 // Structure identification
140 //
141 UINTN Signature;
142
143 //
144 // Current I2C bus configuration
145 //
146 UINTN I2cBusConfiguration;
147
148 //
149 // I2C bus configuration management event
150 //
151 EFI_EVENT I2cBusConfigurationEvent;
152
153 //
154 // I2C operation completion event
155 //
156 EFI_EVENT I2cEvent;
157
158 //
159 // I2C operation and I2C bus configuration management status
160 //
161 EFI_STATUS Status;
162
163 //
164 // I2C bus configuration management operation pending
165 //
166 BOOLEAN I2cBusConfigurationManagementPending;
167
168 //
169 // I2C request list maintained by I2C Host
170 //
171 LIST_ENTRY RequestList;
172
173 //
174 // Upper level API
175 //
176 EFI_I2C_HOST_PROTOCOL I2cHost;
177
178 //
179 // I2C bus configuration management protocol
180 //
181 EFI_I2C_BUS_CONFIGURATION_MANAGEMENT_PROTOCOL *I2cBusConfigurationManagement;
182
183 //
184 // Lower level API for I2C master (controller)
185 //
186 EFI_I2C_MASTER_PROTOCOL *I2cMaster;
188
189#define I2C_HOST_CONTEXT_FROM_PROTOCOL(a) CR (a, I2C_HOST_CONTEXT, I2cHost, I2C_HOST_SIGNATURE)
190
191//
192// Global Variables
193//
194extern EFI_COMPONENT_NAME_PROTOCOL gI2cBusComponentName;
195extern EFI_COMPONENT_NAME2_PROTOCOL gI2cBusComponentName2;
196extern EFI_DRIVER_BINDING_PROTOCOL gI2cBusDriverBinding;
197
198extern EFI_COMPONENT_NAME_PROTOCOL gI2cHostComponentName;
199extern EFI_COMPONENT_NAME2_PROTOCOL gI2cHostComponentName2;
200extern EFI_DRIVER_BINDING_PROTOCOL gI2cHostDriverBinding;
201
219 IN I2C_BUS_CONTEXT *I2cBus,
220 IN EFI_HANDLE Controller,
221 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
222 );
223
241 IN EFI_HANDLE Controller,
242 IN EFI_HANDLE Handle
243 );
244
259 IN I2C_DEVICE_CONTEXT *I2cDeviceContext,
260 IN BOOLEAN BuildControllerNode
261 );
262
338EFIAPI
341 IN UINTN SlaveAddressIndex,
342 IN EFI_EVENT Event OPTIONAL,
343 IN EFI_I2C_REQUEST_PACKET *RequestPacket,
344 OUT EFI_STATUS *I2cStatus OPTIONAL
345 );
346
390EFIAPI
393 IN EFI_HANDLE Controller,
394 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
395 );
396
433EFIAPI
436 IN EFI_HANDLE Controller,
437 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
438 );
439
467EFIAPI
470 IN EFI_HANDLE Controller,
471 IN UINTN NumberOfChildren,
472 IN EFI_HANDLE *ChildHandleBuffer
473 );
474
515EFIAPI
518 IN CHAR8 *Language,
519 OUT CHAR16 **DriverName
520 );
521
591EFIAPI
594 IN EFI_HANDLE ControllerHandle,
595 IN EFI_HANDLE ChildHandle OPTIONAL,
596 IN CHAR8 *Language,
597 OUT CHAR16 **ControllerName
598 );
599
612EFIAPI
614 IN EFI_HANDLE ImageHandle,
615 IN EFI_SYSTEM_TABLE *SystemTable
616 );
617
631EFIAPI
633 IN EFI_HANDLE ImageHandle
634 );
635
644VOID
646 IN I2C_DEVICE_CONTEXT *I2cDeviceContext
647 );
648
660 I2C_HOST_CONTEXT *I2cHost,
661 EFI_STATUS Status
662 );
663
691 I2C_HOST_CONTEXT *I2cHost
692 );
693
737EFIAPI
740 IN EFI_HANDLE Controller,
741 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
742 );
743
780EFIAPI
783 IN EFI_HANDLE Controller,
784 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
785 );
786
814EFIAPI
817 IN EFI_HANDLE Controller,
818 IN UINTN NumberOfChildren,
819 IN EFI_HANDLE *ChildHandleBuffer
820 );
821
862EFIAPI
865 IN CHAR8 *Language,
866 OUT CHAR16 **DriverName
867 );
868
938EFIAPI
941 IN EFI_HANDLE ControllerHandle,
942 IN EFI_HANDLE ChildHandle OPTIONAL,
943 IN CHAR8 *Language,
944 OUT CHAR16 **ControllerName
945 );
946
956VOID
957EFIAPI
959 IN EFI_EVENT Event,
960 IN VOID *Context
961 );
962
972VOID
973EFIAPI
975 IN EFI_EVENT Event,
976 IN VOID *Context
977 );
978
1046EFIAPI
1049 IN UINTN I2cBusConfiguration,
1050 IN UINTN SlaveAddress,
1051 IN EFI_EVENT Event OPTIONAL,
1052 IN EFI_I2C_REQUEST_PACKET *RequestPacket,
1053 OUT EFI_STATUS *I2cStatus OPTIONAL
1054 );
1055
1067EFIAPI
1069 IN EFI_HANDLE ImageHandle,
1070 IN EFI_SYSTEM_TABLE *SystemTable
1071 );
1072
1086EFIAPI
1088 IN EFI_HANDLE ImageHandle
1089 );
1090
1091#endif // __I2C_DXE_H__
UINT64 UINTN
EFI_STATUS EFIAPI I2cBusUnload(IN EFI_HANDLE ImageHandle)
Definition: I2cBus.c:1409
EFI_STATUS UnRegisterI2cDevice(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_HANDLE Handle)
Definition: I2cBus.c:1228
EFI_STATUS EFIAPI I2cBusDriverStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: I2cBus.c:557
EFI_STATUS I2cBusDevicePathAppend(IN I2C_DEVICE_CONTEXT *I2cDeviceContext, IN BOOLEAN BuildControllerNode)
Definition: I2cBus.c:1317
EFI_STATUS EFIAPI I2cHostDriverStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: I2cHost.c:319
VOID ReleaseI2cDeviceContext(IN I2C_DEVICE_CONTEXT *I2cDeviceContext)
Definition: I2cBus.c:1198
EFI_STATUS EFIAPI I2cHostUnload(IN EFI_HANDLE ImageHandle)
Definition: I2cHost.c:1125
EFI_STATUS EFIAPI I2cHostComponentNameGetDriverName(IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
Definition: I2cHost.c:89
EFI_STATUS EFIAPI I2cBusDriverSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: I2cBus.c:385
VOID EFIAPI I2cHostI2cBusConfigurationAvailable(IN EFI_EVENT Event, IN VOID *Context)
Definition: I2cHost.c:604
EFI_STATUS EFIAPI InitializeI2cHost(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: I2cHost.c:1089
EFI_STATUS EFIAPI I2cBusQueueRequest(IN CONST EFI_I2C_IO_PROTOCOL *This, IN UINTN SlaveAddressIndex, IN EFI_EVENT Event OPTIONAL, IN EFI_I2C_REQUEST_PACKET *RequestPacket, OUT EFI_STATUS *I2cStatus OPTIONAL)
Definition: I2cBus.c:1141
EFI_STATUS I2cHostRequestEnable(I2C_HOST_CONTEXT *I2cHost)
Definition: I2cHost.c:786
EFI_STATUS EFIAPI InitializeI2cBus(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: I2cBus.c:1372
EFI_STATUS EFIAPI I2cHostComponentNameGetControllerName(IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
Definition: I2cHost.c:174
EFI_STATUS EFIAPI I2cBusDriverStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: I2cBus.c:777
EFI_STATUS EFIAPI I2cHostDriverSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: I2cHost.c:229
EFI_STATUS RegisterI2cDevice(IN I2C_BUS_CONTEXT *I2cBus, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: I2cBus.c:866
EFI_STATUS EFIAPI I2cHostQueueRequest(IN CONST EFI_I2C_HOST_PROTOCOL *This, IN UINTN I2cBusConfiguration, IN UINTN SlaveAddress, IN EFI_EVENT Event OPTIONAL, IN EFI_I2C_REQUEST_PACKET *RequestPacket, OUT EFI_STATUS *I2cStatus OPTIONAL)
Definition: I2cHost.c:915
EFI_STATUS EFIAPI I2cHostDriverStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: I2cHost.c:503
EFI_STATUS EFIAPI I2cBusComponentNameGetControllerName(IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, OUT CHAR16 **ControllerName)
Definition: I2cBus.c:225
EFI_STATUS I2cHostRequestComplete(I2C_HOST_CONTEXT *I2cHost, EFI_STATUS Status)
Definition: I2cHost.c:688
VOID EFIAPI I2cHostRequestCompleteEvent(IN EFI_EVENT Event, IN VOID *Context)
Definition: I2cHost.c:746
EFI_STATUS EFIAPI I2cBusComponentNameGetDriverName(IN EFI_COMPONENT_NAME2_PROTOCOL *This, IN CHAR8 *Language, OUT CHAR16 **DriverName)
Definition: I2cBus.c:140
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33