0030-MIPS-ath79-pass-PLL-base-to-clock-init-functions.patch 8.5 KB

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