clk_rst.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. /*
  2. * (C) Copyright 2010,2011
  3. * NVIDIA Corporation <www.nvidia.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #ifndef _TEGRA_CLK_RST_H_
  24. #define _TEGRA_CLK_RST_H_
  25. /* PLL registers - there are several PLLs in the clock controller */
  26. struct clk_pll {
  27. uint pll_base; /* the control register */
  28. uint pll_out[2]; /* output control */
  29. uint pll_misc; /* other misc things */
  30. };
  31. /* PLL registers - there are several PLLs in the clock controller */
  32. struct clk_pll_simple {
  33. uint pll_base; /* the control register */
  34. uint pll_misc; /* other misc things */
  35. };
  36. /* RST_DEV_(L,H,U,V,W)_(SET,CLR) and CLK_ENB_(L,H,U,V,W)_(SET,CLR) */
  37. struct clk_set_clr {
  38. uint set;
  39. uint clr;
  40. };
  41. /*
  42. * Most PLLs use the clk_pll structure, but some have a simpler two-member
  43. * structure for which we use clk_pll_simple. The reason for this non-
  44. * othogonal setup is not stated.
  45. */
  46. enum {
  47. TEGRA_CLK_PLLS = 6, /* Number of normal PLLs */
  48. TEGRA_CLK_SIMPLE_PLLS = 3, /* Number of simple PLLs */
  49. TEGRA_CLK_REGS = 3, /* Number of clock enable regs L/H/U */
  50. TEGRA_CLK_SOURCES = 64, /* Number of ppl clock sources L/H/U */
  51. TEGRA_CLK_REGS_VW = 2, /* Number of clock enable regs V/W */
  52. TEGRA_CLK_SOURCES_VW = 32, /* Number of ppl clock sources V/W*/
  53. };
  54. /* Clock/Reset Controller (CLK_RST_CONTROLLER_) regs */
  55. struct clk_rst_ctlr {
  56. uint crc_rst_src; /* _RST_SOURCE_0,0x00 */
  57. uint crc_rst_dev[TEGRA_CLK_REGS]; /* _RST_DEVICES_L/H/U_0 */
  58. uint crc_clk_out_enb[TEGRA_CLK_REGS]; /* _CLK_OUT_ENB_L/H/U_0 */
  59. uint crc_reserved0; /* reserved_0, 0x1C */
  60. uint crc_cclk_brst_pol; /* _CCLK_BURST_POLICY_0,0x20 */
  61. uint crc_super_cclk_div; /* _SUPER_CCLK_DIVIDER_0,0x24 */
  62. uint crc_sclk_brst_pol; /* _SCLK_BURST_POLICY_0, 0x28 */
  63. uint crc_super_sclk_div; /* _SUPER_SCLK_DIVIDER_0,0x2C */
  64. uint crc_clk_sys_rate; /* _CLK_SYSTEM_RATE_0, 0x30 */
  65. uint crc_prog_dly_clk; /* _PROG_DLY_CLK_0, 0x34 */
  66. uint crc_aud_sync_clk_rate; /* _AUDIO_SYNC_CLK_RATE_0,0x38 */
  67. uint crc_reserved1; /* reserved_1, 0x3C */
  68. uint crc_cop_clk_skip_plcy; /* _COP_CLK_SKIP_POLICY_0,0x40 */
  69. uint crc_clk_mask_arm; /* _CLK_MASK_ARM_0, 0x44 */
  70. uint crc_misc_clk_enb; /* _MISC_CLK_ENB_0, 0x48 */
  71. uint crc_clk_cpu_cmplx; /* _CLK_CPU_CMPLX_0, 0x4C */
  72. uint crc_osc_ctrl; /* _OSC_CTRL_0, 0x50 */
  73. uint crc_pll_lfsr; /* _PLL_LFSR_0, 0x54 */
  74. uint crc_osc_freq_det; /* _OSC_FREQ_DET_0, 0x58 */
  75. uint crc_osc_freq_det_stat; /* _OSC_FREQ_DET_STATUS_0,0x5C */
  76. uint crc_reserved2[8]; /* reserved_2[8], 0x60-7C */
  77. struct clk_pll crc_pll[TEGRA_CLK_PLLS]; /* PLLs from 0x80 to 0xdc */
  78. /* PLLs from 0xe0 to 0xf4 */
  79. struct clk_pll_simple crc_pll_simple[TEGRA_CLK_SIMPLE_PLLS];
  80. uint crc_reserved10; /* _reserved_10, 0xF8 */
  81. uint crc_reserved11; /* _reserved_11, 0xFC */
  82. uint crc_clk_src[TEGRA_CLK_SOURCES]; /*_I2S1_0... 0x100-1fc */
  83. uint crc_reserved20[64]; /* _reserved_20, 0x200-2fc */
  84. /* _RST_DEV_L/H/U_SET_0 0x300 ~ 0x314 */
  85. struct clk_set_clr crc_rst_dev_ex[TEGRA_CLK_REGS];
  86. uint crc_reserved30[2]; /* _reserved_30, 0x318, 0x31c */
  87. /* _CLK_ENB_L/H/U_CLR_0 0x320 ~ 0x334 */
  88. struct clk_set_clr crc_clk_enb_ex[TEGRA_CLK_REGS];
  89. uint crc_reserved31[2]; /* _reserved_31, 0x338, 0x33c */
  90. uint crc_cpu_cmplx_set; /* _RST_CPU_CMPLX_SET_0, 0x340 */
  91. uint crc_cpu_cmplx_clr; /* _RST_CPU_CMPLX_CLR_0, 0x344 */
  92. /* Additional (T30) registers */
  93. uint crc_clk_cpu_cmplx_set; /* _CLK_CPU_CMPLX_SET_0, 0x348 */
  94. uint crc_clk_cpu_cmplx_clr; /* _CLK_CPU_CMPLX_SET_0, 0x34c */
  95. uint crc_reserved32[2]; /* _reserved_32, 0x350,0x354 */
  96. uint crc_rst_dev_vw[TEGRA_CLK_REGS_VW]; /* _RST_DEVICES_V/W_0 */
  97. uint crc_clk_out_enb_vw[TEGRA_CLK_REGS_VW]; /* _CLK_OUT_ENB_V/W_0 */
  98. uint crc_cclkg_brst_pol; /* _CCLKG_BURST_POLICY_0, 0x368 */
  99. uint crc_super_cclkg_div; /* _SUPER_CCLKG_DIVIDER_0, 0x36C */
  100. uint crc_cclklp_brst_pol; /* _CCLKLP_BURST_POLICY_0, 0x370 */
  101. uint crc_super_cclkp_div; /* _SUPER_CCLKLP_DIVIDER_0, 0x374 */
  102. uint crc_clk_cpug_cmplx; /* _CLK_CPUG_CMPLX_0, 0x378 */
  103. uint crc_clk_cpulp_cmplx; /* _CLK_CPULP_CMPLX_0, 0x37C */
  104. uint crc_cpu_softrst_ctrl; /* _CPU_SOFTRST_CTRL_0, 0x380 */
  105. uint crc_reserved33[11]; /* _reserved_33, 0x384-3ac */
  106. uint crc_clk_src_vw[TEGRA_CLK_SOURCES_VW]; /* _G3D2_0..., 0x3b0-0x42c */
  107. /* _RST_DEV_V/W_SET_0 0x430 ~ 0x43c */
  108. struct clk_set_clr crc_rst_dev_ex_vw[TEGRA_CLK_REGS_VW];
  109. /* _CLK_ENB_V/W_CLR_0 0x440 ~ 0x44c */
  110. struct clk_set_clr crc_clk_enb_ex_vw[TEGRA_CLK_REGS_VW];
  111. uint crc_reserved40[12]; /* _reserved_40, 0x450-47C */
  112. uint crc_pll_cfg0; /* _PLL_CFG0_0, 0x480 */
  113. uint crc_pll_cfg1; /* _PLL_CFG1_0, 0x484 */
  114. uint crc_pll_cfg2; /* _PLL_CFG2_0, 0x488 */
  115. };
  116. /* CLK_RST_CONTROLLER_CLK_CPU_CMPLX_0 */
  117. #define CPU3_CLK_STP_SHIFT 11
  118. #define CPU2_CLK_STP_SHIFT 10
  119. #define CPU1_CLK_STP_SHIFT 9
  120. #define CPU0_CLK_STP_SHIFT 8
  121. #define CPU0_CLK_STP_MASK (1U << CPU0_CLK_STP_SHIFT)
  122. /* CLK_RST_CONTROLLER_PLLx_BASE_0 */
  123. #define PLL_BYPASS_SHIFT 31
  124. #define PLL_BYPASS_MASK (1U << PLL_BYPASS_SHIFT)
  125. #define PLL_ENABLE_SHIFT 30
  126. #define PLL_ENABLE_MASK (1U << PLL_ENABLE_SHIFT)
  127. #define PLL_BASE_OVRRIDE_MASK (1U << 28)
  128. #define PLL_DIVP_SHIFT 20
  129. #define PLL_DIVP_MASK (7U << PLL_DIVP_SHIFT)
  130. #define PLL_DIVN_SHIFT 8
  131. #define PLL_DIVN_MASK (0x3ffU << PLL_DIVN_SHIFT)
  132. #define PLL_DIVM_SHIFT 0
  133. #define PLL_DIVM_MASK (0x1f << PLL_DIVM_SHIFT)
  134. /* CLK_RST_CONTROLLER_PLLx_OUTx_0 */
  135. #define PLL_OUT_RSTN (1 << 0)
  136. #define PLL_OUT_CLKEN (1 << 1)
  137. #define PLL_OUT_OVRRIDE (1 << 2)
  138. #define PLL_OUT_RATIO_SHIFT 8
  139. #define PLL_OUT_RATIO_MASK (0xffU << PLL_OUT_RATIO_SHIFT)
  140. /* CLK_RST_CONTROLLER_PLLx_MISC_0 */
  141. #define PLL_DCCON_SHIFT 20
  142. #define PLL_DCCON_MASK (1U << PLL_DCCON_SHIFT)
  143. #define PLL_LOCK_ENABLE_SHIFT 18
  144. #define PLL_LOCK_ENABLE_MASK (1U << PLL_LOCK_ENABLE_SHIFT)
  145. #define PLL_CPCON_SHIFT 8
  146. #define PLL_CPCON_MASK (15U << PLL_CPCON_SHIFT)
  147. #define PLL_LFCON_SHIFT 4
  148. #define PLL_LFCON_MASK (15U << PLL_LFCON_SHIFT)
  149. #define PLLU_VCO_FREQ_SHIFT 20
  150. #define PLLU_VCO_FREQ_MASK (1U << PLLU_VCO_FREQ_SHIFT)
  151. #define PLLP_OUT1_OVR (1 << 2)
  152. #define PLLP_OUT2_OVR (1 << 18)
  153. #define PLLP_OUT3_OVR (1 << 2)
  154. #define PLLP_OUT4_OVR (1 << 18)
  155. #define PLLP_OUT1_RATIO 8
  156. #define PLLP_OUT2_RATIO 24
  157. #define PLLP_OUT3_RATIO 8
  158. #define PLLP_OUT4_RATIO 24
  159. enum {
  160. IN_408_OUT_204_DIVISOR = 2,
  161. IN_408_OUT_102_DIVISOR = 6,
  162. IN_408_OUT_48_DIVISOR = 15,
  163. IN_408_OUT_9_6_DIVISOR = 83,
  164. };
  165. /* CLK_RST_CONTROLLER_OSC_CTRL_0 */
  166. #define OSC_XOBP_SHIFT 1
  167. #define OSC_XOBP_MASK (1U << OSC_XOBP_SHIFT)
  168. /*
  169. * CLK_RST_CONTROLLER_CLK_SOURCE_x_OUT_0 - the mask here is normally 8 bits
  170. * but can be 16. We could use knowledge we have to restrict the mask in
  171. * the 8-bit cases (the divider_bits value returned by
  172. * get_periph_clock_source()) but it does not seem worth it since the code
  173. * already checks the ranges of values it is writing, in clk_get_divider().
  174. */
  175. #define OUT_CLK_DIVISOR_SHIFT 0
  176. #define OUT_CLK_DIVISOR_MASK (0xffff << OUT_CLK_DIVISOR_SHIFT)
  177. #define OUT_CLK_SOURCE_SHIFT 30
  178. #define OUT_CLK_SOURCE_MASK (3U << OUT_CLK_SOURCE_SHIFT)
  179. #define OUT_CLK_SOURCE4_SHIFT 28
  180. #define OUT_CLK_SOURCE4_MASK (15U << OUT_CLK_SOURCE4_SHIFT)
  181. /* CLK_RST_CONTROLLER_SCLK_BURST_POLICY */
  182. #define SCLK_SYS_STATE_SHIFT 28U
  183. #define SCLK_SYS_STATE_MASK (15U << SCLK_SYS_STATE_SHIFT)
  184. enum {
  185. SCLK_SYS_STATE_STDBY,
  186. SCLK_SYS_STATE_IDLE,
  187. SCLK_SYS_STATE_RUN,
  188. SCLK_SYS_STATE_IRQ = 4U,
  189. SCLK_SYS_STATE_FIQ = 8U,
  190. };
  191. #define SCLK_COP_FIQ_MASK (1 << 27)
  192. #define SCLK_CPU_FIQ_MASK (1 << 26)
  193. #define SCLK_COP_IRQ_MASK (1 << 25)
  194. #define SCLK_CPU_IRQ_MASK (1 << 24)
  195. #define SCLK_SWAKEUP_FIQ_SOURCE_SHIFT 12
  196. #define SCLK_SWAKEUP_FIQ_SOURCE_MASK \
  197. (7 << SCLK_SWAKEUP_FIQ_SOURCE_SHIFT)
  198. #define SCLK_SWAKEUP_IRQ_SOURCE_SHIFT 8
  199. #define SCLK_SWAKEUP_IRQ_SOURCE_MASK \
  200. (7 << SCLK_SWAKEUP_FIQ_SOURCE_SHIFT)
  201. #define SCLK_SWAKEUP_RUN_SOURCE_SHIFT 4
  202. #define SCLK_SWAKEUP_RUN_SOURCE_MASK \
  203. (7 << SCLK_SWAKEUP_FIQ_SOURCE_SHIFT)
  204. #define SCLK_SWAKEUP_IDLE_SOURCE_SHIFT 0
  205. #define SCLK_SWAKEUP_IDLE_SOURCE_MASK \
  206. (7 << SCLK_SWAKEUP_FIQ_SOURCE_SHIFT)
  207. enum {
  208. SCLK_SOURCE_CLKM,
  209. SCLK_SOURCE_PLLC_OUT1,
  210. SCLK_SOURCE_PLLP_OUT4,
  211. SCLK_SOURCE_PLLP_OUT3,
  212. SCLK_SOURCE_PLLP_OUT2,
  213. SCLK_SOURCE_CLKD,
  214. SCLK_SOURCE_CLKS,
  215. SCLK_SOURCE_PLLM_OUT1,
  216. };
  217. #define SCLK_SWAKE_FIQ_SRC_PLLM_OUT1 (7 << 12)
  218. #define SCLK_SWAKE_IRQ_SRC_PLLM_OUT1 (7 << 8)
  219. #define SCLK_SWAKE_RUN_SRC_PLLM_OUT1 (7 << 4)
  220. #define SCLK_SWAKE_IDLE_SRC_PLLM_OUT1 (7 << 0)
  221. /* CLK_RST_CONTROLLER_SUPER_SCLK_DIVIDER */
  222. #define SUPER_SCLK_ENB_SHIFT 31U
  223. #define SUPER_SCLK_ENB_MASK (1U << 31)
  224. #define SUPER_SCLK_DIVIDEND_SHIFT 8
  225. #define SUPER_SCLK_DIVIDEND_MASK (0xff << SUPER_SCLK_DIVIDEND_SHIFT)
  226. #define SUPER_SCLK_DIVISOR_SHIFT 0
  227. #define SUPER_SCLK_DIVISOR_MASK (0xff << SUPER_SCLK_DIVISOR_SHIFT)
  228. /* CLK_RST_CONTROLLER_CLK_SYSTEM_RATE */
  229. #define CLK_SYS_RATE_HCLK_DISABLE_SHIFT 7
  230. #define CLK_SYS_RATE_HCLK_DISABLE_MASK (1 << CLK_SYS_RATE_HCLK_DISABLE_SHIFT)
  231. #define CLK_SYS_RATE_AHB_RATE_SHIFT 4
  232. #define CLK_SYS_RATE_AHB_RATE_MASK (3 << CLK_SYS_RATE_AHB_RATE_SHIFT)
  233. #define CLK_SYS_RATE_PCLK_DISABLE_SHIFT 3
  234. #define CLK_SYS_RATE_PCLK_DISABLE_MASK (1 << CLK_SYS_RATE_PCLK_DISABLE_SHIFT)
  235. #define CLK_SYS_RATE_APB_RATE_SHIFT 0
  236. #define CLK_SYS_RATE_APB_RATE_MASK (3 << CLK_SYS_RATE_AHB_RATE_SHIFT)
  237. #endif /* _TEGRA_CLK_RST_H_ */