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