diff options
Diffstat (limited to 'arch/sh/kernel/cpu/sh4a/clock-sh7780.c')
-rw-r--r-- | arch/sh/kernel/cpu/sh4a/clock-sh7780.c | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c index 01f3da619d3d..a249d823578e 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7780.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7780.c | |||
@@ -29,30 +29,30 @@ static struct clk_ops sh7780_master_clk_ops = { | |||
29 | .init = master_clk_init, | 29 | .init = master_clk_init, |
30 | }; | 30 | }; |
31 | 31 | ||
32 | static void module_clk_recalc(struct clk *clk) | 32 | static unsigned long module_clk_recalc(struct clk *clk) |
33 | { | 33 | { |
34 | int idx = (ctrl_inl(FRQCR) & 0x0003); | 34 | int idx = (ctrl_inl(FRQCR) & 0x0003); |
35 | clk->rate = clk->parent->rate / pfc_divisors[idx]; | 35 | return clk->parent->rate / pfc_divisors[idx]; |
36 | } | 36 | } |
37 | 37 | ||
38 | static struct clk_ops sh7780_module_clk_ops = { | 38 | static struct clk_ops sh7780_module_clk_ops = { |
39 | .recalc = module_clk_recalc, | 39 | .recalc = module_clk_recalc, |
40 | }; | 40 | }; |
41 | 41 | ||
42 | static void bus_clk_recalc(struct clk *clk) | 42 | static unsigned long bus_clk_recalc(struct clk *clk) |
43 | { | 43 | { |
44 | int idx = ((ctrl_inl(FRQCR) >> 16) & 0x0007); | 44 | int idx = ((ctrl_inl(FRQCR) >> 16) & 0x0007); |
45 | clk->rate = clk->parent->rate / bfc_divisors[idx]; | 45 | return clk->parent->rate / bfc_divisors[idx]; |
46 | } | 46 | } |
47 | 47 | ||
48 | static struct clk_ops sh7780_bus_clk_ops = { | 48 | static struct clk_ops sh7780_bus_clk_ops = { |
49 | .recalc = bus_clk_recalc, | 49 | .recalc = bus_clk_recalc, |
50 | }; | 50 | }; |
51 | 51 | ||
52 | static void cpu_clk_recalc(struct clk *clk) | 52 | static unsigned long cpu_clk_recalc(struct clk *clk) |
53 | { | 53 | { |
54 | int idx = ((ctrl_inl(FRQCR) >> 24) & 0x0001); | 54 | int idx = ((ctrl_inl(FRQCR) >> 24) & 0x0001); |
55 | clk->rate = clk->parent->rate / ifc_divisors[idx]; | 55 | return clk->parent->rate / ifc_divisors[idx]; |
56 | } | 56 | } |
57 | 57 | ||
58 | static struct clk_ops sh7780_cpu_clk_ops = { | 58 | static struct clk_ops sh7780_cpu_clk_ops = { |
@@ -72,10 +72,10 @@ void __init arch_init_clk_ops(struct clk_ops **ops, int idx) | |||
72 | *ops = sh7780_clk_ops[idx]; | 72 | *ops = sh7780_clk_ops[idx]; |
73 | } | 73 | } |
74 | 74 | ||
75 | static void shyway_clk_recalc(struct clk *clk) | 75 | static unsigned long shyway_clk_recalc(struct clk *clk) |
76 | { | 76 | { |
77 | int idx = ((ctrl_inl(FRQCR) >> 20) & 0x0007); | 77 | int idx = ((ctrl_inl(FRQCR) >> 20) & 0x0007); |
78 | clk->rate = clk->parent->rate / cfc_divisors[idx]; | 78 | return clk->parent->rate / cfc_divisors[idx]; |
79 | } | 79 | } |
80 | 80 | ||
81 | static struct clk_ops sh7780_shyway_clk_ops = { | 81 | static struct clk_ops sh7780_shyway_clk_ops = { |
@@ -84,7 +84,7 @@ static struct clk_ops sh7780_shyway_clk_ops = { | |||
84 | 84 | ||
85 | static struct clk sh7780_shyway_clk = { | 85 | static struct clk sh7780_shyway_clk = { |
86 | .name = "shyway_clk", | 86 | .name = "shyway_clk", |
87 | .flags = CLK_ALWAYS_ENABLED, | 87 | .flags = CLK_ENABLE_ON_INIT, |
88 | .ops = &sh7780_shyway_clk_ops, | 88 | .ops = &sh7780_shyway_clk_ops, |
89 | }; | 89 | }; |
90 | 90 | ||
@@ -96,31 +96,22 @@ static struct clk *sh7780_onchip_clocks[] = { | |||
96 | &sh7780_shyway_clk, | 96 | &sh7780_shyway_clk, |
97 | }; | 97 | }; |
98 | 98 | ||
99 | static int __init sh7780_clk_init(void) | 99 | int __init arch_clk_init(void) |
100 | { | 100 | { |
101 | struct clk *clk = clk_get(NULL, "master_clk"); | 101 | struct clk *clk; |
102 | int i; | 102 | int i, ret = 0; |
103 | 103 | ||
104 | cpg_clk_init(); | ||
105 | |||
106 | clk = clk_get(NULL, "master_clk"); | ||
104 | for (i = 0; i < ARRAY_SIZE(sh7780_onchip_clocks); i++) { | 107 | for (i = 0; i < ARRAY_SIZE(sh7780_onchip_clocks); i++) { |
105 | struct clk *clkp = sh7780_onchip_clocks[i]; | 108 | struct clk *clkp = sh7780_onchip_clocks[i]; |
106 | 109 | ||
107 | clkp->parent = clk; | 110 | clkp->parent = clk; |
108 | clk_register(clkp); | 111 | ret |= clk_register(clkp); |
109 | clk_enable(clkp); | ||
110 | } | 112 | } |
111 | 113 | ||
112 | /* | ||
113 | * Now that we have the rest of the clocks registered, we need to | ||
114 | * force the parent clock to propagate so that these clocks will | ||
115 | * automatically figure out their rate. We cheat by handing the | ||
116 | * parent clock its current rate and forcing child propagation. | ||
117 | */ | ||
118 | clk_set_rate(clk, clk_get_rate(clk)); | ||
119 | |||
120 | clk_put(clk); | 114 | clk_put(clk); |
121 | 115 | ||
122 | return 0; | 116 | return ret; |
123 | } | 117 | } |
124 | |||
125 | arch_initcall(sh7780_clk_init); | ||
126 | |||