6a7fb8bee4ab8c9d222431d2d5d66782a29b8072
[mirror_edk2.git] / MdePkg / Include / IndustryStandard / Usb.h
1 /** @file
2 Support for USB 1.1 standard.
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 **/
14
15 #ifndef __USB_H__
16 #define __USB_H__
17
18 //
19 // USB Descriptor types
20 //
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
28
29 //
30 // USB request type
31 //
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)
36
37 //
38 // USB request targer device
39 //
40 #define USB_RECIP_DEVICE 0x00
41 #define USB_RECIP_INTERFACE 0x01
42 #define USB_RECIP_ENDPOINT 0x02
43 #define USB_RECIP_OTHER 0x03
44
45 //
46 // Request target types.
47 //
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)
53
54 //
55 // USB Transfer Results
56 //
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
67
68 //
69 //Use 200 ms to increase the error handling response time
70 //
71 #define EFI_USB_INTERRUPT_DELAY 2000000
72
73 //
74 // USB transation direction
75 //
76 typedef enum {
77 EfiUsbDataIn,
78 EfiUsbDataOut,
79 EfiUsbNoData
80 } EFI_USB_DATA_DIRECTION;
81
82 //
83 // Usb Data recipient type
84 //
85 typedef enum {
86 EfiUsbDevice,
87 EfiUsbInterface,
88 EfiUsbEndpoint
89 } EFI_USB_RECIPIENT;
90
91 typedef enum {
92 EfiUsbEndpointHalt,
93 EfiUsbDeviceRemoteWakeup
94 } EFI_USB_STANDARD_FEATURE_SELECTOR;
95
96 #pragma pack(1)
97 //
98 // Usb device request structure
99 //
100 typedef struct {
101 UINT8 RequestType;
102 UINT8 Request;
103 UINT16 Value;
104 UINT16 Index;
105 UINT16 Length;
106 } EFI_USB_DEVICE_REQUEST;
107
108 //
109 // Standard USB request
110 //
111 #define USB_DEV_GET_STATUS 0x00
112
113 #define USB_DEV_CLEAR_FEATURE 0x01
114
115 #define USB_DEV_SET_FEATURE 0x03
116
117 #define USB_DEV_SET_ADDRESS 0x05
118 #define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00
119
120 #define USB_DEV_GET_DESCRIPTOR 0x06
121 #define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80
122
123 #define USB_DEV_SET_DESCRIPTOR 0x07
124 #define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00
125
126 #define USB_DEV_GET_CONFIGURATION 0x08
127 #define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80
128
129 #define USB_DEV_SET_CONFIGURATION 0x09
130 #define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00
131
132 #define USB_DEV_GET_INTERFACE 0x0A
133 #define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81
134
135 #define USB_DEV_SET_INTERFACE 0x0B
136 #define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01
137
138 #define USB_DEV_SYNCH_FRAME 0x0C
139 #define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82
140
141 //
142 // Device descriptor. refer USB1.1
143 //
144 typedef struct usb_device_descriptor {
145 UINT8 Length;
146 UINT8 DescriptorType;
147 UINT16 BcdUSB;
148 UINT8 DeviceClass;
149 UINT8 DeviceSubClass;
150 UINT8 DeviceProtocol;
151 UINT8 MaxPacketSize0;
152 UINT16 IdVendor;
153 UINT16 IdProduct;
154 UINT16 BcdDevice;
155 UINT8 StrManufacturer;
156 UINT8 StrProduct;
157 UINT8 StrSerialNumber;
158 UINT8 NumConfigurations;
159 } EFI_USB_DEVICE_DESCRIPTOR;
160
161 //
162 // Endpoint descriptor
163 //
164 typedef struct {
165 UINT8 Length;
166 UINT8 DescriptorType;
167 UINT8 EndpointAddress;
168 UINT8 Attributes;
169 UINT16 MaxPacketSize;
170 UINT8 Interval;
171 } EFI_USB_ENDPOINT_DESCRIPTOR;
172
173 //
174 // Interface descriptor
175 //
176 typedef struct {
177 UINT8 Length;
178 UINT8 DescriptorType;
179 UINT8 InterfaceNumber;
180 UINT8 AlternateSetting;
181 UINT8 NumEndpoints;
182 UINT8 InterfaceClass;
183 UINT8 InterfaceSubClass;
184 UINT8 InterfaceProtocol;
185 UINT8 Interface;
186 } EFI_USB_INTERFACE_DESCRIPTOR;
187
188 //
189 // USB alternate setting
190 //
191 typedef struct {
192 EFI_USB_INTERFACE_DESCRIPTOR *Interface;
193 } USB_ALT_SETTING;
194
195 //
196 // Configuration descriptor
197 //
198 typedef struct {
199 UINT8 Length;
200 UINT8 DescriptorType;
201 UINT16 TotalLength;
202 UINT8 NumInterfaces;
203 UINT8 ConfigurationValue;
204 UINT8 Configuration;
205 UINT8 Attributes;
206 UINT8 MaxPower;
207 } EFI_USB_CONFIG_DESCRIPTOR;
208
209 //
210 // Supported String Languages
211 //
212 typedef struct {
213 UINT8 Length;
214 UINT8 DescriptorType;
215 UINT16 SupportedLanID[1];
216 } EFI_USB_SUPPORTED_LANGUAGES;
217
218 //
219 // String descriptor
220 //
221 typedef struct {
222 UINT8 Length;
223 UINT8 DescriptorType;
224 CHAR16 String[1];
225 } EFI_USB_STRING_DESCRIPTOR;
226
227 //
228 // Hub descriptor
229 //
230 #define MAXBYTES 8
231 typedef struct {
232 UINT8 Length;
233 UINT8 DescriptorType;
234 UINT8 NbrPorts;
235 UINT8 HubCharacteristics[2];
236 UINT8 PwrOn2PwrGood;
237 UINT8 HubContrCurrent;
238 UINT8 Filler[MAXBYTES];
239 } EFI_USB_HUB_DESCRIPTOR;
240
241 typedef struct {
242 UINT16 PortStatus;
243 UINT16 PortChangeStatus;
244 } EFI_USB_PORT_STATUS;
245
246 //
247 // Constant value for Port Status & Port Change Status
248 //
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
258
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
264
265 //
266 // Used for set/clear port feature request
267 //
268 typedef enum {
269 EfiUsbPortEnable = 1,
270 EfiUsbPortSuspend = 2,
271 EfiUsbPortReset = 4,
272 EfiUsbPortPower = 8,
273 EfiUsbPortOwner = 13,
274 EfiUsbPortConnectChange = 16,
275 EfiUsbPortEnableChange = 17,
276 EfiUsbPortSuspendChange = 18,
277 EfiUsbPortOverCurrentChange = 19,
278 EfiUsbPortResetChange = 20
279 } EFI_USB_PORT_FEATURE;
280
281 #pragma pack()
282
283 #endif