1 From 6be3809614db2d52724eb4b5193c27d2466142be Mon Sep 17 00:00:00 2001
2 From: notro <notro@tronnes.org>
3 Date: Wed, 9 Jul 2014 14:47:48 +0200
4 Subject: [PATCH 050/114] BCM2708: armctrl: Add IRQ Device Tree support
6 Add Device Tree IRQ support for BCM2708.
7 Usage is the same as for irq-bcm2835.
8 See binding document: brcm,bcm2835-armctrl-ic.txt
10 A bank 3 is added to handle GPIO interrupts. This is done because
11 armctrl also handles GPIO interrupts.
13 Signed-off-by: Noralf Tronnes <notro@tronnes.org>
15 BCM2708: armctrl: remove irq bank 3
17 irq bank 3 was needed by the pinctrl-bcm2708 and bcm2708_gpio
18 combination. It is no longer required.
20 Signed-off-by: Noralf Tronnes <notro@tronnes.org>
22 arch/arm/boot/dts/bcm2708.dtsi | 9 ++++
23 arch/arm/mach-bcm2708/armctrl.c | 96 +++++++++++++++++++++++++++++++++++++++++
24 2 files changed, 105 insertions(+)
26 --- a/arch/arm/boot/dts/bcm2708.dtsi
27 +++ b/arch/arm/boot/dts/bcm2708.dtsi
29 compatible = "brcm,bcm2708";
32 + interrupt-parent = <&intc>;
36 bootargs must be 1024 characters long because the
40 ranges = <0x7e000000 0x20000000 0x02000000>;
42 + intc: interrupt-controller {
43 + compatible = "brcm,bcm2708-armctrl-ic";
44 + reg = <0x7e00b200 0x200>;
45 + interrupt-controller;
46 + #interrupt-cells = <2>;
51 --- a/arch/arm/mach-bcm2708/armctrl.c
52 +++ b/arch/arm/mach-bcm2708/armctrl.c
54 #include <linux/version.h>
55 #include <linux/syscore_ops.h>
56 #include <linux/interrupt.h>
57 +#include <linux/irqdomain.h>
58 +#include <linux/of.h>
60 #include <asm/mach/irq.h>
61 #include <mach/hardware.h>
62 @@ -79,6 +81,99 @@ static void armctrl_unmask_irq(struct ir
68 +#define NR_IRQS_BANK0 21
70 +#define IRQS_PER_BANK 32
72 +/* from drivers/irqchip/irq-bcm2835.c */
73 +static int armctrl_xlate(struct irq_domain *d, struct device_node *ctrlr,
74 + const u32 *intspec, unsigned int intsize,
75 + unsigned long *out_hwirq, unsigned int *out_type)
77 + if (WARN_ON(intsize != 2))
80 + if (WARN_ON(intspec[0] >= NR_BANKS))
83 + if (WARN_ON(intspec[1] >= IRQS_PER_BANK))
86 + if (WARN_ON(intspec[0] == 0 && intspec[1] >= NR_IRQS_BANK0))
89 + if (intspec[0] == 0)
90 + *out_hwirq = ARM_IRQ0_BASE + intspec[1];
91 + else if (intspec[0] == 1)
92 + *out_hwirq = ARM_IRQ1_BASE + intspec[1];
94 + *out_hwirq = ARM_IRQ2_BASE + intspec[1];
96 + /* reverse remap_irqs[] */
97 + switch (*out_hwirq) {
98 + case INTERRUPT_VC_JPEG:
99 + *out_hwirq = INTERRUPT_JPEG;
101 + case INTERRUPT_VC_USB:
102 + *out_hwirq = INTERRUPT_USB;
104 + case INTERRUPT_VC_3D:
105 + *out_hwirq = INTERRUPT_3D;
107 + case INTERRUPT_VC_DMA2:
108 + *out_hwirq = INTERRUPT_DMA2;
110 + case INTERRUPT_VC_DMA3:
111 + *out_hwirq = INTERRUPT_DMA3;
113 + case INTERRUPT_VC_I2C:
114 + *out_hwirq = INTERRUPT_I2C;
116 + case INTERRUPT_VC_SPI:
117 + *out_hwirq = INTERRUPT_SPI;
119 + case INTERRUPT_VC_I2SPCM:
120 + *out_hwirq = INTERRUPT_I2SPCM;
122 + case INTERRUPT_VC_SDIO:
123 + *out_hwirq = INTERRUPT_SDIO;
125 + case INTERRUPT_VC_UART:
126 + *out_hwirq = INTERRUPT_UART;
128 + case INTERRUPT_VC_ARASANSDIO:
129 + *out_hwirq = INTERRUPT_ARASANSDIO;
133 + *out_type = IRQ_TYPE_NONE;
137 +static struct irq_domain_ops armctrl_ops = {
138 + .xlate = armctrl_xlate
141 +void __init armctrl_dt_init(void)
143 + struct device_node *np;
144 + struct irq_domain *domain;
146 + np = of_find_compatible_node(NULL, NULL, "brcm,bcm2708-armctrl-ic");
150 + domain = irq_domain_add_legacy(np, BCM2708_ALLOC_IRQS,
151 + IRQ_ARMCTRL_START, 0,
152 + &armctrl_ops, NULL);
156 +void __init armctrl_dt_init(void) { }
157 +#endif /* CONFIG_OF */
159 #if defined(CONFIG_PM)
161 /* for kernels 3.xx use the new syscore_ops apis but for older kernels use the sys dev class */
162 @@ -215,5 +310,6 @@ int __init armctrl_init(void __iomem * b
164 armctrl_pm_register(base, irq_start, resume_sources);