usbdescriptors.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. /*
  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. *
  16. * This program is free software; you can redistribute it and/or modify
  17. * it under the terms of the GNU General Public License as published by
  18. * the Free Software Foundation; either version 2 of the License, or
  19. * (at your option) any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software
  28. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  29. *
  30. */
  31. /* USB Descriptors - Create a complete description of all of the
  32. * function driver capabilities. These map directly to the USB descriptors.
  33. *
  34. * This heirarchy is created by the functions drivers and is passed to the
  35. * usb-device driver when the function driver is registered.
  36. *
  37. * device
  38. * configuration
  39. * interface
  40. * alternate
  41. * class
  42. * class
  43. * alternate
  44. * endpoint
  45. * endpoint
  46. * interface
  47. * alternate
  48. * endpoint
  49. * endpoint
  50. * configuration
  51. * interface
  52. * alternate
  53. * endpoint
  54. * endpoint
  55. *
  56. *
  57. * The configuration structures refer to the USB Configurations that will be
  58. * made available to a USB HOST during the enumeration process.
  59. *
  60. * The USB HOST will select a configuration and optionally an interface with
  61. * the usb set configuration and set interface commands.
  62. *
  63. * The selected interface (or the default interface if not specifically
  64. * selected) will define the list of endpoints that will be used.
  65. *
  66. * The configuration and interfaces are stored in an array that is indexed
  67. * by the specified configuratin or interface number minus one.
  68. *
  69. * A configuration number of zero is used to specify a return to the unconfigured
  70. * state.
  71. *
  72. */
  73. #ifndef __USBDESCRIPTORS_H__
  74. #define __USBDESCRIPTORS_H__
  75. #include <asm/types.h>
  76. /*
  77. * communications class types
  78. *
  79. * c.f. CDC USB Class Definitions for Communications Devices
  80. * c.f. WMCD USB CDC Subclass Specification for Wireless Mobile Communications Devices
  81. *
  82. */
  83. #define CLASS_BCD_VERSION 0x0110
  84. /* c.f. CDC 4.1 Table 14 */
  85. #define COMMUNICATIONS_DEVICE_CLASS 0x02
  86. /* c.f. CDC 4.2 Table 15 */
  87. #define COMMUNICATIONS_INTERFACE_CLASS_CONTROL 0x02
  88. #define COMMUNICATIONS_INTERFACE_CLASS_DATA 0x0A
  89. #define COMMUNICATIONS_INTERFACE_CLASS_VENDOR 0x0FF
  90. /* c.f. CDC 4.3 Table 16 */
  91. #define COMMUNICATIONS_NO_SUBCLASS 0x00
  92. #define COMMUNICATIONS_DLCM_SUBCLASS 0x01
  93. #define COMMUNICATIONS_ACM_SUBCLASS 0x02
  94. #define COMMUNICATIONS_TCM_SUBCLASS 0x03
  95. #define COMMUNICATIONS_MCCM_SUBCLASS 0x04
  96. #define COMMUNICATIONS_CCM_SUBCLASS 0x05
  97. #define COMMUNICATIONS_ENCM_SUBCLASS 0x06
  98. #define COMMUNICATIONS_ANCM_SUBCLASS 0x07
  99. /* c.f. WMCD 5.1 */
  100. #define COMMUNICATIONS_WHCM_SUBCLASS 0x08
  101. #define COMMUNICATIONS_DMM_SUBCLASS 0x09
  102. #define COMMUNICATIONS_MDLM_SUBCLASS 0x0a
  103. #define COMMUNICATIONS_OBEX_SUBCLASS 0x0b
  104. /* c.f. CDC 4.4 Table 17 */
  105. #define COMMUNICATIONS_NO_PROTOCOL 0x00
  106. #define COMMUNICATIONS_V25TER_PROTOCOL 0x01 /*Common AT Hayes compatible*/
  107. /* c.f. CDC 4.5 Table 18 */
  108. #define DATA_INTERFACE_CLASS 0x0a
  109. /* c.f. CDC 4.6 No Table */
  110. #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 */
  113. /* c.f. CDC 5.2.3 Table 24 */
  114. #define CS_INTERFACE 0x24
  115. #define CS_ENDPOINT 0x25
  116. /*
  117. * bDescriptorSubtypes
  118. *
  119. * c.f. CDC 5.2.3 Table 25
  120. * c.f. WMCD 5.3 Table 5.3
  121. */
  122. #define USB_ST_HEADER 0x00
  123. #define USB_ST_CMF 0x01
  124. #define USB_ST_ACMF 0x02
  125. #define USB_ST_DLMF 0x03
  126. #define USB_ST_TRF 0x04
  127. #define USB_ST_TCLF 0x05
  128. #define USB_ST_UF 0x06
  129. #define USB_ST_CSF 0x07
  130. #define USB_ST_TOMF 0x08
  131. #define USB_ST_USBTF 0x09
  132. #define USB_ST_NCT 0x0a
  133. #define USB_ST_PUF 0x0b
  134. #define USB_ST_EUF 0x0c
  135. #define USB_ST_MCMF 0x0d
  136. #define USB_ST_CCMF 0x0e
  137. #define USB_ST_ENF 0x0f
  138. #define USB_ST_ATMNF 0x10
  139. #define USB_ST_WHCM 0x11
  140. #define USB_ST_MDLM 0x12
  141. #define USB_ST_MDLMD 0x13
  142. #define USB_ST_DMM 0x14
  143. #define USB_ST_OBEX 0x15
  144. #define USB_ST_CS 0x16
  145. #define USB_ST_CSD 0x17
  146. #define USB_ST_TCM 0x18
  147. /* endpoint modifiers
  148. * static struct usb_endpoint_description function_default_A_1[] = {
  149. *
  150. * {this_endpoint: 0, attributes: CONTROL, max_size: 8, polling_interval: 0 },
  151. * {this_endpoint: 1, attributes: BULK, max_size: 64, polling_interval: 0, direction: IN},
  152. * {this_endpoint: 2, attributes: BULK, max_size: 64, polling_interval: 0, direction: OUT},
  153. * {this_endpoint: 3, attributes: INTERRUPT, max_size: 8, polling_interval: 0},
  154. *
  155. *
  156. */
  157. #define OUT 0x00
  158. #define IN 0x80
  159. #define CONTROL 0x00
  160. #define ISOCHRONOUS 0x01
  161. #define BULK 0x02
  162. #define INTERRUPT 0x03
  163. /* configuration modifiers
  164. */
  165. #define BMATTRIBUTE_RESERVED 0x80
  166. #define BMATTRIBUTE_SELF_POWERED 0x40
  167. /*
  168. * standard usb descriptor structures
  169. */
  170. struct usb_endpoint_descriptor {
  171. u8 bLength;
  172. u8 bDescriptorType; /* 0x5 */
  173. u8 bEndpointAddress;
  174. u8 bmAttributes;
  175. u16 wMaxPacketSize;
  176. u8 bInterval;
  177. } __attribute__ ((packed));
  178. struct usb_interface_descriptor {
  179. u8 bLength;
  180. u8 bDescriptorType; /* 0x04 */
  181. u8 bInterfaceNumber;
  182. u8 bAlternateSetting;
  183. u8 bNumEndpoints;
  184. u8 bInterfaceClass;
  185. u8 bInterfaceSubClass;
  186. u8 bInterfaceProtocol;
  187. u8 iInterface;
  188. } __attribute__ ((packed));
  189. struct usb_configuration_descriptor {
  190. u8 bLength;
  191. u8 bDescriptorType; /* 0x2 */
  192. u16 wTotalLength;
  193. u8 bNumInterfaces;
  194. u8 bConfigurationValue;
  195. u8 iConfiguration;
  196. u8 bmAttributes;
  197. u8 bMaxPower;
  198. } __attribute__ ((packed));
  199. struct usb_device_descriptor {
  200. u8 bLength;
  201. u8 bDescriptorType; /* 0x01 */
  202. u16 bcdUSB;
  203. u8 bDeviceClass;
  204. u8 bDeviceSubClass;
  205. u8 bDeviceProtocol;
  206. u8 bMaxPacketSize0;
  207. u16 idVendor;
  208. u16 idProduct;
  209. u16 bcdDevice;
  210. u8 iManufacturer;
  211. u8 iProduct;
  212. u8 iSerialNumber;
  213. u8 bNumConfigurations;
  214. } __attribute__ ((packed));
  215. #if defined(CONFIG_USBD_HS)
  216. struct usb_qualifier_descriptor {
  217. u8 bLength;
  218. u8 bDescriptorType;
  219. u16 bcdUSB;
  220. u8 bDeviceClass;
  221. u8 bDeviceSubClass;
  222. u8 bDeviceProtocol;
  223. u8 bMaxPacketSize0;
  224. u8 bNumConfigurations;
  225. u8 breserved;
  226. } __attribute__ ((packed));
  227. #endif
  228. struct usb_string_descriptor {
  229. u8 bLength;
  230. u8 bDescriptorType; /* 0x03 */
  231. u16 wData[0];
  232. } __attribute__ ((packed));
  233. struct usb_generic_descriptor {
  234. u8 bLength;
  235. u8 bDescriptorType;
  236. u8 bDescriptorSubtype;
  237. } __attribute__ ((packed));
  238. /*
  239. * communications class descriptor structures
  240. *
  241. * c.f. CDC 5.2 Table 25c
  242. */
  243. struct usb_class_function_descriptor {
  244. u8 bFunctionLength;
  245. u8 bDescriptorType;
  246. u8 bDescriptorSubtype;
  247. } __attribute__ ((packed));
  248. struct usb_class_function_descriptor_generic {
  249. u8 bFunctionLength;
  250. u8 bDescriptorType;
  251. u8 bDescriptorSubtype;
  252. u8 bmCapabilities;
  253. } __attribute__ ((packed));
  254. struct usb_class_header_function_descriptor {
  255. u8 bFunctionLength;
  256. u8 bDescriptorType;
  257. u8 bDescriptorSubtype; /* 0x00 */
  258. u16 bcdCDC;
  259. } __attribute__ ((packed));
  260. struct usb_class_call_management_descriptor {
  261. u8 bFunctionLength;
  262. u8 bDescriptorType;
  263. u8 bDescriptorSubtype; /* 0x01 */
  264. u8 bmCapabilities;
  265. u8 bDataInterface;
  266. } __attribute__ ((packed));
  267. struct usb_class_abstract_control_descriptor {
  268. u8 bFunctionLength;
  269. u8 bDescriptorType;
  270. u8 bDescriptorSubtype; /* 0x02 */
  271. u8 bmCapabilities;
  272. } __attribute__ ((packed));
  273. struct usb_class_direct_line_descriptor {
  274. u8 bFunctionLength;
  275. u8 bDescriptorType;
  276. u8 bDescriptorSubtype; /* 0x03 */
  277. } __attribute__ ((packed));
  278. struct usb_class_telephone_ringer_descriptor {
  279. u8 bFunctionLength;
  280. u8 bDescriptorType;
  281. u8 bDescriptorSubtype; /* 0x04 */
  282. u8 bRingerVolSeps;
  283. u8 bNumRingerPatterns;
  284. } __attribute__ ((packed));
  285. struct usb_class_telephone_call_descriptor {
  286. u8 bFunctionLength;
  287. u8 bDescriptorType;
  288. u8 bDescriptorSubtype; /* 0x05 */
  289. u8 bmCapabilities;
  290. } __attribute__ ((packed));
  291. struct usb_class_union_function_descriptor {
  292. u8 bFunctionLength;
  293. u8 bDescriptorType;
  294. u8 bDescriptorSubtype; /* 0x06 */
  295. u8 bMasterInterface;
  296. /* u8 bSlaveInterface0[0]; */
  297. u8 bSlaveInterface0;
  298. } __attribute__ ((packed));
  299. struct usb_class_country_selection_descriptor {
  300. u8 bFunctionLength;
  301. u8 bDescriptorType;
  302. u8 bDescriptorSubtype; /* 0x07 */
  303. u8 iCountryCodeRelDate;
  304. u16 wCountryCode0[0];
  305. } __attribute__ ((packed));
  306. struct usb_class_telephone_operational_descriptor {
  307. u8 bFunctionLength;
  308. u8 bDescriptorType;
  309. u8 bDescriptorSubtype; /* 0x08 */
  310. u8 bmCapabilities;
  311. } __attribute__ ((packed));
  312. struct usb_class_usb_terminal_descriptor {
  313. u8 bFunctionLength;
  314. u8 bDescriptorType;
  315. u8 bDescriptorSubtype; /* 0x09 */
  316. u8 bEntityId;
  317. u8 bInterfaceNo;
  318. u8 bOutInterfaceNo;
  319. u8 bmOptions;
  320. u8 bChild0[0];
  321. } __attribute__ ((packed));
  322. struct usb_class_network_channel_descriptor {
  323. u8 bFunctionLength;
  324. u8 bDescriptorType;
  325. u8 bDescriptorSubtype; /* 0x0a */
  326. u8 bEntityId;
  327. u8 iName;
  328. u8 bChannelIndex;
  329. u8 bPhysicalInterface;
  330. } __attribute__ ((packed));
  331. struct usb_class_protocol_unit_function_descriptor {
  332. u8 bFunctionLength;
  333. u8 bDescriptorType;
  334. u8 bDescriptorSubtype; /* 0x0b */
  335. u8 bEntityId;
  336. u8 bProtocol;
  337. u8 bChild0[0];
  338. } __attribute__ ((packed));
  339. struct usb_class_extension_unit_descriptor {
  340. u8 bFunctionLength;
  341. u8 bDescriptorType;
  342. u8 bDescriptorSubtype; /* 0x0c */
  343. u8 bEntityId;
  344. u8 bExtensionCode;
  345. u8 iName;
  346. u8 bChild0[0];
  347. } __attribute__ ((packed));
  348. struct usb_class_multi_channel_descriptor {
  349. u8 bFunctionLength;
  350. u8 bDescriptorType;
  351. u8 bDescriptorSubtype; /* 0x0d */
  352. u8 bmCapabilities;
  353. } __attribute__ ((packed));
  354. struct usb_class_capi_control_descriptor {
  355. u8 bFunctionLength;
  356. u8 bDescriptorType;
  357. u8 bDescriptorSubtype; /* 0x0e */
  358. u8 bmCapabilities;
  359. } __attribute__ ((packed));
  360. struct usb_class_ethernet_networking_descriptor {
  361. u8 bFunctionLength;
  362. u8 bDescriptorType;
  363. u8 bDescriptorSubtype; /* 0x0f */
  364. u8 iMACAddress;
  365. u32 bmEthernetStatistics;
  366. u16 wMaxSegmentSize;
  367. u16 wNumberMCFilters;
  368. u8 bNumberPowerFilters;
  369. } __attribute__ ((packed));
  370. struct usb_class_atm_networking_descriptor {
  371. u8 bFunctionLength;
  372. u8 bDescriptorType;
  373. u8 bDescriptorSubtype; /* 0x10 */
  374. u8 iEndSystermIdentifier;
  375. u8 bmDataCapabilities;
  376. u8 bmATMDeviceStatistics;
  377. u16 wType2MaxSegmentSize;
  378. u16 wType3MaxSegmentSize;
  379. u16 wMaxVC;
  380. } __attribute__ ((packed));
  381. struct usb_class_mdlm_descriptor {
  382. u8 bFunctionLength;
  383. u8 bDescriptorType;
  384. u8 bDescriptorSubtype; /* 0x12 */
  385. u16 bcdVersion;
  386. u8 bGUID[16];
  387. } __attribute__ ((packed));
  388. struct usb_class_mdlmd_descriptor {
  389. u8 bFunctionLength;
  390. u8 bDescriptorType;
  391. u8 bDescriptorSubtype; /* 0x13 */
  392. u8 bGuidDescriptorType;
  393. u8 bDetailData[0];
  394. } __attribute__ ((packed));
  395. /*
  396. * HID class descriptor structures
  397. *
  398. * c.f. HID 6.2.1
  399. */
  400. struct usb_class_hid_descriptor {
  401. u8 bLength;
  402. u8 bDescriptorType;
  403. u16 bcdCDC;
  404. u8 bCountryCode;
  405. u8 bNumDescriptors; /* 0x01 */
  406. u8 bDescriptorType0;
  407. u16 wDescriptorLength0;
  408. /* optional descriptors are not supported. */
  409. } __attribute__((packed));
  410. struct usb_class_report_descriptor {
  411. u8 bLength; /* dummy */
  412. u8 bDescriptorType;
  413. u16 wLength;
  414. u8 bData[0];
  415. } __attribute__((packed));
  416. /*
  417. * descriptor union structures
  418. */
  419. struct usb_descriptor {
  420. union {
  421. struct usb_generic_descriptor generic;
  422. struct usb_endpoint_descriptor endpoint;
  423. struct usb_interface_descriptor interface;
  424. struct usb_configuration_descriptor configuration;
  425. struct usb_device_descriptor device;
  426. struct usb_string_descriptor string;
  427. } descriptor;
  428. } __attribute__ ((packed));
  429. struct usb_class_descriptor {
  430. union {
  431. struct usb_class_function_descriptor function;
  432. struct usb_class_function_descriptor_generic generic;
  433. struct usb_class_header_function_descriptor header_function;
  434. struct usb_class_call_management_descriptor call_management;
  435. struct usb_class_abstract_control_descriptor abstract_control;
  436. struct usb_class_direct_line_descriptor direct_line;
  437. struct usb_class_telephone_ringer_descriptor telephone_ringer;
  438. struct usb_class_telephone_operational_descriptor telephone_operational;
  439. struct usb_class_telephone_call_descriptor telephone_call;
  440. struct usb_class_union_function_descriptor union_function;
  441. struct usb_class_country_selection_descriptor country_selection;
  442. struct usb_class_usb_terminal_descriptor usb_terminal;
  443. struct usb_class_network_channel_descriptor network_channel;
  444. struct usb_class_extension_unit_descriptor extension_unit;
  445. struct usb_class_multi_channel_descriptor multi_channel;
  446. struct usb_class_capi_control_descriptor capi_control;
  447. struct usb_class_ethernet_networking_descriptor ethernet_networking;
  448. struct usb_class_atm_networking_descriptor atm_networking;
  449. struct usb_class_mdlm_descriptor mobile_direct;
  450. struct usb_class_mdlmd_descriptor mobile_direct_detail;
  451. struct usb_class_hid_descriptor hid;
  452. } descriptor;
  453. } __attribute__ ((packed));
  454. #ifdef DEBUG
  455. static inline void print_device_descriptor(struct usb_device_descriptor *d)
  456. {
  457. serial_printf("usb device descriptor \n");
  458. serial_printf("\tbLength %2.2x\n", d->bLength);
  459. serial_printf("\tbDescriptorType %2.2x\n", d->bDescriptorType);
  460. serial_printf("\tbcdUSB %4.4x\n", d->bcdUSB);
  461. serial_printf("\tbDeviceClass %2.2x\n", d->bDeviceClass);
  462. serial_printf("\tbDeviceSubClass %2.2x\n", d->bDeviceSubClass);
  463. serial_printf("\tbDeviceProtocol %2.2x\n", d->bDeviceProtocol);
  464. serial_printf("\tbMaxPacketSize0 %2.2x\n", d->bMaxPacketSize0);
  465. serial_printf("\tidVendor %4.4x\n", d->idVendor);
  466. serial_printf("\tidProduct %4.4x\n", d->idProduct);
  467. serial_printf("\tbcdDevice %4.4x\n", d->bcdDevice);
  468. serial_printf("\tiManufacturer %2.2x\n", d->iManufacturer);
  469. serial_printf("\tiProduct %2.2x\n", d->iProduct);
  470. serial_printf("\tiSerialNumber %2.2x\n", d->iSerialNumber);
  471. serial_printf("\tbNumConfigurations %2.2x\n", d->bNumConfigurations);
  472. }
  473. #else
  474. /* stubs */
  475. #define print_device_descriptor(d)
  476. #endif /* DEBUG */
  477. #endif