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