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