|
24 | 24 | #include <asm/mach-ath79/ar71xx_regs.h>
|
25 | 25 | #include "common.h"
|
26 | 26 |
|
27 |
| -static void (*ath79_ip2_handler)(void); |
28 |
| -static void (*ath79_ip3_handler)(void); |
29 |
| - |
30 | 27 | static void ath79_misc_irq_handler(unsigned int irq, struct irq_desc *desc)
|
31 | 28 | {
|
32 | 29 | void __iomem *base = ath79_reset_base;
|
@@ -129,10 +126,10 @@ static void ar934x_ip2_irq_dispatch(unsigned int irq, struct irq_desc *desc)
|
129 | 126 | status = ath79_reset_rr(AR934X_RESET_REG_PCIE_WMAC_INT_STATUS);
|
130 | 127 |
|
131 | 128 | if (status & AR934X_PCIE_WMAC_INT_PCIE_ALL) {
|
132 |
| - ath79_ddr_wb_flush(AR934X_DDR_REG_FLUSH_PCIE); |
| 129 | + ath79_ddr_wb_flush(3); |
133 | 130 | generic_handle_irq(ATH79_IP2_IRQ(0));
|
134 | 131 | } else if (status & AR934X_PCIE_WMAC_INT_WMAC_ALL) {
|
135 |
| - ath79_ddr_wb_flush(AR934X_DDR_REG_FLUSH_WMAC); |
| 132 | + ath79_ddr_wb_flush(4); |
136 | 133 | generic_handle_irq(ATH79_IP2_IRQ(1));
|
137 | 134 | } else {
|
138 | 135 | spurious_interrupt();
|
@@ -235,128 +232,50 @@ static void qca955x_irq_init(void)
|
235 | 232 | irq_set_chained_handler(ATH79_CPU_IRQ(3), qca955x_ip3_irq_dispatch);
|
236 | 233 | }
|
237 | 234 |
|
238 |
| -asmlinkage void plat_irq_dispatch(void) |
239 |
| -{ |
240 |
| - unsigned long pending; |
241 |
| - |
242 |
| - pending = read_c0_status() & read_c0_cause() & ST0_IM; |
243 |
| - |
244 |
| - if (pending & STATUSF_IP7) |
245 |
| - do_IRQ(ATH79_CPU_IRQ(7)); |
246 |
| - |
247 |
| - else if (pending & STATUSF_IP2) |
248 |
| - ath79_ip2_handler(); |
249 |
| - |
250 |
| - else if (pending & STATUSF_IP4) |
251 |
| - do_IRQ(ATH79_CPU_IRQ(4)); |
252 |
| - |
253 |
| - else if (pending & STATUSF_IP5) |
254 |
| - do_IRQ(ATH79_CPU_IRQ(5)); |
255 |
| - |
256 |
| - else if (pending & STATUSF_IP3) |
257 |
| - ath79_ip3_handler(); |
258 |
| - |
259 |
| - else if (pending & STATUSF_IP6) |
260 |
| - do_IRQ(ATH79_CPU_IRQ(6)); |
261 |
| - |
262 |
| - else |
263 |
| - spurious_interrupt(); |
264 |
| -} |
265 |
| - |
266 | 235 | /*
|
267 | 236 | * The IP2/IP3 lines are tied to a PCI/WMAC/USB device. Drivers for
|
268 | 237 | * these devices typically allocate coherent DMA memory, however the
|
269 | 238 | * DMA controller may still have some unsynchronized data in the FIFO.
|
270 | 239 | * Issue a flush in the handlers to ensure that the driver sees
|
271 | 240 | * the update.
|
| 241 | + * |
| 242 | + * This array map the interrupt lines to the DDR write buffer channels. |
272 | 243 | */
|
273 | 244 |
|
274 |
| -static void ath79_default_ip2_handler(void) |
275 |
| -{ |
276 |
| - do_IRQ(ATH79_CPU_IRQ(2)); |
277 |
| -} |
278 |
| - |
279 |
| -static void ath79_default_ip3_handler(void) |
280 |
| -{ |
281 |
| - do_IRQ(ATH79_CPU_IRQ(3)); |
282 |
| -} |
283 |
| - |
284 |
| -static void ar71xx_ip2_handler(void) |
285 |
| -{ |
286 |
| - ath79_ddr_wb_flush(AR71XX_DDR_REG_FLUSH_PCI); |
287 |
| - do_IRQ(ATH79_CPU_IRQ(2)); |
288 |
| -} |
289 |
| - |
290 |
| -static void ar724x_ip2_handler(void) |
291 |
| -{ |
292 |
| - ath79_ddr_wb_flush(AR724X_DDR_REG_FLUSH_PCIE); |
293 |
| - do_IRQ(ATH79_CPU_IRQ(2)); |
294 |
| -} |
295 |
| - |
296 |
| -static void ar913x_ip2_handler(void) |
297 |
| -{ |
298 |
| - ath79_ddr_wb_flush(AR913X_DDR_REG_FLUSH_WMAC); |
299 |
| - do_IRQ(ATH79_CPU_IRQ(2)); |
300 |
| -} |
301 |
| - |
302 |
| -static void ar933x_ip2_handler(void) |
303 |
| -{ |
304 |
| - ath79_ddr_wb_flush(AR933X_DDR_REG_FLUSH_WMAC); |
305 |
| - do_IRQ(ATH79_CPU_IRQ(2)); |
306 |
| -} |
307 |
| - |
308 |
| -static void ar71xx_ip3_handler(void) |
309 |
| -{ |
310 |
| - ath79_ddr_wb_flush(AR71XX_DDR_REG_FLUSH_USB); |
311 |
| - do_IRQ(ATH79_CPU_IRQ(3)); |
312 |
| -} |
| 245 | +static unsigned irq_wb_chan[8] = { |
| 246 | + -1, -1, -1, -1, -1, -1, -1, -1, |
| 247 | +}; |
313 | 248 |
|
314 |
| -static void ar724x_ip3_handler(void) |
| 249 | +asmlinkage void plat_irq_dispatch(void) |
315 | 250 | {
|
316 |
| - ath79_ddr_wb_flush(AR724X_DDR_REG_FLUSH_USB); |
317 |
| - do_IRQ(ATH79_CPU_IRQ(3)); |
318 |
| -} |
| 251 | + unsigned long pending; |
| 252 | + int irq; |
319 | 253 |
|
320 |
| -static void ar913x_ip3_handler(void) |
321 |
| -{ |
322 |
| - ath79_ddr_wb_flush(AR913X_DDR_REG_FLUSH_USB); |
323 |
| - do_IRQ(ATH79_CPU_IRQ(3)); |
324 |
| -} |
| 254 | + pending = read_c0_status() & read_c0_cause() & ST0_IM; |
325 | 255 |
|
326 |
| -static void ar933x_ip3_handler(void) |
327 |
| -{ |
328 |
| - ath79_ddr_wb_flush(AR933X_DDR_REG_FLUSH_USB); |
329 |
| - do_IRQ(ATH79_CPU_IRQ(3)); |
330 |
| -} |
| 256 | + if (!pending) { |
| 257 | + spurious_interrupt(); |
| 258 | + return; |
| 259 | + } |
331 | 260 |
|
332 |
| -static void ar934x_ip3_handler(void) |
333 |
| -{ |
334 |
| - ath79_ddr_wb_flush(AR934X_DDR_REG_FLUSH_USB); |
335 |
| - do_IRQ(ATH79_CPU_IRQ(3)); |
| 261 | + pending >>= CAUSEB_IP; |
| 262 | + while (pending) { |
| 263 | + irq = fls(pending) - 1; |
| 264 | + if (irq < ARRAY_SIZE(irq_wb_chan) && irq_wb_chan[irq] != -1) |
| 265 | + ath79_ddr_wb_flush(irq_wb_chan[irq]); |
| 266 | + do_IRQ(MIPS_CPU_IRQ_BASE + irq); |
| 267 | + pending &= ~BIT(irq); |
| 268 | + } |
336 | 269 | }
|
337 | 270 |
|
338 | 271 | void __init arch_init_irq(void)
|
339 | 272 | {
|
340 |
| - if (soc_is_ar71xx()) { |
341 |
| - ath79_ip2_handler = ar71xx_ip2_handler; |
342 |
| - ath79_ip3_handler = ar71xx_ip3_handler; |
343 |
| - } else if (soc_is_ar724x()) { |
344 |
| - ath79_ip2_handler = ar724x_ip2_handler; |
345 |
| - ath79_ip3_handler = ar724x_ip3_handler; |
346 |
| - } else if (soc_is_ar913x()) { |
347 |
| - ath79_ip2_handler = ar913x_ip2_handler; |
348 |
| - ath79_ip3_handler = ar913x_ip3_handler; |
349 |
| - } else if (soc_is_ar933x()) { |
350 |
| - ath79_ip2_handler = ar933x_ip2_handler; |
351 |
| - ath79_ip3_handler = ar933x_ip3_handler; |
| 273 | + if (soc_is_ar71xx() || soc_is_ar724x() || |
| 274 | + soc_is_ar913x() || soc_is_ar933x()) { |
| 275 | + irq_wb_chan[2] = 3; |
| 276 | + irq_wb_chan[3] = 2; |
352 | 277 | } else if (soc_is_ar934x()) {
|
353 |
| - ath79_ip2_handler = ath79_default_ip2_handler; |
354 |
| - ath79_ip3_handler = ar934x_ip3_handler; |
355 |
| - } else if (soc_is_qca955x()) { |
356 |
| - ath79_ip2_handler = ath79_default_ip2_handler; |
357 |
| - ath79_ip3_handler = ath79_default_ip3_handler; |
358 |
| - } else { |
359 |
| - BUG(); |
| 278 | + irq_wb_chan[3] = 2; |
360 | 279 | }
|
361 | 280 |
|
362 | 281 | mips_cpu_irq_init();
|
|
0 commit comments