dwc2_udc_otg_regs.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /* linux/arch/arm/plat-s3c/include/plat/regs-otg.h
  3. *
  4. * Copyright (C) 2004 Herbert Poetzl <herbert@13thfloor.at>
  5. *
  6. * Registers remapping:
  7. * Lukasz Majewski <l.majewski@samsumg.com>
  8. */
  9. #ifndef __ASM_ARCH_REGS_USB_OTG_HS_H
  10. #define __ASM_ARCH_REGS_USB_OTG_HS_H
  11. /* USB2.0 OTG Controller register */
  12. struct dwc2_usbotg_phy {
  13. u32 phypwr;
  14. u32 phyclk;
  15. u32 rstcon;
  16. };
  17. /* Device Logical IN Endpoint-Specific Registers */
  18. struct dwc2_dev_in_endp {
  19. u32 diepctl;
  20. u8 res1[4];
  21. u32 diepint;
  22. u8 res2[4];
  23. u32 dieptsiz;
  24. u32 diepdma;
  25. u8 res3[4];
  26. u32 diepdmab;
  27. };
  28. /* Device Logical OUT Endpoint-Specific Registers */
  29. struct dwc2_dev_out_endp {
  30. u32 doepctl;
  31. u8 res1[4];
  32. u32 doepint;
  33. u8 res2[4];
  34. u32 doeptsiz;
  35. u32 doepdma;
  36. u8 res3[4];
  37. u32 doepdmab;
  38. };
  39. struct ep_fifo {
  40. u32 fifo;
  41. u8 res[4092];
  42. };
  43. /* USB2.0 OTG Controller register */
  44. struct dwc2_usbotg_reg {
  45. /* Core Global Registers */
  46. u32 gotgctl; /* OTG Control & Status */
  47. u32 gotgint; /* OTG Interrupt */
  48. u32 gahbcfg; /* Core AHB Configuration */
  49. u32 gusbcfg; /* Core USB Configuration */
  50. u32 grstctl; /* Core Reset */
  51. u32 gintsts; /* Core Interrupt */
  52. u32 gintmsk; /* Core Interrupt Mask */
  53. u32 grxstsr; /* Receive Status Debug Read/Status Read */
  54. u32 grxstsp; /* Receive Status Debug Pop/Status Pop */
  55. u32 grxfsiz; /* Receive FIFO Size */
  56. u32 gnptxfsiz; /* Non-Periodic Transmit FIFO Size */
  57. u8 res1[216];
  58. u32 dieptxf[15]; /* Device Periodic Transmit FIFO size register */
  59. u8 res2[1728];
  60. /* Device Configuration */
  61. u32 dcfg; /* Device Configuration Register */
  62. u32 dctl; /* Device Control */
  63. u32 dsts; /* Device Status */
  64. u8 res3[4];
  65. u32 diepmsk; /* Device IN Endpoint Common Interrupt Mask */
  66. u32 doepmsk; /* Device OUT Endpoint Common Interrupt Mask */
  67. u32 daint; /* Device All Endpoints Interrupt */
  68. u32 daintmsk; /* Device All Endpoints Interrupt Mask */
  69. u8 res4[224];
  70. struct dwc2_dev_in_endp in_endp[16];
  71. struct dwc2_dev_out_endp out_endp[16];
  72. u8 res5[768];
  73. struct ep_fifo ep[16];
  74. };
  75. /*===================================================================== */
  76. /*definitions related to CSR setting */
  77. /* DWC2_UDC_OTG_GOTGCTL */
  78. #define B_SESSION_VALID (0x1<<19)
  79. #define A_SESSION_VALID (0x1<<18)
  80. /* DWC2_UDC_OTG_GAHBCFG */
  81. #define PTXFE_HALF (0<<8)
  82. #define PTXFE_ZERO (1<<8)
  83. #define NPTXFE_HALF (0<<7)
  84. #define NPTXFE_ZERO (1<<7)
  85. #define MODE_SLAVE (0<<5)
  86. #define MODE_DMA (1<<5)
  87. #define BURST_SINGLE (0<<1)
  88. #define BURST_INCR (1<<1)
  89. #define BURST_INCR4 (3<<1)
  90. #define BURST_INCR8 (5<<1)
  91. #define BURST_INCR16 (7<<1)
  92. #define GBL_INT_UNMASK (1<<0)
  93. #define GBL_INT_MASK (0<<0)
  94. /* DWC2_UDC_OTG_GRSTCTL */
  95. #define AHB_MASTER_IDLE (1u<<31)
  96. #define CORE_SOFT_RESET (0x1<<0)
  97. /* DWC2_UDC_OTG_GINTSTS/DWC2_UDC_OTG_GINTMSK core interrupt register */
  98. #define INT_RESUME (1u<<31)
  99. #define INT_DISCONN (0x1<<29)
  100. #define INT_CONN_ID_STS_CNG (0x1<<28)
  101. #define INT_OUT_EP (0x1<<19)
  102. #define INT_IN_EP (0x1<<18)
  103. #define INT_ENUMDONE (0x1<<13)
  104. #define INT_RESET (0x1<<12)
  105. #define INT_SUSPEND (0x1<<11)
  106. #define INT_EARLY_SUSPEND (0x1<<10)
  107. #define INT_NP_TX_FIFO_EMPTY (0x1<<5)
  108. #define INT_RX_FIFO_NOT_EMPTY (0x1<<4)
  109. #define INT_SOF (0x1<<3)
  110. #define INT_DEV_MODE (0x0<<0)
  111. #define INT_HOST_MODE (0x1<<1)
  112. #define INT_GOUTNakEff (0x01<<7)
  113. #define INT_GINNakEff (0x01<<6)
  114. #define FULL_SPEED_CONTROL_PKT_SIZE 8
  115. #define FULL_SPEED_BULK_PKT_SIZE 64
  116. #define HIGH_SPEED_CONTROL_PKT_SIZE 64
  117. #define HIGH_SPEED_BULK_PKT_SIZE 512
  118. #define RX_FIFO_SIZE (1024)
  119. #define NPTX_FIFO_SIZE (1024)
  120. #define PTX_FIFO_SIZE (384)
  121. #define DEPCTL_TXFNUM_0 (0x0<<22)
  122. #define DEPCTL_TXFNUM_1 (0x1<<22)
  123. #define DEPCTL_TXFNUM_2 (0x2<<22)
  124. #define DEPCTL_TXFNUM_3 (0x3<<22)
  125. #define DEPCTL_TXFNUM_4 (0x4<<22)
  126. /* Enumeration speed */
  127. #define USB_HIGH_30_60MHZ (0x0<<1)
  128. #define USB_FULL_30_60MHZ (0x1<<1)
  129. #define USB_LOW_6MHZ (0x2<<1)
  130. #define USB_FULL_48MHZ (0x3<<1)
  131. /* DWC2_UDC_OTG_GRXSTSP STATUS */
  132. #define OUT_PKT_RECEIVED (0x2<<17)
  133. #define OUT_TRANSFER_COMPLELTED (0x3<<17)
  134. #define SETUP_TRANSACTION_COMPLETED (0x4<<17)
  135. #define SETUP_PKT_RECEIVED (0x6<<17)
  136. #define GLOBAL_OUT_NAK (0x1<<17)
  137. /* DWC2_UDC_OTG_DCTL device control register */
  138. #define NORMAL_OPERATION (0x1<<0)
  139. #define SOFT_DISCONNECT (0x1<<1)
  140. /* DWC2_UDC_OTG_DAINT device all endpoint interrupt register */
  141. #define DAINT_OUT_BIT (16)
  142. #define DAINT_MASK (0xFFFF)
  143. /* DWC2_UDC_OTG_DIEPCTL0/DOEPCTL0 device
  144. control IN/OUT endpoint 0 control register */
  145. #define DEPCTL_EPENA (0x1<<31)
  146. #define DEPCTL_EPDIS (0x1<<30)
  147. #define DEPCTL_SETD1PID (0x1<<29)
  148. #define DEPCTL_SETD0PID (0x1<<28)
  149. #define DEPCTL_SNAK (0x1<<27)
  150. #define DEPCTL_CNAK (0x1<<26)
  151. #define DEPCTL_STALL (0x1<<21)
  152. #define DEPCTL_TYPE_BIT (18)
  153. #define DEPCTL_TYPE_MASK (0x3<<18)
  154. #define DEPCTL_CTRL_TYPE (0x0<<18)
  155. #define DEPCTL_ISO_TYPE (0x1<<18)
  156. #define DEPCTL_BULK_TYPE (0x2<<18)
  157. #define DEPCTL_INTR_TYPE (0x3<<18)
  158. #define DEPCTL_USBACTEP (0x1<<15)
  159. #define DEPCTL_NEXT_EP_BIT (11)
  160. #define DEPCTL_MPS_BIT (0)
  161. #define DEPCTL_MPS_MASK (0x7FF)
  162. #define DEPCTL0_MPS_64 (0x0<<0)
  163. #define DEPCTL0_MPS_32 (0x1<<0)
  164. #define DEPCTL0_MPS_16 (0x2<<0)
  165. #define DEPCTL0_MPS_8 (0x3<<0)
  166. #define DEPCTL_MPS_BULK_512 (512<<0)
  167. #define DEPCTL_MPS_INT_MPS_16 (16<<0)
  168. #define DIEPCTL0_NEXT_EP_BIT (11)
  169. /* DWC2_UDC_OTG_DIEPMSK/DOEPMSK device IN/OUT endpoint
  170. common interrupt mask register */
  171. /* DWC2_UDC_OTG_DIEPINTn/DOEPINTn device IN/OUT endpoint interrupt register */
  172. #define BACK2BACK_SETUP_RECEIVED (0x1<<6)
  173. #define INTKNEPMIS (0x1<<5)
  174. #define INTKN_TXFEMP (0x1<<4)
  175. #define NON_ISO_IN_EP_TIMEOUT (0x1<<3)
  176. #define CTRL_OUT_EP_SETUP_PHASE_DONE (0x1<<3)
  177. #define AHB_ERROR (0x1<<2)
  178. #define EPDISBLD (0x1<<1)
  179. #define TRANSFER_DONE (0x1<<0)
  180. #define USB_PHY_CTRL_EN0 (0x1 << 0)
  181. /* OPHYPWR */
  182. #define PHY_0_SLEEP (0x1 << 5)
  183. #define OTG_DISABLE_0 (0x1 << 4)
  184. #define ANALOG_PWRDOWN (0x1 << 3)
  185. #define FORCE_SUSPEND_0 (0x1 << 0)
  186. /* URSTCON */
  187. #define HOST_SW_RST (0x1 << 4)
  188. #define PHY_SW_RST1 (0x1 << 3)
  189. #define PHYLNK_SW_RST (0x1 << 2)
  190. #define LINK_SW_RST (0x1 << 1)
  191. #define PHY_SW_RST0 (0x1 << 0)
  192. /* OPHYCLK */
  193. #define COMMON_ON_N1 (0x1 << 7)
  194. #define COMMON_ON_N0 (0x1 << 4)
  195. #define ID_PULLUP0 (0x1 << 2)
  196. #define CLK_SEL_24MHZ (0x3 << 0)
  197. #define CLK_SEL_12MHZ (0x2 << 0)
  198. #define CLK_SEL_48MHZ (0x0 << 0)
  199. #define EXYNOS4X12_ID_PULLUP0 (0x01 << 3)
  200. #define EXYNOS4X12_COMMON_ON_N0 (0x01 << 4)
  201. #define EXYNOS4X12_CLK_SEL_12MHZ (0x02 << 0)
  202. #define EXYNOS4X12_CLK_SEL_24MHZ (0x05 << 0)
  203. /* Device Configuration Register DCFG */
  204. #define DEV_SPEED_HIGH_SPEED_20 (0x0 << 0)
  205. #define DEV_SPEED_FULL_SPEED_20 (0x1 << 0)
  206. #define DEV_SPEED_LOW_SPEED_11 (0x2 << 0)
  207. #define DEV_SPEED_FULL_SPEED_11 (0x3 << 0)
  208. #define EP_MISS_CNT(x) (x << 18)
  209. #define DEVICE_ADDRESS(x) (x << 4)
  210. /* Core Reset Register (GRSTCTL) */
  211. #define TX_FIFO_FLUSH (0x1 << 5)
  212. #define RX_FIFO_FLUSH (0x1 << 4)
  213. #define TX_FIFO_NUMBER(x) (x << 6)
  214. #define TX_FIFO_FLUSH_ALL TX_FIFO_NUMBER(0x10)
  215. /* Masks definitions */
  216. #define GINTMSK_INIT (INT_OUT_EP | INT_IN_EP | INT_RESUME | INT_ENUMDONE\
  217. | INT_RESET | INT_SUSPEND)
  218. #define DOEPMSK_INIT (CTRL_OUT_EP_SETUP_PHASE_DONE | AHB_ERROR|TRANSFER_DONE)
  219. #define DIEPMSK_INIT (NON_ISO_IN_EP_TIMEOUT|AHB_ERROR|TRANSFER_DONE)
  220. #define GAHBCFG_INIT (PTXFE_HALF | NPTXFE_HALF | MODE_DMA | BURST_INCR4\
  221. | GBL_INT_UNMASK)
  222. /* Device Endpoint X Transfer Size Register (DIEPTSIZX) */
  223. #define DIEPT_SIZ_PKT_CNT(x) (x << 19)
  224. #define DIEPT_SIZ_XFER_SIZE(x) (x << 0)
  225. /* Device OUT Endpoint X Transfer Size Register (DOEPTSIZX) */
  226. #define DOEPT_SIZ_PKT_CNT(x) (x << 19)
  227. #define DOEPT_SIZ_XFER_SIZE(x) (x << 0)
  228. #define DOEPT_SIZ_XFER_SIZE_MAX_EP0 (0x7F << 0)
  229. #define DOEPT_SIZ_XFER_SIZE_MAX_EP (0x7FFF << 0)
  230. /* Device Endpoint-N Control Register (DIEPCTLn/DOEPCTLn) */
  231. #define DIEPCTL_TX_FIFO_NUM(x) (x << 22)
  232. #define DIEPCTL_TX_FIFO_NUM_MASK (~DIEPCTL_TX_FIFO_NUM(0xF))
  233. /* Device ALL Endpoints Interrupt Register (DAINT) */
  234. #define DAINT_IN_EP_INT(x) (x << 0)
  235. #define DAINT_OUT_EP_INT(x) (x << 16)
  236. #endif