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.
21 // USB Descriptor types
23 #define USB_DT_DEVICE 0x01
24 #define USB_DT_CONFIG 0x02
25 #define USB_DT_STRING 0x03
26 #define USB_DT_INTERFACE 0x04
27 #define USB_DT_ENDPOINT 0x05
28 #define USB_DT_HUB 0x29
29 #define USB_DT_HID 0x21
34 #define USB_TYPE_STANDARD (0x00 << 5)
35 #define USB_TYPE_CLASS (0x01 << 5)
36 #define USB_TYPE_VENDOR (0x02 << 5)
37 #define USB_TYPE_RESERVED (0x03 << 5)
40 // USB request targer device
42 #define USB_RECIP_DEVICE 0x00
43 #define USB_RECIP_INTERFACE 0x01
44 #define USB_RECIP_ENDPOINT 0x02
45 #define USB_RECIP_OTHER 0x03
48 // Request target types.
50 #define USB_RT_DEVICE 0x00
51 #define USB_RT_INTERFACE 0x01
52 #define USB_RT_ENDPOINT 0x02
53 #define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
54 #define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
57 // USB Transfer Results
59 #define EFI_USB_NOERROR 0x00
60 #define EFI_USB_ERR_NOTEXECUTE 0x01
61 #define EFI_USB_ERR_STALL 0x02
62 #define EFI_USB_ERR_BUFFER 0x04
63 #define EFI_USB_ERR_BABBLE 0x08
64 #define EFI_USB_ERR_NAK 0x10
65 #define EFI_USB_ERR_CRC 0x20
66 #define EFI_USB_ERR_TIMEOUT 0x40
67 #define EFI_USB_ERR_BITSTUFF 0x80
68 #define EFI_USB_ERR_SYSTEM 0x100
71 //Use 200 ms to increase the error handling response time
73 #define EFI_USB_INTERRUPT_DELAY 2000000
76 // USB transation direction
82 } EFI_USB_DATA_DIRECTION
;
85 // Usb Data recipient type
95 EfiUsbDeviceRemoteWakeup
96 } EFI_USB_STANDARD_FEATURE_SELECTOR
;
100 // Usb device request structure
108 } EFI_USB_DEVICE_REQUEST
;
111 // Standard USB request
113 #define USB_DEV_GET_STATUS 0x00
115 #define USB_DEV_CLEAR_FEATURE 0x01
117 #define USB_DEV_SET_FEATURE 0x03
119 #define USB_DEV_SET_ADDRESS 0x05
120 #define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00
122 #define USB_DEV_GET_DESCRIPTOR 0x06
123 #define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80
125 #define USB_DEV_SET_DESCRIPTOR 0x07
126 #define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00
128 #define USB_DEV_GET_CONFIGURATION 0x08
129 #define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80
131 #define USB_DEV_SET_CONFIGURATION 0x09
132 #define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00
134 #define USB_DEV_GET_INTERFACE 0x0A
135 #define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81
137 #define USB_DEV_SET_INTERFACE 0x0B
138 #define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01
140 #define USB_DEV_SYNCH_FRAME 0x0C
141 #define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82
144 // Device descriptor. refer USB1.1
146 typedef struct usb_device_descriptor
{
148 UINT8 DescriptorType
;
151 UINT8 DeviceSubClass
;
152 UINT8 DeviceProtocol
;
153 UINT8 MaxPacketSize0
;
157 UINT8 StrManufacturer
;
159 UINT8 StrSerialNumber
;
160 UINT8 NumConfigurations
;
161 } EFI_USB_DEVICE_DESCRIPTOR
;
164 // Endpoint descriptor
168 UINT8 DescriptorType
;
169 UINT8 EndpointAddress
;
171 UINT16 MaxPacketSize
;
173 } EFI_USB_ENDPOINT_DESCRIPTOR
;
176 // Interface descriptor
180 UINT8 DescriptorType
;
181 UINT8 InterfaceNumber
;
182 UINT8 AlternateSetting
;
184 UINT8 InterfaceClass
;
185 UINT8 InterfaceSubClass
;
186 UINT8 InterfaceProtocol
;
188 } EFI_USB_INTERFACE_DESCRIPTOR
;
191 // USB alternate setting
194 EFI_USB_INTERFACE_DESCRIPTOR
*Interface
;
198 // Configuration descriptor
202 UINT8 DescriptorType
;
205 UINT8 ConfigurationValue
;
209 } EFI_USB_CONFIG_DESCRIPTOR
;
212 // Supported String Languages
216 UINT8 DescriptorType
;
217 UINT16 SupportedLanID
[1];
218 } EFI_USB_SUPPORTED_LANGUAGES
;
225 UINT8 DescriptorType
;
227 } EFI_USB_STRING_DESCRIPTOR
;
235 UINT8 DescriptorType
;
237 UINT8 HubCharacteristics
[2];
239 UINT8 HubContrCurrent
;
240 UINT8 Filler
[MAXBYTES
];
241 } EFI_USB_HUB_DESCRIPTOR
;
245 UINT16 PortChangeStatus
;
246 } EFI_USB_PORT_STATUS
;
249 // Constant value for Port Status & Port Change Status
251 #define USB_PORT_STAT_CONNECTION 0x0001
252 #define USB_PORT_STAT_ENABLE 0x0002
253 #define USB_PORT_STAT_SUSPEND 0x0004
254 #define USB_PORT_STAT_OVERCURRENT 0x0008
255 #define USB_PORT_STAT_RESET 0x0010
256 #define USB_PORT_STAT_POWER 0x0100
257 #define USB_PORT_STAT_LOW_SPEED 0x0200
258 #define USB_PORT_STAT_HIGH_SPEED 0x0400
259 #define USB_PORT_STAT_OWNER 0x0800
261 #define USB_PORT_STAT_C_CONNECTION 0x0001
262 #define USB_PORT_STAT_C_ENABLE 0x0002
263 #define USB_PORT_STAT_C_SUSPEND 0x0004
264 #define USB_PORT_STAT_C_OVERCURRENT 0x0008
265 #define USB_PORT_STAT_C_RESET 0x0010
268 // Used for set/clear port feature request
271 EfiUsbPortEnable
= 1,
272 EfiUsbPortSuspend
= 2,
275 EfiUsbPortOwner
= 13,
276 EfiUsbPortConnectChange
= 16,
277 EfiUsbPortEnableChange
= 17,
278 EfiUsbPortSuspendChange
= 18,
279 EfiUsbPortOverCurrentChange
= 19,
280 EfiUsbPortResetChange
= 20
281 } EFI_USB_PORT_FEATURE
;