vhub.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. #ifndef __ASPEED_VHUB_H
  3. #define __ASPEED_VHUB_H
  4. /*****************************
  5. * *
  6. * VHUB register definitions *
  7. * *
  8. *****************************/
  9. #define AST_VHUB_CTRL 0x00 /* Root Function Control & Status Register */
  10. #define AST_VHUB_CONF 0x04 /* Root Configuration Setting Register */
  11. #define AST_VHUB_IER 0x08 /* Interrupt Ctrl Register */
  12. #define AST_VHUB_ISR 0x0C /* Interrupt Status Register */
  13. #define AST_VHUB_EP_ACK_IER 0x10 /* Programmable Endpoint Pool ACK Interrupt Enable Register */
  14. #define AST_VHUB_EP_NACK_IER 0x14 /* Programmable Endpoint Pool NACK Interrupt Enable Register */
  15. #define AST_VHUB_EP_ACK_ISR 0x18 /* Programmable Endpoint Pool ACK Interrupt Status Register */
  16. #define AST_VHUB_EP_NACK_ISR 0x1C /* Programmable Endpoint Pool NACK Interrupt Status Register */
  17. #define AST_VHUB_SW_RESET 0x20 /* Device Controller Soft Reset Enable Register */
  18. #define AST_VHUB_USBSTS 0x24 /* USB Status Register */
  19. #define AST_VHUB_EP_TOGGLE 0x28 /* Programmable Endpoint Pool Data Toggle Value Set */
  20. #define AST_VHUB_ISO_FAIL_ACC 0x2C /* Isochronous Transaction Fail Accumulator */
  21. #define AST_VHUB_EP0_CTRL 0x30 /* Endpoint 0 Contrl/Status Register */
  22. #define AST_VHUB_EP0_DATA 0x34 /* Base Address of Endpoint 0 In/OUT Data Buffer Register */
  23. #define AST_VHUB_EP1_CTRL 0x38 /* Endpoint 1 Contrl/Status Register */
  24. #define AST_VHUB_EP1_STS_CHG 0x3C /* Endpoint 1 Status Change Bitmap Data */
  25. #define AST_VHUB_SETUP0 0x80 /* Root Device Setup Data Buffer0 */
  26. #define AST_VHUB_SETUP1 0x84 /* Root Device Setup Data Buffer1 */
  27. /* Main control reg */
  28. #define VHUB_CTRL_PHY_CLK (1 << 31)
  29. #define VHUB_CTRL_PHY_LOOP_TEST (1 << 25)
  30. #define VHUB_CTRL_DN_PWN (1 << 24)
  31. #define VHUB_CTRL_DP_PWN (1 << 23)
  32. #define VHUB_CTRL_LONG_DESC (1 << 18)
  33. #define VHUB_CTRL_ISO_RSP_CTRL (1 << 17)
  34. #define VHUB_CTRL_SPLIT_IN (1 << 16)
  35. #define VHUB_CTRL_LOOP_T_RESULT (1 << 15)
  36. #define VHUB_CTRL_LOOP_T_STS (1 << 14)
  37. #define VHUB_CTRL_PHY_BIST_RESULT (1 << 13)
  38. #define VHUB_CTRL_PHY_BIST_CTRL (1 << 12)
  39. #define VHUB_CTRL_PHY_RESET_DIS (1 << 11)
  40. #define VHUB_CTRL_SET_TEST_MODE(x) ((x) << 8)
  41. #define VHUB_CTRL_MANUAL_REMOTE_WAKEUP (1 << 4)
  42. #define VHUB_CTRL_AUTO_REMOTE_WAKEUP (1 << 3)
  43. #define VHUB_CTRL_CLK_STOP_SUSPEND (1 << 2)
  44. #define VHUB_CTRL_FULL_SPEED_ONLY (1 << 1)
  45. #define VHUB_CTRL_UPSTREAM_CONNECT (1 << 0)
  46. /* IER & ISR */
  47. #define VHUB_IRQ_USB_CMD_DEADLOCK (1 << 18)
  48. #define VHUB_IRQ_EP_POOL_NAK (1 << 17)
  49. #define VHUB_IRQ_EP_POOL_ACK_STALL (1 << 16)
  50. #define VHUB_IRQ_DEVICE5 (1 << 13)
  51. #define VHUB_IRQ_DEVICE4 (1 << 12)
  52. #define VHUB_IRQ_DEVICE3 (1 << 11)
  53. #define VHUB_IRQ_DEVICE2 (1 << 10)
  54. #define VHUB_IRQ_DEVICE1 (1 << 9)
  55. #define VHUB_IRQ_BUS_RESUME (1 << 8)
  56. #define VHUB_IRQ_BUS_SUSPEND (1 << 7)
  57. #define VHUB_IRQ_BUS_RESET (1 << 6)
  58. #define VHUB_IRQ_HUB_EP1_IN_DATA_ACK (1 << 5)
  59. #define VHUB_IRQ_HUB_EP0_IN_DATA_NAK (1 << 4)
  60. #define VHUB_IRQ_HUB_EP0_IN_ACK_STALL (1 << 3)
  61. #define VHUB_IRQ_HUB_EP0_OUT_NAK (1 << 2)
  62. #define VHUB_IRQ_HUB_EP0_OUT_ACK_STALL (1 << 1)
  63. #define VHUB_IRQ_HUB_EP0_SETUP (1 << 0)
  64. #define VHUB_IRQ_ACK_ALL 0x1ff
  65. /* SW reset reg */
  66. #define VHUB_SW_RESET_EP_POOL (1 << 9)
  67. #define VHUB_SW_RESET_DMA_CONTROLLER (1 << 8)
  68. #define VHUB_SW_RESET_DEVICE5 (1 << 5)
  69. #define VHUB_SW_RESET_DEVICE4 (1 << 4)
  70. #define VHUB_SW_RESET_DEVICE3 (1 << 3)
  71. #define VHUB_SW_RESET_DEVICE2 (1 << 2)
  72. #define VHUB_SW_RESET_DEVICE1 (1 << 1)
  73. #define VHUB_SW_RESET_ROOT_HUB (1 << 0)
  74. #define VHUB_SW_RESET_ALL (VHUB_SW_RESET_EP_POOL | \
  75. VHUB_SW_RESET_DMA_CONTROLLER | \
  76. VHUB_SW_RESET_DEVICE5 | \
  77. VHUB_SW_RESET_DEVICE4 | \
  78. VHUB_SW_RESET_DEVICE3 | \
  79. VHUB_SW_RESET_DEVICE2 | \
  80. VHUB_SW_RESET_DEVICE1 | \
  81. VHUB_SW_RESET_ROOT_HUB)
  82. /* EP ACK/NACK IRQ masks */
  83. #define VHUB_EP_IRQ(n) (1 << (n))
  84. #define VHUB_EP_IRQ_ALL 0x7fff /* 15 EPs */
  85. /* USB status reg */
  86. #define VHUB_USBSTS_HISPEED (1 << 27)
  87. /* EP toggle */
  88. #define VHUB_EP_TOGGLE_VALUE (1 << 8)
  89. #define VHUB_EP_TOGGLE_SET_EPNUM(x) ((x) & 0x1f)
  90. /* HUB EP0 control */
  91. #define VHUB_EP0_CTRL_STALL (1 << 0)
  92. #define VHUB_EP0_TX_BUFF_RDY (1 << 1)
  93. #define VHUB_EP0_RX_BUFF_RDY (1 << 2)
  94. #define VHUB_EP0_RX_LEN(x) (((x) >> 16) & 0x7f)
  95. #define VHUB_EP0_SET_TX_LEN(x) (((x) & 0x7f) << 8)
  96. /* HUB EP1 control */
  97. #define VHUB_EP1_CTRL_RESET_TOGGLE (1 << 2)
  98. #define VHUB_EP1_CTRL_STALL (1 << 1)
  99. #define VHUB_EP1_CTRL_ENABLE (1 << 0)
  100. /***********************************
  101. * *
  102. * per-device register definitions *
  103. * *
  104. ***********************************/
  105. #define AST_VHUB_DEV_EN_CTRL 0x00
  106. #define AST_VHUB_DEV_ISR 0x04
  107. #define AST_VHUB_DEV_EP0_CTRL 0x08
  108. #define AST_VHUB_DEV_EP0_DATA 0x0c
  109. /* Device enable control */
  110. #define VHUB_DEV_EN_SET_ADDR(x) ((x) << 8)
  111. #define VHUB_DEV_EN_ADDR_MASK ((0xff) << 8)
  112. #define VHUB_DEV_EN_EP0_NAK_IRQEN (1 << 6)
  113. #define VHUB_DEV_EN_EP0_IN_ACK_IRQEN (1 << 5)
  114. #define VHUB_DEV_EN_EP0_OUT_NAK_IRQEN (1 << 4)
  115. #define VHUB_DEV_EN_EP0_OUT_ACK_IRQEN (1 << 3)
  116. #define VHUB_DEV_EN_EP0_SETUP_IRQEN (1 << 2)
  117. #define VHUB_DEV_EN_SPEED_SEL_HIGH (1 << 1)
  118. #define VHUB_DEV_EN_ENABLE_PORT (1 << 0)
  119. /* Interrupt status */
  120. #define VHUV_DEV_IRQ_EP0_IN_DATA_NACK (1 << 4)
  121. #define VHUV_DEV_IRQ_EP0_IN_ACK_STALL (1 << 3)
  122. #define VHUV_DEV_IRQ_EP0_OUT_DATA_NACK (1 << 2)
  123. #define VHUV_DEV_IRQ_EP0_OUT_ACK_STALL (1 << 1)
  124. #define VHUV_DEV_IRQ_EP0_SETUP (1 << 0)
  125. /* Control bits.
  126. *
  127. * Note: The driver relies on the bulk of those bits
  128. * matching corresponding vHub EP0 control bits
  129. */
  130. #define VHUB_DEV_EP0_CTRL_STALL VHUB_EP0_CTRL_STALL
  131. #define VHUB_DEV_EP0_TX_BUFF_RDY VHUB_EP0_TX_BUFF_RDY
  132. #define VHUB_DEV_EP0_RX_BUFF_RDY VHUB_EP0_RX_BUFF_RDY
  133. #define VHUB_DEV_EP0_RX_LEN(x) VHUB_EP0_RX_LEN(x)
  134. #define VHUB_DEV_EP0_SET_TX_LEN(x) VHUB_EP0_SET_TX_LEN(x)
  135. /*************************************
  136. * *
  137. * per-endpoint register definitions *
  138. * *
  139. *************************************/
  140. #define AST_VHUB_EP_CONFIG 0x00
  141. #define AST_VHUB_EP_DMA_CTLSTAT 0x04
  142. #define AST_VHUB_EP_DESC_BASE 0x08
  143. #define AST_VHUB_EP_DESC_STATUS 0x0C
  144. /* EP config reg */
  145. #define VHUB_EP_CFG_SET_MAX_PKT(x) (((x) & 0x3ff) << 16)
  146. #define VHUB_EP_CFG_AUTO_DATA_DISABLE (1 << 13)
  147. #define VHUB_EP_CFG_STALL_CTRL (1 << 12)
  148. #define VHUB_EP_CFG_SET_EP_NUM(x) (((x) & 0xf) << 8)
  149. #define VHUB_EP_CFG_SET_TYPE(x) ((x) << 5)
  150. #define EP_TYPE_OFF 0
  151. #define EP_TYPE_BULK 1
  152. #define EP_TYPE_INT 2
  153. #define EP_TYPE_ISO 3
  154. #define VHUB_EP_CFG_DIR_OUT (1 << 4)
  155. #define VHUB_EP_CFG_SET_DEV(x) ((x) << 1)
  156. #define VHUB_EP_CFG_ENABLE (1 << 0)
  157. /* EP DMA control */
  158. #define VHUB_EP_DMA_PROC_STATUS(x) (((x) >> 4) & 0xf)
  159. #define EP_DMA_PROC_RX_IDLE 0
  160. #define EP_DMA_PROC_TX_IDLE 8
  161. #define VHUB_EP_DMA_IN_LONG_MODE (1 << 3)
  162. #define VHUB_EP_DMA_OUT_CONTIG_MODE (1 << 3)
  163. #define VHUB_EP_DMA_CTRL_RESET (1 << 2)
  164. #define VHUB_EP_DMA_SINGLE_STAGE (1 << 1)
  165. #define VHUB_EP_DMA_DESC_MODE (1 << 0)
  166. /* EP DMA status */
  167. #define VHUB_EP_DMA_SET_TX_SIZE(x) ((x) << 16)
  168. #define VHUB_EP_DMA_TX_SIZE(x) (((x) >> 16) & 0x7ff)
  169. #define VHUB_EP_DMA_RPTR(x) (((x) >> 8) & 0xff)
  170. #define VHUB_EP_DMA_SET_RPTR(x) (((x) & 0xff) << 8)
  171. #define VHUB_EP_DMA_SET_CPU_WPTR(x) (x)
  172. #define VHUB_EP_DMA_SINGLE_KICK (1 << 0) /* WPTR = 1 for single mode */
  173. /*******************************
  174. * *
  175. * DMA descriptors definitions *
  176. * *
  177. *******************************/
  178. /* Desc W1 IN */
  179. #define VHUB_DSC1_IN_INTERRUPT (1 << 31)
  180. #define VHUB_DSC1_IN_SPID_DATA0 (0 << 14)
  181. #define VHUB_DSC1_IN_SPID_DATA2 (1 << 14)
  182. #define VHUB_DSC1_IN_SPID_DATA1 (2 << 14)
  183. #define VHUB_DSC1_IN_SPID_MDATA (3 << 14)
  184. #define VHUB_DSC1_IN_SET_LEN(x) ((x) & 0xfff)
  185. #define VHUB_DSC1_IN_LEN(x) ((x) & 0xfff)
  186. /****************************************
  187. * *
  188. * Data structures and misc definitions *
  189. * *
  190. ****************************************/
  191. #define AST_VHUB_NUM_GEN_EPs 15 /* Generic non-0 EPs */
  192. #define AST_VHUB_NUM_PORTS 5 /* vHub ports */
  193. #define AST_VHUB_EP0_MAX_PACKET 64 /* EP0's max packet size */
  194. #define AST_VHUB_EPn_MAX_PACKET 1024 /* Generic EPs max packet size */
  195. #define AST_VHUB_DESCS_COUNT 256 /* Use 256 descriptor mode (valid
  196. * values are 256 and 32)
  197. */
  198. struct ast_vhub;
  199. struct ast_vhub_dev;
  200. /*
  201. * DMA descriptor (generic EPs only, currently only used
  202. * for IN endpoints
  203. */
  204. struct ast_vhub_desc {
  205. __le32 w0;
  206. __le32 w1;
  207. };
  208. /* A transfer request, either core-originated or internal */
  209. struct ast_vhub_req {
  210. struct usb_request req;
  211. struct list_head queue;
  212. /* Actual count written to descriptors (desc mode only) */
  213. unsigned int act_count;
  214. /*
  215. * Desc number of the final packet or -1. For non-desc
  216. * mode (or ep0), any >= 0 value means "last packet"
  217. */
  218. int last_desc;
  219. /* Request active (pending DMAs) */
  220. bool active : 1;
  221. /* Internal request (don't call back core) */
  222. bool internal : 1;
  223. };
  224. #define to_ast_req(__ureq) container_of(__ureq, struct ast_vhub_req, req)
  225. /* Current state of an EP0 */
  226. enum ep0_state {
  227. ep0_state_token,
  228. ep0_state_data,
  229. ep0_state_status,
  230. };
  231. /*
  232. * An endpoint, either generic, ep0, actual gadget EP
  233. * or internal use vhub EP0. vhub EP1 doesn't have an
  234. * associated structure as it's mostly HW managed.
  235. */
  236. struct ast_vhub_ep {
  237. struct usb_ep ep;
  238. /* Request queue */
  239. struct list_head queue;
  240. /* EP index in the device, 0 means this is an EP0 */
  241. unsigned int d_idx;
  242. /* Dev pointer or NULL for vHub EP0 */
  243. struct ast_vhub_dev *dev;
  244. /* vHub itself */
  245. struct ast_vhub *vhub;
  246. /*
  247. * DMA buffer for EP0, fallback DMA buffer for misaligned
  248. * OUT transfers for generic EPs
  249. */
  250. void *buf;
  251. dma_addr_t buf_dma;
  252. /* The rest depends on the EP type */
  253. union {
  254. /* EP0 (either device or vhub) */
  255. struct {
  256. /*
  257. * EP0 registers are "similar" for
  258. * vHub and devices but located in
  259. * different places.
  260. */
  261. void __iomem *ctlstat;
  262. void __iomem *setup;
  263. /* Current state & direction */
  264. enum ep0_state state;
  265. bool dir_in;
  266. /* Internal use request */
  267. struct ast_vhub_req req;
  268. } ep0;
  269. /* Generic endpoint (aka EPn) */
  270. struct {
  271. /* Registers */
  272. void __iomem *regs;
  273. /* Index in global pool (0..14) */
  274. unsigned int g_idx;
  275. /* DMA Descriptors */
  276. struct ast_vhub_desc *descs;
  277. dma_addr_t descs_dma;
  278. unsigned int d_next;
  279. unsigned int d_last;
  280. unsigned int dma_conf;
  281. /* Max chunk size for IN EPs */
  282. unsigned int chunk_max;
  283. /* State flags */
  284. bool is_in : 1;
  285. bool is_iso : 1;
  286. bool stalled : 1;
  287. bool wedged : 1;
  288. bool enabled : 1;
  289. bool desc_mode : 1;
  290. } epn;
  291. };
  292. };
  293. #define to_ast_ep(__uep) container_of(__uep, struct ast_vhub_ep, ep)
  294. /* A device attached to a vHub port */
  295. struct ast_vhub_dev {
  296. struct ast_vhub *vhub;
  297. void __iomem *regs;
  298. /* Device index (0...4) and name string */
  299. unsigned int index;
  300. const char *name;
  301. /* sysfs enclosure for the gadget gunk */
  302. struct device *port_dev;
  303. /* Link to gadget core */
  304. struct usb_gadget gadget;
  305. struct usb_gadget_driver *driver;
  306. bool registered : 1;
  307. bool wakeup_en : 1;
  308. bool suspended : 1;
  309. bool enabled : 1;
  310. /* Endpoint structures */
  311. struct ast_vhub_ep ep0;
  312. struct ast_vhub_ep *epns[AST_VHUB_NUM_GEN_EPs];
  313. };
  314. #define to_ast_dev(__g) container_of(__g, struct ast_vhub_dev, gadget)
  315. /* Per vhub port stateinfo structure */
  316. struct ast_vhub_port {
  317. /* Port status & status change registers */
  318. u16 status;
  319. u16 change;
  320. /* Associated device slot */
  321. struct ast_vhub_dev dev;
  322. };
  323. /* Global vhub structure */
  324. struct ast_vhub {
  325. struct platform_device *pdev;
  326. void __iomem *regs;
  327. int irq;
  328. spinlock_t lock;
  329. struct work_struct wake_work;
  330. struct clk *clk;
  331. /* EP0 DMA buffers allocated in one chunk */
  332. void *ep0_bufs;
  333. dma_addr_t ep0_bufs_dma;
  334. /* EP0 of the vhub itself */
  335. struct ast_vhub_ep ep0;
  336. /* State of vhub ep1 */
  337. bool ep1_stalled : 1;
  338. /* Per-port info */
  339. struct ast_vhub_port ports[AST_VHUB_NUM_PORTS];
  340. /* Generic EP data structures */
  341. struct ast_vhub_ep epns[AST_VHUB_NUM_GEN_EPs];
  342. /* Upstream bus is suspended ? */
  343. bool suspended : 1;
  344. /* Hub itself can signal remote wakeup */
  345. bool wakeup_en : 1;
  346. /* Force full speed only */
  347. bool force_usb1 : 1;
  348. /* Upstream bus speed captured at bus reset */
  349. unsigned int speed;
  350. };
  351. /* Standard request handlers result codes */
  352. enum std_req_rc {
  353. std_req_stall = -1, /* Stall requested */
  354. std_req_complete = 0, /* Request completed with no data */
  355. std_req_data = 1, /* Request completed with data */
  356. std_req_driver = 2, /* Pass to driver pls */
  357. };
  358. #ifdef CONFIG_USB_GADGET_VERBOSE
  359. #define UDCVDBG(u, fmt...) dev_dbg(&(u)->pdev->dev, fmt)
  360. #define EPVDBG(ep, fmt, ...) do { \
  361. dev_dbg(&(ep)->vhub->pdev->dev, \
  362. "%s:EP%d " fmt, \
  363. (ep)->dev ? (ep)->dev->name : "hub", \
  364. (ep)->d_idx, ##__VA_ARGS__); \
  365. } while(0)
  366. #define DVDBG(d, fmt, ...) do { \
  367. dev_dbg(&(d)->vhub->pdev->dev, \
  368. "%s " fmt, (d)->name, \
  369. ##__VA_ARGS__); \
  370. } while(0)
  371. #else
  372. #define UDCVDBG(u, fmt...) do { } while(0)
  373. #define EPVDBG(ep, fmt, ...) do { } while(0)
  374. #define DVDBG(d, fmt, ...) do { } while(0)
  375. #endif
  376. #ifdef CONFIG_USB_GADGET_DEBUG
  377. #define UDCDBG(u, fmt...) dev_dbg(&(u)->pdev->dev, fmt)
  378. #define EPDBG(ep, fmt, ...) do { \
  379. dev_dbg(&(ep)->vhub->pdev->dev, \
  380. "%s:EP%d " fmt, \
  381. (ep)->dev ? (ep)->dev->name : "hub", \
  382. (ep)->d_idx, ##__VA_ARGS__); \
  383. } while(0)
  384. #define DDBG(d, fmt, ...) do { \
  385. dev_dbg(&(d)->vhub->pdev->dev, \
  386. "%s " fmt, (d)->name, \
  387. ##__VA_ARGS__); \
  388. } while(0)
  389. #else
  390. #define UDCDBG(u, fmt...) do { } while(0)
  391. #define EPDBG(ep, fmt, ...) do { } while(0)
  392. #define DDBG(d, fmt, ...) do { } while(0)
  393. #endif
  394. static inline void vhub_dma_workaround(void *addr)
  395. {
  396. /*
  397. * This works around a confirmed HW issue with the Aspeed chip.
  398. *
  399. * The core uses a different bus to memory than the AHB going to
  400. * the USB device controller. Due to the latter having a higher
  401. * priority than the core for arbitration on that bus, it's
  402. * possible for an MMIO to the device, followed by a DMA by the
  403. * device from memory to all be performed and services before
  404. * a previous store to memory gets completed.
  405. *
  406. * This the following scenario can happen:
  407. *
  408. * - Driver writes to a DMA descriptor (Mbus)
  409. * - Driver writes to the MMIO register to start the DMA (AHB)
  410. * - The gadget sees the second write and sends a read of the
  411. * descriptor to the memory controller (Mbus)
  412. * - The gadget hits memory before the descriptor write
  413. * causing it to read an obsolete value.
  414. *
  415. * Thankfully the problem is limited to the USB gadget device, other
  416. * masters in the SoC all have a lower priority than the core, thus
  417. * ensuring that the store by the core arrives first.
  418. *
  419. * The workaround consists of using a dummy read of the memory before
  420. * doing the MMIO writes. This will ensure that the previous writes
  421. * have been "pushed out".
  422. */
  423. mb();
  424. (void)__raw_readl((void __iomem *)addr);
  425. }
  426. /* core.c */
  427. void ast_vhub_done(struct ast_vhub_ep *ep, struct ast_vhub_req *req,
  428. int status);
  429. void ast_vhub_nuke(struct ast_vhub_ep *ep, int status);
  430. struct usb_request *ast_vhub_alloc_request(struct usb_ep *u_ep,
  431. gfp_t gfp_flags);
  432. void ast_vhub_free_request(struct usb_ep *u_ep, struct usb_request *u_req);
  433. void ast_vhub_init_hw(struct ast_vhub *vhub);
  434. /* ep0.c */
  435. void ast_vhub_ep0_handle_ack(struct ast_vhub_ep *ep, bool in_ack);
  436. void ast_vhub_ep0_handle_setup(struct ast_vhub_ep *ep);
  437. void ast_vhub_init_ep0(struct ast_vhub *vhub, struct ast_vhub_ep *ep,
  438. struct ast_vhub_dev *dev);
  439. int ast_vhub_reply(struct ast_vhub_ep *ep, char *ptr, int len);
  440. int __ast_vhub_simple_reply(struct ast_vhub_ep *ep, int len, ...);
  441. #define ast_vhub_simple_reply(udc, ...) \
  442. __ast_vhub_simple_reply((udc), \
  443. sizeof((u8[]) { __VA_ARGS__ })/sizeof(u8), \
  444. __VA_ARGS__)
  445. /* hub.c */
  446. void ast_vhub_init_hub(struct ast_vhub *vhub);
  447. enum std_req_rc ast_vhub_std_hub_request(struct ast_vhub_ep *ep,
  448. struct usb_ctrlrequest *crq);
  449. enum std_req_rc ast_vhub_class_hub_request(struct ast_vhub_ep *ep,
  450. struct usb_ctrlrequest *crq);
  451. void ast_vhub_device_connect(struct ast_vhub *vhub, unsigned int port,
  452. bool on);
  453. void ast_vhub_hub_suspend(struct ast_vhub *vhub);
  454. void ast_vhub_hub_resume(struct ast_vhub *vhub);
  455. void ast_vhub_hub_reset(struct ast_vhub *vhub);
  456. void ast_vhub_hub_wake_all(struct ast_vhub *vhub);
  457. /* dev.c */
  458. int ast_vhub_init_dev(struct ast_vhub *vhub, unsigned int idx);
  459. void ast_vhub_del_dev(struct ast_vhub_dev *d);
  460. void ast_vhub_dev_irq(struct ast_vhub_dev *d);
  461. int ast_vhub_std_dev_request(struct ast_vhub_ep *ep,
  462. struct usb_ctrlrequest *crq);
  463. /* epn.c */
  464. void ast_vhub_epn_ack_irq(struct ast_vhub_ep *ep);
  465. void ast_vhub_update_epn_stall(struct ast_vhub_ep *ep);
  466. struct ast_vhub_ep *ast_vhub_alloc_epn(struct ast_vhub_dev *d, u8 addr);
  467. void ast_vhub_dev_suspend(struct ast_vhub_dev *d);
  468. void ast_vhub_dev_resume(struct ast_vhub_dev *d);
  469. void ast_vhub_dev_reset(struct ast_vhub_dev *d);
  470. #endif /* __ASPEED_VHUB_H */