Paul Mundt | 253b088 | 2009-05-13 17:38:11 +0900 | [diff] [blame] | 1 | #include <linux/clk.h> |
| 2 | #include <linux/compiler.h> |
Magnus Damm | 4c7eb4e | 2009-06-17 04:55:42 +0000 | [diff] [blame] | 3 | #include <linux/slab.h> |
Magnus Damm | 6881e8b | 2009-05-28 12:52:29 +0000 | [diff] [blame] | 4 | #include <linux/io.h> |
Jean-Christop PLAGNIOL-VILLARD | 6d803ba | 2010-11-17 10:04:33 +0100 | [diff] [blame] | 5 | #include <linux/clkdev.h> |
Paul Mundt | 253b088 | 2009-05-13 17:38:11 +0900 | [diff] [blame] | 6 | #include <asm/clock.h> |
| 7 | |
| 8 | static struct clk master_clk = { |
Paul Mundt | 253b088 | 2009-05-13 17:38:11 +0900 | [diff] [blame] | 9 | .flags = CLK_ENABLE_ON_INIT, |
| 10 | .rate = CONFIG_SH_PCLK_FREQ, |
| 11 | }; |
| 12 | |
| 13 | static struct clk peripheral_clk = { |
Paul Mundt | 253b088 | 2009-05-13 17:38:11 +0900 | [diff] [blame] | 14 | .parent = &master_clk, |
| 15 | .flags = CLK_ENABLE_ON_INIT, |
| 16 | }; |
| 17 | |
| 18 | static struct clk bus_clk = { |
Paul Mundt | 253b088 | 2009-05-13 17:38:11 +0900 | [diff] [blame] | 19 | .parent = &master_clk, |
| 20 | .flags = CLK_ENABLE_ON_INIT, |
| 21 | }; |
| 22 | |
| 23 | static struct clk cpu_clk = { |
Paul Mundt | 253b088 | 2009-05-13 17:38:11 +0900 | [diff] [blame] | 24 | .parent = &master_clk, |
| 25 | .flags = CLK_ENABLE_ON_INIT, |
| 26 | }; |
| 27 | |
| 28 | /* |
| 29 | * The ordering of these clocks matters, do not change it. |
| 30 | */ |
| 31 | static struct clk *onchip_clocks[] = { |
| 32 | &master_clk, |
| 33 | &peripheral_clk, |
| 34 | &bus_clk, |
| 35 | &cpu_clk, |
| 36 | }; |
| 37 | |
Magnus Damm | 53041f0 | 2010-05-11 09:35:11 +0000 | [diff] [blame] | 38 | static struct clk_lookup lookups[] = { |
| 39 | /* main clocks */ |
| 40 | CLKDEV_CON_ID("master_clk", &master_clk), |
| 41 | CLKDEV_CON_ID("peripheral_clk", &peripheral_clk), |
| 42 | CLKDEV_CON_ID("bus_clk", &bus_clk), |
| 43 | CLKDEV_CON_ID("cpu_clk", &cpu_clk), |
| 44 | }; |
| 45 | |
Paul Mundt | 253b088 | 2009-05-13 17:38:11 +0900 | [diff] [blame] | 46 | int __init __deprecated cpg_clk_init(void) |
| 47 | { |
| 48 | int i, ret = 0; |
| 49 | |
| 50 | for (i = 0; i < ARRAY_SIZE(onchip_clocks); i++) { |
| 51 | struct clk *clk = onchip_clocks[i]; |
| 52 | arch_init_clk_ops(&clk->ops, i); |
| 53 | if (clk->ops) |
| 54 | ret |= clk_register(clk); |
| 55 | } |
| 56 | |
Magnus Damm | 53041f0 | 2010-05-11 09:35:11 +0000 | [diff] [blame] | 57 | clkdev_add_table(lookups, ARRAY_SIZE(lookups)); |
| 58 | |
Paul Mundt | 0776d60 | 2010-03-29 17:22:50 +0900 | [diff] [blame] | 59 | clk_add_alias("tmu_fck", NULL, "peripheral_clk", NULL); |
| 60 | clk_add_alias("mtu2_fck", NULL, "peripheral_clk", NULL); |
| 61 | clk_add_alias("cmt_fck", NULL, "peripheral_clk", NULL); |
| 62 | clk_add_alias("sci_ick", NULL, "peripheral_clk", NULL); |
| 63 | |
Paul Mundt | 253b088 | 2009-05-13 17:38:11 +0900 | [diff] [blame] | 64 | return ret; |
| 65 | } |
| 66 | |
| 67 | /* |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 68 | * Placeholder for compatibility, until the lazy CPUs do this |
Paul Mundt | 253b088 | 2009-05-13 17:38:11 +0900 | [diff] [blame] | 69 | * on their own. |
| 70 | */ |
| 71 | int __init __weak arch_clk_init(void) |
| 72 | { |
| 73 | return cpg_clk_init(); |
| 74 | } |