ci_udc.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * Copyright 2011, Marvell Semiconductor Inc.
  3. *
  4. * Licensed under the GPL-2 or later.
  5. */
  6. #ifndef __GADGET__CI_UDC_H__
  7. #define __GADGET__CI_UDC_H__
  8. #define NUM_ENDPOINTS 6
  9. #ifdef CONFIG_CI_UDC_HAS_HOSTPC
  10. struct ci_udc {
  11. u32 usbcmd; /* 0x130 */
  12. u32 usbsts; /* 0x134 */
  13. u32 pad1[3];
  14. u32 devaddr; /* 0x144 */
  15. u32 epinitaddr; /* 0x148 */
  16. u32 pad2[10];
  17. u32 portsc; /* 0x174 */
  18. u32 pad178[(0x1b4 - (0x174 + 4)) / 4];
  19. u32 hostpc1_devlc; /* 0x1b4 */
  20. u32 pad1b8[(0x1f8 - (0x1b4 + 4)) / 4];
  21. u32 usbmode; /* 0x1f8 */
  22. u32 pad1fc[(0x208 - (0x1f8 + 4)) / 4];
  23. u32 epsetupstat; /* 0x208 */
  24. u32 epprime; /* 0x20c */
  25. u32 epflush; /* 0x210 */
  26. u32 epstat; /* 0x214 */
  27. u32 epcomp; /* 0x218 */
  28. u32 epctrl[16]; /* 0x21c */
  29. };
  30. #else
  31. struct ci_udc {
  32. u32 usbcmd; /* 0x140 */
  33. u32 usbsts; /* 0x144 */
  34. u32 pad1[3];
  35. u32 devaddr; /* 0x154 */
  36. u32 epinitaddr; /* 0x158 */
  37. u32 pad2[10];
  38. u32 portsc; /* 0x184 */
  39. u32 pad3[8];
  40. u32 usbmode; /* 0x1a8 */
  41. u32 epstat; /* 0x1ac */
  42. u32 epprime; /* 0x1b0 */
  43. u32 epflush; /* 0x1b4 */
  44. u32 pad4;
  45. u32 epcomp; /* 0x1bc */
  46. u32 epctrl[16]; /* 0x1c0 */
  47. };
  48. #define PTS_ENABLE 2
  49. #define PTS(x) (((x) & 0x3) << 30)
  50. #define PFSC (1 << 24)
  51. #endif
  52. #define MICRO_8FRAME 0x8
  53. #define USBCMD_ITC(x) ((((x) > 0xff) ? 0xff : x) << 16)
  54. #define USBCMD_FS2 (1 << 15)
  55. #define USBCMD_RST (1 << 1)
  56. #define USBCMD_RUN (1)
  57. #define STS_SLI (1 << 8)
  58. #define STS_URI (1 << 6)
  59. #define STS_PCI (1 << 2)
  60. #define STS_UEI (1 << 1)
  61. #define STS_UI (1 << 0)
  62. #define USBMODE_DEVICE 2
  63. #define EPT_TX(x) (1 << (((x) & 0xffff) + 16))
  64. #define EPT_RX(x) (1 << ((x) & 0xffff))
  65. #define CTRL_TXE (1 << 23)
  66. #define CTRL_TXR (1 << 22)
  67. #define CTRL_RXE (1 << 7)
  68. #define CTRL_RXR (1 << 6)
  69. #define CTRL_TXT_BULK (2 << 18)
  70. #define CTRL_RXT_BULK (2 << 2)
  71. struct ci_req {
  72. struct usb_request req;
  73. struct list_head queue;
  74. /* Bounce buffer allocated if needed to align the transfer */
  75. uint8_t *b_buf;
  76. uint32_t b_len;
  77. /* Buffer for the current transfer. Either req.buf/len or b_buf/len */
  78. uint8_t *hw_buf;
  79. uint32_t hw_len;
  80. uint32_t dtd_count;
  81. };
  82. struct ci_ep {
  83. struct usb_ep ep;
  84. struct list_head queue;
  85. bool req_primed;
  86. const struct usb_endpoint_descriptor *desc;
  87. };
  88. struct ci_drv {
  89. struct usb_gadget gadget;
  90. struct ci_req *ep0_req;
  91. bool ep0_data_phase;
  92. struct usb_gadget_driver *driver;
  93. struct ehci_ctrl *ctrl;
  94. struct ept_queue_head *epts;
  95. uint8_t *items_mem;
  96. struct ci_ep ep[NUM_ENDPOINTS];
  97. };
  98. struct ept_queue_head {
  99. unsigned config;
  100. unsigned current; /* read-only */
  101. unsigned next;
  102. unsigned info;
  103. unsigned page0;
  104. unsigned page1;
  105. unsigned page2;
  106. unsigned page3;
  107. unsigned page4;
  108. unsigned reserved_0;
  109. unsigned char setup_data[8];
  110. unsigned reserved_1;
  111. unsigned reserved_2;
  112. unsigned reserved_3;
  113. unsigned reserved_4;
  114. };
  115. #define CONFIG_MAX_PKT(n) ((n) << 16)
  116. #define CONFIG_ZLT (1 << 29) /* stop on zero-len xfer */
  117. #define CONFIG_IOS (1 << 15) /* IRQ on setup */
  118. struct ept_queue_item {
  119. unsigned next;
  120. unsigned info;
  121. unsigned page0;
  122. unsigned page1;
  123. unsigned page2;
  124. unsigned page3;
  125. unsigned page4;
  126. unsigned reserved;
  127. };
  128. #define TERMINATE 1
  129. #define INFO_BYTES(n) ((n) << 16)
  130. #define INFO_IOC (1 << 15)
  131. #define INFO_ACTIVE (1 << 7)
  132. #define INFO_HALTED (1 << 6)
  133. #define INFO_BUFFER_ERROR (1 << 5)
  134. #define INFO_TX_ERROR (1 << 3)
  135. #endif