Update Usb.h definitions.
[mirror_edk2.git] / MdePkg / Include / IndustryStandard / Usb.h
1 /** @file
2 Support for USB 1.1 standard.
3
4 Copyright (c) 2006 - 2007, 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 //
20 // Definitions defined in UEFI spec
21 //
22
23 //
24 // USB Transfer Results
25 //
26 #define EFI_USB_NOERROR 0x00
27 #define EFI_USB_ERR_NOTEXECUTE 0x01
28 #define EFI_USB_ERR_STALL 0x02
29 #define EFI_USB_ERR_BUFFER 0x04
30 #define EFI_USB_ERR_BABBLE 0x08
31 #define EFI_USB_ERR_NAK 0x10
32 #define EFI_USB_ERR_CRC 0x20
33 #define EFI_USB_ERR_TIMEOUT 0x40
34 #define EFI_USB_ERR_BITSTUFF 0x80
35 #define EFI_USB_ERR_SYSTEM 0x100
36
37 //
38 // Constant value for Port Status & Port Change Status
39 //
40 #define USB_PORT_STAT_CONNECTION 0x0001
41 #define USB_PORT_STAT_ENABLE 0x0002
42 #define USB_PORT_STAT_SUSPEND 0x0004
43 #define USB_PORT_STAT_OVERCURRENT 0x0008
44 #define USB_PORT_STAT_RESET 0x0010
45 #define USB_PORT_STAT_POWER 0x0100
46 #define USB_PORT_STAT_LOW_SPEED 0x0200
47 #define USB_PORT_STAT_HIGH_SPEED 0x0400
48 #define USB_PORT_STAT_OWNER 0x0800
49
50 #define USB_PORT_STAT_C_CONNECTION 0x0001
51 #define USB_PORT_STAT_C_ENABLE 0x0002
52 #define USB_PORT_STAT_C_SUSPEND 0x0004
53 #define USB_PORT_STAT_C_OVERCURRENT 0x0008
54 #define USB_PORT_STAT_C_RESET 0x0010
55
56 //
57 // USB data transfer direction
58 //
59 typedef enum {
60 EfiUsbDataIn,
61 EfiUsbDataOut,
62 EfiUsbNoData
63 } EFI_USB_DATA_DIRECTION;
64
65 //
66 // Usb port features
67 //
68 typedef enum {
69 EfiUsbPortEnable = 1,
70 EfiUsbPortSuspend = 2,
71 EfiUsbPortReset = 4,
72 EfiUsbPortPower = 8,
73 EfiUsbPortOwner = 13,
74 EfiUsbPortConnectChange = 16,
75 EfiUsbPortEnableChange = 17,
76 EfiUsbPortSuspendChange = 18,
77 EfiUsbPortOverCurrentChange = 19,
78 EfiUsbPortResetChange = 20
79 } EFI_USB_PORT_FEATURE;
80
81
82 //
83 // USB standard descriptors and reqeust
84 //
85 #pragma pack(1)
86 typedef struct {
87 UINT8 RequestType;
88 UINT8 Request;
89 UINT16 Value;
90 UINT16 Index;
91 UINT16 Length;
92 } EFI_USB_DEVICE_REQUEST;
93
94 typedef struct {
95 UINT8 Length;
96 UINT8 DescriptorType;
97 UINT16 BcdUSB;
98 UINT8 DeviceClass;
99 UINT8 DeviceSubClass;
100 UINT8 DeviceProtocol;
101 UINT8 MaxPacketSize0;
102 UINT16 IdVendor;
103 UINT16 IdProduct;
104 UINT16 BcdDevice;
105 UINT8 StrManufacturer;
106 UINT8 StrProduct;
107 UINT8 StrSerialNumber;
108 UINT8 NumConfigurations;
109 } EFI_USB_DEVICE_DESCRIPTOR;
110
111 typedef struct {
112 UINT8 Length;
113 UINT8 DescriptorType;
114 UINT16 TotalLength;
115 UINT8 NumInterfaces;
116 UINT8 ConfigurationValue;
117 UINT8 Configuration;
118 UINT8 Attributes;
119 UINT8 MaxPower;
120 } EFI_USB_CONFIG_DESCRIPTOR;
121
122 typedef struct {
123 UINT8 Length;
124 UINT8 DescriptorType;
125 UINT8 InterfaceNumber;
126 UINT8 AlternateSetting;
127 UINT8 NumEndpoints;
128 UINT8 InterfaceClass;
129 UINT8 InterfaceSubClass;
130 UINT8 InterfaceProtocol;
131 UINT8 Interface;
132 } EFI_USB_INTERFACE_DESCRIPTOR;
133
134 typedef struct {
135 UINT8 Length;
136 UINT8 DescriptorType;
137 UINT8 EndpointAddress;
138 UINT8 Attributes;
139 UINT16 MaxPacketSize;
140 UINT8 Interval;
141 } EFI_USB_ENDPOINT_DESCRIPTOR;
142
143 typedef struct {
144 UINT8 Length;
145 UINT8 DescriptorType;
146 CHAR16 String[1];
147 } EFI_USB_STRING_DESCRIPTOR;
148
149 #pragma pack()
150
151 typedef struct {
152 UINT16 PortStatus;
153 UINT16 PortChangeStatus;
154 } EFI_USB_PORT_STATUS;
155
156
157 //
158 // Following are definitions not specified by UEFI spec.
159 // Add new definitions below this line
160 //
161 enum {
162 //
163 // USB request type
164 //
165 USB_REQ_TYPE_STANDARD = (0x00 << 5),
166 USB_REQ_TYPE_CLASS = (0x01 << 5),
167 USB_REQ_TYPE_VENDOR = (0x02 << 5),
168
169 //
170 // Standard control transfer request type, or the value
171 // to fill in EFI_USB_DEVICE_REQUEST.Request
172 //
173 USB_REQ_GET_STATUS = 0x00,
174 USB_REQ_CLEAR_FEATURE = 0x01,
175 USB_REQ_SET_FEATURE = 0x03,
176 USB_REQ_SET_ADDRESS = 0x05,
177 USB_REQ_GET_DESCRIPTOR = 0x06,
178 USB_REQ_SET_DESCRIPTOR = 0x07,
179 USB_REQ_GET_CONFIG = 0x08,
180 USB_REQ_SET_CONFIG = 0x09,
181 USB_REQ_GET_INTERFACE = 0x0A,
182 USB_REQ_SET_INTERFACE = 0x0B,
183 USB_REQ_SYNCH_FRAME = 0x0C,
184
185 //
186 // Usb control transfer target
187 //
188 USB_TARGET_DEVICE = 0,
189 USB_TARGET_INTERFACE = 0x01,
190 USB_TARGET_ENDPOINT = 0x02,
191 USB_TARGET_OTHER = 0x03,
192
193 //
194 // USB Descriptor types
195 //
196 USB_DESC_TYPE_DEVICE = 0x01,
197 USB_DESC_TYPE_CONFIG = 0x02,
198 USB_DESC_TYPE_STRING = 0x03,
199 USB_DESC_TYPE_INTERFACE = 0x04,
200 USB_DESC_TYPE_ENDPOINT = 0x05,
201 USB_DESC_TYPE_HID = 0x21,
202
203 //
204 // Features to be cleared by CLEAR_FEATURE requests
205 //
206 USB_FEATURE_ENDPOINT_HALT = 0,
207
208 //
209 // USB endpoint types: 00: control, 01: isochronous, 10: bulk, 11: interrupt
210 //
211 USB_ENDPOINT_CONTROL = 0x00,
212 USB_ENDPOINT_ISO = 0x01,
213 USB_ENDPOINT_BULK = 0x02,
214 USB_ENDPOINT_INTERRUPT = 0x03,
215
216 USB_ENDPOINT_TYPE_MASK = 0x03,
217 USB_ENDPOINT_DIR_IN = 0x80,
218
219 //
220 //Use 200 ms to increase the error handling response time
221 //
222 EFI_USB_INTERRUPT_DELAY = 2000000,
223 };
224 #endif