clock_manager_arria10.h 6.9 KB

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