1 /* SPDX-License-Identifier: GPL-2.0+ */
7 * linux/drivers/usbd/usb-function.h - USB Function
9 * Copyright (c) 2000, 2001, 2002 Lineo
10 * Copyright (c) 2001 Hewlett Packard
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
61 #ifndef __USBDESCRIPTORS_H__
62 #define __USBDESCRIPTORS_H__
64 #include <asm/types.h>
67 * communications class types
69 * c.f. CDC USB Class Definitions for Communications Devices
70 * c.f. WMCD USB CDC Subclass Specification for Wireless Mobile Communications Devices
74 #define CLASS_BCD_VERSION 0x0110
76 /* c.f. CDC 4.1 Table 14 */
77 #define COMMUNICATIONS_DEVICE_CLASS 0x02
79 /* c.f. CDC 4.2 Table 15 */
80 #define COMMUNICATIONS_INTERFACE_CLASS_CONTROL 0x02
81 #define COMMUNICATIONS_INTERFACE_CLASS_DATA 0x0A
82 #define COMMUNICATIONS_INTERFACE_CLASS_VENDOR 0x0FF
84 /* c.f. CDC 4.3 Table 16 */
85 #define COMMUNICATIONS_NO_SUBCLASS 0x00
86 #define COMMUNICATIONS_DLCM_SUBCLASS 0x01
87 #define COMMUNICATIONS_ACM_SUBCLASS 0x02
88 #define COMMUNICATIONS_TCM_SUBCLASS 0x03
89 #define COMMUNICATIONS_MCCM_SUBCLASS 0x04
90 #define COMMUNICATIONS_CCM_SUBCLASS 0x05
91 #define COMMUNICATIONS_ENCM_SUBCLASS 0x06
92 #define COMMUNICATIONS_ANCM_SUBCLASS 0x07
95 #define COMMUNICATIONS_WHCM_SUBCLASS 0x08
96 #define COMMUNICATIONS_DMM_SUBCLASS 0x09
97 #define COMMUNICATIONS_MDLM_SUBCLASS 0x0a
98 #define COMMUNICATIONS_OBEX_SUBCLASS 0x0b
100 /* c.f. CDC 4.4 Table 17 */
101 #define COMMUNICATIONS_NO_PROTOCOL 0x00
102 #define COMMUNICATIONS_V25TER_PROTOCOL 0x01 /*Common AT Hayes compatible*/
104 /* c.f. CDC 4.5 Table 18 */
105 #define DATA_INTERFACE_CLASS 0x0a
107 /* c.f. CDC 4.6 No Table */
108 #define DATA_INTERFACE_SUBCLASS_NONE 0x00 /* No subclass pertinent */
110 /* c.f. CDC 4.7 Table 19 */
111 #define DATA_INTERFACE_PROTOCOL_NONE 0x00 /* No class protcol required */
113 /* c.f. CDC 5.2.3 Table 24 */
114 #define CS_INTERFACE 0x24
115 #define CS_ENDPOINT 0x25
118 * bDescriptorSubtypes
120 * c.f. CDC 5.2.3 Table 25
121 * c.f. WMCD 5.3 Table 5.3
124 #define USB_ST_HEADER 0x00
125 #define USB_ST_CMF 0x01
126 #define USB_ST_ACMF 0x02
127 #define USB_ST_DLMF 0x03
128 #define USB_ST_TRF 0x04
129 #define USB_ST_TCLF 0x05
130 #define USB_ST_UF 0x06
131 #define USB_ST_CSF 0x07
132 #define USB_ST_TOMF 0x08
133 #define USB_ST_USBTF 0x09
134 #define USB_ST_NCT 0x0a
135 #define USB_ST_PUF 0x0b
136 #define USB_ST_EUF 0x0c
137 #define USB_ST_MCMF 0x0d
138 #define USB_ST_CCMF 0x0e
139 #define USB_ST_ENF 0x0f
140 #define USB_ST_ATMNF 0x10
142 #define USB_ST_WHCM 0x11
143 #define USB_ST_MDLM 0x12
144 #define USB_ST_MDLMD 0x13
145 #define USB_ST_DMM 0x14
146 #define USB_ST_OBEX 0x15
147 #define USB_ST_CS 0x16
148 #define USB_ST_CSD 0x17
149 #define USB_ST_TCM 0x18
151 /* endpoint modifiers
152 * static struct usb_endpoint_description function_default_A_1[] = {
154 * {this_endpoint: 0, attributes: CONTROL, max_size: 8, polling_interval: 0 },
155 * {this_endpoint: 1, attributes: BULK, max_size: 64, polling_interval: 0, direction: IN},
156 * {this_endpoint: 2, attributes: BULK, max_size: 64, polling_interval: 0, direction: OUT},
157 * {this_endpoint: 3, attributes: INTERRUPT, max_size: 8, polling_interval: 0},
165 #define ISOCHRONOUS 0x01
167 #define INTERRUPT 0x03
169 /* configuration modifiers
171 #define BMATTRIBUTE_RESERVED 0x80
172 #define BMATTRIBUTE_SELF_POWERED 0x40
175 * standard usb descriptor structures
178 struct usb_endpoint_descriptor {
180 u8 bDescriptorType; /* 0x5 */
185 } __attribute__ ((packed));
187 struct usb_interface_descriptor {
189 u8 bDescriptorType; /* 0x04 */
191 u8 bAlternateSetting;
194 u8 bInterfaceSubClass;
195 u8 bInterfaceProtocol;
197 } __attribute__ ((packed));
199 struct usb_configuration_descriptor {
201 u8 bDescriptorType; /* 0x2 */
204 u8 bConfigurationValue;
208 } __attribute__ ((packed));
210 struct usb_device_descriptor {
212 u8 bDescriptorType; /* 0x01 */
224 u8 bNumConfigurations;
225 } __attribute__ ((packed));
227 struct usb_string_descriptor {
229 u8 bDescriptorType; /* 0x03 */
231 } __attribute__ ((packed));
233 struct usb_generic_descriptor {
236 u8 bDescriptorSubtype;
237 } __attribute__ ((packed));
240 * communications class descriptor structures
242 * c.f. CDC 5.2 Table 25c
245 struct usb_class_function_descriptor {
248 u8 bDescriptorSubtype;
249 } __attribute__ ((packed));
251 struct usb_class_function_descriptor_generic {
254 u8 bDescriptorSubtype;
256 } __attribute__ ((packed));
258 struct usb_class_header_function_descriptor {
261 u8 bDescriptorSubtype; /* 0x00 */
263 } __attribute__ ((packed));
265 struct usb_class_call_management_descriptor {
268 u8 bDescriptorSubtype; /* 0x01 */
271 } __attribute__ ((packed));
273 struct usb_class_abstract_control_descriptor {
276 u8 bDescriptorSubtype; /* 0x02 */
278 } __attribute__ ((packed));
280 struct usb_class_direct_line_descriptor {
283 u8 bDescriptorSubtype; /* 0x03 */
284 } __attribute__ ((packed));
286 struct usb_class_telephone_ringer_descriptor {
289 u8 bDescriptorSubtype; /* 0x04 */
291 u8 bNumRingerPatterns;
292 } __attribute__ ((packed));
294 struct usb_class_telephone_call_descriptor {
297 u8 bDescriptorSubtype; /* 0x05 */
299 } __attribute__ ((packed));
301 struct usb_class_union_function_descriptor {
304 u8 bDescriptorSubtype; /* 0x06 */
306 /* u8 bSlaveInterface0[0]; */
308 } __attribute__ ((packed));
310 struct usb_class_country_selection_descriptor {
313 u8 bDescriptorSubtype; /* 0x07 */
314 u8 iCountryCodeRelDate;
315 u16 wCountryCode0[0];
316 } __attribute__ ((packed));
318 struct usb_class_telephone_operational_descriptor {
321 u8 bDescriptorSubtype; /* 0x08 */
323 } __attribute__ ((packed));
325 struct usb_class_usb_terminal_descriptor {
328 u8 bDescriptorSubtype; /* 0x09 */
334 } __attribute__ ((packed));
336 struct usb_class_network_channel_descriptor {
339 u8 bDescriptorSubtype; /* 0x0a */
343 u8 bPhysicalInterface;
344 } __attribute__ ((packed));
346 struct usb_class_protocol_unit_function_descriptor {
349 u8 bDescriptorSubtype; /* 0x0b */
353 } __attribute__ ((packed));
355 struct usb_class_extension_unit_descriptor {
358 u8 bDescriptorSubtype; /* 0x0c */
363 } __attribute__ ((packed));
365 struct usb_class_multi_channel_descriptor {
368 u8 bDescriptorSubtype; /* 0x0d */
370 } __attribute__ ((packed));
372 struct usb_class_capi_control_descriptor {
375 u8 bDescriptorSubtype; /* 0x0e */
377 } __attribute__ ((packed));
379 struct usb_class_ethernet_networking_descriptor {
382 u8 bDescriptorSubtype; /* 0x0f */
384 u32 bmEthernetStatistics;
386 u16 wNumberMCFilters;
387 u8 bNumberPowerFilters;
388 } __attribute__ ((packed));
390 struct usb_class_atm_networking_descriptor {
393 u8 bDescriptorSubtype; /* 0x10 */
394 u8 iEndSystermIdentifier;
395 u8 bmDataCapabilities;
396 u8 bmATMDeviceStatistics;
397 u16 wType2MaxSegmentSize;
398 u16 wType3MaxSegmentSize;
400 } __attribute__ ((packed));
402 struct usb_class_mdlm_descriptor {
405 u8 bDescriptorSubtype; /* 0x12 */
408 } __attribute__ ((packed));
410 struct usb_class_mdlmd_descriptor {
413 u8 bDescriptorSubtype; /* 0x13 */
414 u8 bGuidDescriptorType;
417 } __attribute__ ((packed));
420 * HID class descriptor structures
425 struct usb_class_hid_descriptor {
430 u8 bNumDescriptors; /* 0x01 */
432 u16 wDescriptorLength0;
433 /* optional descriptors are not supported. */
434 } __attribute__((packed));
436 struct usb_class_report_descriptor {
437 u8 bLength; /* dummy */
441 } __attribute__((packed));
444 * descriptor union structures
447 struct usb_descriptor {
449 struct usb_generic_descriptor generic;
450 struct usb_endpoint_descriptor endpoint;
451 struct usb_interface_descriptor interface;
452 struct usb_configuration_descriptor configuration;
453 struct usb_device_descriptor device;
454 struct usb_string_descriptor string;
457 } __attribute__ ((packed));
459 struct usb_class_descriptor {
461 struct usb_class_function_descriptor function;
462 struct usb_class_function_descriptor_generic generic;
463 struct usb_class_header_function_descriptor header_function;
464 struct usb_class_call_management_descriptor call_management;
465 struct usb_class_abstract_control_descriptor abstract_control;
466 struct usb_class_direct_line_descriptor direct_line;
467 struct usb_class_telephone_ringer_descriptor telephone_ringer;
468 struct usb_class_telephone_operational_descriptor telephone_operational;
469 struct usb_class_telephone_call_descriptor telephone_call;
470 struct usb_class_union_function_descriptor union_function;
471 struct usb_class_country_selection_descriptor country_selection;
472 struct usb_class_usb_terminal_descriptor usb_terminal;
473 struct usb_class_network_channel_descriptor network_channel;
474 struct usb_class_extension_unit_descriptor extension_unit;
475 struct usb_class_multi_channel_descriptor multi_channel;
476 struct usb_class_capi_control_descriptor capi_control;
477 struct usb_class_ethernet_networking_descriptor ethernet_networking;
478 struct usb_class_atm_networking_descriptor atm_networking;
479 struct usb_class_mdlm_descriptor mobile_direct;
480 struct usb_class_mdlmd_descriptor mobile_direct_detail;
481 struct usb_class_hid_descriptor hid;
484 } __attribute__ ((packed));
487 static inline void print_device_descriptor(struct usb_device_descriptor *d)
489 serial_printf("usb device descriptor \n");
490 serial_printf("\tbLength %2.2x\n", d->bLength);
491 serial_printf("\tbDescriptorType %2.2x\n", d->bDescriptorType);
492 serial_printf("\tbcdUSB %4.4x\n", d->bcdUSB);
493 serial_printf("\tbDeviceClass %2.2x\n", d->bDeviceClass);
494 serial_printf("\tbDeviceSubClass %2.2x\n", d->bDeviceSubClass);
495 serial_printf("\tbDeviceProtocol %2.2x\n", d->bDeviceProtocol);
496 serial_printf("\tbMaxPacketSize0 %2.2x\n", d->bMaxPacketSize0);
497 serial_printf("\tidVendor %4.4x\n", d->idVendor);
498 serial_printf("\tidProduct %4.4x\n", d->idProduct);
499 serial_printf("\tbcdDevice %4.4x\n", d->bcdDevice);
500 serial_printf("\tiManufacturer %2.2x\n", d->iManufacturer);
501 serial_printf("\tiProduct %2.2x\n", d->iProduct);
502 serial_printf("\tiSerialNumber %2.2x\n", d->iSerialNumber);
503 serial_printf("\tbNumConfigurations %2.2x\n", d->bNumConfigurations);
509 #define print_device_descriptor(d)