aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMagnus Damm <damm@igel.co.jp>2008-07-17 05:52:19 -0400
committerPaul Mundt <lethal@linux-sh.org>2008-07-28 05:10:36 -0400
commit3fec18bd603c3a55aeb325121a3e752f647641be (patch)
tree52dff076dc2183d6d6950746212b88a1e56f57e9 /arch
parent5c8f9d94fea98596db255a579f5d02a0195abda7 (diff)
sh: Use arch_flags to simplify sh7722 siu clock code
Make use of arch_flags to simplify the SIU clock code. Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/sh/kernel/cpu/sh4a/clock-sh7722.c47
1 files changed, 9 insertions, 38 deletions
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
index 299138ebe160..d7b14660f737 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
@@ -411,40 +411,16 @@ static struct clk_ops sh7722_frqcr_clk_ops = {
411 * clock ops methods for SIU A/B and IrDA clock 411 * clock ops methods for SIU A/B and IrDA clock
412 * 412 *
413 */ 413 */
414static int sh7722_siu_which(struct clk *clk)
415{
416 if (!strcmp(clk->name, "siu_a_clk"))
417 return 0;
418 if (!strcmp(clk->name, "siu_b_clk"))
419 return 1;
420#if defined(CONFIG_CPU_SUBTYPE_SH7722)
421 if (!strcmp(clk->name, "irda_clk"))
422 return 2;
423#endif
424 return -EINVAL;
425}
426
427static unsigned long sh7722_siu_regs[] = {
428 [0] = SCLKACR,
429 [1] = SCLKBCR,
430#if defined(CONFIG_CPU_SUBTYPE_SH7722)
431 [2] = IrDACLKCR,
432#endif
433};
434 414
435static int sh7722_siu_start_stop(struct clk *clk, int enable) 415static int sh7722_siu_start_stop(struct clk *clk, int enable)
436{ 416{
437 int siu = sh7722_siu_which(clk);
438 unsigned long r; 417 unsigned long r;
439 418
440 if (siu < 0) 419 r = ctrl_inl(clk->arch_flags);
441 return siu;
442 BUG_ON(siu > 2);
443 r = ctrl_inl(sh7722_siu_regs[siu]);
444 if (enable) 420 if (enable)
445 ctrl_outl(r & ~(1 << 8), sh7722_siu_regs[siu]); 421 ctrl_outl(r & ~(1 << 8), clk->arch_flags);
446 else 422 else
447 ctrl_outl(r | (1 << 8), sh7722_siu_regs[siu]); 423 ctrl_outl(r | (1 << 8), clk->arch_flags);
448 return 0; 424 return 0;
449} 425}
450 426
@@ -496,31 +472,23 @@ static void sh7722_video_recalc(struct clk *clk)
496 472
497static int sh7722_siu_set_rate(struct clk *clk, unsigned long rate, int algo_id) 473static int sh7722_siu_set_rate(struct clk *clk, unsigned long rate, int algo_id)
498{ 474{
499 int siu = sh7722_siu_which(clk);
500 unsigned long r; 475 unsigned long r;
501 int div; 476 int div;
502 477
503 if (siu < 0) 478 r = ctrl_inl(clk->arch_flags);
504 return siu;
505 BUG_ON(siu > 2);
506 r = ctrl_inl(sh7722_siu_regs[siu]);
507 div = sh7722_find_divisors(clk->parent->rate, rate); 479 div = sh7722_find_divisors(clk->parent->rate, rate);
508 if (div < 0) 480 if (div < 0)
509 return div; 481 return div;
510 r = (r & ~0xF) | div; 482 r = (r & ~0xF) | div;
511 ctrl_outl(r, sh7722_siu_regs[siu]); 483 ctrl_outl(r, clk->arch_flags);
512 return 0; 484 return 0;
513} 485}
514 486
515static void sh7722_siu_recalc(struct clk *clk) 487static void sh7722_siu_recalc(struct clk *clk)
516{ 488{
517 int siu = sh7722_siu_which(clk);
518 unsigned long r; 489 unsigned long r;
519 490
520 if (siu < 0) 491 r = ctrl_inl(clk->arch_flags);
521 return /* siu */ ;
522 BUG_ON(siu > 2);
523 r = ctrl_inl(sh7722_siu_regs[siu]);
524 clk->rate = clk->parent->rate * 2 / divisors2[r & 0xF]; 492 clk->rate = clk->parent->rate * 2 / divisors2[r & 0xF];
525} 493}
526 494
@@ -567,17 +535,20 @@ static struct clk sh7722_sdram_clock = {
567 */ 535 */
568static struct clk sh7722_siu_a_clock = { 536static struct clk sh7722_siu_a_clock = {
569 .name = "siu_a_clk", 537 .name = "siu_a_clk",
538 .arch_flags = SCLKACR,
570 .ops = &sh7722_siu_clk_ops, 539 .ops = &sh7722_siu_clk_ops,
571}; 540};
572 541
573static struct clk sh7722_siu_b_clock = { 542static struct clk sh7722_siu_b_clock = {
574 .name = "siu_b_clk", 543 .name = "siu_b_clk",
544 .arch_flags = SCLKBCR,
575 .ops = &sh7722_siu_clk_ops, 545 .ops = &sh7722_siu_clk_ops,
576}; 546};
577 547
578#if defined(CONFIG_CPU_SUBTYPE_SH7722) 548#if defined(CONFIG_CPU_SUBTYPE_SH7722)
579static struct clk sh7722_irda_clock = { 549static struct clk sh7722_irda_clock = {
580 .name = "irda_clk", 550 .name = "irda_clk",
551 .arch_flags = IrDACLKCR,
581 .ops = &sh7722_siu_clk_ops, 552 .ops = &sh7722_siu_clk_ops,
582}; 553};
583#endif 554#endif