aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/alchemy/common/irq.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/alchemy/common/irq.c')
-rw-r--r--arch/mips/alchemy/common/irq.c174
1 files changed, 90 insertions, 84 deletions
diff --git a/arch/mips/alchemy/common/irq.c b/arch/mips/alchemy/common/irq.c
index b2821ace4d00..9f78ada83b3c 100644
--- a/arch/mips/alchemy/common/irq.c
+++ b/arch/mips/alchemy/common/irq.c
@@ -29,6 +29,8 @@
29#include <linux/init.h> 29#include <linux/init.h>
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>
33#include <linux/sysdev.h>
32 34
33#include <asm/irq_cpu.h> 35#include <asm/irq_cpu.h>
34#include <asm/mipsregs.h> 36#include <asm/mipsregs.h>
@@ -216,90 +218,6 @@ struct au1xxx_irqmap au1200_irqmap[] __initdata = {
216}; 218};
217 219
218 220
219#ifdef CONFIG_PM
220
221/*
222 * Save/restore the interrupt controller state.
223 * Called from the save/restore core registers as part of the
224 * au_sleep function in power.c.....maybe I should just pm_register()
225 * them instead?
226 */
227static unsigned int sleep_intctl_config0[2];
228static unsigned int sleep_intctl_config1[2];
229static unsigned int sleep_intctl_config2[2];
230static unsigned int sleep_intctl_src[2];
231static unsigned int sleep_intctl_assign[2];
232static unsigned int sleep_intctl_wake[2];
233static unsigned int sleep_intctl_mask[2];
234
235void save_au1xxx_intctl(void)
236{
237 sleep_intctl_config0[0] = au_readl(IC0_CFG0RD);
238 sleep_intctl_config1[0] = au_readl(IC0_CFG1RD);
239 sleep_intctl_config2[0] = au_readl(IC0_CFG2RD);
240 sleep_intctl_src[0] = au_readl(IC0_SRCRD);
241 sleep_intctl_assign[0] = au_readl(IC0_ASSIGNRD);
242 sleep_intctl_wake[0] = au_readl(IC0_WAKERD);
243 sleep_intctl_mask[0] = au_readl(IC0_MASKRD);
244
245 sleep_intctl_config0[1] = au_readl(IC1_CFG0RD);
246 sleep_intctl_config1[1] = au_readl(IC1_CFG1RD);
247 sleep_intctl_config2[1] = au_readl(IC1_CFG2RD);
248 sleep_intctl_src[1] = au_readl(IC1_SRCRD);
249 sleep_intctl_assign[1] = au_readl(IC1_ASSIGNRD);
250 sleep_intctl_wake[1] = au_readl(IC1_WAKERD);
251 sleep_intctl_mask[1] = au_readl(IC1_MASKRD);
252}
253
254/*
255 * For most restore operations, we clear the entire register and
256 * then set the bits we found during the save.
257 */
258void restore_au1xxx_intctl(void)
259{
260 au_writel(0xffffffff, IC0_MASKCLR); au_sync();
261
262 au_writel(0xffffffff, IC0_CFG0CLR); au_sync();
263 au_writel(sleep_intctl_config0[0], IC0_CFG0SET); au_sync();
264 au_writel(0xffffffff, IC0_CFG1CLR); au_sync();
265 au_writel(sleep_intctl_config1[0], IC0_CFG1SET); au_sync();
266 au_writel(0xffffffff, IC0_CFG2CLR); au_sync();
267 au_writel(sleep_intctl_config2[0], IC0_CFG2SET); au_sync();
268 au_writel(0xffffffff, IC0_SRCCLR); au_sync();
269 au_writel(sleep_intctl_src[0], IC0_SRCSET); au_sync();
270 au_writel(0xffffffff, IC0_ASSIGNCLR); au_sync();
271 au_writel(sleep_intctl_assign[0], IC0_ASSIGNSET); au_sync();
272 au_writel(0xffffffff, IC0_WAKECLR); au_sync();
273 au_writel(sleep_intctl_wake[0], IC0_WAKESET); au_sync();
274 au_writel(0xffffffff, IC0_RISINGCLR); au_sync();
275 au_writel(0xffffffff, IC0_FALLINGCLR); au_sync();
276 au_writel(0x00000000, IC0_TESTBIT); au_sync();
277
278 au_writel(0xffffffff, IC1_MASKCLR); au_sync();
279
280 au_writel(0xffffffff, IC1_CFG0CLR); au_sync();
281 au_writel(sleep_intctl_config0[1], IC1_CFG0SET); au_sync();
282 au_writel(0xffffffff, IC1_CFG1CLR); au_sync();
283 au_writel(sleep_intctl_config1[1], IC1_CFG1SET); au_sync();
284 au_writel(0xffffffff, IC1_CFG2CLR); au_sync();
285 au_writel(sleep_intctl_config2[1], IC1_CFG2SET); au_sync();
286 au_writel(0xffffffff, IC1_SRCCLR); au_sync();
287 au_writel(sleep_intctl_src[1], IC1_SRCSET); au_sync();
288 au_writel(0xffffffff, IC1_ASSIGNCLR); au_sync();
289 au_writel(sleep_intctl_assign[1], IC1_ASSIGNSET); au_sync();
290 au_writel(0xffffffff, IC1_WAKECLR); au_sync();
291 au_writel(sleep_intctl_wake[1], IC1_WAKESET); au_sync();
292 au_writel(0xffffffff, IC1_RISINGCLR); au_sync();
293 au_writel(0xffffffff, IC1_FALLINGCLR); au_sync();
294 au_writel(0x00000000, IC1_TESTBIT); au_sync();
295
296 au_writel(sleep_intctl_mask[1], IC1_MASKSET); au_sync();
297
298 au_writel(sleep_intctl_mask[0], IC0_MASKSET); au_sync();
299}
300#endif /* CONFIG_PM */
301
302
303static void au1x_ic0_unmask(unsigned int irq_nr) 221static void au1x_ic0_unmask(unsigned int irq_nr)
304{ 222{
305 unsigned int bit = irq_nr - AU1000_INTC0_INT_BASE; 223 unsigned int bit = irq_nr - AU1000_INTC0_INT_BASE;
@@ -635,3 +553,91 @@ void __init arch_init_irq(void)
635 break; 553 break;
636 } 554 }
637} 555}
556
557struct alchemy_ic_sysdev {
558 struct sys_device sysdev;
559 void __iomem *base;
560 unsigned long pmdata[7];
561};
562
563static int alchemy_ic_suspend(struct sys_device *dev, pm_message_t state)
564{
565 struct alchemy_ic_sysdev *icdev =
566 container_of(dev, struct alchemy_ic_sysdev, sysdev);
567
568 icdev->pmdata[0] = __raw_readl(icdev->base + IC_CFG0RD);
569 icdev->pmdata[1] = __raw_readl(icdev->base + IC_CFG1RD);
570 icdev->pmdata[2] = __raw_readl(icdev->base + IC_CFG2RD);
571 icdev->pmdata[3] = __raw_readl(icdev->base + IC_SRCRD);
572 icdev->pmdata[4] = __raw_readl(icdev->base + IC_ASSIGNRD);
573 icdev->pmdata[5] = __raw_readl(icdev->base + IC_WAKERD);
574 icdev->pmdata[6] = __raw_readl(icdev->base + IC_MASKRD);
575
576 return 0;
577}
578
579static int alchemy_ic_resume(struct sys_device *dev)
580{
581 struct alchemy_ic_sysdev *icdev =
582 container_of(dev, struct alchemy_ic_sysdev, sysdev);
583
584 __raw_writel(0xffffffff, icdev->base + IC_MASKCLR);
585 __raw_writel(0xffffffff, icdev->base + IC_CFG0CLR);
586 __raw_writel(0xffffffff, icdev->base + IC_CFG1CLR);
587 __raw_writel(0xffffffff, icdev->base + IC_CFG2CLR);
588 __raw_writel(0xffffffff, icdev->base + IC_SRCCLR);
589 __raw_writel(0xffffffff, icdev->base + IC_ASSIGNCLR);
590 __raw_writel(0xffffffff, icdev->base + IC_WAKECLR);
591 __raw_writel(0xffffffff, icdev->base + IC_RISINGCLR);
592 __raw_writel(0xffffffff, icdev->base + IC_FALLINGCLR);
593 __raw_writel(0x00000000, icdev->base + IC_TESTBIT);
594 wmb();
595 __raw_writel(icdev->pmdata[0], icdev->base + IC_CFG0SET);
596 __raw_writel(icdev->pmdata[1], icdev->base + IC_CFG1SET);
597 __raw_writel(icdev->pmdata[2], icdev->base + IC_CFG2SET);
598 __raw_writel(icdev->pmdata[3], icdev->base + IC_SRCSET);
599 __raw_writel(icdev->pmdata[4], icdev->base + IC_ASSIGNSET);
600 __raw_writel(icdev->pmdata[5], icdev->base + IC_WAKESET);
601 wmb();
602
603 __raw_writel(icdev->pmdata[6], icdev->base + IC_MASKSET);
604 wmb();
605
606 return 0;
607}
608
609static struct sysdev_class alchemy_ic_sysdev_class = {
610 .name = "ic",
611 .suspend = alchemy_ic_suspend,
612 .resume = alchemy_ic_resume,
613};
614
615static int __init alchemy_ic_sysdev_init(void)
616{
617 struct alchemy_ic_sysdev *icdev;
618 unsigned long icbase[2] = { IC0_PHYS_ADDR, IC1_PHYS_ADDR };
619 int err, i;
620
621 err = sysdev_class_register(&alchemy_ic_sysdev_class);
622 if (err)
623 return err;
624
625 for (i = 0; i < 2; i++) {
626 icdev = kzalloc(sizeof(struct alchemy_ic_sysdev), GFP_KERNEL);
627 if (!icdev)
628 return -ENOMEM;
629
630 icdev->base = ioremap(icbase[i], 0x1000);
631
632 icdev->sysdev.id = i;
633 icdev->sysdev.cls = &alchemy_ic_sysdev_class;
634 err = sysdev_register(&icdev->sysdev);
635 if (err) {
636 kfree(icdev);
637 return err;
638 }
639 }
640
641 return 0;
642}
643device_initcall(alchemy_ic_sysdev_init);