first adaption of 'usbport' by Benedikt Sauter
[ppcskel.git] / usb / usbspec / usb11spec.h
1 /* usb11spec.h
2 * Copyright (C) 2005  Benedikt Sauter
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18 #ifndef _USB11PSEC_H
19 #define _USB11SPEC_H
20
21 /*-------------------------------------------
22  * device descriptor 
23  * ------------------------------------------*/
24 struct usb_device_descriptor 
25 {
26         unsigned char   bLength;
27         unsigned char   bDescriptorType;
28         unsigned short  bcdUSB;
29         unsigned char   bDeviceClass;
30         unsigned char   bDeviceSubClass;
31         unsigned char   bDeviceProtocol;
32         unsigned char   bMaxPacketSize0;
33         unsigned short  idVendor;
34         unsigned short  idProduct;
35         unsigned short  bcdDevice;
36         unsigned char   iManufacturer;
37         unsigned char   iProduct;
38         unsigned char   iSerialNumber;
39         unsigned char   bNumConfigurations;
40 };
41
42 /*-------------------------------------------
43  * configuration descriptor 
44  * ------------------------------------------*/
45
46 struct usb_configuration_descriptor 
47 {
48         unsigned char   bLength;
49         unsigned char   bDescriptorType;
50         unsigned short  wTotalLength;
51         unsigned char   bNumInterfaces;
52         unsigned char   bConfigurationValue;
53         unsigned char   iConfiguration;
54         unsigned char   bmAttributes;
55         unsigned char   MaxPower;
56 };
57
58 /*-------------------------------------------
59  * interface descriptor 
60  * ------------------------------------------*/
61
62 struct usb_interface_descriptor 
63 {
64         unsigned char   bLength;
65         unsigned char   bDescriptorType;
66         unsigned char   bInterfaceNumber;
67         unsigned char   bAlternateSetting;
68         unsigned char   bNumEndpoints;
69         unsigned char   bInterfaceClass;
70         unsigned char   bInterfaceSubClass;
71         unsigned char   bInterfaceProtocol;
72         unsigned char   iInterface;
73 };
74
75
76 /*-------------------------------------------
77  * endpoint descriptor 
78  * ------------------------------------------*/
79 struct usb_endpoint_descriptor 
80 {
81         unsigned char   bLength;
82         unsigned char   bDescriptorType;
83         unsigned char   bEndpointAddress;
84         unsigned char   bmAttributes;
85         unsigned short  wMaxPacketSize;
86         unsigned char   bIntervall;
87 };
88
89
90
91 /*-------------------------------------------
92  * string descriptor 
93  * ------------------------------------------*/
94 struct usb_string_descriptor 
95 {
96         unsigned char   bLength;
97         unsigned char   bDescriptorType;
98         unsigned char*  String;
99 };
100
101
102
103
104 /*-------------------------------------------
105  * USB Device Request
106  * ------------------------------------------*/
107 typedef struct usb_device_request_t usb_device_request;
108 struct usb_device_request_t
109 {
110         unsigned char bmRequestType;
111         unsigned char bRequest;
112         unsigned short wValue;
113         unsigned short wIndex;  
114         unsigned short wLength;
115 };
116
117 /*-------------------------------------------
118  * Get Device Descriptor Request
119  * ------------------------------------------*/
120 //char GetDeviceDescriptor[] {0x80,GET_DESCRIPTOR, DEVICE,0x00, 0x00,0x00,0x00,0x40};
121 //char GetDeviceDescriptor[] {0x80,GET_DESCRIPTOR, DEVICE,0x00, 0x00,0x00,0x00,0x40};
122 //char SetAddress[] {0x00,SET_ADDRESS, 0x00, address, 0x00,0x00,0x00,0x40};
123 //char SetAddress[] {0x00,SET_ADDRESS, 0x00, 0x00, 0x00,0x00,0x00,0x00};
124
125
126 /*------------------------------------------
127  * transfer types 
128  * ------------------------------------------*/
129
130 #define USB_CTRL                0x00
131 #define USB_ISOC                0x01
132 #define USB_BULK                0x02
133 #define USB_INTR                0x03
134
135 /*-------------------------------------------
136  * device descriptor types 
137  * ------------------------------------------*/
138 #define DO_STANDARD   0x00
139 #define DO_CLASS      0x20
140 #define DO_VENDOR     0x40
141
142 /*-------------------------------------------
143  * standard requests for ep0 
144  * ------------------------------------------*/
145
146 #define GET_STATUS              0x00 
147 #define CLR_FEATURE             0x01
148 #define SET_FEATURE             0x03
149 #define SET_ADDRESS             0x05
150 #define GET_DESCRIPTOR          0x06
151 #define SET_DESCRIPTOR          0x07
152 #define GET_CONFIGURATION       0x08
153 #define SET_CONFIGURATION       0x09
154 #define GET_INTERFACE           0x0A
155 #define SET_INTERFACE           0x0B
156
157 /*-------------------------------------------
158  * descriptor types 
159  * ------------------------------------------*/
160
161 #define DEVICE                  0x01
162 #define CONFIGURATION           0x02
163 #define STRING                  0x03
164 #define INTERFACE               0x04
165 #define ENDPOINT                0x05
166 #define DEVICEQUALIFIER         0x06 // only usb2.0
167 #define OTHERSPEEDCONFIGURATION 0x07 // only usb2.0
168
169
170 /*-------------------------------------------
171  * pid fields 
172  * ------------------------------------------*/
173
174 #define USB_PID_SOF     0x05
175 #define USB_PID_SETUP   0x0D
176 #define USB_PID_IN      0x09
177 #define USB_PID_OUT     0x01
178 #define USB_PID_DATA0   0x03
179 #define USB_PID_DATA1   0x0B
180 #define USB_PID_ACK     0x02
181 #define USB_PID_NACK    0x0A
182 #define USB_PID_STALL   0x0E
183 #define USB_PID_PRE     0x0C
184
185
186 #define MASS_STORAGE_CLASSCODE  0x08
187 #define HUB_CLASSCODE           0x09
188
189
190
191 #endif /* __USB11SPEC_H__ */