xref: /openbmc/u-boot/include/usbdescriptors.h (revision 69df3c4d)
1 /*
2  * (C) Copyright 2003
3  * Gerry Hamel, geh@ti.com, Texas Instruments
4  *
5  * Based on
6  * linux/drivers/usbd/usb-function.h - USB Function
7  *
8  * Copyright (c) 2000, 2001, 2002 Lineo
9  * Copyright (c) 2001 Hewlett Packard
10  *
11  * By:
12  *	Stuart Lynne <sl@lineo.com>,
13  *	Tom Rushworth <tbr@lineo.com>,
14  *	Bruce Balden <balden@lineo.com>
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 2 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29  *
30  */
31 
32 /* USB Descriptors - Create a complete description of all of the
33  * function driver capabilities. These map directly to the USB descriptors.
34  *
35  * This heirarchy is created by the functions drivers and is passed to the
36  * usb-device driver when the function driver is registered.
37  *
38  *  device
39  *	configuration
40  *	     interface
41  *		alternate
42  *		     class
43  *		     class
44  *		alternate
45  *		     endpoint
46  *		     endpoint
47  *	     interface
48  *		alternate
49  *		     endpoint
50  *		     endpoint
51  *	configuration
52  *	     interface
53  *		alternate
54  *		     endpoint
55  *		     endpoint
56  *
57  *
58  * The configuration structures refer to the USB Configurations that will be
59  * made available to a USB HOST during the enumeration process.
60  *
61  * The USB HOST will select a configuration and optionally an interface with
62  * the usb set configuration and set interface commands.
63  *
64  * The selected interface (or the default interface if not specifically
65  * selected) will define the list of endpoints that will be used.
66  *
67  * The configuration and interfaces are stored in an array that is indexed
68  * by the specified configuratin or interface number minus one.
69  *
70  * A configuration number of zero is used to specify a return to the unconfigured
71  * state.
72  *
73  */
74 
75 
76 #ifndef __USBDESCRIPTORS_H__
77 #define __USBDESCRIPTORS_H__
78 
79 #include <asm/types.h>
80 
81 /*
82  * communications class types
83  *
84  * c.f. CDC  USB Class Definitions for Communications Devices
85  * c.f. WMCD USB CDC Subclass Specification for Wireless Mobile Communications Devices
86  *
87  */
88 
89 #define CLASS_BCD_VERSION		0x0110
90 
91 /* c.f. CDC 4.1 Table 14 */
92 #define COMMUNICATIONS_DEVICE_CLASS	0x02
93 
94 /* c.f. CDC 4.2 Table 15 */
95 #define COMMUNICATIONS_INTERFACE_CLASS	0x02
96 
97 /* c.f. CDC 4.3 Table 16 */
98 #define COMMUNICATIONS_NO_SUBCLASS	0x00
99 #define COMMUNICATIONS_DLCM_SUBCLASS	0x01
100 #define COMMUNICATIONS_ACM_SUBCLASS	0x02
101 #define COMMUNICATIONS_TCM_SUBCLASS	0x03
102 #define COMMUNICATIONS_MCCM_SUBCLASS	0x04
103 #define COMMUNICATIONS_CCM_SUBCLASS	0x05
104 #define COMMUNICATIONS_ENCM_SUBCLASS	0x06
105 #define COMMUNICATIONS_ANCM_SUBCLASS	0x07
106 
107 /* c.f. WMCD 5.1 */
108 #define COMMUNICATIONS_WHCM_SUBCLASS	0x08
109 #define COMMUNICATIONS_DMM_SUBCLASS	0x09
110 #define COMMUNICATIONS_MDLM_SUBCLASS	0x0a
111 #define COMMUNICATIONS_OBEX_SUBCLASS	0x0b
112 
113 /* c.f. CDC 4.6 Table 18 */
114 #define DATA_INTERFACE_CLASS		0x0a
115 
116 /* c.f. CDC 4.7 Table 19 */
117 #define COMMUNICATIONS_NO_PROTOCOL	0x00
118 
119 
120 /* c.f. CDC 5.2.3 Table 24 */
121 #define CS_INTERFACE			0x24
122 #define CS_ENDPOINT			0x25
123 
124 /*
125  * bDescriptorSubtypes
126  *
127  * c.f. CDC 5.2.3 Table 25
128  * c.f. WMCD 5.3 Table 5.3
129  */
130 
131 #define USB_ST_HEADER			0x00
132 #define USB_ST_CMF			0x01
133 #define USB_ST_ACMF			0x02
134 #define USB_ST_DLMF			0x03
135 #define USB_ST_TRF			0x04
136 #define USB_ST_TCLF			0x05
137 #define USB_ST_UF			0x06
138 #define USB_ST_CSF			0x07
139 #define USB_ST_TOMF			0x08
140 #define USB_ST_USBTF			0x09
141 #define USB_ST_NCT			0x0a
142 #define USB_ST_PUF			0x0b
143 #define USB_ST_EUF			0x0c
144 #define USB_ST_MCMF			0x0d
145 #define USB_ST_CCMF			0x0e
146 #define USB_ST_ENF			0x0f
147 #define USB_ST_ATMNF			0x10
148 
149 #define USB_ST_WHCM			0x11
150 #define USB_ST_MDLM			0x12
151 #define USB_ST_MDLMD			0x13
152 #define USB_ST_DMM			0x14
153 #define USB_ST_OBEX			0x15
154 #define USB_ST_CS			0x16
155 #define USB_ST_CSD			0x17
156 #define USB_ST_TCM			0x18
157 
158 /* endpoint modifiers
159  * static struct usb_endpoint_description function_default_A_1[] = {
160  *
161  *     {this_endpoint: 0, attributes: CONTROL,	 max_size: 8,  polling_interval: 0 },
162  *     {this_endpoint: 1, attributes: BULK,	 max_size: 64, polling_interval: 0, direction: IN},
163  *     {this_endpoint: 2, attributes: BULK,	 max_size: 64, polling_interval: 0, direction: OUT},
164  *     {this_endpoint: 3, attributes: INTERRUPT, max_size: 8,  polling_interval: 0},
165  *
166  *
167  */
168 #define OUT		0x00
169 #define IN		0x80
170 
171 #define CONTROL		0x00
172 #define ISOCHRONOUS	0x01
173 #define BULK		0x02
174 #define INTERRUPT	0x03
175 
176 
177 /* configuration modifiers
178  */
179 #define BMATTRIBUTE_RESERVED		0x80
180 #define BMATTRIBUTE_SELF_POWERED	0x40
181 
182 /*
183  * standard usb descriptor structures
184  */
185 
186 struct usb_endpoint_descriptor {
187 	u8 bLength;
188 	u8 bDescriptorType;	/* 0x5 */
189 	u8 bEndpointAddress;
190 	u8 bmAttributes;
191 	u16 wMaxPacketSize;
192 	u8 bInterval;
193 } __attribute__ ((packed));
194 
195 struct usb_interface_descriptor {
196 	u8 bLength;
197 	u8 bDescriptorType;	/* 0x04 */
198 	u8 bInterfaceNumber;
199 	u8 bAlternateSetting;
200 	u8 bNumEndpoints;
201 	u8 bInterfaceClass;
202 	u8 bInterfaceSubClass;
203 	u8 bInterfaceProtocol;
204 	u8 iInterface;
205 } __attribute__ ((packed));
206 
207 struct usb_configuration_descriptor {
208 	u8 bLength;
209 	u8 bDescriptorType;	/* 0x2 */
210 	u16 wTotalLength;
211 	u8 bNumInterfaces;
212 	u8 bConfigurationValue;
213 	u8 iConfiguration;
214 	u8 bmAttributes;
215 	u8 bMaxPower;
216 } __attribute__ ((packed));
217 
218 struct usb_device_descriptor {
219 	u8 bLength;
220 	u8 bDescriptorType;	/* 0x01 */
221 	u16 bcdUSB;
222 	u8 bDeviceClass;
223 	u8 bDeviceSubClass;
224 	u8 bDeviceProtocol;
225 	u8 bMaxPacketSize0;
226 	u16 idVendor;
227 	u16 idProduct;
228 	u16 bcdDevice;
229 	u8 iManufacturer;
230 	u8 iProduct;
231 	u8 iSerialNumber;
232 	u8 bNumConfigurations;
233 } __attribute__ ((packed));
234 
235 struct usb_string_descriptor {
236 	u8 bLength;
237 	u8 bDescriptorType;	/* 0x03 */
238 	u16 wData[0];
239 } __attribute__ ((packed));
240 
241 struct usb_generic_descriptor {
242 	u8 bLength;
243 	u8 bDescriptorType;
244 	u8 bDescriptorSubtype;
245 } __attribute__ ((packed));
246 
247 
248 /*
249  * communications class descriptor structures
250  *
251  * c.f. CDC 5.2 Table 25c
252  */
253 
254 struct usb_class_function_descriptor {
255 	u8 bFunctionLength;
256 	u8 bDescriptorType;
257 	u8 bDescriptorSubtype;
258 } __attribute__ ((packed));
259 
260 struct usb_class_function_descriptor_generic {
261 	u8 bFunctionLength;
262 	u8 bDescriptorType;
263 	u8 bDescriptorSubtype;
264 	u8 bmCapabilities;
265 } __attribute__ ((packed));
266 
267 struct usb_class_header_function_descriptor {
268 	u8 bFunctionLength;
269 	u8 bDescriptorType;
270 	u8 bDescriptorSubtype;	/* 0x00 */
271 	u16 bcdCDC;
272 } __attribute__ ((packed));
273 
274 struct usb_class_call_management_descriptor {
275 	u8 bFunctionLength;
276 	u8 bDescriptorType;
277 	u8 bDescriptorSubtype;	/* 0x01 */
278 	u8 bmCapabilities;
279 	u8 bDataInterface;
280 } __attribute__ ((packed));
281 
282 struct usb_class_abstract_control_descriptor {
283 	u8 bFunctionLength;
284 	u8 bDescriptorType;
285 	u8 bDescriptorSubtype;	/* 0x02 */
286 	u8 bmCapabilities;
287 } __attribute__ ((packed));
288 
289 struct usb_class_direct_line_descriptor {
290 	u8 bFunctionLength;
291 	u8 bDescriptorType;
292 	u8 bDescriptorSubtype;	/* 0x03 */
293 } __attribute__ ((packed));
294 
295 struct usb_class_telephone_ringer_descriptor {
296 	u8 bFunctionLength;
297 	u8 bDescriptorType;
298 	u8 bDescriptorSubtype;	/* 0x04 */
299 	u8 bRingerVolSeps;
300 	u8 bNumRingerPatterns;
301 } __attribute__ ((packed));
302 
303 struct usb_class_telephone_call_descriptor {
304 	u8 bFunctionLength;
305 	u8 bDescriptorType;
306 	u8 bDescriptorSubtype;	/* 0x05 */
307 	u8 bmCapabilities;
308 } __attribute__ ((packed));
309 
310 struct usb_class_union_function_descriptor {
311 	u8 bFunctionLength;
312 	u8 bDescriptorType;
313 	u8 bDescriptorSubtype;	/* 0x06 */
314 	u8 bMasterInterface;
315 	u8 bSlaveInterface0[0];
316 } __attribute__ ((packed));
317 
318 struct usb_class_country_selection_descriptor {
319 	u8 bFunctionLength;
320 	u8 bDescriptorType;
321 	u8 bDescriptorSubtype;	/* 0x07 */
322 	u8 iCountryCodeRelDate;
323 	u16 wCountryCode0[0];
324 } __attribute__ ((packed));
325 
326 
327 struct usb_class_telephone_operational_descriptor {
328 	u8 bFunctionLength;
329 	u8 bDescriptorType;
330 	u8 bDescriptorSubtype;	/* 0x08 */
331 	u8 bmCapabilities;
332 } __attribute__ ((packed));
333 
334 
335 struct usb_class_usb_terminal_descriptor {
336 	u8 bFunctionLength;
337 	u8 bDescriptorType;
338 	u8 bDescriptorSubtype;	/* 0x09 */
339 	u8 bEntityId;
340 	u8 bInterfaceNo;
341 	u8 bOutInterfaceNo;
342 	u8 bmOptions;
343 	u8 bChild0[0];
344 } __attribute__ ((packed));
345 
346 struct usb_class_network_channel_descriptor {
347 	u8 bFunctionLength;
348 	u8 bDescriptorType;
349 	u8 bDescriptorSubtype;	/* 0x0a */
350 	u8 bEntityId;
351 	u8 iName;
352 	u8 bChannelIndex;
353 	u8 bPhysicalInterface;
354 } __attribute__ ((packed));
355 
356 struct usb_class_protocol_unit_function_descriptor {
357 	u8 bFunctionLength;
358 	u8 bDescriptorType;
359 	u8 bDescriptorSubtype;	/* 0x0b */
360 	u8 bEntityId;
361 	u8 bProtocol;
362 	u8 bChild0[0];
363 } __attribute__ ((packed));
364 
365 struct usb_class_extension_unit_descriptor {
366 	u8 bFunctionLength;
367 	u8 bDescriptorType;
368 	u8 bDescriptorSubtype;	/* 0x0c */
369 	u8 bEntityId;
370 	u8 bExtensionCode;
371 	u8 iName;
372 	u8 bChild0[0];
373 } __attribute__ ((packed));
374 
375 struct usb_class_multi_channel_descriptor {
376 	u8 bFunctionLength;
377 	u8 bDescriptorType;
378 	u8 bDescriptorSubtype;	/* 0x0d */
379 	u8 bmCapabilities;
380 } __attribute__ ((packed));
381 
382 struct usb_class_capi_control_descriptor {
383 	u8 bFunctionLength;
384 	u8 bDescriptorType;
385 	u8 bDescriptorSubtype;	/* 0x0e */
386 	u8 bmCapabilities;
387 } __attribute__ ((packed));
388 
389 struct usb_class_ethernet_networking_descriptor {
390 	u8 bFunctionLength;
391 	u8 bDescriptorType;
392 	u8 bDescriptorSubtype;	/* 0x0f */
393 	u8 iMACAddress;
394 	u32 bmEthernetStatistics;
395 	u16 wMaxSegmentSize;
396 	u16 wNumberMCFilters;
397 	u8 bNumberPowerFilters;
398 } __attribute__ ((packed));
399 
400 struct usb_class_atm_networking_descriptor {
401 	u8 bFunctionLength;
402 	u8 bDescriptorType;
403 	u8 bDescriptorSubtype;	/* 0x10 */
404 	u8 iEndSystermIdentifier;
405 	u8 bmDataCapabilities;
406 	u8 bmATMDeviceStatistics;
407 	u16 wType2MaxSegmentSize;
408 	u16 wType3MaxSegmentSize;
409 	u16 wMaxVC;
410 } __attribute__ ((packed));
411 
412 
413 struct usb_class_mdlm_descriptor {
414 	u8 bFunctionLength;
415 	u8 bDescriptorType;
416 	u8 bDescriptorSubtype;	/* 0x12 */
417 	u16 bcdVersion;
418 	u8 bGUID[16];
419 } __attribute__ ((packed));
420 
421 struct usb_class_mdlmd_descriptor {
422 	u8 bFunctionLength;
423 	u8 bDescriptorType;
424 	u8 bDescriptorSubtype;	/* 0x13 */
425 	u8 bGuidDescriptorType;
426 	u8 bDetailData[0];
427 
428 } __attribute__ ((packed));
429 
430 /*
431  * HID class descriptor structures
432  *
433  * c.f. HID 6.2.1
434  */
435 
436 struct usb_class_hid_descriptor {
437     u8	      bLength;
438     u8	      bDescriptorType;
439     u16	      bcdCDC;
440     u8	      bCountryCode;
441     u8	      bNumDescriptors;	/* 0x01 */
442     u8	      bDescriptorType0;
443     u16	      wDescriptorLength0;
444     /* optional descriptors are not supported. */
445 } __attribute__((packed));
446 
447 struct usb_class_report_descriptor {
448     u8	      bLength;	/* dummy */
449     u8	      bDescriptorType;
450     u16	      wLength;
451     u8		bData[0];
452 } __attribute__((packed));
453 
454 /*
455  * descriptor union structures
456  */
457 
458 struct usb_descriptor {
459 	union {
460 		struct usb_generic_descriptor generic;
461 		struct usb_endpoint_descriptor endpoint;
462 		struct usb_interface_descriptor interface;
463 		struct usb_configuration_descriptor configuration;
464 		struct usb_device_descriptor device;
465 		struct usb_string_descriptor string;
466 	} descriptor;
467 
468 } __attribute__ ((packed));
469 
470 struct usb_class_descriptor {
471 	union {
472 		struct usb_class_function_descriptor function;
473 		struct usb_class_function_descriptor_generic generic;
474 		struct usb_class_header_function_descriptor header_function;
475 		struct usb_class_call_management_descriptor call_management;
476 		struct usb_class_abstract_control_descriptor abstract_control;
477 		struct usb_class_direct_line_descriptor direct_line;
478 		struct usb_class_telephone_ringer_descriptor telephone_ringer;
479 		struct usb_class_telephone_operational_descriptor telephone_operational;
480 		struct usb_class_telephone_call_descriptor telephone_call;
481 		struct usb_class_union_function_descriptor union_function;
482 		struct usb_class_country_selection_descriptor country_selection;
483 		struct usb_class_usb_terminal_descriptor usb_terminal;
484 		struct usb_class_network_channel_descriptor network_channel;
485 		struct usb_class_extension_unit_descriptor extension_unit;
486 		struct usb_class_multi_channel_descriptor multi_channel;
487 		struct usb_class_capi_control_descriptor capi_control;
488 		struct usb_class_ethernet_networking_descriptor ethernet_networking;
489 		struct usb_class_atm_networking_descriptor atm_networking;
490 		struct usb_class_mdlm_descriptor mobile_direct;
491 		struct usb_class_mdlmd_descriptor mobile_direct_detail;
492 		struct usb_class_hid_descriptor hid;
493 	} descriptor;
494 
495 } __attribute__ ((packed));
496 
497 #endif
498