aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>2013-09-09 08:01:20 -0400
committerSebastian Hesselbarth <sebastian.hesselbarth@gmail.com>2013-12-13 10:29:40 -0500
commit350d71b94fc9ed4ba9a349786f928aa5e594adc1 (patch)
tree36125d138f08596af23b63ce30166d173dc225cc
parent6ce4eac1f600b34f2f7f58f9cd8f0503d79e42ae (diff)
irqchip: add DesignWare APB ICTL interrupt controller
This adds an irqchip driver and corresponding devicetree binding for the secondary interrupt controllers based on Synopsys DesignWare IP dw_apb_ictl. Signed-off-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com> Reviewed-by: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Jisheng Zhang <jszhang@marvell.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r--Documentation/devicetree/bindings/interrupt-controller/snps,dw-apb-ictl.txt32
-rw-r--r--drivers/irqchip/Kconfig4
-rw-r--r--drivers/irqchip/Makefile1
-rw-r--r--drivers/irqchip/irq-dw-apb-ictl.c150
4 files changed, 187 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/interrupt-controller/snps,dw-apb-ictl.txt b/Documentation/devicetree/bindings/interrupt-controller/snps,dw-apb-ictl.txt
new file mode 100644
index 000000000000..492911744ca3
--- /dev/null
+++ b/Documentation/devicetree/bindings/interrupt-controller/snps,dw-apb-ictl.txt
@@ -0,0 +1,32 @@
1Synopsys DesignWare APB interrupt controller (dw_apb_ictl)
2
3Synopsys DesignWare provides interrupt controller IP for APB known as
4dw_apb_ictl. The IP is used as secondary interrupt controller in some SoCs with
5APB bus, e.g. Marvell Armada 1500.
6
7Required properties:
8- compatible: shall be "snps,dw-apb-ictl"
9- reg: physical base address of the controller and length of memory mapped
10 region starting with ENABLE_LOW register
11- interrupt-controller: identifies the node as an interrupt controller
12- #interrupt-cells: number of cells to encode an interrupt-specifier, shall be 1
13- interrupts: interrupt reference to primary interrupt controller
14- interrupt-parent: (optional) reference specific primary interrupt controller
15
16The interrupt sources map to the corresponding bits in the interrupt
17registers, i.e.
18- 0 maps to bit 0 of low interrupts,
19- 1 maps to bit 1 of low interrupts,
20- 32 maps to bit 0 of high interrupts,
21- 33 maps to bit 1 of high interrupts,
22- (optional) fast interrupts start at 64.
23
24Example:
25 aic: interrupt-controller@3000 {
26 compatible = "snps,dw-apb-ictl";
27 reg = <0x3000 0xc00>;
28 interrupt-controller;
29 #interrupt-cells = <1>;
30 interrupt-parent = <&gic>;
31 interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
32 };
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
index 3792a1aa52b8..940638ddc982 100644
--- a/drivers/irqchip/Kconfig
+++ b/drivers/irqchip/Kconfig
@@ -30,6 +30,10 @@ config ARM_VIC_NR
30 The maximum number of VICs available in the system, for 30 The maximum number of VICs available in the system, for
31 power management. 31 power management.
32 32
33config DW_APB_ICTL
34 bool
35 select IRQ_DOMAIN
36
33config IMGPDC_IRQ 37config IMGPDC_IRQ
34 bool 38 bool
35 select GENERIC_IRQ_CHIP 39 select GENERIC_IRQ_CHIP
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
index c60b9010b152..6427323af4c3 100644
--- a/drivers/irqchip/Makefile
+++ b/drivers/irqchip/Makefile
@@ -6,6 +6,7 @@ obj-$(CONFIG_ARCH_MMP) += irq-mmp.o
6obj-$(CONFIG_ARCH_MVEBU) += irq-armada-370-xp.o 6obj-$(CONFIG_ARCH_MVEBU) += irq-armada-370-xp.o
7obj-$(CONFIG_ARCH_MXS) += irq-mxs.o 7obj-$(CONFIG_ARCH_MXS) += irq-mxs.o
8obj-$(CONFIG_ARCH_S3C24XX) += irq-s3c24xx.o 8obj-$(CONFIG_ARCH_S3C24XX) += irq-s3c24xx.o
9obj-$(CONFIG_DW_APB_ICTL) += irq-dw-apb-ictl.o
9obj-$(CONFIG_METAG) += irq-metag-ext.o 10obj-$(CONFIG_METAG) += irq-metag-ext.o
10obj-$(CONFIG_METAG_PERFCOUNTER_IRQS) += irq-metag.o 11obj-$(CONFIG_METAG_PERFCOUNTER_IRQS) += irq-metag.o
11obj-$(CONFIG_ARCH_MOXART) += irq-moxart.o 12obj-$(CONFIG_ARCH_MOXART) += irq-moxart.o
diff --git a/drivers/irqchip/irq-dw-apb-ictl.c b/drivers/irqchip/irq-dw-apb-ictl.c
new file mode 100644
index 000000000000..31e231e1f566
--- /dev/null
+++ b/drivers/irqchip/irq-dw-apb-ictl.c
@@ -0,0 +1,150 @@
1/*
2 * Synopsys DW APB ICTL irqchip driver.
3 *
4 * Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
5 *
6 * based on GPL'ed 2.6 kernel sources
7 * (c) Marvell International Ltd.
8 *
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
12 */
13
14#include <linux/io.h>
15#include <linux/irq.h>
16#include <linux/irqchip/chained_irq.h>
17#include <linux/of_address.h>
18#include <linux/of_irq.h>
19
20#include "irqchip.h"
21
22#define APB_INT_ENABLE_L 0x00
23#define APB_INT_ENABLE_H 0x04
24#define APB_INT_MASK_L 0x08
25#define APB_INT_MASK_H 0x0c
26#define APB_INT_FINALSTATUS_L 0x30
27#define APB_INT_FINALSTATUS_H 0x34
28
29static void dw_apb_ictl_handler(unsigned int irq, struct irq_desc *desc)
30{
31 struct irq_chip *chip = irq_get_chip(irq);
32 struct irq_chip_generic *gc = irq_get_handler_data(irq);
33 struct irq_domain *d = gc->private;
34 u32 stat;
35 int n;
36
37 chained_irq_enter(chip, desc);
38
39 for (n = 0; n < gc->num_ct; n++) {
40 stat = readl_relaxed(gc->reg_base +
41 APB_INT_FINALSTATUS_L + 4 * n);
42 while (stat) {
43 u32 hwirq = ffs(stat) - 1;
44 generic_handle_irq(irq_find_mapping(d,
45 gc->irq_base + hwirq + 32 * n));
46 stat &= ~(1 << hwirq);
47 }
48 }
49
50 chained_irq_exit(chip, desc);
51}
52
53static int __init dw_apb_ictl_init(struct device_node *np,
54 struct device_node *parent)
55{
56 unsigned int clr = IRQ_NOREQUEST | IRQ_NOPROBE | IRQ_NOAUTOEN;
57 struct resource r;
58 struct irq_domain *domain;
59 struct irq_chip_generic *gc;
60 void __iomem *iobase;
61 int ret, nrirqs, irq;
62 u32 reg;
63
64 /* Map the parent interrupt for the chained handler */
65 irq = irq_of_parse_and_map(np, 0);
66 if (irq <= 0) {
67 pr_err("%s: unable to parse irq\n", np->full_name);
68 return -EINVAL;
69 }
70
71 ret = of_address_to_resource(np, 0, &r);
72 if (ret) {
73 pr_err("%s: unable to get resource\n", np->full_name);
74 return ret;
75 }
76
77 if (!request_mem_region(r.start, resource_size(&r), np->full_name)) {
78 pr_err("%s: unable to request mem region\n", np->full_name);
79 return -ENOMEM;
80 }
81
82 iobase = ioremap(r.start, resource_size(&r));
83 if (!iobase) {
84 pr_err("%s: unable to map resource\n", np->full_name);
85 ret = -ENOMEM;
86 goto err_release;
87 }
88
89 /*
90 * DW IP can be configured to allow 2-64 irqs. We can determine
91 * the number of irqs supported by writing into enable register
92 * and look for bits not set, as corresponding flip-flops will
93 * have been removed by sythesis tool.
94 */
95
96 /* mask and enable all interrupts */
97 writel(~0, iobase + APB_INT_MASK_L);
98 writel(~0, iobase + APB_INT_MASK_H);
99 writel(~0, iobase + APB_INT_ENABLE_L);
100 writel(~0, iobase + APB_INT_ENABLE_H);
101
102 reg = readl(iobase + APB_INT_ENABLE_H);
103 if (reg)
104 nrirqs = 32 + fls(reg);
105 else
106 nrirqs = fls(readl(iobase + APB_INT_ENABLE_L));
107
108 domain = irq_domain_add_linear(np, nrirqs,
109 &irq_generic_chip_ops, NULL);
110 if (!domain) {
111 pr_err("%s: unable to add irq domain\n", np->full_name);
112 ret = -ENOMEM;
113 goto err_unmap;
114 }
115
116 ret = irq_alloc_domain_generic_chips(domain, 32, (nrirqs > 32) ? 2 : 1,
117 np->name, handle_level_irq, clr, 0,
118 IRQ_GC_INIT_MASK_CACHE);
119 if (ret) {
120 pr_err("%s: unable to alloc irq domain gc\n", np->full_name);
121 goto err_unmap;
122 }
123
124 gc = irq_get_domain_generic_chip(domain, 0);
125 gc->private = domain;
126 gc->reg_base = iobase;
127
128 gc->chip_types[0].regs.mask = APB_INT_MASK_L;
129 gc->chip_types[0].chip.irq_mask = irq_gc_mask_set_bit;
130 gc->chip_types[0].chip.irq_unmask = irq_gc_mask_clr_bit;
131
132 if (nrirqs > 32) {
133 gc->chip_types[1].regs.mask = APB_INT_MASK_H;
134 gc->chip_types[1].chip.irq_mask = irq_gc_mask_set_bit;
135 gc->chip_types[1].chip.irq_unmask = irq_gc_mask_clr_bit;
136 }
137
138 irq_set_handler_data(irq, gc);
139 irq_set_chained_handler(irq, dw_apb_ictl_handler);
140
141 return 0;
142
143err_unmap:
144 iounmap(iobase);
145err_release:
146 release_mem_region(r.start, resource_size(&r));
147 return ret;
148}
149IRQCHIP_DECLARE(dw_apb_ictl,
150 "snps,dw-apb-ictl", dw_apb_ictl_init);