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