2 * arch/mips/ifxmips/interrupt.c
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
18 * Copyright (C) 2005 Wu Qi Ming infineon
20 * Rewrite of Infineon IFXMips code, thanks to infineon for the support,
21 * software and hardware
23 * Copyright (C) 2007 John Crispin <blogic@openwrt.org>
27 #include <linux/init.h>
28 #include <linux/sched.h>
29 #include <linux/slab.h>
30 #include <linux/interrupt.h>
31 #include <linux/kernel_stat.h>
32 #include <linux/module.h>
34 #include <asm/bootinfo.h>
36 #include <asm/ifxmips/ifxmips.h>
37 #include <asm/ifxmips/ifxmips_irq.h>
38 #include <asm/irq_cpu.h>
42 disable_ifxmips_irq (unsigned int irq_nr
)
45 u32
*ifxmips_ier
= IFXMIPS_ICU_IM0_IER
;
47 irq_nr
-= INT_NUM_IRQ0
;
48 for (i
= 0; i
<= 4; i
++)
50 if (irq_nr
< INT_NUM_IM_OFFSET
){
51 writel(readl(ifxmips_ier
) & ~(1 << irq_nr
), ifxmips_ier
);
54 ifxmips_ier
+= IFXMIPS_ICU_OFFSET
;
55 irq_nr
-= INT_NUM_IM_OFFSET
;
58 EXPORT_SYMBOL (disable_ifxmips_irq
);
61 mask_and_ack_ifxmips_irq (unsigned int irq_nr
)
64 u32
*ifxmips_ier
= IFXMIPS_ICU_IM0_IER
;
65 u32
*ifxmips_isr
= IFXMIPS_ICU_IM0_ISR
;
67 irq_nr
-= INT_NUM_IRQ0
;
68 for (i
= 0; i
<= 4; i
++)
70 if (irq_nr
< INT_NUM_IM_OFFSET
)
72 writel(readl(ifxmips_ier
) & ~(1 << irq_nr
), ifxmips_ier
);
73 writel((1 << irq_nr
), ifxmips_isr
);
76 ifxmips_ier
+= IFXMIPS_ICU_OFFSET
;
77 ifxmips_isr
+= IFXMIPS_ICU_OFFSET
;
78 irq_nr
-= INT_NUM_IM_OFFSET
;
81 EXPORT_SYMBOL (mask_and_ack_ifxmips_irq
);
84 enable_ifxmips_irq (unsigned int irq_nr
)
87 u32
*ifxmips_ier
= IFXMIPS_ICU_IM0_IER
;
89 irq_nr
-= INT_NUM_IRQ0
;
90 for (i
= 0; i
<= 4; i
++)
92 if (irq_nr
< INT_NUM_IM_OFFSET
)
94 writel(readl(ifxmips_ier
) | (1 << irq_nr
), ifxmips_ier
);
97 ifxmips_ier
+= IFXMIPS_ICU_OFFSET
;
98 irq_nr
-= INT_NUM_IM_OFFSET
;
101 EXPORT_SYMBOL (enable_ifxmips_irq
);
104 startup_ifxmips_irq (unsigned int irq
)
106 enable_ifxmips_irq (irq
);
111 end_ifxmips_irq (unsigned int irq
)
113 if (!(irq_desc
[irq
].status
& (IRQ_DISABLED
| IRQ_INPROGRESS
)))
114 enable_ifxmips_irq (irq
);
117 static struct hw_interrupt_type ifxmips_irq_type
= {
119 .startup
= startup_ifxmips_irq
,
120 .enable
= enable_ifxmips_irq
,
121 .disable
= disable_ifxmips_irq
,
122 .unmask
= enable_ifxmips_irq
,
123 .ack
= end_ifxmips_irq
,
124 .mask
= disable_ifxmips_irq
,
125 .mask_ack
= mask_and_ack_ifxmips_irq
,
126 .end
= end_ifxmips_irq
,
130 ls1bit32(unsigned long x
)
144 ifxmips_hw_irqdispatch (int module
)
148 irq
= readl(IFXMIPS_ICU_IM0_IOSR
+ (module
* IFXMIPS_ICU_OFFSET
));
152 irq
= ls1bit32 (irq
);
153 do_IRQ ((int) irq
+ INT_NUM_IM0_IRL0
+ (INT_NUM_IM_OFFSET
* module
));
155 if ((irq
== 22) && (module
== 0)){
156 writel(readl(IFXMIPS_EBU_PCC_ISTAT
) | 0x10, IFXMIPS_EBU_PCC_ISTAT
);
161 plat_irq_dispatch (void)
163 unsigned int pending
= read_c0_status() & read_c0_cause() & ST0_IM
;
166 if (pending
& CAUSEF_IP7
){
167 do_IRQ(MIPS_CPU_TIMER_IRQ
);
170 for (i
= 0; i
< 5; i
++)
172 if (pending
& (CAUSEF_IP2
<< i
))
174 ifxmips_hw_irqdispatch(i
);
179 printk("Spurious IRQ: CAUSE=0x%08x\n", read_c0_status());
185 static struct irqaction cascade
= {
186 .handler
= no_action
,
187 .flags
= IRQF_DISABLED
,
196 for (i
= 0; i
< 5; i
++)
198 writel(0, IFXMIPS_ICU_IM0_IER
+ (i
* IFXMIPS_ICU_OFFSET
));
203 for (i
= 2; i
<= 6; i
++)
205 setup_irq(i
, &cascade
);
208 for (i
= INT_NUM_IRQ0
; i
<= (INT_NUM_IRQ0
+ (5 * INT_NUM_IM_OFFSET
)); i
++)
211 irq_desc
[i
].status
= IRQ_DISABLED
;
212 irq_desc
[i
].action
= NULL
;
213 irq_desc
[i
].depth
= 1;
215 set_irq_chip_and_handler(i
, &ifxmips_irq_type
, handle_level_irq
);
218 set_c0_status (IE_IRQ0
| IE_IRQ1
| IE_IRQ2
| IE_IRQ3
| IE_IRQ4
| IE_IRQ5
);