2 * interrupt controller support for CSR SiRFprimaII
4 * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
6 * Licensed under GPLv2 or later.
9 #include <linux/init.h>
11 #include <linux/irq.h>
12 #include <mach/hardware.h>
13 #include <asm/mach/irq.h>
15 #include <linux/of_address.h>
16 #include <linux/irqdomain.h>
17 #include <linux/syscore_ops.h>
19 #define SIRFSOC_INT_RISC_MASK0 0x0018
20 #define SIRFSOC_INT_RISC_MASK1 0x001C
21 #define SIRFSOC_INT_RISC_LEVEL0 0x0020
22 #define SIRFSOC_INT_RISC_LEVEL1 0x0024
24 void __iomem
*sirfsoc_intc_base
;
27 sirfsoc_alloc_gc(void __iomem
*base
, unsigned int irq_start
, unsigned int num
)
29 struct irq_chip_generic
*gc
;
30 struct irq_chip_type
*ct
;
32 gc
= irq_alloc_generic_chip("SIRFINTC", 1, irq_start
, base
, handle_level_irq
);
35 ct
->chip
.irq_mask
= irq_gc_mask_clr_bit
;
36 ct
->chip
.irq_unmask
= irq_gc_mask_set_bit
;
37 ct
->regs
.mask
= SIRFSOC_INT_RISC_MASK0
;
39 irq_setup_generic_chip(gc
, IRQ_MSK(num
), IRQ_GC_INIT_MASK_CACHE
, IRQ_NOREQUEST
, 0);
42 static __init
void sirfsoc_irq_init(void)
44 sirfsoc_alloc_gc(sirfsoc_intc_base
, 0, 32);
45 sirfsoc_alloc_gc(sirfsoc_intc_base
+ 4, 32, SIRFSOC_INTENAL_IRQ_END
- 32);
47 writel_relaxed(0, sirfsoc_intc_base
+ SIRFSOC_INT_RISC_LEVEL0
);
48 writel_relaxed(0, sirfsoc_intc_base
+ SIRFSOC_INT_RISC_LEVEL1
);
50 writel_relaxed(0, sirfsoc_intc_base
+ SIRFSOC_INT_RISC_MASK0
);
51 writel_relaxed(0, sirfsoc_intc_base
+ SIRFSOC_INT_RISC_MASK1
);
54 static struct of_device_id intc_ids
[] = {
55 { .compatible
= "sirf,prima2-intc" },
59 void __init
sirfsoc_of_irq_init(void)
61 struct device_node
*np
;
63 np
= of_find_matching_node(NULL
, intc_ids
);
65 panic("unable to find compatible intc node in dtb\n");
67 sirfsoc_intc_base
= of_iomap(np
, 0);
68 if (!sirfsoc_intc_base
)
69 panic("unable to map intc cpu registers\n");
71 irq_domain_add_simple(np
, 0);
78 struct sirfsoc_irq_status
{
85 static struct sirfsoc_irq_status sirfsoc_irq_st
;
87 static int sirfsoc_irq_suspend(void)
89 sirfsoc_irq_st
.mask0
= readl_relaxed(sirfsoc_intc_base
+ SIRFSOC_INT_RISC_MASK0
);
90 sirfsoc_irq_st
.mask1
= readl_relaxed(sirfsoc_intc_base
+ SIRFSOC_INT_RISC_MASK1
);
91 sirfsoc_irq_st
.level0
= readl_relaxed(sirfsoc_intc_base
+ SIRFSOC_INT_RISC_LEVEL0
);
92 sirfsoc_irq_st
.level1
= readl_relaxed(sirfsoc_intc_base
+ SIRFSOC_INT_RISC_LEVEL1
);
97 static void sirfsoc_irq_resume(void)
99 writel_relaxed(sirfsoc_irq_st
.mask0
, sirfsoc_intc_base
+ SIRFSOC_INT_RISC_MASK0
);
100 writel_relaxed(sirfsoc_irq_st
.mask1
, sirfsoc_intc_base
+ SIRFSOC_INT_RISC_MASK1
);
101 writel_relaxed(sirfsoc_irq_st
.level0
, sirfsoc_intc_base
+ SIRFSOC_INT_RISC_LEVEL0
);
102 writel_relaxed(sirfsoc_irq_st
.level1
, sirfsoc_intc_base
+ SIRFSOC_INT_RISC_LEVEL1
);
105 static struct syscore_ops sirfsoc_irq_syscore_ops
= {
106 .suspend
= sirfsoc_irq_suspend
,
107 .resume
= sirfsoc_irq_resume
,
110 static int __init
sirfsoc_irq_pm_init(void)
112 register_syscore_ops(&sirfsoc_irq_syscore_ops
);
115 device_initcall(sirfsoc_irq_pm_init
);