blob: db1d6ef791bf145f4599987542a0ed0505cff1e3 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
wdenk232c1502004-03-12 00:14:09 +00002/*
3 * (C) Copyright 2003
4 * Gerry Hamel, geh@ti.com, Texas Instruments
5 *
6 * Based on
7 * linux/drivers/usbd/usb-function.h - USB Function
8 *
9 * Copyright (c) 2000, 2001, 2002 Lineo
10 * Copyright (c) 2001 Hewlett Packard
11 *
12 * By:
13 * Stuart Lynne <sl@lineo.com>,
14 * Tom Rushworth <tbr@lineo.com>,
15 * Bruce Balden <balden@lineo.com>
wdenk232c1502004-03-12 00:14:09 +000016 */
17
18/* USB Descriptors - Create a complete description of all of the
19 * function driver capabilities. These map directly to the USB descriptors.
20 *
21 * This heirarchy is created by the functions drivers and is passed to the
22 * usb-device driver when the function driver is registered.
23 *
24 * device
25 * configuration
26 * interface
27 * alternate
28 * class
29 * class
30 * alternate
31 * endpoint
32 * endpoint
33 * interface
34 * alternate
35 * endpoint
36 * endpoint
37 * configuration
38 * interface
39 * alternate
40 * endpoint
41 * endpoint
42 *
43 *
44 * The configuration structures refer to the USB Configurations that will be
45 * made available to a USB HOST during the enumeration process.
46 *
47 * The USB HOST will select a configuration and optionally an interface with
48 * the usb set configuration and set interface commands.
49 *
50 * The selected interface (or the default interface if not specifically
51 * selected) will define the list of endpoints that will be used.
52 *
53 * The configuration and interfaces are stored in an array that is indexed
54 * by the specified configuratin or interface number minus one.
55 *
56 * A configuration number of zero is used to specify a return to the unconfigured
57 * state.
58 *
59 */
60
wdenk232c1502004-03-12 00:14:09 +000061#ifndef __USBDESCRIPTORS_H__
62#define __USBDESCRIPTORS_H__
63
64#include <asm/types.h>
65
66/*
67 * communications class types
68 *
69 * c.f. CDC USB Class Definitions for Communications Devices
70 * c.f. WMCD USB CDC Subclass Specification for Wireless Mobile Communications Devices
71 *
72 */
73
74#define CLASS_BCD_VERSION 0x0110
75
76/* c.f. CDC 4.1 Table 14 */
77#define COMMUNICATIONS_DEVICE_CLASS 0x02
78
79/* c.f. CDC 4.2 Table 15 */
Wolfgang Denk16c8d5e2006-06-14 17:45:53 +020080#define COMMUNICATIONS_INTERFACE_CLASS_CONTROL 0x02
81#define COMMUNICATIONS_INTERFACE_CLASS_DATA 0x0A
82#define COMMUNICATIONS_INTERFACE_CLASS_VENDOR 0x0FF
wdenk232c1502004-03-12 00:14:09 +000083
84/* c.f. CDC 4.3 Table 16 */
Wolfgang Denk16c8d5e2006-06-14 17:45:53 +020085#define COMMUNICATIONS_NO_SUBCLASS 0x00
wdenk232c1502004-03-12 00:14:09 +000086#define COMMUNICATIONS_DLCM_SUBCLASS 0x01
Wolfgang Denk16c8d5e2006-06-14 17:45:53 +020087#define COMMUNICATIONS_ACM_SUBCLASS 0x02
88#define COMMUNICATIONS_TCM_SUBCLASS 0x03
wdenk232c1502004-03-12 00:14:09 +000089#define COMMUNICATIONS_MCCM_SUBCLASS 0x04
Wolfgang Denk16c8d5e2006-06-14 17:45:53 +020090#define COMMUNICATIONS_CCM_SUBCLASS 0x05
wdenk232c1502004-03-12 00:14:09 +000091#define COMMUNICATIONS_ENCM_SUBCLASS 0x06
92#define COMMUNICATIONS_ANCM_SUBCLASS 0x07
93
94/* c.f. WMCD 5.1 */
95#define COMMUNICATIONS_WHCM_SUBCLASS 0x08
Wolfgang Denk16c8d5e2006-06-14 17:45:53 +020096#define COMMUNICATIONS_DMM_SUBCLASS 0x09
wdenk232c1502004-03-12 00:14:09 +000097#define COMMUNICATIONS_MDLM_SUBCLASS 0x0a
98#define COMMUNICATIONS_OBEX_SUBCLASS 0x0b
99
Wolfgang Denk16c8d5e2006-06-14 17:45:53 +0200100/* c.f. CDC 4.4 Table 17 */
101#define COMMUNICATIONS_NO_PROTOCOL 0x00
102#define COMMUNICATIONS_V25TER_PROTOCOL 0x01 /*Common AT Hayes compatible*/
103
104/* c.f. CDC 4.5 Table 18 */
wdenk232c1502004-03-12 00:14:09 +0000105#define DATA_INTERFACE_CLASS 0x0a
106
Wolfgang Denk16c8d5e2006-06-14 17:45:53 +0200107/* c.f. CDC 4.6 No Table */
108#define DATA_INTERFACE_SUBCLASS_NONE 0x00 /* No subclass pertinent */
109
wdenk232c1502004-03-12 00:14:09 +0000110/* c.f. CDC 4.7 Table 19 */
Wolfgang Denk16c8d5e2006-06-14 17:45:53 +0200111#define DATA_INTERFACE_PROTOCOL_NONE 0x00 /* No class protcol required */
wdenk232c1502004-03-12 00:14:09 +0000112
wdenk232c1502004-03-12 00:14:09 +0000113/* c.f. CDC 5.2.3 Table 24 */
Wolfgang Denk16c8d5e2006-06-14 17:45:53 +0200114#define CS_INTERFACE 0x24
wdenk232c1502004-03-12 00:14:09 +0000115#define CS_ENDPOINT 0x25
116
117/*
118 * bDescriptorSubtypes
119 *
120 * c.f. CDC 5.2.3 Table 25
121 * c.f. WMCD 5.3 Table 5.3
122 */
123
Wolfgang Denk16c8d5e2006-06-14 17:45:53 +0200124#define USB_ST_HEADER 0x00
wdenk232c1502004-03-12 00:14:09 +0000125#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
Wolfgang Denk16c8d5e2006-06-14 17:45:53 +0200133#define USB_ST_USBTF 0x09
wdenk232c1502004-03-12 00:14:09 +0000134#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
Wolfgang Denk16c8d5e2006-06-14 17:45:53 +0200140#define USB_ST_ATMNF 0x10
wdenk232c1502004-03-12 00:14:09 +0000141
142#define USB_ST_WHCM 0x11
143#define USB_ST_MDLM 0x12
Wolfgang Denk16c8d5e2006-06-14 17:45:53 +0200144#define USB_ST_MDLMD 0x13
wdenk232c1502004-03-12 00:14:09 +0000145#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
150
151/* endpoint modifiers
152 * static struct usb_endpoint_description function_default_A_1[] = {
153 *
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},
158 *
159 *
160 */
161#define OUT 0x00
162#define IN 0x80
163
164#define CONTROL 0x00
165#define ISOCHRONOUS 0x01
166#define BULK 0x02
167#define INTERRUPT 0x03
168
wdenk232c1502004-03-12 00:14:09 +0000169/* configuration modifiers
170 */
171#define BMATTRIBUTE_RESERVED 0x80
172#define BMATTRIBUTE_SELF_POWERED 0x40
173
174/*
175 * standard usb descriptor structures
176 */
177
178struct usb_endpoint_descriptor {
179 u8 bLength;
180 u8 bDescriptorType; /* 0x5 */
181 u8 bEndpointAddress;
182 u8 bmAttributes;
183 u16 wMaxPacketSize;
184 u8 bInterval;
Tom Rinib2fb47f2011-12-15 08:40:51 -0700185} __attribute__ ((packed));
wdenk232c1502004-03-12 00:14:09 +0000186
187struct usb_interface_descriptor {
188 u8 bLength;
189 u8 bDescriptorType; /* 0x04 */
190 u8 bInterfaceNumber;
191 u8 bAlternateSetting;
192 u8 bNumEndpoints;
193 u8 bInterfaceClass;
194 u8 bInterfaceSubClass;
195 u8 bInterfaceProtocol;
196 u8 iInterface;
197} __attribute__ ((packed));
198
199struct usb_configuration_descriptor {
200 u8 bLength;
201 u8 bDescriptorType; /* 0x2 */
202 u16 wTotalLength;
203 u8 bNumInterfaces;
204 u8 bConfigurationValue;
205 u8 iConfiguration;
206 u8 bmAttributes;
207 u8 bMaxPower;
208} __attribute__ ((packed));
209
210struct usb_device_descriptor {
211 u8 bLength;
212 u8 bDescriptorType; /* 0x01 */
213 u16 bcdUSB;
214 u8 bDeviceClass;
215 u8 bDeviceSubClass;
216 u8 bDeviceProtocol;
217 u8 bMaxPacketSize0;
218 u16 idVendor;
219 u16 idProduct;
220 u16 bcdDevice;
221 u8 iManufacturer;
222 u8 iProduct;
223 u8 iSerialNumber;
224 u8 bNumConfigurations;
225} __attribute__ ((packed));
226
227struct usb_string_descriptor {
228 u8 bLength;
229 u8 bDescriptorType; /* 0x03 */
230 u16 wData[0];
231} __attribute__ ((packed));
232
233struct usb_generic_descriptor {
234 u8 bLength;
235 u8 bDescriptorType;
236 u8 bDescriptorSubtype;
237} __attribute__ ((packed));
238
wdenk232c1502004-03-12 00:14:09 +0000239/*
240 * communications class descriptor structures
241 *
242 * c.f. CDC 5.2 Table 25c
243 */
244
245struct usb_class_function_descriptor {
246 u8 bFunctionLength;
247 u8 bDescriptorType;
248 u8 bDescriptorSubtype;
249} __attribute__ ((packed));
250
251struct usb_class_function_descriptor_generic {
252 u8 bFunctionLength;
253 u8 bDescriptorType;
254 u8 bDescriptorSubtype;
255 u8 bmCapabilities;
256} __attribute__ ((packed));
257
258struct usb_class_header_function_descriptor {
259 u8 bFunctionLength;
260 u8 bDescriptorType;
261 u8 bDescriptorSubtype; /* 0x00 */
262 u16 bcdCDC;
263} __attribute__ ((packed));
264
265struct usb_class_call_management_descriptor {
266 u8 bFunctionLength;
267 u8 bDescriptorType;
268 u8 bDescriptorSubtype; /* 0x01 */
269 u8 bmCapabilities;
270 u8 bDataInterface;
271} __attribute__ ((packed));
272
273struct usb_class_abstract_control_descriptor {
274 u8 bFunctionLength;
275 u8 bDescriptorType;
276 u8 bDescriptorSubtype; /* 0x02 */
277 u8 bmCapabilities;
278} __attribute__ ((packed));
279
280struct usb_class_direct_line_descriptor {
281 u8 bFunctionLength;
282 u8 bDescriptorType;
283 u8 bDescriptorSubtype; /* 0x03 */
284} __attribute__ ((packed));
285
286struct usb_class_telephone_ringer_descriptor {
287 u8 bFunctionLength;
288 u8 bDescriptorType;
289 u8 bDescriptorSubtype; /* 0x04 */
290 u8 bRingerVolSeps;
291 u8 bNumRingerPatterns;
292} __attribute__ ((packed));
293
294struct usb_class_telephone_call_descriptor {
295 u8 bFunctionLength;
296 u8 bDescriptorType;
297 u8 bDescriptorSubtype; /* 0x05 */
298 u8 bmCapabilities;
299} __attribute__ ((packed));
300
301struct usb_class_union_function_descriptor {
302 u8 bFunctionLength;
303 u8 bDescriptorType;
304 u8 bDescriptorSubtype; /* 0x06 */
305 u8 bMasterInterface;
Wolfgang Denk386eda02006-06-14 18:14:56 +0200306 /* u8 bSlaveInterface0[0]; */
Wolfgang Denk16c8d5e2006-06-14 17:45:53 +0200307 u8 bSlaveInterface0;
wdenk232c1502004-03-12 00:14:09 +0000308} __attribute__ ((packed));
309
310struct usb_class_country_selection_descriptor {
311 u8 bFunctionLength;
312 u8 bDescriptorType;
313 u8 bDescriptorSubtype; /* 0x07 */
314 u8 iCountryCodeRelDate;
315 u16 wCountryCode0[0];
316} __attribute__ ((packed));
317
wdenk232c1502004-03-12 00:14:09 +0000318struct usb_class_telephone_operational_descriptor {
319 u8 bFunctionLength;
320 u8 bDescriptorType;
321 u8 bDescriptorSubtype; /* 0x08 */
322 u8 bmCapabilities;
323} __attribute__ ((packed));
324
wdenk232c1502004-03-12 00:14:09 +0000325struct usb_class_usb_terminal_descriptor {
326 u8 bFunctionLength;
327 u8 bDescriptorType;
328 u8 bDescriptorSubtype; /* 0x09 */
329 u8 bEntityId;
330 u8 bInterfaceNo;
331 u8 bOutInterfaceNo;
332 u8 bmOptions;
333 u8 bChild0[0];
334} __attribute__ ((packed));
335
336struct usb_class_network_channel_descriptor {
337 u8 bFunctionLength;
338 u8 bDescriptorType;
339 u8 bDescriptorSubtype; /* 0x0a */
340 u8 bEntityId;
341 u8 iName;
342 u8 bChannelIndex;
343 u8 bPhysicalInterface;
344} __attribute__ ((packed));
345
346struct usb_class_protocol_unit_function_descriptor {
347 u8 bFunctionLength;
348 u8 bDescriptorType;
349 u8 bDescriptorSubtype; /* 0x0b */
350 u8 bEntityId;
351 u8 bProtocol;
352 u8 bChild0[0];
353} __attribute__ ((packed));
354
355struct usb_class_extension_unit_descriptor {
356 u8 bFunctionLength;
357 u8 bDescriptorType;
358 u8 bDescriptorSubtype; /* 0x0c */
359 u8 bEntityId;
360 u8 bExtensionCode;
361 u8 iName;
362 u8 bChild0[0];
363} __attribute__ ((packed));
364
365struct usb_class_multi_channel_descriptor {
366 u8 bFunctionLength;
367 u8 bDescriptorType;
368 u8 bDescriptorSubtype; /* 0x0d */
369 u8 bmCapabilities;
370} __attribute__ ((packed));
371
372struct usb_class_capi_control_descriptor {
373 u8 bFunctionLength;
374 u8 bDescriptorType;
375 u8 bDescriptorSubtype; /* 0x0e */
376 u8 bmCapabilities;
377} __attribute__ ((packed));
378
379struct usb_class_ethernet_networking_descriptor {
380 u8 bFunctionLength;
381 u8 bDescriptorType;
382 u8 bDescriptorSubtype; /* 0x0f */
383 u8 iMACAddress;
384 u32 bmEthernetStatistics;
385 u16 wMaxSegmentSize;
386 u16 wNumberMCFilters;
387 u8 bNumberPowerFilters;
388} __attribute__ ((packed));
389
390struct usb_class_atm_networking_descriptor {
391 u8 bFunctionLength;
392 u8 bDescriptorType;
393 u8 bDescriptorSubtype; /* 0x10 */
394 u8 iEndSystermIdentifier;
395 u8 bmDataCapabilities;
396 u8 bmATMDeviceStatistics;
397 u16 wType2MaxSegmentSize;
398 u16 wType3MaxSegmentSize;
399 u16 wMaxVC;
400} __attribute__ ((packed));
401
wdenk232c1502004-03-12 00:14:09 +0000402struct usb_class_mdlm_descriptor {
403 u8 bFunctionLength;
404 u8 bDescriptorType;
405 u8 bDescriptorSubtype; /* 0x12 */
406 u16 bcdVersion;
407 u8 bGUID[16];
408} __attribute__ ((packed));
409
410struct usb_class_mdlmd_descriptor {
411 u8 bFunctionLength;
412 u8 bDescriptorType;
413 u8 bDescriptorSubtype; /* 0x13 */
414 u8 bGuidDescriptorType;
415 u8 bDetailData[0];
416
417} __attribute__ ((packed));
418
419/*
420 * HID class descriptor structures
421 *
422 * c.f. HID 6.2.1
423 */
424
425struct usb_class_hid_descriptor {
426 u8 bLength;
427 u8 bDescriptorType;
428 u16 bcdCDC;
429 u8 bCountryCode;
430 u8 bNumDescriptors; /* 0x01 */
431 u8 bDescriptorType0;
432 u16 wDescriptorLength0;
433 /* optional descriptors are not supported. */
434} __attribute__((packed));
435
436struct usb_class_report_descriptor {
437 u8 bLength; /* dummy */
438 u8 bDescriptorType;
439 u16 wLength;
440 u8 bData[0];
441} __attribute__((packed));
442
443/*
444 * descriptor union structures
445 */
446
447struct usb_descriptor {
448 union {
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;
455 } descriptor;
456
457} __attribute__ ((packed));
458
459struct usb_class_descriptor {
460 union {
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;
482 } descriptor;
483
484} __attribute__ ((packed));
485
Tom Rix988365a2009-10-31 12:37:39 -0500486#ifdef DEBUG
487static inline void print_device_descriptor(struct usb_device_descriptor *d)
488{
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);
504}
505
506#else
507
508/* stubs */
509#define print_device_descriptor(d)
510
511#endif /* DEBUG */
wdenk232c1502004-03-12 00:14:09 +0000512#endif