1 /* SPDX-License-Identifier: GPL-2.0+ */
4 * Gerry Hamel, geh@ti.com, Texas Instruments
7 * linux/drivers/usbd/usb-function.h - USB Function
9 * Copyright (c) 2000, 2001, 2002 Lineo
10 * Copyright (c) 2001 Hewlett Packard
13 * Stuart Lynne <sl@lineo.com>,
14 * Tom Rushworth <tbr@lineo.com>,
15 * Bruce Balden <balden@lineo.com>
18 /* USB Descriptors - Create a complete description of all of the
19 * function driver capabilities. These map directly to the USB descriptors.
21 * This heirarchy is created by the functions drivers and is passed to the
22 * usb-device driver when the function driver is registered.
44 * The configuration structures refer to the USB Configurations that will be
45 * made available to a USB HOST during the enumeration process.
47 * The USB HOST will select a configuration and optionally an interface with
48 * the usb set configuration and set interface commands.
50 * The selected interface (or the default interface if not specifically
51 * selected) will define the list of endpoints that will be used.
53 * The configuration and interfaces are stored in an array that is indexed
54 * by the specified configuratin or interface number minus one.
56 * A configuration number of zero is used to specify a return to the unconfigured
62 #ifndef __USBDESCRIPTORS_H__
63 #define __USBDESCRIPTORS_H__
65 #include <asm/types.h>
68 * communications class types
70 * c.f. CDC USB Class Definitions for Communications Devices
71 * c.f. WMCD USB CDC Subclass Specification for Wireless Mobile Communications Devices
75 #define CLASS_BCD_VERSION 0x0110
77 /* c.f. CDC 4.1 Table 14 */
78 #define COMMUNICATIONS_DEVICE_CLASS 0x02
80 /* c.f. CDC 4.2 Table 15 */
81 #define COMMUNICATIONS_INTERFACE_CLASS_CONTROL 0x02
82 #define COMMUNICATIONS_INTERFACE_CLASS_DATA 0x0A
83 #define COMMUNICATIONS_INTERFACE_CLASS_VENDOR 0x0FF
85 /* c.f. CDC 4.3 Table 16 */
86 #define COMMUNICATIONS_NO_SUBCLASS 0x00
87 #define COMMUNICATIONS_DLCM_SUBCLASS 0x01
88 #define COMMUNICATIONS_ACM_SUBCLASS 0x02
89 #define COMMUNICATIONS_TCM_SUBCLASS 0x03
90 #define COMMUNICATIONS_MCCM_SUBCLASS 0x04
91 #define COMMUNICATIONS_CCM_SUBCLASS 0x05
92 #define COMMUNICATIONS_ENCM_SUBCLASS 0x06
93 #define COMMUNICATIONS_ANCM_SUBCLASS 0x07
96 #define COMMUNICATIONS_WHCM_SUBCLASS 0x08
97 #define COMMUNICATIONS_DMM_SUBCLASS 0x09
98 #define COMMUNICATIONS_MDLM_SUBCLASS 0x0a
99 #define COMMUNICATIONS_OBEX_SUBCLASS 0x0b
101 /* c.f. CDC 4.4 Table 17 */
102 #define COMMUNICATIONS_NO_PROTOCOL 0x00
103 #define COMMUNICATIONS_V25TER_PROTOCOL 0x01 /*Common AT Hayes compatible*/
105 /* c.f. CDC 4.5 Table 18 */
106 #define DATA_INTERFACE_CLASS 0x0a
108 /* c.f. CDC 4.6 No Table */
109 #define DATA_INTERFACE_SUBCLASS_NONE 0x00 /* No subclass pertinent */
111 /* c.f. CDC 4.7 Table 19 */
112 #define DATA_INTERFACE_PROTOCOL_NONE 0x00 /* No class protcol required */
115 /* c.f. CDC 5.2.3 Table 24 */
116 #define CS_INTERFACE 0x24
117 #define CS_ENDPOINT 0x25
120 * bDescriptorSubtypes
122 * c.f. CDC 5.2.3 Table 25
123 * c.f. WMCD 5.3 Table 5.3
126 #define USB_ST_HEADER 0x00
127 #define USB_ST_CMF 0x01
128 #define USB_ST_ACMF 0x02
129 #define USB_ST_DLMF 0x03
130 #define USB_ST_TRF 0x04
131 #define USB_ST_TCLF 0x05
132 #define USB_ST_UF 0x06
133 #define USB_ST_CSF 0x07
134 #define USB_ST_TOMF 0x08
135 #define USB_ST_USBTF 0x09
136 #define USB_ST_NCT 0x0a
137 #define USB_ST_PUF 0x0b
138 #define USB_ST_EUF 0x0c
139 #define USB_ST_MCMF 0x0d
140 #define USB_ST_CCMF 0x0e
141 #define USB_ST_ENF 0x0f
142 #define USB_ST_ATMNF 0x10
144 #define USB_ST_WHCM 0x11
145 #define USB_ST_MDLM 0x12
146 #define USB_ST_MDLMD 0x13
147 #define USB_ST_DMM 0x14
148 #define USB_ST_OBEX 0x15
149 #define USB_ST_CS 0x16
150 #define USB_ST_CSD 0x17
151 #define USB_ST_TCM 0x18
153 /* endpoint modifiers
154 * static struct usb_endpoint_description function_default_A_1[] = {
156 * {this_endpoint: 0, attributes: CONTROL, max_size: 8, polling_interval: 0 },
157 * {this_endpoint: 1, attributes: BULK, max_size: 64, polling_interval: 0, direction: IN},
158 * {this_endpoint: 2, attributes: BULK, max_size: 64, polling_interval: 0, direction: OUT},
159 * {this_endpoint: 3, attributes: INTERRUPT, max_size: 8, polling_interval: 0},
167 #define ISOCHRONOUS 0x01
169 #define INTERRUPT 0x03
172 /* configuration modifiers
174 #define BMATTRIBUTE_RESERVED 0x80
175 #define BMATTRIBUTE_SELF_POWERED 0x40
178 * standard usb descriptor structures
181 struct usb_endpoint_descriptor {
183 u8 bDescriptorType; /* 0x5 */
188 } __attribute__ ((packed));
190 struct usb_interface_descriptor {
192 u8 bDescriptorType; /* 0x04 */
194 u8 bAlternateSetting;
197 u8 bInterfaceSubClass;
198 u8 bInterfaceProtocol;
200 } __attribute__ ((packed));
202 struct usb_configuration_descriptor {
204 u8 bDescriptorType; /* 0x2 */
207 u8 bConfigurationValue;
211 } __attribute__ ((packed));
213 struct usb_device_descriptor {
215 u8 bDescriptorType; /* 0x01 */
227 u8 bNumConfigurations;
228 } __attribute__ ((packed));
230 struct usb_string_descriptor {
232 u8 bDescriptorType; /* 0x03 */
234 } __attribute__ ((packed));
236 struct usb_generic_descriptor {
239 u8 bDescriptorSubtype;
240 } __attribute__ ((packed));
244 * communications class descriptor structures
246 * c.f. CDC 5.2 Table 25c
249 struct usb_class_function_descriptor {
252 u8 bDescriptorSubtype;
253 } __attribute__ ((packed));
255 struct usb_class_function_descriptor_generic {
258 u8 bDescriptorSubtype;
260 } __attribute__ ((packed));
262 struct usb_class_header_function_descriptor {
265 u8 bDescriptorSubtype; /* 0x00 */
267 } __attribute__ ((packed));
269 struct usb_class_call_management_descriptor {
272 u8 bDescriptorSubtype; /* 0x01 */
275 } __attribute__ ((packed));
277 struct usb_class_abstract_control_descriptor {
280 u8 bDescriptorSubtype; /* 0x02 */
282 } __attribute__ ((packed));
284 struct usb_class_direct_line_descriptor {
287 u8 bDescriptorSubtype; /* 0x03 */
288 } __attribute__ ((packed));
290 struct usb_class_telephone_ringer_descriptor {
293 u8 bDescriptorSubtype; /* 0x04 */
295 u8 bNumRingerPatterns;
296 } __attribute__ ((packed));
298 struct usb_class_telephone_call_descriptor {
301 u8 bDescriptorSubtype; /* 0x05 */
303 } __attribute__ ((packed));
305 struct usb_class_union_function_descriptor {
308 u8 bDescriptorSubtype; /* 0x06 */
310 /* u8 bSlaveInterface0[0]; */
312 } __attribute__ ((packed));
314 struct usb_class_country_selection_descriptor {
317 u8 bDescriptorSubtype; /* 0x07 */
318 u8 iCountryCodeRelDate;
319 u16 wCountryCode0[0];
320 } __attribute__ ((packed));
323 struct usb_class_telephone_operational_descriptor {
326 u8 bDescriptorSubtype; /* 0x08 */
328 } __attribute__ ((packed));
331 struct usb_class_usb_terminal_descriptor {
334 u8 bDescriptorSubtype; /* 0x09 */
340 } __attribute__ ((packed));
342 struct usb_class_network_channel_descriptor {
345 u8 bDescriptorSubtype; /* 0x0a */
349 u8 bPhysicalInterface;
350 } __attribute__ ((packed));
352 struct usb_class_protocol_unit_function_descriptor {
355 u8 bDescriptorSubtype; /* 0x0b */
359 } __attribute__ ((packed));
361 struct usb_class_extension_unit_descriptor {
364 u8 bDescriptorSubtype; /* 0x0c */
369 } __attribute__ ((packed));
371 struct usb_class_multi_channel_descriptor {
374 u8 bDescriptorSubtype; /* 0x0d */
376 } __attribute__ ((packed));
378 struct usb_class_capi_control_descriptor {
381 u8 bDescriptorSubtype; /* 0x0e */
383 } __attribute__ ((packed));
385 struct usb_class_ethernet_networking_descriptor {
388 u8 bDescriptorSubtype; /* 0x0f */
390 u32 bmEthernetStatistics;
392 u16 wNumberMCFilters;
393 u8 bNumberPowerFilters;
394 } __attribute__ ((packed));
396 struct usb_class_atm_networking_descriptor {
399 u8 bDescriptorSubtype; /* 0x10 */
400 u8 iEndSystermIdentifier;
401 u8 bmDataCapabilities;
402 u8 bmATMDeviceStatistics;
403 u16 wType2MaxSegmentSize;
404 u16 wType3MaxSegmentSize;
406 } __attribute__ ((packed));
409 struct usb_class_mdlm_descriptor {
412 u8 bDescriptorSubtype; /* 0x12 */
415 } __attribute__ ((packed));
417 struct usb_class_mdlmd_descriptor {
420 u8 bDescriptorSubtype; /* 0x13 */
421 u8 bGuidDescriptorType;
424 } __attribute__ ((packed));
427 * HID class descriptor structures
432 struct usb_class_hid_descriptor {
437 u8 bNumDescriptors; /* 0x01 */
439 u16 wDescriptorLength0;
440 /* optional descriptors are not supported. */
441 } __attribute__((packed));
443 struct usb_class_report_descriptor {
444 u8 bLength; /* dummy */
448 } __attribute__((packed));
451 * descriptor union structures
454 struct usb_descriptor {
456 struct usb_generic_descriptor generic;
457 struct usb_endpoint_descriptor endpoint;
458 struct usb_interface_descriptor interface;
459 struct usb_configuration_descriptor configuration;
460 struct usb_device_descriptor device;
461 struct usb_string_descriptor string;
464 } __attribute__ ((packed));
466 struct usb_class_descriptor {
468 struct usb_class_function_descriptor function;
469 struct usb_class_function_descriptor_generic generic;
470 struct usb_class_header_function_descriptor header_function;
471 struct usb_class_call_management_descriptor call_management;
472 struct usb_class_abstract_control_descriptor abstract_control;
473 struct usb_class_direct_line_descriptor direct_line;
474 struct usb_class_telephone_ringer_descriptor telephone_ringer;
475 struct usb_class_telephone_operational_descriptor telephone_operational;
476 struct usb_class_telephone_call_descriptor telephone_call;
477 struct usb_class_union_function_descriptor union_function;
478 struct usb_class_country_selection_descriptor country_selection;
479 struct usb_class_usb_terminal_descriptor usb_terminal;
480 struct usb_class_network_channel_descriptor network_channel;
481 struct usb_class_extension_unit_descriptor extension_unit;
482 struct usb_class_multi_channel_descriptor multi_channel;
483 struct usb_class_capi_control_descriptor capi_control;
484 struct usb_class_ethernet_networking_descriptor ethernet_networking;
485 struct usb_class_atm_networking_descriptor atm_networking;
486 struct usb_class_mdlm_descriptor mobile_direct;
487 struct usb_class_mdlmd_descriptor mobile_direct_detail;
488 struct usb_class_hid_descriptor hid;
491 } __attribute__ ((packed));
494 static inline void print_device_descriptor(struct usb_device_descriptor *d)
496 serial_printf("usb device descriptor \n");
497 serial_printf("\tbLength %2.2x\n", d->bLength);
498 serial_printf("\tbDescriptorType %2.2x\n", d->bDescriptorType);
499 serial_printf("\tbcdUSB %4.4x\n", d->bcdUSB);
500 serial_printf("\tbDeviceClass %2.2x\n", d->bDeviceClass);
501 serial_printf("\tbDeviceSubClass %2.2x\n", d->bDeviceSubClass);
502 serial_printf("\tbDeviceProtocol %2.2x\n", d->bDeviceProtocol);
503 serial_printf("\tbMaxPacketSize0 %2.2x\n", d->bMaxPacketSize0);
504 serial_printf("\tidVendor %4.4x\n", d->idVendor);
505 serial_printf("\tidProduct %4.4x\n", d->idProduct);
506 serial_printf("\tbcdDevice %4.4x\n", d->bcdDevice);
507 serial_printf("\tiManufacturer %2.2x\n", d->iManufacturer);
508 serial_printf("\tiProduct %2.2x\n", d->iProduct);
509 serial_printf("\tiSerialNumber %2.2x\n", d->iSerialNumber);
510 serial_printf("\tbNumConfigurations %2.2x\n", d->bNumConfigurations);
516 #define print_device_descriptor(d)