diff options
author | Manuel Lauss <manuel.lauss@googlemail.com> | 2011-05-08 04:42:15 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2011-05-19 04:55:45 -0400 |
commit | 4b5c82b5e57ac6cb919e7e74984e28b312bdf10c (patch) | |
tree | bd92c63f5b7e8dd2daab99dc3741b5b8b01dcbdd /arch/mips/alchemy | |
parent | dca7587185b3a499a09a9e2755316eee31c49c7f (diff) |
MIPS: Alchemy: Convert irq.c to syscore_ops.
Convert the PM sysdev to use syscore_ops instead.
Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com>
To: Linux-MIPS <linux-mips@linux-mips.org>
Cc: Florian Fainelli <florian@openwrt.org>
Cc: Wolfgang Grandegger <wg@grandegger.com>
Patchwork: https://patchwork.linux-mips.org/patch/2350/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/alchemy')
-rw-r--r-- | arch/mips/alchemy/common/irq.c | 101 |
1 files changed, 41 insertions, 60 deletions
diff --git a/arch/mips/alchemy/common/irq.c b/arch/mips/alchemy/common/irq.c index b72e12829480..8b60ba0675e2 100644 --- a/arch/mips/alchemy/common/irq.c +++ b/arch/mips/alchemy/common/irq.c | |||
@@ -30,7 +30,7 @@ | |||
30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
31 | #include <linux/irq.h> | 31 | #include <linux/irq.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/sysdev.h> | 33 | #include <linux/syscore_ops.h> |
34 | 34 | ||
35 | #include <asm/irq_cpu.h> | 35 | #include <asm/irq_cpu.h> |
36 | #include <asm/mipsregs.h> | 36 | #include <asm/mipsregs.h> |
@@ -585,81 +585,62 @@ void __init arch_init_irq(void) | |||
585 | } | 585 | } |
586 | } | 586 | } |
587 | 587 | ||
588 | struct alchemy_ic_sysdev { | ||
589 | struct sys_device sysdev; | ||
590 | void __iomem *base; | ||
591 | unsigned long pmdata[7]; | ||
592 | }; | ||
593 | |||
594 | static int alchemy_ic_suspend(struct sys_device *dev, pm_message_t state) | ||
595 | { | ||
596 | struct alchemy_ic_sysdev *icdev = | ||
597 | container_of(dev, struct alchemy_ic_sysdev, sysdev); | ||
598 | 588 | ||
599 | icdev->pmdata[0] = __raw_readl(icdev->base + IC_CFG0RD); | 589 | static unsigned long alchemy_ic_pmdata[7 * 2]; |
600 | icdev->pmdata[1] = __raw_readl(icdev->base + IC_CFG1RD); | ||
601 | icdev->pmdata[2] = __raw_readl(icdev->base + IC_CFG2RD); | ||
602 | icdev->pmdata[3] = __raw_readl(icdev->base + IC_SRCRD); | ||
603 | icdev->pmdata[4] = __raw_readl(icdev->base + IC_ASSIGNRD); | ||
604 | icdev->pmdata[5] = __raw_readl(icdev->base + IC_WAKERD); | ||
605 | icdev->pmdata[6] = __raw_readl(icdev->base + IC_MASKRD); | ||
606 | 590 | ||
607 | return 0; | 591 | static inline void alchemy_ic_suspend_one(void __iomem *base, unsigned long *d) |
592 | { | ||
593 | d[0] = __raw_readl(base + IC_CFG0RD); | ||
594 | d[1] = __raw_readl(base + IC_CFG1RD); | ||
595 | d[2] = __raw_readl(base + IC_CFG2RD); | ||
596 | d[3] = __raw_readl(base + IC_SRCRD); | ||
597 | d[4] = __raw_readl(base + IC_ASSIGNRD); | ||
598 | d[5] = __raw_readl(base + IC_WAKERD); | ||
599 | d[6] = __raw_readl(base + IC_MASKRD); | ||
600 | ic_init(base); /* shut it up too while at it */ | ||
608 | } | 601 | } |
609 | 602 | ||
610 | static int alchemy_ic_resume(struct sys_device *dev) | 603 | static inline void alchemy_ic_resume_one(void __iomem *base, unsigned long *d) |
611 | { | 604 | { |
612 | struct alchemy_ic_sysdev *icdev = | 605 | ic_init(base); |
613 | container_of(dev, struct alchemy_ic_sysdev, sysdev); | 606 | |
614 | 607 | __raw_writel(d[0], base + IC_CFG0SET); | |
615 | ic_init(icdev->base); | 608 | __raw_writel(d[1], base + IC_CFG1SET); |
616 | 609 | __raw_writel(d[2], base + IC_CFG2SET); | |
617 | __raw_writel(icdev->pmdata[0], icdev->base + IC_CFG0SET); | 610 | __raw_writel(d[3], base + IC_SRCSET); |
618 | __raw_writel(icdev->pmdata[1], icdev->base + IC_CFG1SET); | 611 | __raw_writel(d[4], base + IC_ASSIGNSET); |
619 | __raw_writel(icdev->pmdata[2], icdev->base + IC_CFG2SET); | 612 | __raw_writel(d[5], base + IC_WAKESET); |
620 | __raw_writel(icdev->pmdata[3], icdev->base + IC_SRCSET); | ||
621 | __raw_writel(icdev->pmdata[4], icdev->base + IC_ASSIGNSET); | ||
622 | __raw_writel(icdev->pmdata[5], icdev->base + IC_WAKESET); | ||
623 | wmb(); | 613 | wmb(); |
624 | 614 | ||
625 | __raw_writel(icdev->pmdata[6], icdev->base + IC_MASKSET); | 615 | __raw_writel(d[6], base + IC_MASKSET); |
626 | wmb(); | 616 | wmb(); |
617 | } | ||
627 | 618 | ||
619 | static int alchemy_ic_suspend(void) | ||
620 | { | ||
621 | alchemy_ic_suspend_one((void __iomem *)KSEG1ADDR(AU1000_IC0_PHYS_ADDR), | ||
622 | alchemy_ic_pmdata); | ||
623 | alchemy_ic_suspend_one((void __iomem *)KSEG1ADDR(AU1000_IC1_PHYS_ADDR), | ||
624 | &alchemy_ic_pmdata[7]); | ||
628 | return 0; | 625 | return 0; |
629 | } | 626 | } |
630 | 627 | ||
631 | static struct sysdev_class alchemy_ic_sysdev_class = { | 628 | static void alchemy_ic_resume(void) |
632 | .name = "ic", | 629 | { |
630 | alchemy_ic_resume_one((void __iomem *)KSEG1ADDR(AU1000_IC1_PHYS_ADDR), | ||
631 | &alchemy_ic_pmdata[7]); | ||
632 | alchemy_ic_resume_one((void __iomem *)KSEG1ADDR(AU1000_IC0_PHYS_ADDR), | ||
633 | alchemy_ic_pmdata); | ||
634 | } | ||
635 | |||
636 | static struct syscore_ops alchemy_ic_syscore_ops = { | ||
633 | .suspend = alchemy_ic_suspend, | 637 | .suspend = alchemy_ic_suspend, |
634 | .resume = alchemy_ic_resume, | 638 | .resume = alchemy_ic_resume, |
635 | }; | 639 | }; |
636 | 640 | ||
637 | static int __init alchemy_ic_sysdev_init(void) | 641 | static int __init alchemy_ic_pm_init(void) |
638 | { | 642 | { |
639 | struct alchemy_ic_sysdev *icdev; | 643 | register_syscore_ops(&alchemy_ic_syscore_ops); |
640 | unsigned long icbase[2] = { AU1000_IC0_PHYS_ADDR, AU1000_IC1_PHYS_ADDR }; | ||
641 | int err, i; | ||
642 | |||
643 | err = sysdev_class_register(&alchemy_ic_sysdev_class); | ||
644 | if (err) | ||
645 | return err; | ||
646 | |||
647 | for (i = 0; i < 2; i++) { | ||
648 | icdev = kzalloc(sizeof(struct alchemy_ic_sysdev), GFP_KERNEL); | ||
649 | if (!icdev) | ||
650 | return -ENOMEM; | ||
651 | |||
652 | icdev->base = ioremap(icbase[i], 0x1000); | ||
653 | |||
654 | icdev->sysdev.id = i; | ||
655 | icdev->sysdev.cls = &alchemy_ic_sysdev_class; | ||
656 | err = sysdev_register(&icdev->sysdev); | ||
657 | if (err) { | ||
658 | kfree(icdev); | ||
659 | return err; | ||
660 | } | ||
661 | } | ||
662 | |||
663 | return 0; | 644 | return 0; |
664 | } | 645 | } |
665 | device_initcall(alchemy_ic_sysdev_init); | 646 | device_initcall(alchemy_ic_pm_init); |