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