usbhost.h 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261
  1. /************************************************************************************
  2. * include/nuttx/usb/usbhost.h
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ************************************************************************************/
  20. /* References:
  21. * "Universal Serial Bus Mass Storage Class, Specification Overview,"
  22. * Revision 1.2, USB Implementer's Forum, June 23, 2003.
  23. *
  24. * "Universal Serial Bus Mass Storage Class, Bulk-Only Transport,"
  25. * Revision 1.0, USB Implementer's Forum, September 31, 1999.
  26. */
  27. #ifndef __INCLUDE_NUTTX_USB_USBHOST_H
  28. #define __INCLUDE_NUTTX_USB_USBHOST_H
  29. /************************************************************************************
  30. * Included Files
  31. ************************************************************************************/
  32. #include <nuttx/config.h>
  33. #include <sys/types.h>
  34. #include <stdint.h>
  35. #include <stdbool.h>
  36. #ifdef CONFIG_USBHOST_MSC_NOTIFIER
  37. # include <nuttx/wqueue.h>
  38. #endif
  39. #include <nuttx/usb/usbhost_devaddr.h>
  40. /************************************************************************************
  41. * Pre-processor Definitions
  42. ************************************************************************************/
  43. /************************************************************************************
  44. * Name: ROOTHUB
  45. *
  46. * Description:
  47. * Check if a hub instance is the root hub.
  48. *
  49. ************************************************************************************/
  50. #ifdef CONFIG_USBHOST_HUB
  51. # define ROOTHUB(hub) ((hub)->parent == NULL)
  52. #else
  53. # define ROOTHUB(hub) true
  54. #endif
  55. /************************************************************************************
  56. * Name: CLASS_CREATE
  57. *
  58. * Description:
  59. * This macro will call the create() method of struct usbhost_registry_s.
  60. * The create() method is a callback into the class implementation. It is used
  61. * to (1) create a new instance of the USB host class state and to (2) bind a
  62. * USB host driver "session" to the class instance. Use of this create() method
  63. * will support environments where there may be multiple USB ports and multiple
  64. * USB devices simultaneously connected.
  65. *
  66. * Input Parameters:
  67. * reg - The USB host class registry entry previously obtained from a call to
  68. * usbhost_findclass().
  69. * hport - The hub hat manages the new class instance.
  70. * id - In the case where the device supports multiple base classes, subclasses, or
  71. * protocols, this specifies which to configure for.
  72. *
  73. * Returned Value:
  74. * On success, this function will return a non-NULL instance of struct
  75. * usbhost_class_s that can be used by the USB host driver to communicate with the
  76. * USB host class. NULL is returned on failure; this function will fail only if
  77. * the drvr input parameter is NULL or if there are insufficient resources to
  78. * create another USB host class instance.
  79. *
  80. * Assumptions:
  81. * If this function is called from an interrupt handler, it will be unable to
  82. * allocate memory and CONFIG_USBHOST_NPREALLOC should be defined to be a value
  83. * greater than zero specify a number of pre-allocated class structures.
  84. *
  85. ************************************************************************************/
  86. #define CLASS_CREATE(reg,hport,id) ((reg)->create(hport,id))
  87. /************************************************************************************
  88. * Name: CLASS_CONNECT
  89. *
  90. * Description:
  91. * This macro will call the connect() method of struct usbhost_class_s. This
  92. * method is a callback into the devclass implementation. It is used to provide
  93. * the device's configuration descriptor to the devclass so that the devclass may
  94. * initialize properly.
  95. *
  96. * Input Parameters:
  97. * devclass - The USB host class entry previously obtained from a call
  98. * to create().
  99. * configdesc - A pointer to a uint8_t buffer containing the configuration
  100. * descriptor.
  101. * desclen - The length in bytes of the configuration descriptor.
  102. *
  103. * Returned Value:
  104. * On success, zero (OK) is returned. On a failure, a negated errno value is
  105. * returned indicating the nature of the failure
  106. *
  107. * NOTE that the class instance remains valid upon return with a failure. It is
  108. * the responsibility of the higher level enumeration logic to call
  109. * CLASS_DISCONNECTED to free up the class driver resources.
  110. *
  111. * Assumptions:
  112. * - This function is probably called on the same thread that called the driver
  113. * enumerate() method. This function will *not* be called from an interrupt
  114. * handler.
  115. * - If this function returns an error, the USB host controller driver
  116. * must call to DISCONNECTED method to recover from the error
  117. *
  118. ************************************************************************************/
  119. #define CLASS_CONNECT(devclass,configdesc,desclen) \
  120. ((devclass)->connect(devclass,configdesc,desclen))
  121. /************************************************************************************
  122. * Name: CLASS_DISCONNECTED
  123. *
  124. * Description:
  125. * This macro will call the disconnected() method of struct usbhost_class_s. This
  126. * method is a callback into the class implementation. It is used to inform the
  127. * class that the USB device has been disconnected.
  128. *
  129. * Input Parameters:
  130. * devclass - The USB host class entry previously obtained from a call to create().
  131. *
  132. * Returned Value:
  133. * On success, zero (OK) is returned. On a failure, a negated errno value is
  134. * returned indicating the nature of the failure
  135. *
  136. * Assumptions:
  137. * This function will *not* be called from an interrupt handler.
  138. *
  139. ************************************************************************************/
  140. #define CLASS_DISCONNECTED(devclass) ((devclass)->disconnected(devclass))
  141. /************************************************************************************
  142. * Name: CONN_WAIT
  143. *
  144. * Description:
  145. * Wait for a device to be connected or disconnected to/from a hub port.
  146. *
  147. * Input Parameters:
  148. * conn - The USB host connection instance obtained as a parameter from the call to
  149. * the USB driver initialization logic.
  150. * hport - The location to return the hub port descriptor that detected the
  151. * connection related event.
  152. *
  153. * Returned Value:
  154. * Zero (OK) is returned on success when a device is connected or
  155. * disconnected. This function will not return until either (1) a device is
  156. * connected or disconnect to/from any hub port or until (2) some failure
  157. * occurs. On a failure, a negated errno value is returned indicating the
  158. * nature of the failure
  159. *
  160. * Assumptions:
  161. * - Called from a single thread so no mutual exclusion is required.
  162. * - Never called from an interrupt handler.
  163. *
  164. ************************************************************************************/
  165. #define CONN_WAIT(conn,hport) ((conn)->wait(conn,hport))
  166. /************************************************************************************
  167. * Name: CONN_ENUMERATE
  168. *
  169. * Description:
  170. * Enumerate the connected device. As part of this enumeration process,
  171. * the driver will (1) get the device's configuration descriptor, (2)
  172. * extract the class ID info from the configuration descriptor, (3) call
  173. * usbhost_findclass() to find the class that supports this device, (4)
  174. * call the create() method on the struct usbhost_registry_s interface
  175. * to get a class instance, and finally (5) call the connect() method
  176. * of the struct usbhost_class_s interface. After that, the class is in
  177. * charge of the sequence of operations.
  178. *
  179. * Input Parameters:
  180. * conn - The USB host connection instance obtained as a parameter from
  181. * the call to the USB driver initialization logic.
  182. * hport - The descriptor of the hub port that has the newly connected
  183. * device.
  184. *
  185. * Returned Value:
  186. * On success, zero (OK) is returned. On a failure, a negated errno value is
  187. * returned indicating the nature of the failure
  188. *
  189. * Assumptions:
  190. * This function will *not* be called from an interrupt handler.
  191. *
  192. ************************************************************************************/
  193. #define CONN_ENUMERATE(conn,rhpndx) ((conn)->enumerate(conn,rhpndx))
  194. /************************************************************************************
  195. * Name: DRVR_EP0CONFIGURE
  196. *
  197. * Description:
  198. * Configure endpoint 0. This method is normally used internally by the
  199. * enumerate() method but is made available at the interface to support
  200. * an external implementation of the enumeration logic.
  201. *
  202. * Input Parameters:
  203. * drvr - The USB host driver instance obtained as a parameter from the call to
  204. * the class create() method.
  205. * ep0 - The (opaque) EP0 endpoint instance
  206. * funcaddr - The USB address of the function containing the endpoint that EP0
  207. * controls
  208. * speed - The speed of the port USB_SPEED_LOW, _FULL, or _HIGH
  209. * mps (maxpacketsize) - The maximum number of bytes that can be sent to or
  210. * received from the endpoint in a single data packet
  211. *
  212. * Returned Value:
  213. * On success, zero (OK) is returned. On a failure, a negated errno value is
  214. * returned indicating the nature of the failure
  215. *
  216. * Assumptions:
  217. * This function will *not* be called from an interrupt handler.
  218. *
  219. ************************************************************************************/
  220. #define DRVR_EP0CONFIGURE(drvr,ep0,funcaddr,speed,mps) \
  221. ((drvr)->ep0configure(drvr,ep0,funcaddr,speed,mps))
  222. /************************************************************************************
  223. * Name: DRVR_GETDEVINFO
  224. *
  225. * Description:
  226. * Get information about the connected device.
  227. *
  228. * Input Parameters:
  229. * drvr - The USB host driver instance obtained as a parameter from the call to
  230. * the class create() method.
  231. * devinfo - A pointer to memory provided by the caller in which to return the
  232. * device information.
  233. *
  234. * Returned Value:
  235. * On success, zero (OK) is returned. On a failure, a negated errno value is
  236. * returned indicating the nature of the failure
  237. *
  238. * Assumptions:
  239. * This function will *not* be called from an interrupt handler.
  240. *
  241. ************************************************************************************/
  242. #define DRVR_GETDEVINFO(drvr,devinfo) ((drvr)->getdevinfo(drvr,devinfo))
  243. /************************************************************************************
  244. * Name: DRVR_EPALLOC
  245. *
  246. * Description:
  247. * Allocate and configure one endpoint.
  248. *
  249. * Input Parameters:
  250. * drvr - The USB host driver instance obtained as a parameter from the call to
  251. * the class create() method.
  252. * epdesc - Describes the endpoint to be allocated.
  253. * ep - A memory location provided by the caller in which to receive the
  254. * allocated endpoint descriptor.
  255. *
  256. * Returned Value:
  257. * On success, zero (OK) is returned. On a failure, a negated errno value is
  258. * returned indicating the nature of the failure
  259. *
  260. * Assumptions:
  261. * This function will *not* be called from an interrupt handler.
  262. *
  263. ************************************************************************************/
  264. #define DRVR_EPALLOC(drvr,epdesc,ep) ((drvr)->epalloc(drvr,epdesc,ep))
  265. /************************************************************************************
  266. * Name: DRVR_EPFREE
  267. *
  268. * Description:
  269. * Free and endpoint previously allocated by DRVR_EPALLOC.
  270. *
  271. * Input Parameters:
  272. * drvr - The USB host driver instance obtained as a parameter from the call to
  273. * the class create() method.
  274. * ep - The endpoint to be freed.
  275. *
  276. * Returned Value:
  277. * On success, zero (OK) is returned. On a failure, a negated errno value is
  278. * returned indicating the nature of the failure
  279. *
  280. * Assumptions:
  281. * This function will *not* be called from an interrupt handler.
  282. *
  283. ************************************************************************************/
  284. #define DRVR_EPFREE(drvr,ep) ((drvr)->epfree(drvr,ep))
  285. /************************************************************************************
  286. * Name: DRVR_ALLOC
  287. *
  288. * Description:
  289. * Some hardware supports special memory in which request and descriptor data can
  290. * be accessed more efficiently. This method provides a mechanism to allocate
  291. * the request/descriptor memory. If the underlying hardware does not support
  292. * such "special" memory, this functions may simply map to kmm_malloc.
  293. *
  294. * This interface was optimized under a particular assumption. It was assumed
  295. * that the driver maintains a pool of small, pre-allocated buffers for descriptor
  296. * traffic. NOTE that size is not an input, but an output: The size of the
  297. * pre-allocated buffer is returned.
  298. *
  299. * Input Parameters:
  300. * drvr - The USB host driver instance obtained as a parameter from the call to
  301. * the class create() method.
  302. * buffer - The address of a memory location provided by the caller in which to
  303. * return the allocated buffer memory address.
  304. * maxlen - The address of a memory location provided by the caller in which to
  305. * return the maximum size of the allocated buffer memory.
  306. *
  307. * Returned Value:
  308. * On success, zero (OK) is returned. On a failure, a negated errno value is
  309. * returned indicating the nature of the failure
  310. *
  311. * Assumptions:
  312. * This function will *not* be called from an interrupt handler.
  313. *
  314. ************************************************************************************/
  315. #define DRVR_ALLOC(drvr,buffer,maxlen) ((drvr)->alloc(drvr,buffer,maxlen))
  316. /************************************************************************************
  317. * Name: DRVR_FREE
  318. *
  319. * Description:
  320. * Some hardware supports special memory in which request and descriptor data can
  321. * be accessed more efficiently. This method provides a mechanism to free that
  322. * request/descriptor memory. If the underlying hardware does not support
  323. * such "special" memory, this functions may simply map to kmm_free().
  324. *
  325. * Input Parameters:
  326. * drvr - The USB host driver instance obtained as a parameter from the call to
  327. * the class create() method.
  328. * buffer - The address of the allocated buffer memory to be freed.
  329. *
  330. * Returned Value:
  331. * On success, zero (OK) is returned. On a failure, a negated errno value is
  332. * returned indicating the nature of the failure
  333. *
  334. * Assumptions:
  335. * This function will *not* be called from an interrupt handler.
  336. *
  337. ************************************************************************************/
  338. #define DRVR_FREE(drvr,buffer) ((drvr)->free(drvr,buffer))
  339. /************************************************************************************
  340. * Name: DRVR_IOALLOC
  341. *
  342. * Description:
  343. * Some hardware supports special memory in which larger IO buffers can
  344. * be accessed more efficiently. This method provides a mechanism to allocate
  345. * the request/descriptor memory. If the underlying hardware does not support
  346. * such "special" memory, this functions may simply map to kmm_malloc.
  347. *
  348. * This interface differs from DRVR_ALLOC in that the buffers are variable-sized.
  349. *
  350. * Input Parameters:
  351. * drvr - The USB host driver instance obtained as a parameter from the call to
  352. * the class create() method.
  353. * buffer - The address of a memory location provided by the caller in which to
  354. * return the allocated buffer memory address.
  355. * buflen - The size of the buffer required.
  356. *
  357. * Returned Value:
  358. * On success, zero (OK) is returned. On a failure, a negated errno value is
  359. * returned indicating the nature of the failure
  360. *
  361. * Assumptions:
  362. * This function will *not* be called from an interrupt handler.
  363. *
  364. ************************************************************************************/
  365. #define DRVR_IOALLOC(drvr,buffer,buflen) ((drvr)->ioalloc(drvr,buffer,buflen))
  366. /************************************************************************************
  367. * Name: DRVR_IOFREE
  368. *
  369. * Description:
  370. * Some hardware supports special memory in which IO data can be accessed more
  371. * efficiently. This method provides a mechanism to free that IO buffer
  372. * memory. If the underlying hardware does not support such "special" memory,
  373. * this functions may simply map to kmm_free().
  374. *
  375. * Input Parameters:
  376. * drvr - The USB host driver instance obtained as a parameter from the call to
  377. * the class create() method.
  378. * buffer - The address of the allocated buffer memory to be freed.
  379. *
  380. * Returned Value:
  381. * On success, zero (OK) is returned. On a failure, a negated errno value is
  382. * returned indicating the nature of the failure
  383. *
  384. * Assumptions:
  385. * This function will *not* be called from an interrupt handler.
  386. *
  387. ************************************************************************************/
  388. #define DRVR_IOFREE(drvr,buffer) ((drvr)->iofree(drvr,buffer))
  389. /************************************************************************************
  390. * Name: DRVR_CTRLIN and DRVR_CTRLOUT
  391. *
  392. * Description:
  393. * Process a IN or OUT request on the control endpoint. These methods
  394. * will enqueue the request and wait for it to complete. Only one transfer may be
  395. * queued; Neither these methods nor the transfer() method can be called again
  396. * until the control transfer functions returns.
  397. *
  398. * These are blocking methods; these functions will not return until the
  399. * control transfer has completed.
  400. *
  401. * Input Parameters:
  402. * drvr - The USB host driver instance obtained as a parameter from the call to
  403. * the class create() method.
  404. * ep0 - The control endpoint to send/receive the control request.
  405. * req - Describes the request to be sent. This request must lie in memory
  406. * created by DRVR_ALLOC.
  407. * buffer - A buffer used for sending the request and for returning any
  408. * responses. This buffer must be large enough to hold the length value
  409. * in the request description. buffer must have been allocated using DRVR_ALLOC.
  410. *
  411. * NOTE: On an IN transaction, req and buffer may refer to the same allocated
  412. * memory.
  413. *
  414. * Returned Value:
  415. * On success, zero (OK) is returned. On a failure, a negated errno value is
  416. * returned indicating the nature of the failure
  417. *
  418. * Assumptions:
  419. * This function will *not* be called from an interrupt handler.
  420. *
  421. ************************************************************************************/
  422. #define DRVR_CTRLIN(drvr,ep0,req,buffer) ((drvr)->ctrlin(drvr,ep0,req,buffer))
  423. #define DRVR_CTRLOUT(drvr,ep0,req,buffer) ((drvr)->ctrlout(drvr,ep0,req,buffer))
  424. /************************************************************************************
  425. * Name: DRVR_TRANSFER
  426. *
  427. * Description:
  428. * Process a request to handle a transfer descriptor. This method will
  429. * enqueue the transfer request and wait for it to complete. Only one
  430. * transfer may be queued; Neither this method nor the ctrlin nor ctrlout
  431. * methods can be called) again until this function returns.
  432. *
  433. * This is a blocking method; this method will not return until the
  434. * transfer has completed.
  435. *
  436. * Input Parameters:
  437. * drvr - The USB host driver instance obtained as a parameter from the call to
  438. * the class create() method.
  439. * ep - The IN or OUT endpoint descriptor for the device endpoint on which to
  440. * perform the transfer.
  441. * buffer - A buffer containing the data to be sent (OUT endpoint) or received
  442. * (IN endpoint). buffer must have been allocated using DRVR_ALLOC
  443. * buflen - The length of the data to be sent or received.
  444. *
  445. * Returned Value:
  446. * On success, a non-negative value is returned that indicates the number
  447. * of bytes successfully transferred. On a failure, a negated errno value is
  448. * returned that indicates the nature of the failure:
  449. *
  450. * EAGAIN - If devices NAKs the transfer (or NYET or other error where
  451. * it may be appropriate to restart the entire transaction).
  452. * EPERM - If the endpoint stalls
  453. * EIO - On a TX or data toggle error
  454. * EPIPE - Overrun errors
  455. *
  456. * Assumptions:
  457. * This function will *not* be called from an interrupt handler.
  458. *
  459. ************************************************************************************/
  460. #define DRVR_TRANSFER(drvr,ep,buffer,buflen) \
  461. ((drvr)->transfer(drvr,ep,buffer,buflen))
  462. /************************************************************************************
  463. * Name: DRVR_ASYNCH
  464. *
  465. * Description:
  466. * Process a request to handle a transfer asynchronously. This method
  467. * will enqueue the transfer request and return immediately. Only one
  468. * transfer may be queued on a given endpoint/
  469. *
  470. * When the transfer completes, the callback will be invoked with the
  471. * provided argument.
  472. *
  473. * This method is useful for receiving interrupt transfers which may come
  474. * infrequently.
  475. *
  476. * Input Parameters:
  477. * drvr - The USB host driver instance obtained as a parameter from the call to
  478. * the class create() method.
  479. * ep - The IN or OUT endpoint descriptor for the device endpoint on which to
  480. * perform the transfer.
  481. * buffer - A buffer containing the data to be sent (OUT endpoint) or received
  482. * (IN endpoint). buffer must have been allocated using DRVR_ALLOC
  483. * buflen - The length of the data to be sent or received.
  484. * callback - This function will be called when the transfer completes.
  485. * arg - The arbitrary parameter that will be passed to the callback function
  486. * when the transfer completes.
  487. *
  488. * Returned Value:
  489. * On success, zero (OK) is returned. On a failure, a negated errno value is
  490. * returned indicating the nature of the failure.
  491. *
  492. * Assumptions:
  493. * This function will *not* be called from an interrupt handler.
  494. *
  495. ************************************************************************************/
  496. #ifdef CONFIG_USBHOST_ASYNCH
  497. # define DRVR_ASYNCH(drvr,ep,buffer,buflen,callback,arg) \
  498. ((drvr)->asynch(drvr,ep,buffer,buflen,callback,arg))
  499. #endif
  500. /************************************************************************************
  501. * Name: DRVR_CANCEL
  502. *
  503. * Description:
  504. * Cancel a pending transfer on an endpoint. Cancelled synchronous or
  505. * asynchronous transfer will complete normally with the error -ESHUTDOWN.
  506. *
  507. * Input Parameters:
  508. * drvr - The USB host driver instance obtained as a parameter from the call to
  509. * the class create() method.
  510. * ep - The IN or OUT endpoint descriptor for the device endpoint on which an
  511. * asynchronous transfer should be transferred.
  512. *
  513. * Returned Value:
  514. * On success, zero (OK) is returned. On a failure, a negated errno value is
  515. * returned indicating the nature of the failure.
  516. *
  517. ************************************************************************************/
  518. #define DRVR_CANCEL(drvr,ep) ((drvr)->cancel(drvr,ep))
  519. /************************************************************************************
  520. * Name: DRVR_CONNECT
  521. *
  522. * Description:
  523. * New connections may be detected by an attached hub. This method is the
  524. * mechanism that is used by the hub class to introduce a new connection
  525. * and port description to the system.
  526. *
  527. * Input Parameters:
  528. * drvr - The USB host driver instance obtained as a parameter from the call to
  529. * the class create() method.
  530. * hport - The descriptor of the hub port that detected the connection
  531. * related event
  532. * connected - True: device connected; false: device disconnected
  533. *
  534. * Returned Value:
  535. * On success, zero (OK) is returned. On a failure, a negated errno value is
  536. * returned indicating the nature of the failure.
  537. *
  538. ************************************************************************************/
  539. #ifdef CONFIG_USBHOST_HUB
  540. # define DRVR_CONNECT(drvr,hport,connected) \
  541. ((drvr)->connect(drvr,hport,connected))
  542. #endif
  543. /************************************************************************************
  544. * Name: DRVR_DISCONNECT
  545. *
  546. * Description:
  547. * Called by the class when an error occurs and driver has been disconnected.
  548. * The USB host driver should discard the handle to the class instance (it is
  549. * stale) and not attempt any further interaction with the class driver instance
  550. * (until a new instance is received from the create() method). The driver
  551. * should not called the class' disconnected() method.
  552. *
  553. * Input Parameters:
  554. * drvr - The USB host driver instance obtained as a parameter from the call to
  555. * the class create() method.
  556. * hport - The port from which the device is being disconnected. Might be a port
  557. * on a hub.
  558. *
  559. * Returned Value:
  560. * None
  561. *
  562. * Assumptions:
  563. * This function will *not* be called from an interrupt handler.
  564. *
  565. ************************************************************************************/
  566. #define DRVR_DISCONNECT(drvr, hport) ((drvr)->disconnect(drvr, hport))
  567. /************************************************************************************
  568. * Public Types
  569. ************************************************************************************/
  570. /* This struct contains all of the information that is needed to associate a device
  571. * this is connected via a USB port to a class.
  572. */
  573. struct usbhost_id_s
  574. {
  575. uint8_t base; /* Base device class code (see USB_CLASS_* defines in usb.h) */
  576. uint8_t subclass; /* Sub-class, depends on base class. Eg., See USBMSC_SUBCLASS_* */
  577. uint8_t proto; /* Protocol, depends on base class. Eg., See USBMSC_PROTO_* */
  578. uint16_t vid; /* Vendor ID (for vendor/product specific devices) */
  579. uint16_t pid; /* Product ID (for vendor/product specific devices) */
  580. };
  581. /* The struct usbhost_registry_s type describes information that is kept in the
  582. * USB host registry. USB host class implementations register this information so
  583. * that USB host drivers can later find the class that matches the device that is
  584. * connected to the USB port.
  585. */
  586. struct usbhost_hubport_s; /* Forward reference to the hub state structure */
  587. struct usbhost_class_s; /* Forward reference to the class state structure */
  588. struct usbhost_registry_s
  589. {
  590. /* This field is used to implement a singly-link registry structure. Because of
  591. * the presence of this link, provides of struct usbhost_registry_s instances must
  592. * provide those instances in write-able memory (RAM).
  593. */
  594. FAR struct usbhost_registry_s *flink;
  595. /* This is a callback into the class implementation. It is used to (1) create
  596. * a new instance of the USB host class state and to (2) bind a USB host driver
  597. * "session" to the class instance. Use of this create() method will support
  598. * environments where there may be multiple USB ports and multiple USB devices
  599. * simultaneously connected (see the CLASS_CREATE() macro above).
  600. */
  601. CODE FAR struct usbhost_class_s *(*create)(FAR struct usbhost_hubport_s *hub,
  602. FAR const struct usbhost_id_s *id);
  603. /* This information uniquely identifies the USB host class implementation that
  604. * goes with a specific USB device.
  605. */
  606. uint8_t nids; /* Number of IDs in the id[] array */
  607. FAR const struct usbhost_id_s *id; /* An array of ID info. Actual dimension is nids */
  608. };
  609. /* This type represents one endpoint configured by the epalloc() method.
  610. * The actual form is known only internally to the USB host controller
  611. * (for example, for an OHCI driver, this would probably be a pointer
  612. * to an endpoint descriptor).
  613. */
  614. typedef FAR void *usbhost_ep_t;
  615. /* In the hierarchy of things, there is the host control driver (HCD),
  616. * represented by struct usbhost_driver_s. Connected to the HCD are one
  617. * or more hubs. At a minimum, the root hub is always present. Each hub
  618. * has from 1 to 4 ports.
  619. */
  620. /* Every class connects to the host controller driver (HCD) via a port on a
  621. * hub. That hub may be an external hub or the internal, root hub. The
  622. * root hub is managed by the HCD. This structure describes that state of
  623. * that port and provides the linkage to the parent hub in that event that
  624. * the port is on an external hub.
  625. *
  626. * The root hub port can be distinguish because it has parent == NULL.
  627. */
  628. struct usbhost_hubport_s
  629. {
  630. FAR struct usbhost_driver_s *drvr; /* Common host driver */
  631. #ifdef CONFIG_USBHOST_HUB
  632. FAR struct usbhost_hubport_s *parent; /* Parent hub (NULL=root hub) */
  633. #endif
  634. FAR struct usbhost_class_s *devclass; /* The bound device class driver */
  635. usbhost_ep_t ep0; /* Control endpoint, ep0 */
  636. bool connected; /* True: device connected; false: disconnected */
  637. uint8_t port; /* Hub port index */
  638. uint8_t funcaddr; /* Device function address */
  639. uint8_t speed; /* Device speed */
  640. };
  641. /* The root hub port differs in that it includes a data set that is used to
  642. * manage the generation of unique device function addresses on all
  643. * downstream ports.
  644. */
  645. struct usbhost_roothubport_s
  646. {
  647. /* This structure must appear first so that this structure is cast-
  648. * compatible with usbhost_hubport_s.
  649. */
  650. struct usbhost_hubport_s hport; /* Common hub port definitions */
  651. struct usbhost_devaddr_s devgen; /* Address generation data */
  652. };
  653. /* struct usbhost_class_s provides access from the USB host driver to the
  654. * USB host class implementation.
  655. */
  656. struct usbhost_class_s
  657. {
  658. /* Class instances are associated with devices connected on one port on a
  659. * hub and are represented by this structure.
  660. */
  661. FAR struct usbhost_hubport_s *hport; /* The port used by this class instance */
  662. /* Provides the configuration descriptor to the class. The configuration
  663. * descriptor contains critical information needed by the class in order to
  664. * initialize properly (such as endpoint selections).
  665. */
  666. CODE int (*connect)(FAR struct usbhost_class_s *devclass,
  667. FAR const uint8_t *configdesc,
  668. int desclen);
  669. /* This method informs the class that the USB device has been disconnected. */
  670. CODE int (*disconnected)(FAR struct usbhost_class_s *devclass);
  671. };
  672. /* This structure describes one endpoint. It is used as an input to the
  673. * epalloc() method. Most of this information comes from the endpoint
  674. * descriptor.
  675. */
  676. struct usbhost_epdesc_s
  677. {
  678. FAR struct usbhost_hubport_s *hport; /* Hub port that supports the endpoint */
  679. uint8_t addr; /* Endpoint address */
  680. bool in; /* Direction: true->IN */
  681. uint8_t xfrtype; /* Transfer type. See USB_EP_ATTR_XFER_*
  682. * in usb.h */
  683. uint8_t interval; /* Polling interval */
  684. uint16_t mxpacketsize; /* Max packetsize */
  685. };
  686. /* struct usbhost_connection_s provides as interface between platform-specific
  687. * connection monitoring and the USB host driver connection and enumeration
  688. * logic.
  689. */
  690. struct usbhost_connection_s
  691. {
  692. /* Wait for a device to connect or disconnect. */
  693. CODE int (*wait)(FAR struct usbhost_connection_s *conn,
  694. FAR struct usbhost_hubport_s **hport);
  695. /* Enumerate the device connected on a hub port. As part of this
  696. * enumeration process, the driver will (1) get the device's configuration
  697. * descriptor, (2) extract the class ID info from the configuration
  698. * descriptor, (3) call usbhost_findclass() to find the class that supports
  699. * this device, (4) call the create() method on the struct usbhost_registry_s
  700. * interface to get a class instance, and finally (5) call the connect()
  701. * method of the struct usbhost_class_s interface. After that, the class is
  702. * in charge of the sequence of operations.
  703. */
  704. CODE int (*enumerate)(FAR struct usbhost_connection_s *conn,
  705. FAR struct usbhost_hubport_s *hport);
  706. };
  707. /* Callback type used with asynchronous transfers. The result of the
  708. * transfer is provided by the 'result' parameters. If >= 0, then 'result'
  709. * is the number of bytes transfers. If < 0 then the transfer failed and
  710. * result is a negated errno value that indicates the nature of the failure.
  711. */
  712. typedef CODE void (*usbhost_asynch_t)(FAR void *arg, ssize_t result);
  713. /* struct usbhost_driver_s provides access to the USB host driver from the
  714. * USB host class implementation.
  715. */
  716. struct usbhost_driver_s
  717. {
  718. /* Configure endpoint 0. This method is normally used internally by the
  719. * enumerate() method but is made available at the interface to support
  720. * an external implementation of the enumeration logic.
  721. */
  722. CODE int (*ep0configure)(FAR struct usbhost_driver_s *drvr,
  723. usbhost_ep_t ep0, uint8_t funcaddr,
  724. uint8_t speed, uint16_t maxpacketsize);
  725. /* Allocate and configure an endpoint. */
  726. CODE int (*epalloc)(FAR struct usbhost_driver_s *drvr,
  727. FAR const struct usbhost_epdesc_s *epdesc,
  728. FAR usbhost_ep_t *ep);
  729. CODE int (*epfree)(FAR struct usbhost_driver_s *drvr,
  730. FAR usbhost_ep_t ep);
  731. /* Some hardware supports special memory in which transfer descriptors can
  732. * be accessed more efficiently. The following methods provide a mechanism
  733. * to allocate and free the transfer descriptor memory. If the underlying
  734. * hardware does not support such "special" memory, these functions may
  735. * simply map to kmm_malloc and kmm_free.
  736. *
  737. * This interface was optimized under a particular assumption. It was assumed
  738. * that the driver maintains a pool of small, pre-allocated buffers for descriptor
  739. * traffic. NOTE that size is not an input, but an output: The size of the
  740. * pre-allocated buffer is returned.
  741. */
  742. CODE int (*alloc)(FAR struct usbhost_driver_s *drvr,
  743. FAR uint8_t **buffer, FAR size_t *maxlen);
  744. CODE int (*free)(FAR struct usbhost_driver_s *drvr, FAR uint8_t *buffer);
  745. /* Some hardware supports special memory in which larger IO buffers can
  746. * be accessed more efficiently. This method provides a mechanism to allocate
  747. * the request/descriptor memory. If the underlying hardware does not support
  748. * such "special" memory, this functions may simply map to kmm_malloc.
  749. *
  750. * This interface differs from DRVR_ALLOC in that the buffers are variable-sized.
  751. */
  752. CODE int (*ioalloc)(FAR struct usbhost_driver_s *drvr,
  753. FAR uint8_t **buffer, size_t buflen);
  754. CODE int (*iofree)(FAR struct usbhost_driver_s *drvr,
  755. FAR uint8_t *buffer);
  756. /* Process a IN or OUT request on the control endpoint. These methods
  757. * will enqueue the request and wait for it to complete. Only one transfer may
  758. * be queued; Neither these methods nor the transfer() method can be called again
  759. * until the control transfer methods returns.
  760. *
  761. * These are blocking methods; these methods will not return until the
  762. * control transfer has completed.
  763. */
  764. CODE int (*ctrlin)(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0,
  765. FAR const struct usb_ctrlreq_s *req,
  766. FAR uint8_t *buffer);
  767. CODE int (*ctrlout)(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep0,
  768. FAR const struct usb_ctrlreq_s *req,
  769. FAR const uint8_t *buffer);
  770. /* Process a request to handle a transfer descriptor. This method will
  771. * enqueue the transfer request and wait for it to complete. Only one
  772. * transfer may be queued; Neither this method nor the ctrlin nor ctrlout
  773. * methods can be called) again until this function returns.
  774. *
  775. * This is a blocking method; this method will not return until the
  776. * transfer has completed.
  777. */
  778. CODE ssize_t (*transfer)(FAR struct usbhost_driver_s *drvr,
  779. usbhost_ep_t ep, FAR uint8_t *buffer,
  780. size_t buflen);
  781. /* Process a request to handle a transfer asynchronously. This method
  782. * will enqueue the transfer request and return immediately. Only one
  783. * transfer may be queued on a given endpoint/
  784. *
  785. * When the transfer completes, the callback will be invoked with the
  786. * provided argument.
  787. *
  788. * This method is useful for receiving interrupt transfers which may come
  789. * infrequently.
  790. */
  791. #ifdef CONFIG_USBHOST_ASYNCH
  792. CODE int (*asynch)(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep,
  793. FAR uint8_t *buffer, size_t buflen,
  794. usbhost_asynch_t callback, FAR void *arg);
  795. #endif
  796. /* Cancel any pending syncrhonous or asynchronous transfer on an endpoint */
  797. CODE int (*cancel)(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep);
  798. #ifdef CONFIG_USBHOST_HUB
  799. /* New connections may be detected by an attached hub. This method is the
  800. * mechanism that is used by the hub class to introduce a new connection
  801. * and port description to the system.
  802. */
  803. CODE int (*connect)(FAR struct usbhost_driver_s *drvr,
  804. FAR struct usbhost_hubport_s *hport,
  805. bool connected);
  806. #endif
  807. /* Called by the class when an error occurs and driver has been disconnected.
  808. * The USB host driver should discard the handle to the class instance (it is
  809. * stale) and not attempt any further interaction with the class driver instance
  810. * (until a new instance is received from the create() method).
  811. */
  812. CODE void (*disconnect)(FAR struct usbhost_driver_s *drvr,
  813. FAR struct usbhost_hubport_s *hport);
  814. };
  815. /************************************************************************************
  816. * Public Data
  817. ************************************************************************************/
  818. #undef EXTERN
  819. #if defined(__cplusplus)
  820. #define EXTERN extern "C"
  821. extern "C"
  822. {
  823. #else
  824. #define EXTERN extern
  825. #endif
  826. /************************************************************************************
  827. * Public Function Prototypes
  828. ************************************************************************************/
  829. /************************************************************************************
  830. * Name: usbhost_registerclass
  831. *
  832. * Description:
  833. * Register a USB host class implementation. The caller provides an instance of
  834. * struct usbhost_registry_s that contains all of the information that will be
  835. * needed later to (1) associate the USB host class implementation with a connected
  836. * USB device, and (2) to obtain and bind a struct usbhost_class_s instance for
  837. * the device.
  838. *
  839. * Input Parameters:
  840. * devclass - An write-able instance of struct usbhost_registry_s that will be
  841. * maintained in a registry.
  842. *
  843. * Returned Value:
  844. * On success, this function will return zero (OK). Otherwise, a negated errno
  845. * value is returned.
  846. *
  847. ************************************************************************************/
  848. int usbhost_registerclass(FAR struct usbhost_registry_s *devclass);
  849. /************************************************************************************
  850. * Name: usbhost_findclass
  851. *
  852. * Description:
  853. * Find a USB host class implementation previously registered by
  854. * usbhost_registerclass(). On success, an instance of struct usbhost_registry_s
  855. * will be returned. That instance will contain all of the information that will
  856. * be needed to obtain and bind a struct usbhost_class_s instance for the device.
  857. *
  858. * Input Parameters:
  859. * id - Identifies the USB device class that has connect to the USB host.
  860. *
  861. * Returned Value:
  862. * On success this function will return a non-NULL instance of struct
  863. * usbhost_registry_s. NULL will be returned on failure. This function can only
  864. * fail if (1) id is NULL, or (2) no USB host class is registered that matches the
  865. * device class ID.
  866. *
  867. ************************************************************************************/
  868. const struct usbhost_registry_s *
  869. usbhost_findclass(FAR const struct usbhost_id_s *id);
  870. #ifdef CONFIG_USBHOST_HUB
  871. /************************************************************************************
  872. * Name: usbhost_hub_initialize
  873. *
  874. * Description:
  875. * Initialize the USB hub class. This function should be called
  876. * be platform-specific code in order to initialize and register support
  877. * for the USB host storage class.
  878. *
  879. * Input Parameters:
  880. * None
  881. *
  882. * Returned Value:
  883. * On success this function will return zero (OK); A negated errno value
  884. * will be returned on failure.
  885. *
  886. ************************************************************************************/
  887. int usbhost_hub_initialize(void);
  888. #endif
  889. #ifdef CONFIG_USBHOST_MSC
  890. /************************************************************************************
  891. * Name: usbhost_msc_initialize
  892. *
  893. * Description:
  894. * Initialize the USB host storage class. This function should be called
  895. * be platform-specific code in order to initialize and register support
  896. * for the USB host storage class.
  897. *
  898. * Input Parameters:
  899. * None
  900. *
  901. * Returned Value:
  902. * On success this function will return zero (OK); A negated errno value
  903. * will be returned on failure.
  904. *
  905. ************************************************************************************/
  906. int usbhost_msc_initialize(void);
  907. # ifdef CONFIG_USBHOST_MSC_NOTIFIER
  908. /************************************************************************************
  909. * Name: usbhost_msc_notifier_setup
  910. *
  911. * Description:
  912. * Set up to perform a callback to the worker function when a mass storage
  913. * device is attached.
  914. *
  915. * Input Parameters:
  916. * worker - The worker function to execute on the low priority work queue
  917. * when the event occurs.
  918. * event - Only WORK_USB_MSC_CONNECT and WORK_USB_MSC_DISCONNECT
  919. * sdchar - sdchar of the connected or disconnected block device
  920. * arg - A user-defined argument that will be available to the worker
  921. * function when it runs.
  922. *
  923. * Returned Value:
  924. * > 0 - The notification is in place. The returned value is a key that
  925. * may be used later in a call to
  926. * usbmsc_attach_notifier_teardown().
  927. * == 0 - Not used.
  928. * < 0 - An unexpected error occurred and no notification will occur. The
  929. * returned value is a negated errno value that indicates the
  930. * nature of the failure.
  931. *
  932. ************************************************************************************/
  933. int usbhost_msc_notifier_setup(worker_t worker, uint8_t event, char sdchar,
  934. FAR void *arg);
  935. /************************************************************************************
  936. * Name: usbhost_msc_notifier_teardown
  937. *
  938. * Description:
  939. * Eliminate an USB MSC notification previously setup by
  940. * usbhost_msc_notifier_setup().
  941. * This function should only be called if the notification should be
  942. * aborted prior to the notification. The notification will automatically
  943. * be torn down after the notification.
  944. *
  945. * Input Parameters:
  946. * key - The key value returned from a previous call to
  947. * usbhost_msc_notifier_setup().
  948. *
  949. * Returned Value:
  950. * Zero (OK) is returned on success; a negated errno value is returned on
  951. * any failure.
  952. *
  953. ************************************************************************************/
  954. int usbhost_msc_notifier_teardown(int key);
  955. /************************************************************************************
  956. * Name: usbhost_msc_notifier_signal
  957. *
  958. * Description:
  959. * An USB mass storage device has been connected or disconnected.
  960. * Signal all threads.
  961. *
  962. * Input Parameters:
  963. * event - Currently only USBHOST_MSC_DISCONNECT and USBHOST_MSC_CONNECT
  964. * sdchar - sdchar of the connected or disconnected block device
  965. *
  966. * Returned Value:
  967. * None.
  968. *
  969. ************************************************************************************/
  970. void usbhost_msc_notifier_signal(uint8_t event, char sdchar);
  971. # endif
  972. #endif
  973. #ifdef CONFIG_USBHOST_CDCACM
  974. /************************************************************************************
  975. * Name: usbhost_cdcacm_initialize
  976. *
  977. * Description:
  978. * Initialize the USB host CDC/ACM class. This function should be called
  979. * be platform-specific code in order to initialize and register support
  980. * for the USB host CDC/ACM class.
  981. *
  982. * Input Parameters:
  983. * None
  984. *
  985. * Returned Value:
  986. * On success this function will return zero (OK); A negated errno value
  987. * will be returned on failure.
  988. *
  989. ************************************************************************************/
  990. int usbhost_cdcacm_initialize(void);
  991. #endif
  992. #ifdef CONFIG_USBHOST_FT232R
  993. /************************************************************************************
  994. * Name: usbhost_ft232r_initialize
  995. *
  996. * Description:
  997. * Initialize the USB FT232R driver. This function should be called
  998. * be platform-specific code in order to initialize and register support
  999. * for the FT232R.
  1000. *
  1001. * Input Parameters:
  1002. * None
  1003. *
  1004. * Returned Value:
  1005. * On success this function will return zero (OK); A negated errno value
  1006. * will be returned on failure.
  1007. *
  1008. ************************************************************************************/
  1009. int usbhost_ft232r_initialize(void);
  1010. #endif
  1011. #ifdef CONFIG_USBHOST_HIDKBD
  1012. /************************************************************************************
  1013. * Name: usbhost_kbdinit
  1014. *
  1015. * Description:
  1016. * Initialize the USB storage HID keyboard class driver. This function
  1017. * should be called be platform-specific code in order to initialize and
  1018. * register support for the USB host HID keyboard class device.
  1019. *
  1020. * Input Parameters:
  1021. * None
  1022. *
  1023. * Returned Value:
  1024. * On success this function will return zero (OK); A negated errno value
  1025. * will be returned on failure.
  1026. *
  1027. ************************************************************************************/
  1028. int usbhost_kbdinit(void);
  1029. #endif
  1030. #ifdef CONFIG_USBHOST_HIDMOUSE
  1031. /************************************************************************************
  1032. * Name: usbhost_mouse_init
  1033. *
  1034. * Description:
  1035. * Initialize the USB storage HID mouse class driver. This function
  1036. * should be called be platform-specific code in order to initialize and
  1037. * register support for the USB host HID mouse class device.
  1038. *
  1039. * Input Parameters:
  1040. * None
  1041. *
  1042. * Returned Value:
  1043. * On success this function will return zero (OK); A negated errno value
  1044. * will be returned on failure.
  1045. *
  1046. ************************************************************************************/
  1047. int usbhost_mouse_init(void);
  1048. #endif
  1049. #ifdef CONFIG_USBHOST_XBOXCONTROLLER
  1050. /************************************************************************************
  1051. * Name: usbhost_xboxcontroller_init
  1052. *
  1053. * Description:
  1054. * Initialize the USB XBox controller driver. This function
  1055. * should be called be platform-specific code in order to initialize and
  1056. * register support for the USB XBox controller.
  1057. *
  1058. * Input Parameters:
  1059. * None
  1060. *
  1061. * Returned Value:
  1062. * On success this function will return zero (OK); A negated errno value
  1063. * will be returned on failure.
  1064. *
  1065. ************************************************************************************/
  1066. int usbhost_xboxcontroller_init(void);
  1067. #endif
  1068. /************************************************************************************
  1069. * Name: usbhost_wlaninit
  1070. *
  1071. * Description:
  1072. * Initialize the USB WLAN class driver. This function should be called
  1073. * be platform-specific code in order to initialize and register support
  1074. * for the USB host class device.
  1075. *
  1076. * Input Parameters:
  1077. * None
  1078. *
  1079. * Returned Value:
  1080. * On success this function will return zero (OK); A negated errno value
  1081. * will be returned on failure.
  1082. *
  1083. ************************************************************************************/
  1084. int usbhost_wlaninit(void);
  1085. /************************************************************************************
  1086. * Name: usbhost_enumerate
  1087. *
  1088. * Description:
  1089. * This is a share-able implementation of most of the logic required by the
  1090. * driver enumerate() method. This logic within this method should be common
  1091. * to all USB host drivers.
  1092. *
  1093. * Enumerate the connected device. As part of this enumeration process,
  1094. * the driver will (1) get the device's configuration descriptor, (2)
  1095. * extract the class ID info from the configuration descriptor, (3) call
  1096. * usbhost_findclass() to find the class that supports this device, (4)
  1097. * call the create() method on the struct usbhost_registry_s interface
  1098. * to get a class instance, and finally (5) call the configdesc() method
  1099. * of the struct usbhost_class_s interface. After that, the class is in
  1100. * charge of the sequence of operations.
  1101. *
  1102. * Input Parameters:
  1103. * hub - The hub that manages the new class.
  1104. * devclass - If the class driver for the device is successful located
  1105. * and bound to the hub, the allocated class instance is returned into
  1106. * this caller-provided memory location.
  1107. *
  1108. * Returned Value:
  1109. * On success, zero (OK) is returned. On a failure, a negated errno value is
  1110. * returned indicating the nature of the failure
  1111. *
  1112. * Assumptions:
  1113. * - Only a single class bound to a single device is supported.
  1114. * - Called from a single thread so no mutual exclusion is required.
  1115. * - Never called from an interrupt handler.
  1116. *
  1117. ************************************************************************************/
  1118. int usbhost_enumerate(FAR struct usbhost_hubport_s *hub,
  1119. FAR struct usbhost_class_s **devclass);
  1120. #undef EXTERN
  1121. #if defined(__cplusplus)
  1122. }
  1123. #endif
  1124. #endif /* __INCLUDE_NUTTX_USB_USBHOST_H */