clock_manager_arria10.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /*
  2. * Copyright (C) 2016-2017 Intel Corporation
  3. *
  4. * SPDX-License-Identifier: GPL-2.0
  5. */
  6. #ifndef CLOCK_MANAGER_ARRIA10
  7. #define CLOCK_MANAGER_ARRIA10
  8. #ifndef __ASSEMBLER__
  9. struct socfpga_clock_manager_main_pll {
  10. u32 vco0;
  11. u32 vco1;
  12. u32 en;
  13. u32 ens;
  14. u32 enr;
  15. u32 bypass;
  16. u32 bypasss;
  17. u32 bypassr;
  18. u32 mpuclk;
  19. u32 nocclk;
  20. u32 cntr2clk;
  21. u32 cntr3clk;
  22. u32 cntr4clk;
  23. u32 cntr5clk;
  24. u32 cntr6clk;
  25. u32 cntr7clk;
  26. u32 cntr8clk;
  27. u32 cntr9clk;
  28. u32 pad_0x48_0x5b[5];
  29. u32 cntr15clk;
  30. u32 outrst;
  31. u32 outrststat;
  32. u32 nocdiv;
  33. u32 pad_0x6c_0x80[5];
  34. };
  35. struct socfpga_clock_manager_per_pll {
  36. u32 vco0;
  37. u32 vco1;
  38. u32 en;
  39. u32 ens;
  40. u32 enr;
  41. u32 bypass;
  42. u32 bypasss;
  43. u32 bypassr;
  44. u32 pad_0x20_0x27[2];
  45. u32 cntr2clk;
  46. u32 cntr3clk;
  47. u32 cntr4clk;
  48. u32 cntr5clk;
  49. u32 cntr6clk;
  50. u32 cntr7clk;
  51. u32 cntr8clk;
  52. u32 cntr9clk;
  53. u32 pad_0x48_0x5f[6];
  54. u32 outrst;
  55. u32 outrststat;
  56. u32 emacctl;
  57. u32 gpiodiv;
  58. u32 pad_0x70_0x80[4];
  59. };
  60. struct socfpga_clock_manager_altera {
  61. u32 mpuclk;
  62. u32 nocclk;
  63. u32 mainmisc0;
  64. u32 mainmisc1;
  65. u32 perimisc0;
  66. u32 perimisc1;
  67. };
  68. struct socfpga_clock_manager {
  69. /* clkmgr */
  70. u32 ctrl;
  71. u32 intr;
  72. u32 intrs;
  73. u32 intrr;
  74. u32 intren;
  75. u32 intrens;
  76. u32 intrenr;
  77. u32 stat;
  78. u32 testioctrl;
  79. u32 _pad_0x24_0x40[7];
  80. /* mainpllgrp */
  81. struct socfpga_clock_manager_main_pll main_pll;
  82. /* perpllgrp */
  83. struct socfpga_clock_manager_per_pll per_pll;
  84. struct socfpga_clock_manager_altera altera;
  85. };
  86. void cm_use_intosc(void);
  87. unsigned int cm_get_noc_clk_hz(void);
  88. unsigned int cm_get_l4_noc_hz(unsigned int nocdivshift);
  89. int cm_basic_init(const void *blob);
  90. unsigned int cm_get_l4_sp_clk_hz(void);
  91. unsigned int cm_get_main_vco_clk_hz(void);
  92. unsigned int cm_get_per_vco_clk_hz(void);
  93. unsigned long cm_get_mpu_clk_hz(void);
  94. unsigned int cm_get_qspi_controller_clk_hz(void);
  95. unsigned int cm_get_mmc_controller_clk_hz(void);
  96. unsigned int cm_get_spi_controller_clk_hz(void);
  97. #endif /* __ASSEMBLER__ */
  98. #define CLKMGR_ALTERAGRP_MPU_CLK_OFFSET 0x140
  99. #define CLKMGR_MAINPLL_NOC_CLK_OFFSET 0x144
  100. #define LOCKED_MASK (CLKMGR_CLKMGR_STAT_MAINPLLLOCKED_SET_MSK | \
  101. CLKMGR_CLKMGR_STAT_PERPLLLOCKED_SET_MSK)
  102. /* value */
  103. #define CLKMGR_MAINPLL_BYPASS_RESET 0x0000003f
  104. #define CLKMGR_PERPLL_BYPASS_RESET 0x000000ff
  105. #define CLKMGR_MAINPLL_VCO0_RESET 0x00010053
  106. #define CLKMGR_MAINPLL_VCO1_RESET 0x00010001
  107. #define CLKMGR_PERPLL_VCO0_RESET 0x00010053
  108. #define CLKMGR_PERPLL_VCO1_RESET 0x00010001
  109. #define CLKMGR_MAINPLL_VCO0_PSRC_EOSC 0x0
  110. #define CLKMGR_MAINPLL_VCO0_PSRC_E_INTOSC 0x1
  111. #define CLKMGR_MAINPLL_VCO0_PSRC_F2S 0x2
  112. #define CLKMGR_PERPLL_VCO0_PSRC_EOSC 0x0
  113. #define CLKMGR_PERPLL_VCO0_PSRC_E_INTOSC 0x1
  114. #define CLKMGR_PERPLL_VCO0_PSRC_F2S 0x2
  115. #define CLKMGR_PERPLL_VCO0_PSRC_MAIN 0x3
  116. /* mask */
  117. #define CLKMGR_MAINPLL_EN_S2FUSER0CLKEN_SET_MSK BIT(6)
  118. #define CLKMGR_MAINPLL_EN_HMCPLLREFCLKEN_SET_MSK BIT(7)
  119. #define CLKMGR_CLKMGR_STAT_MAINPLLLOCKED_SET_MSK BIT(8)
  120. #define CLKMGR_CLKMGR_STAT_PERPLLLOCKED_SET_MSK BIT(9)
  121. #define CLKMGR_CLKMGR_STAT_BOOTCLKSRC_SET_MSK BIT(17)
  122. #define CLKMGR_MAINPLL_VCO0_BGPWRDN_SET_MSK BIT(0)
  123. #define CLKMGR_MAINPLL_VCO0_PWRDN_SET_MSK BIT(1)
  124. #define CLKMGR_MAINPLL_VCO0_EN_SET_MSK BIT(2)
  125. #define CLKMGR_MAINPLL_VCO0_OUTRSTALL_SET_MSK BIT(3)
  126. #define CLKMGR_MAINPLL_VCO0_REGEXTSEL_SET_MSK BIT(4)
  127. #define CLKMGR_PERPLL_VCO0_BGPWRDN_SET_MSK BIT(0)
  128. #define CLKMGR_PERPLL_VCO0_PWRDN_SET_MSK BIT(1)
  129. #define CLKMGR_PERPLL_VCO0_EN_SET_MSK BIT(2)
  130. #define CLKMGR_PERPLL_VCO0_OUTRSTALL_SET_MSK BIT(3)
  131. #define CLKMGR_PERPLL_VCO0_REGEXTSEL_SET_MSK BIT(4)
  132. #define CLKMGR_CLKMGR_INTR_MAINPLLACHIEVED_SET_MSK BIT(0)
  133. #define CLKMGR_CLKMGR_INTR_PERPLLACHIEVED_SET_MSK BIT(1)
  134. #define CLKMGR_CLKMGR_INTR_MAINPLLLOST_SET_MSK BIT(2)
  135. #define CLKMGR_CLKMGR_INTR_PERPLLLOST_SET_MSK BIT(3)
  136. #define CLKMGR_CLKMGR_INTR_MAINPLLRFSLIP_SET_MSK BIT(8)
  137. #define CLKMGR_CLKMGR_INTR_PERPLLRFSLIP_SET_MSK BIT(9)
  138. #define CLKMGR_CLKMGR_INTR_MAINPLLFBSLIP_SET_MSK BIT(10)
  139. #define CLKMGR_CLKMGR_INTR_PERPLLFBSLIP_SET_MSK BIT(11)
  140. #define CLKMGR_CLKMGR_CTL_BOOTMOD_SET_MSK BIT(0)
  141. #define CLKMGR_CLKMGR_CTL_BOOTCLK_INTOSC_SET_MSK 0x00000300
  142. #define CLKMGR_PERPLL_EN_RESET 0x00000f7f
  143. #define CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK BIT(5)
  144. #define CLKMGR_MAINPLL_VCO0_PSRC_MSK 0x00000003
  145. #define CLKMGR_MAINPLL_VCO1_NUMER_MSK 0x00001fff
  146. #define CLKMGR_MAINPLL_VCO1_DENOM_MSK 0x0000003f
  147. #define CLKMGR_MAINPLL_CNTRCLK_MSK 0x000003ff
  148. #define CLKMGR_PERPLL_VCO0_PSRC_MSK 0x00000003
  149. #define CLKMGR_PERPLL_VCO1_NUMER_MSK 0x00001fff
  150. #define CLKMGR_PERPLL_VCO1_DENOM_MSK 0x0000003f
  151. #define CLKMGR_PERPLL_CNTRCLK_MSK 0x000003ff
  152. #define CLKMGR_MAINPLL_MPUCLK_SRC_MSK 0x00000007
  153. #define CLKMGR_MAINPLL_MPUCLK_CNT_MSK 0x000003ff
  154. #define CLKMGR_MAINPLL_MPUCLK_SRC_MAIN 0
  155. #define CLKMGR_MAINPLL_MPUCLK_SRC_PERI 1
  156. #define CLKMGR_MAINPLL_MPUCLK_SRC_OSC1 2
  157. #define CLKMGR_MAINPLL_MPUCLK_SRC_INTOSC 3
  158. #define CLKMGR_MAINPLL_MPUCLK_SRC_FPGA 4
  159. #define CLKMGR_MAINPLL_NOCDIV_MSK 0x00000003
  160. #define CLKMGR_MAINPLL_NOCCLK_CNT_MSK 0x000003ff
  161. #define CLKMGR_MAINPLL_NOCCLK_SRC_MSK 0x00000007
  162. #define CLKMGR_MAINPLL_NOCCLK_SRC_MAIN 0
  163. #define CLKMGR_MAINPLL_NOCCLK_SRC_PERI 1
  164. #define CLKMGR_MAINPLL_NOCCLK_SRC_OSC1 2
  165. #define CLKMGR_MAINPLL_NOCCLK_SRC_INTOSC 3
  166. #define CLKMGR_MAINPLL_NOCCLK_SRC_FPGA 4
  167. #define CLKMGR_PERPLLGRP_SRC_MSK 0x00000007
  168. #define CLKMGR_PERPLLGRP_SRC_MAIN 0
  169. #define CLKMGR_PERPLLGRP_SRC_PERI 1
  170. #define CLKMGR_PERPLLGRP_SRC_OSC1 2
  171. #define CLKMGR_PERPLLGRP_SRC_INTOSC 3
  172. #define CLKMGR_PERPLLGRP_SRC_FPGA 4
  173. /* bit shifting macro */
  174. #define CLKMGR_MAINPLL_VCO0_PSRC_LSB 8
  175. #define CLKMGR_PERPLL_VCO0_PSRC_LSB 8
  176. #define CLKMGR_MAINPLL_VCO1_DENOM_LSB 16
  177. #define CLKMGR_PERPLL_VCO1_DENOM_LSB 16
  178. #define CLKMGR_MAINPLL_NOCCLK_PERICNT_LSB 16
  179. #define CLKMGR_MAINPLL_NOCCLK_SRC_LSB 16
  180. #define CLKMGR_MAINPLL_NOCDIV_L4MAINCLK_LSB 0
  181. #define CLKMGR_MAINPLL_NOCDIV_L4MPCLK_LSB 8
  182. #define CLKMGR_MAINPLL_NOCDIV_L4SPCLK_LSB 16
  183. #define CLKMGR_MAINPLL_NOCDIV_CSATCLK_LSB 24
  184. #define CLKMGR_MAINPLL_NOCDIV_CSTRACECLK_LSB 26
  185. #define CLKMGR_MAINPLL_NOCDIV_CSPDBGCLK_LSB 28
  186. #define CLKMGR_MAINPLL_MPUCLK_SRC_LSB 16
  187. #define CLKMGR_MAINPLL_MPUCLK_PERICNT_LSB 16
  188. #define CLKMGR_MAINPLL_NOCCLK_SRC_LSB 16
  189. #define CLKMGR_MAINPLL_CNTR7CLK_SRC_LSB 16
  190. #define CLKMGR_MAINPLL_CNTR9CLK_SRC_LSB 16
  191. #define CLKMGR_PERPLL_CNTR2CLK_SRC_LSB 16
  192. #define CLKMGR_PERPLL_CNTR3CLK_SRC_LSB 16
  193. #define CLKMGR_PERPLL_CNTR4CLK_SRC_LSB 16
  194. #define CLKMGR_PERPLL_CNTR5CLK_SRC_LSB 16
  195. #define CLKMGR_PERPLL_CNTR6CLK_SRC_LSB 16
  196. #define CLKMGR_PERPLL_CNTR8CLK_SRC_LSB 16
  197. #define CLKMGR_PERPLL_EMACCTL_EMAC0SEL_LSB 26
  198. #define CLKMGR_PERPLL_EMACCTL_EMAC1SEL_LSB 27
  199. #define CLKMGR_PERPLL_EMACCTL_EMAC2SEL_LSB 28
  200. /* PLL ramping work around */
  201. #define CLKMGR_PLL_RAMP_MPUCLK_THRESHOLD_HZ 900000000
  202. #define CLKMGR_PLL_RAMP_NOCCLK_THRESHOLD_HZ 300000000
  203. #define CLKMGR_PLL_RAMP_MPUCLK_INCREMENT_HZ 100000000
  204. #define CLKMGR_PLL_RAMP_NOCCLK_INCREMENT_HZ 33000000
  205. #define CLKMGR_STAT_BUSY BIT(0)
  206. #endif /* CLOCK_MANAGER_ARRIA10 */