2 Support for USB 1.1 standard.
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
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.
19 // USB Descriptor types
21 #define USB_DT_DEVICE 0x01
22 #define USB_DT_CONFIG 0x02
23 #define USB_DT_STRING 0x03
24 #define USB_DT_INTERFACE 0x04
25 #define USB_DT_ENDPOINT 0x05
26 #define USB_DT_HUB 0x29
27 #define USB_DT_HID 0x21
32 #define USB_TYPE_STANDARD (0x00 << 5)
33 #define USB_TYPE_CLASS (0x01 << 5)
34 #define USB_TYPE_VENDOR (0x02 << 5)
35 #define USB_TYPE_RESERVED (0x03 << 5)
38 // USB request targer device
40 #define USB_RECIP_DEVICE 0x00
41 #define USB_RECIP_INTERFACE 0x01
42 #define USB_RECIP_ENDPOINT 0x02
43 #define USB_RECIP_OTHER 0x03
46 // Request target types.
48 #define USB_RT_DEVICE 0x00
49 #define USB_RT_INTERFACE 0x01
50 #define USB_RT_ENDPOINT 0x02
51 #define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
52 #define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
55 // USB Transfer Results
57 #define EFI_USB_NOERROR 0x00
58 #define EFI_USB_ERR_NOTEXECUTE 0x01
59 #define EFI_USB_ERR_STALL 0x02
60 #define EFI_USB_ERR_BUFFER 0x04
61 #define EFI_USB_ERR_BABBLE 0x08
62 #define EFI_USB_ERR_NAK 0x10
63 #define EFI_USB_ERR_CRC 0x20
64 #define EFI_USB_ERR_TIMEOUT 0x40
65 #define EFI_USB_ERR_BITSTUFF 0x80
66 #define EFI_USB_ERR_SYSTEM 0x100
69 //Use 200 ms to increase the error handling response time
71 #define EFI_USB_INTERRUPT_DELAY 2000000
74 // USB transation direction
80 } EFI_USB_DATA_DIRECTION
;
83 // Usb Data recipient type
93 EfiUsbDeviceRemoteWakeup
94 } EFI_USB_STANDARD_FEATURE_SELECTOR
;
98 // Usb device request structure
106 } EFI_USB_DEVICE_REQUEST
;
109 // Standard USB request
111 #define USB_DEV_GET_STATUS 0x00
113 #define USB_DEV_CLEAR_FEATURE 0x01
115 #define USB_DEV_SET_FEATURE 0x03
117 #define USB_DEV_SET_ADDRESS 0x05
118 #define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00
120 #define USB_DEV_GET_DESCRIPTOR 0x06
121 #define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80
123 #define USB_DEV_SET_DESCRIPTOR 0x07
124 #define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00
126 #define USB_DEV_GET_CONFIGURATION 0x08
127 #define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80
129 #define USB_DEV_SET_CONFIGURATION 0x09
130 #define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00
132 #define USB_DEV_GET_INTERFACE 0x0A
133 #define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81
135 #define USB_DEV_SET_INTERFACE 0x0B
136 #define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01
138 #define USB_DEV_SYNCH_FRAME 0x0C
139 #define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82
142 // Device descriptor. refer USB1.1
144 typedef struct usb_device_descriptor
{
146 UINT8 DescriptorType
;
149 UINT8 DeviceSubClass
;
150 UINT8 DeviceProtocol
;
151 UINT8 MaxPacketSize0
;
155 UINT8 StrManufacturer
;
157 UINT8 StrSerialNumber
;
158 UINT8 NumConfigurations
;
159 } EFI_USB_DEVICE_DESCRIPTOR
;
162 // Endpoint descriptor
166 UINT8 DescriptorType
;
167 UINT8 EndpointAddress
;
169 UINT16 MaxPacketSize
;
171 } EFI_USB_ENDPOINT_DESCRIPTOR
;
174 // Interface descriptor
178 UINT8 DescriptorType
;
179 UINT8 InterfaceNumber
;
180 UINT8 AlternateSetting
;
182 UINT8 InterfaceClass
;
183 UINT8 InterfaceSubClass
;
184 UINT8 InterfaceProtocol
;
186 } EFI_USB_INTERFACE_DESCRIPTOR
;
189 // USB alternate setting
192 EFI_USB_INTERFACE_DESCRIPTOR
*Interface
;
196 // Configuration descriptor
200 UINT8 DescriptorType
;
203 UINT8 ConfigurationValue
;
207 } EFI_USB_CONFIG_DESCRIPTOR
;
210 // Supported String Languages
214 UINT8 DescriptorType
;
215 UINT16 SupportedLanID
[1];
216 } EFI_USB_SUPPORTED_LANGUAGES
;
223 UINT8 DescriptorType
;
225 } EFI_USB_STRING_DESCRIPTOR
;
233 UINT8 DescriptorType
;
235 UINT8 HubCharacteristics
[2];
237 UINT8 HubContrCurrent
;
238 UINT8 Filler
[MAXBYTES
];
239 } EFI_USB_HUB_DESCRIPTOR
;
243 UINT16 PortChangeStatus
;
244 } EFI_USB_PORT_STATUS
;
247 // Constant value for Port Status & Port Change Status
249 #define USB_PORT_STAT_CONNECTION 0x0001
250 #define USB_PORT_STAT_ENABLE 0x0002
251 #define USB_PORT_STAT_SUSPEND 0x0004
252 #define USB_PORT_STAT_OVERCURRENT 0x0008
253 #define USB_PORT_STAT_RESET 0x0010
254 #define USB_PORT_STAT_POWER 0x0100
255 #define USB_PORT_STAT_LOW_SPEED 0x0200
256 #define USB_PORT_STAT_HIGH_SPEED 0x0400
257 #define USB_PORT_STAT_OWNER 0x0800
259 #define USB_PORT_STAT_C_CONNECTION 0x0001
260 #define USB_PORT_STAT_C_ENABLE 0x0002
261 #define USB_PORT_STAT_C_SUSPEND 0x0004
262 #define USB_PORT_STAT_C_OVERCURRENT 0x0008
263 #define USB_PORT_STAT_C_RESET 0x0010
266 // Used for set/clear port feature request
269 EfiUsbPortEnable
= 1,
270 EfiUsbPortSuspend
= 2,
273 EfiUsbPortOwner
= 13,
274 EfiUsbPortConnectChange
= 16,
275 EfiUsbPortEnableChange
= 17,
276 EfiUsbPortSuspendChange
= 18,
277 EfiUsbPortOverCurrentChange
= 19,
278 EfiUsbPortResetChange
= 20
279 } EFI_USB_PORT_FEATURE
;