]>
Commit | Line | Data |
---|---|---|
9b6bbcdb MK |
1 | /** @file\r |
2 | Provides the definition of Usb Hc Protocol and OHCI controller\r | |
3 | private data structure.\r | |
4 | \r | |
5 | Copyright (c) 2013-2015 Intel Corporation.\r | |
6 | \r | |
c9f231d0 | 7 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
9b6bbcdb MK |
8 | \r |
9 | **/\r | |
10 | \r | |
11 | \r | |
12 | \r | |
13 | #ifndef _OHCI_PEIM_H\r | |
14 | #define _OHCI_PEIM_H\r | |
15 | \r | |
16 | #include <PiPei.h>\r | |
17 | \r | |
18 | #include <Ppi/UsbController.h>\r | |
19 | #include <Ppi/UsbHostController.h>\r | |
20 | \r | |
21 | #include <Library/DebugLib.h>\r | |
22 | #include <Library/PeimEntryPoint.h>\r | |
23 | #include <Library/PeiServicesLib.h>\r | |
24 | #include <Library/BaseMemoryLib.h>\r | |
25 | #include <Library/TimerLib.h>\r | |
26 | #include <Library/IoLib.h>\r | |
27 | \r | |
28 | typedef struct _USB_OHCI_HC_DEV USB_OHCI_HC_DEV;\r | |
29 | \r | |
30 | #include "UsbHcMem.h"\r | |
31 | #include "OhciReg.h"\r | |
32 | #include "OhciSched.h"\r | |
33 | #include "OhciUrb.h"\r | |
34 | #include "Descriptor.h"\r | |
35 | \r | |
36 | #define EFI_USB_SPEED_FULL 0x0000\r | |
37 | #define EFI_USB_SPEED_LOW 0x0001\r | |
38 | #define EFI_USB_SPEED_HIGH 0x0002\r | |
39 | \r | |
40 | #define PAGESIZE 4096\r | |
41 | \r | |
42 | #define HC_1_MICROSECOND 1\r | |
43 | #define HC_1_MILLISECOND (1000 * HC_1_MICROSECOND)\r | |
44 | #define HC_1_SECOND (1000 * HC_1_MILLISECOND)\r | |
45 | \r | |
46 | \r | |
47 | #define USB_OHCI_HC_DEV_SIGNATURE SIGNATURE_32('o','h','c','i')\r | |
48 | \r | |
49 | struct _USB_OHCI_HC_DEV {\r | |
50 | UINTN Signature;\r | |
51 | PEI_USB_HOST_CONTROLLER_PPI UsbHostControllerPpi;\r | |
52 | EFI_PEI_PPI_DESCRIPTOR PpiDescriptor;\r | |
53 | UINT32 UsbHostControllerBaseAddress;\r | |
54 | VOID *MemPool;\r | |
55 | };\r | |
56 | \r | |
57 | #define PEI_RECOVERY_USB_OHC_DEV_FROM_EHCI_THIS(a) CR (a, USB_OHCI_HC_DEV, UsbHostControllerPpi, USB_OHCI_HC_DEV_SIGNATURE)\r | |
58 | \r | |
59 | //\r | |
60 | // Func List\r | |
61 | //\r | |
62 | \r | |
63 | /**\r | |
64 | Provides software reset for the USB host controller.\r | |
65 | \r | |
66 | @param PeiServices The pointer of EFI_PEI_SERVICES.\r | |
67 | @param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.\r | |
68 | @param Attributes A bit mask of the reset operation to perform.\r | |
69 | \r | |
70 | @retval EFI_SUCCESS The reset operation succeeded.\r | |
71 | @retval EFI_INVALID_PARAMETER Attributes is not valid.\r | |
72 | @retval EFI_UNSUPPOURTED The type of reset specified by Attributes is\r | |
73 | not currently supported by the host controller.\r | |
74 | @retval EFI_DEVICE_ERROR Host controller isn't halted to reset.\r | |
75 | \r | |
76 | **/\r | |
77 | EFI_STATUS\r | |
78 | InitializeUsbHC (\r | |
79 | IN EFI_PEI_SERVICES **PeiServices,\r | |
80 | IN USB_OHCI_HC_DEV *Ohc,\r | |
81 | IN UINT16 Attributes\r | |
82 | );\r | |
83 | \r | |
84 | /**\r | |
85 | Submits control transfer to a target USB device.\r | |
86 | \r | |
87 | @param PeiServices The pointer of EFI_PEI_SERVICES.\r | |
88 | @param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.\r | |
89 | @param DeviceAddress The target device address.\r | |
90 | @param DeviceSpeed Target device speed.\r | |
91 | @param MaximumPacketLength Maximum packet size the default control transfer\r | |
92 | endpoint is capable of sending or receiving.\r | |
93 | @param Request USB device request to send.\r | |
94 | @param TransferDirection Specifies the data direction for the data stage.\r | |
95 | @param Data Data buffer to be transmitted or received from USB device.\r | |
96 | @param DataLength The size (in bytes) of the data buffer.\r | |
97 | @param TimeOut Indicates the maximum timeout, in millisecond.\r | |
98 | @param TransferResult Return the result of this control transfer.\r | |
99 | \r | |
100 | @retval EFI_SUCCESS Transfer was completed successfully.\r | |
101 | @retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resources.\r | |
102 | @retval EFI_INVALID_PARAMETER Some parameters are invalid.\r | |
103 | @retval EFI_TIMEOUT Transfer failed due to timeout.\r | |
104 | @retval EFI_DEVICE_ERROR Transfer failed due to host controller or device error.\r | |
105 | \r | |
106 | **/\r | |
107 | EFI_STATUS\r | |
108 | EFIAPI\r | |
109 | OhciControlTransfer (\r | |
110 | IN EFI_PEI_SERVICES **PeiServices,\r | |
111 | IN PEI_USB_HOST_CONTROLLER_PPI *This,\r | |
112 | IN UINT8 DeviceAddress,\r | |
113 | IN UINT8 DeviceSpeed,\r | |
114 | IN UINT8 MaxPacketLength,\r | |
115 | IN EFI_USB_DEVICE_REQUEST *Request,\r | |
116 | IN EFI_USB_DATA_DIRECTION TransferDirection,\r | |
117 | IN OUT VOID *Data,\r | |
118 | IN OUT UINTN *DataLength,\r | |
119 | IN UINTN TimeOut,\r | |
120 | OUT UINT32 *TransferResult\r | |
121 | );\r | |
122 | /**\r | |
123 | Submits bulk transfer to a bulk endpoint of a USB device.\r | |
124 | \r | |
125 | @param PeiServices The pointer of EFI_PEI_SERVICES.\r | |
126 | @param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.\r | |
127 | @param DeviceAddress Target device address.\r | |
128 | @param EndPointAddress Endpoint number and its direction in bit 7.\r | |
129 | @param MaxiPacketLength Maximum packet size the endpoint is capable of\r | |
130 | sending or receiving.\r | |
131 | @param Data A pointers to the buffers of data to transmit\r | |
132 | from or receive into.\r | |
133 | @param DataLength The lenght of the data buffer.\r | |
134 | @param DataToggle On input, the initial data toggle for the transfer;\r | |
135 | On output, it is updated to to next data toggle to use of\r | |
136 | the subsequent bulk transfer.\r | |
137 | @param TimeOut Indicates the maximum time, in millisecond, which the\r | |
138 | transfer is allowed to complete.\r | |
139 | @param TransferResult A pointer to the detailed result information of the\r | |
140 | bulk transfer.\r | |
141 | \r | |
142 | @retval EFI_SUCCESS The transfer was completed successfully.\r | |
143 | @retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resource.\r | |
144 | @retval EFI_INVALID_PARAMETER Parameters are invalid.\r | |
145 | @retval EFI_TIMEOUT The transfer failed due to timeout.\r | |
146 | @retval EFI_DEVICE_ERROR The transfer failed due to host controller error.\r | |
147 | \r | |
148 | **/\r | |
149 | EFI_STATUS\r | |
150 | EFIAPI\r | |
151 | OhciBulkTransfer (\r | |
152 | IN EFI_PEI_SERVICES **PeiServices,\r | |
153 | IN PEI_USB_HOST_CONTROLLER_PPI *This,\r | |
154 | IN UINT8 DeviceAddress,\r | |
155 | IN UINT8 EndPointAddress,\r | |
156 | IN UINT8 MaxPacketLength,\r | |
157 | IN OUT VOID *Data,\r | |
158 | IN OUT UINTN *DataLength,\r | |
159 | IN OUT UINT8 *DataToggle,\r | |
160 | IN UINTN TimeOut,\r | |
161 | OUT UINT32 *TransferResult\r | |
162 | );\r | |
163 | /**\r | |
164 | Retrieves the number of root hub ports.\r | |
165 | \r | |
166 | @param[in] PeiServices The pointer to the PEI Services Table.\r | |
167 | @param[in] This The pointer to this instance of the\r | |
168 | PEI_USB_HOST_CONTROLLER_PPI.\r | |
169 | @param[out] NumOfPorts The pointer to the number of the root hub ports.\r | |
170 | \r | |
171 | @retval EFI_SUCCESS The port number was retrieved successfully.\r | |
172 | @retval EFI_INVALID_PARAMETER PortNumber is NULL.\r | |
173 | \r | |
174 | **/\r | |
175 | \r | |
176 | EFI_STATUS\r | |
177 | EFIAPI\r | |
178 | OhciGetRootHubNumOfPorts (\r | |
179 | IN EFI_PEI_SERVICES **PeiServices,\r | |
180 | IN PEI_USB_HOST_CONTROLLER_PPI *This,\r | |
181 | OUT UINT8 *NumOfPorts\r | |
182 | );\r | |
183 | /**\r | |
184 | Retrieves the current status of a USB root hub port.\r | |
185 | \r | |
186 | @param PeiServices The pointer of EFI_PEI_SERVICES.\r | |
187 | @param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.\r | |
188 | @param PortNumber The root hub port to retrieve the state from.\r | |
189 | @param PortStatus Variable to receive the port state.\r | |
190 | \r | |
191 | @retval EFI_SUCCESS The status of the USB root hub port specified.\r | |
192 | by PortNumber was returned in PortStatus.\r | |
193 | @retval EFI_INVALID_PARAMETER PortNumber is invalid.\r | |
194 | \r | |
195 | **/\r | |
196 | \r | |
197 | EFI_STATUS\r | |
198 | EFIAPI\r | |
199 | OhciGetRootHubPortStatus (\r | |
200 | IN EFI_PEI_SERVICES **PeiServices,\r | |
201 | IN PEI_USB_HOST_CONTROLLER_PPI *This,\r | |
202 | IN UINT8 PortNumber,\r | |
203 | OUT EFI_USB_PORT_STATUS *PortStatus\r | |
204 | );\r | |
205 | /**\r | |
206 | \r | |
207 | Sets a feature for the specified root hub port.\r | |
208 | \r | |
209 | @param This A pointer to the EFI_USB_HC_PROTOCOL.\r | |
210 | @param PortNumber Specifies the root hub port whose feature\r | |
211 | is requested to be set.\r | |
212 | @param PortFeature Indicates the feature selector associated\r | |
213 | with the feature set request.\r | |
214 | \r | |
215 | @retval EFI_SUCCESS The feature specified by PortFeature was set for the\r | |
216 | USB root hub port specified by PortNumber.\r | |
217 | @retval EFI_DEVICE_ERROR Set feature failed because of hardware issue\r | |
218 | @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid.\r | |
219 | **/\r | |
220 | EFI_STATUS\r | |
221 | EFIAPI\r | |
222 | OhciSetRootHubPortFeature (\r | |
223 | IN EFI_PEI_SERVICES **PeiServices,\r | |
224 | IN PEI_USB_HOST_CONTROLLER_PPI *This,\r | |
225 | IN UINT8 PortNumber,\r | |
226 | IN EFI_USB_PORT_FEATURE PortFeature\r | |
227 | );\r | |
228 | /**\r | |
229 | Clears a feature for the specified root hub port.\r | |
230 | \r | |
231 | @param PeiServices The pointer of EFI_PEI_SERVICES.\r | |
232 | @param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.\r | |
233 | @param PortNumber Specifies the root hub port whose feature\r | |
234 | is requested to be cleared.\r | |
235 | @param PortFeature Indicates the feature selector associated with the\r | |
236 | feature clear request.\r | |
237 | \r | |
238 | @retval EFI_SUCCESS The feature specified by PortFeature was cleared\r | |
239 | for the USB root hub port specified by PortNumber.\r | |
240 | @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid.\r | |
241 | \r | |
242 | **/\r | |
243 | \r | |
244 | EFI_STATUS\r | |
245 | EFIAPI\r | |
246 | OhciClearRootHubPortFeature (\r | |
247 | IN EFI_PEI_SERVICES **PeiServices,\r | |
248 | IN PEI_USB_HOST_CONTROLLER_PPI *This,\r | |
249 | IN UINT8 PortNumber,\r | |
250 | IN EFI_USB_PORT_FEATURE PortFeature\r | |
251 | );\r | |
252 | #endif\r |