2 * Ralink RT288x SoC specific interrupt handling
4 * Copyright (C) 2008-2009 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/interrupt.h>
15 #include <linux/irq.h>
17 #include <asm/irq_cpu.h>
18 #include <asm/mipsregs.h>
20 #include <asm/mach-ralink/rt288x.h>
21 #include <asm/mach-ralink/rt288x_regs.h>
23 static void rt288x_intc_irq_dispatch(void)
27 pending
= rt288x_intc_rr(INTC_REG_STATUS0
);
29 if (pending
& RT2880_INTC_INT_TIMER0
)
30 do_IRQ(RT2880_INTC_IRQ_TIMER0
);
32 else if (pending
& RT2880_INTC_INT_TIMER1
)
33 do_IRQ(RT2880_INTC_IRQ_TIMER1
);
35 else if (pending
& RT2880_INTC_INT_UART0
)
36 do_IRQ(RT2880_INTC_IRQ_UART0
);
38 else if (pending
& RT2880_INTC_INT_PCM
)
39 do_IRQ(RT2880_INTC_IRQ_PCM
);
41 else if (pending
& RT2880_INTC_INT_UART1
)
42 do_IRQ(RT2880_INTC_IRQ_UART1
);
44 /* TODO: handle PIO interrupts as well */
50 static void rt288x_intc_irq_unmask(unsigned int irq
)
52 irq
-= RT288X_INTC_IRQ_BASE
;
53 rt288x_intc_wr((1 << irq
), INTC_REG_ENABLE
);
56 static void rt288x_intc_irq_mask(unsigned int irq
)
58 irq
-= RT288X_INTC_IRQ_BASE
;
59 rt288x_intc_wr((1 << irq
), INTC_REG_DISABLE
);
62 struct irq_chip rt288x_intc_irq_chip
= {
63 .name
= "RT288X INTC",
64 .unmask
= rt288x_intc_irq_unmask
,
65 .mask
= rt288x_intc_irq_mask
,
66 .mask_ack
= rt288x_intc_irq_mask
,
69 static struct irqaction rt288x_intc_irqaction
= {
71 .name
= "cascade [RT288X INTC]",
74 static void __init
rt288x_intc_irq_init(void)
78 /* disable all interrupts */
79 rt288x_intc_wr(~0, INTC_REG_DISABLE
);
81 /* route all INTC interrupts to MIPS HW0 interrupt */
82 rt288x_intc_wr(0, INTC_REG_TYPE
);
84 for (i
= RT288X_INTC_IRQ_BASE
;
85 i
< RT288X_INTC_IRQ_BASE
+ RT288X_INTC_IRQ_COUNT
; i
++) {
86 irq_desc
[i
].status
= IRQ_DISABLED
;
87 set_irq_chip_and_handler(i
, &rt288x_intc_irq_chip
,
91 setup_irq(RT288X_CPU_IRQ_INTC
, &rt288x_intc_irqaction
);
93 rt288x_intc_wr(RT2880_INTC_INT_GLOBAL
, INTC_REG_ENABLE
);
96 asmlinkage
void plat_irq_dispatch(void)
98 unsigned long pending
;
100 pending
= read_c0_status() & read_c0_cause() & ST0_IM
;
102 if (pending
& STATUSF_IP7
)
103 do_IRQ(RT288X_CPU_IRQ_COUNTER
);
105 else if (pending
& STATUSF_IP4
)
106 do_IRQ(RT288X_CPU_IRQ_PCI
);
108 else if (pending
& STATUSF_IP5
)
109 do_IRQ(RT288X_CPU_IRQ_FE
);
111 else if (pending
& STATUSF_IP6
)
112 do_IRQ(RT288X_CPU_IRQ_WNIC
);
114 else if (pending
& STATUSF_IP2
)
115 rt288x_intc_irq_dispatch();
118 spurious_interrupt();
121 void __init
arch_init_irq(void)
124 rt288x_intc_irq_init();