aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Mundt <lethal@linux-sh.org>2009-05-14 04:38:46 -0400
committerPaul Mundt <lethal@linux-sh.org>2009-05-14 04:38:46 -0400
commit549b5e358d17a8c04953ed80896ce07d37722451 (patch)
treec9cf2badccaf4868f3ba014b67a73983e7f7d1a9
parentcedcf3366f2191885aff92d33d6078ef08203e52 (diff)
sh: clkfwk: Add MSTP bits to SH7785 clock framework.
This plugs in all of the MSTP functions in to the clock framework, and hands them off to the platform devices that want them. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r--arch/sh/include/asm/clock.h3
-rw-r--r--arch/sh/kernel/cpu/clock.c4
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7785.c63
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7785.c18
4 files changed, 80 insertions, 8 deletions
diff --git a/arch/sh/include/asm/clock.h b/arch/sh/include/asm/clock.h
index c499d470b8c9..64c93cb3d685 100644
--- a/arch/sh/include/asm/clock.h
+++ b/arch/sh/include/asm/clock.h
@@ -36,6 +36,9 @@ struct clk {
36 unsigned long rate; 36 unsigned long rate;
37 unsigned long flags; 37 unsigned long flags;
38 38
39 void __iomem *enable_reg;
40 unsigned int enable_bit;
41
39 unsigned long arch_flags; 42 unsigned long arch_flags;
40 void *priv; 43 void *priv;
41 struct dentry *dentry; 44 struct dentry *dentry;
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index 686477f8ae5b..012d23476a72 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -39,7 +39,7 @@ static DEFINE_MUTEX(clock_list_sem);
39/* Used for clocks that always have same value as the parent clock */ 39/* Used for clocks that always have same value as the parent clock */
40unsigned long followparent_recalc(struct clk *clk) 40unsigned long followparent_recalc(struct clk *clk)
41{ 41{
42 return clk->parent->rate; 42 return clk->parent ? clk->parent->rate : 0;
43} 43}
44 44
45int clk_reparent(struct clk *child, struct clk *parent) 45int clk_reparent(struct clk *child, struct clk *parent)
@@ -512,7 +512,7 @@ static int clk_debugfs_register_one(struct clk *c)
512 char *p = s; 512 char *p = s;
513 513
514 p += sprintf(p, "%s", c->name); 514 p += sprintf(p, "%s", c->name);
515 if (c->id > 0) 515 if (c->id >= 0)
516 sprintf(p, ":%d", c->id); 516 sprintf(p, ":%d", c->id);
517 d = debugfs_create_dir(s, pa ? pa->dentry : clk_debugfs_root); 517 d = debugfs_create_dir(s, pa ? pa->dentry : clk_debugfs_root);
518 if (!d) 518 if (!d)
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
index b7a32dd1b2db..cf042b53b3ae 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7785.c
@@ -228,12 +228,75 @@ static struct clk *clks[] = {
228 &umem_clk, 228 &umem_clk,
229}; 229};
230 230
231static int mstpcr_clk_enable(struct clk *clk)
232{
233 __raw_writel(__raw_readl(clk->enable_reg) & ~(1 << clk->enable_bit),
234 clk->enable_reg);
235 return 0;
236}
237
238static void mstpcr_clk_disable(struct clk *clk)
239{
240 __raw_writel(__raw_readl(clk->enable_reg) | (1 << clk->enable_bit),
241 clk->enable_reg);
242}
243
244static struct clk_ops mstpcr_clk_ops = {
245 .enable = mstpcr_clk_enable,
246 .disable = mstpcr_clk_disable,
247 .recalc = followparent_recalc,
248};
249
250#define MSTPCR0 0xffc80030
251#define MSTPCR1 0xffc80034
252
253#define CLK(_name, _id, _parent, _enable_reg, \
254 _enable_bit, _flags) \
255{ \
256 .name = _name, \
257 .id = _id, \
258 .parent = _parent, \
259 .enable_reg = (void __iomem *)_enable_reg, \
260 .enable_bit = _enable_bit, \
261 .flags = _flags, \
262 .ops = &mstpcr_clk_ops, \
263}
264
265static struct clk mstpcr_clks[] = {
266 /* MSTPCR0 */
267 CLK("scif_fck", 5, &peripheral_clk, MSTPCR0, 29, 0),
268 CLK("scif_fck", 4, &peripheral_clk, MSTPCR0, 28, 0),
269 CLK("scif_fck", 3, &peripheral_clk, MSTPCR0, 27, 0),
270 CLK("scif_fck", 2, &peripheral_clk, MSTPCR0, 26, 0),
271 CLK("scif_fck", 1, &peripheral_clk, MSTPCR0, 25, 0),
272 CLK("scif_fck", 0, &peripheral_clk, MSTPCR0, 24, 0),
273 CLK("ssi_fck", 1, &peripheral_clk, MSTPCR0, 21, 0),
274 CLK("ssi_fck", 0, &peripheral_clk, MSTPCR0, 20, 0),
275 CLK("hac_fck", 1, &peripheral_clk, MSTPCR0, 17, 0),
276 CLK("hac_fck", 0, &peripheral_clk, MSTPCR0, 16, 0),
277 CLK("mmcif_fck", -1, &peripheral_clk, MSTPCR0, 13, 0),
278 CLK("flctl_fck", -1, &peripheral_clk, MSTPCR0, 12, 0),
279 CLK("tmu345_fck", -1, &peripheral_clk, MSTPCR0, 9, 0),
280 CLK("tmu012_fck", -1, &peripheral_clk, MSTPCR0, 8, 0),
281 CLK("siof_fck", -1, &peripheral_clk, MSTPCR0, 3, 0),
282 CLK("hspi_fck", -1, &peripheral_clk, MSTPCR0, 2, 0),
283
284 /* MSTPCR1 */
285 CLK("hudi_fck", -1, NULL, MSTPCR1, 19, 0),
286 CLK("ubc_fck", -1, NULL, MSTPCR1, 17, 0),
287 CLK("dmac_11_6_fck", -1, NULL, MSTPCR1, 5, 0),
288 CLK("dmac_5_0_fck", -1, NULL, MSTPCR1, 4, 0),
289 CLK("gdta_fck", -1, NULL, MSTPCR1, 0, 0),
290};
291
231int __init arch_clk_init(void) 292int __init arch_clk_init(void)
232{ 293{
233 int i, ret = 0; 294 int i, ret = 0;
234 295
235 for (i = 0; i < ARRAY_SIZE(clks); i++) 296 for (i = 0; i < ARRAY_SIZE(clks); i++)
236 ret |= clk_register(clks[i]); 297 ret |= clk_register(clks[i]);
298 for (i = 0; i < ARRAY_SIZE(mstpcr_clks); i++)
299 ret |= clk_register(&mstpcr_clks[i]);
237 300
238 return ret; 301 return ret;
239} 302}
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7785.c b/arch/sh/kernel/cpu/sh4a/setup-sh7785.c
index d7e77bc77e28..af561402570b 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7785.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7785.c
@@ -20,7 +20,7 @@ static struct sh_timer_config tmu0_platform_data = {
20 .name = "TMU0", 20 .name = "TMU0",
21 .channel_offset = 0x04, 21 .channel_offset = 0x04,
22 .timer_bit = 0, 22 .timer_bit = 0,
23 .clk = "peripheral_clk", 23 .clk = "tmu012_fck",
24 .clockevent_rating = 200, 24 .clockevent_rating = 200,
25}; 25};
26 26
@@ -51,7 +51,7 @@ static struct sh_timer_config tmu1_platform_data = {
51 .name = "TMU1", 51 .name = "TMU1",
52 .channel_offset = 0x10, 52 .channel_offset = 0x10,
53 .timer_bit = 1, 53 .timer_bit = 1,
54 .clk = "peripheral_clk", 54 .clk = "tmu012_fck",
55 .clocksource_rating = 200, 55 .clocksource_rating = 200,
56}; 56};
57 57
@@ -82,7 +82,7 @@ static struct sh_timer_config tmu2_platform_data = {
82 .name = "TMU2", 82 .name = "TMU2",
83 .channel_offset = 0x1c, 83 .channel_offset = 0x1c,
84 .timer_bit = 2, 84 .timer_bit = 2,
85 .clk = "peripheral_clk", 85 .clk = "tmu012_fck",
86}; 86};
87 87
88static struct resource tmu2_resources[] = { 88static struct resource tmu2_resources[] = {
@@ -112,7 +112,7 @@ static struct sh_timer_config tmu3_platform_data = {
112 .name = "TMU3", 112 .name = "TMU3",
113 .channel_offset = 0x04, 113 .channel_offset = 0x04,
114 .timer_bit = 0, 114 .timer_bit = 0,
115 .clk = "peripheral_clk", 115 .clk = "tmu345_fck",
116}; 116};
117 117
118static struct resource tmu3_resources[] = { 118static struct resource tmu3_resources[] = {
@@ -142,7 +142,7 @@ static struct sh_timer_config tmu4_platform_data = {
142 .name = "TMU4", 142 .name = "TMU4",
143 .channel_offset = 0x10, 143 .channel_offset = 0x10,
144 .timer_bit = 1, 144 .timer_bit = 1,
145 .clk = "peripheral_clk", 145 .clk = "tmu345_fck",
146}; 146};
147 147
148static struct resource tmu4_resources[] = { 148static struct resource tmu4_resources[] = {
@@ -172,7 +172,7 @@ static struct sh_timer_config tmu5_platform_data = {
172 .name = "TMU5", 172 .name = "TMU5",
173 .channel_offset = 0x1c, 173 .channel_offset = 0x1c,
174 .timer_bit = 2, 174 .timer_bit = 2,
175 .clk = "peripheral_clk", 175 .clk = "tmu345_fck",
176}; 176};
177 177
178static struct resource tmu5_resources[] = { 178static struct resource tmu5_resources[] = {
@@ -204,31 +204,37 @@ static struct plat_sci_port sci_platform_data[] = {
204 .flags = UPF_BOOT_AUTOCONF, 204 .flags = UPF_BOOT_AUTOCONF,
205 .type = PORT_SCIF, 205 .type = PORT_SCIF,
206 .irqs = { 40, 40, 40, 40 }, 206 .irqs = { 40, 40, 40, 40 },
207 .clk = "scif_fck",
207 }, { 208 }, {
208 .mapbase = 0xffeb0000, 209 .mapbase = 0xffeb0000,
209 .flags = UPF_BOOT_AUTOCONF, 210 .flags = UPF_BOOT_AUTOCONF,
210 .type = PORT_SCIF, 211 .type = PORT_SCIF,
211 .irqs = { 44, 44, 44, 44 }, 212 .irqs = { 44, 44, 44, 44 },
213 .clk = "scif_fck",
212 }, { 214 }, {
213 .mapbase = 0xffec0000, 215 .mapbase = 0xffec0000,
214 .flags = UPF_BOOT_AUTOCONF, 216 .flags = UPF_BOOT_AUTOCONF,
215 .type = PORT_SCIF, 217 .type = PORT_SCIF,
216 .irqs = { 60, 60, 60, 60 }, 218 .irqs = { 60, 60, 60, 60 },
219 .clk = "scif_fck",
217 }, { 220 }, {
218 .mapbase = 0xffed0000, 221 .mapbase = 0xffed0000,
219 .flags = UPF_BOOT_AUTOCONF, 222 .flags = UPF_BOOT_AUTOCONF,
220 .type = PORT_SCIF, 223 .type = PORT_SCIF,
221 .irqs = { 61, 61, 61, 61 }, 224 .irqs = { 61, 61, 61, 61 },
225 .clk = "scif_fck",
222 }, { 226 }, {
223 .mapbase = 0xffee0000, 227 .mapbase = 0xffee0000,
224 .flags = UPF_BOOT_AUTOCONF, 228 .flags = UPF_BOOT_AUTOCONF,
225 .type = PORT_SCIF, 229 .type = PORT_SCIF,
226 .irqs = { 62, 62, 62, 62 }, 230 .irqs = { 62, 62, 62, 62 },
231 .clk = "scif_fck",
227 }, { 232 }, {
228 .mapbase = 0xffef0000, 233 .mapbase = 0xffef0000,
229 .flags = UPF_BOOT_AUTOCONF, 234 .flags = UPF_BOOT_AUTOCONF,
230 .type = PORT_SCIF, 235 .type = PORT_SCIF,
231 .irqs = { 63, 63, 63, 63 }, 236 .irqs = { 63, 63, 63, 63 },
237 .clk = "scif_fck",
232 }, { 238 }, {
233 .flags = 0, 239 .flags = 0,
234 } 240 }