usb.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (c) 2011 The Chromium OS Authors.
  4. * Copyright (c) 2013 NVIDIA Corporation
  5. */
  6. #ifndef _TEGRA_USB_H_
  7. #define _TEGRA_USB_H_
  8. /* USB Controller (USBx_CONTROLLER_) regs */
  9. struct usb_ctlr {
  10. /* 0x000 */
  11. uint id;
  12. uint reserved0;
  13. uint host;
  14. uint device;
  15. /* 0x010 */
  16. uint txbuf;
  17. uint rxbuf;
  18. uint reserved1[2];
  19. /* 0x020 */
  20. uint reserved2[56];
  21. /* 0x100 */
  22. u16 cap_length;
  23. u16 hci_version;
  24. uint hcs_params;
  25. uint hcc_params;
  26. uint reserved3[5];
  27. /* 0x120 */
  28. uint dci_version;
  29. uint dcc_params;
  30. uint reserved4[2];
  31. #ifdef CONFIG_TEGRA20
  32. /* 0x130 */
  33. uint reserved4_2[4];
  34. /* 0x140 */
  35. uint usb_cmd;
  36. uint usb_sts;
  37. uint usb_intr;
  38. uint frindex;
  39. /* 0x150 */
  40. uint reserved5;
  41. uint periodic_list_base;
  42. uint async_list_addr;
  43. uint async_tt_sts;
  44. /* 0x160 */
  45. uint burst_size;
  46. uint tx_fill_tuning;
  47. uint reserved6; /* is this port_sc1 on some controllers? */
  48. uint icusb_ctrl;
  49. /* 0x170 */
  50. uint ulpi_viewport;
  51. uint reserved7;
  52. uint endpt_nak;
  53. uint endpt_nak_enable;
  54. /* 0x180 */
  55. uint reserved;
  56. uint port_sc1;
  57. uint reserved8[6];
  58. /* 0x1a0 */
  59. uint reserved9;
  60. uint otgsc;
  61. uint usb_mode;
  62. uint endpt_setup_stat;
  63. /* 0x1b0 */
  64. uint reserved10[20];
  65. /* 0x200 */
  66. uint reserved11[0x80];
  67. #else
  68. /* 0x130 */
  69. uint usb_cmd;
  70. uint usb_sts;
  71. uint usb_intr;
  72. uint frindex;
  73. /* 0x140 */
  74. uint reserved5;
  75. uint periodic_list_base;
  76. uint async_list_addr;
  77. uint reserved5_1;
  78. /* 0x150 */
  79. uint burst_size;
  80. uint tx_fill_tuning;
  81. uint reserved6;
  82. uint icusb_ctrl;
  83. /* 0x160 */
  84. uint ulpi_viewport;
  85. uint reserved7[3];
  86. /* 0x170 */
  87. uint reserved;
  88. uint port_sc1;
  89. uint reserved8[6];
  90. /* 0x190 */
  91. uint reserved9[8];
  92. /* 0x1b0 */
  93. uint reserved10;
  94. uint hostpc1_devlc;
  95. uint reserved10_1[2];
  96. /* 0x1c0 */
  97. uint reserved10_2[4];
  98. /* 0x1d0 */
  99. uint reserved10_3[4];
  100. /* 0x1e0 */
  101. uint reserved10_4[4];
  102. /* 0x1f0 */
  103. uint reserved10_5;
  104. uint otgsc;
  105. uint usb_mode;
  106. uint reserved10_6;
  107. /* 0x200 */
  108. uint endpt_nak;
  109. uint endpt_nak_enable;
  110. uint endpt_setup_stat;
  111. uint reserved11_1[0x7D];
  112. #endif
  113. /* 0x400 */
  114. uint susp_ctrl;
  115. uint phy_vbus_sensors;
  116. uint phy_vbus_wakeup_id;
  117. uint phy_alt_vbus_sys;
  118. #ifdef CONFIG_TEGRA20
  119. /* 0x410 */
  120. uint usb1_legacy_ctrl;
  121. uint reserved12[4];
  122. /* 0x424 */
  123. uint ulpi_timing_ctrl_0;
  124. uint ulpi_timing_ctrl_1;
  125. uint reserved13[53];
  126. #else
  127. /* 0x410 */
  128. uint usb1_legacy_ctrl;
  129. uint reserved12[3];
  130. /* 0x420 */
  131. uint reserved13[56];
  132. #endif
  133. /* 0x500 */
  134. uint reserved14[64 * 3];
  135. /* 0x800 */
  136. uint utmip_pll_cfg0;
  137. uint utmip_pll_cfg1;
  138. uint utmip_xcvr_cfg0;
  139. uint utmip_bias_cfg0;
  140. /* 0x810 */
  141. uint utmip_hsrx_cfg0;
  142. uint utmip_hsrx_cfg1;
  143. uint utmip_fslsrx_cfg0;
  144. uint utmip_fslsrx_cfg1;
  145. /* 0x820 */
  146. uint utmip_tx_cfg0;
  147. uint utmip_misc_cfg0;
  148. uint utmip_misc_cfg1;
  149. uint utmip_debounce_cfg0;
  150. /* 0x830 */
  151. uint utmip_bat_chrg_cfg0;
  152. uint utmip_spare_cfg0;
  153. uint utmip_xcvr_cfg1;
  154. uint utmip_bias_cfg1;
  155. };
  156. /* USB1_LEGACY_CTRL */
  157. #define USB1_NO_LEGACY_MODE 1
  158. #define VBUS_SENSE_CTL_SHIFT 1
  159. #define VBUS_SENSE_CTL_MASK (3 << VBUS_SENSE_CTL_SHIFT)
  160. #define VBUS_SENSE_CTL_VBUS_WAKEUP 0
  161. #define VBUS_SENSE_CTL_AB_SESS_VLD_OR_VBUS_WAKEUP 1
  162. #define VBUS_SENSE_CTL_AB_SESS_VLD 2
  163. #define VBUS_SENSE_CTL_A_SESS_VLD 3
  164. /* USBx_IF_USB_SUSP_CTRL_0 */
  165. #define UTMIP_PHY_ENB (1 << 12)
  166. #define UTMIP_RESET (1 << 11)
  167. #define USB_PHY_CLK_VALID (1 << 7)
  168. #define USB_SUSP_CLR (1 << 5)
  169. #if defined(CONFIG_TEGRA20) || defined(CONFIG_TEGRA30)
  170. /* USB2_IF_USB_SUSP_CTRL_0 */
  171. #define ULPI_PHY_ENB (1 << 13)
  172. /* USB2_IF_ULPI_TIMING_CTRL_0 */
  173. #define ULPI_OUTPUT_PINMUX_BYP (1 << 10)
  174. #define ULPI_CLKOUT_PINMUX_BYP (1 << 11)
  175. /* USB2_IF_ULPI_TIMING_CTRL_1 */
  176. #define ULPI_DATA_TRIMMER_LOAD (1 << 0)
  177. #define ULPI_DATA_TRIMMER_SEL(x) (((x) & 0x7) << 1)
  178. #define ULPI_STPDIRNXT_TRIMMER_LOAD (1 << 16)
  179. #define ULPI_STPDIRNXT_TRIMMER_SEL(x) (((x) & 0x7) << 17)
  180. #define ULPI_DIR_TRIMMER_LOAD (1 << 24)
  181. #define ULPI_DIR_TRIMMER_SEL(x) (((x) & 0x7) << 25)
  182. #endif
  183. /* USBx_UTMIP_MISC_CFG0 */
  184. #define UTMIP_SUSPEND_EXIT_ON_EDGE (1 << 22)
  185. /* USBx_UTMIP_MISC_CFG1 */
  186. #define UTMIP_PHY_XTAL_CLOCKEN (1 << 30)
  187. /*
  188. * Tegra 3 and later: Moved to Clock and Reset register space, see
  189. * CLK_RST_CONTROLLER_UTMIP_PLL_CFG2_0
  190. */
  191. #define UTMIP_PLLU_STABLE_COUNT_SHIFT 6
  192. #define UTMIP_PLLU_STABLE_COUNT_MASK \
  193. (0xfff << UTMIP_PLLU_STABLE_COUNT_SHIFT)
  194. /*
  195. * Tegra 3 and later: Moved to Clock and Reset register space, see
  196. * CLK_RST_CONTROLLER_UTMIP_PLL_CFG2_0
  197. */
  198. #define UTMIP_PLL_ACTIVE_DLY_COUNT_SHIFT 18
  199. #define UTMIP_PLL_ACTIVE_DLY_COUNT_MASK \
  200. (0x1f << UTMIP_PLL_ACTIVE_DLY_COUNT_SHIFT)
  201. /* USBx_UTMIP_PLL_CFG1_0 */
  202. /* Tegra 3 and later: Moved to Clock and Reset register space */
  203. #define UTMIP_PLLU_ENABLE_DLY_COUNT_SHIFT 27
  204. #define UTMIP_PLLU_ENABLE_DLY_COUNT_MASK \
  205. (0x1f << UTMIP_PLLU_ENABLE_DLY_COUNT_SHIFT)
  206. #define UTMIP_XTAL_FREQ_COUNT_SHIFT 0
  207. #define UTMIP_XTAL_FREQ_COUNT_MASK 0xfff
  208. /* USBx_UTMIP_BIAS_CFG0_0 */
  209. #define UTMIP_HSDISCON_LEVEL_MSB (1 << 24)
  210. #define UTMIP_OTGPD (1 << 11)
  211. #define UTMIP_BIASPD (1 << 10)
  212. #define UTMIP_HSDISCON_LEVEL_SHIFT 2
  213. #define UTMIP_HSDISCON_LEVEL_MASK \
  214. (0x3 << UTMIP_HSDISCON_LEVEL_SHIFT)
  215. #define UTMIP_HSSQUELCH_LEVEL_SHIFT 0
  216. #define UTMIP_HSSQUELCH_LEVEL_MASK \
  217. (0x3 << UTMIP_HSSQUELCH_LEVEL_SHIFT)
  218. /* USBx_UTMIP_BIAS_CFG1_0 */
  219. #define UTMIP_FORCE_PDTRK_POWERDOWN 1
  220. #define UTMIP_BIAS_DEBOUNCE_TIMESCALE_SHIFT 8
  221. #define UTMIP_BIAS_DEBOUNCE_TIMESCALE_MASK \
  222. (0x3f << UTMIP_BIAS_DEBOUNCE_TIMESCALE_SHIFT)
  223. #define UTMIP_BIAS_PDTRK_COUNT_SHIFT 3
  224. #define UTMIP_BIAS_PDTRK_COUNT_MASK \
  225. (0x1f << UTMIP_BIAS_PDTRK_COUNT_SHIFT)
  226. /* USBx_UTMIP_DEBOUNCE_CFG0_0 */
  227. #define UTMIP_DEBOUNCE_CFG0_SHIFT 0
  228. #define UTMIP_DEBOUNCE_CFG0_MASK 0xffff
  229. /* USBx_UTMIP_TX_CFG0_0 */
  230. #define UTMIP_FS_PREAMBLE_J (1 << 19)
  231. /* USBx_UTMIP_BAT_CHRG_CFG0_0 */
  232. #define UTMIP_PD_CHRG 1
  233. /* USBx_UTMIP_SPARE_CFG0_0 */
  234. #define FUSE_SETUP_SEL (1 << 3)
  235. /* USBx_UTMIP_HSRX_CFG0_0 */
  236. #define UTMIP_IDLE_WAIT_SHIFT 15
  237. #define UTMIP_IDLE_WAIT_MASK (0x1f << UTMIP_IDLE_WAIT_SHIFT)
  238. #define UTMIP_ELASTIC_LIMIT_SHIFT 10
  239. #define UTMIP_ELASTIC_LIMIT_MASK \
  240. (0x1f << UTMIP_ELASTIC_LIMIT_SHIFT)
  241. /* USBx_UTMIP_HSRX_CFG1_0 */
  242. #define UTMIP_HS_SYNC_START_DLY_SHIFT 1
  243. #define UTMIP_HS_SYNC_START_DLY_MASK \
  244. (0x1f << UTMIP_HS_SYNC_START_DLY_SHIFT)
  245. /* USBx_CONTROLLER_2_USB2D_ICUSB_CTRL_0 */
  246. #define IC_ENB1 (1 << 3)
  247. #ifdef CONFIG_TEGRA20
  248. /* PORTSC1, USB1 */
  249. #define PTS1_SHIFT 31
  250. #define PTS1_MASK (1 << PTS1_SHIFT)
  251. #define STS1 (1 << 30)
  252. /* PORTSC, USB2, USB3 */
  253. #define PTS_SHIFT 30
  254. #define PTS_MASK (3U << PTS_SHIFT)
  255. #define STS (1 << 29)
  256. #else
  257. /* USB2D_HOSTPC1_DEVLC_0 */
  258. #define PTS_SHIFT 29
  259. #define PTS_MASK (0x7U << PTS_SHIFT)
  260. #define STS (1 << 28)
  261. #endif
  262. #define PTS_UTMI 0
  263. #define PTS_RESERVED 1
  264. #define PTS_ULPI 2
  265. #define PTS_ICUSB_SER 3
  266. #define PTS_HSIC 4
  267. /* SB2_CONTROLLER_2_USB2D_PORTSC1_0 */
  268. #define WKOC (1 << 22)
  269. #define WKDS (1 << 21)
  270. #define WKCN (1 << 20)
  271. /* USBx_UTMIP_XCVR_CFG0_0 */
  272. #define UTMIP_FORCE_PD_POWERDOWN (1 << 14)
  273. #define UTMIP_FORCE_PD2_POWERDOWN (1 << 16)
  274. #define UTMIP_FORCE_PDZI_POWERDOWN (1 << 18)
  275. #define UTMIP_XCVR_LSBIAS_SE (1 << 21)
  276. #define UTMIP_XCVR_HSSLEW_MSB_SHIFT 25
  277. #define UTMIP_XCVR_HSSLEW_MSB_MASK \
  278. (0x7f << UTMIP_XCVR_HSSLEW_MSB_SHIFT)
  279. #define UTMIP_XCVR_SETUP_MSB_SHIFT 22
  280. #define UTMIP_XCVR_SETUP_MSB_MASK (0x7 << UTMIP_XCVR_SETUP_MSB_SHIFT)
  281. #define UTMIP_XCVR_SETUP_SHIFT 0
  282. #define UTMIP_XCVR_SETUP_MASK (0xf << UTMIP_XCVR_SETUP_SHIFT)
  283. /* USBx_UTMIP_XCVR_CFG1_0 */
  284. #define UTMIP_XCVR_TERM_RANGE_ADJ_SHIFT 18
  285. #define UTMIP_XCVR_TERM_RANGE_ADJ_MASK \
  286. (0xf << UTMIP_XCVR_TERM_RANGE_ADJ_SHIFT)
  287. #define UTMIP_FORCE_PDDISC_POWERDOWN (1 << 0)
  288. #define UTMIP_FORCE_PDCHRP_POWERDOWN (1 << 2)
  289. #define UTMIP_FORCE_PDDR_POWERDOWN (1 << 4)
  290. /* USB3_IF_USB_PHY_VBUS_SENSORS_0 */
  291. #define VBUS_VLD_STS (1 << 26)
  292. #define VBUS_B_SESS_VLD_SW_VALUE (1 << 12)
  293. #define VBUS_B_SESS_VLD_SW_EN (1 << 11)
  294. /* Setup USB on the board */
  295. int usb_process_devicetree(const void *blob);
  296. #endif /* _TEGRA_USB_H_ */