aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMagnus Damm <damm@igel.co.jp>2008-10-31 07:14:28 -0400
committerPaul Mundt <lethal@linux-sh.org>2008-12-22 04:42:50 -0500
commit1dc7b776d91ac9f016982e418e74cb14f63c5b02 (patch)
tree8d206c247d8eafc7005b6563c7d5718880f2ef70 /arch
parentd902d04f5410176bdec77bfefa032516326eb542 (diff)
sh: use arch_flags for sh_mobile mstpcr clock bits
Use arch_flags to keep track of register and flag number. 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.c72
1 files changed, 30 insertions, 42 deletions
diff --git a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
index ebf1e1d7de00..69ab62dd0158 100644
--- a/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/clock-sh7722.c
@@ -567,12 +567,30 @@ static struct clk sh7722_video_clock = {
567 .ops = &sh7722_video_clk_ops, 567 .ops = &sh7722_video_clk_ops,
568}; 568};
569 569
570static int sh7722_mstpcr_start_stop(struct clk *clk, unsigned long reg, 570#define MSTPCR_ARCH_FLAGS(reg, bit) (((reg) << 8) | (bit))
571 int enable) 571#define MSTPCR_ARCH_FLAGS_REG(value) ((value) >> 8)
572#define MSTPCR_ARCH_FLAGS_BIT(value) ((value) & 0xff)
573
574static int sh7722_mstpcr_start_stop(struct clk *clk, int enable)
572{ 575{
573 unsigned long bit = clk->arch_flags; 576 unsigned long bit = MSTPCR_ARCH_FLAGS_BIT(clk->arch_flags);
577 unsigned long reg;
574 unsigned long r; 578 unsigned long r;
575 579
580 switch(MSTPCR_ARCH_FLAGS_REG(clk->arch_flags)) {
581 case 0:
582 reg = MSTPCR0;
583 break;
584 case 1:
585 reg = MSTPCR1;
586 break;
587 case 2:
588 reg = MSTPCR2;
589 break;
590 default:
591 return -EINVAL;
592 }
593
576 r = ctrl_inl(reg); 594 r = ctrl_inl(reg);
577 595
578 if (enable) 596 if (enable)
@@ -584,56 +602,26 @@ static int sh7722_mstpcr_start_stop(struct clk *clk, unsigned long reg,
584 return 0; 602 return 0;
585} 603}
586 604
587static void sh7722_mstpcr0_enable(struct clk *clk) 605static void sh7722_mstpcr_enable(struct clk *clk)
588{
589 sh7722_mstpcr_start_stop(clk, MSTPCR0, 1);
590}
591
592static void sh7722_mstpcr0_disable(struct clk *clk)
593{ 606{
594 sh7722_mstpcr_start_stop(clk, MSTPCR0, 0); 607 sh7722_mstpcr_start_stop(clk, 1);
595} 608}
596 609
597static void sh7722_mstpcr1_enable(struct clk *clk) 610static void sh7722_mstpcr_disable(struct clk *clk)
598{ 611{
599 sh7722_mstpcr_start_stop(clk, MSTPCR1, 1); 612 sh7722_mstpcr_start_stop(clk, 0);
600} 613}
601 614
602static void sh7722_mstpcr1_disable(struct clk *clk) 615static struct clk_ops sh7722_mstpcr_clk_ops = {
603{ 616 .enable = sh7722_mstpcr_enable,
604 sh7722_mstpcr_start_stop(clk, MSTPCR1, 0); 617 .disable = sh7722_mstpcr_disable,
605}
606
607static void sh7722_mstpcr2_enable(struct clk *clk)
608{
609 sh7722_mstpcr_start_stop(clk, MSTPCR2, 1);
610}
611
612static void sh7722_mstpcr2_disable(struct clk *clk)
613{
614 sh7722_mstpcr_start_stop(clk, MSTPCR2, 0);
615}
616
617static struct clk_ops sh7722_mstpcr0_clk_ops = {
618 .enable = sh7722_mstpcr0_enable,
619 .disable = sh7722_mstpcr0_disable,
620};
621
622static struct clk_ops sh7722_mstpcr1_clk_ops = {
623 .enable = sh7722_mstpcr1_enable,
624 .disable = sh7722_mstpcr1_disable,
625};
626
627static struct clk_ops sh7722_mstpcr2_clk_ops = {
628 .enable = sh7722_mstpcr2_enable,
629 .disable = sh7722_mstpcr2_disable,
630}; 618};
631 619
632#define DECLARE_MSTPCRN(regnr, bitnr, bitstr) \ 620#define DECLARE_MSTPCRN(regnr, bitnr, bitstr) \
633{ \ 621{ \
634 .name = "mstp" __stringify(regnr) bitstr, \ 622 .name = "mstp" __stringify(regnr) bitstr, \
635 .arch_flags = bitnr, \ 623 .arch_flags = MSTPCR_ARCH_FLAGS(regnr, bitnr), \
636 .ops = &sh7722_mstpcr ## regnr ## _clk_ops, \ 624 .ops = &sh7722_mstpcr_clk_ops, \
637} 625}
638 626
639#define DECLARE_MSTPCR(regnr) \ 627#define DECLARE_MSTPCR(regnr) \