| 1 | /* |
| 2 | * Ralink RT3662/RT3883 SoC specific interrupt handling |
| 3 | * |
| 4 | * Copyright (C) 2011-2012 Gabor Juhos <juhosg@openwrt.org> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License version 2 as published |
| 8 | * by the Free Software Foundation. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/interrupt.h> |
| 14 | #include <linux/irq.h> |
| 15 | |
| 16 | #include <asm/irq_cpu.h> |
| 17 | #include <asm/mipsregs.h> |
| 18 | |
| 19 | #include <asm/mach-ralink/common.h> |
| 20 | #include <asm/mach-ralink/rt3883.h> |
| 21 | #include <asm/mach-ralink/rt3883_regs.h> |
| 22 | |
| 23 | static void rt3883_intc_irq_dispatch(void) |
| 24 | { |
| 25 | u32 pending; |
| 26 | |
| 27 | pending = ramips_intc_get_status(); |
| 28 | |
| 29 | if (pending & RT3883_INTC_INT_TIMER0) |
| 30 | do_IRQ(RT3883_INTC_IRQ_TIMER0); |
| 31 | |
| 32 | else if (pending & RT3883_INTC_INT_TIMER1) |
| 33 | do_IRQ(RT3883_INTC_IRQ_TIMER1); |
| 34 | |
| 35 | else if (pending & RT3883_INTC_INT_UART0) |
| 36 | do_IRQ(RT3883_INTC_IRQ_UART0); |
| 37 | |
| 38 | else if (pending & RT3883_INTC_INT_UART1) |
| 39 | do_IRQ(RT3883_INTC_IRQ_UART1); |
| 40 | |
| 41 | else if (pending & RT3883_INTC_INT_PERFC) |
| 42 | do_IRQ(RT3883_INTC_IRQ_PERFC); |
| 43 | |
| 44 | else if (pending & RT3883_INTC_INT_UHST) |
| 45 | do_IRQ(RT3883_INTC_IRQ_UHST); |
| 46 | |
| 47 | /* TODO: handle PIO interrupts as well */ |
| 48 | |
| 49 | else |
| 50 | spurious_interrupt(); |
| 51 | } |
| 52 | |
| 53 | asmlinkage void plat_irq_dispatch(void) |
| 54 | { |
| 55 | unsigned long pending; |
| 56 | |
| 57 | pending = read_c0_status() & read_c0_cause() & ST0_IM; |
| 58 | |
| 59 | if (pending & STATUSF_IP7) |
| 60 | do_IRQ(RT3883_CPU_IRQ_COUNTER); |
| 61 | |
| 62 | else if (pending & STATUSF_IP5) |
| 63 | do_IRQ(RT3883_CPU_IRQ_FE); |
| 64 | |
| 65 | else if (pending & STATUSF_IP6) |
| 66 | do_IRQ(RT3883_CPU_IRQ_WLAN); |
| 67 | |
| 68 | else if (pending & STATUSF_IP4) |
| 69 | do_IRQ(RT3883_CPU_IRQ_PCI); |
| 70 | |
| 71 | else if (pending & STATUSF_IP2) |
| 72 | rt3883_intc_irq_dispatch(); |
| 73 | |
| 74 | else |
| 75 | spurious_interrupt(); |
| 76 | } |
| 77 | |
| 78 | void __init arch_init_irq(void) |
| 79 | { |
| 80 | mips_cpu_irq_init(); |
| 81 | ramips_intc_irq_init(RT3883_INTC_BASE, RT3883_CPU_IRQ_INTC, |
| 82 | RT3883_INTC_IRQ_BASE); |
| 83 | cp0_perfcount_irq = RT3883_INTC_IRQ_PERFC; |
| 84 | } |
| 85 | |