]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Include/IndustryStandard/usb.h
Add in the 1st version of ECP.
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Include / IndustryStandard / usb.h
CommitLineData
3eb9473e 1/*++\r
2\r
3Copyright (c) 2004 - 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 usb.h\r
15\r
16Abstract:\r
17 Support for USB 1.1 standard.\r
18\r
19\r
20\r
21\r
22Revision History\r
23\r
24--*/\r
25\r
26#ifndef _USB_H\r
27#define _USB_H\r
28//\r
29// USB Descriptor types\r
30//\r
31#define USB_DT_DEVICE 0x01\r
32#define USB_DT_CONFIG 0x02\r
33#define USB_DT_STRING 0x03\r
34#define USB_DT_INTERFACE 0x04\r
35#define USB_DT_ENDPOINT 0x05\r
36#define USB_DT_HUB 0x29\r
37#define USB_DT_HID 0x21\r
38\r
39//\r
40// USB request type\r
41//\r
42#define USB_TYPE_STANDARD (0x00 << 5)\r
43#define USB_TYPE_CLASS (0x01 << 5)\r
44#define USB_TYPE_VENDOR (0x02 << 5)\r
45#define USB_TYPE_RESERVED (0x03 << 5)\r
46\r
47//\r
48// USB request targer device\r
49//\r
50#define USB_RECIP_DEVICE 0x00\r
51#define USB_RECIP_INTERFACE 0x01\r
52#define USB_RECIP_ENDPOINT 0x02\r
53#define USB_RECIP_OTHER 0x03\r
54\r
55//\r
56// Request target types.\r
57//\r
58#define USB_RT_DEVICE 0x00\r
59#define USB_RT_INTERFACE 0x01\r
60#define USB_RT_ENDPOINT 0x02\r
61#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)\r
62#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)\r
63\r
64//\r
65// USB Transfer Results\r
66//\r
67#define EFI_USB_NOERROR 0x00\r
68#define EFI_USB_ERR_NOTEXECUTE 0x01\r
69#define EFI_USB_ERR_STALL 0x02\r
70#define EFI_USB_ERR_BUFFER 0x04\r
71#define EFI_USB_ERR_BABBLE 0x08\r
72#define EFI_USB_ERR_NAK 0x10\r
73#define EFI_USB_ERR_CRC 0x20\r
74#define EFI_USB_ERR_TIMEOUT 0x40\r
75#define EFI_USB_ERR_BITSTUFF 0x80\r
76#define EFI_USB_ERR_SYSTEM 0x100\r
77\r
78//\r
79//Use 200 ms to increase the error handling response time\r
80//\r
81#define EFI_USB_INTERRUPT_DELAY 2000000\r
82\r
83//\r
84// USB transation direction\r
85//\r
86typedef enum {\r
87 EfiUsbDataIn,\r
88 EfiUsbDataOut,\r
89 EfiUsbNoData\r
90} EFI_USB_DATA_DIRECTION;\r
91\r
92//\r
93// Usb Data recipient type\r
94//\r
95typedef enum {\r
96 EfiUsbDevice,\r
97 EfiUsbInterface,\r
98 EfiUsbEndpoint\r
99} EFI_USB_RECIPIENT;\r
100\r
101typedef enum {\r
102 EfiUsbEndpointHalt,\r
103 EfiUsbDeviceRemoteWakeup\r
104} EFI_USB_STANDARD_FEATURE_SELECTOR;\r
105\r
106#pragma pack(1)\r
107//\r
108// Usb device request structure\r
109//\r
110typedef struct {\r
111 UINT8 RequestType;\r
112 UINT8 Request;\r
113 UINT16 Value;\r
114 UINT16 Index;\r
115 UINT16 Length;\r
116} EFI_USB_DEVICE_REQUEST;\r
117\r
118//\r
119// Standard USB request\r
120//\r
121#define USB_DEV_GET_STATUS 0x00\r
122\r
123#define USB_DEV_CLEAR_FEATURE 0x01\r
124\r
125#define USB_DEV_SET_FEATURE 0x03\r
126\r
127#define USB_DEV_SET_ADDRESS 0x05\r
128#define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00\r
129\r
130#define USB_DEV_GET_DESCRIPTOR 0x06\r
131#define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80\r
132\r
133#define USB_DEV_SET_DESCRIPTOR 0x07\r
134#define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00\r
135\r
136#define USB_DEV_GET_CONFIGURATION 0x08\r
137#define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80\r
138\r
139#define USB_DEV_SET_CONFIGURATION 0x09\r
140#define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00\r
141\r
142#define USB_DEV_GET_INTERFACE 0x0A\r
143#define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81\r
144\r
145#define USB_DEV_SET_INTERFACE 0x0B\r
146#define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01\r
147\r
148#define USB_DEV_SYNCH_FRAME 0x0C\r
149#define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82\r
150\r
151//\r
152// Device descriptor. refer USB1.1\r
153//\r
154typedef struct usb_device_descriptor {\r
155 UINT8 Length;\r
156 UINT8 DescriptorType;\r
157 UINT16 BcdUSB;\r
158 UINT8 DeviceClass;\r
159 UINT8 DeviceSubClass;\r
160 UINT8 DeviceProtocol;\r
161 UINT8 MaxPacketSize0;\r
162 UINT16 IdVendor;\r
163 UINT16 IdProduct;\r
164 UINT16 BcdDevice;\r
165 UINT8 StrManufacturer;\r
166 UINT8 StrProduct;\r
167 UINT8 StrSerialNumber;\r
168 UINT8 NumConfigurations;\r
169} EFI_USB_DEVICE_DESCRIPTOR;\r
170\r
171//\r
172// Endpoint descriptor\r
173//\r
174typedef struct {\r
175 UINT8 Length;\r
176 UINT8 DescriptorType;\r
177 UINT8 EndpointAddress;\r
178 UINT8 Attributes;\r
179 UINT16 MaxPacketSize;\r
180 UINT8 Interval;\r
181} EFI_USB_ENDPOINT_DESCRIPTOR;\r
182\r
183//\r
184// Interface descriptor\r
185//\r
186typedef struct {\r
187 UINT8 Length;\r
188 UINT8 DescriptorType;\r
189 UINT8 InterfaceNumber;\r
190 UINT8 AlternateSetting;\r
191 UINT8 NumEndpoints;\r
192 UINT8 InterfaceClass;\r
193 UINT8 InterfaceSubClass;\r
194 UINT8 InterfaceProtocol;\r
195 UINT8 Interface;\r
196} EFI_USB_INTERFACE_DESCRIPTOR;\r
197\r
198//\r
199// USB alternate setting\r
200//\r
201typedef struct {\r
202 EFI_USB_INTERFACE_DESCRIPTOR *Interface;\r
203} USB_ALT_SETTING;\r
204\r
205//\r
206// Configuration descriptor\r
207//\r
208typedef struct {\r
209 UINT8 Length;\r
210 UINT8 DescriptorType;\r
211 UINT16 TotalLength;\r
212 UINT8 NumInterfaces;\r
213 UINT8 ConfigurationValue;\r
214 UINT8 Configuration;\r
215 UINT8 Attributes;\r
216 UINT8 MaxPower;\r
217} EFI_USB_CONFIG_DESCRIPTOR;\r
218\r
219//\r
220// Supported String Languages\r
221//\r
222typedef struct {\r
223 UINT8 Length;\r
224 UINT8 DescriptorType;\r
225 UINT16 SupportedLanID[1];\r
226} EFI_USB_SUPPORTED_LANGUAGES;\r
227\r
228//\r
229// String descriptor\r
230//\r
231typedef struct {\r
232 UINT8 Length;\r
233 UINT8 DescriptorType;\r
234 CHAR16 String[1];\r
235} EFI_USB_STRING_DESCRIPTOR;\r
236\r
237//\r
238// Hub descriptor\r
239//\r
240#define MAXBYTES 8\r
241typedef struct {\r
242 UINT8 Length;\r
243 UINT8 DescriptorType;\r
244 UINT8 NbrPorts;\r
245 UINT8 HubCharacteristics[2];\r
246 UINT8 PwrOn2PwrGood;\r
247 UINT8 HubContrCurrent;\r
248 UINT8 Filler[MAXBYTES];\r
249} EFI_USB_HUB_DESCRIPTOR;\r
250\r
251typedef struct {\r
252 UINT16 PortStatus;\r
253 UINT16 PortChangeStatus;\r
254} EFI_USB_PORT_STATUS;\r
255\r
256//\r
257// Constant value for Port Status & Port Change Status\r
258//\r
259#define USB_PORT_STAT_CONNECTION 0x0001\r
260#define USB_PORT_STAT_ENABLE 0x0002\r
261#define USB_PORT_STAT_SUSPEND 0x0004\r
262#define USB_PORT_STAT_OVERCURRENT 0x0008\r
263#define USB_PORT_STAT_RESET 0x0010\r
264#define USB_PORT_STAT_POWER 0x0100\r
265#define USB_PORT_STAT_LOW_SPEED 0x0200\r
266#define USB_PORT_STAT_HIGH_SPEED 0x0400\r
267#define USB_PORT_STAT_OWNER 0x0800\r
268\r
269#define USB_PORT_STAT_C_CONNECTION 0x0001\r
270#define USB_PORT_STAT_C_ENABLE 0x0002\r
271#define USB_PORT_STAT_C_SUSPEND 0x0004\r
272#define USB_PORT_STAT_C_OVERCURRENT 0x0008\r
273#define USB_PORT_STAT_C_RESET 0x0010\r
274\r
275//\r
276// Used for set/clear port feature request\r
277//\r
278typedef enum {\r
279 EfiUsbPortEnable = 1,\r
280 EfiUsbPortSuspend = 2,\r
281 EfiUsbPortReset = 4,\r
282 EfiUsbPortPower = 8,\r
283 EfiUsbPortOwner = 13,\r
284 EfiUsbPortConnectChange = 16,\r
285 EfiUsbPortEnableChange = 17,\r
286 EfiUsbPortSuspendChange = 18,\r
287 EfiUsbPortOverCurrentChange = 19,\r
288 EfiUsbPortResetChange = 20\r
289} EFI_USB_PORT_FEATURE;\r
290\r
291#pragma pack()\r
292\r
293#endif\r