usbdescriptors.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  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 0x02
  88. /* c.f. CDC 4.3 Table 16 */
  89. #define COMMUNICATIONS_NO_SUBCLASS 0x00
  90. #define COMMUNICATIONS_DLCM_SUBCLASS 0x01
  91. #define COMMUNICATIONS_ACM_SUBCLASS 0x02
  92. #define COMMUNICATIONS_TCM_SUBCLASS 0x03
  93. #define COMMUNICATIONS_MCCM_SUBCLASS 0x04
  94. #define COMMUNICATIONS_CCM_SUBCLASS 0x05
  95. #define COMMUNICATIONS_ENCM_SUBCLASS 0x06
  96. #define COMMUNICATIONS_ANCM_SUBCLASS 0x07
  97. /* c.f. WMCD 5.1 */
  98. #define COMMUNICATIONS_WHCM_SUBCLASS 0x08
  99. #define COMMUNICATIONS_DMM_SUBCLASS 0x09
  100. #define COMMUNICATIONS_MDLM_SUBCLASS 0x0a
  101. #define COMMUNICATIONS_OBEX_SUBCLASS 0x0b
  102. /* c.f. CDC 4.6 Table 18 */
  103. #define DATA_INTERFACE_CLASS 0x0a
  104. /* c.f. CDC 4.7 Table 19 */
  105. #define COMMUNICATIONS_NO_PROTOCOL 0x00
  106. /* c.f. CDC 5.2.3 Table 24 */
  107. #define CS_INTERFACE 0x24
  108. #define CS_ENDPOINT 0x25
  109. /*
  110. * bDescriptorSubtypes
  111. *
  112. * c.f. CDC 5.2.3 Table 25
  113. * c.f. WMCD 5.3 Table 5.3
  114. */
  115. #define USB_ST_HEADER 0x00
  116. #define USB_ST_CMF 0x01
  117. #define USB_ST_ACMF 0x02
  118. #define USB_ST_DLMF 0x03
  119. #define USB_ST_TRF 0x04
  120. #define USB_ST_TCLF 0x05
  121. #define USB_ST_UF 0x06
  122. #define USB_ST_CSF 0x07
  123. #define USB_ST_TOMF 0x08
  124. #define USB_ST_USBTF 0x09
  125. #define USB_ST_NCT 0x0a
  126. #define USB_ST_PUF 0x0b
  127. #define USB_ST_EUF 0x0c
  128. #define USB_ST_MCMF 0x0d
  129. #define USB_ST_CCMF 0x0e
  130. #define USB_ST_ENF 0x0f
  131. #define USB_ST_ATMNF 0x10
  132. #define USB_ST_WHCM 0x11
  133. #define USB_ST_MDLM 0x12
  134. #define USB_ST_MDLMD 0x13
  135. #define USB_ST_DMM 0x14
  136. #define USB_ST_OBEX 0x15
  137. #define USB_ST_CS 0x16
  138. #define USB_ST_CSD 0x17
  139. #define USB_ST_TCM 0x18
  140. /* endpoint modifiers
  141. * static struct usb_endpoint_description function_default_A_1[] = {
  142. *
  143. * {this_endpoint: 0, attributes: CONTROL, max_size: 8, polling_interval: 0 },
  144. * {this_endpoint: 1, attributes: BULK, max_size: 64, polling_interval: 0, direction: IN},
  145. * {this_endpoint: 2, attributes: BULK, max_size: 64, polling_interval: 0, direction: OUT},
  146. * {this_endpoint: 3, attributes: INTERRUPT, max_size: 8, polling_interval: 0},
  147. *
  148. *
  149. */
  150. #define OUT 0x00
  151. #define IN 0x80
  152. #define CONTROL 0x00
  153. #define ISOCHRONOUS 0x01
  154. #define BULK 0x02
  155. #define INTERRUPT 0x03
  156. /* configuration modifiers
  157. */
  158. #define BMATTRIBUTE_RESERVED 0x80
  159. #define BMATTRIBUTE_SELF_POWERED 0x40
  160. /*
  161. * standard usb descriptor structures
  162. */
  163. struct usb_endpoint_descriptor {
  164. u8 bLength;
  165. u8 bDescriptorType; /* 0x5 */
  166. u8 bEndpointAddress;
  167. u8 bmAttributes;
  168. u16 wMaxPacketSize;
  169. u8 bInterval;
  170. } __attribute__ ((packed));
  171. struct usb_interface_descriptor {
  172. u8 bLength;
  173. u8 bDescriptorType; /* 0x04 */
  174. u8 bInterfaceNumber;
  175. u8 bAlternateSetting;
  176. u8 bNumEndpoints;
  177. u8 bInterfaceClass;
  178. u8 bInterfaceSubClass;
  179. u8 bInterfaceProtocol;
  180. u8 iInterface;
  181. } __attribute__ ((packed));
  182. struct usb_configuration_descriptor {
  183. u8 bLength;
  184. u8 bDescriptorType; /* 0x2 */
  185. u16 wTotalLength;
  186. u8 bNumInterfaces;
  187. u8 bConfigurationValue;
  188. u8 iConfiguration;
  189. u8 bmAttributes;
  190. u8 bMaxPower;
  191. } __attribute__ ((packed));
  192. struct usb_device_descriptor {
  193. u8 bLength;
  194. u8 bDescriptorType; /* 0x01 */
  195. u16 bcdUSB;
  196. u8 bDeviceClass;
  197. u8 bDeviceSubClass;
  198. u8 bDeviceProtocol;
  199. u8 bMaxPacketSize0;
  200. u16 idVendor;
  201. u16 idProduct;
  202. u16 bcdDevice;
  203. u8 iManufacturer;
  204. u8 iProduct;
  205. u8 iSerialNumber;
  206. u8 bNumConfigurations;
  207. } __attribute__ ((packed));
  208. struct usb_string_descriptor {
  209. u8 bLength;
  210. u8 bDescriptorType; /* 0x03 */
  211. u16 wData[0];
  212. } __attribute__ ((packed));
  213. struct usb_generic_descriptor {
  214. u8 bLength;
  215. u8 bDescriptorType;
  216. u8 bDescriptorSubtype;
  217. } __attribute__ ((packed));
  218. /*
  219. * communications class descriptor structures
  220. *
  221. * c.f. CDC 5.2 Table 25c
  222. */
  223. struct usb_class_function_descriptor {
  224. u8 bFunctionLength;
  225. u8 bDescriptorType;
  226. u8 bDescriptorSubtype;
  227. } __attribute__ ((packed));
  228. struct usb_class_function_descriptor_generic {
  229. u8 bFunctionLength;
  230. u8 bDescriptorType;
  231. u8 bDescriptorSubtype;
  232. u8 bmCapabilities;
  233. } __attribute__ ((packed));
  234. struct usb_class_header_function_descriptor {
  235. u8 bFunctionLength;
  236. u8 bDescriptorType;
  237. u8 bDescriptorSubtype; /* 0x00 */
  238. u16 bcdCDC;
  239. } __attribute__ ((packed));
  240. struct usb_class_call_management_descriptor {
  241. u8 bFunctionLength;
  242. u8 bDescriptorType;
  243. u8 bDescriptorSubtype; /* 0x01 */
  244. u8 bmCapabilities;
  245. u8 bDataInterface;
  246. } __attribute__ ((packed));
  247. struct usb_class_abstract_control_descriptor {
  248. u8 bFunctionLength;
  249. u8 bDescriptorType;
  250. u8 bDescriptorSubtype; /* 0x02 */
  251. u8 bmCapabilities;
  252. } __attribute__ ((packed));
  253. struct usb_class_direct_line_descriptor {
  254. u8 bFunctionLength;
  255. u8 bDescriptorType;
  256. u8 bDescriptorSubtype; /* 0x03 */
  257. } __attribute__ ((packed));
  258. struct usb_class_telephone_ringer_descriptor {
  259. u8 bFunctionLength;
  260. u8 bDescriptorType;
  261. u8 bDescriptorSubtype; /* 0x04 */
  262. u8 bRingerVolSeps;
  263. u8 bNumRingerPatterns;
  264. } __attribute__ ((packed));
  265. struct usb_class_telephone_call_descriptor {
  266. u8 bFunctionLength;
  267. u8 bDescriptorType;
  268. u8 bDescriptorSubtype; /* 0x05 */
  269. u8 bmCapabilities;
  270. } __attribute__ ((packed));
  271. struct usb_class_union_function_descriptor {
  272. u8 bFunctionLength;
  273. u8 bDescriptorType;
  274. u8 bDescriptorSubtype; /* 0x06 */
  275. u8 bMasterInterface;
  276. u8 bSlaveInterface0[0];
  277. } __attribute__ ((packed));
  278. struct usb_class_country_selection_descriptor {
  279. u8 bFunctionLength;
  280. u8 bDescriptorType;
  281. u8 bDescriptorSubtype; /* 0x07 */
  282. u8 iCountryCodeRelDate;
  283. u16 wCountryCode0[0];
  284. } __attribute__ ((packed));
  285. struct usb_class_telephone_operational_descriptor {
  286. u8 bFunctionLength;
  287. u8 bDescriptorType;
  288. u8 bDescriptorSubtype; /* 0x08 */
  289. u8 bmCapabilities;
  290. } __attribute__ ((packed));
  291. struct usb_class_usb_terminal_descriptor {
  292. u8 bFunctionLength;
  293. u8 bDescriptorType;
  294. u8 bDescriptorSubtype; /* 0x09 */
  295. u8 bEntityId;
  296. u8 bInterfaceNo;
  297. u8 bOutInterfaceNo;
  298. u8 bmOptions;
  299. u8 bChild0[0];
  300. } __attribute__ ((packed));
  301. struct usb_class_network_channel_descriptor {
  302. u8 bFunctionLength;
  303. u8 bDescriptorType;
  304. u8 bDescriptorSubtype; /* 0x0a */
  305. u8 bEntityId;
  306. u8 iName;
  307. u8 bChannelIndex;
  308. u8 bPhysicalInterface;
  309. } __attribute__ ((packed));
  310. struct usb_class_protocol_unit_function_descriptor {
  311. u8 bFunctionLength;
  312. u8 bDescriptorType;
  313. u8 bDescriptorSubtype; /* 0x0b */
  314. u8 bEntityId;
  315. u8 bProtocol;
  316. u8 bChild0[0];
  317. } __attribute__ ((packed));
  318. struct usb_class_extension_unit_descriptor {
  319. u8 bFunctionLength;
  320. u8 bDescriptorType;
  321. u8 bDescriptorSubtype; /* 0x0c */
  322. u8 bEntityId;
  323. u8 bExtensionCode;
  324. u8 iName;
  325. u8 bChild0[0];
  326. } __attribute__ ((packed));
  327. struct usb_class_multi_channel_descriptor {
  328. u8 bFunctionLength;
  329. u8 bDescriptorType;
  330. u8 bDescriptorSubtype; /* 0x0d */
  331. u8 bmCapabilities;
  332. } __attribute__ ((packed));
  333. struct usb_class_capi_control_descriptor {
  334. u8 bFunctionLength;
  335. u8 bDescriptorType;
  336. u8 bDescriptorSubtype; /* 0x0e */
  337. u8 bmCapabilities;
  338. } __attribute__ ((packed));
  339. struct usb_class_ethernet_networking_descriptor {
  340. u8 bFunctionLength;
  341. u8 bDescriptorType;
  342. u8 bDescriptorSubtype; /* 0x0f */
  343. u8 iMACAddress;
  344. u32 bmEthernetStatistics;
  345. u16 wMaxSegmentSize;
  346. u16 wNumberMCFilters;
  347. u8 bNumberPowerFilters;
  348. } __attribute__ ((packed));
  349. struct usb_class_atm_networking_descriptor {
  350. u8 bFunctionLength;
  351. u8 bDescriptorType;
  352. u8 bDescriptorSubtype; /* 0x10 */
  353. u8 iEndSystermIdentifier;
  354. u8 bmDataCapabilities;
  355. u8 bmATMDeviceStatistics;
  356. u16 wType2MaxSegmentSize;
  357. u16 wType3MaxSegmentSize;
  358. u16 wMaxVC;
  359. } __attribute__ ((packed));
  360. struct usb_class_mdlm_descriptor {
  361. u8 bFunctionLength;
  362. u8 bDescriptorType;
  363. u8 bDescriptorSubtype; /* 0x12 */
  364. u16 bcdVersion;
  365. u8 bGUID[16];
  366. } __attribute__ ((packed));
  367. struct usb_class_mdlmd_descriptor {
  368. u8 bFunctionLength;
  369. u8 bDescriptorType;
  370. u8 bDescriptorSubtype; /* 0x13 */
  371. u8 bGuidDescriptorType;
  372. u8 bDetailData[0];
  373. } __attribute__ ((packed));
  374. /*
  375. * HID class descriptor structures
  376. *
  377. * c.f. HID 6.2.1
  378. */
  379. struct usb_class_hid_descriptor {
  380. u8 bLength;
  381. u8 bDescriptorType;
  382. u16 bcdCDC;
  383. u8 bCountryCode;
  384. u8 bNumDescriptors; /* 0x01 */
  385. u8 bDescriptorType0;
  386. u16 wDescriptorLength0;
  387. /* optional descriptors are not supported. */
  388. } __attribute__((packed));
  389. struct usb_class_report_descriptor {
  390. u8 bLength; /* dummy */
  391. u8 bDescriptorType;
  392. u16 wLength;
  393. u8 bData[0];
  394. } __attribute__((packed));
  395. /*
  396. * descriptor union structures
  397. */
  398. struct usb_descriptor {
  399. union {
  400. struct usb_generic_descriptor generic;
  401. struct usb_endpoint_descriptor endpoint;
  402. struct usb_interface_descriptor interface;
  403. struct usb_configuration_descriptor configuration;
  404. struct usb_device_descriptor device;
  405. struct usb_string_descriptor string;
  406. } descriptor;
  407. } __attribute__ ((packed));
  408. struct usb_class_descriptor {
  409. union {
  410. struct usb_class_function_descriptor function;
  411. struct usb_class_function_descriptor_generic generic;
  412. struct usb_class_header_function_descriptor header_function;
  413. struct usb_class_call_management_descriptor call_management;
  414. struct usb_class_abstract_control_descriptor abstract_control;
  415. struct usb_class_direct_line_descriptor direct_line;
  416. struct usb_class_telephone_ringer_descriptor telephone_ringer;
  417. struct usb_class_telephone_operational_descriptor telephone_operational;
  418. struct usb_class_telephone_call_descriptor telephone_call;
  419. struct usb_class_union_function_descriptor union_function;
  420. struct usb_class_country_selection_descriptor country_selection;
  421. struct usb_class_usb_terminal_descriptor usb_terminal;
  422. struct usb_class_network_channel_descriptor network_channel;
  423. struct usb_class_extension_unit_descriptor extension_unit;
  424. struct usb_class_multi_channel_descriptor multi_channel;
  425. struct usb_class_capi_control_descriptor capi_control;
  426. struct usb_class_ethernet_networking_descriptor ethernet_networking;
  427. struct usb_class_atm_networking_descriptor atm_networking;
  428. struct usb_class_mdlm_descriptor mobile_direct;
  429. struct usb_class_mdlmd_descriptor mobile_direct_detail;
  430. struct usb_class_hid_descriptor hid;
  431. } descriptor;
  432. } __attribute__ ((packed));
  433. #endif