diff options
author | Alban Bedel <albeu@free.fr> | 2015-05-30 20:18:22 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2015-06-21 15:54:06 -0400 |
commit | 6451af0220a538334155261b562776f266fe5f8f (patch) | |
tree | 269a6ee29d2923c809c72d234d9c6468f368fad2 /arch | |
parent | 44fad3323833624941b99dafd982978e1742dd53 (diff) |
MIPS: ath79: Add OF support to the clocks
Allow using the SoC clocks in the device tree.
Signed-off-by: Alban Bedel <albeu@free.fr>
Cc: linux-mips@linux-mips.org
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/mips/ath79/clock.c | 63 |
1 files changed, 44 insertions, 19 deletions
diff --git a/arch/mips/ath79/clock.c b/arch/mips/ath79/clock.c index 1fcb6917783c..eb5117ced95a 100644 --- a/arch/mips/ath79/clock.c +++ b/arch/mips/ath79/clock.c | |||
@@ -29,7 +29,14 @@ | |||
29 | #define AR724X_BASE_FREQ 5000000 | 29 | #define AR724X_BASE_FREQ 5000000 |
30 | #define AR913X_BASE_FREQ 5000000 | 30 | #define AR913X_BASE_FREQ 5000000 |
31 | 31 | ||
32 | static void __init ath79_add_sys_clkdev(const char *id, unsigned long rate) | 32 | static struct clk *clks[3]; |
33 | static struct clk_onecell_data clk_data = { | ||
34 | .clks = clks, | ||
35 | .clk_num = ARRAY_SIZE(clks), | ||
36 | }; | ||
37 | |||
38 | static struct clk *__init ath79_add_sys_clkdev( | ||
39 | const char *id, unsigned long rate) | ||
33 | { | 40 | { |
34 | struct clk *clk; | 41 | struct clk *clk; |
35 | int err; | 42 | int err; |
@@ -41,6 +48,8 @@ static void __init ath79_add_sys_clkdev(const char *id, unsigned long rate) | |||
41 | err = clk_register_clkdev(clk, id, NULL); | 48 | err = clk_register_clkdev(clk, id, NULL); |
42 | if (err) | 49 | if (err) |
43 | panic("unable to register %s clock device", id); | 50 | panic("unable to register %s clock device", id); |
51 | |||
52 | return clk; | ||
44 | } | 53 | } |
45 | 54 | ||
46 | static void __init ar71xx_clocks_init(void) | 55 | static void __init ar71xx_clocks_init(void) |
@@ -70,9 +79,9 @@ static void __init ar71xx_clocks_init(void) | |||
70 | ahb_rate = cpu_rate / div; | 79 | ahb_rate = cpu_rate / div; |
71 | 80 | ||
72 | ath79_add_sys_clkdev("ref", ref_rate); | 81 | ath79_add_sys_clkdev("ref", ref_rate); |
73 | ath79_add_sys_clkdev("cpu", cpu_rate); | 82 | clks[0] = ath79_add_sys_clkdev("cpu", cpu_rate); |
74 | ath79_add_sys_clkdev("ddr", ddr_rate); | 83 | clks[1] = ath79_add_sys_clkdev("ddr", ddr_rate); |
75 | ath79_add_sys_clkdev("ahb", ahb_rate); | 84 | clks[2] = ath79_add_sys_clkdev("ahb", ahb_rate); |
76 | 85 | ||
77 | clk_add_alias("wdt", NULL, "ahb", NULL); | 86 | clk_add_alias("wdt", NULL, "ahb", NULL); |
78 | clk_add_alias("uart", NULL, "ahb", NULL); | 87 | clk_add_alias("uart", NULL, "ahb", NULL); |
@@ -106,9 +115,9 @@ static void __init ar724x_clocks_init(void) | |||
106 | ahb_rate = cpu_rate / div; | 115 | ahb_rate = cpu_rate / div; |
107 | 116 | ||
108 | ath79_add_sys_clkdev("ref", ref_rate); | 117 | ath79_add_sys_clkdev("ref", ref_rate); |
109 | ath79_add_sys_clkdev("cpu", cpu_rate); | 118 | clks[0] = ath79_add_sys_clkdev("cpu", cpu_rate); |
110 | ath79_add_sys_clkdev("ddr", ddr_rate); | 119 | clks[1] = ath79_add_sys_clkdev("ddr", ddr_rate); |
111 | ath79_add_sys_clkdev("ahb", ahb_rate); | 120 | clks[2] = ath79_add_sys_clkdev("ahb", ahb_rate); |
112 | 121 | ||
113 | clk_add_alias("wdt", NULL, "ahb", NULL); | 122 | clk_add_alias("wdt", NULL, "ahb", NULL); |
114 | clk_add_alias("uart", NULL, "ahb", NULL); | 123 | clk_add_alias("uart", NULL, "ahb", NULL); |
@@ -139,9 +148,9 @@ static void __init ar913x_clocks_init(void) | |||
139 | ahb_rate = cpu_rate / div; | 148 | ahb_rate = cpu_rate / div; |
140 | 149 | ||
141 | ath79_add_sys_clkdev("ref", ref_rate); | 150 | ath79_add_sys_clkdev("ref", ref_rate); |
142 | ath79_add_sys_clkdev("cpu", cpu_rate); | 151 | clks[0] = ath79_add_sys_clkdev("cpu", cpu_rate); |
143 | ath79_add_sys_clkdev("ddr", ddr_rate); | 152 | clks[1] = ath79_add_sys_clkdev("ddr", ddr_rate); |
144 | ath79_add_sys_clkdev("ahb", ahb_rate); | 153 | clks[2] = ath79_add_sys_clkdev("ahb", ahb_rate); |
145 | 154 | ||
146 | clk_add_alias("wdt", NULL, "ahb", NULL); | 155 | clk_add_alias("wdt", NULL, "ahb", NULL); |
147 | clk_add_alias("uart", NULL, "ahb", NULL); | 156 | clk_add_alias("uart", NULL, "ahb", NULL); |
@@ -201,9 +210,9 @@ static void __init ar933x_clocks_init(void) | |||
201 | } | 210 | } |
202 | 211 | ||
203 | ath79_add_sys_clkdev("ref", ref_rate); | 212 | ath79_add_sys_clkdev("ref", ref_rate); |
204 | ath79_add_sys_clkdev("cpu", cpu_rate); | 213 | clks[0] = ath79_add_sys_clkdev("cpu", cpu_rate); |
205 | ath79_add_sys_clkdev("ddr", ddr_rate); | 214 | clks[1] = ath79_add_sys_clkdev("ddr", ddr_rate); |
206 | ath79_add_sys_clkdev("ahb", ahb_rate); | 215 | clks[2] = ath79_add_sys_clkdev("ahb", ahb_rate); |
207 | 216 | ||
208 | clk_add_alias("wdt", NULL, "ahb", NULL); | 217 | clk_add_alias("wdt", NULL, "ahb", NULL); |
209 | clk_add_alias("uart", NULL, "ref", NULL); | 218 | clk_add_alias("uart", NULL, "ref", NULL); |
@@ -335,9 +344,9 @@ static void __init ar934x_clocks_init(void) | |||
335 | ahb_rate = cpu_pll / (postdiv + 1); | 344 | ahb_rate = cpu_pll / (postdiv + 1); |
336 | 345 | ||
337 | ath79_add_sys_clkdev("ref", ref_rate); | 346 | ath79_add_sys_clkdev("ref", ref_rate); |
338 | ath79_add_sys_clkdev("cpu", cpu_rate); | 347 | clks[0] = ath79_add_sys_clkdev("cpu", cpu_rate); |
339 | ath79_add_sys_clkdev("ddr", ddr_rate); | 348 | clks[1] = ath79_add_sys_clkdev("ddr", ddr_rate); |
340 | ath79_add_sys_clkdev("ahb", ahb_rate); | 349 | clks[2] = ath79_add_sys_clkdev("ahb", ahb_rate); |
341 | 350 | ||
342 | clk_add_alias("wdt", NULL, "ref", NULL); | 351 | clk_add_alias("wdt", NULL, "ref", NULL); |
343 | clk_add_alias("uart", NULL, "ref", NULL); | 352 | clk_add_alias("uart", NULL, "ref", NULL); |
@@ -422,9 +431,9 @@ static void __init qca955x_clocks_init(void) | |||
422 | ahb_rate = cpu_pll / (postdiv + 1); | 431 | ahb_rate = cpu_pll / (postdiv + 1); |
423 | 432 | ||
424 | ath79_add_sys_clkdev("ref", ref_rate); | 433 | ath79_add_sys_clkdev("ref", ref_rate); |
425 | ath79_add_sys_clkdev("cpu", cpu_rate); | 434 | clks[0] = ath79_add_sys_clkdev("cpu", cpu_rate); |
426 | ath79_add_sys_clkdev("ddr", ddr_rate); | 435 | clks[1] = ath79_add_sys_clkdev("ddr", ddr_rate); |
427 | ath79_add_sys_clkdev("ahb", ahb_rate); | 436 | clks[2] = ath79_add_sys_clkdev("ahb", ahb_rate); |
428 | 437 | ||
429 | clk_add_alias("wdt", NULL, "ref", NULL); | 438 | clk_add_alias("wdt", NULL, "ref", NULL); |
430 | clk_add_alias("uart", NULL, "ref", NULL); | 439 | clk_add_alias("uart", NULL, "ref", NULL); |
@@ -446,6 +455,8 @@ void __init ath79_clocks_init(void) | |||
446 | qca955x_clocks_init(); | 455 | qca955x_clocks_init(); |
447 | else | 456 | else |
448 | BUG(); | 457 | BUG(); |
458 | |||
459 | of_clk_init(NULL); | ||
449 | } | 460 | } |
450 | 461 | ||
451 | unsigned long __init | 462 | unsigned long __init |
@@ -463,3 +474,17 @@ ath79_get_sys_clk_rate(const char *id) | |||
463 | 474 | ||
464 | return rate; | 475 | return rate; |
465 | } | 476 | } |
477 | |||
478 | #ifdef CONFIG_OF | ||
479 | static void __init ath79_clocks_init_dt(struct device_node *np) | ||
480 | { | ||
481 | of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); | ||
482 | } | ||
483 | |||
484 | CLK_OF_DECLARE(ar7100, "qca,ar7100-pll", ath79_clocks_init_dt); | ||
485 | CLK_OF_DECLARE(ar7240, "qca,ar7240-pll", ath79_clocks_init_dt); | ||
486 | CLK_OF_DECLARE(ar9130, "qca,ar9130-pll", ath79_clocks_init_dt); | ||
487 | CLK_OF_DECLARE(ar9330, "qca,ar9330-pll", ath79_clocks_init_dt); | ||
488 | CLK_OF_DECLARE(ar9340, "qca,ar9340-pll", ath79_clocks_init_dt); | ||
489 | CLK_OF_DECLARE(ar9550, "qca,qca9550-pll", ath79_clocks_init_dt); | ||
490 | #endif | ||