blob: 50bc3b01a4c4fb50116a64abd689a29105057462 [file] [log] [blame]
Gabor Juhosd4a67d92011-01-04 21:28:14 +01001/*
2 * Atheros AR71XX/AR724X/AR913X common routines
3 *
Gabor Juhos88896122012-03-14 10:45:22 +01004 * Copyright (C) 2010-2011 Jaiganesh Narayanan <jnarayanan@atheros.com>
Gabor Juhosd4a67d92011-01-04 21:28:14 +01005 * Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
6 *
Gabor Juhos88896122012-03-14 10:45:22 +01007 * Parts of this file are based on Atheros' 2.6.15/2.6.31 BSP
8 *
Gabor Juhosd4a67d92011-01-04 21:28:14 +01009 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
12 */
13
14#include <linux/kernel.h>
Gabor Juhosd4a67d92011-01-04 21:28:14 +010015#include <linux/init.h>
16#include <linux/err.h>
17#include <linux/clk.h>
Gabor Juhos2c4f1ac2013-08-28 10:41:47 +020018#include <linux/clkdev.h>
Alban Bedel411520a2015-04-19 14:30:04 +020019#include <linux/clk-provider.h>
Antony Pavlov3bdf1072016-03-17 06:34:15 +030020#include <linux/of.h>
21#include <linux/of_address.h>
Antony Pavlovaf5ad0d2016-03-17 06:34:14 +030022#include <dt-bindings/clock/ath79-clk.h>
Gabor Juhosd4a67d92011-01-04 21:28:14 +010023
Gabor Juhos97541cc2012-09-08 14:02:21 +020024#include <asm/div64.h>
25
Gabor Juhosd4a67d92011-01-04 21:28:14 +010026#include <asm/mach-ath79/ath79.h>
27#include <asm/mach-ath79/ar71xx_regs.h>
28#include "common.h"
Antony Pavlov3bdf1072016-03-17 06:34:15 +030029#include "machtypes.h"
Gabor Juhosd4a67d92011-01-04 21:28:14 +010030
31#define AR71XX_BASE_FREQ 40000000
Weijie Gaoc338d592016-03-17 06:34:09 +030032#define AR724X_BASE_FREQ 40000000
Gabor Juhosd4a67d92011-01-04 21:28:14 +010033
Antony Pavlovaf5ad0d2016-03-17 06:34:14 +030034static struct clk *clks[ATH79_CLK_END];
Alban Bedel6451af02015-05-31 02:18:22 +020035static struct clk_onecell_data clk_data = {
36 .clks = clks,
37 .clk_num = ARRAY_SIZE(clks),
38};
39
Felix Fietkau9b56e0d2019-01-11 15:22:30 +010040static const char * const clk_names[ATH79_CLK_END] = {
41 [ATH79_CLK_CPU] = "cpu",
42 [ATH79_CLK_DDR] = "ddr",
43 [ATH79_CLK_AHB] = "ahb",
44 [ATH79_CLK_REF] = "ref",
45};
46
47static const char * __init ath79_clk_name(int type)
Gabor Juhos2c4f1ac2013-08-28 10:41:47 +020048{
Felix Fietkau9b56e0d2019-01-11 15:22:30 +010049 BUG_ON(type >= ARRAY_SIZE(clk_names) || !clk_names[type]);
50 return clk_names[type];
51}
Gabor Juhos2c4f1ac2013-08-28 10:41:47 +020052
Felix Fietkau9b56e0d2019-01-11 15:22:30 +010053static void __init __ath79_set_clk(int type, const char *name, struct clk *clk)
54{
Christophe JAILLET20d6f0c2016-10-30 09:25:46 +010055 if (IS_ERR(clk))
Felix Fietkau9b56e0d2019-01-11 15:22:30 +010056 panic("failed to allocate %s clock structure", clk_names[type]);
Gabor Juhos2c4f1ac2013-08-28 10:41:47 +020057
Felix Fietkau9b56e0d2019-01-11 15:22:30 +010058 clks[type] = clk;
59 clk_register_clkdev(clk, name, NULL);
60}
Alban Bedel6451af02015-05-31 02:18:22 +020061
Felix Fietkau9b56e0d2019-01-11 15:22:30 +010062static struct clk * __init ath79_set_clk(int type, unsigned long rate)
63{
64 const char *name = ath79_clk_name(type);
65 struct clk *clk;
66
67 clk = clk_register_fixed_rate(NULL, name, NULL, 0, rate);
68 __ath79_set_clk(type, name, clk);
69 return clk;
70}
71
72static struct clk * __init ath79_set_ff_clk(int type, const char *parent,
73 unsigned int mult, unsigned int div)
74{
75 const char *name = ath79_clk_name(type);
76 struct clk *clk;
77
78 clk = clk_register_fixed_factor(NULL, name, parent, 0, mult, div);
79 __ath79_set_clk(type, name, clk);
Alban Bedel6451af02015-05-31 02:18:22 +020080 return clk;
Gabor Juhos2c4f1ac2013-08-28 10:41:47 +020081}
Gabor Juhosd4a67d92011-01-04 21:28:14 +010082
83static void __init ar71xx_clocks_init(void)
84{
Gabor Juhos6612a682013-08-28 10:41:46 +020085 unsigned long ref_rate;
86 unsigned long cpu_rate;
87 unsigned long ddr_rate;
88 unsigned long ahb_rate;
Gabor Juhosd4a67d92011-01-04 21:28:14 +010089 u32 pll;
90 u32 freq;
91 u32 div;
92
Gabor Juhos6612a682013-08-28 10:41:46 +020093 ref_rate = AR71XX_BASE_FREQ;
Gabor Juhosd4a67d92011-01-04 21:28:14 +010094
95 pll = ath79_pll_rr(AR71XX_PLL_REG_CPU_CONFIG);
96
Alban Bedel626a0692015-04-19 14:30:02 +020097 div = ((pll >> AR71XX_PLL_FB_SHIFT) & AR71XX_PLL_FB_MASK) + 1;
Gabor Juhos6612a682013-08-28 10:41:46 +020098 freq = div * ref_rate;
Gabor Juhosd4a67d92011-01-04 21:28:14 +010099
100 div = ((pll >> AR71XX_CPU_DIV_SHIFT) & AR71XX_CPU_DIV_MASK) + 1;
Gabor Juhos6612a682013-08-28 10:41:46 +0200101 cpu_rate = freq / div;
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100102
103 div = ((pll >> AR71XX_DDR_DIV_SHIFT) & AR71XX_DDR_DIV_MASK) + 1;
Gabor Juhos6612a682013-08-28 10:41:46 +0200104 ddr_rate = freq / div;
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100105
106 div = (((pll >> AR71XX_AHB_DIV_SHIFT) & AR71XX_AHB_DIV_MASK) + 1) * 2;
Gabor Juhos6612a682013-08-28 10:41:46 +0200107 ahb_rate = cpu_rate / div;
108
Felix Fietkau9b56e0d2019-01-11 15:22:30 +0100109 ath79_set_clk(ATH79_CLK_REF, ref_rate);
110 ath79_set_clk(ATH79_CLK_CPU, cpu_rate);
111 ath79_set_clk(ATH79_CLK_DDR, ddr_rate);
112 ath79_set_clk(ATH79_CLK_AHB, ahb_rate);
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100113
Gabor Juhos2c4f1ac2013-08-28 10:41:47 +0200114 clk_add_alias("wdt", NULL, "ahb", NULL);
115 clk_add_alias("uart", NULL, "ahb", NULL);
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100116}
117
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300118static void __init ar724x_clk_init(struct clk *ref_clk, void __iomem *pll_base)
119{
120 u32 pll;
121 u32 mult, div, ddr_div, ahb_div;
122
123 pll = __raw_readl(pll_base + AR724X_PLL_REG_CPU_CONFIG);
124
125 mult = ((pll >> AR724X_PLL_FB_SHIFT) & AR724X_PLL_FB_MASK);
126 div = ((pll >> AR724X_PLL_REF_DIV_SHIFT) & AR724X_PLL_REF_DIV_MASK) * 2;
127
128 ddr_div = ((pll >> AR724X_DDR_DIV_SHIFT) & AR724X_DDR_DIV_MASK) + 1;
129 ahb_div = (((pll >> AR724X_AHB_DIV_SHIFT) & AR724X_AHB_DIV_MASK) + 1) * 2;
130
Felix Fietkau9b56e0d2019-01-11 15:22:30 +0100131 ath79_set_ff_clk(ATH79_CLK_CPU, "ref", mult, div);
132 ath79_set_ff_clk(ATH79_CLK_DDR, "ref", mult, div * ddr_div);
133 ath79_set_ff_clk(ATH79_CLK_AHB, "ref", mult, div * ahb_div);
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300134}
135
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100136static void __init ar724x_clocks_init(void)
137{
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300138 struct clk *ref_clk;
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100139
Felix Fietkau9b56e0d2019-01-11 15:22:30 +0100140 ref_clk = ath79_set_clk(ATH79_CLK_REF, AR724X_BASE_FREQ);
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100141
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300142 ar724x_clk_init(ref_clk, ath79_pll_base);
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100143
Gabor Juhos2c4f1ac2013-08-28 10:41:47 +0200144 clk_add_alias("wdt", NULL, "ahb", NULL);
145 clk_add_alias("uart", NULL, "ahb", NULL);
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100146}
147
Antony Pavlov5ae5c452016-03-17 06:34:18 +0300148static void __init ar9330_clk_init(struct clk *ref_clk, void __iomem *pll_base)
149{
150 u32 clock_ctrl;
151 u32 ref_div;
152 u32 ninit_mul;
153 u32 out_div;
154
155 u32 cpu_div;
156 u32 ddr_div;
157 u32 ahb_div;
158
159 clock_ctrl = __raw_readl(pll_base + AR933X_PLL_CLOCK_CTRL_REG);
160 if (clock_ctrl & AR933X_PLL_CLOCK_CTRL_BYPASS) {
161 ref_div = 1;
162 ninit_mul = 1;
163 out_div = 1;
164
165 cpu_div = 1;
166 ddr_div = 1;
167 ahb_div = 1;
168 } else {
169 u32 cpu_config;
170 u32 t;
171
172 cpu_config = __raw_readl(pll_base + AR933X_PLL_CPU_CONFIG_REG);
173
174 t = (cpu_config >> AR933X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
175 AR933X_PLL_CPU_CONFIG_REFDIV_MASK;
176 ref_div = t;
177
178 ninit_mul = (cpu_config >> AR933X_PLL_CPU_CONFIG_NINT_SHIFT) &
179 AR933X_PLL_CPU_CONFIG_NINT_MASK;
180
181 t = (cpu_config >> AR933X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
182 AR933X_PLL_CPU_CONFIG_OUTDIV_MASK;
183 if (t == 0)
184 t = 1;
185
186 out_div = (1 << t);
187
188 cpu_div = ((clock_ctrl >> AR933X_PLL_CLOCK_CTRL_CPU_DIV_SHIFT) &
189 AR933X_PLL_CLOCK_CTRL_CPU_DIV_MASK) + 1;
190
191 ddr_div = ((clock_ctrl >> AR933X_PLL_CLOCK_CTRL_DDR_DIV_SHIFT) &
192 AR933X_PLL_CLOCK_CTRL_DDR_DIV_MASK) + 1;
193
194 ahb_div = ((clock_ctrl >> AR933X_PLL_CLOCK_CTRL_AHB_DIV_SHIFT) &
195 AR933X_PLL_CLOCK_CTRL_AHB_DIV_MASK) + 1;
196 }
197
Felix Fietkau9b56e0d2019-01-11 15:22:30 +0100198 ath79_set_ff_clk(ATH79_CLK_CPU, "ref", ninit_mul,
199 ref_div * out_div * cpu_div);
200 ath79_set_ff_clk(ATH79_CLK_DDR, "ref", ninit_mul,
201 ref_div * out_div * ddr_div);
202 ath79_set_ff_clk(ATH79_CLK_AHB, "ref", ninit_mul,
203 ref_div * out_div * ahb_div);
Antony Pavlov5ae5c452016-03-17 06:34:18 +0300204}
205
Gabor Juhos04225e12011-06-20 21:26:04 +0200206static void __init ar933x_clocks_init(void)
207{
Antony Pavlov5ae5c452016-03-17 06:34:18 +0300208 struct clk *ref_clk;
Gabor Juhos6612a682013-08-28 10:41:46 +0200209 unsigned long ref_rate;
Gabor Juhos04225e12011-06-20 21:26:04 +0200210 u32 t;
211
212 t = ath79_reset_rr(AR933X_RESET_REG_BOOTSTRAP);
213 if (t & AR933X_BOOTSTRAP_REF_CLK_40)
Gabor Juhos6612a682013-08-28 10:41:46 +0200214 ref_rate = (40 * 1000 * 1000);
Gabor Juhos04225e12011-06-20 21:26:04 +0200215 else
Gabor Juhos6612a682013-08-28 10:41:46 +0200216 ref_rate = (25 * 1000 * 1000);
Gabor Juhos04225e12011-06-20 21:26:04 +0200217
Felix Fietkau9b56e0d2019-01-11 15:22:30 +0100218 ref_clk = ath79_set_clk(ATH79_CLK_REF, ref_rate);
Gabor Juhos04225e12011-06-20 21:26:04 +0200219
Antony Pavlov5ae5c452016-03-17 06:34:18 +0300220 ar9330_clk_init(ref_clk, ath79_pll_base);
Gabor Juhos04225e12011-06-20 21:26:04 +0200221
Gabor Juhos2c4f1ac2013-08-28 10:41:47 +0200222 clk_add_alias("wdt", NULL, "ahb", NULL);
223 clk_add_alias("uart", NULL, "ref", NULL);
Gabor Juhos04225e12011-06-20 21:26:04 +0200224}
225
Gabor Juhos97541cc2012-09-08 14:02:21 +0200226static u32 __init ar934x_get_pll_freq(u32 ref, u32 ref_div, u32 nint, u32 nfrac,
227 u32 frac, u32 out_div)
228{
229 u64 t;
230 u32 ret;
231
Gabor Juhos837f0362013-08-28 10:41:43 +0200232 t = ref;
Gabor Juhos97541cc2012-09-08 14:02:21 +0200233 t *= nint;
234 do_div(t, ref_div);
235 ret = t;
236
Gabor Juhos837f0362013-08-28 10:41:43 +0200237 t = ref;
Gabor Juhos97541cc2012-09-08 14:02:21 +0200238 t *= nfrac;
239 do_div(t, ref_div * frac);
240 ret += t;
241
242 ret /= (1 << out_div);
243 return ret;
244}
245
Gabor Juhos88896122012-03-14 10:45:22 +0100246static void __init ar934x_clocks_init(void)
247{
Gabor Juhos6612a682013-08-28 10:41:46 +0200248 unsigned long ref_rate;
249 unsigned long cpu_rate;
250 unsigned long ddr_rate;
251 unsigned long ahb_rate;
Gabor Juhos97541cc2012-09-08 14:02:21 +0200252 u32 pll, out_div, ref_div, nint, nfrac, frac, clk_ctrl, postdiv;
Gabor Juhos88896122012-03-14 10:45:22 +0100253 u32 cpu_pll, ddr_pll;
254 u32 bootstrap;
Gabor Juhos97541cc2012-09-08 14:02:21 +0200255 void __iomem *dpll_base;
256
257 dpll_base = ioremap(AR934X_SRIF_BASE, AR934X_SRIF_SIZE);
Gabor Juhos88896122012-03-14 10:45:22 +0100258
259 bootstrap = ath79_reset_rr(AR934X_RESET_REG_BOOTSTRAP);
Ralf Baechle70342282013-01-22 12:59:30 +0100260 if (bootstrap & AR934X_BOOTSTRAP_REF_CLK_40)
Gabor Juhos6612a682013-08-28 10:41:46 +0200261 ref_rate = 40 * 1000 * 1000;
Gabor Juhos88896122012-03-14 10:45:22 +0100262 else
Gabor Juhos6612a682013-08-28 10:41:46 +0200263 ref_rate = 25 * 1000 * 1000;
Gabor Juhos88896122012-03-14 10:45:22 +0100264
Gabor Juhos97541cc2012-09-08 14:02:21 +0200265 pll = __raw_readl(dpll_base + AR934X_SRIF_CPU_DPLL2_REG);
266 if (pll & AR934X_SRIF_DPLL2_LOCAL_PLL) {
267 out_div = (pll >> AR934X_SRIF_DPLL2_OUTDIV_SHIFT) &
268 AR934X_SRIF_DPLL2_OUTDIV_MASK;
269 pll = __raw_readl(dpll_base + AR934X_SRIF_CPU_DPLL1_REG);
270 nint = (pll >> AR934X_SRIF_DPLL1_NINT_SHIFT) &
271 AR934X_SRIF_DPLL1_NINT_MASK;
272 nfrac = pll & AR934X_SRIF_DPLL1_NFRAC_MASK;
273 ref_div = (pll >> AR934X_SRIF_DPLL1_REFDIV_SHIFT) &
274 AR934X_SRIF_DPLL1_REFDIV_MASK;
275 frac = 1 << 18;
276 } else {
277 pll = ath79_pll_rr(AR934X_PLL_CPU_CONFIG_REG);
278 out_div = (pll >> AR934X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
279 AR934X_PLL_CPU_CONFIG_OUTDIV_MASK;
280 ref_div = (pll >> AR934X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
281 AR934X_PLL_CPU_CONFIG_REFDIV_MASK;
282 nint = (pll >> AR934X_PLL_CPU_CONFIG_NINT_SHIFT) &
283 AR934X_PLL_CPU_CONFIG_NINT_MASK;
284 nfrac = (pll >> AR934X_PLL_CPU_CONFIG_NFRAC_SHIFT) &
285 AR934X_PLL_CPU_CONFIG_NFRAC_MASK;
286 frac = 1 << 6;
287 }
Gabor Juhos88896122012-03-14 10:45:22 +0100288
Gabor Juhos6612a682013-08-28 10:41:46 +0200289 cpu_pll = ar934x_get_pll_freq(ref_rate, ref_div, nint,
Gabor Juhos97541cc2012-09-08 14:02:21 +0200290 nfrac, frac, out_div);
Gabor Juhos88896122012-03-14 10:45:22 +0100291
Gabor Juhos97541cc2012-09-08 14:02:21 +0200292 pll = __raw_readl(dpll_base + AR934X_SRIF_DDR_DPLL2_REG);
293 if (pll & AR934X_SRIF_DPLL2_LOCAL_PLL) {
294 out_div = (pll >> AR934X_SRIF_DPLL2_OUTDIV_SHIFT) &
295 AR934X_SRIF_DPLL2_OUTDIV_MASK;
296 pll = __raw_readl(dpll_base + AR934X_SRIF_DDR_DPLL1_REG);
297 nint = (pll >> AR934X_SRIF_DPLL1_NINT_SHIFT) &
298 AR934X_SRIF_DPLL1_NINT_MASK;
299 nfrac = pll & AR934X_SRIF_DPLL1_NFRAC_MASK;
300 ref_div = (pll >> AR934X_SRIF_DPLL1_REFDIV_SHIFT) &
301 AR934X_SRIF_DPLL1_REFDIV_MASK;
302 frac = 1 << 18;
303 } else {
304 pll = ath79_pll_rr(AR934X_PLL_DDR_CONFIG_REG);
305 out_div = (pll >> AR934X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
306 AR934X_PLL_DDR_CONFIG_OUTDIV_MASK;
307 ref_div = (pll >> AR934X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
308 AR934X_PLL_DDR_CONFIG_REFDIV_MASK;
309 nint = (pll >> AR934X_PLL_DDR_CONFIG_NINT_SHIFT) &
310 AR934X_PLL_DDR_CONFIG_NINT_MASK;
311 nfrac = (pll >> AR934X_PLL_DDR_CONFIG_NFRAC_SHIFT) &
312 AR934X_PLL_DDR_CONFIG_NFRAC_MASK;
313 frac = 1 << 10;
314 }
Gabor Juhos88896122012-03-14 10:45:22 +0100315
Gabor Juhos6612a682013-08-28 10:41:46 +0200316 ddr_pll = ar934x_get_pll_freq(ref_rate, ref_div, nint,
Gabor Juhos97541cc2012-09-08 14:02:21 +0200317 nfrac, frac, out_div);
Gabor Juhos88896122012-03-14 10:45:22 +0100318
319 clk_ctrl = ath79_pll_rr(AR934X_PLL_CPU_DDR_CLK_CTRL_REG);
320
321 postdiv = (clk_ctrl >> AR934X_PLL_CPU_DDR_CLK_CTRL_CPU_POST_DIV_SHIFT) &
322 AR934X_PLL_CPU_DDR_CLK_CTRL_CPU_POST_DIV_MASK;
323
324 if (clk_ctrl & AR934X_PLL_CPU_DDR_CLK_CTRL_CPU_PLL_BYPASS)
Gabor Juhos6612a682013-08-28 10:41:46 +0200325 cpu_rate = ref_rate;
Gabor Juhos88896122012-03-14 10:45:22 +0100326 else if (clk_ctrl & AR934X_PLL_CPU_DDR_CLK_CTRL_CPUCLK_FROM_CPUPLL)
Gabor Juhos6612a682013-08-28 10:41:46 +0200327 cpu_rate = cpu_pll / (postdiv + 1);
Gabor Juhos88896122012-03-14 10:45:22 +0100328 else
Gabor Juhos6612a682013-08-28 10:41:46 +0200329 cpu_rate = ddr_pll / (postdiv + 1);
Gabor Juhos88896122012-03-14 10:45:22 +0100330
331 postdiv = (clk_ctrl >> AR934X_PLL_CPU_DDR_CLK_CTRL_DDR_POST_DIV_SHIFT) &
332 AR934X_PLL_CPU_DDR_CLK_CTRL_DDR_POST_DIV_MASK;
333
334 if (clk_ctrl & AR934X_PLL_CPU_DDR_CLK_CTRL_DDR_PLL_BYPASS)
Gabor Juhos6612a682013-08-28 10:41:46 +0200335 ddr_rate = ref_rate;
Gabor Juhos88896122012-03-14 10:45:22 +0100336 else if (clk_ctrl & AR934X_PLL_CPU_DDR_CLK_CTRL_DDRCLK_FROM_DDRPLL)
Gabor Juhos6612a682013-08-28 10:41:46 +0200337 ddr_rate = ddr_pll / (postdiv + 1);
Gabor Juhos88896122012-03-14 10:45:22 +0100338 else
Gabor Juhos6612a682013-08-28 10:41:46 +0200339 ddr_rate = cpu_pll / (postdiv + 1);
Gabor Juhos88896122012-03-14 10:45:22 +0100340
341 postdiv = (clk_ctrl >> AR934X_PLL_CPU_DDR_CLK_CTRL_AHB_POST_DIV_SHIFT) &
342 AR934X_PLL_CPU_DDR_CLK_CTRL_AHB_POST_DIV_MASK;
343
344 if (clk_ctrl & AR934X_PLL_CPU_DDR_CLK_CTRL_AHB_PLL_BYPASS)
Gabor Juhos6612a682013-08-28 10:41:46 +0200345 ahb_rate = ref_rate;
Gabor Juhos88896122012-03-14 10:45:22 +0100346 else if (clk_ctrl & AR934X_PLL_CPU_DDR_CLK_CTRL_AHBCLK_FROM_DDRPLL)
Gabor Juhos6612a682013-08-28 10:41:46 +0200347 ahb_rate = ddr_pll / (postdiv + 1);
Gabor Juhos88896122012-03-14 10:45:22 +0100348 else
Gabor Juhos6612a682013-08-28 10:41:46 +0200349 ahb_rate = cpu_pll / (postdiv + 1);
350
Felix Fietkau9b56e0d2019-01-11 15:22:30 +0100351 ath79_set_clk(ATH79_CLK_REF, ref_rate);
352 ath79_set_clk(ATH79_CLK_CPU, cpu_rate);
353 ath79_set_clk(ATH79_CLK_DDR, ddr_rate);
354 ath79_set_clk(ATH79_CLK_AHB, ahb_rate);
Gabor Juhos88896122012-03-14 10:45:22 +0100355
Gabor Juhos2c4f1ac2013-08-28 10:41:47 +0200356 clk_add_alias("wdt", NULL, "ref", NULL);
357 clk_add_alias("uart", NULL, "ref", NULL);
Gabor Juhos97541cc2012-09-08 14:02:21 +0200358
359 iounmap(dpll_base);
Gabor Juhos88896122012-03-14 10:45:22 +0100360}
361
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200362static void __init qca953x_clocks_init(void)
363{
364 unsigned long ref_rate;
365 unsigned long cpu_rate;
366 unsigned long ddr_rate;
367 unsigned long ahb_rate;
368 u32 pll, out_div, ref_div, nint, frac, clk_ctrl, postdiv;
369 u32 cpu_pll, ddr_pll;
370 u32 bootstrap;
371
372 bootstrap = ath79_reset_rr(QCA953X_RESET_REG_BOOTSTRAP);
373 if (bootstrap & QCA953X_BOOTSTRAP_REF_CLK_40)
374 ref_rate = 40 * 1000 * 1000;
375 else
376 ref_rate = 25 * 1000 * 1000;
377
378 pll = ath79_pll_rr(QCA953X_PLL_CPU_CONFIG_REG);
379 out_div = (pll >> QCA953X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
380 QCA953X_PLL_CPU_CONFIG_OUTDIV_MASK;
381 ref_div = (pll >> QCA953X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
382 QCA953X_PLL_CPU_CONFIG_REFDIV_MASK;
383 nint = (pll >> QCA953X_PLL_CPU_CONFIG_NINT_SHIFT) &
384 QCA953X_PLL_CPU_CONFIG_NINT_MASK;
385 frac = (pll >> QCA953X_PLL_CPU_CONFIG_NFRAC_SHIFT) &
386 QCA953X_PLL_CPU_CONFIG_NFRAC_MASK;
387
388 cpu_pll = nint * ref_rate / ref_div;
389 cpu_pll += frac * (ref_rate >> 6) / ref_div;
390 cpu_pll /= (1 << out_div);
391
392 pll = ath79_pll_rr(QCA953X_PLL_DDR_CONFIG_REG);
393 out_div = (pll >> QCA953X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
394 QCA953X_PLL_DDR_CONFIG_OUTDIV_MASK;
395 ref_div = (pll >> QCA953X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
396 QCA953X_PLL_DDR_CONFIG_REFDIV_MASK;
397 nint = (pll >> QCA953X_PLL_DDR_CONFIG_NINT_SHIFT) &
398 QCA953X_PLL_DDR_CONFIG_NINT_MASK;
399 frac = (pll >> QCA953X_PLL_DDR_CONFIG_NFRAC_SHIFT) &
400 QCA953X_PLL_DDR_CONFIG_NFRAC_MASK;
401
402 ddr_pll = nint * ref_rate / ref_div;
403 ddr_pll += frac * (ref_rate >> 6) / (ref_div << 4);
404 ddr_pll /= (1 << out_div);
405
406 clk_ctrl = ath79_pll_rr(QCA953X_PLL_CLK_CTRL_REG);
407
408 postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT) &
409 QCA953X_PLL_CLK_CTRL_CPU_POST_DIV_MASK;
410
411 if (clk_ctrl & QCA953X_PLL_CLK_CTRL_CPU_PLL_BYPASS)
412 cpu_rate = ref_rate;
413 else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_CPUCLK_FROM_CPUPLL)
414 cpu_rate = cpu_pll / (postdiv + 1);
415 else
416 cpu_rate = ddr_pll / (postdiv + 1);
417
418 postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT) &
419 QCA953X_PLL_CLK_CTRL_DDR_POST_DIV_MASK;
420
421 if (clk_ctrl & QCA953X_PLL_CLK_CTRL_DDR_PLL_BYPASS)
422 ddr_rate = ref_rate;
423 else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL)
424 ddr_rate = ddr_pll / (postdiv + 1);
425 else
426 ddr_rate = cpu_pll / (postdiv + 1);
427
428 postdiv = (clk_ctrl >> QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT) &
429 QCA953X_PLL_CLK_CTRL_AHB_POST_DIV_MASK;
430
431 if (clk_ctrl & QCA953X_PLL_CLK_CTRL_AHB_PLL_BYPASS)
432 ahb_rate = ref_rate;
433 else if (clk_ctrl & QCA953X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL)
434 ahb_rate = ddr_pll / (postdiv + 1);
435 else
436 ahb_rate = cpu_pll / (postdiv + 1);
437
Felix Fietkau9b56e0d2019-01-11 15:22:30 +0100438 ath79_set_clk(ATH79_CLK_REF, ref_rate);
439 ath79_set_clk(ATH79_CLK_CPU, cpu_rate);
440 ath79_set_clk(ATH79_CLK_DDR, ddr_rate);
441 ath79_set_clk(ATH79_CLK_AHB, ahb_rate);
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200442
443 clk_add_alias("wdt", NULL, "ref", NULL);
444 clk_add_alias("uart", NULL, "ref", NULL);
445}
446
Gabor Juhos41583c02013-02-15 13:38:17 +0000447static void __init qca955x_clocks_init(void)
448{
Gabor Juhos6612a682013-08-28 10:41:46 +0200449 unsigned long ref_rate;
450 unsigned long cpu_rate;
451 unsigned long ddr_rate;
452 unsigned long ahb_rate;
Gabor Juhos41583c02013-02-15 13:38:17 +0000453 u32 pll, out_div, ref_div, nint, frac, clk_ctrl, postdiv;
454 u32 cpu_pll, ddr_pll;
455 u32 bootstrap;
456
457 bootstrap = ath79_reset_rr(QCA955X_RESET_REG_BOOTSTRAP);
458 if (bootstrap & QCA955X_BOOTSTRAP_REF_CLK_40)
Gabor Juhos6612a682013-08-28 10:41:46 +0200459 ref_rate = 40 * 1000 * 1000;
Gabor Juhos41583c02013-02-15 13:38:17 +0000460 else
Gabor Juhos6612a682013-08-28 10:41:46 +0200461 ref_rate = 25 * 1000 * 1000;
Gabor Juhos41583c02013-02-15 13:38:17 +0000462
463 pll = ath79_pll_rr(QCA955X_PLL_CPU_CONFIG_REG);
464 out_div = (pll >> QCA955X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
465 QCA955X_PLL_CPU_CONFIG_OUTDIV_MASK;
466 ref_div = (pll >> QCA955X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
467 QCA955X_PLL_CPU_CONFIG_REFDIV_MASK;
468 nint = (pll >> QCA955X_PLL_CPU_CONFIG_NINT_SHIFT) &
469 QCA955X_PLL_CPU_CONFIG_NINT_MASK;
470 frac = (pll >> QCA955X_PLL_CPU_CONFIG_NFRAC_SHIFT) &
471 QCA955X_PLL_CPU_CONFIG_NFRAC_MASK;
472
Gabor Juhos6612a682013-08-28 10:41:46 +0200473 cpu_pll = nint * ref_rate / ref_div;
474 cpu_pll += frac * ref_rate / (ref_div * (1 << 6));
Gabor Juhos41583c02013-02-15 13:38:17 +0000475 cpu_pll /= (1 << out_div);
476
477 pll = ath79_pll_rr(QCA955X_PLL_DDR_CONFIG_REG);
478 out_div = (pll >> QCA955X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
479 QCA955X_PLL_DDR_CONFIG_OUTDIV_MASK;
480 ref_div = (pll >> QCA955X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
481 QCA955X_PLL_DDR_CONFIG_REFDIV_MASK;
482 nint = (pll >> QCA955X_PLL_DDR_CONFIG_NINT_SHIFT) &
483 QCA955X_PLL_DDR_CONFIG_NINT_MASK;
484 frac = (pll >> QCA955X_PLL_DDR_CONFIG_NFRAC_SHIFT) &
485 QCA955X_PLL_DDR_CONFIG_NFRAC_MASK;
486
Gabor Juhos6612a682013-08-28 10:41:46 +0200487 ddr_pll = nint * ref_rate / ref_div;
488 ddr_pll += frac * ref_rate / (ref_div * (1 << 10));
Gabor Juhos41583c02013-02-15 13:38:17 +0000489 ddr_pll /= (1 << out_div);
490
491 clk_ctrl = ath79_pll_rr(QCA955X_PLL_CLK_CTRL_REG);
492
493 postdiv = (clk_ctrl >> QCA955X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT) &
494 QCA955X_PLL_CLK_CTRL_CPU_POST_DIV_MASK;
495
496 if (clk_ctrl & QCA955X_PLL_CLK_CTRL_CPU_PLL_BYPASS)
Gabor Juhos6612a682013-08-28 10:41:46 +0200497 cpu_rate = ref_rate;
Gabor Juhos41583c02013-02-15 13:38:17 +0000498 else if (clk_ctrl & QCA955X_PLL_CLK_CTRL_CPUCLK_FROM_CPUPLL)
Gabor Juhos6612a682013-08-28 10:41:46 +0200499 cpu_rate = ddr_pll / (postdiv + 1);
Gabor Juhos41583c02013-02-15 13:38:17 +0000500 else
Gabor Juhos6612a682013-08-28 10:41:46 +0200501 cpu_rate = cpu_pll / (postdiv + 1);
Gabor Juhos41583c02013-02-15 13:38:17 +0000502
503 postdiv = (clk_ctrl >> QCA955X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT) &
504 QCA955X_PLL_CLK_CTRL_DDR_POST_DIV_MASK;
505
506 if (clk_ctrl & QCA955X_PLL_CLK_CTRL_DDR_PLL_BYPASS)
Gabor Juhos6612a682013-08-28 10:41:46 +0200507 ddr_rate = ref_rate;
Gabor Juhos41583c02013-02-15 13:38:17 +0000508 else if (clk_ctrl & QCA955X_PLL_CLK_CTRL_DDRCLK_FROM_DDRPLL)
Gabor Juhos6612a682013-08-28 10:41:46 +0200509 ddr_rate = cpu_pll / (postdiv + 1);
Gabor Juhos41583c02013-02-15 13:38:17 +0000510 else
Gabor Juhos6612a682013-08-28 10:41:46 +0200511 ddr_rate = ddr_pll / (postdiv + 1);
Gabor Juhos41583c02013-02-15 13:38:17 +0000512
513 postdiv = (clk_ctrl >> QCA955X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT) &
514 QCA955X_PLL_CLK_CTRL_AHB_POST_DIV_MASK;
515
516 if (clk_ctrl & QCA955X_PLL_CLK_CTRL_AHB_PLL_BYPASS)
Gabor Juhos6612a682013-08-28 10:41:46 +0200517 ahb_rate = ref_rate;
Gabor Juhos41583c02013-02-15 13:38:17 +0000518 else if (clk_ctrl & QCA955X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL)
Gabor Juhos6612a682013-08-28 10:41:46 +0200519 ahb_rate = ddr_pll / (postdiv + 1);
Gabor Juhos41583c02013-02-15 13:38:17 +0000520 else
Gabor Juhos6612a682013-08-28 10:41:46 +0200521 ahb_rate = cpu_pll / (postdiv + 1);
522
Felix Fietkau9b56e0d2019-01-11 15:22:30 +0100523 ath79_set_clk(ATH79_CLK_REF, ref_rate);
524 ath79_set_clk(ATH79_CLK_CPU, cpu_rate);
525 ath79_set_clk(ATH79_CLK_DDR, ddr_rate);
526 ath79_set_clk(ATH79_CLK_AHB, ahb_rate);
Gabor Juhos41583c02013-02-15 13:38:17 +0000527
Gabor Juhos2c4f1ac2013-08-28 10:41:47 +0200528 clk_add_alias("wdt", NULL, "ref", NULL);
529 clk_add_alias("uart", NULL, "ref", NULL);
Gabor Juhos41583c02013-02-15 13:38:17 +0000530}
531
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200532static void __init qca956x_clocks_init(void)
533{
534 unsigned long ref_rate;
535 unsigned long cpu_rate;
536 unsigned long ddr_rate;
537 unsigned long ahb_rate;
538 u32 pll, out_div, ref_div, nint, hfrac, lfrac, clk_ctrl, postdiv;
539 u32 cpu_pll, ddr_pll;
540 u32 bootstrap;
541
542 /*
543 * QCA956x timer init workaround has to be applied right before setting
544 * up the clock. Else, there will be no jiffies
545 */
546 u32 misc;
547
548 misc = ath79_reset_rr(AR71XX_RESET_REG_MISC_INT_ENABLE);
549 misc |= MISC_INT_MIPS_SI_TIMERINT_MASK;
550 ath79_reset_wr(AR71XX_RESET_REG_MISC_INT_ENABLE, misc);
551
552 bootstrap = ath79_reset_rr(QCA956X_RESET_REG_BOOTSTRAP);
553 if (bootstrap & QCA956X_BOOTSTRAP_REF_CLK_40)
554 ref_rate = 40 * 1000 * 1000;
555 else
556 ref_rate = 25 * 1000 * 1000;
557
558 pll = ath79_pll_rr(QCA956X_PLL_CPU_CONFIG_REG);
559 out_div = (pll >> QCA956X_PLL_CPU_CONFIG_OUTDIV_SHIFT) &
560 QCA956X_PLL_CPU_CONFIG_OUTDIV_MASK;
561 ref_div = (pll >> QCA956X_PLL_CPU_CONFIG_REFDIV_SHIFT) &
562 QCA956X_PLL_CPU_CONFIG_REFDIV_MASK;
563
564 pll = ath79_pll_rr(QCA956X_PLL_CPU_CONFIG1_REG);
565 nint = (pll >> QCA956X_PLL_CPU_CONFIG1_NINT_SHIFT) &
566 QCA956X_PLL_CPU_CONFIG1_NINT_MASK;
567 hfrac = (pll >> QCA956X_PLL_CPU_CONFIG1_NFRAC_H_SHIFT) &
568 QCA956X_PLL_CPU_CONFIG1_NFRAC_H_MASK;
569 lfrac = (pll >> QCA956X_PLL_CPU_CONFIG1_NFRAC_L_SHIFT) &
570 QCA956X_PLL_CPU_CONFIG1_NFRAC_L_MASK;
571
572 cpu_pll = nint * ref_rate / ref_div;
573 cpu_pll += (lfrac * ref_rate) / ((ref_div * 25) << 13);
574 cpu_pll += (hfrac >> 13) * ref_rate / ref_div;
575 cpu_pll /= (1 << out_div);
576
577 pll = ath79_pll_rr(QCA956X_PLL_DDR_CONFIG_REG);
578 out_div = (pll >> QCA956X_PLL_DDR_CONFIG_OUTDIV_SHIFT) &
579 QCA956X_PLL_DDR_CONFIG_OUTDIV_MASK;
580 ref_div = (pll >> QCA956X_PLL_DDR_CONFIG_REFDIV_SHIFT) &
581 QCA956X_PLL_DDR_CONFIG_REFDIV_MASK;
582 pll = ath79_pll_rr(QCA956X_PLL_DDR_CONFIG1_REG);
583 nint = (pll >> QCA956X_PLL_DDR_CONFIG1_NINT_SHIFT) &
584 QCA956X_PLL_DDR_CONFIG1_NINT_MASK;
585 hfrac = (pll >> QCA956X_PLL_DDR_CONFIG1_NFRAC_H_SHIFT) &
586 QCA956X_PLL_DDR_CONFIG1_NFRAC_H_MASK;
587 lfrac = (pll >> QCA956X_PLL_DDR_CONFIG1_NFRAC_L_SHIFT) &
588 QCA956X_PLL_DDR_CONFIG1_NFRAC_L_MASK;
589
590 ddr_pll = nint * ref_rate / ref_div;
591 ddr_pll += (lfrac * ref_rate) / ((ref_div * 25) << 13);
592 ddr_pll += (hfrac >> 13) * ref_rate / ref_div;
593 ddr_pll /= (1 << out_div);
594
595 clk_ctrl = ath79_pll_rr(QCA956X_PLL_CLK_CTRL_REG);
596
597 postdiv = (clk_ctrl >> QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_SHIFT) &
598 QCA956X_PLL_CLK_CTRL_CPU_POST_DIV_MASK;
599
600 if (clk_ctrl & QCA956X_PLL_CLK_CTRL_CPU_PLL_BYPASS)
601 cpu_rate = ref_rate;
602 else if (clk_ctrl & QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_CPUPLL)
603 cpu_rate = ddr_pll / (postdiv + 1);
604 else
605 cpu_rate = cpu_pll / (postdiv + 1);
606
607 postdiv = (clk_ctrl >> QCA956X_PLL_CLK_CTRL_DDR_POST_DIV_SHIFT) &
608 QCA956X_PLL_CLK_CTRL_DDR_POST_DIV_MASK;
609
610 if (clk_ctrl & QCA956X_PLL_CLK_CTRL_DDR_PLL_BYPASS)
611 ddr_rate = ref_rate;
612 else if (clk_ctrl & QCA956X_PLL_CLK_CTRL_CPU_DDRCLK_FROM_DDRPLL)
613 ddr_rate = cpu_pll / (postdiv + 1);
614 else
615 ddr_rate = ddr_pll / (postdiv + 1);
616
617 postdiv = (clk_ctrl >> QCA956X_PLL_CLK_CTRL_AHB_POST_DIV_SHIFT) &
618 QCA956X_PLL_CLK_CTRL_AHB_POST_DIV_MASK;
619
620 if (clk_ctrl & QCA956X_PLL_CLK_CTRL_AHB_PLL_BYPASS)
621 ahb_rate = ref_rate;
622 else if (clk_ctrl & QCA956X_PLL_CLK_CTRL_AHBCLK_FROM_DDRPLL)
623 ahb_rate = ddr_pll / (postdiv + 1);
624 else
625 ahb_rate = cpu_pll / (postdiv + 1);
626
Felix Fietkau9b56e0d2019-01-11 15:22:30 +0100627 ath79_set_clk(ATH79_CLK_REF, ref_rate);
628 ath79_set_clk(ATH79_CLK_CPU, cpu_rate);
629 ath79_set_clk(ATH79_CLK_DDR, ddr_rate);
630 ath79_set_clk(ATH79_CLK_AHB, ahb_rate);
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200631
632 clk_add_alias("wdt", NULL, "ref", NULL);
633 clk_add_alias("uart", NULL, "ref", NULL);
634}
635
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100636void __init ath79_clocks_init(void)
637{
638 if (soc_is_ar71xx())
639 ar71xx_clocks_init();
Alban Bedelf4c87b72016-03-17 06:34:10 +0300640 else if (soc_is_ar724x() || soc_is_ar913x())
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100641 ar724x_clocks_init();
Gabor Juhos04225e12011-06-20 21:26:04 +0200642 else if (soc_is_ar933x())
643 ar933x_clocks_init();
Gabor Juhos88896122012-03-14 10:45:22 +0100644 else if (soc_is_ar934x())
645 ar934x_clocks_init();
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200646 else if (soc_is_qca953x())
647 qca953x_clocks_init();
Gabor Juhos41583c02013-02-15 13:38:17 +0000648 else if (soc_is_qca955x())
649 qca955x_clocks_init();
Matthias Schifferaf2d1b52018-07-20 13:58:19 +0200650 else if (soc_is_qca956x() || soc_is_tp9343())
651 qca956x_clocks_init();
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100652 else
653 BUG();
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100654}
655
Gabor Juhos23107802013-08-28 10:41:44 +0200656unsigned long __init
657ath79_get_sys_clk_rate(const char *id)
658{
659 struct clk *clk;
660 unsigned long rate;
661
662 clk = clk_get(NULL, id);
663 if (IS_ERR(clk))
664 panic("unable to get %s clock, err=%d", id, (int) PTR_ERR(clk));
665
666 rate = clk_get_rate(clk);
667 clk_put(clk);
668
669 return rate;
670}
Alban Bedel6451af02015-05-31 02:18:22 +0200671
672#ifdef CONFIG_OF
673static void __init ath79_clocks_init_dt(struct device_node *np)
674{
675 of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
676}
677
678CLK_OF_DECLARE(ar7100, "qca,ar7100-pll", ath79_clocks_init_dt);
679CLK_OF_DECLARE(ar7240, "qca,ar7240-pll", ath79_clocks_init_dt);
Alban Bedel6451af02015-05-31 02:18:22 +0200680CLK_OF_DECLARE(ar9340, "qca,ar9340-pll", ath79_clocks_init_dt);
681CLK_OF_DECLARE(ar9550, "qca,qca9550-pll", ath79_clocks_init_dt);
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300682
683static void __init ath79_clocks_init_dt_ng(struct device_node *np)
684{
685 struct clk *ref_clk;
686 void __iomem *pll_base;
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300687
688 ref_clk = of_clk_get(np, 0);
689 if (IS_ERR(ref_clk)) {
Rob Herring7f27b5b2017-07-18 16:42:45 -0500690 pr_err("%pOF: of_clk_get failed\n", np);
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300691 goto err;
692 }
693
694 pll_base = of_iomap(np, 0);
695 if (!pll_base) {
Rob Herring7f27b5b2017-07-18 16:42:45 -0500696 pr_err("%pOF: can't map pll registers\n", np);
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300697 goto err_clk;
698 }
699
Antony Pavlov5ae5c452016-03-17 06:34:18 +0300700 if (of_device_is_compatible(np, "qca,ar9130-pll"))
701 ar724x_clk_init(ref_clk, pll_base);
702 else if (of_device_is_compatible(np, "qca,ar9330-pll"))
703 ar9330_clk_init(ref_clk, pll_base);
704 else {
Rob Herring7f27b5b2017-07-18 16:42:45 -0500705 pr_err("%pOF: could not find any appropriate clk_init()\n", np);
Arvind Yadavb3d91db2017-01-02 15:18:21 +0530706 goto err_iounmap;
Antony Pavlov5ae5c452016-03-17 06:34:18 +0300707 }
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300708
709 if (of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data)) {
Rob Herring7f27b5b2017-07-18 16:42:45 -0500710 pr_err("%pOF: could not register clk provider\n", np);
Arvind Yadavb3d91db2017-01-02 15:18:21 +0530711 goto err_iounmap;
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300712 }
713
714 return;
715
Arvind Yadavb3d91db2017-01-02 15:18:21 +0530716err_iounmap:
717 iounmap(pll_base);
718
Antony Pavlov3bdf1072016-03-17 06:34:15 +0300719err_clk:
720 clk_put(ref_clk);
721
722err:
723 return;
724}
725CLK_OF_DECLARE(ar9130_clk, "qca,ar9130-pll", ath79_clocks_init_dt_ng);
Antony Pavlov5ae5c452016-03-17 06:34:18 +0300726CLK_OF_DECLARE(ar9330_clk, "qca,ar9330-pll", ath79_clocks_init_dt_ng);
Alban Bedel6451af02015-05-31 02:18:22 +0200727#endif