aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap1/clock.c
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2009-02-08 11:07:46 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-02-08 12:50:11 -0500
commitd5e6072b753041b56236b014ccfd72a0d3177e08 (patch)
tree9e922b16f7c84c063977d22c71385239fbd4e5c2 /arch/arm/mach-omap1/clock.c
parent9a5fedac187f30116013a8420149d4ca11a44f0d (diff)
[ARM] omap: handle RATE_CKCTL via .set_rate/.round_rate methods
It makes no sense to have the CKCTL rate selection implemented as a flag and a special exception in the top level set_rate/round_rate methods. Provide CKCTL set_rate/round_rate methods, and use these for where ever RATE_CKCTL is used and they're not already overridden. This allows us to remove the RATE_CKCTL flag. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-omap1/clock.c')
-rw-r--r--arch/arm/mach-omap1/clock.c96
1 files changed, 45 insertions, 51 deletions
diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c
index be500014dcb8..6b17da120e5f 100644
--- a/arch/arm/mach-omap1/clock.c
+++ b/arch/arm/mach-omap1/clock.c
@@ -216,9 +216,6 @@ static int calc_dsor_exp(struct clk *clk, unsigned long rate)
216 struct clk * parent; 216 struct clk * parent;
217 unsigned dsor_exp; 217 unsigned dsor_exp;
218 218
219 if (unlikely(!(clk->flags & RATE_CKCTL)))
220 return -EINVAL;
221
222 parent = clk->parent; 219 parent = clk->parent;
223 if (unlikely(parent == NULL)) 220 if (unlikely(parent == NULL))
224 return -EIO; 221 return -EIO;
@@ -307,26 +304,52 @@ static int omap1_select_table_rate(struct clk * clk, unsigned long rate)
307 304
308static int omap1_clk_set_rate_dsp_domain(struct clk *clk, unsigned long rate) 305static int omap1_clk_set_rate_dsp_domain(struct clk *clk, unsigned long rate)
309{ 306{
310 int ret = -EINVAL; 307 int dsor_exp;
311 int dsor_exp; 308 u16 regval;
312 __u16 regval;
313
314 if (clk->flags & RATE_CKCTL) {
315 dsor_exp = calc_dsor_exp(clk, rate);
316 if (dsor_exp > 3)
317 dsor_exp = -EINVAL;
318 if (dsor_exp < 0)
319 return dsor_exp;
320
321 regval = __raw_readw(DSP_CKCTL);
322 regval &= ~(3 << clk->rate_offset);
323 regval |= dsor_exp << clk->rate_offset;
324 __raw_writew(regval, DSP_CKCTL);
325 clk->rate = clk->parent->rate / (1 << dsor_exp);
326 ret = 0;
327 }
328 309
329 return ret; 310 dsor_exp = calc_dsor_exp(clk, rate);
311 if (dsor_exp > 3)
312 dsor_exp = -EINVAL;
313 if (dsor_exp < 0)
314 return dsor_exp;
315
316 regval = __raw_readw(DSP_CKCTL);
317 regval &= ~(3 << clk->rate_offset);
318 regval |= dsor_exp << clk->rate_offset;
319 __raw_writew(regval, DSP_CKCTL);
320 clk->rate = clk->parent->rate / (1 << dsor_exp);
321
322 return 0;
323}
324
325static long omap1_clk_round_rate_ckctl_arm(struct clk *clk, unsigned long rate)
326{
327 int dsor_exp = calc_dsor_exp(clk, rate);
328 if (dsor_exp < 0)
329 return dsor_exp;
330 if (dsor_exp > 3)
331 dsor_exp = 3;
332 return clk->parent->rate / (1 << dsor_exp);
333}
334
335static int omap1_clk_set_rate_ckctl_arm(struct clk *clk, unsigned long rate)
336{
337 int dsor_exp;
338 u16 regval;
339
340 dsor_exp = calc_dsor_exp(clk, rate);
341 if (dsor_exp > 3)
342 dsor_exp = -EINVAL;
343 if (dsor_exp < 0)
344 return dsor_exp;
345
346 regval = omap_readw(ARM_CKCTL);
347 regval &= ~(3 << clk->rate_offset);
348 regval |= dsor_exp << clk->rate_offset;
349 regval = verify_ckctl_value(regval);
350 omap_writew(regval, ARM_CKCTL);
351 clk->rate = clk->parent->rate / (1 << dsor_exp);
352 return 0;
330} 353}
331 354
332static long omap1_round_to_table_rate(struct clk * clk, unsigned long rate) 355static long omap1_round_to_table_rate(struct clk * clk, unsigned long rate)
@@ -572,20 +595,9 @@ static const struct clkops clkops_generic = {
572 595
573static long omap1_clk_round_rate(struct clk *clk, unsigned long rate) 596static long omap1_clk_round_rate(struct clk *clk, unsigned long rate)
574{ 597{
575 int dsor_exp;
576
577 if (clk->flags & RATE_FIXED) 598 if (clk->flags & RATE_FIXED)
578 return clk->rate; 599 return clk->rate;
579 600
580 if (clk->flags & RATE_CKCTL) {
581 dsor_exp = calc_dsor_exp(clk, rate);
582 if (dsor_exp < 0)
583 return dsor_exp;
584 if (dsor_exp > 3)
585 dsor_exp = 3;
586 return clk->parent->rate / (1 << dsor_exp);
587 }
588
589 if (clk->round_rate != NULL) 601 if (clk->round_rate != NULL)
590 return clk->round_rate(clk, rate); 602 return clk->round_rate(clk, rate);
591 603
@@ -595,27 +607,9 @@ static long omap1_clk_round_rate(struct clk *clk, unsigned long rate)
595static int omap1_clk_set_rate(struct clk *clk, unsigned long rate) 607static int omap1_clk_set_rate(struct clk *clk, unsigned long rate)
596{ 608{
597 int ret = -EINVAL; 609 int ret = -EINVAL;
598 int dsor_exp;
599 __u16 regval;
600 610
601 if (clk->set_rate) 611 if (clk->set_rate)
602 ret = clk->set_rate(clk, rate); 612 ret = clk->set_rate(clk, rate);
603 else if (clk->flags & RATE_CKCTL) {
604 dsor_exp = calc_dsor_exp(clk, rate);
605 if (dsor_exp > 3)
606 dsor_exp = -EINVAL;
607 if (dsor_exp < 0)
608 return dsor_exp;
609
610 regval = omap_readw(ARM_CKCTL);
611 regval &= ~(3 << clk->rate_offset);
612 regval |= dsor_exp << clk->rate_offset;
613 regval = verify_ckctl_value(regval);
614 omap_writew(regval, ARM_CKCTL);
615 clk->rate = clk->parent->rate / (1 << dsor_exp);
616 ret = 0;
617 }
618
619 return ret; 613 return ret;
620} 614}
621 615