3 Manage Usb Port/Hc/Etc.
5 Copyright (c) 2007, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #ifndef _EFI_USB_UTILITY_H_
17 #define _EFI_USB_UTILITY_H_
20 Get the capability of the host controller.
22 @param UsbBus The usb driver.
23 @param MaxSpeed The maximum speed this host controller supports.
24 @param NumOfPort The number of the root hub port.
25 @param Is64BitCapable Whether this controller support 64 bit addressing.
27 @retval EFI_SUCCESS The host controller capability is returned.
28 @retval Others Failed to retrieve the host controller capability.
36 OUT UINT8
*Is64BitCapable
40 Reset the host controller.
42 @param UsbBus The usb bus driver.
43 @param Attributes The reset type, only global reset is used by this driver.
45 @retval EFI_SUCCESS The reset operation succeeded.
46 @retval EFI_INVALID_PARAMETER Attributes is not valid.
47 @retval EFI_UNSUPPOURTED The type of reset specified by Attributes is
48 not currently supported by the host controller.
49 @retval EFI_DEVICE_ERROR Host controller isn't halted to reset.
58 Get the current operation state of the host controller.
60 @param UsbBus The USB bus driver.
61 @param State The host controller operation state.
63 @retval EFI_SUCCESS The operation state is returned in State.
64 @retval Others Failed to get the host controller state.
70 OUT EFI_USB_HC_STATE
*State
74 Set the host controller operation state.
76 @param UsbBus The USB bus driver.
77 @param State The state to set.
79 @retval EFI_SUCCESS The host controller is now working at State.
80 @retval Others Failed to set operation state.
86 IN EFI_USB_HC_STATE State
90 Get the root hub port state.
92 @param UsbBus The USB bus driver.
93 @param PortIndex The index of port.
94 @param PortStatus The variable to save port state.
96 @retval EFI_SUCCESS The root port state is returned in.
97 @retval Others Failed to get the root hub port state.
101 UsbHcGetRootHubPortStatus (
104 OUT EFI_USB_PORT_STATUS
*PortStatus
108 Set the root hub port feature.
110 @param UsbBus The USB bus driver.
111 @param PortIndex The port index.
112 @param Feature The port feature to set.
114 @retval EFI_SUCCESS The port feature is set.
115 @retval Others Failed to set port feature.
119 UsbHcSetRootHubPortFeature (
122 IN EFI_USB_PORT_FEATURE Feature
126 Clear the root hub port feature.
128 @param UsbBus The USB bus driver.
129 @param PortIndex The port index.
130 @param Feature The port feature to clear.
132 @retval EFI_SUCCESS The port feature is clear.
133 @retval Others Failed to clear port feature.
137 UsbHcClearRootHubPortFeature (
140 IN EFI_USB_PORT_FEATURE Feature
144 Execute a control transfer to the device.
146 @param UsbBus The USB bus driver.
147 @param DevAddr The device address.
148 @param DevSpeed The device speed.
149 @param MaxPacket Maximum packet size of endpoint 0.
150 @param Request The control transfer request.
151 @param Direction The direction of data stage.
152 @param Data The buffer holding data.
153 @param DataLength The length of the data.
154 @param TimeOut Timeout (in ms) to wait until timeout.
155 @param Translator The transaction translator for low/full speed device.
156 @param UsbResult The result of transfer.
158 @retval EFI_SUCCESS The control transfer finished without error.
159 @retval Others The control transfer failed, reason returned in UsbReslt.
163 UsbHcControlTransfer (
168 IN EFI_USB_DEVICE_REQUEST
*Request
,
169 IN EFI_USB_DATA_DIRECTION Direction
,
171 IN OUT UINTN
*DataLength
,
173 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
174 OUT UINT32
*UsbResult
178 Execute a bulk transfer to the device's endpoint.
180 @param UsbBus The USB bus driver.
181 @param DevAddr The target device address.
182 @param EpAddr The target endpoint address, with direction encoded in
184 @param DevSpeed The device's speed.
185 @param MaxPacket The endpoint's max packet size.
186 @param BufferNum The number of data buffer.
187 @param Data Array of pointers to data buffer.
188 @param DataLength The length of data buffer.
189 @param DataToggle On input, the initial data toggle to use, also return
190 the next toggle on output.
191 @param TimeOut The time to wait until timeout.
192 @param Translator The transaction translator for low/full speed device.
193 @param UsbResult The result of USB execution.
195 @retval EFI_SUCCESS The bulk transfer is finished without error.
196 @retval Others Failed to execute bulk transfer, result in UsbResult.
207 IN OUT VOID
*Data
[EFI_USB_MAX_BULK_BUFFER_NUM
],
208 IN OUT UINTN
*DataLength
,
209 IN OUT UINT8
*DataToggle
,
211 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
212 OUT UINT32
*UsbResult
216 Queue or cancel an asynchronous interrupt transfer.
218 @param UsbBus The USB bus driver.
219 @param DevAddr The target device address.
220 @param EpAddr The target endpoint address, with direction encoded in
222 @param DevSpeed The device's speed.
223 @param MaxPacket The endpoint's max packet size.
224 @param IsNewTransfer Whether this is a new request. If not, cancel the old
226 @param DataToggle Data toggle to use on input, next toggle on output.
227 @param PollingInterval The interval to poll the interrupt transfer (in ms).
228 @param DataLength The length of periodical data receive.
229 @param Translator The transaction translator for low/full speed device.
230 @param Callback Function to call when data is received.
231 @param Context The context to the callback.
233 @retval EFI_SUCCESS The asynchronous transfer is queued.
234 @retval Others Failed to queue the transfer.
238 UsbHcAsyncInterruptTransfer (
244 IN BOOLEAN IsNewTransfer
,
245 IN OUT UINT8
*DataToggle
,
246 IN UINTN PollingInterval
,
248 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
249 IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback
,
250 IN VOID
*Context OPTIONAL
254 Execute a synchronous interrupt transfer to the target endpoint.
256 @param UsbBus The USB bus driver.
257 @param DevAddr The target device address.
258 @param EpAddr The target endpoint address, with direction encoded in
260 @param DevSpeed The device's speed.
261 @param MaxPacket The endpoint's max packet size.
262 @param Data Pointer to data buffer.
263 @param DataLength The length of data buffer.
264 @param DataToggle On input, the initial data toggle to use, also return
265 the next toggle on output.
266 @param TimeOut The time to wait until timeout.
267 @param Translator The transaction translator for low/full speed device.
268 @param UsbResult The result of USB execution.
270 @retval EFI_SUCCESS The synchronous interrupt transfer is OK.
271 @retval Others Failed to execute the synchronous interrupt transfer.
275 UsbHcSyncInterruptTransfer (
282 IN OUT UINTN
*DataLength
,
283 IN OUT UINT8
*DataToggle
,
285 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
286 OUT UINT32
*UsbResult
290 Execute a synchronous Isochronous USB transfer.
292 @param UsbBus The USB bus driver.
293 @param DevAddr The target device address.
294 @param EpAddr The target endpoint address, with direction encoded in
296 @param DevSpeed The device's speed.
297 @param MaxPacket The endpoint's max packet size.
298 @param BufferNum The number of data buffer.
299 @param Data Array of pointers to data buffer.
300 @param DataLength The length of data buffer.
301 @param Translator The transaction translator for low/full speed device.
302 @param UsbResult The result of USB execution.
304 @retval EFI_UNSUPPORTED The isochronous transfer isn't supported now.
308 UsbHcIsochronousTransfer (
315 IN OUT VOID
*Data
[EFI_USB_MAX_ISO_BUFFER_NUM
],
317 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
318 OUT UINT32
*UsbResult
322 Queue an asynchronous isochronous transfer.
324 @param UsbBus The USB bus driver.
325 @param DevAddr The target device address.
326 @param EpAddr The target endpoint address, with direction encoded in
328 @param DevSpeed The device's speed.
329 @param MaxPacket The endpoint's max packet size.
330 @param BufferNum The number of data buffer.
331 @param Data Array of pointers to data buffer.
332 @param DataLength The length of data buffer.
333 @param Translator The transaction translator for low/full speed device.
334 @param Callback The function to call when data is transferred.
335 @param Context The context to the callback function.
337 @retval EFI_UNSUPPORTED The asynchronous isochronous transfer isn't supported.
341 UsbHcAsyncIsochronousTransfer (
348 IN OUT VOID
*Data
[EFI_USB_MAX_ISO_BUFFER_NUM
],
350 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR
*Translator
,
351 IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback
,
356 Open the USB host controller protocol BY_CHILD.
358 @param Bus The USB bus driver.
359 @param Child The child handle.
361 @return The open protocol return.
365 UsbOpenHostProtoByChild (
371 Close the USB host controller protocol BY_CHILD.
373 @param Bus The USB bus driver.
374 @param Child The child handle.
380 UsbCloseHostProtoByChild (
386 return the current TPL, copied from the EDKII glue lib.