mu3d_hal_hw.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. #ifndef _MU3D_HAL_HW_H_
  2. #define _MU3D_HAL_HW_H_
  3. /* #include <mach/mt_reg_base.h> */
  4. #include <mu3d/ssusb_hw_regs.h>
  5. #define SW_VERSION "20140707"
  6. /* U3D configuration */
  7. /*This define for DVT OTG testing*/
  8. /* #define SUPPORT_OTG */
  9. /* This should be defined if superspeed is supported */
  10. /* #define SUPPORT_U3 */
  11. #ifdef SUPPORT_U3
  12. #define U3D_DFT_SPEED SSUSB_SPEED_SUPER
  13. #define U2_U3_SWITCH
  14. /* #define U2_U3_SWITCH_AUTO */
  15. #else
  16. #define U3D_DFT_SPEED SSUSB_SPEED_HIGH
  17. #endif
  18. /* #ifndef CONFIG_USB_MU3D_DRV */
  19. /* #define POWER_SAVING_MODE */
  20. /* #endif */
  21. /* clock setting
  22. this setting is applied ONLY for DR FPGA
  23. please check integrator for your platform setting
  24. */
  25. /* OSC 125MHz/2 = 62.5MHz, ceil(62.5) = 63 */
  26. /* #define U3D_MAC_SYS_CK 63 */
  27. /* OSC 20Mhz/2 = 10MHz */
  28. /* #define U3D_MAC_REF_CK 10 */
  29. /* U3D_PHY_REF_CK = U3D_MAC_REF_CK on ASIC */
  30. /* On FPGA, these two clocks are separated */
  31. /* #define U3D_PHY_REF_CK 48 */
  32. #define PIO_MODE 1
  33. #define DMA_MODE 2
  34. #define QMU_MODE 3
  35. #define BUS_MODE PIO_MODE
  36. #define EP0_BUS_MODE PIO_MODE
  37. #define AUTOSET
  38. /* #define AUTOCLEAR */
  39. #define BOUNDARY_4K
  40. #define DIS_ZLP_CHECK_CRC32 /* disable check crc32 in zlp */
  41. #define CS_12B 1
  42. #define CS_16B 2
  43. #define CHECKSUM_TYPE CS_16B
  44. #define U3D_COMMAND_TIMER 10
  45. #if (CHECKSUM_TYPE == CS_16B)
  46. #define CHECKSUM_LENGTH 16
  47. #else
  48. #define CHECKSUM_LENGTH 12
  49. #endif
  50. #define NO_ZLP 0
  51. #define HW_MODE 1
  52. #define GPD_MODE 2
  53. #define CFG_RX_COZ_EN /* complete on ZLP */
  54. #ifdef _USB_NORMAL_
  55. #define TXZLP NO_ZLP
  56. #else
  57. #define TXZLP GPD_MODE
  58. #endif
  59. #define ISO_UPDATE_TEST 0
  60. #define ISO_UPDATE_MODE 1
  61. #define LPM_STRESS 0
  62. /*EP number is hard code, not read from U3D_CAP_EPINFO*/
  63. #define HARDCODE_EP
  64. #if 0
  65. /**
  66. * @U3D register map
  67. */
  68. #ifdef SSUSB_DEV_BASE
  69. #error "---- usb 3 base ----"
  70. #endif
  71. /*
  72. * 0x1127_0000 for MAC register
  73. * relative to MAC base address (USB3_BASE defined in mt_reg_base.h)
  74. */
  75. /* 4K for each, offset may differ from project to project. Please check integrator */
  76. #define SSUSB_DEV_BASE (0x1000)
  77. #define SSUSB_EPCTL_CSR_BASE (0x1800)
  78. #define SSUSB_USB3_MAC_CSR_BASE (0x2400)
  79. #define SSUSB_USB3_SYS_CSR_BASE (0x2400)
  80. #define SSUSB_USB2_CSR_BASE (0x3400)
  81. /*
  82. * 0x1128_0000 for sifslv register in Infra
  83. * relative to SIFSLV base address (USB3_SIF_BASE defined in mt_reg_base.h)
  84. */
  85. #define SSUSB_SIFSLV_IPPC_BASE (0x700)
  86. #define SSUSB_SIFSLV_U2PHY_COM_BASE (0x800)
  87. #define SSUSB_SIFSLV_U3PHYD_BASE (0x900)
  88. #define SSUSB_SIFSLV_U2FREQ_BASE (0xF00)
  89. #ifdef CONFIG_SSUSB_PROJECT_PHY
  90. /*
  91. * 0x1129_0000 for sifslv register in top_ao
  92. * relative to SIFSLV2 base address (USB3_SIF2_BASE defined in mt_reg_base.h)
  93. */
  94. #define SSUSB_SIFSLV_U2PHY_COM_SIV_B_BASE (0x800)
  95. #define SSUSB_USB30_PHYA_SIV_B_BASE (0xB00)
  96. #endif
  97. #include <mu3d/hal/ssusb_dev_c_header.h>
  98. #include <mu3d/hal/ssusb_epctl_csr_c_header.h>
  99. /* usb3_mac / usb3_sys do not exist in U2 ONLY IP */
  100. #include <mu3d/hal/ssusb_usb3_mac_csr_c_header.h>
  101. #include <mu3d/hal/ssusb_usb3_sys_csr_c_header.h>
  102. #include <mu3d/hal/ssusb_usb2_csr_c_header.h>
  103. #include <mu3d/hal/ssusb_sifslv_ippc_c_header.h>
  104. /* #include <linux/mu3phy/mtk-phy.h> */
  105. #endif
  106. #ifdef EXT_VBUS_DET
  107. #define FPGA_REG 0xf0008098
  108. #define VBUS_RISE_BIT (1<<11) /* W1C */
  109. #define VBUS_FALL_BIT (1<<12) /* W1C */
  110. #define VBUS_MSK (VBUS_RISE_BIT | VBUS_FALL_BIT)
  111. #define VBUS_RISE_IRQ 13
  112. #define VBUS_FALL_IRQ 14
  113. #endif
  114. #define USB_IRQ 146
  115. #define RISC_SIZE_1B 0x0
  116. #define RISC_SIZE_2B 0x1
  117. #define RISC_SIZE_4B 0x2
  118. /* #define USB_FIFO(ep_num) (U3D_FIFO0+ep_num*0x10) */
  119. #define USB_FIFOSZ_SIZE_8 (0x03)
  120. #define USB_FIFOSZ_SIZE_16 (0x04)
  121. #define USB_FIFOSZ_SIZE_32 (0x05)
  122. #define USB_FIFOSZ_SIZE_64 (0x06)
  123. #define USB_FIFOSZ_SIZE_128 (0x07)
  124. #define USB_FIFOSZ_SIZE_256 (0x08)
  125. #define USB_FIFOSZ_SIZE_512 (0x09)
  126. #define USB_FIFOSZ_SIZE_1024 (0x0A)
  127. #define USB_FIFOSZ_SIZE_2048 (0x0B)
  128. #define USB_FIFOSZ_SIZE_4096 (0x0C)
  129. #define USB_FIFOSZ_SIZE_8192 (0x0D)
  130. #define USB_FIFOSZ_SIZE_16384 (0x0E)
  131. #define USB_FIFOSZ_SIZE_32768 (0x0F)
  132. /* U3D_EP0CSR */
  133. #define CSR0_SETUPEND (0x00200000) /* /removed, use SETUPENDISR */
  134. #define CSR0_FLUSHFIFO (0x01000000) /* /removed */
  135. #define CSR0_SERVICESETUPEND (0x08000000) /* /removed, W1C SETUPENDISR */
  136. #define EP0_W1C_BITS (~(EP0_RXPKTRDY | EP0_SETUPPKTRDY | EP0_SENTSTALL))
  137. /* U3D_TX1CSR0 */
  138. #define USB_TXCSR_FLUSHFIFO (0x00100000) /* removed */
  139. #define TX_W1C_BITS (~(TX_SENTSTALL))
  140. /* USB_RXCSR */
  141. #define USB_RXCSR_FLUSHFIFO (0x00100000) /* removed */
  142. #define RX_W1C_BITS (~(RX_SENTSTALL|RX_RXPKTRDY))
  143. #define BIT0 (1<<0)
  144. #define BIT16 (1<<16)
  145. #define TYPE_BULK (0x00)
  146. #define TYPE_INT (0x10)
  147. #define TYPE_ISO (0x20)
  148. #define TYPE_MASK (0x30)
  149. /* QMU macros */
  150. #define USB_QMU_RQCSR(n) (U3D_RXQCSR1 + 0x10 * ((n) - 1))
  151. #define USB_QMU_RQSAR(n) (U3D_RXQSAR1 + 0x10 * ((n) - 1))
  152. #define USB_QMU_RQCPR(n) (U3D_RXQCPR1 + 0x10 * ((n) - 1))
  153. #define USB_QMU_RQLDPR(n) (U3D_RXQLDPR1 + 0x10 * ((n) - 1))
  154. #define USB_QMU_TQCSR(n) (U3D_TXQCSR1 + 0x10 * ((n) - 1))
  155. #define USB_QMU_TQSAR(n) (U3D_TXQSAR1 + 0x10 * ((n) - 1))
  156. #define USB_QMU_TQCPR(n) (U3D_TXQCPR1 + 0x10 * ((n) - 1))
  157. #define QMU_Q_START (0x00000001)
  158. #define QMU_Q_RESUME (0x00000002)
  159. #define QMU_Q_STOP (0x00000004)
  160. #define QMU_Q_ACTIVE (0x00008000)
  161. #define QMU_TX_EN(n) (BIT0<<(n))
  162. #define QMU_RX_EN(n) (BIT16<<(n))
  163. #define QMU_TX_CS_EN(n) (BIT0<<(n))
  164. #define QMU_RX_CS_EN(n) (BIT16<<(n))
  165. #define QMU_TX_ZLP(n) (BIT0<<(n))
  166. #define QMU_RX_MULTIPLE(n) (BIT16<<((n)-1))
  167. #define QMU_RX_ZLP(n) (BIT0<<(n))
  168. #define QMU_RX_COZ(n) (BIT16<<(n))
  169. #define QMU_RX_EMPTY(n) (BIT16<<(n))
  170. #define QMU_TX_EMPTY(n) (BIT0<<(n))
  171. #define QMU_RX_DONE(n) (BIT16<<(n))
  172. #define QMU_TX_DONE(n) (BIT0<<(n))
  173. #define QMU_RX_ZLP_ERR(n) (BIT16<<(n))
  174. #define QMU_RX_EP_ERR(n) (BIT0<<(n))
  175. #define QMU_RX_LEN_ERR(n) (BIT16<<(n))
  176. #define QMU_RX_CS_ERR(n) (BIT0<<(n))
  177. #define QMU_TX_LEN_ERR(n) (BIT16<<(n))
  178. #define QMU_TX_CS_ERR(n) (BIT0<<(n))
  179. #define SSUSB_U3_CTRL(p) (U3D_SSUSB_U3_CTRL_0P + (p * 0x08))
  180. #define SSUSB_U2_CTRL(p) (U3D_SSUSB_U2_CTRL_0P + (p * 0x08))
  181. #define SSUSB_U3_PORT_NUM(p) (p & 0xff)
  182. #define SSUSB_U2_PORT_NUM(p) ((p >> 8) & 0xff)
  183. /**
  184. * @MAC value Definition
  185. */
  186. /* U3D_LINK_STATE_MACHINE */
  187. #define STATE_RESET (0)
  188. #define STATE_DISABLE (1)
  189. #define STATE_DISABLE_EXIT (2)
  190. #define STATE_SS_INACTIVE_QUITE (3)
  191. #define STATE_SS_INACTIVE_DISC_DETECT (4)
  192. #define STATE_RX_DETECT_RESET (5)
  193. #define STATE_RX_DETECT_ACTIVE (6)
  194. #define STATE_RX_DETECT_QUITE (7)
  195. #define STATE_POLLING_LFPS (8)
  196. #define STATE_POLLING_RXEQ (9)
  197. #define STATE_POLLING_ACTIVE (10)
  198. #define STATE_POLLING_CONFIGURATION (11)
  199. #define STATE_POLLING_IDLE (12)
  200. #define STATE_U0_STATE (13)
  201. #define STATE_U1_STATE (14)
  202. #define STATE_U1_TX_PING (15)
  203. #define STATE_U1_EXIT (16)
  204. #define STATE_U2_STATE (17)
  205. #define STATE_U2_DETECT (18)
  206. #define STATE_U2_EXIT (19)
  207. #define STATE_U3_STATE (20)
  208. #define STATE_U3_DETECT (21)
  209. #define STATE_U3_EXIT (22)
  210. #define STATE_COMPLIANCE (23)
  211. #define STATE_RECOVERY_ACTIVE (24)
  212. #define STATE_RECOVERY_CONFIGURATION (25)
  213. #define STATE_RECOVERY_IDLE (26)
  214. #define STATE_LOOPBACK_ACTIVE_MASTER (27)
  215. #define STATE_LOOPBACK_ACTIVE_SLAVE (28)
  216. /* DEVICE_CONTROL */
  217. #define USB_DEVCTL_VBUSVALID (0x18)
  218. #endif /* USB_HW_H */