2 Provides the definition of Usb Hc Protocol and OHCI controller
3 private data structure.
5 Copyright (c) 2013-2015 Intel Corporation.
7 SPDX-License-Identifier: BSD-2-Clause-Patent
18 #include <Ppi/UsbController.h>
19 #include <Ppi/UsbHostController.h>
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>
28 typedef struct _USB_OHCI_HC_DEV USB_OHCI_HC_DEV
;
32 #include "OhciSched.h"
34 #include "Descriptor.h"
36 #define EFI_USB_SPEED_FULL 0x0000
37 #define EFI_USB_SPEED_LOW 0x0001
38 #define EFI_USB_SPEED_HIGH 0x0002
42 #define HC_1_MICROSECOND 1
43 #define HC_1_MILLISECOND (1000 * HC_1_MICROSECOND)
44 #define HC_1_SECOND (1000 * HC_1_MILLISECOND)
47 #define USB_OHCI_HC_DEV_SIGNATURE SIGNATURE_32('o','h','c','i')
49 struct _USB_OHCI_HC_DEV
{
51 PEI_USB_HOST_CONTROLLER_PPI UsbHostControllerPpi
;
52 EFI_PEI_PPI_DESCRIPTOR PpiDescriptor
;
53 UINT32 UsbHostControllerBaseAddress
;
57 #define PEI_RECOVERY_USB_OHC_DEV_FROM_EHCI_THIS(a) CR (a, USB_OHCI_HC_DEV, UsbHostControllerPpi, USB_OHCI_HC_DEV_SIGNATURE)
64 Provides software reset for the USB host controller.
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.
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.
79 IN EFI_PEI_SERVICES
**PeiServices
,
80 IN USB_OHCI_HC_DEV
*Ohc
,
85 Submits control transfer to a target USB device.
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.
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.
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
,
118 IN OUT UINTN
*DataLength
,
120 OUT UINT32
*TransferResult
123 Submits bulk transfer to a bulk endpoint of a USB device.
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
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.
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
,
158 IN OUT UINTN
*DataLength
,
159 IN OUT UINT8
*DataToggle
,
161 OUT UINT32
*TransferResult
164 Retrieves the number of root hub ports.
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.
171 @retval EFI_SUCCESS The port number was retrieved successfully.
172 @retval EFI_INVALID_PARAMETER PortNumber is NULL.
178 OhciGetRootHubNumOfPorts (
179 IN EFI_PEI_SERVICES
**PeiServices
,
180 IN PEI_USB_HOST_CONTROLLER_PPI
*This
,
181 OUT UINT8
*NumOfPorts
184 Retrieves the current status of a USB root hub port.
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.
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.
199 OhciGetRootHubPortStatus (
200 IN EFI_PEI_SERVICES
**PeiServices
,
201 IN PEI_USB_HOST_CONTROLLER_PPI
*This
,
203 OUT EFI_USB_PORT_STATUS
*PortStatus
207 Sets a feature for the specified root hub port.
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.
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.
222 OhciSetRootHubPortFeature (
223 IN EFI_PEI_SERVICES
**PeiServices
,
224 IN PEI_USB_HOST_CONTROLLER_PPI
*This
,
226 IN EFI_USB_PORT_FEATURE PortFeature
229 Clears a feature for the specified root hub port.
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.
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.
246 OhciClearRootHubPortFeature (
247 IN EFI_PEI_SERVICES
**PeiServices
,
248 IN PEI_USB_HOST_CONTROLLER_PPI
*This
,
250 IN EFI_USB_PORT_FEATURE PortFeature