dwc3.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /* include/linux/usb/dwc3.h
  2. *
  3. * Copyright (c) 2012 Samsung Electronics Co. Ltd
  4. *
  5. * Designware SuperSpeed USB 3.0 DRD Controller global and OTG registers
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #ifndef __DWC3_H_
  10. #define __DWC3_H_
  11. /* Global constants */
  12. #define DWC3_ENDPOINTS_NUM 32
  13. #define DWC3_EVENT_BUFFERS_SIZE PAGE_SIZE
  14. #define DWC3_EVENT_TYPE_MASK 0xfe
  15. #define DWC3_EVENT_TYPE_DEV 0
  16. #define DWC3_EVENT_TYPE_CARKIT 3
  17. #define DWC3_EVENT_TYPE_I2C 4
  18. #define DWC3_DEVICE_EVENT_DISCONNECT 0
  19. #define DWC3_DEVICE_EVENT_RESET 1
  20. #define DWC3_DEVICE_EVENT_CONNECT_DONE 2
  21. #define DWC3_DEVICE_EVENT_LINK_STATUS_CHANGE 3
  22. #define DWC3_DEVICE_EVENT_WAKEUP 4
  23. #define DWC3_DEVICE_EVENT_EOPF 6
  24. #define DWC3_DEVICE_EVENT_SOF 7
  25. #define DWC3_DEVICE_EVENT_ERRATIC_ERROR 9
  26. #define DWC3_DEVICE_EVENT_CMD_CMPL 10
  27. #define DWC3_DEVICE_EVENT_OVERFLOW 11
  28. #define DWC3_GEVNTCOUNT_MASK 0xfffc
  29. #define DWC3_GSNPSID_MASK 0xffff0000
  30. #define DWC3_GSNPSID_SHIFT 16
  31. #define DWC3_GSNPSREV_MASK 0xffff
  32. #define DWC3_REVISION_MASK 0xffff
  33. #define DWC3_REG_OFFSET 0xC100
  34. struct g_event_buffer {
  35. u32 g_evntadrlo;
  36. u32 g_evntadrhi;
  37. u32 g_evntsiz;
  38. u32 g_evntcount;
  39. };
  40. struct d_physical_endpoint {
  41. u32 d_depcmdpar2;
  42. u32 d_depcmdpar1;
  43. u32 d_depcmdpar0;
  44. u32 d_depcmd;
  45. };
  46. struct dwc3 { /* offset: 0xC100 */
  47. u32 g_sbuscfg0;
  48. u32 g_sbuscfg1;
  49. u32 g_txthrcfg;
  50. u32 g_rxthrcfg;
  51. u32 g_ctl;
  52. u32 reserved1;
  53. u32 g_sts;
  54. u32 reserved2;
  55. u32 g_snpsid;
  56. u32 g_gpio;
  57. u32 g_uid;
  58. u32 g_uctl;
  59. u64 g_buserraddr;
  60. u64 g_prtbimap;
  61. u32 g_hwparams0;
  62. u32 g_hwparams1;
  63. u32 g_hwparams2;
  64. u32 g_hwparams3;
  65. u32 g_hwparams4;
  66. u32 g_hwparams5;
  67. u32 g_hwparams6;
  68. u32 g_hwparams7;
  69. u32 g_dbgfifospace;
  70. u32 g_dbgltssm;
  71. u32 g_dbglnmcc;
  72. u32 g_dbgbmu;
  73. u32 g_dbglspmux;
  74. u32 g_dbglsp;
  75. u32 g_dbgepinfo0;
  76. u32 g_dbgepinfo1;
  77. u64 g_prtbimap_hs;
  78. u64 g_prtbimap_fs;
  79. u32 reserved3[28];
  80. u32 g_usb2phycfg[16];
  81. u32 g_usb2i2cctl[16];
  82. u32 g_usb2phyacc[16];
  83. u32 g_usb3pipectl[16];
  84. u32 g_txfifosiz[32];
  85. u32 g_rxfifosiz[32];
  86. struct g_event_buffer g_evnt_buf[32];
  87. u32 g_hwparams8;
  88. u32 reserved4[11];
  89. u32 g_fladj;
  90. u32 reserved5[51];
  91. u32 d_cfg;
  92. u32 d_ctl;
  93. u32 d_evten;
  94. u32 d_sts;
  95. u32 d_gcmdpar;
  96. u32 d_gcmd;
  97. u32 reserved6[2];
  98. u32 d_alepena;
  99. u32 reserved7[55];
  100. struct d_physical_endpoint d_phy_ep_cmd[32];
  101. u32 reserved8[128];
  102. u32 o_cfg;
  103. u32 o_ctl;
  104. u32 o_evt;
  105. u32 o_evten;
  106. u32 o_sts;
  107. u32 reserved9[3];
  108. u32 adp_cfg;
  109. u32 adp_ctl;
  110. u32 adp_evt;
  111. u32 adp_evten;
  112. u32 bc_cfg;
  113. u32 reserved10;
  114. u32 bc_evt;
  115. u32 bc_evten;
  116. };
  117. /* Global Configuration Register */
  118. #define DWC3_GCTL_PWRDNSCALE(n) ((n) << 19)
  119. #define DWC3_GCTL_U2RSTECN (1 << 16)
  120. #define DWC3_GCTL_RAMCLKSEL(x) \
  121. (((x) & DWC3_GCTL_CLK_MASK) << 6)
  122. #define DWC3_GCTL_CLK_BUS (0)
  123. #define DWC3_GCTL_CLK_PIPE (1)
  124. #define DWC3_GCTL_CLK_PIPEHALF (2)
  125. #define DWC3_GCTL_CLK_MASK (3)
  126. #define DWC3_GCTL_PRTCAP(n) (((n) & (3 << 12)) >> 12)
  127. #define DWC3_GCTL_PRTCAPDIR(n) ((n) << 12)
  128. #define DWC3_GCTL_PRTCAP_HOST 1
  129. #define DWC3_GCTL_PRTCAP_DEVICE 2
  130. #define DWC3_GCTL_PRTCAP_OTG 3
  131. #define DWC3_GCTL_CORESOFTRESET (1 << 11)
  132. #define DWC3_GCTL_SCALEDOWN(n) ((n) << 4)
  133. #define DWC3_GCTL_SCALEDOWN_MASK DWC3_GCTL_SCALEDOWN(3)
  134. #define DWC3_GCTL_DISSCRAMBLE (1 << 3)
  135. #define DWC3_GCTL_DSBLCLKGTNG (1 << 0)
  136. /* Global HWPARAMS1 Register */
  137. #define DWC3_GHWPARAMS1_EN_PWROPT(n) (((n) & (3 << 24)) >> 24)
  138. #define DWC3_GHWPARAMS1_EN_PWROPT_NO 0
  139. #define DWC3_GHWPARAMS1_EN_PWROPT_CLK 1
  140. /* Global USB2 PHY Configuration Register */
  141. #define DWC3_GUSB2PHYCFG_PHYSOFTRST (1 << 31)
  142. #define DWC3_GUSB2PHYCFG_U2_FREECLK_EXISTS (1 << 30)
  143. #define DWC3_GUSB2PHYCFG_ENBLSLPM (1 << 8)
  144. #define DWC3_GUSB2PHYCFG_SUSPHY (1 << 6)
  145. #define DWC3_GUSB2PHYCFG_PHYIF (1 << 3)
  146. /* Global USB2 PHY Configuration Mask */
  147. #define DWC3_GUSB2PHYCFG_USBTRDTIM_MASK (0xf << 10)
  148. /* Global USB2 PHY Configuration Offset */
  149. #define DWC3_GUSB2PHYCFG_USBTRDTIM_OFFSET 10
  150. #define DWC3_GUSB2PHYCFG_USBTRDTIM_16BIT (0x5 << \
  151. DWC3_GUSB2PHYCFG_USBTRDTIM_OFFSET)
  152. #define DWC3_GUSB2PHYCFG_USBTRDTIM_8BIT (0x9 << \
  153. DWC3_GUSB2PHYCFG_USBTRDTIM_OFFSET)
  154. /* Global USB3 PIPE Control Register */
  155. #define DWC3_GUSB3PIPECTL_PHYSOFTRST (1 << 31)
  156. #define DWC3_GUSB3PIPECTL_DISRXDETP3 (1 << 28)
  157. #define DWC3_GUSB3PIPECTL_SUSPHY (1 << 17)
  158. /* Global TX Fifo Size Register */
  159. #define DWC3_GTXFIFOSIZ_TXFDEF(n) ((n) & 0xffff)
  160. #define DWC3_GTXFIFOSIZ_TXFSTADDR(n) ((n) & 0xffff0000)
  161. /* Device Control Register */
  162. #define DWC3_DCTL_RUN_STOP (1 << 31)
  163. #define DWC3_DCTL_CSFTRST (1 << 30)
  164. #define DWC3_DCTL_LSFTRST (1 << 29)
  165. /* Global Frame Length Adjustment Register */
  166. #define GFLADJ_30MHZ_REG_SEL (1 << 7)
  167. #define GFLADJ_30MHZ(n) ((n) & 0x3f)
  168. #define GFLADJ_30MHZ_DEFAULT 0x20
  169. #ifdef CONFIG_USB_XHCI_DWC3
  170. void dwc3_set_mode(struct dwc3 *dwc3_reg, u32 mode);
  171. void dwc3_core_soft_reset(struct dwc3 *dwc3_reg);
  172. int dwc3_core_init(struct dwc3 *dwc3_reg);
  173. void dwc3_set_fladj(struct dwc3 *dwc3_reg, u32 val);
  174. #endif
  175. #endif /* __DWC3_H_ */