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 #if defined(CONFIG_USBD_HS)
231 struct usb_qualifier_descriptor
{
240 u8 bNumConfigurations
;
242 } __attribute__ ((packed
));
245 struct usb_string_descriptor
{
247 u8 bDescriptorType
; /* 0x03 */
249 } __attribute__ ((packed
));
251 struct usb_generic_descriptor
{
254 u8 bDescriptorSubtype
;
255 } __attribute__ ((packed
));
259 * communications class descriptor structures
261 * c.f. CDC 5.2 Table 25c
264 struct usb_class_function_descriptor
{
267 u8 bDescriptorSubtype
;
268 } __attribute__ ((packed
));
270 struct usb_class_function_descriptor_generic
{
273 u8 bDescriptorSubtype
;
275 } __attribute__ ((packed
));
277 struct usb_class_header_function_descriptor
{
280 u8 bDescriptorSubtype
; /* 0x00 */
282 } __attribute__ ((packed
));
284 struct usb_class_call_management_descriptor
{
287 u8 bDescriptorSubtype
; /* 0x01 */
290 } __attribute__ ((packed
));
292 struct usb_class_abstract_control_descriptor
{
295 u8 bDescriptorSubtype
; /* 0x02 */
297 } __attribute__ ((packed
));
299 struct usb_class_direct_line_descriptor
{
302 u8 bDescriptorSubtype
; /* 0x03 */
303 } __attribute__ ((packed
));
305 struct usb_class_telephone_ringer_descriptor
{
308 u8 bDescriptorSubtype
; /* 0x04 */
310 u8 bNumRingerPatterns
;
311 } __attribute__ ((packed
));
313 struct usb_class_telephone_call_descriptor
{
316 u8 bDescriptorSubtype
; /* 0x05 */
318 } __attribute__ ((packed
));
320 struct usb_class_union_function_descriptor
{
323 u8 bDescriptorSubtype
; /* 0x06 */
325 /* u8 bSlaveInterface0[0]; */
327 } __attribute__ ((packed
));
329 struct usb_class_country_selection_descriptor
{
332 u8 bDescriptorSubtype
; /* 0x07 */
333 u8 iCountryCodeRelDate
;
334 u16 wCountryCode0
[0];
335 } __attribute__ ((packed
));
338 struct usb_class_telephone_operational_descriptor
{
341 u8 bDescriptorSubtype
; /* 0x08 */
343 } __attribute__ ((packed
));
346 struct usb_class_usb_terminal_descriptor
{
349 u8 bDescriptorSubtype
; /* 0x09 */
355 } __attribute__ ((packed
));
357 struct usb_class_network_channel_descriptor
{
360 u8 bDescriptorSubtype
; /* 0x0a */
364 u8 bPhysicalInterface
;
365 } __attribute__ ((packed
));
367 struct usb_class_protocol_unit_function_descriptor
{
370 u8 bDescriptorSubtype
; /* 0x0b */
374 } __attribute__ ((packed
));
376 struct usb_class_extension_unit_descriptor
{
379 u8 bDescriptorSubtype
; /* 0x0c */
384 } __attribute__ ((packed
));
386 struct usb_class_multi_channel_descriptor
{
389 u8 bDescriptorSubtype
; /* 0x0d */
391 } __attribute__ ((packed
));
393 struct usb_class_capi_control_descriptor
{
396 u8 bDescriptorSubtype
; /* 0x0e */
398 } __attribute__ ((packed
));
400 struct usb_class_ethernet_networking_descriptor
{
403 u8 bDescriptorSubtype
; /* 0x0f */
405 u32 bmEthernetStatistics
;
407 u16 wNumberMCFilters
;
408 u8 bNumberPowerFilters
;
409 } __attribute__ ((packed
));
411 struct usb_class_atm_networking_descriptor
{
414 u8 bDescriptorSubtype
; /* 0x10 */
415 u8 iEndSystermIdentifier
;
416 u8 bmDataCapabilities
;
417 u8 bmATMDeviceStatistics
;
418 u16 wType2MaxSegmentSize
;
419 u16 wType3MaxSegmentSize
;
421 } __attribute__ ((packed
));
424 struct usb_class_mdlm_descriptor
{
427 u8 bDescriptorSubtype
; /* 0x12 */
430 } __attribute__ ((packed
));
432 struct usb_class_mdlmd_descriptor
{
435 u8 bDescriptorSubtype
; /* 0x13 */
436 u8 bGuidDescriptorType
;
439 } __attribute__ ((packed
));
442 * HID class descriptor structures
447 struct usb_class_hid_descriptor
{
452 u8 bNumDescriptors
; /* 0x01 */
454 u16 wDescriptorLength0
;
455 /* optional descriptors are not supported. */
456 } __attribute__((packed
));
458 struct usb_class_report_descriptor
{
459 u8 bLength
; /* dummy */
463 } __attribute__((packed
));
466 * descriptor union structures
469 struct usb_descriptor
{
471 struct usb_generic_descriptor generic
;
472 struct usb_endpoint_descriptor endpoint
;
473 struct usb_interface_descriptor interface
;
474 struct usb_configuration_descriptor configuration
;
475 struct usb_device_descriptor device
;
476 struct usb_string_descriptor string
;
479 } __attribute__ ((packed
));
481 struct usb_class_descriptor
{
483 struct usb_class_function_descriptor function
;
484 struct usb_class_function_descriptor_generic generic
;
485 struct usb_class_header_function_descriptor header_function
;
486 struct usb_class_call_management_descriptor call_management
;
487 struct usb_class_abstract_control_descriptor abstract_control
;
488 struct usb_class_direct_line_descriptor direct_line
;
489 struct usb_class_telephone_ringer_descriptor telephone_ringer
;
490 struct usb_class_telephone_operational_descriptor telephone_operational
;
491 struct usb_class_telephone_call_descriptor telephone_call
;
492 struct usb_class_union_function_descriptor union_function
;
493 struct usb_class_country_selection_descriptor country_selection
;
494 struct usb_class_usb_terminal_descriptor usb_terminal
;
495 struct usb_class_network_channel_descriptor network_channel
;
496 struct usb_class_extension_unit_descriptor extension_unit
;
497 struct usb_class_multi_channel_descriptor multi_channel
;
498 struct usb_class_capi_control_descriptor capi_control
;
499 struct usb_class_ethernet_networking_descriptor ethernet_networking
;
500 struct usb_class_atm_networking_descriptor atm_networking
;
501 struct usb_class_mdlm_descriptor mobile_direct
;
502 struct usb_class_mdlmd_descriptor mobile_direct_detail
;
503 struct usb_class_hid_descriptor hid
;
506 } __attribute__ ((packed
));
509 static inline void print_device_descriptor(struct usb_device_descriptor
*d
)
511 serial_printf("usb device descriptor \n");
512 serial_printf("\tbLength %2.2x\n", d
->bLength
);
513 serial_printf("\tbDescriptorType %2.2x\n", d
->bDescriptorType
);
514 serial_printf("\tbcdUSB %4.4x\n", d
->bcdUSB
);
515 serial_printf("\tbDeviceClass %2.2x\n", d
->bDeviceClass
);
516 serial_printf("\tbDeviceSubClass %2.2x\n", d
->bDeviceSubClass
);
517 serial_printf("\tbDeviceProtocol %2.2x\n", d
->bDeviceProtocol
);
518 serial_printf("\tbMaxPacketSize0 %2.2x\n", d
->bMaxPacketSize0
);
519 serial_printf("\tidVendor %4.4x\n", d
->idVendor
);
520 serial_printf("\tidProduct %4.4x\n", d
->idProduct
);
521 serial_printf("\tbcdDevice %4.4x\n", d
->bcdDevice
);
522 serial_printf("\tiManufacturer %2.2x\n", d
->iManufacturer
);
523 serial_printf("\tiProduct %2.2x\n", d
->iProduct
);
524 serial_printf("\tiSerialNumber %2.2x\n", d
->iSerialNumber
);
525 serial_printf("\tbNumConfigurations %2.2x\n", d
->bNumConfigurations
);
531 #define print_device_descriptor(d)