vhub.h 17 KB

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