1 From f1c0239d61d6d43469133d144e458f485b6cbda6 Mon Sep 17 00:00:00 2001
2 From: Gabor Juhos <juhosg@openwrt.org>
3 Date: Fri, 15 Feb 2013 18:53:47 +0000
4 Subject: [PATCH] MIPS: ath79: add IRQ handling code for the QCA955X SoCs
6 commit 53330332f176eaa9567481c69bbad8b2176b4eb5 upstream.
8 The IRQ routing in the QCA955x SoCs is slightly
9 different from the routing implemented in the
10 already supported SoCs.
12 Cc: Rodriguez, Luis <rodrigue@qca.qualcomm.com>
13 Cc: Giori, Kathy <kgiori@qca.qualcomm.com>
14 Cc: QCA Linux Team <qca-linux-team@qca.qualcomm.com>
15 Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
16 Patchwork: http://patchwork.linux-mips.org/patch/4955/
17 Signed-off-by: John Crispin <blogic@openwrt.org>
19 arch/mips/ath79/irq.c | 110 ++++++++++++++++++++++--
20 arch/mips/include/asm/mach-ath79/ar71xx_regs.h | 32 +++++++
21 arch/mips/include/asm/mach-ath79/irq.h | 6 +-
22 3 files changed, 140 insertions(+), 8 deletions(-)
24 --- a/arch/mips/ath79/irq.c
25 +++ b/arch/mips/ath79/irq.c
26 @@ -103,7 +103,10 @@ static void __init ath79_misc_irq_init(v
28 if (soc_is_ar71xx() || soc_is_ar913x())
29 ath79_misc_irq_chip.irq_mask_ack = ar71xx_misc_irq_mask;
30 - else if (soc_is_ar724x() || soc_is_ar933x() || soc_is_ar934x())
31 + else if (soc_is_ar724x() ||
35 ath79_misc_irq_chip.irq_ack = ar724x_misc_irq_ack;
38 @@ -150,6 +153,88 @@ static void ar934x_ip2_irq_init(void)
39 irq_set_chained_handler(ATH79_CPU_IRQ(2), ar934x_ip2_irq_dispatch);
42 +static void qca955x_ip2_irq_dispatch(unsigned int irq, struct irq_desc *desc)
46 + disable_irq_nosync(irq);
48 + status = ath79_reset_rr(QCA955X_RESET_REG_EXT_INT_STATUS);
49 + status &= QCA955X_EXT_INT_PCIE_RC1_ALL | QCA955X_EXT_INT_WMAC_ALL;
52 + spurious_interrupt();
56 + if (status & QCA955X_EXT_INT_PCIE_RC1_ALL) {
57 + /* TODO: flush DDR? */
58 + generic_handle_irq(ATH79_IP2_IRQ(0));
61 + if (status & QCA955X_EXT_INT_WMAC_ALL) {
62 + /* TODO: flush DDR? */
63 + generic_handle_irq(ATH79_IP2_IRQ(1));
70 +static void qca955x_ip3_irq_dispatch(unsigned int irq, struct irq_desc *desc)
74 + disable_irq_nosync(irq);
76 + status = ath79_reset_rr(QCA955X_RESET_REG_EXT_INT_STATUS);
77 + status &= QCA955X_EXT_INT_PCIE_RC2_ALL |
78 + QCA955X_EXT_INT_USB1 |
79 + QCA955X_EXT_INT_USB2;
82 + spurious_interrupt();
86 + if (status & QCA955X_EXT_INT_USB1) {
87 + /* TODO: flush DDR? */
88 + generic_handle_irq(ATH79_IP3_IRQ(0));
91 + if (status & QCA955X_EXT_INT_USB2) {
92 + /* TODO: flush DDR? */
93 + generic_handle_irq(ATH79_IP3_IRQ(1));
96 + if (status & QCA955X_EXT_INT_PCIE_RC2_ALL) {
97 + /* TODO: flush DDR? */
98 + generic_handle_irq(ATH79_IP3_IRQ(2));
105 +static void qca955x_irq_init(void)
109 + for (i = ATH79_IP2_IRQ_BASE;
110 + i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
111 + irq_set_chip_and_handler(i, &dummy_irq_chip,
114 + irq_set_chained_handler(ATH79_CPU_IRQ(2), qca955x_ip2_irq_dispatch);
116 + for (i = ATH79_IP3_IRQ_BASE;
117 + i < ATH79_IP3_IRQ_BASE + ATH79_IP3_IRQ_COUNT; i++)
118 + irq_set_chip_and_handler(i, &dummy_irq_chip,
121 + irq_set_chained_handler(ATH79_CPU_IRQ(3), qca955x_ip3_irq_dispatch);
124 asmlinkage void plat_irq_dispatch(void)
126 unsigned long pending;
127 @@ -185,6 +270,17 @@ asmlinkage void plat_irq_dispatch(void)
128 * Issue a flush in the handlers to ensure that the driver sees
132 +static void ath79_default_ip2_handler(void)
134 + do_IRQ(ATH79_CPU_IRQ(2));
137 +static void ath79_default_ip3_handler(void)
139 + do_IRQ(ATH79_CPU_IRQ(3));
142 static void ar71xx_ip2_handler(void)
144 ath79_ddr_wb_flush(AR71XX_DDR_REG_FLUSH_PCI);
145 @@ -209,11 +305,6 @@ static void ar933x_ip2_handler(void)
146 do_IRQ(ATH79_CPU_IRQ(2));
149 -static void ar934x_ip2_handler(void)
151 - do_IRQ(ATH79_CPU_IRQ(2));
154 static void ar71xx_ip3_handler(void)
156 ath79_ddr_wb_flush(AR71XX_DDR_REG_FLUSH_USB);
157 @@ -259,8 +350,11 @@ void __init arch_init_irq(void)
158 ath79_ip2_handler = ar933x_ip2_handler;
159 ath79_ip3_handler = ar933x_ip3_handler;
160 } else if (soc_is_ar934x()) {
161 - ath79_ip2_handler = ar934x_ip2_handler;
162 + ath79_ip2_handler = ath79_default_ip2_handler;
163 ath79_ip3_handler = ar934x_ip3_handler;
164 + } else if (soc_is_qca955x()) {
165 + ath79_ip2_handler = ath79_default_ip2_handler;
166 + ath79_ip3_handler = ath79_default_ip3_handler;
170 @@ -271,4 +365,6 @@ void __init arch_init_irq(void)
173 ar934x_ip2_irq_init();
174 + else if (soc_is_qca955x())
175 + qca955x_irq_init();
177 --- a/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
178 +++ b/arch/mips/include/asm/mach-ath79/ar71xx_regs.h
180 #define AR934X_RESET_REG_PCIE_WMAC_INT_STATUS 0xac
182 #define QCA955X_RESET_REG_BOOTSTRAP 0xb0
183 +#define QCA955X_RESET_REG_EXT_INT_STATUS 0xac
185 #define MISC_INT_ETHSW BIT(12)
186 #define MISC_INT_TIMER4 BIT(10)
188 AR934X_PCIE_WMAC_INT_PCIE_RC1 | AR934X_PCIE_WMAC_INT_PCIE_RC2 | \
189 AR934X_PCIE_WMAC_INT_PCIE_RC3)
191 +#define QCA955X_EXT_INT_WMAC_MISC BIT(0)
192 +#define QCA955X_EXT_INT_WMAC_TX BIT(1)
193 +#define QCA955X_EXT_INT_WMAC_RXLP BIT(2)
194 +#define QCA955X_EXT_INT_WMAC_RXHP BIT(3)
195 +#define QCA955X_EXT_INT_PCIE_RC1 BIT(4)
196 +#define QCA955X_EXT_INT_PCIE_RC1_INT0 BIT(5)
197 +#define QCA955X_EXT_INT_PCIE_RC1_INT1 BIT(6)
198 +#define QCA955X_EXT_INT_PCIE_RC1_INT2 BIT(7)
199 +#define QCA955X_EXT_INT_PCIE_RC1_INT3 BIT(8)
200 +#define QCA955X_EXT_INT_PCIE_RC2 BIT(12)
201 +#define QCA955X_EXT_INT_PCIE_RC2_INT0 BIT(13)
202 +#define QCA955X_EXT_INT_PCIE_RC2_INT1 BIT(14)
203 +#define QCA955X_EXT_INT_PCIE_RC2_INT2 BIT(15)
204 +#define QCA955X_EXT_INT_PCIE_RC2_INT3 BIT(16)
205 +#define QCA955X_EXT_INT_USB1 BIT(24)
206 +#define QCA955X_EXT_INT_USB2 BIT(28)
208 +#define QCA955X_EXT_INT_WMAC_ALL \
209 + (QCA955X_EXT_INT_WMAC_MISC | QCA955X_EXT_INT_WMAC_TX | \
210 + QCA955X_EXT_INT_WMAC_RXLP | QCA955X_EXT_INT_WMAC_RXHP)
212 +#define QCA955X_EXT_INT_PCIE_RC1_ALL \
213 + (QCA955X_EXT_INT_PCIE_RC1 | QCA955X_EXT_INT_PCIE_RC1_INT0 | \
214 + QCA955X_EXT_INT_PCIE_RC1_INT1 | QCA955X_EXT_INT_PCIE_RC1_INT2 | \
215 + QCA955X_EXT_INT_PCIE_RC1_INT3)
217 +#define QCA955X_EXT_INT_PCIE_RC2_ALL \
218 + (QCA955X_EXT_INT_PCIE_RC2 | QCA955X_EXT_INT_PCIE_RC2_INT0 | \
219 + QCA955X_EXT_INT_PCIE_RC2_INT1 | QCA955X_EXT_INT_PCIE_RC2_INT2 | \
220 + QCA955X_EXT_INT_PCIE_RC2_INT3)
222 #define REV_ID_MAJOR_MASK 0xfff0
223 #define REV_ID_MAJOR_AR71XX 0x00a0
224 #define REV_ID_MAJOR_AR913X 0x00b0
225 --- a/arch/mips/include/asm/mach-ath79/irq.h
226 +++ b/arch/mips/include/asm/mach-ath79/irq.h
228 #define __ASM_MACH_ATH79_IRQ_H
230 #define MIPS_CPU_IRQ_BASE 0
234 #define ATH79_CPU_IRQ(_x) (MIPS_CPU_IRQ_BASE + (_x))
237 #define ATH79_IP2_IRQ_COUNT 2
238 #define ATH79_IP2_IRQ(_x) (ATH79_IP2_IRQ_BASE + (_x))
240 +#define ATH79_IP3_IRQ_BASE (ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT)
241 +#define ATH79_IP3_IRQ_COUNT 3
242 +#define ATH79_IP3_IRQ(_x) (ATH79_IP3_IRQ_BASE + (_x))
244 #include_next <irq.h>
246 #endif /* __ASM_MACH_ATH79_IRQ_H */