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