usbdescriptors.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  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. struct usb_string_descriptor {
  216. u8 bLength;
  217. u8 bDescriptorType; /* 0x03 */
  218. u16 wData[0];
  219. } __attribute__ ((packed));
  220. struct usb_generic_descriptor {
  221. u8 bLength;
  222. u8 bDescriptorType;
  223. u8 bDescriptorSubtype;
  224. } __attribute__ ((packed));
  225. /*
  226. * communications class descriptor structures
  227. *
  228. * c.f. CDC 5.2 Table 25c
  229. */
  230. struct usb_class_function_descriptor {
  231. u8 bFunctionLength;
  232. u8 bDescriptorType;
  233. u8 bDescriptorSubtype;
  234. } __attribute__ ((packed));
  235. struct usb_class_function_descriptor_generic {
  236. u8 bFunctionLength;
  237. u8 bDescriptorType;
  238. u8 bDescriptorSubtype;
  239. u8 bmCapabilities;
  240. } __attribute__ ((packed));
  241. struct usb_class_header_function_descriptor {
  242. u8 bFunctionLength;
  243. u8 bDescriptorType;
  244. u8 bDescriptorSubtype; /* 0x00 */
  245. u16 bcdCDC;
  246. } __attribute__ ((packed));
  247. struct usb_class_call_management_descriptor {
  248. u8 bFunctionLength;
  249. u8 bDescriptorType;
  250. u8 bDescriptorSubtype; /* 0x01 */
  251. u8 bmCapabilities;
  252. u8 bDataInterface;
  253. } __attribute__ ((packed));
  254. struct usb_class_abstract_control_descriptor {
  255. u8 bFunctionLength;
  256. u8 bDescriptorType;
  257. u8 bDescriptorSubtype; /* 0x02 */
  258. u8 bmCapabilities;
  259. } __attribute__ ((packed));
  260. struct usb_class_direct_line_descriptor {
  261. u8 bFunctionLength;
  262. u8 bDescriptorType;
  263. u8 bDescriptorSubtype; /* 0x03 */
  264. } __attribute__ ((packed));
  265. struct usb_class_telephone_ringer_descriptor {
  266. u8 bFunctionLength;
  267. u8 bDescriptorType;
  268. u8 bDescriptorSubtype; /* 0x04 */
  269. u8 bRingerVolSeps;
  270. u8 bNumRingerPatterns;
  271. } __attribute__ ((packed));
  272. struct usb_class_telephone_call_descriptor {
  273. u8 bFunctionLength;
  274. u8 bDescriptorType;
  275. u8 bDescriptorSubtype; /* 0x05 */
  276. u8 bmCapabilities;
  277. } __attribute__ ((packed));
  278. struct usb_class_union_function_descriptor {
  279. u8 bFunctionLength;
  280. u8 bDescriptorType;
  281. u8 bDescriptorSubtype; /* 0x06 */
  282. u8 bMasterInterface;
  283. /* u8 bSlaveInterface0[0]; */
  284. u8 bSlaveInterface0;
  285. } __attribute__ ((packed));
  286. struct usb_class_country_selection_descriptor {
  287. u8 bFunctionLength;
  288. u8 bDescriptorType;
  289. u8 bDescriptorSubtype; /* 0x07 */
  290. u8 iCountryCodeRelDate;
  291. u16 wCountryCode0[0];
  292. } __attribute__ ((packed));
  293. struct usb_class_telephone_operational_descriptor {
  294. u8 bFunctionLength;
  295. u8 bDescriptorType;
  296. u8 bDescriptorSubtype; /* 0x08 */
  297. u8 bmCapabilities;
  298. } __attribute__ ((packed));
  299. struct usb_class_usb_terminal_descriptor {
  300. u8 bFunctionLength;
  301. u8 bDescriptorType;
  302. u8 bDescriptorSubtype; /* 0x09 */
  303. u8 bEntityId;
  304. u8 bInterfaceNo;
  305. u8 bOutInterfaceNo;
  306. u8 bmOptions;
  307. u8 bChild0[0];
  308. } __attribute__ ((packed));
  309. struct usb_class_network_channel_descriptor {
  310. u8 bFunctionLength;
  311. u8 bDescriptorType;
  312. u8 bDescriptorSubtype; /* 0x0a */
  313. u8 bEntityId;
  314. u8 iName;
  315. u8 bChannelIndex;
  316. u8 bPhysicalInterface;
  317. } __attribute__ ((packed));
  318. struct usb_class_protocol_unit_function_descriptor {
  319. u8 bFunctionLength;
  320. u8 bDescriptorType;
  321. u8 bDescriptorSubtype; /* 0x0b */
  322. u8 bEntityId;
  323. u8 bProtocol;
  324. u8 bChild0[0];
  325. } __attribute__ ((packed));
  326. struct usb_class_extension_unit_descriptor {
  327. u8 bFunctionLength;
  328. u8 bDescriptorType;
  329. u8 bDescriptorSubtype; /* 0x0c */
  330. u8 bEntityId;
  331. u8 bExtensionCode;
  332. u8 iName;
  333. u8 bChild0[0];
  334. } __attribute__ ((packed));
  335. struct usb_class_multi_channel_descriptor {
  336. u8 bFunctionLength;
  337. u8 bDescriptorType;
  338. u8 bDescriptorSubtype; /* 0x0d */
  339. u8 bmCapabilities;
  340. } __attribute__ ((packed));
  341. struct usb_class_capi_control_descriptor {
  342. u8 bFunctionLength;
  343. u8 bDescriptorType;
  344. u8 bDescriptorSubtype; /* 0x0e */
  345. u8 bmCapabilities;
  346. } __attribute__ ((packed));
  347. struct usb_class_ethernet_networking_descriptor {
  348. u8 bFunctionLength;
  349. u8 bDescriptorType;
  350. u8 bDescriptorSubtype; /* 0x0f */
  351. u8 iMACAddress;
  352. u32 bmEthernetStatistics;
  353. u16 wMaxSegmentSize;
  354. u16 wNumberMCFilters;
  355. u8 bNumberPowerFilters;
  356. } __attribute__ ((packed));
  357. struct usb_class_atm_networking_descriptor {
  358. u8 bFunctionLength;
  359. u8 bDescriptorType;
  360. u8 bDescriptorSubtype; /* 0x10 */
  361. u8 iEndSystermIdentifier;
  362. u8 bmDataCapabilities;
  363. u8 bmATMDeviceStatistics;
  364. u16 wType2MaxSegmentSize;
  365. u16 wType3MaxSegmentSize;
  366. u16 wMaxVC;
  367. } __attribute__ ((packed));
  368. struct usb_class_mdlm_descriptor {
  369. u8 bFunctionLength;
  370. u8 bDescriptorType;
  371. u8 bDescriptorSubtype; /* 0x12 */
  372. u16 bcdVersion;
  373. u8 bGUID[16];
  374. } __attribute__ ((packed));
  375. struct usb_class_mdlmd_descriptor {
  376. u8 bFunctionLength;
  377. u8 bDescriptorType;
  378. u8 bDescriptorSubtype; /* 0x13 */
  379. u8 bGuidDescriptorType;
  380. u8 bDetailData[0];
  381. } __attribute__ ((packed));
  382. /*
  383. * HID class descriptor structures
  384. *
  385. * c.f. HID 6.2.1
  386. */
  387. struct usb_class_hid_descriptor {
  388. u8 bLength;
  389. u8 bDescriptorType;
  390. u16 bcdCDC;
  391. u8 bCountryCode;
  392. u8 bNumDescriptors; /* 0x01 */
  393. u8 bDescriptorType0;
  394. u16 wDescriptorLength0;
  395. /* optional descriptors are not supported. */
  396. } __attribute__((packed));
  397. struct usb_class_report_descriptor {
  398. u8 bLength; /* dummy */
  399. u8 bDescriptorType;
  400. u16 wLength;
  401. u8 bData[0];
  402. } __attribute__((packed));
  403. /*
  404. * descriptor union structures
  405. */
  406. struct usb_descriptor {
  407. union {
  408. struct usb_generic_descriptor generic;
  409. struct usb_endpoint_descriptor endpoint;
  410. struct usb_interface_descriptor interface;
  411. struct usb_configuration_descriptor configuration;
  412. struct usb_device_descriptor device;
  413. struct usb_string_descriptor string;
  414. } descriptor;
  415. } __attribute__ ((packed));
  416. struct usb_class_descriptor {
  417. union {
  418. struct usb_class_function_descriptor function;
  419. struct usb_class_function_descriptor_generic generic;
  420. struct usb_class_header_function_descriptor header_function;
  421. struct usb_class_call_management_descriptor call_management;
  422. struct usb_class_abstract_control_descriptor abstract_control;
  423. struct usb_class_direct_line_descriptor direct_line;
  424. struct usb_class_telephone_ringer_descriptor telephone_ringer;
  425. struct usb_class_telephone_operational_descriptor telephone_operational;
  426. struct usb_class_telephone_call_descriptor telephone_call;
  427. struct usb_class_union_function_descriptor union_function;
  428. struct usb_class_country_selection_descriptor country_selection;
  429. struct usb_class_usb_terminal_descriptor usb_terminal;
  430. struct usb_class_network_channel_descriptor network_channel;
  431. struct usb_class_extension_unit_descriptor extension_unit;
  432. struct usb_class_multi_channel_descriptor multi_channel;
  433. struct usb_class_capi_control_descriptor capi_control;
  434. struct usb_class_ethernet_networking_descriptor ethernet_networking;
  435. struct usb_class_atm_networking_descriptor atm_networking;
  436. struct usb_class_mdlm_descriptor mobile_direct;
  437. struct usb_class_mdlmd_descriptor mobile_direct_detail;
  438. struct usb_class_hid_descriptor hid;
  439. } descriptor;
  440. } __attribute__ ((packed));
  441. #ifdef DEBUG
  442. static inline void print_device_descriptor(struct usb_device_descriptor *d)
  443. {
  444. serial_printf("usb device descriptor \n");
  445. serial_printf("\tbLength %2.2x\n", d->bLength);
  446. serial_printf("\tbDescriptorType %2.2x\n", d->bDescriptorType);
  447. serial_printf("\tbcdUSB %4.4x\n", d->bcdUSB);
  448. serial_printf("\tbDeviceClass %2.2x\n", d->bDeviceClass);
  449. serial_printf("\tbDeviceSubClass %2.2x\n", d->bDeviceSubClass);
  450. serial_printf("\tbDeviceProtocol %2.2x\n", d->bDeviceProtocol);
  451. serial_printf("\tbMaxPacketSize0 %2.2x\n", d->bMaxPacketSize0);
  452. serial_printf("\tidVendor %4.4x\n", d->idVendor);
  453. serial_printf("\tidProduct %4.4x\n", d->idProduct);
  454. serial_printf("\tbcdDevice %4.4x\n", d->bcdDevice);
  455. serial_printf("\tiManufacturer %2.2x\n", d->iManufacturer);
  456. serial_printf("\tiProduct %2.2x\n", d->iProduct);
  457. serial_printf("\tiSerialNumber %2.2x\n", d->iSerialNumber);
  458. serial_printf("\tbNumConfigurations %2.2x\n", d->bNumConfigurations);
  459. }
  460. #else
  461. /* stubs */
  462. #define print_device_descriptor(d)
  463. #endif /* DEBUG */
  464. #endif