3 * Gerry Hamel, geh@ti.com, Texas Instruments
6 * linux/drivers/usbd/usb-function.h - USB Function
8 * Copyright (c) 2000, 2001, 2002 Lineo
9 * Copyright (c) 2001 Hewlett Packard
12 * Stuart Lynne <sl@lineo.com>,
13 * Tom Rushworth <tbr@lineo.com>,
14 * Bruce Balden <balden@lineo.com>
16 * SPDX-License-Identifier: GPL-2.0+
19 /* USB Descriptors - Create a complete description of all of the
20 * function driver capabilities. These map directly to the USB descriptors.
22 * This heirarchy is created by the functions drivers and is passed to the
23 * usb-device driver when the function driver is registered.
45 * The configuration structures refer to the USB Configurations that will be
46 * made available to a USB HOST during the enumeration process.
48 * The USB HOST will select a configuration and optionally an interface with
49 * the usb set configuration and set interface commands.
51 * The selected interface (or the default interface if not specifically
52 * selected) will define the list of endpoints that will be used.
54 * The configuration and interfaces are stored in an array that is indexed
55 * by the specified configuratin or interface number minus one.
57 * A configuration number of zero is used to specify a return to the unconfigured
63 #ifndef __USBDESCRIPTORS_H__
64 #define __USBDESCRIPTORS_H__
66 #include <asm/types.h>
69 * communications class types
71 * c.f. CDC USB Class Definitions for Communications Devices
72 * c.f. WMCD USB CDC Subclass Specification for Wireless Mobile Communications Devices
76 #define CLASS_BCD_VERSION 0x0110
78 /* c.f. CDC 4.1 Table 14 */
79 #define COMMUNICATIONS_DEVICE_CLASS 0x02
81 /* c.f. CDC 4.2 Table 15 */
82 #define COMMUNICATIONS_INTERFACE_CLASS_CONTROL 0x02
83 #define COMMUNICATIONS_INTERFACE_CLASS_DATA 0x0A
84 #define COMMUNICATIONS_INTERFACE_CLASS_VENDOR 0x0FF
86 /* c.f. CDC 4.3 Table 16 */
87 #define COMMUNICATIONS_NO_SUBCLASS 0x00
88 #define COMMUNICATIONS_DLCM_SUBCLASS 0x01
89 #define COMMUNICATIONS_ACM_SUBCLASS 0x02
90 #define COMMUNICATIONS_TCM_SUBCLASS 0x03
91 #define COMMUNICATIONS_MCCM_SUBCLASS 0x04
92 #define COMMUNICATIONS_CCM_SUBCLASS 0x05
93 #define COMMUNICATIONS_ENCM_SUBCLASS 0x06
94 #define COMMUNICATIONS_ANCM_SUBCLASS 0x07
97 #define COMMUNICATIONS_WHCM_SUBCLASS 0x08
98 #define COMMUNICATIONS_DMM_SUBCLASS 0x09
99 #define COMMUNICATIONS_MDLM_SUBCLASS 0x0a
100 #define COMMUNICATIONS_OBEX_SUBCLASS 0x0b
102 /* c.f. CDC 4.4 Table 17 */
103 #define COMMUNICATIONS_NO_PROTOCOL 0x00
104 #define COMMUNICATIONS_V25TER_PROTOCOL 0x01 /*Common AT Hayes compatible*/
106 /* c.f. CDC 4.5 Table 18 */
107 #define DATA_INTERFACE_CLASS 0x0a
109 /* c.f. CDC 4.6 No Table */
110 #define DATA_INTERFACE_SUBCLASS_NONE 0x00 /* No subclass pertinent */
112 /* c.f. CDC 4.7 Table 19 */
113 #define DATA_INTERFACE_PROTOCOL_NONE 0x00 /* No class protcol required */
116 /* c.f. CDC 5.2.3 Table 24 */
117 #define CS_INTERFACE 0x24
118 #define CS_ENDPOINT 0x25
121 * bDescriptorSubtypes
123 * c.f. CDC 5.2.3 Table 25
124 * c.f. WMCD 5.3 Table 5.3
127 #define USB_ST_HEADER 0x00
128 #define USB_ST_CMF 0x01
129 #define USB_ST_ACMF 0x02
130 #define USB_ST_DLMF 0x03
131 #define USB_ST_TRF 0x04
132 #define USB_ST_TCLF 0x05
133 #define USB_ST_UF 0x06
134 #define USB_ST_CSF 0x07
135 #define USB_ST_TOMF 0x08
136 #define USB_ST_USBTF 0x09
137 #define USB_ST_NCT 0x0a
138 #define USB_ST_PUF 0x0b
139 #define USB_ST_EUF 0x0c
140 #define USB_ST_MCMF 0x0d
141 #define USB_ST_CCMF 0x0e
142 #define USB_ST_ENF 0x0f
143 #define USB_ST_ATMNF 0x10
145 #define USB_ST_WHCM 0x11
146 #define USB_ST_MDLM 0x12
147 #define USB_ST_MDLMD 0x13
148 #define USB_ST_DMM 0x14
149 #define USB_ST_OBEX 0x15
150 #define USB_ST_CS 0x16
151 #define USB_ST_CSD 0x17
152 #define USB_ST_TCM 0x18
154 /* endpoint modifiers
155 * static struct usb_endpoint_description function_default_A_1[] = {
157 * {this_endpoint: 0, attributes: CONTROL, max_size: 8, polling_interval: 0 },
158 * {this_endpoint: 1, attributes: BULK, max_size: 64, polling_interval: 0, direction: IN},
159 * {this_endpoint: 2, attributes: BULK, max_size: 64, polling_interval: 0, direction: OUT},
160 * {this_endpoint: 3, attributes: INTERRUPT, max_size: 8, polling_interval: 0},
168 #define ISOCHRONOUS 0x01
170 #define INTERRUPT 0x03
173 /* configuration modifiers
175 #define BMATTRIBUTE_RESERVED 0x80
176 #define BMATTRIBUTE_SELF_POWERED 0x40
179 * standard usb descriptor structures
182 struct usb_endpoint_descriptor {
184 u8 bDescriptorType; /* 0x5 */
189 } __attribute__ ((packed));
191 struct usb_interface_descriptor {
193 u8 bDescriptorType; /* 0x04 */
195 u8 bAlternateSetting;
198 u8 bInterfaceSubClass;
199 u8 bInterfaceProtocol;
201 } __attribute__ ((packed));
203 struct usb_configuration_descriptor {
205 u8 bDescriptorType; /* 0x2 */
208 u8 bConfigurationValue;
212 } __attribute__ ((packed));
214 struct usb_device_descriptor {
216 u8 bDescriptorType; /* 0x01 */
228 u8 bNumConfigurations;
229 } __attribute__ ((packed));
231 #if defined(CONFIG_USBD_HS)
232 struct usb_qualifier_descriptor {
241 u8 bNumConfigurations;
243 } __attribute__ ((packed));
246 struct usb_string_descriptor {
248 u8 bDescriptorType; /* 0x03 */
250 } __attribute__ ((packed));
252 struct usb_generic_descriptor {
255 u8 bDescriptorSubtype;
256 } __attribute__ ((packed));
260 * communications class descriptor structures
262 * c.f. CDC 5.2 Table 25c
265 struct usb_class_function_descriptor {
268 u8 bDescriptorSubtype;
269 } __attribute__ ((packed));
271 struct usb_class_function_descriptor_generic {
274 u8 bDescriptorSubtype;
276 } __attribute__ ((packed));
278 struct usb_class_header_function_descriptor {
281 u8 bDescriptorSubtype; /* 0x00 */
283 } __attribute__ ((packed));
285 struct usb_class_call_management_descriptor {
288 u8 bDescriptorSubtype; /* 0x01 */
291 } __attribute__ ((packed));
293 struct usb_class_abstract_control_descriptor {
296 u8 bDescriptorSubtype; /* 0x02 */
298 } __attribute__ ((packed));
300 struct usb_class_direct_line_descriptor {
303 u8 bDescriptorSubtype; /* 0x03 */
304 } __attribute__ ((packed));
306 struct usb_class_telephone_ringer_descriptor {
309 u8 bDescriptorSubtype; /* 0x04 */
311 u8 bNumRingerPatterns;
312 } __attribute__ ((packed));
314 struct usb_class_telephone_call_descriptor {
317 u8 bDescriptorSubtype; /* 0x05 */
319 } __attribute__ ((packed));
321 struct usb_class_union_function_descriptor {
324 u8 bDescriptorSubtype; /* 0x06 */
326 /* u8 bSlaveInterface0[0]; */
328 } __attribute__ ((packed));
330 struct usb_class_country_selection_descriptor {
333 u8 bDescriptorSubtype; /* 0x07 */
334 u8 iCountryCodeRelDate;
335 u16 wCountryCode0[0];
336 } __attribute__ ((packed));
339 struct usb_class_telephone_operational_descriptor {
342 u8 bDescriptorSubtype; /* 0x08 */
344 } __attribute__ ((packed));
347 struct usb_class_usb_terminal_descriptor {
350 u8 bDescriptorSubtype; /* 0x09 */
356 } __attribute__ ((packed));
358 struct usb_class_network_channel_descriptor {
361 u8 bDescriptorSubtype; /* 0x0a */
365 u8 bPhysicalInterface;
366 } __attribute__ ((packed));
368 struct usb_class_protocol_unit_function_descriptor {
371 u8 bDescriptorSubtype; /* 0x0b */
375 } __attribute__ ((packed));
377 struct usb_class_extension_unit_descriptor {
380 u8 bDescriptorSubtype; /* 0x0c */
385 } __attribute__ ((packed));
387 struct usb_class_multi_channel_descriptor {
390 u8 bDescriptorSubtype; /* 0x0d */
392 } __attribute__ ((packed));
394 struct usb_class_capi_control_descriptor {
397 u8 bDescriptorSubtype; /* 0x0e */
399 } __attribute__ ((packed));
401 struct usb_class_ethernet_networking_descriptor {
404 u8 bDescriptorSubtype; /* 0x0f */
406 u32 bmEthernetStatistics;
408 u16 wNumberMCFilters;
409 u8 bNumberPowerFilters;
410 } __attribute__ ((packed));
412 struct usb_class_atm_networking_descriptor {
415 u8 bDescriptorSubtype; /* 0x10 */
416 u8 iEndSystermIdentifier;
417 u8 bmDataCapabilities;
418 u8 bmATMDeviceStatistics;
419 u16 wType2MaxSegmentSize;
420 u16 wType3MaxSegmentSize;
422 } __attribute__ ((packed));
425 struct usb_class_mdlm_descriptor {
428 u8 bDescriptorSubtype; /* 0x12 */
431 } __attribute__ ((packed));
433 struct usb_class_mdlmd_descriptor {
436 u8 bDescriptorSubtype; /* 0x13 */
437 u8 bGuidDescriptorType;
440 } __attribute__ ((packed));
443 * HID class descriptor structures
448 struct usb_class_hid_descriptor {
453 u8 bNumDescriptors; /* 0x01 */
455 u16 wDescriptorLength0;
456 /* optional descriptors are not supported. */
457 } __attribute__((packed));
459 struct usb_class_report_descriptor {
460 u8 bLength; /* dummy */
464 } __attribute__((packed));
467 * descriptor union structures
470 struct usb_descriptor {
472 struct usb_generic_descriptor generic;
473 struct usb_endpoint_descriptor endpoint;
474 struct usb_interface_descriptor interface;
475 struct usb_configuration_descriptor configuration;
476 struct usb_device_descriptor device;
477 struct usb_string_descriptor string;
480 } __attribute__ ((packed));
482 struct usb_class_descriptor {
484 struct usb_class_function_descriptor function;
485 struct usb_class_function_descriptor_generic generic;
486 struct usb_class_header_function_descriptor header_function;
487 struct usb_class_call_management_descriptor call_management;
488 struct usb_class_abstract_control_descriptor abstract_control;
489 struct usb_class_direct_line_descriptor direct_line;
490 struct usb_class_telephone_ringer_descriptor telephone_ringer;
491 struct usb_class_telephone_operational_descriptor telephone_operational;
492 struct usb_class_telephone_call_descriptor telephone_call;
493 struct usb_class_union_function_descriptor union_function;
494 struct usb_class_country_selection_descriptor country_selection;
495 struct usb_class_usb_terminal_descriptor usb_terminal;
496 struct usb_class_network_channel_descriptor network_channel;
497 struct usb_class_extension_unit_descriptor extension_unit;
498 struct usb_class_multi_channel_descriptor multi_channel;
499 struct usb_class_capi_control_descriptor capi_control;
500 struct usb_class_ethernet_networking_descriptor ethernet_networking;
501 struct usb_class_atm_networking_descriptor atm_networking;
502 struct usb_class_mdlm_descriptor mobile_direct;
503 struct usb_class_mdlmd_descriptor mobile_direct_detail;
504 struct usb_class_hid_descriptor hid;
507 } __attribute__ ((packed));
510 static inline void print_device_descriptor(struct usb_device_descriptor *d)
512 serial_printf("usb device descriptor \n");
513 serial_printf("\tbLength %2.2x\n", d->bLength);
514 serial_printf("\tbDescriptorType %2.2x\n", d->bDescriptorType);
515 serial_printf("\tbcdUSB %4.4x\n", d->bcdUSB);
516 serial_printf("\tbDeviceClass %2.2x\n", d->bDeviceClass);
517 serial_printf("\tbDeviceSubClass %2.2x\n", d->bDeviceSubClass);
518 serial_printf("\tbDeviceProtocol %2.2x\n", d->bDeviceProtocol);
519 serial_printf("\tbMaxPacketSize0 %2.2x\n", d->bMaxPacketSize0);
520 serial_printf("\tidVendor %4.4x\n", d->idVendor);
521 serial_printf("\tidProduct %4.4x\n", d->idProduct);
522 serial_printf("\tbcdDevice %4.4x\n", d->bcdDevice);
523 serial_printf("\tiManufacturer %2.2x\n", d->iManufacturer);
524 serial_printf("\tiProduct %2.2x\n", d->iProduct);
525 serial_printf("\tiSerialNumber %2.2x\n", d->iSerialNumber);
526 serial_printf("\tbNumConfigurations %2.2x\n", d->bNumConfigurations);
532 #define print_device_descriptor(d)