2a9d02da07ab94009628f51bf46f6a5a067c431e
[mirror_edk2.git] / MdePkg / Include / Protocol / Usb2HostController.h
1 /** @file
2 EFI_USB2_HC_PROTOCOL as defined in UEFI 2.0.
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 Module Name: Usb2HostController.h
14
15 **/
16
17 #ifndef _USB2_HOSTCONTROLLER_H_
18 #define _USB2_HOSTCONTROLLER_H_
19
20 #define EFI_USB2_HC_PROTOCOL_GUID \
21 { \
22 0x3e745226, 0x9818, 0x45b6, {0xa2, 0xac, 0xd7, 0xcd, 0xe, 0x8b, 0xa2, 0xbc } \
23 }
24
25 //
26 // Forward reference for pure ANSI compatability
27 //
28 typedef struct _EFI_USB2_HC_PROTOCOL EFI_USB2_HC_PROTOCOL;
29
30 #define EFI_USB_SPEED_FULL 0x0000 // 12 Mb/s, USB 1.1 OHCI and UHCI HC.
31 #define EFI_USB_SPEED_LOW 0x0001 // 1 Mb/s, USB 1.1 OHCI and UHCI HC.
32 #define EFI_USB_SPEED_HIGH 0x0002 // 480 Mb/s, USB 2.0 EHCI HC.
33
34 typedef struct {
35 UINT8 TranslatorHubAddress;
36 UINT8 TranslatorPortNumber;
37 } EFI_USB2_HC_TRANSACTION_TRANSLATOR;
38
39 //
40 // Protocol definitions
41 //
42
43 /**
44 Retrieves the Host Controller capabilities.
45
46 @param This A pointer to the EFI_USB2_HC_PROTOCOL instance.
47 @param MaxSpeed Host controller data transfer speed.
48 @param PortNumber Number of the root hub ports.
49 @param Is64BitCapable TRUE if controller supports 64-bit memory addressing,
50 FALSE otherwise.
51
52 @retval EFI_SUCCESS The host controller capabilities were retrieved successfully.
53 @retval EFI_INVALID_PARAMETER One of the input args was NULL.
54 @retval EFI_DEVICE_ERROR An error was encountered while attempting to
55 retrieve the capabilities.
56
57 **/
58 typedef
59 EFI_STATUS
60 (EFIAPI *EFI_USB2_HC_PROTOCOL_GET_CAPABILITY) (
61 IN EFI_USB2_HC_PROTOCOL *This,
62 OUT UINT8 *MaxSpeed,
63 OUT UINT8 *PortNumber,
64 OUT UINT8 *Is64BitCapable
65 )
66 ;
67
68 /**
69 Provides software reset for the USB host controller.
70
71 @param This A pointer to the EFI_USB2_HC_PROTOCOL instance.
72 @param Attributes A bit mask of the reset operation to perform.
73
74 @retval EFI_SUCCESS The reset operation succeeded.
75 @retval EFI_INVALID_PARAMETER Attributes is not valid.
76 @retval EFI_UNSUPPORTED The type of reset specified by Attributes is not currently
77 supported by the host controller hardware.
78 @retval EFI_ACCESS_DENIED Reset operation is rejected due to the debug port being configured
79 and active; only EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG or
80 EFI_USB_HC_RESET_HOST_WITH_DEBUG reset Attributes can be used to
81 perform reset operation for this host controller.
82 @retval EFI_DEVICE_ERROR An error was encountered while attempting to
83 retrieve the capabilities.
84
85 **/
86 typedef
87 EFI_STATUS
88 (EFIAPI *EFI_USB2_HC_PROTOCOL_RESET) (
89 IN EFI_USB2_HC_PROTOCOL *This,
90 IN UINT16 Attributes
91 )
92 ;
93
94 /**
95 Retrieves current state of the USB host controller.
96
97 @param This A pointer to the EFI_USB2_HC_PROTOCOL instance.
98 @param State A pointer to the EFI_USB_HC_STATE data structure that
99 indicates current state of the USB host controller.
100
101 @retval EFI_SUCCESS The state information of the host controller was returned in State.
102 @retval EFI_INVALID_PARAMETER State is NULL.
103 @retval EFI_DEVICE_ERROR An error was encountered while attempting to retrieve the
104 host controller¡¯s current state.
105
106 **/
107 typedef
108 EFI_STATUS
109 (EFIAPI *EFI_USB2_HC_PROTOCOL_GET_STATE) (
110 IN EFI_USB2_HC_PROTOCOL *This,
111 OUT EFI_USB_HC_STATE *State
112 )
113 ;
114
115 /**
116 Sets the USB host controller to a specific state.
117
118 @param This A pointer to the EFI_USB2_HC_PROTOCOL instance.
119 @param State Indicates the state of the host controller that will be set.
120
121 @retval EFI_SUCCESS The USB host controller was successfully placed in the state
122 specified by State.
123 @retval EFI_INVALID_PARAMETER State is not valid.
124 @retval EFI_DEVICE_ERROR Failed to set the state specified by State due to device error.
125
126 **/
127 typedef
128 EFI_STATUS
129 (EFIAPI *EFI_USB2_HC_PROTOCOL_SET_STATE) (
130 IN EFI_USB2_HC_PROTOCOL *This,
131 IN EFI_USB_HC_STATE State
132 )
133 ;
134
135 /**
136 Submits control transfer to a target USB device.
137
138 @param This A pointer to the EFI_USB2_HC_PROTOCOL instance.
139 @param DeviceAddress Represents the address of the target device on the USB.
140 @param DeviceSpeed Indicates device speed.
141 @param MaximumPacketLength Indicates the maximum packet size that the default control transfer
142 endpoint is capable of sending or receiving.
143 @param Request A pointer to the USB device request that will be sent to the USB device.
144 @param TransferDirection Specifies the data direction for the transfer. There are three values
145 available, EfiUsbDataIn, EfiUsbDataOut and EfiUsbNoData.
146 @param Data A pointer to the buffer of data that will be transmitted to USB device or
147 received from USB device.
148 @param DataLength On input, indicates the size, in bytes, of the data buffer specified by Data.
149 On output, indicates the amount of data actually transferred.
150 @param Translator A pointer to the transaction translator data.
151 @param TimeOut Indicates the maximum time, in milliseconds, which the transfer is
152 allowed to complete.
153 @param TransferResult A pointer to the detailed result information generated by this control
154 transfer.
155
156 @retval EFI_SUCCESS The control transfer was completed successfully.
157 @retval EFI_INVALID_PARAMETER Some parameters are invalid.
158 @retval EFI_OUT_OF_RESOURCES The control transfer could not be completed due to a lack of resources.
159 @retval EFI_TIMEOUT The control transfer failed due to timeout.
160 @retval EFI_DEVICE_ERROR The control transfer failed due to host controller or device error.
161 Caller should check TransferResult for detailed error information.
162
163 **/
164 typedef
165 EFI_STATUS
166 (EFIAPI *EFI_USB2_HC_PROTOCOL_CONTROL_TRANSFER) (
167 IN EFI_USB2_HC_PROTOCOL *This,
168 IN UINT8 DeviceAddress,
169 IN UINT8 DeviceSpeed,
170 IN UINTN MaximumPacketLength,
171 IN EFI_USB_DEVICE_REQUEST *Request,
172 IN EFI_USB_DATA_DIRECTION TransferDirection,
173 IN OUT VOID *Data OPTIONAL,
174 IN OUT UINTN *DataLength OPTIONAL,
175 IN UINTN TimeOut,
176 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
177 OUT UINT32 *TransferResult
178 )
179 ;
180
181 #define EFI_USB_MAX_BULK_BUFFER_NUM 10
182
183 /**
184 Submits bulk transfer to a bulk endpoint of a USB device.
185
186 @param This A pointer to the EFI_USB2_HC_PROTOCOL instance.
187 @param DeviceAddress Represents the address of the target device on the USB.
188 @param EndPointAddress The combination of an endpoint number and an endpoint direction of the
189 target USB device.
190 @param DeviceSpeed Indicates device speed.
191 @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of
192 sending or receiving.
193 @param DataBuffersNumber Number of data buffers prepared for the transfer.
194 @param Data Array of pointers to the buffers of data that will be transmitted to USB
195 device or received from USB device.
196 @param DataLength When input, indicates the size, in bytes, of the data buffers specified by
197 Data. When output, indicates the actually transferred data size.
198 @param DataToggle A pointer to the data toggle value.
199 @param Translator A pointer to the transaction translator data.
200 @param TimeOut Indicates the maximum time, in milliseconds, which the transfer is
201 allowed to complete.
202 @param TransferResult A pointer to the detailed result information of the bulk transfer.
203
204 @retval EFI_SUCCESS The bulk transfer was completed successfully.
205 @retval EFI_INVALID_PARAMETER Some parameters are invalid.
206 @retval EFI_OUT_OF_RESOURCES The bulk transfer could not be submitted due to a lack of resources.
207 @retval EFI_TIMEOUT The bulk transfer failed due to timeout.
208 @retval EFI_DEVICE_ERROR The bulk transfer failed due to host controller or device error.
209 Caller should check TransferResult for detailed error information.
210
211 **/
212 typedef
213 EFI_STATUS
214 (EFIAPI *EFI_USB2_HC_PROTOCOL_BULK_TRANSFER) (
215 IN EFI_USB2_HC_PROTOCOL *This,
216 IN UINT8 DeviceAddress,
217 IN UINT8 EndPointAddress,
218 IN UINT8 DeviceSpeed,
219 IN UINTN MaximumPacketLength,
220 IN UINT8 DataBuffersNumber,
221 IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
222 IN OUT UINTN *DataLength,
223 IN OUT UINT8 *DataToggle,
224 IN UINTN TimeOut,
225 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
226 OUT UINT32 *TransferResult
227 )
228 ;
229
230 /**
231 Submits an asynchronous interrupt transfer to an interrupt endpoint of a USB device.
232
233 @param This A pointer to the EFI_USB2_HC_PROTOCOL instance.
234 @param DeviceAddress Represents the address of the target device on the USB.
235 @param EndPointAddress The combination of an endpoint number and an endpoint direction of the
236 target USB device.
237 @param DeviceSpeed Indicates device speed.
238 @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of
239 sending or receiving.
240 @param IsNewTransfer If TRUE, an asynchronous interrupt pipe is built between the host and the
241 target interrupt endpoint. If FALSE, the specified asynchronous interrupt
242 pipe is canceled. If TRUE, and an interrupt transfer exists for the target
243 end point, then EFI_INVALID_PARAMETER is returned.
244 @param DataToggle A pointer to the data toggle value.
245 @param PollingInterval Indicates the interval, in milliseconds, that the asynchronous interrupt
246 transfer is polled.
247 @param DataLength Indicates the length of data to be received at the rate specified by
248 PollingInterval from the target asynchronous interrupt endpoint.
249 @param CallBackFunction The Callback function. This function is called at the rate specified by
250 PollingInterval.
251 @param Context The context that is passed to the CallBackFunction. This is an
252 optional parameter and may be NULL.
253
254 @retval EFI_SUCCESS The asynchronous interrupt transfer request has been successfully
255 submitted or canceled.
256 @retval EFI_INVALID_PARAMETER Some parameters are invalid.
257 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
258
259 **/
260 typedef
261 EFI_STATUS
262 (EFIAPI *EFI_USB2_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER) (
263 IN EFI_USB2_HC_PROTOCOL *This,
264 IN UINT8 DeviceAddress,
265 IN UINT8 EndPointAddress,
266 IN UINT8 DeviceSpeed,
267 IN UINTN MaxiumPacketLength,
268 IN BOOLEAN IsNewTransfer,
269 IN OUT UINT8 *DataToggle,
270 IN UINTN PollingInterval OPTIONAL,
271 IN UINTN DataLength OPTIONAL,
272 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator OPTIONAL,
273 IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction OPTIONAL,
274 IN VOID *Context OPTIONAL
275 )
276 ;
277
278 /**
279 Submits synchronous interrupt transfer to an interrupt endpoint of a USB device.
280
281 @param This A pointer to the EFI_USB2_HC_PROTOCOL instance.
282 @param DeviceAddress Represents the address of the target device on the USB.
283 @param EndPointAddress The combination of an endpoint number and an endpoint direction of the
284 target USB device.
285 @param DeviceSpeed Indicates device speed.
286 @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of
287 sending or receiving.
288 @param Data A pointer to the buffer of data that will be transmitted to USB device or
289 received from USB device.
290 @param DataLength On input, the size, in bytes, of the data buffer specified by Data. On
291 output, the number of bytes transferred.
292 @param DataToggle A pointer to the data toggle value.
293 @param TimeOut Indicates the maximum time, in milliseconds, which the transfer is
294 allowed to complete.
295 @param TransferResult A pointer to the detailed result information from the synchronous
296 interrupt transfer.
297
298 @retval EFI_SUCCESS The synchronous interrupt transfer was completed successfully.
299 @retval EFI_INVALID_PARAMETER Some parameters are invalid.
300 @retval EFI_OUT_OF_RESOURCES The synchronous interrupt transfer could not be submitted due to a lack of resources.
301 @retval EFI_TIMEOUT The synchronous interrupt transfer failed due to timeout.
302 @retval EFI_DEVICE_ERROR The synchronous interrupt transfer failed due to host controller or device error.
303 Caller should check TransferResult for detailed error information.
304
305 **/
306 typedef
307 EFI_STATUS
308 (EFIAPI *EFI_USB2_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER) (
309 IN EFI_USB2_HC_PROTOCOL *This,
310 IN UINT8 DeviceAddress,
311 IN UINT8 EndPointAddress,
312 IN UINT8 DeviceSpeed,
313 IN UINTN MaximumPacketLength,
314 IN OUT VOID *Data,
315 IN OUT UINTN *DataLength,
316 IN OUT UINT8 *DataToggle,
317 IN UINTN TimeOut,
318 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
319 OUT UINT32 *TransferResult
320 )
321 ;
322
323 #define EFI_USB_MAX_ISO_BUFFER_NUM 7
324 #define EFI_USB_MAX_ISO_BUFFER_NUM1 2
325
326 /**
327 Submits isochronous transfer to an isochronous endpoint of a USB device.
328
329 @param This A pointer to the EFI_USB2_HC_PROTOCOL instance.
330 @param DeviceAddress Represents the address of the target device on the USB.
331 @param EndPointAddress The combination of an endpoint number and an endpoint direction of the
332 target USB device.
333 @param DeviceSpeed Indicates device speed.
334 @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of
335 sending or receiving.
336 @param DataBuffersNumber Number of data buffers prepared for the transfer.
337 @param Data Array of pointers to the buffers of data that will be transmitted to USB
338 device or received from USB device.
339 @param DataLength Specifies the length, in bytes, of the data to be sent to or received from
340 the USB device.
341 @param Translator A pointer to the transaction translator data.
342 @param TransferResult A pointer to the detailed result information of the isochronous transfer.
343
344 @retval EFI_SUCCESS The isochronous transfer was completed successfully.
345 @retval EFI_INVALID_PARAMETER Some parameters are invalid.
346 @retval EFI_OUT_OF_RESOURCES The isochronous transfer could not be submitted due to a lack of resources.
347 @retval EFI_TIMEOUT The isochronous transfer cannot be completed within the one USB frame time.
348 @retval EFI_DEVICE_ERROR The isochronous transfer failed due to host controller or device error.
349 Caller should check TransferResult for detailed error information.
350
351 **/
352 typedef
353 EFI_STATUS
354 (EFIAPI *EFI_USB2_HC_PROTOCOL_ISOCHRONOUS_TRANSFER) (
355 IN EFI_USB2_HC_PROTOCOL *This,
356 IN UINT8 DeviceAddress,
357 IN UINT8 EndPointAddress,
358 IN UINT8 DeviceSpeed,
359 IN UINTN MaximumPacketLength,
360 IN UINT8 DataBuffersNumber,
361 IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
362 IN UINTN DataLength,
363 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
364 OUT UINT32 *TransferResult
365 )
366 ;
367
368 /**
369 Submits nonblocking isochronous transfer to an isochronous endpoint of a USB device.
370
371 @param This A pointer to the EFI_USB2_HC_PROTOCOL instance.
372 @param DeviceAddress Represents the address of the target device on the USB.
373 @param EndPointAddress The combination of an endpoint number and an endpoint direction of the
374 target USB device.
375 @param DeviceSpeed Indicates device speed.
376 @param MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of
377 sending or receiving.
378 @param DataBuffersNumber Number of data buffers prepared for the transfer.
379 @param Data Array of pointers to the buffers of data that will be transmitted to USB
380 device or received from USB device.
381 @param DataLength Specifies the length, in bytes, of the data to be sent to or received from
382 the USB device.
383 @param Translator A pointer to the transaction translator data.
384 @param IsochronousCallback The Callback function. This function is called if the requested
385 isochronous transfer is completed.
386 @param Context Data passed to the IsochronousCallback function. This is an
387 optional parameter and may be NULL.
388
389 @retval EFI_SUCCESS The asynchronous isochronous transfer request has been successfully
390 submitted or canceled.
391 @retval EFI_INVALID_PARAMETER Some parameters are invalid.
392 @retval EFI_OUT_OF_RESOURCES The asynchronous isochronous transfer could not be submitted due to
393 a lack of resources.
394
395 **/
396 typedef
397 EFI_STATUS
398 (EFIAPI *EFI_USB2_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER) (
399 IN EFI_USB2_HC_PROTOCOL *This,
400 IN UINT8 DeviceAddress,
401 IN UINT8 EndPointAddress,
402 IN UINT8 DeviceSpeed,
403 IN UINTN MaximumPacketLength,
404 IN UINT8 DataBuffersNumber,
405 IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
406 IN UINTN DataLength,
407 IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
408 IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack,
409 IN VOID *Context OPTIONAL
410 )
411 ;
412
413 /**
414 Retrieves the current status of a USB root hub port.
415
416 @param This A pointer to the EFI_USB2_HC_PROTOCOL instance.
417 @param PortNumber Specifies the root hub port from which the status is to be retrieved.
418 This value is zero based.
419 @param PortStatus A pointer to the current port status bits and port status change bits.
420
421 @retval EFI_SUCCESS The status of the USB root hub port specified by PortNumber
422 was returned in PortStatus.
423 @retval EFI_INVALID_PARAMETER PortNumber is invalid.
424
425 **/
426 typedef
427 EFI_STATUS
428 (EFIAPI *EFI_USB2_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS) (
429 IN EFI_USB2_HC_PROTOCOL *This,
430 IN UINT8 PortNumber,
431 OUT EFI_USB_PORT_STATUS *PortStatus
432 )
433 ;
434
435 /**
436 Sets a feature for the specified root hub port.
437
438 @param This A pointer to the EFI_USB2_HC_PROTOCOL instance.
439 @param PortNumber Specifies the root hub port whose feature is requested to be set. This
440 value is zero based.
441 @param PortFeature Indicates the feature selector associated with the feature set request.
442
443 @retval EFI_SUCCESS The feature specified by PortFeature was set for the USB
444 root hub port specified by PortNumber.
445 @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid for this function.
446
447 **/
448 typedef
449 EFI_STATUS
450 (EFIAPI *EFI_USB2_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE) (
451 IN EFI_USB2_HC_PROTOCOL *This,
452 IN UINT8 PortNumber,
453 IN EFI_USB_PORT_FEATURE PortFeature
454 )
455 ;
456
457 /**
458 Clears a feature for the specified root hub port.
459
460 @param This A pointer to the EFI_USB2_HC_PROTOCOL instance.
461 @param PortNumber Specifies the root hub port whose feature is requested to be cleared. This
462 value is zero based.
463 @param PortFeature Indicates the feature selector associated with the feature clear request.
464
465 @retval EFI_SUCCESS The feature specified by PortFeature was cleared for the USB
466 root hub port specified by PortNumber.
467 @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid for this function.
468
469 **/
470 typedef
471 EFI_STATUS
472 (EFIAPI *EFI_USB2_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE) (
473 IN EFI_USB2_HC_PROTOCOL *This,
474 IN UINT8 PortNumber,
475 IN EFI_USB_PORT_FEATURE PortFeature
476 )
477 ;
478
479 struct _EFI_USB2_HC_PROTOCOL {
480 EFI_USB2_HC_PROTOCOL_GET_CAPABILITY GetCapability;
481 EFI_USB2_HC_PROTOCOL_RESET Reset;
482 EFI_USB2_HC_PROTOCOL_GET_STATE GetState;
483 EFI_USB2_HC_PROTOCOL_SET_STATE SetState;
484 EFI_USB2_HC_PROTOCOL_CONTROL_TRANSFER ControlTransfer;
485 EFI_USB2_HC_PROTOCOL_BULK_TRANSFER BulkTransfer;
486 EFI_USB2_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER AsyncInterruptTransfer;
487 EFI_USB2_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER SyncInterruptTransfer;
488 EFI_USB2_HC_PROTOCOL_ISOCHRONOUS_TRANSFER IsochronousTransfer;
489 EFI_USB2_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER AsyncIsochronousTransfer;
490 EFI_USB2_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS GetRootHubPortStatus;
491 EFI_USB2_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE SetRootHubPortFeature;
492 EFI_USB2_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE ClearRootHubPortFeature;
493 UINT16 MajorRevision;
494 UINT16 MinorRevision;
495 };
496
497 extern EFI_GUID gEfiUsb2HcProtocolGuid;
498
499 #endif