Root/usbboot/xburst_include/usb/usb.h

1/*
2 * Copyright (C) 2009 Qi Hardware Inc.,
3 * Author: Xiangfu Liu <xiangfu@sharism.cc>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * version 3 as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA
18 */
19#ifndef __USB_H
20#define __USB_H
21
22#include "target/xburst_types.h"
23
24extern int usbdebug;
25
26enum USB_ENDPOINT_TYPE
27{
28    ENDPOINT_TYPE_CONTROL,
29    /* Typically used to configure a device when attached to the host.
30     * It may also be used for other device specific purposes, including
31     * control of other pipes on the device.
32     */
33    ENDPOINT_TYPE_ISOCHRONOUS,
34    /* Typically used for applications which need guaranteed speed.
35     * Isochronous transfer is fast but with possible data loss. A typical
36     * use is audio data which requires a constant data rate.
37     */
38    ENDPOINT_TYPE_BULK,
39    /* Typically used by devices that generate or consume data in relatively
40     * large and bursty quantities. Bulk transfer has wide dynamic latitude
41     * in transmission constraints. It can use all remaining available bandwidth,
42     * but with no guarantees on bandwidth or latency. Since the USB bus is
43     * normally not very busy, there is typically 90% or more of the bandwidth
44     * available for USB transfers.
45     */
46    ENDPOINT_TYPE_INTERRUPT
47    /* Typically used by devices that need guaranteed quick responses
48     * (bounded latency).
49     */
50};
51
52
53enum USB_STANDARD_REQUEST_CODE {
54    GET_STATUS,
55    CLEAR_FEATURE,
56    SET_FEATURE = 3,
57    SET_ADDRESS = 5,
58    GET_DESCRIPTOR,
59    SET_DESCRIPTOR,
60    GET_CONFIGURATION,
61    SET_CONFIGURATION,
62    GET_INTERFACE,
63    SET_INTERFACE,
64    SYNCH_FRAME
65};
66
67
68enum USB_DESCRIPTOR_TYPE {
69    DEVICE_DESCRIPTOR = 1,
70    CONFIGURATION_DESCRIPTOR,
71    STRING_DESCRIPTOR,
72    INTERFACE_DESCRIPTOR,
73    ENDPOINT_DESCRIPTOR,
74    DEVICE_QUALIFIER_DESCRIPTOR,
75    OTHER_SPEED_CONFIGURATION_DESCRIPTOR,
76    INTERFACE_POWER1_DESCRIPTOR
77};
78
79
80enum USB_FEATURE_SELECTOR {
81    ENDPOINT_HALT,
82    DEVICE_REMOTE_WAKEUP,
83    TEST_MODE
84};
85
86enum USB_CLASS_CODE {
87    CLASS_DEVICE,
88    CLASS_AUDIO,
89    CLASS_COMM_AND_CDC_CONTROL,
90    CLASS_HID,
91    CLASS_PHYSICAL = 0x05,
92    CLASS_STILL_IMAGING,
93    CLASS_PRINTER,
94    CLASS_MASS_STORAGE,
95    CLASS_HUB,
96    CLASS_CDC_DATA,
97    CLASS_SMART_CARD,
98    CLASS_CONTENT_SECURITY = 0x0d,
99    CLASS_VIDEO,
100    CLASS_DIAGNOSTIC_DEVICE = 0xdc,
101    CLASS_WIRELESS_CONTROLLER = 0xe0,
102    CLASS_MISCELLANEOUS = 0xef,
103    CLASS_APP_SPECIFIC = 0xfe,
104    CLASS_VENDOR_SPECIFIC = 0xff
105};
106
107
108typedef struct {
109    u8 bmRequestType;
110    u8 bRequest;
111    u16 wValue;
112    u16 wIndex;
113    u16 wLength;
114} __attribute__ ((packed)) USB_DeviceRequest;
115
116
117typedef struct {
118    u8 bLength;
119    u8 bDescriptorType;
120    u16 bcdUSB;
121    u8 bDeviceClass;
122    u8 bDeviceSubClass;
123    u8 bDeviceProtocol;
124    u8 bMaxPacketSize0;
125    u16 idVendor;
126    u16 idProduct;
127    u16 bcdDevice;
128    u8 iManufacturer;
129    u8 iProduct;
130    u8 iSerialNumber;
131    u8 bNumConfigurations;
132} __attribute__ ((packed)) USB_DeviceDescriptor;
133
134
135typedef struct {
136    u8 bLength;
137    u8 bDescriptorType;
138    u16 bcdUSB;
139    u8 bDeviceClass;
140    u8 bDeviceSubClass;
141    u8 bDeviceProtocol;
142    u8 bMaxPacketSize0;
143    u8 bNumConfigurations;
144    u8 bReserved;
145} __attribute__ ((packed)) USB_DeviceQualifierDescriptor;
146
147
148typedef struct {
149    u8 bLength;
150    u8 bDescriptorType;
151    u16 wTotalLength;
152    u8 bNumInterfaces;
153    u8 bConfigurationValue;
154    u8 iConfiguration;
155    u8 bmAttributes;
156    u8 MaxPower;
157} __attribute__ ((packed)) USB_ConfigDescriptor;
158
159
160typedef struct {
161    u8 bLength;
162    u8 bDescriptorType;
163    u16 wTotalLength;
164    u8 bNumInterfaces;
165    u8 bConfigurationValue;
166    u8 iConfiguration;
167    u8 bmAttributes;
168    u8 bMaxPower;
169} __attribute__ ((packed)) USB_OtherSpeedConfigDescriptor;
170
171
172typedef struct {
173    u8 bLength;
174    u8 bDescriptorType;
175    u8 bInterfaceNumber;
176    u8 bAlternateSetting;
177    u8 bNumEndpoints;
178    u8 bInterfaceClass;
179    u8 bInterfaceSubClass;
180    u8 bInterfaceProtocol;
181    u8 iInterface;
182} __attribute__ ((packed)) USB_InterfaceDescriptor;
183
184
185typedef struct {
186    u8 bLegth;
187    u8 bDescriptorType;
188    u8 bEndpointAddress;
189    u8 bmAttributes;
190    u16 wMaxPacketSize;
191    u8 bInterval;
192} __attribute__ ((packed)) USB_EndPointDescriptor;
193
194
195typedef struct {
196    u8 bLength;
197    u8 bDescriptorType;
198    u16 SomeDesriptor[1];
199} __attribute__ ((packed)) USB_StringDescriptor;
200
201
202#endif // !defined(__USB_H)
203
204

Archive Download this file



interactive