blob: 050f6553f3987ae847fb3d4220363e1b372e04c5 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Gabor Juhosd4a67d92011-01-04 21:28:14 +01002/*
3 * Atheros AR71XX/AR724X/AR913X common routines
4 *
Gabor Juhos88896122012-03-14 10:45:22 +01005 * Copyright (C) 2010-2011 Jaiganesh Narayanan <jnarayanan@atheros.com>
Gabor Juhosd4a67d92011-01-04 21:28:14 +01006 * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
7 *
Gabor Juhos88896122012-03-14 10:45:22 +01008 * Parts of this file are based on Atheros' 2.6.15/2.6.31 BSP
Gabor Juhosd4a67d92011-01-04 21:28:14 +01009 */
10
11#include <linux/kernel.h>
Gabor Juhosd4a67d92011-01-04 21:28:14 +010012#include <linux/init.h>
Stephen Boyd62e59c42019-04-18 15:20:22 -070013#include <linux/io.h>
Gabor Juhosd4a67d92011-01-04 21:28:14 +010014#include <linux/err.h>
15#include <linux/clk.h>
Gabor Juhos2c4f1ac2013-08-28 10:41:47 +020016#include <linux/clkdev.h>
Alban Bedel411520a2015-04-19 14:30:04 +020017#include <linux/clk-provider.h>
Antony Pavlov3bdf1072016-03-17 06:34:15 +030018#include <linux/of.h>
19#include <linux/of_address.h>
Antony Pavlovaf5ad0d2016-03-17 06:34:14 +030020#include <dt-bindings/clock/ath79-clk.h>
Gabor Juhosd4a67d92011-01-04 21:28:14 +010021
Gabor Juhos97541cc2012-09-08 14:02:21 +020022#include <asm/div64.h>
23
Gabor Juhosd4a67d92011-01-04 21:28:14 +010024#include <asm/mach-ath79/ath79.h>
25#include <asm/mach-ath79/ar71xx_regs.h>
26#include "common.h"
27
28#define AR71XX_BASE_FREQ 40000000
Weijie Gaoc338d592016-03-17 06:34:09 +030029#define AR724X_BASE_FREQ 40000000
Gabor Juhosd4a67d92011-01-04 21:28:14 +010030
Antony Pavlovaf5ad0d2016-03-17 06:34:14 +030031static struct clk *clks[ATH79_CLK_END];
Alban Bedel6451af02015-05-31 02:18:22 +020032static struct clk_onecell_data clk_data = {
33 .clks = clks,
34 .clk_num = ARRAY_SIZE(clks),
35};
36
Felix Fietkau9b56e0d2019-01-11 15:22:30 +010037static const char * const clk_names[ATH79_CLK_END] = {
38 [ATH79_CLK_CPU] = "cpu",
39 [ATH79_CLK_DDR] = "ddr",
40 [ATH79_CLK_AHB] = "ahb",
41 [ATH79_CLK_REF] = "ref",
Felix Fietkau6810ed32019-01-11 15:22:35 +010042 [ATH79_CLK_MDIO] = "mdio",
Felix Fietkau9b56e0d2019-01-11 15:22:30 +010043};
44
45static const char * __init ath79_clk_name(int type)
Gabor Juhos2c4f1ac2013-08-28 10:41:47 +020046{
Felix Fietkau9b56e0d2019-01-11 15:22:30 +010047 BUG_ON(type >= ARRAY_SIZE(clk_names) || !clk_names[type]);
48 return clk_names[type];
49}
Gabor Juhos2c4f1ac2013-08-28 10:41:47 +020050
Felix Fietkau9b56e0d2019-01-11 15:22:30 +010051static void __init __ath79_set_clk(int type, const char *name, struct clk *clk)
52{
Christophe JAILLET20d6f0c2016-10-30 09:25:46 +010053 if (IS_ERR(clk))
Felix Fietkau9b56e0d2019-01-11 15:22:30 +010054 panic("failed to allocate %s clock structure", clk_names[type]);
Gabor Juhos2c4f1ac2013-08-28 10:41:47 +020055
Felix Fietkau9b56e0d2019-01-11 15:22:30 +010056 clks[type] = clk;
57 clk_register_clkdev(clk, name, NULL);
58}
Alban Bedel6451af02015-05-31 02:18:22 +020059
Felix Fietkau9b56e0d2019-01-11 15:22:30 +010060static struct clk * __init ath79_set_clk(int type, unsigned long rate)
61{
62 const char *name = ath79_clk_name(type);
63 struct clk *clk;
64
65 clk = clk_register_fixed_rate(NULL, name, NULL, 0, rate);
66 __ath79_set_clk(type, name, clk);
67 return clk;
68}
69
70static struct clk * __init ath79_set_ff_clk(int type, const char *parent,
71 unsigned int mult, unsigned int div)
72{
73 const char *name = ath79_clk_name(type);
74 struct clk *clk;
75
76 clk = clk_register_fixed_factor(NULL, name, parent, 0, mult, div);
77 __ath79_set_clk(type, name, clk);
Alban Bedel6451af02015-05-31 02:18:22 +020078 return clk;
Gabor Juhos2c4f1ac2013-08-28 10:41:47 +020079}
Gabor Juhosd4a67d92011-01-04 21:28:14 +010080
Felix Fietkau8e641752019-01-11 15:22:33 +010081static unsigned long __init ath79_setup_ref_clk(unsigned long rate)
82{
83 struct clk *clk = clks[ATH79_CLK_REF];
84
85 if (clk)
86 rate = clk_get_rate(clk);
87 else
88 clk = ath79_set_clk(ATH79_CLK_REF, rate);
89
90 return rate;
91}
92
Felix Fietkau9aca5cb2019-01-11 15:22:32 +010093static void __init ar71xx_clocks_init(void __iomem *pll_base)
Gabor Juhosd4a67d92011-01-04 21:28:14 +010094{
Gabor Juhos6612a682013-08-28 10:41:46 +020095 unsigned long ref_rate;
96 unsigned long cpu_rate;
97 unsigned long ddr_rate;
98 unsigned long ahb_rate;
Gabor Juhosd4a67d92011-01-04 21:28:14 +010099 u32 pll;
100 u32 freq;
101 u32 div;
102
Felix Fietkau8e641752019-01-11 15:22:33 +0100103 ref_rate = ath79_setup_ref_clk(AR71XX_BASE_FREQ);
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100104
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100105 pll = __raw_readl(pll_base + AR71XX_PLL_REG_CPU_CONFIG);
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100106
Alban Bedel626a0692015-04-19 14:30:02 +0200107 div = ((pll >> AR71XX_PLL_FB_SHIFT) & AR71XX_PLL_FB_MASK) + 1;
Gabor Juhos6612a682013-08-28 10:41:46 +0200108 freq = div * ref_rate;
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100109
110 div = ((pll >> AR71XX_CPU_DIV_SHIFT) & AR71XX_CPU_DIV_MASK) + 1;
Gabor Juhos6612a682013-08-28 10:41:46 +0200111 cpu_rate = freq / div;
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100112
113 div = ((pll >> AR71XX_DDR_DIV_SHIFT) & AR71XX_DDR_DIV_MASK) + 1;
Gabor Juhos6612a682013-08-28 10:41:46 +0200114 ddr_rate = freq / div;
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100115
116 div = (((pll >> AR71XX_AHB_DIV_SHIFT) & AR71XX_AHB_DIV_MASK) + 1) * 2;
Gabor Juhos6612a682013-08-28 10:41:46 +0200117 ahb_rate = cpu_rate / div;
118
Felix Fietkau9b56e0d2019-01-11 15:22:30 +0100119 ath79_set_clk(ATH79_CLK_CPU, cpu_rate);
120 ath79_set_clk(ATH79_CLK_DDR, ddr_rate);
121 ath79_set_clk(ATH79_CLK_AHB, ahb_rate);
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100122}
123
Felix Fietkau8e641752019-01-11 15:22:33 +0100124static void __init ar724x_clocks_init(void __iomem *pll_base)
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300125{
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300126 u32 mult, div, ddr_div, ahb_div;
Felix Fietkau8e641752019-01-11 15:22:33 +0100127 u32 pll;
128
129 ath79_setup_ref_clk(AR71XX_BASE_FREQ);
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300130
131 pll = __raw_readl(pll_base + AR724X_PLL_REG_CPU_CONFIG);
132
133 mult = ((pll >> AR724X_PLL_FB_SHIFT) & AR724X_PLL_FB_MASK);
134 div = ((pll >> AR724X_PLL_REF_DIV_SHIFT) & AR724X_PLL_REF_DIV_MASK) * 2;
135
136 ddr_div = ((pll >> AR724X_DDR_DIV_SHIFT) & AR724X_DDR_DIV_MASK) + 1;
137 ahb_div = (((pll >> AR724X_AHB_DIV_SHIFT) & AR724X_AHB_DIV_MASK) + 1) * 2;
138
Felix Fietkau9b56e0d2019-01-11 15:22:30 +0100139 ath79_set_ff_clk(ATH79_CLK_CPU, "ref", mult, div);
140 ath79_set_ff_clk(ATH79_CLK_DDR, "ref", mult, div * ddr_div);
141 ath79_set_ff_clk(ATH79_CLK_AHB, "ref", mult, div * ahb_div);
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300142}
143
Felix Fietkau8e641752019-01-11 15:22:33 +0100144static void __init ar933x_clocks_init(void __iomem *pll_base)
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100145{
Felix Fietkau8e641752019-01-11 15:22:33 +0100146 unsigned long ref_rate;
Antony Pavlov5ae5c452016-03-17 06:34:18 +0300147 u32 clock_ctrl;
148 u32 ref_div;
149 u32 ninit_mul;
150 u32 out_div;
151
152 u32 cpu_div;
153 u32 ddr_div;
154 u32 ahb_div;
Felix Fietkau8e641752019-01-11 15:22:33 +0100155 u32 t;
156
157 t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
158 if (t & AR933X_BOOTSTRAP_REF_CLK_40)
159 ref_rate = (40 * 1000 * 1000);
160 else
161 ref_rate = (25 * 1000 * 1000);
162
163 ath79_setup_ref_clk(ref_rate);
Antony Pavlov5ae5c452016-03-17 06:34:18 +0300164
165 clock_ctrl = __raw_readl(pll_base + AR933X_PLL_CLOCK_CTRL_REG);
166 if (clock_ctrl & AR933X_PLL_CLOCK_CTRL_BYPASS) {
167 ref_div = 1;
168 ninit_mul = 1;
169 out_div = 1;
170
171 cpu_div = 1;
172 ddr_div = 1;
173 ahb_div = 1;
174 } else {
175 u32 cpu_config;
176 u32 t;
177
178 cpu_config = __raw_readl(pll_base + AR933X_PLL_CPU_CONFIG_REG);
179
180 t = (cpu_config >> AR933X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
181 AR933X_PLL_CPU_CONFIG_REFDIV_MASK;
182 ref_div = t;
183
184 ninit_mul = (cpu_config >> AR933X_PLL_CPU_CONFIG_NINT_SHIFT) &
185 AR933X_PLL_CPU_CONFIG_NINT_MASK;
186
187 t = (cpu_config >> AR933X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
188 AR933X_PLL_CPU_CONFIG_OUTDIV_MASK;
189 if (t == 0)
190 t = 1;
191
192 out_div = (1 << t);
193
194 cpu_div = ((clock_ctrl >> AR933X_PLL_CLOCK_CTRL_CPU_DIV_SHIFT) &
195 AR933X_PLL_CLOCK_CTRL_CPU_DIV_MASK) + 1;
196
197 ddr_div = ((clock_ctrl >> AR933X_PLL_CLOCK_CTRL_DDR_DIV_SHIFT) &
198 AR933X_PLL_CLOCK_CTRL_DDR_DIV_MASK) + 1;
199
200 ahb_div = ((clock_ctrl >> AR933X_PLL_CLOCK_CTRL_AHB_DIV_SHIFT) &
201 AR933X_PLL_CLOCK_CTRL_AHB_DIV_MASK) + 1;
202 }
203
Felix Fietkau9b56e0d2019-01-11 15:22:30 +0100204 ath79_set_ff_clk(ATH79_CLK_CPU, "ref", ninit_mul,
205 ref_div * out_div * cpu_div);
206 ath79_set_ff_clk(ATH79_CLK_DDR, "ref", ninit_mul,
207 ref_div * out_div * ddr_div);
208 ath79_set_ff_clk(ATH79_CLK_AHB, "ref", ninit_mul,
209 ref_div * out_div * ahb_div);
Antony Pavlov5ae5c452016-03-17 06:34:18 +0300210}
211
Gabor Juhos97541cc2012-09-08 14:02:21 +0200212static u32 __init ar934x_get_pll_freq(u32 ref, u32 ref_div, u32 nint, u32 nfrac,
213 u32 frac, u32 out_div)
214{
215 u64 t;
216 u32 ret;
217
Gabor Juhos837f0362013-08-28 10:41:43 +0200218 t = ref;
Gabor Juhos97541cc2012-09-08 14:02:21 +0200219 t *= nint;
220 do_div(t, ref_div);
221 ret = t;
222
Gabor Juhos837f0362013-08-28 10:41:43 +0200223 t = ref;
Gabor Juhos97541cc2012-09-08 14:02:21 +0200224 t *= nfrac;
225 do_div(t, ref_div * frac);
226 ret += t;
227
228 ret /= (1 << out_div);
229 return ret;
230}
231
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100232static void __init ar934x_clocks_init(void __iomem *pll_base)
Gabor Juhos88896122012-03-14 10:45:22 +0100233{
Gabor Juhos6612a682013-08-28 10:41:46 +0200234 unsigned long ref_rate;
235 unsigned long cpu_rate;
236 unsigned long ddr_rate;
237 unsigned long ahb_rate;
Gabor Juhos97541cc2012-09-08 14:02:21 +0200238 u32 pll, out_div, ref_div, nint, nfrac, frac, clk_ctrl, postdiv;
Gabor Juhos88896122012-03-14 10:45:22 +0100239 u32 cpu_pll, ddr_pll;
240 u32 bootstrap;
Gabor Juhos97541cc2012-09-08 14:02:21 +0200241 void __iomem *dpll_base;
242
243 dpll_base = ioremap(AR934X_SRIF_BASE, AR934X_SRIF_SIZE);
Gabor Juhos88896122012-03-14 10:45:22 +0100244
245 bootstrap = ath79_reset_rr(AR934X_RESET_REG_BOOTSTRAP);
Ralf Baechle70342282013-01-22 12:59:30 +0100246 if (bootstrap & AR934X_BOOTSTRAP_REF_CLK_40)
Gabor Juhos6612a682013-08-28 10:41:46 +0200247 ref_rate = 40 * 1000 * 1000;
Gabor Juhos88896122012-03-14 10:45:22 +0100248 else
Gabor Juhos6612a682013-08-28 10:41:46 +0200249 ref_rate = 25 * 1000 * 1000;
Gabor Juhos88896122012-03-14 10:45:22 +0100250
Felix Fietkau8e641752019-01-11 15:22:33 +0100251 ref_rate = ath79_setup_ref_clk(ref_rate);
252
Gabor Juhos97541cc2012-09-08 14:02:21 +0200253 pll = __raw_readl(dpll_base + AR934X_SRIF_CPU_DPLL2_REG);
254 if (pll & AR934X_SRIF_DPLL2_LOCAL_PLL) {
255 out_div = (pll >> AR934X_SRIF_DPLL2_OUTDIV_SHIFT) &
256 AR934X_SRIF_DPLL2_OUTDIV_MASK;
257 pll = __raw_readl(dpll_base + AR934X_SRIF_CPU_DPLL1_REG);
258 nint = (pll >> AR934X_SRIF_DPLL1_NINT_SHIFT) &
259 AR934X_SRIF_DPLL1_NINT_MASK;
260 nfrac = pll & AR934X_SRIF_DPLL1_NFRAC_MASK;
261 ref_div = (pll >> AR934X_SRIF_DPLL1_REFDIV_SHIFT) &
262 AR934X_SRIF_DPLL1_REFDIV_MASK;
263 frac = 1 << 18;
264 } else {
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100265 pll = __raw_readl(pll_base + AR934X_PLL_CPU_CONFIG_REG);
Gabor Juhos97541cc2012-09-08 14:02:21 +0200266 out_div = (pll >> AR934X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
267 AR934X_PLL_CPU_CONFIG_OUTDIV_MASK;
268 ref_div = (pll >> AR934X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
269 AR934X_PLL_CPU_CONFIG_REFDIV_MASK;
270 nint = (pll >> AR934X_PLL_CPU_CONFIG_NINT_SHIFT) &
271 AR934X_PLL_CPU_CONFIG_NINT_MASK;
272 nfrac = (pll >> AR934X_PLL_CPU_CONFIG_NFRAC_SHIFT) &
273 AR934X_PLL_CPU_CONFIG_NFRAC_MASK;
274 frac = 1 << 6;
275 }
Gabor Juhos88896122012-03-14 10:45:22 +0100276
Gabor Juhos6612a682013-08-28 10:41:46 +0200277 cpu_pll = ar934x_get_pll_freq(ref_rate, ref_div, nint,
Gabor Juhos97541cc2012-09-08 14:02:21 +0200278 nfrac, frac, out_div);
Gabor Juhos88896122012-03-14 10:45:22 +0100279
Gabor Juhos97541cc2012-09-08 14:02:21 +0200280 pll = __raw_readl(dpll_base + AR934X_SRIF_DDR_DPLL2_REG);
281 if (pll & AR934X_SRIF_DPLL2_LOCAL_PLL) {
282 out_div = (pll >> AR934X_SRIF_DPLL2_OUTDIV_SHIFT) &
283 AR934X_SRIF_DPLL2_OUTDIV_MASK;
284 pll = __raw_readl(dpll_base + AR934X_SRIF_DDR_DPLL1_REG);
285 nint = (pll >> AR934X_SRIF_DPLL1_NINT_SHIFT) &
286 AR934X_SRIF_DPLL1_NINT_MASK;
287 nfrac = pll & AR934X_SRIF_DPLL1_NFRAC_MASK;
288 ref_div = (pll >> AR934X_SRIF_DPLL1_REFDIV_SHIFT) &
289 AR934X_SRIF_DPLL1_REFDIV_MASK;
290 frac = 1 << 18;
291 } else {
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100292 pll = __raw_readl(pll_base + AR934X_PLL_DDR_CONFIG_REG);
Gabor Juhos97541cc2012-09-08 14:02:21 +0200293 out_div = (pll >> AR934X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
294 AR934X_PLL_DDR_CONFIG_OUTDIV_MASK;
295 ref_div = (pll >> AR934X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
296 AR934X_PLL_DDR_CONFIG_REFDIV_MASK;
297 nint = (pll >> AR934X_PLL_DDR_CONFIG_NINT_SHIFT) &
298 AR934X_PLL_DDR_CONFIG_NINT_MASK;
299 nfrac = (pll >> AR934X_PLL_DDR_CONFIG_NFRAC_SHIFT) &
300 AR934X_PLL_DDR_CONFIG_NFRAC_MASK;
301 frac = 1 << 10;
302 }
Gabor Juhos88896122012-03-14 10:45:22 +0100303
Gabor Juhos6612a682013-08-28 10:41:46 +0200304 ddr_pll = ar934x_get_pll_freq(ref_rate, ref_div, nint,
Gabor Juhos97541cc2012-09-08 14:02:21 +0200305 nfrac, frac, out_div);
Gabor Juhos88896122012-03-14 10:45:22 +0100306
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100307 clk_ctrl = __raw_readl(pll_base + AR934X_PLL_CPU_DDR_CLK_CTRL_REG);
Gabor Juhos88896122012-03-14 10:45:22 +0100308
309 postdiv = (clk_ctrl >> AR934X_PLL_CPU_DDR_CLK_CTRL_CPU_POST_DIV_SHIFT) &
310 AR934X_PLL_CPU_DDR_CLK_CTRL_CPU_POST_DIV_MASK;
311
312 if (clk_ctrl & AR934X_PLL_CPU_DDR_CLK_CTRL_CPU_PLL_BYPASS)
Gabor Juhos6612a682013-08-28 10:41:46 +0200313 cpu_rate = ref_rate;
Gabor Juhos88896122012-03-14 10:45:22 +0100314 else if (clk_ctrl & AR934X_PLL_CPU_DDR_CLK_CTRL_CPUCLK_FROM_CPUPLL)
Gabor Juhos6612a682013-08-28 10:41:46 +0200315 cpu_rate = cpu_pll / (postdiv + 1);
Gabor Juhos88896122012-03-14 10:45:22 +0100316 else
Gabor Juhos6612a682013-08-28 10:41:46 +0200317 cpu_rate = ddr_pll / (postdiv + 1);
Gabor Juhos88896122012-03-14 10:45:22 +0100318
319 postdiv = (clk_ctrl >> AR934X_PLL_CPU_DDR_CLK_CTRL_DDR_POST_DIV_SHIFT) &
320 AR934X_PLL_CPU_DDR_CLK_CTRL_DDR_POST_DIV_MASK;
321
322 if (clk_ctrl & AR934X_PLL_CPU_DDR_CLK_CTRL_DDR_PLL_BYPASS)
Gabor Juhos6612a682013-08-28 10:41:46 +0200323 ddr_rate = ref_rate;
Gabor Juhos88896122012-03-14 10:45:22 +0100324 else if (clk_ctrl & AR934X_PLL_CPU_DDR_CLK_CTRL_DDRCLK_FROM_DDRPLL)
Gabor Juhos6612a682013-08-28 10:41:46 +0200325 ddr_rate = ddr_pll / (postdiv + 1);
Gabor Juhos88896122012-03-14 10:45:22 +0100326 else
Gabor Juhos6612a682013-08-28 10:41:46 +0200327 ddr_rate = cpu_pll / (postdiv + 1);
Gabor Juhos88896122012-03-14 10:45:22 +0100328
329 postdiv = (clk_ctrl >> AR934X_PLL_CPU_DDR_CLK_CTRL_AHB_POST_DIV_SHIFT) &
330 AR934X_PLL_CPU_DDR_CLK_CTRL_AHB_POST_DIV_MASK;
331
332 if (clk_ctrl & AR934X_PLL_CPU_DDR_CLK_CTRL_AHB_PLL_BYPASS)
Gabor Juhos6612a682013-08-28 10:41:46 +0200333 ahb_rate = ref_rate;
Gabor Juhos88896122012-03-14 10:45:22 +0100334 else if (clk_ctrl & AR934X_PLL_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL)
Gabor Juhos6612a682013-08-28 10:41:46 +0200335 ahb_rate = ddr_pll / (postdiv + 1);
Gabor Juhos88896122012-03-14 10:45:22 +0100336 else
Gabor Juhos6612a682013-08-28 10:41:46 +0200337 ahb_rate = cpu_pll / (postdiv + 1);
338
Felix Fietkau9b56e0d2019-01-11 15:22:30 +0100339 ath79_set_clk(ATH79_CLK_CPU, cpu_rate);
340 ath79_set_clk(ATH79_CLK_DDR, ddr_rate);
341 ath79_set_clk(ATH79_CLK_AHB, ahb_rate);
Gabor Juhos88896122012-03-14 10:45:22 +0100342
Felix Fietkau6810ed32019-01-11 15:22:35 +0100343 clk_ctrl = __raw_readl(pll_base + AR934X_PLL_SWITCH_CLOCK_CONTROL_REG);
344 if (clk_ctrl & AR934X_PLL_SWITCH_CLOCK_CONTROL_MDIO_CLK_SEL)
345 ath79_set_clk(ATH79_CLK_MDIO, 100 * 1000 * 1000);
346
Gabor Juhos97541cc2012-09-08 14:02:21 +0200347 iounmap(dpll_base);
Gabor Juhos88896122012-03-14 10:45:22 +0100348}
349
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100350static void __init qca953x_clocks_init(void __iomem *pll_base)
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200351{
352 unsigned long ref_rate;
353 unsigned long cpu_rate;
354 unsigned long ddr_rate;
355 unsigned long ahb_rate;
356 u32 pll, out_div, ref_div, nint, frac, clk_ctrl, postdiv;
357 u32 cpu_pll, ddr_pll;
358 u32 bootstrap;
359
360 bootstrap = ath79_reset_rr(QCA953X_RESET_REG_BOOTSTRAP);
361 if (bootstrap & QCA953X_BOOTSTRAP_REF_CLK_40)
362 ref_rate = 40 * 1000 * 1000;
363 else
364 ref_rate = 25 * 1000 * 1000;
365
Felix Fietkau8e641752019-01-11 15:22:33 +0100366 ref_rate = ath79_setup_ref_clk(ref_rate);
367
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100368 pll = __raw_readl(pll_base + QCA953X_PLL_CPU_CONFIG_REG);
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200369 out_div = (pll >> QCA953X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
370 QCA953X_PLL_CPU_CONFIG_OUTDIV_MASK;
371 ref_div = (pll >> QCA953X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
372 QCA953X_PLL_CPU_CONFIG_REFDIV_MASK;
373 nint = (pll >> QCA953X_PLL_CPU_CONFIG_NINT_SHIFT) &
374 QCA953X_PLL_CPU_CONFIG_NINT_MASK;
375 frac = (pll >> QCA953X_PLL_CPU_CONFIG_NFRAC_SHIFT) &
376 QCA953X_PLL_CPU_CONFIG_NFRAC_MASK;
377
378 cpu_pll = nint * ref_rate / ref_div;
379 cpu_pll += frac * (ref_rate >> 6) / ref_div;
380 cpu_pll /= (1 << out_div);
381
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100382 pll = __raw_readl(pll_base + QCA953X_PLL_DDR_CONFIG_REG);
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200383 out_div = (pll >> QCA953X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
384 QCA953X_PLL_DDR_CONFIG_OUTDIV_MASK;
385 ref_div = (pll >> QCA953X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
386 QCA953X_PLL_DDR_CONFIG_REFDIV_MASK;
387 nint = (pll >> QCA953X_PLL_DDR_CONFIG_NINT_SHIFT) &
388 QCA953X_PLL_DDR_CONFIG_NINT_MASK;
389 frac = (pll >> QCA953X_PLL_DDR_CONFIG_NFRAC_SHIFT) &
390 QCA953X_PLL_DDR_CONFIG_NFRAC_MASK;
391
392 ddr_pll = nint * ref_rate / ref_div;
393 ddr_pll += frac * (ref_rate >> 6) / (ref_div << 4);
394 ddr_pll /= (1 << out_div);
395
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100396 clk_ctrl = __raw_readl(pll_base + QCA953X_PLL_CLK_CTRL_REG);
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200397
398 postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT) &
399 QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_MASK;
400
401 if (clk_ctrl & QCA953X_PLL_CLK_CTRL_CPU_PLL_BYPASS)
402 cpu_rate = ref_rate;
403 else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_CPUCLK_FROM_CPUPLL)
404 cpu_rate = cpu_pll / (postdiv + 1);
405 else
406 cpu_rate = ddr_pll / (postdiv + 1);
407
408 postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT) &
409 QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_MASK;
410
411 if (clk_ctrl & QCA953X_PLL_CLK_CTRL_DDR_PLL_BYPASS)
412 ddr_rate = ref_rate;
413 else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL)
414 ddr_rate = ddr_pll / (postdiv + 1);
415 else
416 ddr_rate = cpu_pll / (postdiv + 1);
417
418 postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT) &
419 QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_MASK;
420
421 if (clk_ctrl & QCA953X_PLL_CLK_CTRL_AHB_PLL_BYPASS)
422 ahb_rate = ref_rate;
423 else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL)
424 ahb_rate = ddr_pll / (postdiv + 1);
425 else
426 ahb_rate = cpu_pll / (postdiv + 1);
427
Felix Fietkau9b56e0d2019-01-11 15:22:30 +0100428 ath79_set_clk(ATH79_CLK_CPU, cpu_rate);
429 ath79_set_clk(ATH79_CLK_DDR, ddr_rate);
430 ath79_set_clk(ATH79_CLK_AHB, ahb_rate);
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200431}
432
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100433static void __init qca955x_clocks_init(void __iomem *pll_base)
Gabor Juhos41583c02013-02-15 13:38:17 +0000434{
Gabor Juhos6612a682013-08-28 10:41:46 +0200435 unsigned long ref_rate;
436 unsigned long cpu_rate;
437 unsigned long ddr_rate;
438 unsigned long ahb_rate;
Gabor Juhos41583c02013-02-15 13:38:17 +0000439 u32 pll, out_div, ref_div, nint, frac, clk_ctrl, postdiv;
440 u32 cpu_pll, ddr_pll;
441 u32 bootstrap;
442
443 bootstrap = ath79_reset_rr(QCA955X_RESET_REG_BOOTSTRAP);
444 if (bootstrap & QCA955X_BOOTSTRAP_REF_CLK_40)
Gabor Juhos6612a682013-08-28 10:41:46 +0200445 ref_rate = 40 * 1000 * 1000;
Gabor Juhos41583c02013-02-15 13:38:17 +0000446 else
Gabor Juhos6612a682013-08-28 10:41:46 +0200447 ref_rate = 25 * 1000 * 1000;
Gabor Juhos41583c02013-02-15 13:38:17 +0000448
Felix Fietkau8e641752019-01-11 15:22:33 +0100449 ref_rate = ath79_setup_ref_clk(ref_rate);
450
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100451 pll = __raw_readl(pll_base + QCA955X_PLL_CPU_CONFIG_REG);
Gabor Juhos41583c02013-02-15 13:38:17 +0000452 out_div = (pll >> QCA955X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
453 QCA955X_PLL_CPU_CONFIG_OUTDIV_MASK;
454 ref_div = (pll >> QCA955X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
455 QCA955X_PLL_CPU_CONFIG_REFDIV_MASK;
456 nint = (pll >> QCA955X_PLL_CPU_CONFIG_NINT_SHIFT) &
457 QCA955X_PLL_CPU_CONFIG_NINT_MASK;
458 frac = (pll >> QCA955X_PLL_CPU_CONFIG_NFRAC_SHIFT) &
459 QCA955X_PLL_CPU_CONFIG_NFRAC_MASK;
460
Gabor Juhos6612a682013-08-28 10:41:46 +0200461 cpu_pll = nint * ref_rate / ref_div;
462 cpu_pll += frac * ref_rate / (ref_div * (1 << 6));
Gabor Juhos41583c02013-02-15 13:38:17 +0000463 cpu_pll /= (1 << out_div);
464
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100465 pll = __raw_readl(pll_base + QCA955X_PLL_DDR_CONFIG_REG);
Gabor Juhos41583c02013-02-15 13:38:17 +0000466 out_div = (pll >> QCA955X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
467 QCA955X_PLL_DDR_CONFIG_OUTDIV_MASK;
468 ref_div = (pll >> QCA955X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
469 QCA955X_PLL_DDR_CONFIG_REFDIV_MASK;
470 nint = (pll >> QCA955X_PLL_DDR_CONFIG_NINT_SHIFT) &
471 QCA955X_PLL_DDR_CONFIG_NINT_MASK;
472 frac = (pll >> QCA955X_PLL_DDR_CONFIG_NFRAC_SHIFT) &
473 QCA955X_PLL_DDR_CONFIG_NFRAC_MASK;
474
Gabor Juhos6612a682013-08-28 10:41:46 +0200475 ddr_pll = nint * ref_rate / ref_div;
476 ddr_pll += frac * ref_rate / (ref_div * (1 << 10));
Gabor Juhos41583c02013-02-15 13:38:17 +0000477 ddr_pll /= (1 << out_div);
478
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100479 clk_ctrl = __raw_readl(pll_base + QCA955X_PLL_CLK_CTRL_REG);
Gabor Juhos41583c02013-02-15 13:38:17 +0000480
481 postdiv = (clk_ctrl >> QCA955X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT) &
482 QCA955X_PLL_CLK_CTRL_CPU_POST_DIV_MASK;
483
484 if (clk_ctrl & QCA955X_PLL_CLK_CTRL_CPU_PLL_BYPASS)
Gabor Juhos6612a682013-08-28 10:41:46 +0200485 cpu_rate = ref_rate;
Gabor Juhos41583c02013-02-15 13:38:17 +0000486 else if (clk_ctrl & QCA955X_PLL_CLK_CTRL_CPUCLK_FROM_CPUPLL)
Gabor Juhos6612a682013-08-28 10:41:46 +0200487 cpu_rate = ddr_pll / (postdiv + 1);
Gabor Juhos41583c02013-02-15 13:38:17 +0000488 else
Gabor Juhos6612a682013-08-28 10:41:46 +0200489 cpu_rate = cpu_pll / (postdiv + 1);
Gabor Juhos41583c02013-02-15 13:38:17 +0000490
491 postdiv = (clk_ctrl >> QCA955X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT) &
492 QCA955X_PLL_CLK_CTRL_DDR_POST_DIV_MASK;
493
494 if (clk_ctrl & QCA955X_PLL_CLK_CTRL_DDR_PLL_BYPASS)
Gabor Juhos6612a682013-08-28 10:41:46 +0200495 ddr_rate = ref_rate;
Gabor Juhos41583c02013-02-15 13:38:17 +0000496 else if (clk_ctrl & QCA955X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL)
Gabor Juhos6612a682013-08-28 10:41:46 +0200497 ddr_rate = cpu_pll / (postdiv + 1);
Gabor Juhos41583c02013-02-15 13:38:17 +0000498 else
Gabor Juhos6612a682013-08-28 10:41:46 +0200499 ddr_rate = ddr_pll / (postdiv + 1);
Gabor Juhos41583c02013-02-15 13:38:17 +0000500
501 postdiv = (clk_ctrl >> QCA955X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT) &
502 QCA955X_PLL_CLK_CTRL_AHB_POST_DIV_MASK;
503
504 if (clk_ctrl & QCA955X_PLL_CLK_CTRL_AHB_PLL_BYPASS)
Gabor Juhos6612a682013-08-28 10:41:46 +0200505 ahb_rate = ref_rate;
Gabor Juhos41583c02013-02-15 13:38:17 +0000506 else if (clk_ctrl & QCA955X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL)
Gabor Juhos6612a682013-08-28 10:41:46 +0200507 ahb_rate = ddr_pll / (postdiv + 1);
Gabor Juhos41583c02013-02-15 13:38:17 +0000508 else
Gabor Juhos6612a682013-08-28 10:41:46 +0200509 ahb_rate = cpu_pll / (postdiv + 1);
510
Felix Fietkau9b56e0d2019-01-11 15:22:30 +0100511 ath79_set_clk(ATH79_CLK_CPU, cpu_rate);
512 ath79_set_clk(ATH79_CLK_DDR, ddr_rate);
513 ath79_set_clk(ATH79_CLK_AHB, ahb_rate);
Gabor Juhos41583c02013-02-15 13:38:17 +0000514}
515
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100516static void __init qca956x_clocks_init(void __iomem *pll_base)
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200517{
518 unsigned long ref_rate;
519 unsigned long cpu_rate;
520 unsigned long ddr_rate;
521 unsigned long ahb_rate;
522 u32 pll, out_div, ref_div, nint, hfrac, lfrac, clk_ctrl, postdiv;
523 u32 cpu_pll, ddr_pll;
524 u32 bootstrap;
525
526 /*
527 * QCA956x timer init workaround has to be applied right before setting
528 * up the clock. Else, there will be no jiffies
529 */
530 u32 misc;
531
532 misc = ath79_reset_rr(AR71XX_RESET_REG_MISC_INT_ENABLE);
533 misc |= MISC_INT_MIPS_SI_TIMERINT_MASK;
534 ath79_reset_wr(AR71XX_RESET_REG_MISC_INT_ENABLE, misc);
535
536 bootstrap = ath79_reset_rr(QCA956X_RESET_REG_BOOTSTRAP);
537 if (bootstrap & QCA956X_BOOTSTRAP_REF_CLK_40)
538 ref_rate = 40 * 1000 * 1000;
539 else
540 ref_rate = 25 * 1000 * 1000;
541
Felix Fietkau8e641752019-01-11 15:22:33 +0100542 ref_rate = ath79_setup_ref_clk(ref_rate);
543
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100544 pll = __raw_readl(pll_base + QCA956X_PLL_CPU_CONFIG_REG);
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200545 out_div = (pll >> QCA956X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
546 QCA956X_PLL_CPU_CONFIG_OUTDIV_MASK;
547 ref_div = (pll >> QCA956X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
548 QCA956X_PLL_CPU_CONFIG_REFDIV_MASK;
549
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100550 pll = __raw_readl(pll_base + QCA956X_PLL_CPU_CONFIG1_REG);
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200551 nint = (pll >> QCA956X_PLL_CPU_CONFIG1_NINT_SHIFT) &
552 QCA956X_PLL_CPU_CONFIG1_NINT_MASK;
553 hfrac = (pll >> QCA956X_PLL_CPU_CONFIG1_NFRAC_H_SHIFT) &
554 QCA956X_PLL_CPU_CONFIG1_NFRAC_H_MASK;
555 lfrac = (pll >> QCA956X_PLL_CPU_CONFIG1_NFRAC_L_SHIFT) &
556 QCA956X_PLL_CPU_CONFIG1_NFRAC_L_MASK;
557
558 cpu_pll = nint * ref_rate / ref_div;
559 cpu_pll += (lfrac * ref_rate) / ((ref_div * 25) << 13);
560 cpu_pll += (hfrac >> 13) * ref_rate / ref_div;
561 cpu_pll /= (1 << out_div);
562
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100563 pll = __raw_readl(pll_base + QCA956X_PLL_DDR_CONFIG_REG);
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200564 out_div = (pll >> QCA956X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
565 QCA956X_PLL_DDR_CONFIG_OUTDIV_MASK;
566 ref_div = (pll >> QCA956X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
567 QCA956X_PLL_DDR_CONFIG_REFDIV_MASK;
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100568 pll = __raw_readl(pll_base + QCA956X_PLL_DDR_CONFIG1_REG);
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200569 nint = (pll >> QCA956X_PLL_DDR_CONFIG1_NINT_SHIFT) &
570 QCA956X_PLL_DDR_CONFIG1_NINT_MASK;
571 hfrac = (pll >> QCA956X_PLL_DDR_CONFIG1_NFRAC_H_SHIFT) &
572 QCA956X_PLL_DDR_CONFIG1_NFRAC_H_MASK;
573 lfrac = (pll >> QCA956X_PLL_DDR_CONFIG1_NFRAC_L_SHIFT) &
574 QCA956X_PLL_DDR_CONFIG1_NFRAC_L_MASK;
575
576 ddr_pll = nint * ref_rate / ref_div;
577 ddr_pll += (lfrac * ref_rate) / ((ref_div * 25) << 13);
578 ddr_pll += (hfrac >> 13) * ref_rate / ref_div;
579 ddr_pll /= (1 << out_div);
580
Felix Fietkau9aca5cb2019-01-11 15:22:32 +0100581 clk_ctrl = __raw_readl(pll_base + QCA956X_PLL_CLK_CTRL_REG);
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200582
583 postdiv = (clk_ctrl >> QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT) &
584 QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_MASK;
585
586 if (clk_ctrl & QCA956X_PLL_CLK_CTRL_CPU_PLL_BYPASS)
587 cpu_rate = ref_rate;
588 else if (clk_ctrl & QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_CPUPLL)
589 cpu_rate = ddr_pll / (postdiv + 1);
590 else
591 cpu_rate = cpu_pll / (postdiv + 1);
592
593 postdiv = (clk_ctrl >> QCA956X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT) &
594 QCA956X_PLL_CLK_CTRL_DDR_POST_DIV_MASK;
595
596 if (clk_ctrl & QCA956X_PLL_CLK_CTRL_DDR_PLL_BYPASS)
597 ddr_rate = ref_rate;
598 else if (clk_ctrl & QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_DDRPLL)
599 ddr_rate = cpu_pll / (postdiv + 1);
600 else
601 ddr_rate = ddr_pll / (postdiv + 1);
602
603 postdiv = (clk_ctrl >> QCA956X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT) &
604 QCA956X_PLL_CLK_CTRL_AHB_POST_DIV_MASK;
605
606 if (clk_ctrl & QCA956X_PLL_CLK_CTRL_AHB_PLL_BYPASS)
607 ahb_rate = ref_rate;
608 else if (clk_ctrl & QCA956X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL)
609 ahb_rate = ddr_pll / (postdiv + 1);
610 else
611 ahb_rate = cpu_pll / (postdiv + 1);
612
Felix Fietkau9b56e0d2019-01-11 15:22:30 +0100613 ath79_set_clk(ATH79_CLK_CPU, cpu_rate);
614 ath79_set_clk(ATH79_CLK_DDR, ddr_rate);
615 ath79_set_clk(ATH79_CLK_AHB, ahb_rate);
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200616}
617
Alban Bedel6451af02015-05-31 02:18:22 +0200618static void __init ath79_clocks_init_dt(struct device_node *np)
619{
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300620 struct clk *ref_clk;
621 void __iomem *pll_base;
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300622
623 ref_clk = of_clk_get(np, 0);
Felix Fietkau8e641752019-01-11 15:22:33 +0100624 if (!IS_ERR(ref_clk))
625 clks[ATH79_CLK_REF] = ref_clk;
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300626
627 pll_base = of_iomap(np, 0);
628 if (!pll_base) {
Rob Herring7f27b5b2017-07-18 16:42:45 -0500629 pr_err("%pOF: can't map pll registers\n", np);
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300630 goto err_clk;
631 }
632
Felix Fietkaue7eea042019-01-11 15:22:34 +0100633 if (of_device_is_compatible(np, "qca,ar7100-pll"))
634 ar71xx_clocks_init(pll_base);
635 else if (of_device_is_compatible(np, "qca,ar7240-pll") ||
636 of_device_is_compatible(np, "qca,ar9130-pll"))
Felix Fietkau8e641752019-01-11 15:22:33 +0100637 ar724x_clocks_init(pll_base);
Antony Pavlov5ae5c452016-03-17 06:34:18 +0300638 else if (of_device_is_compatible(np, "qca,ar9330-pll"))
Felix Fietkau8e641752019-01-11 15:22:33 +0100639 ar933x_clocks_init(pll_base);
Felix Fietkaue7eea042019-01-11 15:22:34 +0100640 else if (of_device_is_compatible(np, "qca,ar9340-pll"))
641 ar934x_clocks_init(pll_base);
642 else if (of_device_is_compatible(np, "qca,qca9530-pll"))
643 qca953x_clocks_init(pll_base);
644 else if (of_device_is_compatible(np, "qca,qca9550-pll"))
645 qca955x_clocks_init(pll_base);
646 else if (of_device_is_compatible(np, "qca,qca9560-pll"))
647 qca956x_clocks_init(pll_base);
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300648
Felix Fietkau6810ed32019-01-11 15:22:35 +0100649 if (!clks[ATH79_CLK_MDIO])
650 clks[ATH79_CLK_MDIO] = clks[ATH79_CLK_REF];
651
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300652 if (of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data)) {
Rob Herring7f27b5b2017-07-18 16:42:45 -0500653 pr_err("%pOF: could not register clk provider\n", np);
Arvind Yadavb3d91db2017-01-02 15:18:21 +0530654 goto err_iounmap;
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300655 }
656
657 return;
658
Arvind Yadavb3d91db2017-01-02 15:18:21 +0530659err_iounmap:
660 iounmap(pll_base);
661
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300662err_clk:
663 clk_put(ref_clk);
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300664}
Felix Fietkaue7eea042019-01-11 15:22:34 +0100665
666CLK_OF_DECLARE(ar7100_clk, "qca,ar7100-pll", ath79_clocks_init_dt);
667CLK_OF_DECLARE(ar7240_clk, "qca,ar7240-pll", ath79_clocks_init_dt);
668CLK_OF_DECLARE(ar9130_clk, "qca,ar9130-pll", ath79_clocks_init_dt);
669CLK_OF_DECLARE(ar9330_clk, "qca,ar9330-pll", ath79_clocks_init_dt);
670CLK_OF_DECLARE(ar9340_clk, "qca,ar9340-pll", ath79_clocks_init_dt);
671CLK_OF_DECLARE(ar9530_clk, "qca,qca9530-pll", ath79_clocks_init_dt);
672CLK_OF_DECLARE(ar9550_clk, "qca,qca9550-pll", ath79_clocks_init_dt);
673CLK_OF_DECLARE(ar9560_clk, "qca,qca9560-pll", ath79_clocks_init_dt);