blob: 83a0b3c359daecee88c87223beef876d9b35aab9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Code to handle IP32 IRQs
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 2000 Harald Koerfgen
9 * Copyright (C) 2001 Keith M Wesolowski
10 */
11#include <linux/init.h>
12#include <linux/kernel_stat.h>
13#include <linux/types.h>
14#include <linux/interrupt.h>
15#include <linux/irq.h>
16#include <linux/bitops.h>
17#include <linux/kernel.h>
18#include <linux/slab.h>
19#include <linux/mm.h>
20#include <linux/random.h>
21#include <linux/sched.h>
22
Ralf Baechledd67b152007-10-14 14:02:26 +010023#include <asm/irq_cpu.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <asm/mipsregs.h>
25#include <asm/signal.h>
26#include <asm/system.h>
27#include <asm/time.h>
28#include <asm/ip32/crime.h>
29#include <asm/ip32/mace.h>
30#include <asm/ip32/ip32_ints.h>
31
32/* issue a PIO read to make sure no PIO writes are pending */
33static void inline flush_crime_bus(void)
34{
Ralf Baechleb6d7c7a2006-05-30 02:13:16 +010035 crime->control;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036}
37
38static void inline flush_mace_bus(void)
39{
Ralf Baechleb6d7c7a2006-05-30 02:13:16 +010040 mace->perif.ctrl.misc;
Linus Torvalds1da177e2005-04-16 15:20:36 -070041}
42
Ralf Baechledd67b152007-10-14 14:02:26 +010043/*
44 * O2 irq map
Linus Torvalds1da177e2005-04-16 15:20:36 -070045 *
46 * IP0 -> software (ignored)
47 * IP1 -> software (ignored)
48 * IP2 -> (irq0) C crime 1.1 all interrupts; crime 1.5 ???
49 * IP3 -> (irq1) X unknown
50 * IP4 -> (irq2) X unknown
51 * IP5 -> (irq3) X unknown
52 * IP6 -> (irq4) X unknown
Ralf Baechledd67b152007-10-14 14:02:26 +010053 * IP7 -> (irq5) 7 CPU count/compare timer (system timer)
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 *
55 * crime: (C)
56 *
57 * CRIME_INT_STAT 31:0:
58 *
Ralf Baechledd67b152007-10-14 14:02:26 +010059 * 0 -> 8 Video in 1
60 * 1 -> 9 Video in 2
61 * 2 -> 10 Video out
62 * 3 -> 11 Mace ethernet
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 * 4 -> S SuperIO sub-interrupt
64 * 5 -> M Miscellaneous sub-interrupt
65 * 6 -> A Audio sub-interrupt
Ralf Baechledd67b152007-10-14 14:02:26 +010066 * 7 -> 15 PCI bridge errors
67 * 8 -> 16 PCI SCSI aic7xxx 0
68 * 9 -> 17 PCI SCSI aic7xxx 1
69 * 10 -> 18 PCI slot 0
70 * 11 -> 19 unused (PCI slot 1)
71 * 12 -> 20 unused (PCI slot 2)
72 * 13 -> 21 unused (PCI shared 0)
73 * 14 -> 22 unused (PCI shared 1)
74 * 15 -> 23 unused (PCI shared 2)
75 * 16 -> 24 GBE0 (E)
76 * 17 -> 25 GBE1 (E)
77 * 18 -> 26 GBE2 (E)
78 * 19 -> 27 GBE3 (E)
79 * 20 -> 28 CPU errors
80 * 21 -> 29 Memory errors
81 * 22 -> 30 RE empty edge (E)
82 * 23 -> 31 RE full edge (E)
83 * 24 -> 32 RE idle edge (E)
84 * 25 -> 33 RE empty level
85 * 26 -> 34 RE full level
86 * 27 -> 35 RE idle level
87 * 28 -> 36 unused (software 0) (E)
88 * 29 -> 37 unused (software 1) (E)
89 * 30 -> 38 unused (software 2) - crime 1.5 CPU SysCorError (E)
90 * 31 -> 39 VICE
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 *
92 * S, M, A: Use the MACE ISA interrupt register
93 * MACE_ISA_INT_STAT 31:0
94 *
Ralf Baechledd67b152007-10-14 14:02:26 +010095 * 0-7 -> 40-47 Audio
96 * 8 -> 48 RTC
97 * 9 -> 49 Keyboard
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 * 10 -> X Keyboard polled
Ralf Baechledd67b152007-10-14 14:02:26 +010099 * 11 -> 51 Mouse
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 * 12 -> X Mouse polled
Ralf Baechledd67b152007-10-14 14:02:26 +0100101 * 13-15 -> 53-55 Count/compare timers
102 * 16-19 -> 56-59 Parallel (16 E)
103 * 20-25 -> 60-62 Serial 1 (22 E)
104 * 26-31 -> 66-71 Serial 2 (28 E)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 *
Ralf Baechledd67b152007-10-14 14:02:26 +0100106 * Note that this means IRQs 12-14, 50, and 52 do not exist. This is a
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 * different IRQ map than IRIX uses, but that's OK as Linux irq handling
108 * is quite different anyway.
109 */
110
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111/* Some initial interrupts to set up */
Ralf Baechle937a8012006-10-07 19:44:33 +0100112extern irqreturn_t crime_memerr_intr(int irq, void *dev_id);
113extern irqreturn_t crime_cpuerr_intr(int irq, void *dev_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
Thomas Gleixner4e451712007-08-28 09:03:01 +0000115struct irqaction memerr_irq = {
116 .handler = crime_memerr_intr,
117 .flags = IRQF_DISABLED,
Thomas Gleixner4e451712007-08-28 09:03:01 +0000118 .name = "CRIME memory error",
119};
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000120
Thomas Gleixner4e451712007-08-28 09:03:01 +0000121struct irqaction cpuerr_irq = {
122 .handler = crime_cpuerr_intr,
123 .flags = IRQF_DISABLED,
Thomas Gleixner4e451712007-08-28 09:03:01 +0000124 .name = "CRIME CPU error",
125};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 * This is for pure CRIME interrupts - ie not MACE. The advantage?
129 * We get to split the register in half and do faster lookups.
130 */
131
132static uint64_t crime_mask;
133
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000134static inline void crime_enable_irq(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135{
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000136 unsigned int bit = irq - CRIME_IRQ_BASE;
137
138 crime_mask |= 1 << bit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 crime->imask = crime_mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140}
141
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000142static inline void crime_disable_irq(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143{
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000144 unsigned int bit = irq - CRIME_IRQ_BASE;
145
146 crime_mask &= ~(1 << bit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 crime->imask = crime_mask;
148 flush_crime_bus();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149}
150
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000151static void crime_level_mask_and_ack_irq(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152{
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000153 crime_disable_irq(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154}
155
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000156static void crime_level_end_irq(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157{
158 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000159 crime_enable_irq(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160}
161
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000162static struct irq_chip crime_level_interrupt = {
163 .name = "IP32 CRIME",
164 .ack = crime_level_mask_and_ack_irq,
165 .mask = crime_disable_irq,
166 .mask_ack = crime_level_mask_and_ack_irq,
167 .unmask = crime_enable_irq,
168 .end = crime_level_end_irq,
169};
170
171static void crime_edge_mask_and_ack_irq(unsigned int irq)
172{
173 unsigned int bit = irq - CRIME_IRQ_BASE;
174 uint64_t crime_int;
175
176 /* Edge triggered interrupts must be cleared. */
177
178 crime_int = crime->hard_int;
179 crime_int &= ~(1 << bit);
180 crime->hard_int = crime_int;
181
182 crime_disable_irq(irq);
183}
184
185static void crime_edge_end_irq(unsigned int irq)
186{
187 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
188 crime_enable_irq(irq);
189}
190
191static struct irq_chip crime_edge_interrupt = {
192 .name = "IP32 CRIME",
193 .ack = crime_edge_mask_and_ack_irq,
194 .mask = crime_disable_irq,
195 .mask_ack = crime_edge_mask_and_ack_irq,
196 .unmask = crime_enable_irq,
197 .end = crime_edge_end_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198};
199
200/*
201 * This is for MACE PCI interrupts. We can decrease bus traffic by masking
202 * as close to the source as possible. This also means we can take the
203 * next chunk of the CRIME register in one piece.
204 */
205
206static unsigned long macepci_mask;
207
208static void enable_macepci_irq(unsigned int irq)
209{
Ralf Baechle98ce4722007-10-30 15:43:44 +0000210 macepci_mask |= MACEPCI_CONTROL_INT(irq - MACEPCI_SCSI0_IRQ);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 mace->pci.control = macepci_mask;
Ralf Baechle98ce4722007-10-30 15:43:44 +0000212 crime_mask |= 1 << (irq - CRIME_IRQ_BASE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 crime->imask = crime_mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214}
215
216static void disable_macepci_irq(unsigned int irq)
217{
Ralf Baechle98ce4722007-10-30 15:43:44 +0000218 crime_mask &= ~(1 << (irq - CRIME_IRQ_BASE));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 crime->imask = crime_mask;
220 flush_crime_bus();
Ralf Baechle98ce4722007-10-30 15:43:44 +0000221 macepci_mask &= ~MACEPCI_CONTROL_INT(irq - MACEPCI_SCSI0_IRQ);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222 mace->pci.control = macepci_mask;
223 flush_mace_bus();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224}
225
226static void end_macepci_irq(unsigned int irq)
227{
228 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
229 enable_macepci_irq(irq);
230}
231
Ralf Baechle94dee172006-07-02 14:41:42 +0100232static struct irq_chip ip32_macepci_interrupt = {
Atsushi Nemoto70d21cd2007-01-15 00:07:25 +0900233 .name = "IP32 MACE PCI",
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +0900234 .ack = disable_macepci_irq,
235 .mask = disable_macepci_irq,
236 .mask_ack = disable_macepci_irq,
237 .unmask = enable_macepci_irq,
Ralf Baechle8ab00b92005-02-28 13:39:57 +0000238 .end = end_macepci_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239};
240
241/* This is used for MACE ISA interrupts. That means bits 4-6 in the
242 * CRIME register.
243 */
244
245#define MACEISA_AUDIO_INT (MACEISA_AUDIO_SW_INT | \
246 MACEISA_AUDIO_SC_INT | \
247 MACEISA_AUDIO1_DMAT_INT | \
248 MACEISA_AUDIO1_OF_INT | \
249 MACEISA_AUDIO2_DMAT_INT | \
250 MACEISA_AUDIO2_MERR_INT | \
251 MACEISA_AUDIO3_DMAT_INT | \
252 MACEISA_AUDIO3_MERR_INT)
253#define MACEISA_MISC_INT (MACEISA_RTC_INT | \
254 MACEISA_KEYB_INT | \
255 MACEISA_KEYB_POLL_INT | \
256 MACEISA_MOUSE_INT | \
257 MACEISA_MOUSE_POLL_INT | \
Thiemo Seufercfbae5d2006-07-05 18:43:29 +0100258 MACEISA_TIMER0_INT | \
259 MACEISA_TIMER1_INT | \
260 MACEISA_TIMER2_INT)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261#define MACEISA_SUPERIO_INT (MACEISA_PARALLEL_INT | \
262 MACEISA_PAR_CTXA_INT | \
263 MACEISA_PAR_CTXB_INT | \
264 MACEISA_PAR_MERR_INT | \
265 MACEISA_SERIAL1_INT | \
266 MACEISA_SERIAL1_TDMAT_INT | \
267 MACEISA_SERIAL1_TDMAPR_INT | \
268 MACEISA_SERIAL1_TDMAME_INT | \
269 MACEISA_SERIAL1_RDMAT_INT | \
270 MACEISA_SERIAL1_RDMAOR_INT | \
271 MACEISA_SERIAL2_INT | \
272 MACEISA_SERIAL2_TDMAT_INT | \
273 MACEISA_SERIAL2_TDMAPR_INT | \
274 MACEISA_SERIAL2_TDMAME_INT | \
275 MACEISA_SERIAL2_RDMAT_INT | \
276 MACEISA_SERIAL2_RDMAOR_INT)
277
278static unsigned long maceisa_mask;
279
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100280static void enable_maceisa_irq(unsigned int irq)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281{
282 unsigned int crime_int = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000284 pr_debug("maceisa enable: %u\n", irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285
286 switch (irq) {
287 case MACEISA_AUDIO_SW_IRQ ... MACEISA_AUDIO3_MERR_IRQ:
288 crime_int = MACE_AUDIO_INT;
289 break;
Thiemo Seufercfbae5d2006-07-05 18:43:29 +0100290 case MACEISA_RTC_IRQ ... MACEISA_TIMER2_IRQ:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 crime_int = MACE_MISC_INT;
292 break;
293 case MACEISA_PARALLEL_IRQ ... MACEISA_SERIAL2_RDMAOR_IRQ:
294 crime_int = MACE_SUPERIO_INT;
295 break;
296 }
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000297 pr_debug("crime_int %08x enabled\n", crime_int);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 crime_mask |= crime_int;
299 crime->imask = crime_mask;
Ralf Baechle98ce4722007-10-30 15:43:44 +0000300 maceisa_mask |= 1 << (irq - MACEISA_AUDIO_SW_IRQ);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 mace->perif.ctrl.imask = maceisa_mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302}
303
304static void disable_maceisa_irq(unsigned int irq)
305{
306 unsigned int crime_int = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307
Ralf Baechle98ce4722007-10-30 15:43:44 +0000308 maceisa_mask &= ~(1 << (irq - MACEISA_AUDIO_SW_IRQ));
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000309 if (!(maceisa_mask & MACEISA_AUDIO_INT))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 crime_int |= MACE_AUDIO_INT;
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000311 if (!(maceisa_mask & MACEISA_MISC_INT))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 crime_int |= MACE_MISC_INT;
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000313 if (!(maceisa_mask & MACEISA_SUPERIO_INT))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 crime_int |= MACE_SUPERIO_INT;
315 crime_mask &= ~crime_int;
316 crime->imask = crime_mask;
317 flush_crime_bus();
318 mace->perif.ctrl.imask = maceisa_mask;
319 flush_mace_bus();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320}
321
322static void mask_and_ack_maceisa_irq(unsigned int irq)
323{
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +0900324 unsigned long mace_int;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325
Ralf Baechlec87e0902009-03-30 14:49:44 +0200326 /* edge triggered */
327 mace_int = mace->perif.ctrl.istat;
328 mace_int &= ~(1 << (irq - MACEISA_AUDIO_SW_IRQ));
329 mace->perif.ctrl.istat = mace_int;
330
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 disable_maceisa_irq(irq);
332}
333
334static void end_maceisa_irq(unsigned irq)
335{
336 if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS)))
337 enable_maceisa_irq(irq);
338}
339
Ralf Baechlec87e0902009-03-30 14:49:44 +0200340static struct irq_chip ip32_maceisa_level_interrupt = {
341 .name = "IP32 MACE ISA",
342 .ack = disable_maceisa_irq,
343 .mask = disable_maceisa_irq,
344 .mask_ack = disable_maceisa_irq,
345 .unmask = enable_maceisa_irq,
346 .end = end_maceisa_irq,
347};
348
349static struct irq_chip ip32_maceisa_edge_interrupt = {
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000350 .name = "IP32 MACE ISA",
351 .ack = mask_and_ack_maceisa_irq,
352 .mask = disable_maceisa_irq,
353 .mask_ack = mask_and_ack_maceisa_irq,
354 .unmask = enable_maceisa_irq,
355 .end = end_maceisa_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356};
357
358/* This is used for regular non-ISA, non-PCI MACE interrupts. That means
359 * bits 0-3 and 7 in the CRIME register.
360 */
361
362static void enable_mace_irq(unsigned int irq)
363{
Ralf Baechle98ce4722007-10-30 15:43:44 +0000364 unsigned int bit = irq - CRIME_IRQ_BASE;
365
366 crime_mask |= (1 << bit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 crime->imask = crime_mask;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368}
369
370static void disable_mace_irq(unsigned int irq)
371{
Ralf Baechle98ce4722007-10-30 15:43:44 +0000372 unsigned int bit = irq - CRIME_IRQ_BASE;
373
374 crime_mask &= ~(1 << bit);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 crime->imask = crime_mask;
376 flush_crime_bus();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377}
378
379static void end_mace_irq(unsigned int irq)
380{
381 if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS)))
382 enable_mace_irq(irq);
383}
384
Ralf Baechle94dee172006-07-02 14:41:42 +0100385static struct irq_chip ip32_mace_interrupt = {
Atsushi Nemoto70d21cd2007-01-15 00:07:25 +0900386 .name = "IP32 MACE",
Atsushi Nemoto1603b5a2006-11-02 02:08:36 +0900387 .ack = disable_mace_irq,
388 .mask = disable_mace_irq,
389 .mask_ack = disable_mace_irq,
390 .unmask = enable_mace_irq,
Ralf Baechle8ab00b92005-02-28 13:39:57 +0000391 .end = end_mace_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392};
393
Ralf Baechle937a8012006-10-07 19:44:33 +0100394static void ip32_unknown_interrupt(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395{
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100396 printk("Unknown interrupt occurred!\n");
397 printk("cp0_status: %08x\n", read_c0_status());
398 printk("cp0_cause: %08x\n", read_c0_cause());
399 printk("CRIME intr mask: %016lx\n", crime->imask);
400 printk("CRIME intr status: %016lx\n", crime->istat);
401 printk("CRIME hardware intr register: %016lx\n", crime->hard_int);
402 printk("MACE ISA intr mask: %08lx\n", mace->perif.ctrl.imask);
403 printk("MACE ISA intr status: %08lx\n", mace->perif.ctrl.istat);
404 printk("MACE PCI control register: %08x\n", mace->pci.control);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405
406 printk("Register dump:\n");
Ralf Baechle937a8012006-10-07 19:44:33 +0100407 show_regs(get_irq_regs());
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408
409 printk("Please mail this report to linux-mips@linux-mips.org\n");
410 printk("Spinning...");
411 while(1) ;
412}
413
414/* CRIME 1.1 appears to deliver all interrupts to this one pin. */
415/* change this to loop over all edge-triggered irqs, exception masked out ones */
Ralf Baechle937a8012006-10-07 19:44:33 +0100416static void ip32_irq0(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417{
418 uint64_t crime_int;
419 int irq = 0;
420
Ralf Baechledd67b152007-10-14 14:02:26 +0100421 /*
422 * Sanity check interrupt numbering enum.
423 * MACE got 32 interrupts and there are 32 MACE ISA interrupts daisy
424 * chained.
425 */
426 BUILD_BUG_ON(CRIME_VICE_IRQ - MACE_VID_IN1_IRQ != 31);
427 BUILD_BUG_ON(MACEISA_SERIAL2_RDMAOR_IRQ - MACEISA_AUDIO_SW_IRQ != 31);
428
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429 crime_int = crime->istat & crime_mask;
Thomas Bogendoerfer1faf7f22008-06-24 00:48:05 +0200430
431 /* crime sometime delivers spurious interrupts, ignore them */
432 if (unlikely(crime_int == 0))
433 return;
434
Ralf Baechledd67b152007-10-14 14:02:26 +0100435 irq = MACE_VID_IN1_IRQ + __ffs(crime_int);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436
437 if (crime_int & CRIME_MACEISA_INT_MASK) {
438 unsigned long mace_int = mace->perif.ctrl.istat;
Ralf Baechledd67b152007-10-14 14:02:26 +0100439 irq = __ffs(mace_int & maceisa_mask) + MACEISA_AUDIO_SW_IRQ;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 }
Ralf Baechledd67b152007-10-14 14:02:26 +0100441
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000442 pr_debug("*irq %u*\n", irq);
Ralf Baechle937a8012006-10-07 19:44:33 +0100443 do_IRQ(irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444}
445
Ralf Baechle937a8012006-10-07 19:44:33 +0100446static void ip32_irq1(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447{
Ralf Baechle937a8012006-10-07 19:44:33 +0100448 ip32_unknown_interrupt();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449}
450
Ralf Baechle937a8012006-10-07 19:44:33 +0100451static void ip32_irq2(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452{
Ralf Baechle937a8012006-10-07 19:44:33 +0100453 ip32_unknown_interrupt();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454}
455
Ralf Baechle937a8012006-10-07 19:44:33 +0100456static void ip32_irq3(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457{
Ralf Baechle937a8012006-10-07 19:44:33 +0100458 ip32_unknown_interrupt();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459}
460
Ralf Baechle937a8012006-10-07 19:44:33 +0100461static void ip32_irq4(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462{
Ralf Baechle937a8012006-10-07 19:44:33 +0100463 ip32_unknown_interrupt();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464}
465
Ralf Baechle937a8012006-10-07 19:44:33 +0100466static void ip32_irq5(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467{
Ralf Baechledd67b152007-10-14 14:02:26 +0100468 do_IRQ(MIPS_CPU_IRQ_BASE + 7);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469}
470
Ralf Baechle937a8012006-10-07 19:44:33 +0100471asmlinkage void plat_irq_dispatch(void)
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100472{
Thiemo Seufer119537c2007-03-19 00:13:37 +0000473 unsigned int pending = read_c0_status() & read_c0_cause();
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100474
475 if (likely(pending & IE_IRQ0))
Ralf Baechle937a8012006-10-07 19:44:33 +0100476 ip32_irq0();
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100477 else if (unlikely(pending & IE_IRQ1))
Ralf Baechle937a8012006-10-07 19:44:33 +0100478 ip32_irq1();
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100479 else if (unlikely(pending & IE_IRQ2))
Ralf Baechle937a8012006-10-07 19:44:33 +0100480 ip32_irq2();
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100481 else if (unlikely(pending & IE_IRQ3))
Ralf Baechle937a8012006-10-07 19:44:33 +0100482 ip32_irq3();
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100483 else if (unlikely(pending & IE_IRQ4))
Ralf Baechle937a8012006-10-07 19:44:33 +0100484 ip32_irq4();
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100485 else if (likely(pending & IE_IRQ5))
Ralf Baechle937a8012006-10-07 19:44:33 +0100486 ip32_irq5();
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100487}
488
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489void __init arch_init_irq(void)
490{
491 unsigned int irq;
492
493 /* Install our interrupt handler, then clear and disable all
494 * CRIME and MACE interrupts. */
495 crime->imask = 0;
496 crime->hard_int = 0;
497 crime->soft_int = 0;
498 mace->perif.ctrl.istat = 0;
499 mace->perif.ctrl.imask = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500
Ralf Baechledd67b152007-10-14 14:02:26 +0100501 mips_cpu_irq_init();
Ralf Baechle98ce4722007-10-30 15:43:44 +0000502 for (irq = CRIME_IRQ_BASE; irq <= IP32_IRQ_MAX; irq++) {
Ralf Baechledd67b152007-10-14 14:02:26 +0100503 switch (irq) {
504 case MACE_VID_IN1_IRQ ... MACE_PCI_BRIDGE_IRQ:
Ralf Baechlec87e0902009-03-30 14:49:44 +0200505 set_irq_chip_and_handler_name(irq,&ip32_mace_interrupt,
506 handle_level_irq, "level");
Ralf Baechledd67b152007-10-14 14:02:26 +0100507 break;
Ralf Baechlec87e0902009-03-30 14:49:44 +0200508
Ralf Baechledd67b152007-10-14 14:02:26 +0100509 case MACEPCI_SCSI0_IRQ ... MACEPCI_SHARED2_IRQ:
Ralf Baechlec87e0902009-03-30 14:49:44 +0200510 set_irq_chip_and_handler_name(irq,
511 &ip32_macepci_interrupt, handle_level_irq,
512 "level");
Ralf Baechledd67b152007-10-14 14:02:26 +0100513 break;
Ralf Baechlec87e0902009-03-30 14:49:44 +0200514
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000515 case CRIME_GBE0_IRQ ... CRIME_GBE3_IRQ:
Ralf Baechlec87e0902009-03-30 14:49:44 +0200516 set_irq_chip_and_handler_name(irq,
517 &crime_edge_interrupt, handle_edge_irq, "edge");
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000518 break;
519 case CRIME_CPUERR_IRQ:
520 case CRIME_MEMERR_IRQ:
Ralf Baechlec87e0902009-03-30 14:49:44 +0200521 set_irq_chip_and_handler_name(irq,
522 &crime_level_interrupt, handle_level_irq,
523 "level");
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000524 break;
Ralf Baechlec87e0902009-03-30 14:49:44 +0200525
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000526 case CRIME_RE_EMPTY_E_IRQ ... CRIME_RE_IDLE_E_IRQ:
527 case CRIME_SOFT0_IRQ ... CRIME_SOFT2_IRQ:
Ralf Baechlec87e0902009-03-30 14:49:44 +0200528 set_irq_chip_and_handler_name(irq,
529 &crime_edge_interrupt, handle_edge_irq, "edge");
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000530 break;
Ralf Baechlec87e0902009-03-30 14:49:44 +0200531
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000532 case CRIME_VICE_IRQ:
Ralf Baechlec87e0902009-03-30 14:49:44 +0200533 set_irq_chip_and_handler_name(irq,
534 &crime_edge_interrupt, handle_edge_irq, "edge");
Ralf Baechledd67b152007-10-14 14:02:26 +0100535 break;
Ralf Baechlec87e0902009-03-30 14:49:44 +0200536
537 case MACEISA_PARALLEL_IRQ:
538 case MACEISA_SERIAL1_TDMAPR_IRQ:
539 case MACEISA_SERIAL2_TDMAPR_IRQ:
540 set_irq_chip_and_handler_name(irq,
541 &ip32_maceisa_edge_interrupt, handle_edge_irq,
542 "edge");
543 break;
544
Ralf Baechledd67b152007-10-14 14:02:26 +0100545 default:
Ralf Baechlec87e0902009-03-30 14:49:44 +0200546 set_irq_chip_and_handler_name(irq,
547 &ip32_maceisa_level_interrupt, handle_level_irq,
548 "level");
Ralf Baechle8a13ecd2007-10-28 18:46:39 +0000549 break;
Ralf Baechledd67b152007-10-14 14:02:26 +0100550 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 }
552 setup_irq(CRIME_MEMERR_IRQ, &memerr_irq);
553 setup_irq(CRIME_CPUERR_IRQ, &cpuerr_irq);
554
555#define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
556 change_c0_status(ST0_IM, ALLINTS);
557}