mu3d_hal_hw.h 7.7 KB

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