aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt110
-rw-r--r--arch/arm/boot/dts/bcm2835.dtsi8
-rw-r--r--arch/arm/mach-bcm2835/bcm2835.c10
-rw-r--r--drivers/Kconfig2
-rw-r--r--drivers/Makefile2
-rw-r--r--drivers/irqchip/Kconfig0
-rw-r--r--drivers/irqchip/Makefile1
-rw-r--r--drivers/irqchip/irq-bcm2835.c223
-rw-r--r--include/linux/irqchip/bcm2835.h29
9 files changed, 376 insertions, 9 deletions
diff --git a/Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt b/Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt
new file mode 100644
index 000000000000..548892c08c59
--- /dev/null
+++ b/Documentation/devicetree/bindings/interrupt-controller/brcm,bcm2835-armctrl-ic.txt
@@ -0,0 +1,110 @@
1BCM2835 Top-Level ("ARMCTRL") Interrupt Controller
2
3The BCM2835 contains a custom top-level interrupt controller, which supports
472 interrupt sources using a 2-level register scheme. The interrupt
5controller, or the HW block containing it, is referred to occasionally
6as "armctrl" in the SoC documentation, hence naming of this binding.
7
8Required properties:
9
10- compatible : should be "brcm,bcm2835-armctrl-ic.txt"
11- reg : Specifies base physical address and size of the registers.
12- interrupt-controller : Identifies the node as an interrupt controller
13- #interrupt-cells : Specifies the number of cells needed to encode an
14 interrupt source. The value shall be 2.
15
16 The 1st cell is the interrupt bank; 0 for interrupts in the "IRQ basic
17 pending" register, or 1/2 respectively for interrupts in the "IRQ pending
18 1/2" register.
19
20 The 2nd cell contains the interrupt number within the bank. Valid values
21 are 0..7 for bank 0, and 0..31 for bank 1.
22
23The interrupt sources are as follows:
24
25Bank 0:
260: ARM_TIMER
271: ARM_MAILBOX
282: ARM_DOORBELL_0
293: ARM_DOORBELL_1
304: VPU0_HALTED
315: VPU1_HALTED
326: ILLEGAL_TYPE0
337: ILLEGAL_TYPE1
34
35Bank 1:
360: TIMER0
371: TIMER1
382: TIMER2
393: TIMER3
404: CODEC0
415: CODEC1
426: CODEC2
437: VC_JPEG
448: ISP
459: VC_USB
4610: VC_3D
4711: TRANSPOSER
4812: MULTICORESYNC0
4913: MULTICORESYNC1
5014: MULTICORESYNC2
5115: MULTICORESYNC3
5216: DMA0
5317: DMA1
5418: VC_DMA2
5519: VC_DMA3
5620: DMA4
5721: DMA5
5822: DMA6
5923: DMA7
6024: DMA8
6125: DMA9
6226: DMA10
6327: DMA11
6428: DMA12
6529: AUX
6630: ARM
6731: VPUDMA
68
69Bank 2:
700: HOSTPORT
711: VIDEOSCALER
722: CCP2TX
733: SDC
744: DSI0
755: AVE
766: CAM0
777: CAM1
788: HDMI0
799: HDMI1
8010: PIXELVALVE1
8111: I2CSPISLV
8212: DSI1
8313: PWA0
8414: PWA1
8515: CPR
8616: SMI
8717: GPIO0
8818: GPIO1
8919: GPIO2
9020: GPIO3
9121: VC_I2C
9222: VC_SPI
9323: VC_I2SPCM
9424: VC_SDIO
9525: VC_UART
9626: SLIMBUS
9727: VEC
9828: CPG
9929: RNG
10030: VC_ARASANSDIO
10131: AVSPMON
102
103Example:
104
105intc: interrupt-controller {
106 compatible = "brcm,bcm2835-armctrl-ic";
107 reg = <0x7e00b200 0x200>;
108 interrupt-controller;
109 #interrupt-cells = <2>;
110};
diff --git a/arch/arm/boot/dts/bcm2835.dtsi b/arch/arm/boot/dts/bcm2835.dtsi
index a31cb40ef684..8842d751d7dd 100644
--- a/arch/arm/boot/dts/bcm2835.dtsi
+++ b/arch/arm/boot/dts/bcm2835.dtsi
@@ -3,6 +3,7 @@
3/ { 3/ {
4 compatible = "brcm,bcm2835"; 4 compatible = "brcm,bcm2835";
5 model = "BCM2835"; 5 model = "BCM2835";
6 interrupt-parent = <&intc>;
6 7
7 chosen { 8 chosen {
8 bootargs = "earlyprintk"; 9 bootargs = "earlyprintk";
@@ -13,5 +14,12 @@
13 #address-cells = <1>; 14 #address-cells = <1>;
14 #size-cells = <1>; 15 #size-cells = <1>;
15 ranges = <0x7e000000 0x20000000 0x02000000>; 16 ranges = <0x7e000000 0x20000000 0x02000000>;
17
18 intc: interrupt-controller {
19 compatible = "brcm,bcm2835-armctrl-ic";
20 reg = <0x7e00b200 0x200>;
21 interrupt-controller;
22 #interrupt-cells = <2>;
23 };
16 }; 24 };
17}; 25};
diff --git a/arch/arm/mach-bcm2835/bcm2835.c b/arch/arm/mach-bcm2835/bcm2835.c
index f6b36b4b5921..72c4b5ff8f90 100644
--- a/arch/arm/mach-bcm2835/bcm2835.c
+++ b/arch/arm/mach-bcm2835/bcm2835.c
@@ -13,12 +13,12 @@
13 */ 13 */
14 14
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/irqchip/bcm2835.h>
16#include <linux/of_platform.h> 17#include <linux/of_platform.h>
17 18
18#include <asm/mach/arch.h> 19#include <asm/mach/arch.h>
19#include <asm/mach/map.h> 20#include <asm/mach/map.h>
20#include <asm/mach/time.h> 21#include <asm/mach/time.h>
21#include <asm/exception.h>
22 22
23#include <mach/bcm2835_soc.h> 23#include <mach/bcm2835_soc.h>
24 24
@@ -34,14 +34,6 @@ void __init bcm2835_map_io(void)
34 iotable_init(&io_map, 1); 34 iotable_init(&io_map, 1);
35} 35}
36 36
37void __init bcm2835_init_irq(void)
38{
39}
40
41asmlinkage void __exception_irq_entry bcm2835_handle_irq(struct pt_regs *regs)
42{
43}
44
45void __init bcm2835_init(void) 37void __init bcm2835_init(void)
46{ 38{
47 int ret; 39 int ret;
diff --git a/drivers/Kconfig b/drivers/Kconfig
index ece958d3762e..36d3daa19a74 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -152,4 +152,6 @@ source "drivers/vme/Kconfig"
152 152
153source "drivers/pwm/Kconfig" 153source "drivers/pwm/Kconfig"
154 154
155source "drivers/irqchip/Kconfig"
156
155endmenu 157endmenu
diff --git a/drivers/Makefile b/drivers/Makefile
index 5b421840c48d..8c30e73cd94c 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -5,6 +5,8 @@
5# Rewritten to use lists instead of if-statements. 5# Rewritten to use lists instead of if-statements.
6# 6#
7 7
8obj-y += irqchip/
9
8# GPIO must come after pinctrl as gpios may need to mux pins etc 10# GPIO must come after pinctrl as gpios may need to mux pins etc
9obj-y += pinctrl/ 11obj-y += pinctrl/
10obj-y += gpio/ 12obj-y += gpio/
diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/drivers/irqchip/Kconfig
diff --git a/drivers/irqchip/Makefile b/drivers/irqchip/Makefile
new file mode 100644
index 000000000000..054321db4350
--- /dev/null
+++ b/drivers/irqchip/Makefile
@@ -0,0 +1 @@
obj-$(CONFIG_ARCH_BCM2835) += irq-bcm2835.o
diff --git a/drivers/irqchip/irq-bcm2835.c b/drivers/irqchip/irq-bcm2835.c
new file mode 100644
index 000000000000..dc670ccc6978
--- /dev/null
+++ b/drivers/irqchip/irq-bcm2835.c
@@ -0,0 +1,223 @@
1/*
2 * Copyright 2010 Broadcom
3 * Copyright 2012 Simon Arlott, Chris Boot, Stephen Warren
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * Quirk 1: Shortcut interrupts don't set the bank 1/2 register pending bits
16 *
17 * If an interrupt fires on bank 1 that isn't in the shortcuts list, bit 8
18 * on bank 0 is set to signify that an interrupt in bank 1 has fired, and
19 * to look in the bank 1 status register for more information.
20 *
21 * If an interrupt fires on bank 1 that _is_ in the shortcuts list, its
22 * shortcut bit in bank 0 is set as well as its interrupt bit in the bank 1
23 * status register, but bank 0 bit 8 is _not_ set.
24 *
25 * Quirk 2: You can't mask the register 1/2 pending interrupts
26 *
27 * In a proper cascaded interrupt controller, the interrupt lines with
28 * cascaded interrupt controllers on them are just normal interrupt lines.
29 * You can mask the interrupts and get on with things. With this controller
30 * you can't do that.
31 *
32 * Quirk 3: The shortcut interrupts can't be (un)masked in bank 0
33 *
34 * Those interrupts that have shortcuts can only be masked/unmasked in
35 * their respective banks' enable/disable registers. Doing so in the bank 0
36 * enable/disable registers has no effect.
37 *
38 * The FIQ control register:
39 * Bits 0-6: IRQ (index in order of interrupts from banks 1, 2, then 0)
40 * Bit 7: Enable FIQ generation
41 * Bits 8+: Unused
42 *
43 * An interrupt must be disabled before configuring it for FIQ generation
44 * otherwise both handlers will fire at the same time!
45 */
46
47#include <linux/io.h>
48#include <linux/slab.h>
49#include <linux/of_address.h>
50#include <linux/of_irq.h>
51#include <linux/irqdomain.h>
52#include <linux/irqchip/bcm2835.h>
53
54#include <asm/exception.h>
55
56/* Put the bank and irq (32 bits) into the hwirq */
57#define MAKE_HWIRQ(b, n) ((b << 5) | (n))
58#define HWIRQ_BANK(i) (i >> 5)
59#define HWIRQ_BIT(i) BIT(i & 0x1f)
60
61#define NR_IRQS_BANK0 8
62#define BANK0_HWIRQ_MASK 0xff
63/* Shortcuts can't be disabled so any unknown new ones need to be masked */
64#define SHORTCUT1_MASK 0x00007c00
65#define SHORTCUT2_MASK 0x001f8000
66#define SHORTCUT_SHIFT 10
67#define BANK1_HWIRQ BIT(8)
68#define BANK2_HWIRQ BIT(9)
69#define BANK0_VALID_MASK (BANK0_HWIRQ_MASK | BANK1_HWIRQ | BANK2_HWIRQ \
70 | SHORTCUT1_MASK | SHORTCUT2_MASK)
71
72#define REG_FIQ_CONTROL 0x0c
73
74#define NR_BANKS 3
75#define IRQS_PER_BANK 32
76
77static int reg_pending[] __initconst = { 0x00, 0x04, 0x08 };
78static int reg_enable[] __initconst = { 0x18, 0x10, 0x14 };
79static int reg_disable[] __initconst = { 0x24, 0x1c, 0x20 };
80static int bank_irqs[] __initconst = { 8, 32, 32 };
81
82static const int shortcuts[] = {
83 7, 9, 10, 18, 19, /* Bank 1 */
84 21, 22, 23, 24, 25, 30 /* Bank 2 */
85};
86
87struct armctrl_ic {
88 void __iomem *base;
89 void __iomem *pending[NR_BANKS];
90 void __iomem *enable[NR_BANKS];
91 void __iomem *disable[NR_BANKS];
92 struct irq_domain *domain;
93};
94
95static struct armctrl_ic intc __read_mostly;
96
97static void armctrl_mask_irq(struct irq_data *d)
98{
99 writel_relaxed(HWIRQ_BIT(d->hwirq), intc.disable[HWIRQ_BANK(d->hwirq)]);
100}
101
102static void armctrl_unmask_irq(struct irq_data *d)
103{
104 writel_relaxed(HWIRQ_BIT(d->hwirq), intc.enable[HWIRQ_BANK(d->hwirq)]);
105}
106
107static struct irq_chip armctrl_chip = {
108 .name = "ARMCTRL-level",
109 .irq_mask = armctrl_mask_irq,
110 .irq_unmask = armctrl_unmask_irq
111};
112
113static int armctrl_xlate(struct irq_domain *d, struct device_node *ctrlr,
114 const u32 *intspec, unsigned int intsize,
115 unsigned long *out_hwirq, unsigned int *out_type)
116{
117 if (WARN_ON(intsize != 2))
118 return -EINVAL;
119
120 if (WARN_ON(intspec[0] >= NR_BANKS))
121 return -EINVAL;
122
123 if (WARN_ON(intspec[1] >= IRQS_PER_BANK))
124 return -EINVAL;
125
126 if (WARN_ON(intspec[0] == 0 && intspec[1] >= NR_IRQS_BANK0))
127 return -EINVAL;
128
129 *out_hwirq = MAKE_HWIRQ(intspec[0], intspec[1]);
130 *out_type = IRQ_TYPE_NONE;
131 return 0;
132}
133
134static struct irq_domain_ops armctrl_ops = {
135 .xlate = armctrl_xlate
136};
137
138static int __init armctrl_of_init(struct device_node *node,
139 struct device_node *parent)
140{
141 void __iomem *base;
142 int irq, b, i;
143
144 base = of_iomap(node, 0);
145 if (!base)
146 panic("%s: unable to map IC registers\n",
147 node->full_name);
148
149 intc.domain = irq_domain_add_linear(node, MAKE_HWIRQ(NR_BANKS, 0),
150 &armctrl_ops, NULL);
151 if (!intc.domain)
152 panic("%s: unable to create IRQ domain\n", node->full_name);
153
154 for (b = 0; b < NR_BANKS; b++) {
155 intc.pending[b] = base + reg_pending[b];
156 intc.enable[b] = base + reg_enable[b];
157 intc.disable[b] = base + reg_disable[b];
158
159 for (i = 0; i < bank_irqs[b]; i++) {
160 irq = irq_create_mapping(intc.domain, MAKE_HWIRQ(b, i));
161 BUG_ON(irq <= 0);
162 irq_set_chip_and_handler(irq, &armctrl_chip,
163 handle_level_irq);
164 set_irq_flags(irq, IRQF_VALID | IRQF_PROBE);
165 }
166 }
167 return 0;
168}
169
170static struct of_device_id irq_of_match[] __initconst = {
171 { .compatible = "brcm,bcm2835-armctrl-ic", .data = armctrl_of_init }
172};
173
174void __init bcm2835_init_irq(void)
175{
176 of_irq_init(irq_of_match);
177}
178
179/*
180 * Handle each interrupt across the entire interrupt controller. This reads the
181 * status register before handling each interrupt, which is necessary given that
182 * handle_IRQ may briefly re-enable interrupts for soft IRQ handling.
183 */
184
185static void armctrl_handle_bank(int bank, struct pt_regs *regs)
186{
187 u32 stat, irq;
188
189 while ((stat = readl_relaxed(intc.pending[bank]))) {
190 irq = MAKE_HWIRQ(bank, ffs(stat) - 1);
191 handle_IRQ(irq_linear_revmap(intc.domain, irq), regs);
192 }
193}
194
195static void armctrl_handle_shortcut(int bank, struct pt_regs *regs,
196 u32 stat)
197{
198 u32 irq = MAKE_HWIRQ(bank, shortcuts[ffs(stat >> SHORTCUT_SHIFT) - 1]);
199 handle_IRQ(irq_linear_revmap(intc.domain, irq), regs);
200}
201
202asmlinkage void __exception_irq_entry bcm2835_handle_irq(
203 struct pt_regs *regs)
204{
205 u32 stat, irq;
206
207 while ((stat = readl_relaxed(intc.pending[0]) & BANK0_VALID_MASK)) {
208 if (stat & BANK0_HWIRQ_MASK) {
209 irq = MAKE_HWIRQ(0, ffs(stat & BANK0_HWIRQ_MASK) - 1);
210 handle_IRQ(irq_linear_revmap(intc.domain, irq), regs);
211 } else if (stat & SHORTCUT1_MASK) {
212 armctrl_handle_shortcut(1, regs, stat & SHORTCUT1_MASK);
213 } else if (stat & SHORTCUT2_MASK) {
214 armctrl_handle_shortcut(2, regs, stat & SHORTCUT2_MASK);
215 } else if (stat & BANK1_HWIRQ) {
216 armctrl_handle_bank(1, regs);
217 } else if (stat & BANK2_HWIRQ) {
218 armctrl_handle_bank(2, regs);
219 } else {
220 BUG();
221 }
222 }
223}
diff --git a/include/linux/irqchip/bcm2835.h b/include/linux/irqchip/bcm2835.h
new file mode 100644
index 000000000000..48a859bc9dca
--- /dev/null
+++ b/include/linux/irqchip/bcm2835.h
@@ -0,0 +1,29 @@
1/*
2 * Copyright (C) 2010 Broadcom
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19#ifndef __LINUX_IRQCHIP_BCM2835_H_
20#define __LINUX_IRQCHIP_BCM2835_H_
21
22#include <asm/exception.h>
23
24extern void bcm2835_init_irq(void);
25
26extern asmlinkage void __exception_irq_entry bcm2835_handle_irq(
27 struct pt_regs *regs);
28
29#endif