blob: 2dfff1f19004326c06ec366033418e8152f76309 [file] [log] [blame]
Gabor Juhosd4a67d92011-01-04 21:28:14 +01001/*
2 * Atheros AR71xx/AR724x/AR913x specific interrupt handling
3 *
Gabor Juhosfce5cc62012-03-14 10:45:25 +01004 * Copyright (C) 2010-2011 Jaiganesh Narayanan <jnarayanan@atheros.com>
Gabor Juhos4dbcbdf2012-03-14 10:45:24 +01005 * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org>
Gabor Juhosd4a67d92011-01-04 21:28:14 +01006 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
7 *
Gabor Juhosfce5cc62012-03-14 10:45:25 +01008 * Parts of this file are based on Atheros' 2.6.15/2.6.31 BSP
Gabor Juhosd4a67d92011-01-04 21:28:14 +01009 *
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published
12 * by the Free Software Foundation.
13 */
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/interrupt.h>
Alban Bedelb29e8b82015-05-31 01:52:29 +020018#include <linux/irqchip.h>
19#include <linux/of_irq.h>
Gabor Juhosd4a67d92011-01-04 21:28:14 +010020
21#include <asm/irq_cpu.h>
22#include <asm/mipsregs.h>
23
24#include <asm/mach-ath79/ath79.h>
25#include <asm/mach-ath79/ar71xx_regs.h>
26#include "common.h"
Alban Bedelb29e8b82015-05-31 01:52:29 +020027#include "machtypes.h"
Gabor Juhosd4a67d92011-01-04 21:28:14 +010028
Gabor Juhosd4a67d92011-01-04 21:28:14 +010029
Thomas Gleixnerbd0b9ac2015-09-14 10:42:37 +020030static void ar934x_ip2_irq_dispatch(struct irq_desc *desc)
Gabor Juhosfce5cc62012-03-14 10:45:25 +010031{
32 u32 status;
33
Gabor Juhosfce5cc62012-03-14 10:45:25 +010034 status = ath79_reset_rr(AR934X_RESET_REG_PCIE_WMAC_INT_STATUS);
35
36 if (status & AR934X_PCIE_WMAC_INT_PCIE_ALL) {
Alban Bedel24b0e3e2015-04-19 14:30:03 +020037 ath79_ddr_wb_flush(3);
Gabor Juhosfce5cc62012-03-14 10:45:25 +010038 generic_handle_irq(ATH79_IP2_IRQ(0));
39 } else if (status & AR934X_PCIE_WMAC_INT_WMAC_ALL) {
Alban Bedel24b0e3e2015-04-19 14:30:03 +020040 ath79_ddr_wb_flush(4);
Gabor Juhosfce5cc62012-03-14 10:45:25 +010041 generic_handle_irq(ATH79_IP2_IRQ(1));
42 } else {
43 spurious_interrupt();
44 }
Gabor Juhosfce5cc62012-03-14 10:45:25 +010045}
46
47static void ar934x_ip2_irq_init(void)
48{
49 int i;
50
51 for (i = ATH79_IP2_IRQ_BASE;
52 i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
53 irq_set_chip_and_handler(i, &dummy_irq_chip,
54 handle_level_irq);
55
Gabor Juhos7e69c102013-02-07 19:32:23 +000056 irq_set_chained_handler(ATH79_CPU_IRQ(2), ar934x_ip2_irq_dispatch);
Gabor Juhosfce5cc62012-03-14 10:45:25 +010057}
58
Thomas Gleixnerbd0b9ac2015-09-14 10:42:37 +020059static void qca955x_ip2_irq_dispatch(struct irq_desc *desc)
Gabor Juhos53330332013-02-15 18:53:47 +000060{
61 u32 status;
62
Gabor Juhos53330332013-02-15 18:53:47 +000063 status = ath79_reset_rr(QCA955X_RESET_REG_EXT_INT_STATUS);
64 status &= QCA955X_EXT_INT_PCIE_RC1_ALL | QCA955X_EXT_INT_WMAC_ALL;
65
66 if (status == 0) {
67 spurious_interrupt();
Thomas Gleixner9d9a2fa2015-07-13 20:46:06 +000068 return;
Gabor Juhos53330332013-02-15 18:53:47 +000069 }
70
71 if (status & QCA955X_EXT_INT_PCIE_RC1_ALL) {
72 /* TODO: flush DDR? */
73 generic_handle_irq(ATH79_IP2_IRQ(0));
74 }
75
76 if (status & QCA955X_EXT_INT_WMAC_ALL) {
77 /* TODO: flush DDR? */
78 generic_handle_irq(ATH79_IP2_IRQ(1));
79 }
Gabor Juhos53330332013-02-15 18:53:47 +000080}
81
Thomas Gleixnerbd0b9ac2015-09-14 10:42:37 +020082static void qca955x_ip3_irq_dispatch(struct irq_desc *desc)
Gabor Juhos53330332013-02-15 18:53:47 +000083{
84 u32 status;
85
Gabor Juhos53330332013-02-15 18:53:47 +000086 status = ath79_reset_rr(QCA955X_RESET_REG_EXT_INT_STATUS);
87 status &= QCA955X_EXT_INT_PCIE_RC2_ALL |
88 QCA955X_EXT_INT_USB1 |
89 QCA955X_EXT_INT_USB2;
90
91 if (status == 0) {
92 spurious_interrupt();
Thomas Gleixner9d9a2fa2015-07-13 20:46:06 +000093 return;
Gabor Juhos53330332013-02-15 18:53:47 +000094 }
95
96 if (status & QCA955X_EXT_INT_USB1) {
97 /* TODO: flush DDR? */
98 generic_handle_irq(ATH79_IP3_IRQ(0));
99 }
100
101 if (status & QCA955X_EXT_INT_USB2) {
102 /* TODO: flush DDR? */
103 generic_handle_irq(ATH79_IP3_IRQ(1));
104 }
105
106 if (status & QCA955X_EXT_INT_PCIE_RC2_ALL) {
107 /* TODO: flush DDR? */
108 generic_handle_irq(ATH79_IP3_IRQ(2));
109 }
Gabor Juhos53330332013-02-15 18:53:47 +0000110}
111
112static void qca955x_irq_init(void)
113{
114 int i;
115
116 for (i = ATH79_IP2_IRQ_BASE;
117 i < ATH79_IP2_IRQ_BASE + ATH79_IP2_IRQ_COUNT; i++)
118 irq_set_chip_and_handler(i, &dummy_irq_chip,
119 handle_level_irq);
120
121 irq_set_chained_handler(ATH79_CPU_IRQ(2), qca955x_ip2_irq_dispatch);
122
123 for (i = ATH79_IP3_IRQ_BASE;
124 i < ATH79_IP3_IRQ_BASE + ATH79_IP3_IRQ_COUNT; i++)
125 irq_set_chip_and_handler(i, &dummy_irq_chip,
126 handle_level_irq);
127
128 irq_set_chained_handler(ATH79_CPU_IRQ(3), qca955x_ip3_irq_dispatch);
129}
130
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100131void __init arch_init_irq(void)
132{
Alban Bedel81ffb182016-01-23 13:57:47 +0100133 unsigned irq_wb_chan2 = -1;
134 unsigned irq_wb_chan3 = -1;
Alban Bedel07ba4b02016-01-23 13:57:46 +0100135 bool misc_is_ar71xx;
136
Alban Bedelb29e8b82015-05-31 01:52:29 +0200137 if (mips_machtype == ATH79_MACH_GENERIC_OF) {
138 irqchip_init();
139 return;
140 }
141
Alban Bedel24b0e3e2015-04-19 14:30:03 +0200142 if (soc_is_ar71xx() || soc_is_ar724x() ||
143 soc_is_ar913x() || soc_is_ar933x()) {
Alban Bedel81ffb182016-01-23 13:57:47 +0100144 irq_wb_chan2 = 3;
145 irq_wb_chan3 = 2;
Gabor Juhosfce5cc62012-03-14 10:45:25 +0100146 } else if (soc_is_ar934x()) {
Alban Bedel81ffb182016-01-23 13:57:47 +0100147 irq_wb_chan3 = 2;
Gabor Juhos4dbcbdf2012-03-14 10:45:24 +0100148 }
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100149
Alban Bedel81ffb182016-01-23 13:57:47 +0100150 ath79_cpu_irq_init(irq_wb_chan2, irq_wb_chan3);
Alban Bedel07ba4b02016-01-23 13:57:46 +0100151
152 if (soc_is_ar71xx() || soc_is_ar913x())
153 misc_is_ar71xx = true;
154 else if (soc_is_ar724x() ||
155 soc_is_ar933x() ||
156 soc_is_ar934x() ||
157 soc_is_qca955x())
158 misc_is_ar71xx = false;
159 else
160 BUG();
161 ath79_misc_irq_init(
162 ath79_reset_base + AR71XX_RESET_REG_MISC_INT_STATUS,
163 ATH79_CPU_IRQ(6), ATH79_MISC_IRQ_BASE, misc_is_ar71xx);
Gabor Juhosfce5cc62012-03-14 10:45:25 +0100164
165 if (soc_is_ar934x())
166 ar934x_ip2_irq_init();
Gabor Juhos53330332013-02-15 18:53:47 +0000167 else if (soc_is_qca955x())
168 qca955x_irq_init();
Gabor Juhosd4a67d92011-01-04 21:28:14 +0100169}