bleh, tmp commit...
[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         u8 *payload;
116 };
117
118 /*-------------------------------------------
119  * Get Device Descriptor Request
120  * ------------------------------------------*/
121 //char GetDeviceDescriptor[] {0x80,GET_DESCRIPTOR, DEVICE,0x00, 0x00,0x00,0x00,0x40};
122 //char GetDeviceDescriptor[] {0x80,GET_DESCRIPTOR, DEVICE,0x00, 0x00,0x00,0x00,0x40};
123 //char SetAddress[] {0x00,SET_ADDRESS, 0x00, address, 0x00,0x00,0x00,0x40};
124 //char SetAddress[] {0x00,SET_ADDRESS, 0x00, 0x00, 0x00,0x00,0x00,0x00};
125
126
127 /*------------------------------------------
128  * transfer types 
129  * ------------------------------------------*/
130
131 #define USB_CTRL                0x00
132 #define USB_ISOC                0x01
133 #define USB_BULK                0x02
134 #define USB_INTR                0x03
135
136 /*-------------------------------------------
137  * device descriptor types 
138  * ------------------------------------------*/
139 #define DO_STANDARD   0x00
140 #define DO_CLASS      0x20
141 #define DO_VENDOR     0x40
142
143 /*-------------------------------------------
144  * standard requests for ep0 
145  * ------------------------------------------*/
146
147 #define GET_STATUS              0x00 
148 #define CLR_FEATURE             0x01
149 #define SET_FEATURE             0x03
150 #define SET_ADDRESS             0x05
151 #define GET_DESCRIPTOR          0x06
152 #define SET_DESCRIPTOR          0x07
153 #define GET_CONFIGURATION       0x08
154 #define SET_CONFIGURATION       0x09
155 #define GET_INTERFACE           0x0A
156 #define SET_INTERFACE           0x0B
157
158 /*-------------------------------------------
159  * descriptor types 
160  * ------------------------------------------*/
161
162 #define DEVICE                  0x01
163 #define CONFIGURATION           0x02
164 #define STRING                  0x03
165 #define INTERFACE               0x04
166 #define ENDPOINT                0x05
167 #define DEVICEQUALIFIER         0x06 // only usb2.0
168 #define OTHERSPEEDCONFIGURATION 0x07 // only usb2.0
169
170
171 /*-------------------------------------------
172  * pid fields 
173  * ------------------------------------------*/
174
175 #define USB_PID_SOF     0x05
176 #define USB_PID_SETUP   0x0D
177 #define USB_PID_IN      0x09
178 #define USB_PID_OUT     0x01
179 #define USB_PID_DATA0   0x03
180 #define USB_PID_DATA1   0x0B
181 #define USB_PID_ACK     0x02
182 #define USB_PID_NACK    0x0A
183 #define USB_PID_STALL   0x0E
184 #define USB_PID_PRE     0x0C
185
186
187 #define HID_CLASSCODE   0x03
188 #define MASS_STORAGE_CLASSCODE  0x08
189 #define HUB_CLASSCODE           0x09
190
191
192
193 #endif /* __USB11SPEC_H__ */