3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 Support for USB 1.1 standard.
29 // USB Descriptor types
31 #define USB_DT_DEVICE 0x01
32 #define USB_DT_CONFIG 0x02
33 #define USB_DT_STRING 0x03
34 #define USB_DT_INTERFACE 0x04
35 #define USB_DT_ENDPOINT 0x05
36 #define USB_DT_HUB 0x29
37 #define USB_DT_HID 0x21
42 #define USB_TYPE_STANDARD (0x00 << 5)
43 #define USB_TYPE_CLASS (0x01 << 5)
44 #define USB_TYPE_VENDOR (0x02 << 5)
45 #define USB_TYPE_RESERVED (0x03 << 5)
48 // USB request targer device
50 #define USB_RECIP_DEVICE 0x00
51 #define USB_RECIP_INTERFACE 0x01
52 #define USB_RECIP_ENDPOINT 0x02
53 #define USB_RECIP_OTHER 0x03
56 // Request target types.
58 #define USB_RT_DEVICE 0x00
59 #define USB_RT_INTERFACE 0x01
60 #define USB_RT_ENDPOINT 0x02
61 #define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
62 #define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
65 // USB Transfer Results
67 #define EFI_USB_NOERROR 0x00
68 #define EFI_USB_ERR_NOTEXECUTE 0x01
69 #define EFI_USB_ERR_STALL 0x02
70 #define EFI_USB_ERR_BUFFER 0x04
71 #define EFI_USB_ERR_BABBLE 0x08
72 #define EFI_USB_ERR_NAK 0x10
73 #define EFI_USB_ERR_CRC 0x20
74 #define EFI_USB_ERR_TIMEOUT 0x40
75 #define EFI_USB_ERR_BITSTUFF 0x80
76 #define EFI_USB_ERR_SYSTEM 0x100
79 //Use 200 ms to increase the error handling response time
81 #define EFI_USB_INTERRUPT_DELAY 2000000
84 // USB transation direction
90 } EFI_USB_DATA_DIRECTION
;
93 // Usb Data recipient type
103 EfiUsbDeviceRemoteWakeup
104 } EFI_USB_STANDARD_FEATURE_SELECTOR
;
108 // Usb device request structure
116 } EFI_USB_DEVICE_REQUEST
;
119 // Standard USB request
121 #define USB_DEV_GET_STATUS 0x00
123 #define USB_DEV_CLEAR_FEATURE 0x01
125 #define USB_DEV_SET_FEATURE 0x03
127 #define USB_DEV_SET_ADDRESS 0x05
128 #define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00
130 #define USB_DEV_GET_DESCRIPTOR 0x06
131 #define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80
133 #define USB_DEV_SET_DESCRIPTOR 0x07
134 #define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00
136 #define USB_DEV_GET_CONFIGURATION 0x08
137 #define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80
139 #define USB_DEV_SET_CONFIGURATION 0x09
140 #define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00
142 #define USB_DEV_GET_INTERFACE 0x0A
143 #define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81
145 #define USB_DEV_SET_INTERFACE 0x0B
146 #define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01
148 #define USB_DEV_SYNCH_FRAME 0x0C
149 #define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82
152 // Device descriptor. refer USB1.1
154 typedef struct usb_device_descriptor
{
156 UINT8 DescriptorType
;
159 UINT8 DeviceSubClass
;
160 UINT8 DeviceProtocol
;
161 UINT8 MaxPacketSize0
;
165 UINT8 StrManufacturer
;
167 UINT8 StrSerialNumber
;
168 UINT8 NumConfigurations
;
169 } EFI_USB_DEVICE_DESCRIPTOR
;
172 // Endpoint descriptor
176 UINT8 DescriptorType
;
177 UINT8 EndpointAddress
;
179 UINT16 MaxPacketSize
;
181 } EFI_USB_ENDPOINT_DESCRIPTOR
;
184 // Interface descriptor
188 UINT8 DescriptorType
;
189 UINT8 InterfaceNumber
;
190 UINT8 AlternateSetting
;
192 UINT8 InterfaceClass
;
193 UINT8 InterfaceSubClass
;
194 UINT8 InterfaceProtocol
;
196 } EFI_USB_INTERFACE_DESCRIPTOR
;
199 // USB alternate setting
202 EFI_USB_INTERFACE_DESCRIPTOR
*Interface
;
206 // Configuration descriptor
210 UINT8 DescriptorType
;
213 UINT8 ConfigurationValue
;
217 } EFI_USB_CONFIG_DESCRIPTOR
;
220 // Supported String Languages
224 UINT8 DescriptorType
;
225 UINT16 SupportedLanID
[1];
226 } EFI_USB_SUPPORTED_LANGUAGES
;
233 UINT8 DescriptorType
;
235 } EFI_USB_STRING_DESCRIPTOR
;
243 UINT8 DescriptorType
;
245 UINT8 HubCharacteristics
[2];
247 UINT8 HubContrCurrent
;
248 UINT8 Filler
[MAXBYTES
];
249 } EFI_USB_HUB_DESCRIPTOR
;
253 UINT16 PortChangeStatus
;
254 } EFI_USB_PORT_STATUS
;
257 // Constant value for Port Status & Port Change Status
259 #define USB_PORT_STAT_CONNECTION 0x0001
260 #define USB_PORT_STAT_ENABLE 0x0002
261 #define USB_PORT_STAT_SUSPEND 0x0004
262 #define USB_PORT_STAT_OVERCURRENT 0x0008
263 #define USB_PORT_STAT_RESET 0x0010
264 #define USB_PORT_STAT_POWER 0x0100
265 #define USB_PORT_STAT_LOW_SPEED 0x0200
266 #define USB_PORT_STAT_HIGH_SPEED 0x0400
267 #define USB_PORT_STAT_OWNER 0x0800
269 #define USB_PORT_STAT_C_CONNECTION 0x0001
270 #define USB_PORT_STAT_C_ENABLE 0x0002
271 #define USB_PORT_STAT_C_SUSPEND 0x0004
272 #define USB_PORT_STAT_C_OVERCURRENT 0x0008
273 #define USB_PORT_STAT_C_RESET 0x0010
276 // Used for set/clear port feature request
279 EfiUsbPortEnable
= 1,
280 EfiUsbPortSuspend
= 2,
283 EfiUsbPortOwner
= 13,
284 EfiUsbPortConnectChange
= 16,
285 EfiUsbPortEnableChange
= 17,
286 EfiUsbPortSuspendChange
= 18,
287 EfiUsbPortOverCurrentChange
= 19,
288 EfiUsbPortResetChange
= 20
289 } EFI_USB_PORT_FEATURE
;