aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlban Bedel <albeu@free.fr>2016-03-16 23:34:10 -0400
committerRalf Baechle <ralf@linux-mips.org>2016-04-03 06:32:10 -0400
commitf4c87b7a944adcc34f67a925d50889088fd87992 (patch)
tree657a4ea42ae790d3a2ec9b624ceb7dc1ce902bcf
parentc338d59d12dc93c3287160acd7e726b56dc94f43 (diff)
MIPS: ath79: Fix the ar913x reference clock rate
The reference clock on ar913x is at 40MHz and not 5MHz. The current implementation use the wrong reference rate because it doesn't take the PLL divider in account. But if we fix the code to use the divider it becomes identical with the implementation for ar724x, so just drop the broken ar913x implementation. Signed-off-by: Alban Bedel <albeu@free.fr> Tested-by: Antony Pavlov <antonynpavlov@gmail.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/12871/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r--arch/mips/ath79/clock.c38
1 files changed, 1 insertions, 37 deletions
diff --git a/arch/mips/ath79/clock.c b/arch/mips/ath79/clock.c
index ed2846578405..618dfd735eed 100644
--- a/arch/mips/ath79/clock.c
+++ b/arch/mips/ath79/clock.c
@@ -27,7 +27,6 @@
27 27
28#define AR71XX_BASE_FREQ 40000000 28#define AR71XX_BASE_FREQ 40000000
29#define AR724X_BASE_FREQ 40000000 29#define AR724X_BASE_FREQ 40000000
30#define AR913X_BASE_FREQ 5000000
31 30
32static struct clk *clks[3]; 31static struct clk *clks[3];
33static struct clk_onecell_data clk_data = { 32static struct clk_onecell_data clk_data = {
@@ -123,39 +122,6 @@ static void __init ar724x_clocks_init(void)
123 clk_add_alias("uart", NULL, "ahb", NULL); 122 clk_add_alias("uart", NULL, "ahb", NULL);
124} 123}
125 124
126static void __init ar913x_clocks_init(void)
127{
128 unsigned long ref_rate;
129 unsigned long cpu_rate;
130 unsigned long ddr_rate;
131 unsigned long ahb_rate;
132 u32 pll;
133 u32 freq;
134 u32 div;
135
136 ref_rate = AR913X_BASE_FREQ;
137 pll = ath79_pll_rr(AR913X_PLL_REG_CPU_CONFIG);
138
139 div = ((pll >> AR913X_PLL_FB_SHIFT) & AR913X_PLL_FB_MASK);
140 freq = div * ref_rate;
141
142 cpu_rate = freq;
143
144 div = ((pll >> AR913X_DDR_DIV_SHIFT) & AR913X_DDR_DIV_MASK) + 1;
145 ddr_rate = freq / div;
146
147 div = (((pll >> AR913X_AHB_DIV_SHIFT) & AR913X_AHB_DIV_MASK) + 1) * 2;
148 ahb_rate = cpu_rate / div;
149
150 ath79_add_sys_clkdev("ref", ref_rate);
151 clks[0] = ath79_add_sys_clkdev("cpu", cpu_rate);
152 clks[1] = ath79_add_sys_clkdev("ddr", ddr_rate);
153 clks[2] = ath79_add_sys_clkdev("ahb", ahb_rate);
154
155 clk_add_alias("wdt", NULL, "ahb", NULL);
156 clk_add_alias("uart", NULL, "ahb", NULL);
157}
158
159static void __init ar933x_clocks_init(void) 125static void __init ar933x_clocks_init(void)
160{ 126{
161 unsigned long ref_rate; 127 unsigned long ref_rate;
@@ -443,10 +409,8 @@ void __init ath79_clocks_init(void)
443{ 409{
444 if (soc_is_ar71xx()) 410 if (soc_is_ar71xx())
445 ar71xx_clocks_init(); 411 ar71xx_clocks_init();
446 else if (soc_is_ar724x()) 412 else if (soc_is_ar724x() || soc_is_ar913x())
447 ar724x_clocks_init(); 413 ar724x_clocks_init();
448 else if (soc_is_ar913x())
449 ar913x_clocks_init();
450 else if (soc_is_ar933x()) 414 else if (soc_is_ar933x())
451 ar933x_clocks_init(); 415 ar933x_clocks_init();
452 else if (soc_is_ar934x()) 416 else if (soc_is_ar934x())