diff options
Diffstat (limited to 'arch/sh/kernel/cpu/sh4a/clock-sh7722.c')
-rw-r--r-- | arch/sh/kernel/cpu/sh4a/clock-sh7722.c | 177 |
1 files changed, 123 insertions, 54 deletions
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c index 15db6d521c5c..2030f3d9fac7 100644 --- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c +++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
23 | #include <linux/io.h> | 23 | #include <linux/io.h> |
24 | #include <asm/clkdev.h> | ||
24 | #include <asm/clock.h> | 25 | #include <asm/clock.h> |
25 | #include <asm/hwblk.h> | 26 | #include <asm/hwblk.h> |
26 | #include <cpu/sh7722.h> | 27 | #include <cpu/sh7722.h> |
@@ -36,8 +37,6 @@ | |||
36 | 37 | ||
37 | /* Fixed 32 KHz root clock for RTC and Power Management purposes */ | 38 | /* Fixed 32 KHz root clock for RTC and Power Management purposes */ |
38 | static struct clk r_clk = { | 39 | static struct clk r_clk = { |
39 | .name = "rclk", | ||
40 | .id = -1, | ||
41 | .rate = 32768, | 40 | .rate = 32768, |
42 | }; | 41 | }; |
43 | 42 | ||
@@ -46,8 +45,6 @@ static struct clk r_clk = { | |||
46 | * from the platform code. | 45 | * from the platform code. |
47 | */ | 46 | */ |
48 | struct clk extal_clk = { | 47 | struct clk extal_clk = { |
49 | .name = "extal", | ||
50 | .id = -1, | ||
51 | .rate = 33333333, | 48 | .rate = 33333333, |
52 | }; | 49 | }; |
53 | 50 | ||
@@ -69,8 +66,6 @@ static struct clk_ops dll_clk_ops = { | |||
69 | }; | 66 | }; |
70 | 67 | ||
71 | static struct clk dll_clk = { | 68 | static struct clk dll_clk = { |
72 | .name = "dll_clk", | ||
73 | .id = -1, | ||
74 | .ops = &dll_clk_ops, | 69 | .ops = &dll_clk_ops, |
75 | .parent = &r_clk, | 70 | .parent = &r_clk, |
76 | .flags = CLK_ENABLE_ON_INIT, | 71 | .flags = CLK_ENABLE_ON_INIT, |
@@ -94,8 +89,6 @@ static struct clk_ops pll_clk_ops = { | |||
94 | }; | 89 | }; |
95 | 90 | ||
96 | static struct clk pll_clk = { | 91 | static struct clk pll_clk = { |
97 | .name = "pll_clk", | ||
98 | .id = -1, | ||
99 | .ops = &pll_clk_ops, | 92 | .ops = &pll_clk_ops, |
100 | .flags = CLK_ENABLE_ON_INIT, | 93 | .flags = CLK_ENABLE_ON_INIT, |
101 | }; | 94 | }; |
@@ -121,68 +114,142 @@ static struct clk_div4_table div4_table = { | |||
121 | .div_mult_table = &div4_div_mult_table, | 114 | .div_mult_table = &div4_div_mult_table, |
122 | }; | 115 | }; |
123 | 116 | ||
124 | #define DIV4(_str, _reg, _bit, _mask, _flags) \ | 117 | #define DIV4(_reg, _bit, _mask, _flags) \ |
125 | SH_CLK_DIV4(_str, &pll_clk, _reg, _bit, _mask, _flags) | 118 | SH_CLK_DIV4(&pll_clk, _reg, _bit, _mask, _flags) |
126 | 119 | ||
127 | enum { DIV4_I, DIV4_U, DIV4_SH, DIV4_B, DIV4_B3, DIV4_P, DIV4_NR }; | 120 | enum { DIV4_I, DIV4_U, DIV4_SH, DIV4_B, DIV4_B3, DIV4_P, DIV4_NR }; |
128 | 121 | ||
129 | struct clk div4_clks[DIV4_NR] = { | 122 | struct clk div4_clks[DIV4_NR] = { |
130 | [DIV4_I] = DIV4("cpu_clk", FRQCR, 20, 0x1fef, CLK_ENABLE_ON_INIT), | 123 | [DIV4_I] = DIV4(FRQCR, 20, 0x1fef, CLK_ENABLE_ON_INIT), |
131 | [DIV4_U] = DIV4("umem_clk", FRQCR, 16, 0x1fff, CLK_ENABLE_ON_INIT), | 124 | [DIV4_U] = DIV4(FRQCR, 16, 0x1fff, CLK_ENABLE_ON_INIT), |
132 | [DIV4_SH] = DIV4("shyway_clk", FRQCR, 12, 0x1fff, CLK_ENABLE_ON_INIT), | 125 | [DIV4_SH] = DIV4(FRQCR, 12, 0x1fff, CLK_ENABLE_ON_INIT), |
133 | [DIV4_B] = DIV4("bus_clk", FRQCR, 8, 0x1fff, CLK_ENABLE_ON_INIT), | 126 | [DIV4_B] = DIV4(FRQCR, 8, 0x1fff, CLK_ENABLE_ON_INIT), |
134 | [DIV4_B3] = DIV4("b3_clk", FRQCR, 4, 0x1fff, CLK_ENABLE_ON_INIT), | 127 | [DIV4_B3] = DIV4(FRQCR, 4, 0x1fff, CLK_ENABLE_ON_INIT), |
135 | [DIV4_P] = DIV4("peripheral_clk", FRQCR, 0, 0x1fff, 0), | 128 | [DIV4_P] = DIV4(FRQCR, 0, 0x1fff, 0), |
136 | }; | 129 | }; |
137 | 130 | ||
138 | enum { DIV4_IRDA, DIV4_ENABLE_NR }; | 131 | enum { DIV4_IRDA, DIV4_ENABLE_NR }; |
139 | 132 | ||
140 | struct clk div4_enable_clks[DIV4_ENABLE_NR] = { | 133 | struct clk div4_enable_clks[DIV4_ENABLE_NR] = { |
141 | [DIV4_IRDA] = DIV4("irda_clk", IRDACLKCR, 0, 0x1fff, 0), | 134 | [DIV4_IRDA] = DIV4(IRDACLKCR, 0, 0x1fff, 0), |
142 | }; | 135 | }; |
143 | 136 | ||
144 | enum { DIV4_SIUA, DIV4_SIUB, DIV4_REPARENT_NR }; | 137 | enum { DIV4_SIUA, DIV4_SIUB, DIV4_REPARENT_NR }; |
145 | 138 | ||
146 | struct clk div4_reparent_clks[DIV4_REPARENT_NR] = { | 139 | struct clk div4_reparent_clks[DIV4_REPARENT_NR] = { |
147 | [DIV4_SIUA] = DIV4("siua_clk", SCLKACR, 0, 0x1fff, 0), | 140 | [DIV4_SIUA] = DIV4(SCLKACR, 0, 0x1fff, 0), |
148 | [DIV4_SIUB] = DIV4("siub_clk", SCLKBCR, 0, 0x1fff, 0), | 141 | [DIV4_SIUB] = DIV4(SCLKBCR, 0, 0x1fff, 0), |
149 | }; | 142 | }; |
150 | 143 | ||
151 | struct clk div6_clks[] = { | 144 | enum { DIV6_V, DIV6_NR }; |
152 | SH_CLK_DIV6("video_clk", &pll_clk, VCLKCR, 0), | 145 | |
146 | struct clk div6_clks[DIV6_NR] = { | ||
147 | [DIV6_V] = SH_CLK_DIV6(&pll_clk, VCLKCR, 0), | ||
148 | }; | ||
149 | |||
150 | static struct clk mstp_clks[HWBLK_NR] = { | ||
151 | SH_HWBLK_CLK(HWBLK_URAM, &div4_clks[DIV4_U], CLK_ENABLE_ON_INIT), | ||
152 | SH_HWBLK_CLK(HWBLK_XYMEM, &div4_clks[DIV4_B], CLK_ENABLE_ON_INIT), | ||
153 | SH_HWBLK_CLK(HWBLK_TMU, &div4_clks[DIV4_P], 0), | ||
154 | SH_HWBLK_CLK(HWBLK_CMT, &r_clk, 0), | ||
155 | SH_HWBLK_CLK(HWBLK_RWDT, &r_clk, 0), | ||
156 | SH_HWBLK_CLK(HWBLK_FLCTL, &div4_clks[DIV4_P], 0), | ||
157 | SH_HWBLK_CLK(HWBLK_SCIF0, &div4_clks[DIV4_P], 0), | ||
158 | SH_HWBLK_CLK(HWBLK_SCIF1, &div4_clks[DIV4_P], 0), | ||
159 | SH_HWBLK_CLK(HWBLK_SCIF2, &div4_clks[DIV4_P], 0), | ||
160 | |||
161 | SH_HWBLK_CLK(HWBLK_IIC, &div4_clks[DIV4_P], 0), | ||
162 | SH_HWBLK_CLK(HWBLK_RTC, &r_clk, 0), | ||
163 | |||
164 | SH_HWBLK_CLK(HWBLK_SDHI, &div4_clks[DIV4_P], 0), | ||
165 | SH_HWBLK_CLK(HWBLK_KEYSC, &r_clk, 0), | ||
166 | SH_HWBLK_CLK(HWBLK_USBF, &div4_clks[DIV4_P], 0), | ||
167 | SH_HWBLK_CLK(HWBLK_2DG, &div4_clks[DIV4_B], 0), | ||
168 | SH_HWBLK_CLK(HWBLK_SIU, &div4_clks[DIV4_B], 0), | ||
169 | SH_HWBLK_CLK(HWBLK_VOU, &div4_clks[DIV4_B], 0), | ||
170 | SH_HWBLK_CLK(HWBLK_JPU, &div4_clks[DIV4_B], 0), | ||
171 | SH_HWBLK_CLK(HWBLK_BEU, &div4_clks[DIV4_B], 0), | ||
172 | SH_HWBLK_CLK(HWBLK_CEU, &div4_clks[DIV4_B], 0), | ||
173 | SH_HWBLK_CLK(HWBLK_VEU, &div4_clks[DIV4_B], 0), | ||
174 | SH_HWBLK_CLK(HWBLK_VPU, &div4_clks[DIV4_B], 0), | ||
175 | SH_HWBLK_CLK(HWBLK_LCDC, &div4_clks[DIV4_P], 0), | ||
153 | }; | 176 | }; |
154 | 177 | ||
155 | #define R_CLK &r_clk | 178 | #define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk } |
156 | #define P_CLK &div4_clks[DIV4_P] | 179 | |
157 | #define B_CLK &div4_clks[DIV4_B] | 180 | static struct clk_lookup lookups[] = { |
158 | #define U_CLK &div4_clks[DIV4_U] | 181 | /* main clocks */ |
159 | 182 | CLKDEV_CON_ID("rclk", &r_clk), | |
160 | static struct clk mstp_clks[] = { | 183 | CLKDEV_CON_ID("extal", &extal_clk), |
161 | SH_HWBLK_CLK("uram0", -1, U_CLK, HWBLK_URAM, CLK_ENABLE_ON_INIT), | 184 | CLKDEV_CON_ID("dll_clk", &dll_clk), |
162 | SH_HWBLK_CLK("xymem0", -1, B_CLK, HWBLK_XYMEM, CLK_ENABLE_ON_INIT), | 185 | CLKDEV_CON_ID("pll_clk", &pll_clk), |
163 | SH_HWBLK_CLK("tmu0", -1, P_CLK, HWBLK_TMU, 0), | 186 | |
164 | SH_HWBLK_CLK("cmt0", -1, R_CLK, HWBLK_CMT, 0), | 187 | /* DIV4 clocks */ |
165 | SH_HWBLK_CLK("rwdt0", -1, R_CLK, HWBLK_RWDT, 0), | 188 | CLKDEV_CON_ID("cpu_clk", &div4_clks[DIV4_I]), |
166 | SH_HWBLK_CLK("flctl0", -1, P_CLK, HWBLK_FLCTL, 0), | 189 | CLKDEV_CON_ID("umem_clk", &div4_clks[DIV4_U]), |
167 | SH_HWBLK_CLK("scif0", -1, P_CLK, HWBLK_SCIF0, 0), | 190 | CLKDEV_CON_ID("shyway_clk", &div4_clks[DIV4_SH]), |
168 | SH_HWBLK_CLK("scif1", -1, P_CLK, HWBLK_SCIF1, 0), | 191 | CLKDEV_CON_ID("bus_clk", &div4_clks[DIV4_B]), |
169 | SH_HWBLK_CLK("scif2", -1, P_CLK, HWBLK_SCIF2, 0), | 192 | CLKDEV_CON_ID("b3_clk", &div4_clks[DIV4_B3]), |
170 | 193 | CLKDEV_CON_ID("peripheral_clk", &div4_clks[DIV4_P]), | |
171 | SH_HWBLK_CLK("i2c0", -1, P_CLK, HWBLK_IIC, 0), | 194 | CLKDEV_CON_ID("irda_clk", &div4_enable_clks[DIV4_IRDA]), |
172 | SH_HWBLK_CLK("rtc0", -1, R_CLK, HWBLK_RTC, 0), | 195 | CLKDEV_CON_ID("siua_clk", &div4_reparent_clks[DIV4_SIUA]), |
173 | 196 | CLKDEV_CON_ID("siub_clk", &div4_reparent_clks[DIV4_SIUB]), | |
174 | SH_HWBLK_CLK("sdhi0", -1, P_CLK, HWBLK_SDHI, 0), | 197 | |
175 | SH_HWBLK_CLK("keysc0", -1, R_CLK, HWBLK_KEYSC, 0), | 198 | /* DIV6 clocks */ |
176 | SH_HWBLK_CLK("usbf0", -1, P_CLK, HWBLK_USBF, 0), | 199 | CLKDEV_CON_ID("video_clk", &div6_clks[DIV6_V]), |
177 | SH_HWBLK_CLK("2dg0", -1, B_CLK, HWBLK_2DG, 0), | 200 | |
178 | SH_HWBLK_CLK("siu0", -1, B_CLK, HWBLK_SIU, 0), | 201 | /* MSTP clocks */ |
179 | SH_HWBLK_CLK("vou0", -1, B_CLK, HWBLK_VOU, 0), | 202 | CLKDEV_CON_ID("uram0", &mstp_clks[HWBLK_URAM]), |
180 | SH_HWBLK_CLK("jpu0", -1, B_CLK, HWBLK_JPU, 0), | 203 | CLKDEV_CON_ID("xymem0", &mstp_clks[HWBLK_XYMEM]), |
181 | SH_HWBLK_CLK("beu0", -1, B_CLK, HWBLK_BEU, 0), | 204 | { |
182 | SH_HWBLK_CLK("ceu0", -1, B_CLK, HWBLK_CEU, 0), | 205 | /* TMU0 */ |
183 | SH_HWBLK_CLK("veu0", -1, B_CLK, HWBLK_VEU, 0), | 206 | .dev_id = "sh_tmu.0", |
184 | SH_HWBLK_CLK("vpu0", -1, B_CLK, HWBLK_VPU, 0), | 207 | .con_id = "tmu_fck", |
185 | SH_HWBLK_CLK("lcdc0", -1, P_CLK, HWBLK_LCDC, 0), | 208 | .clk = &mstp_clks[HWBLK_TMU], |
209 | }, { | ||
210 | /* TMU1 */ | ||
211 | .dev_id = "sh_tmu.1", | ||
212 | .con_id = "tmu_fck", | ||
213 | .clk = &mstp_clks[HWBLK_TMU], | ||
214 | }, { | ||
215 | /* TMU2 */ | ||
216 | .dev_id = "sh_tmu.2", | ||
217 | .con_id = "tmu_fck", | ||
218 | .clk = &mstp_clks[HWBLK_TMU], | ||
219 | }, | ||
220 | CLKDEV_CON_ID("cmt_fck", &mstp_clks[HWBLK_CMT]), | ||
221 | CLKDEV_CON_ID("rwdt0", &mstp_clks[HWBLK_RWDT]), | ||
222 | CLKDEV_CON_ID("flctl0", &mstp_clks[HWBLK_FLCTL]), | ||
223 | { | ||
224 | /* SCIF0 */ | ||
225 | .dev_id = "sh-sci.0", | ||
226 | .con_id = "sci_fck", | ||
227 | .clk = &mstp_clks[HWBLK_SCIF0], | ||
228 | }, { | ||
229 | /* SCIF1 */ | ||
230 | .dev_id = "sh-sci.1", | ||
231 | .con_id = "sci_fck", | ||
232 | .clk = &mstp_clks[HWBLK_SCIF1], | ||
233 | }, { | ||
234 | /* SCIF2 */ | ||
235 | .dev_id = "sh-sci.2", | ||
236 | .con_id = "sci_fck", | ||
237 | .clk = &mstp_clks[HWBLK_SCIF2], | ||
238 | }, | ||
239 | CLKDEV_CON_ID("i2c0", &mstp_clks[HWBLK_IIC]), | ||
240 | CLKDEV_CON_ID("rtc0", &mstp_clks[HWBLK_RTC]), | ||
241 | CLKDEV_CON_ID("sdhi0", &mstp_clks[HWBLK_SDHI]), | ||
242 | CLKDEV_CON_ID("keysc0", &mstp_clks[HWBLK_KEYSC]), | ||
243 | CLKDEV_CON_ID("usbf0", &mstp_clks[HWBLK_USBF]), | ||
244 | CLKDEV_CON_ID("2dg0", &mstp_clks[HWBLK_2DG]), | ||
245 | CLKDEV_CON_ID("siu0", &mstp_clks[HWBLK_SIU]), | ||
246 | CLKDEV_CON_ID("vou0", &mstp_clks[HWBLK_VOU]), | ||
247 | CLKDEV_CON_ID("jpu0", &mstp_clks[HWBLK_JPU]), | ||
248 | CLKDEV_CON_ID("beu0", &mstp_clks[HWBLK_BEU]), | ||
249 | CLKDEV_CON_ID("ceu0", &mstp_clks[HWBLK_CEU]), | ||
250 | CLKDEV_CON_ID("veu0", &mstp_clks[HWBLK_VEU]), | ||
251 | CLKDEV_CON_ID("vpu0", &mstp_clks[HWBLK_VPU]), | ||
252 | CLKDEV_CON_ID("lcdc0", &mstp_clks[HWBLK_LCDC]), | ||
186 | }; | 253 | }; |
187 | 254 | ||
188 | int __init arch_clk_init(void) | 255 | int __init arch_clk_init(void) |
@@ -198,6 +265,8 @@ int __init arch_clk_init(void) | |||
198 | for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++) | 265 | for (k = 0; !ret && (k < ARRAY_SIZE(main_clks)); k++) |
199 | ret = clk_register(main_clks[k]); | 266 | ret = clk_register(main_clks[k]); |
200 | 267 | ||
268 | clkdev_add_table(lookups, ARRAY_SIZE(lookups)); | ||
269 | |||
201 | if (!ret) | 270 | if (!ret) |
202 | ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table); | 271 | ret = sh_clk_div4_register(div4_clks, DIV4_NR, &div4_table); |
203 | 272 | ||
@@ -210,10 +279,10 @@ int __init arch_clk_init(void) | |||
210 | DIV4_REPARENT_NR, &div4_table); | 279 | DIV4_REPARENT_NR, &div4_table); |
211 | 280 | ||
212 | if (!ret) | 281 | if (!ret) |
213 | ret = sh_clk_div6_register(div6_clks, ARRAY_SIZE(div6_clks)); | 282 | ret = sh_clk_div6_register(div6_clks, DIV6_NR); |
214 | 283 | ||
215 | if (!ret) | 284 | if (!ret) |
216 | ret = sh_hwblk_clk_register(mstp_clks, ARRAY_SIZE(mstp_clks)); | 285 | ret = sh_hwblk_clk_register(mstp_clks, HWBLK_NR); |
217 | 286 | ||
218 | return ret; | 287 | return ret; |
219 | } | 288 | } |