2 Provides the definition of Usb Hc Protocol and OHCI controller
3 private data structure.
5 Copyright (c) 2013-2015 Intel Corporation.
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
24 #include <Ppi/UsbController.h>
25 #include <Ppi/UsbHostController.h>
27 #include <Library/DebugLib.h>
28 #include <Library/PeimEntryPoint.h>
29 #include <Library/PeiServicesLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/TimerLib.h>
32 #include <Library/IoLib.h>
34 typedef struct _USB_OHCI_HC_DEV USB_OHCI_HC_DEV
;
38 #include "OhciSched.h"
40 #include "Descriptor.h"
42 #define EFI_USB_SPEED_FULL 0x0000
43 #define EFI_USB_SPEED_LOW 0x0001
44 #define EFI_USB_SPEED_HIGH 0x0002
48 #define HC_1_MICROSECOND 1
49 #define HC_1_MILLISECOND (1000 * HC_1_MICROSECOND)
50 #define HC_1_SECOND (1000 * HC_1_MILLISECOND)
53 #define USB_OHCI_HC_DEV_SIGNATURE SIGNATURE_32('o','h','c','i')
55 struct _USB_OHCI_HC_DEV
{
57 PEI_USB_HOST_CONTROLLER_PPI UsbHostControllerPpi
;
58 EFI_PEI_PPI_DESCRIPTOR PpiDescriptor
;
59 UINT32 UsbHostControllerBaseAddress
;
63 #define PEI_RECOVERY_USB_OHC_DEV_FROM_EHCI_THIS(a) CR (a, USB_OHCI_HC_DEV, UsbHostControllerPpi, USB_OHCI_HC_DEV_SIGNATURE)
70 Provides software reset for the USB host controller.
72 @param PeiServices The pointer of EFI_PEI_SERVICES.
73 @param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.
74 @param Attributes A bit mask of the reset operation to perform.
76 @retval EFI_SUCCESS The reset operation succeeded.
77 @retval EFI_INVALID_PARAMETER Attributes is not valid.
78 @retval EFI_UNSUPPOURTED The type of reset specified by Attributes is
79 not currently supported by the host controller.
80 @retval EFI_DEVICE_ERROR Host controller isn't halted to reset.
85 IN EFI_PEI_SERVICES
**PeiServices
,
86 IN USB_OHCI_HC_DEV
*Ohc
,
91 Submits control transfer to a target USB device.
93 @param PeiServices The pointer of EFI_PEI_SERVICES.
94 @param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.
95 @param DeviceAddress The target device address.
96 @param DeviceSpeed Target device speed.
97 @param MaximumPacketLength Maximum packet size the default control transfer
98 endpoint is capable of sending or receiving.
99 @param Request USB device request to send.
100 @param TransferDirection Specifies the data direction for the data stage.
101 @param Data Data buffer to be transmitted or received from USB device.
102 @param DataLength The size (in bytes) of the data buffer.
103 @param TimeOut Indicates the maximum timeout, in millisecond.
104 @param TransferResult Return the result of this control transfer.
106 @retval EFI_SUCCESS Transfer was completed successfully.
107 @retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resources.
108 @retval EFI_INVALID_PARAMETER Some parameters are invalid.
109 @retval EFI_TIMEOUT Transfer failed due to timeout.
110 @retval EFI_DEVICE_ERROR Transfer failed due to host controller or device error.
115 OhciControlTransfer (
116 IN EFI_PEI_SERVICES
**PeiServices
,
117 IN PEI_USB_HOST_CONTROLLER_PPI
*This
,
118 IN UINT8 DeviceAddress
,
119 IN UINT8 DeviceSpeed
,
120 IN UINT8 MaxPacketLength
,
121 IN EFI_USB_DEVICE_REQUEST
*Request
,
122 IN EFI_USB_DATA_DIRECTION TransferDirection
,
124 IN OUT UINTN
*DataLength
,
126 OUT UINT32
*TransferResult
129 Submits bulk transfer to a bulk endpoint of a USB device.
131 @param PeiServices The pointer of EFI_PEI_SERVICES.
132 @param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.
133 @param DeviceAddress Target device address.
134 @param EndPointAddress Endpoint number and its direction in bit 7.
135 @param MaxiPacketLength Maximum packet size the endpoint is capable of
136 sending or receiving.
137 @param Data A pointers to the buffers of data to transmit
138 from or receive into.
139 @param DataLength The lenght of the data buffer.
140 @param DataToggle On input, the initial data toggle for the transfer;
141 On output, it is updated to to next data toggle to use of
142 the subsequent bulk transfer.
143 @param TimeOut Indicates the maximum time, in millisecond, which the
144 transfer is allowed to complete.
145 @param TransferResult A pointer to the detailed result information of the
148 @retval EFI_SUCCESS The transfer was completed successfully.
149 @retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resource.
150 @retval EFI_INVALID_PARAMETER Parameters are invalid.
151 @retval EFI_TIMEOUT The transfer failed due to timeout.
152 @retval EFI_DEVICE_ERROR The transfer failed due to host controller error.
158 IN EFI_PEI_SERVICES
**PeiServices
,
159 IN PEI_USB_HOST_CONTROLLER_PPI
*This
,
160 IN UINT8 DeviceAddress
,
161 IN UINT8 EndPointAddress
,
162 IN UINT8 MaxPacketLength
,
164 IN OUT UINTN
*DataLength
,
165 IN OUT UINT8
*DataToggle
,
167 OUT UINT32
*TransferResult
170 Retrieves the number of root hub ports.
172 @param[in] PeiServices The pointer to the PEI Services Table.
173 @param[in] This The pointer to this instance of the
174 PEI_USB_HOST_CONTROLLER_PPI.
175 @param[out] NumOfPorts The pointer to the number of the root hub ports.
177 @retval EFI_SUCCESS The port number was retrieved successfully.
178 @retval EFI_INVALID_PARAMETER PortNumber is NULL.
184 OhciGetRootHubNumOfPorts (
185 IN EFI_PEI_SERVICES
**PeiServices
,
186 IN PEI_USB_HOST_CONTROLLER_PPI
*This
,
187 OUT UINT8
*NumOfPorts
190 Retrieves the current status of a USB root hub port.
192 @param PeiServices The pointer of EFI_PEI_SERVICES.
193 @param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.
194 @param PortNumber The root hub port to retrieve the state from.
195 @param PortStatus Variable to receive the port state.
197 @retval EFI_SUCCESS The status of the USB root hub port specified.
198 by PortNumber was returned in PortStatus.
199 @retval EFI_INVALID_PARAMETER PortNumber is invalid.
205 OhciGetRootHubPortStatus (
206 IN EFI_PEI_SERVICES
**PeiServices
,
207 IN PEI_USB_HOST_CONTROLLER_PPI
*This
,
209 OUT EFI_USB_PORT_STATUS
*PortStatus
213 Sets a feature for the specified root hub port.
215 @param This A pointer to the EFI_USB_HC_PROTOCOL.
216 @param PortNumber Specifies the root hub port whose feature
217 is requested to be set.
218 @param PortFeature Indicates the feature selector associated
219 with the feature set request.
221 @retval EFI_SUCCESS The feature specified by PortFeature was set for the
222 USB root hub port specified by PortNumber.
223 @retval EFI_DEVICE_ERROR Set feature failed because of hardware issue
224 @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid.
228 OhciSetRootHubPortFeature (
229 IN EFI_PEI_SERVICES
**PeiServices
,
230 IN PEI_USB_HOST_CONTROLLER_PPI
*This
,
232 IN EFI_USB_PORT_FEATURE PortFeature
235 Clears a feature for the specified root hub port.
237 @param PeiServices The pointer of EFI_PEI_SERVICES.
238 @param This The pointer of PEI_USB_HOST_CONTROLLER_PPI.
239 @param PortNumber Specifies the root hub port whose feature
240 is requested to be cleared.
241 @param PortFeature Indicates the feature selector associated with the
242 feature clear request.
244 @retval EFI_SUCCESS The feature specified by PortFeature was cleared
245 for the USB root hub port specified by PortNumber.
246 @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid.
252 OhciClearRootHubPortFeature (
253 IN EFI_PEI_SERVICES
**PeiServices
,
254 IN PEI_USB_HOST_CONTROLLER_PPI
*This
,
256 IN EFI_USB_PORT_FEATURE PortFeature