1
0

0023-MIPS-ath79-pass-PLL-base-to-clock-init-functions.patch 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. From 6350b2c36c522fecbc91a80b63f49319dafd2a72 Mon Sep 17 00:00:00 2001
  2. From: Felix Fietkau <nbd@nbd.name>
  3. Date: Tue, 6 Mar 2018 13:23:20 +0100
  4. Subject: [PATCH 23/33] MIPS: ath79: pass PLL base to clock init functions
  5. Preparation for passing the mapped base via DT
  6. Signed-off-by: Felix Fietkau <nbd@nbd.name>
  7. Signed-off-by: John Crispin <john@phrozen.org>
  8. ---
  9. arch/mips/ath79/clock.c | 60 ++++++++++++++++++++++++-------------------------
  10. 1 file changed, 30 insertions(+), 30 deletions(-)
  11. --- a/arch/mips/ath79/clock.c
  12. +++ b/arch/mips/ath79/clock.c
  13. @@ -80,7 +80,7 @@ static struct clk * __init ath79_set_ff_
  14. return clk;
  15. }
  16. -static void __init ar71xx_clocks_init(void)
  17. +static void __init ar71xx_clocks_init(void __iomem *pll_base)
  18. {
  19. unsigned long ref_rate;
  20. unsigned long cpu_rate;
  21. @@ -92,7 +92,7 @@ static void __init ar71xx_clocks_init(vo
  22. ref_rate = AR71XX_BASE_FREQ;
  23. - pll = ath79_pll_rr(AR71XX_PLL_REG_CPU_CONFIG);
  24. + pll = __raw_readl(pll_base + AR71XX_PLL_REG_CPU_CONFIG);
  25. div = ((pll >> AR71XX_PLL_FB_SHIFT) & AR71XX_PLL_FB_MASK) + 1;
  26. freq = div * ref_rate;
  27. @@ -130,13 +130,13 @@ static void __init ar724x_clk_init(struc
  28. ath79_set_ff_clk(ATH79_CLK_AHB, "ref", mult, div * ahb_div);
  29. }
  30. -static void __init ar724x_clocks_init(void)
  31. +static void __init ar724x_clocks_init(void __iomem *pll_base)
  32. {
  33. struct clk *ref_clk;
  34. ref_clk = ath79_set_clk(ATH79_CLK_REF, AR724X_BASE_FREQ);
  35. - ar724x_clk_init(ref_clk, ath79_pll_base);
  36. + ar724x_clk_init(ref_clk, pll_base);
  37. }
  38. static void __init ar9330_clk_init(struct clk *ref_clk, void __iomem *pll_base)
  39. @@ -197,7 +197,7 @@ static void __init ar9330_clk_init(struc
  40. ref_div * out_div * ahb_div);
  41. }
  42. -static void __init ar933x_clocks_init(void)
  43. +static void __init ar933x_clocks_init(void __iomem *pll_base)
  44. {
  45. struct clk *ref_clk;
  46. unsigned long ref_rate;
  47. @@ -234,7 +234,7 @@ static u32 __init ar934x_get_pll_freq(u3
  48. return ret;
  49. }
  50. -static void __init ar934x_clocks_init(void)
  51. +static void __init ar934x_clocks_init(void __iomem *pll_base)
  52. {
  53. unsigned long ref_rate;
  54. unsigned long cpu_rate;
  55. @@ -265,7 +265,7 @@ static void __init ar934x_clocks_init(vo
  56. AR934X_SRIF_DPLL1_REFDIV_MASK;
  57. frac = 1 << 18;
  58. } else {
  59. - pll = ath79_pll_rr(AR934X_PLL_CPU_CONFIG_REG);
  60. + pll = __raw_readl(pll_base + AR934X_PLL_CPU_CONFIG_REG);
  61. out_div = (pll >> AR934X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
  62. AR934X_PLL_CPU_CONFIG_OUTDIV_MASK;
  63. ref_div = (pll >> AR934X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
  64. @@ -292,7 +292,7 @@ static void __init ar934x_clocks_init(vo
  65. AR934X_SRIF_DPLL1_REFDIV_MASK;
  66. frac = 1 << 18;
  67. } else {
  68. - pll = ath79_pll_rr(AR934X_PLL_DDR_CONFIG_REG);
  69. + pll = __raw_readl(pll_base + AR934X_PLL_DDR_CONFIG_REG);
  70. out_div = (pll >> AR934X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
  71. AR934X_PLL_DDR_CONFIG_OUTDIV_MASK;
  72. ref_div = (pll >> AR934X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
  73. @@ -307,7 +307,7 @@ static void __init ar934x_clocks_init(vo
  74. ddr_pll = ar934x_get_pll_freq(ref_rate, ref_div, nint,
  75. nfrac, frac, out_div);
  76. - clk_ctrl = ath79_pll_rr(AR934X_PLL_CPU_DDR_CLK_CTRL_REG);
  77. + clk_ctrl = __raw_readl(pll_base + AR934X_PLL_CPU_DDR_CLK_CTRL_REG);
  78. postdiv = (clk_ctrl >> AR934X_PLL_CPU_DDR_CLK_CTRL_CPU_POST_DIV_SHIFT) &
  79. AR934X_PLL_CPU_DDR_CLK_CTRL_CPU_POST_DIV_MASK;
  80. @@ -347,7 +347,7 @@ static void __init ar934x_clocks_init(vo
  81. iounmap(dpll_base);
  82. }
  83. -static void __init qca953x_clocks_init(void)
  84. +static void __init qca953x_clocks_init(void __iomem *pll_base)
  85. {
  86. unsigned long ref_rate;
  87. unsigned long cpu_rate;
  88. @@ -363,7 +363,7 @@ static void __init qca953x_clocks_init(v
  89. else
  90. ref_rate = 25 * 1000 * 1000;
  91. - pll = ath79_pll_rr(QCA953X_PLL_CPU_CONFIG_REG);
  92. + pll = __raw_readl(pll_base + QCA953X_PLL_CPU_CONFIG_REG);
  93. out_div = (pll >> QCA953X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
  94. QCA953X_PLL_CPU_CONFIG_OUTDIV_MASK;
  95. ref_div = (pll >> QCA953X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
  96. @@ -377,7 +377,7 @@ static void __init qca953x_clocks_init(v
  97. cpu_pll += frac * (ref_rate >> 6) / ref_div;
  98. cpu_pll /= (1 << out_div);
  99. - pll = ath79_pll_rr(QCA953X_PLL_DDR_CONFIG_REG);
  100. + pll = __raw_readl(pll_base + QCA953X_PLL_DDR_CONFIG_REG);
  101. out_div = (pll >> QCA953X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
  102. QCA953X_PLL_DDR_CONFIG_OUTDIV_MASK;
  103. ref_div = (pll >> QCA953X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
  104. @@ -391,7 +391,7 @@ static void __init qca953x_clocks_init(v
  105. ddr_pll += frac * (ref_rate >> 6) / (ref_div << 4);
  106. ddr_pll /= (1 << out_div);
  107. - clk_ctrl = ath79_pll_rr(QCA953X_PLL_CLK_CTRL_REG);
  108. + clk_ctrl = __raw_readl(pll_base + QCA953X_PLL_CLK_CTRL_REG);
  109. postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT) &
  110. QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_MASK;
  111. @@ -429,7 +429,7 @@ static void __init qca953x_clocks_init(v
  112. ath79_set_clk(ATH79_CLK_AHB, ahb_rate);
  113. }
  114. -static void __init qca955x_clocks_init(void)
  115. +static void __init qca955x_clocks_init(void __iomem *pll_base)
  116. {
  117. unsigned long ref_rate;
  118. unsigned long cpu_rate;
  119. @@ -445,7 +445,7 @@ static void __init qca955x_clocks_init(v
  120. else
  121. ref_rate = 25 * 1000 * 1000;
  122. - pll = ath79_pll_rr(QCA955X_PLL_CPU_CONFIG_REG);
  123. + pll = __raw_readl(pll_base + QCA955X_PLL_CPU_CONFIG_REG);
  124. out_div = (pll >> QCA955X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
  125. QCA955X_PLL_CPU_CONFIG_OUTDIV_MASK;
  126. ref_div = (pll >> QCA955X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
  127. @@ -459,7 +459,7 @@ static void __init qca955x_clocks_init(v
  128. cpu_pll += frac * ref_rate / (ref_div * (1 << 6));
  129. cpu_pll /= (1 << out_div);
  130. - pll = ath79_pll_rr(QCA955X_PLL_DDR_CONFIG_REG);
  131. + pll = __raw_readl(pll_base + QCA955X_PLL_DDR_CONFIG_REG);
  132. out_div = (pll >> QCA955X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
  133. QCA955X_PLL_DDR_CONFIG_OUTDIV_MASK;
  134. ref_div = (pll >> QCA955X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
  135. @@ -473,7 +473,7 @@ static void __init qca955x_clocks_init(v
  136. ddr_pll += frac * ref_rate / (ref_div * (1 << 10));
  137. ddr_pll /= (1 << out_div);
  138. - clk_ctrl = ath79_pll_rr(QCA955X_PLL_CLK_CTRL_REG);
  139. + clk_ctrl = __raw_readl(pll_base + QCA955X_PLL_CLK_CTRL_REG);
  140. postdiv = (clk_ctrl >> QCA955X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT) &
  141. QCA955X_PLL_CLK_CTRL_CPU_POST_DIV_MASK;
  142. @@ -511,7 +511,7 @@ static void __init qca955x_clocks_init(v
  143. ath79_set_clk(ATH79_CLK_AHB, ahb_rate);
  144. }
  145. -static void __init qca956x_clocks_init(void)
  146. +static void __init qca956x_clocks_init(void __iomem *pll_base)
  147. {
  148. unsigned long ref_rate;
  149. unsigned long cpu_rate;
  150. @@ -537,13 +537,13 @@ static void __init qca956x_clocks_init(v
  151. else
  152. ref_rate = 25 * 1000 * 1000;
  153. - pll = ath79_pll_rr(QCA956X_PLL_CPU_CONFIG_REG);
  154. + pll = __raw_readl(pll_base + QCA956X_PLL_CPU_CONFIG_REG);
  155. out_div = (pll >> QCA956X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
  156. QCA956X_PLL_CPU_CONFIG_OUTDIV_MASK;
  157. ref_div = (pll >> QCA956X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
  158. QCA956X_PLL_CPU_CONFIG_REFDIV_MASK;
  159. - pll = ath79_pll_rr(QCA956X_PLL_CPU_CONFIG1_REG);
  160. + pll = __raw_readl(pll_base + QCA956X_PLL_CPU_CONFIG1_REG);
  161. nint = (pll >> QCA956X_PLL_CPU_CONFIG1_NINT_SHIFT) &
  162. QCA956X_PLL_CPU_CONFIG1_NINT_MASK;
  163. hfrac = (pll >> QCA956X_PLL_CPU_CONFIG1_NFRAC_H_SHIFT) &
  164. @@ -556,12 +556,12 @@ static void __init qca956x_clocks_init(v
  165. cpu_pll += (hfrac >> 13) * ref_rate / ref_div;
  166. cpu_pll /= (1 << out_div);
  167. - pll = ath79_pll_rr(QCA956X_PLL_DDR_CONFIG_REG);
  168. + pll = __raw_readl(pll_base + QCA956X_PLL_DDR_CONFIG_REG);
  169. out_div = (pll >> QCA956X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
  170. QCA956X_PLL_DDR_CONFIG_OUTDIV_MASK;
  171. ref_div = (pll >> QCA956X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
  172. QCA956X_PLL_DDR_CONFIG_REFDIV_MASK;
  173. - pll = ath79_pll_rr(QCA956X_PLL_DDR_CONFIG1_REG);
  174. + pll = __raw_readl(pll_base + QCA956X_PLL_DDR_CONFIG1_REG);
  175. nint = (pll >> QCA956X_PLL_DDR_CONFIG1_NINT_SHIFT) &
  176. QCA956X_PLL_DDR_CONFIG1_NINT_MASK;
  177. hfrac = (pll >> QCA956X_PLL_DDR_CONFIG1_NFRAC_H_SHIFT) &
  178. @@ -574,7 +574,7 @@ static void __init qca956x_clocks_init(v
  179. ddr_pll += (hfrac >> 13) * ref_rate / ref_div;
  180. ddr_pll /= (1 << out_div);
  181. - clk_ctrl = ath79_pll_rr(QCA956X_PLL_CLK_CTRL_REG);
  182. + clk_ctrl = __raw_readl(pll_base + QCA956X_PLL_CLK_CTRL_REG);
  183. postdiv = (clk_ctrl >> QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT) &
  184. QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_MASK;
  185. @@ -618,19 +618,19 @@ void __init ath79_clocks_init(void)
  186. const char *uart;
  187. if (soc_is_ar71xx())
  188. - ar71xx_clocks_init();
  189. + ar71xx_clocks_init(ath79_pll_base);
  190. else if (soc_is_ar724x() || soc_is_ar913x())
  191. - ar724x_clocks_init();
  192. + ar724x_clocks_init(ath79_pll_base);
  193. else if (soc_is_ar933x())
  194. - ar933x_clocks_init();
  195. + ar933x_clocks_init(ath79_pll_base);
  196. else if (soc_is_ar934x())
  197. - ar934x_clocks_init();
  198. + ar934x_clocks_init(ath79_pll_base);
  199. else if (soc_is_qca953x())
  200. - qca953x_clocks_init();
  201. + qca953x_clocks_init(ath79_pll_base);
  202. else if (soc_is_qca955x())
  203. - qca955x_clocks_init();
  204. + qca955x_clocks_init(ath79_pll_base);
  205. else if (soc_is_qca956x() || soc_is_tp9343())
  206. - qca956x_clocks_init();
  207. + qca956x_clocks_init(ath79_pll_base);
  208. else
  209. BUG();