11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds * Code to handle IP32 IRQs
31da177e4SLinus Torvalds *
41da177e4SLinus Torvalds * This file is subject to the terms and conditions of the GNU General Public
51da177e4SLinus Torvalds * License. See the file "COPYING" in the main directory of this archive
61da177e4SLinus Torvalds * for more details.
71da177e4SLinus Torvalds *
81da177e4SLinus Torvalds * Copyright (C) 2000 Harald Koerfgen
91da177e4SLinus Torvalds * Copyright (C) 2001 Keith M Wesolowski
101da177e4SLinus Torvalds */
111da177e4SLinus Torvalds #include <linux/init.h>
121da177e4SLinus Torvalds #include <linux/kernel_stat.h>
131da177e4SLinus Torvalds #include <linux/types.h>
141da177e4SLinus Torvalds #include <linux/interrupt.h>
151da177e4SLinus Torvalds #include <linux/irq.h>
161da177e4SLinus Torvalds #include <linux/bitops.h>
171da177e4SLinus Torvalds #include <linux/kernel.h>
181da177e4SLinus Torvalds #include <linux/mm.h>
191da177e4SLinus Torvalds #include <linux/random.h>
201da177e4SLinus Torvalds #include <linux/sched.h>
21b17b0153SIngo Molnar #include <linux/sched/debug.h>
221da177e4SLinus Torvalds
23dd67b155SRalf Baechle #include <asm/irq_cpu.h>
241da177e4SLinus Torvalds #include <asm/mipsregs.h>
251da177e4SLinus Torvalds #include <asm/signal.h>
261da177e4SLinus Torvalds #include <asm/time.h>
271da177e4SLinus Torvalds #include <asm/ip32/crime.h>
281da177e4SLinus Torvalds #include <asm/ip32/mace.h>
291da177e4SLinus Torvalds #include <asm/ip32/ip32_ints.h>
301da177e4SLinus Torvalds
31*f64fdde9SThomas Bogendoerfer #include "ip32-common.h"
32*f64fdde9SThomas Bogendoerfer
331da177e4SLinus Torvalds /* issue a PIO read to make sure no PIO writes are pending */
flush_crime_bus(void)3442b76a1dSArnd Bergmann static inline void flush_crime_bus(void)
351da177e4SLinus Torvalds {
36b6d7c7a9SRalf Baechle crime->control;
371da177e4SLinus Torvalds }
381da177e4SLinus Torvalds
flush_mace_bus(void)3942b76a1dSArnd Bergmann static inline void flush_mace_bus(void)
401da177e4SLinus Torvalds {
41b6d7c7a9SRalf Baechle mace->perif.ctrl.misc;
421da177e4SLinus Torvalds }
431da177e4SLinus Torvalds
44dd67b155SRalf Baechle /*
45dd67b155SRalf Baechle * O2 irq map
461da177e4SLinus Torvalds *
471da177e4SLinus Torvalds * IP0 -> software (ignored)
481da177e4SLinus Torvalds * IP1 -> software (ignored)
491da177e4SLinus Torvalds * IP2 -> (irq0) C crime 1.1 all interrupts; crime 1.5 ???
501da177e4SLinus Torvalds * IP3 -> (irq1) X unknown
511da177e4SLinus Torvalds * IP4 -> (irq2) X unknown
521da177e4SLinus Torvalds * IP5 -> (irq3) X unknown
531da177e4SLinus Torvalds * IP6 -> (irq4) X unknown
54dd67b155SRalf Baechle * IP7 -> (irq5) 7 CPU count/compare timer (system timer)
551da177e4SLinus Torvalds *
561da177e4SLinus Torvalds * crime: (C)
571da177e4SLinus Torvalds *
581da177e4SLinus Torvalds * CRIME_INT_STAT 31:0:
591da177e4SLinus Torvalds *
60dd67b155SRalf Baechle * 0 -> 8 Video in 1
61dd67b155SRalf Baechle * 1 -> 9 Video in 2
62dd67b155SRalf Baechle * 2 -> 10 Video out
63dd67b155SRalf Baechle * 3 -> 11 Mace ethernet
641da177e4SLinus Torvalds * 4 -> S SuperIO sub-interrupt
651da177e4SLinus Torvalds * 5 -> M Miscellaneous sub-interrupt
661da177e4SLinus Torvalds * 6 -> A Audio sub-interrupt
67dd67b155SRalf Baechle * 7 -> 15 PCI bridge errors
68dd67b155SRalf Baechle * 8 -> 16 PCI SCSI aic7xxx 0
69dd67b155SRalf Baechle * 9 -> 17 PCI SCSI aic7xxx 1
70dd67b155SRalf Baechle * 10 -> 18 PCI slot 0
71dd67b155SRalf Baechle * 11 -> 19 unused (PCI slot 1)
72dd67b155SRalf Baechle * 12 -> 20 unused (PCI slot 2)
73dd67b155SRalf Baechle * 13 -> 21 unused (PCI shared 0)
74dd67b155SRalf Baechle * 14 -> 22 unused (PCI shared 1)
75dd67b155SRalf Baechle * 15 -> 23 unused (PCI shared 2)
76dd67b155SRalf Baechle * 16 -> 24 GBE0 (E)
77dd67b155SRalf Baechle * 17 -> 25 GBE1 (E)
78dd67b155SRalf Baechle * 18 -> 26 GBE2 (E)
79dd67b155SRalf Baechle * 19 -> 27 GBE3 (E)
80dd67b155SRalf Baechle * 20 -> 28 CPU errors
81dd67b155SRalf Baechle * 21 -> 29 Memory errors
82dd67b155SRalf Baechle * 22 -> 30 RE empty edge (E)
83dd67b155SRalf Baechle * 23 -> 31 RE full edge (E)
84dd67b155SRalf Baechle * 24 -> 32 RE idle edge (E)
85dd67b155SRalf Baechle * 25 -> 33 RE empty level
86dd67b155SRalf Baechle * 26 -> 34 RE full level
87dd67b155SRalf Baechle * 27 -> 35 RE idle level
88dd67b155SRalf Baechle * 28 -> 36 unused (software 0) (E)
89dd67b155SRalf Baechle * 29 -> 37 unused (software 1) (E)
90dd67b155SRalf Baechle * 30 -> 38 unused (software 2) - crime 1.5 CPU SysCorError (E)
91dd67b155SRalf Baechle * 31 -> 39 VICE
921da177e4SLinus Torvalds *
931da177e4SLinus Torvalds * S, M, A: Use the MACE ISA interrupt register
941da177e4SLinus Torvalds * MACE_ISA_INT_STAT 31:0
951da177e4SLinus Torvalds *
96dd67b155SRalf Baechle * 0-7 -> 40-47 Audio
97dd67b155SRalf Baechle * 8 -> 48 RTC
98dd67b155SRalf Baechle * 9 -> 49 Keyboard
991da177e4SLinus Torvalds * 10 -> X Keyboard polled
100dd67b155SRalf Baechle * 11 -> 51 Mouse
1011da177e4SLinus Torvalds * 12 -> X Mouse polled
102dd67b155SRalf Baechle * 13-15 -> 53-55 Count/compare timers
103dd67b155SRalf Baechle * 16-19 -> 56-59 Parallel (16 E)
104dd67b155SRalf Baechle * 20-25 -> 60-62 Serial 1 (22 E)
105dd67b155SRalf Baechle * 26-31 -> 66-71 Serial 2 (28 E)
1061da177e4SLinus Torvalds *
107dd67b155SRalf Baechle * Note that this means IRQs 12-14, 50, and 52 do not exist. This is a
1081da177e4SLinus Torvalds * different IRQ map than IRIX uses, but that's OK as Linux irq handling
1091da177e4SLinus Torvalds * is quite different anyway.
1101da177e4SLinus Torvalds */
1111da177e4SLinus Torvalds
1121da177e4SLinus Torvalds /*
1131da177e4SLinus Torvalds * This is for pure CRIME interrupts - ie not MACE. The advantage?
1141da177e4SLinus Torvalds * We get to split the register in half and do faster lookups.
1151da177e4SLinus Torvalds */
1161da177e4SLinus Torvalds
1171da177e4SLinus Torvalds static uint64_t crime_mask;
1181da177e4SLinus Torvalds
crime_enable_irq(struct irq_data * d)1194d2796f8SThomas Gleixner static inline void crime_enable_irq(struct irq_data *d)
1201da177e4SLinus Torvalds {
1214d2796f8SThomas Gleixner unsigned int bit = d->irq - CRIME_IRQ_BASE;
1228a13ecd7SRalf Baechle
1238a13ecd7SRalf Baechle crime_mask |= 1 << bit;
1241da177e4SLinus Torvalds crime->imask = crime_mask;
1251da177e4SLinus Torvalds }
1261da177e4SLinus Torvalds
crime_disable_irq(struct irq_data * d)1274d2796f8SThomas Gleixner static inline void crime_disable_irq(struct irq_data *d)
1281da177e4SLinus Torvalds {
1294d2796f8SThomas Gleixner unsigned int bit = d->irq - CRIME_IRQ_BASE;
1308a13ecd7SRalf Baechle
1318a13ecd7SRalf Baechle crime_mask &= ~(1 << bit);
1321da177e4SLinus Torvalds crime->imask = crime_mask;
1331da177e4SLinus Torvalds flush_crime_bus();
1341da177e4SLinus Torvalds }
1351da177e4SLinus Torvalds
1368a13ecd7SRalf Baechle static struct irq_chip crime_level_interrupt = {
13770d21cdeSAtsushi Nemoto .name = "IP32 CRIME",
1384d2796f8SThomas Gleixner .irq_mask = crime_disable_irq,
1394d2796f8SThomas Gleixner .irq_unmask = crime_enable_irq,
1408a13ecd7SRalf Baechle };
1418a13ecd7SRalf Baechle
crime_edge_mask_and_ack_irq(struct irq_data * d)1424d2796f8SThomas Gleixner static void crime_edge_mask_and_ack_irq(struct irq_data *d)
1438a13ecd7SRalf Baechle {
1444d2796f8SThomas Gleixner unsigned int bit = d->irq - CRIME_IRQ_BASE;
1458a13ecd7SRalf Baechle uint64_t crime_int;
1468a13ecd7SRalf Baechle
1478a13ecd7SRalf Baechle /* Edge triggered interrupts must be cleared. */
1488a13ecd7SRalf Baechle crime_int = crime->hard_int;
1498a13ecd7SRalf Baechle crime_int &= ~(1 << bit);
1508a13ecd7SRalf Baechle crime->hard_int = crime_int;
1518a13ecd7SRalf Baechle
1524d2796f8SThomas Gleixner crime_disable_irq(d);
1538a13ecd7SRalf Baechle }
1548a13ecd7SRalf Baechle
1558a13ecd7SRalf Baechle static struct irq_chip crime_edge_interrupt = {
1568a13ecd7SRalf Baechle .name = "IP32 CRIME",
1574d2796f8SThomas Gleixner .irq_ack = crime_edge_mask_and_ack_irq,
1584d2796f8SThomas Gleixner .irq_mask = crime_disable_irq,
1594d2796f8SThomas Gleixner .irq_mask_ack = crime_edge_mask_and_ack_irq,
1604d2796f8SThomas Gleixner .irq_unmask = crime_enable_irq,
1611da177e4SLinus Torvalds };
1621da177e4SLinus Torvalds
1631da177e4SLinus Torvalds /*
1641da177e4SLinus Torvalds * This is for MACE PCI interrupts. We can decrease bus traffic by masking
1651da177e4SLinus Torvalds * as close to the source as possible. This also means we can take the
1661da177e4SLinus Torvalds * next chunk of the CRIME register in one piece.
1671da177e4SLinus Torvalds */
1681da177e4SLinus Torvalds
1691da177e4SLinus Torvalds static unsigned long macepci_mask;
1701da177e4SLinus Torvalds
enable_macepci_irq(struct irq_data * d)1714d2796f8SThomas Gleixner static void enable_macepci_irq(struct irq_data *d)
1721da177e4SLinus Torvalds {
1734d2796f8SThomas Gleixner macepci_mask |= MACEPCI_CONTROL_INT(d->irq - MACEPCI_SCSI0_IRQ);
1741da177e4SLinus Torvalds mace->pci.control = macepci_mask;
1754d2796f8SThomas Gleixner crime_mask |= 1 << (d->irq - CRIME_IRQ_BASE);
1761da177e4SLinus Torvalds crime->imask = crime_mask;
1771da177e4SLinus Torvalds }
1781da177e4SLinus Torvalds
disable_macepci_irq(struct irq_data * d)1794d2796f8SThomas Gleixner static void disable_macepci_irq(struct irq_data *d)
1801da177e4SLinus Torvalds {
1814d2796f8SThomas Gleixner crime_mask &= ~(1 << (d->irq - CRIME_IRQ_BASE));
1821da177e4SLinus Torvalds crime->imask = crime_mask;
1831da177e4SLinus Torvalds flush_crime_bus();
1844d2796f8SThomas Gleixner macepci_mask &= ~MACEPCI_CONTROL_INT(d->irq - MACEPCI_SCSI0_IRQ);
1851da177e4SLinus Torvalds mace->pci.control = macepci_mask;
1861da177e4SLinus Torvalds flush_mace_bus();
1871da177e4SLinus Torvalds }
1881da177e4SLinus Torvalds
18994dee171SRalf Baechle static struct irq_chip ip32_macepci_interrupt = {
19070d21cdeSAtsushi Nemoto .name = "IP32 MACE PCI",
1914d2796f8SThomas Gleixner .irq_mask = disable_macepci_irq,
1924d2796f8SThomas Gleixner .irq_unmask = enable_macepci_irq,
1931da177e4SLinus Torvalds };
1941da177e4SLinus Torvalds
1951da177e4SLinus Torvalds /* This is used for MACE ISA interrupts. That means bits 4-6 in the
1961da177e4SLinus Torvalds * CRIME register.
1971da177e4SLinus Torvalds */
1981da177e4SLinus Torvalds
1991da177e4SLinus Torvalds #define MACEISA_AUDIO_INT (MACEISA_AUDIO_SW_INT | \
2001da177e4SLinus Torvalds MACEISA_AUDIO_SC_INT | \
2011da177e4SLinus Torvalds MACEISA_AUDIO1_DMAT_INT | \
2021da177e4SLinus Torvalds MACEISA_AUDIO1_OF_INT | \
2031da177e4SLinus Torvalds MACEISA_AUDIO2_DMAT_INT | \
2041da177e4SLinus Torvalds MACEISA_AUDIO2_MERR_INT | \
2051da177e4SLinus Torvalds MACEISA_AUDIO3_DMAT_INT | \
2061da177e4SLinus Torvalds MACEISA_AUDIO3_MERR_INT)
2071da177e4SLinus Torvalds #define MACEISA_MISC_INT (MACEISA_RTC_INT | \
2081da177e4SLinus Torvalds MACEISA_KEYB_INT | \
2091da177e4SLinus Torvalds MACEISA_KEYB_POLL_INT | \
2101da177e4SLinus Torvalds MACEISA_MOUSE_INT | \
2111da177e4SLinus Torvalds MACEISA_MOUSE_POLL_INT | \
212cfbae5d3SThiemo Seufer MACEISA_TIMER0_INT | \
213cfbae5d3SThiemo Seufer MACEISA_TIMER1_INT | \
214cfbae5d3SThiemo Seufer MACEISA_TIMER2_INT)
2151da177e4SLinus Torvalds #define MACEISA_SUPERIO_INT (MACEISA_PARALLEL_INT | \
2161da177e4SLinus Torvalds MACEISA_PAR_CTXA_INT | \
2171da177e4SLinus Torvalds MACEISA_PAR_CTXB_INT | \
2181da177e4SLinus Torvalds MACEISA_PAR_MERR_INT | \
2191da177e4SLinus Torvalds MACEISA_SERIAL1_INT | \
2201da177e4SLinus Torvalds MACEISA_SERIAL1_TDMAT_INT | \
2211da177e4SLinus Torvalds MACEISA_SERIAL1_TDMAPR_INT | \
2221da177e4SLinus Torvalds MACEISA_SERIAL1_TDMAME_INT | \
2231da177e4SLinus Torvalds MACEISA_SERIAL1_RDMAT_INT | \
2241da177e4SLinus Torvalds MACEISA_SERIAL1_RDMAOR_INT | \
2251da177e4SLinus Torvalds MACEISA_SERIAL2_INT | \
2261da177e4SLinus Torvalds MACEISA_SERIAL2_TDMAT_INT | \
2271da177e4SLinus Torvalds MACEISA_SERIAL2_TDMAPR_INT | \
2281da177e4SLinus Torvalds MACEISA_SERIAL2_TDMAME_INT | \
2291da177e4SLinus Torvalds MACEISA_SERIAL2_RDMAT_INT | \
2301da177e4SLinus Torvalds MACEISA_SERIAL2_RDMAOR_INT)
2311da177e4SLinus Torvalds
2321da177e4SLinus Torvalds static unsigned long maceisa_mask;
2331da177e4SLinus Torvalds
enable_maceisa_irq(struct irq_data * d)2344d2796f8SThomas Gleixner static void enable_maceisa_irq(struct irq_data *d)
2351da177e4SLinus Torvalds {
2361da177e4SLinus Torvalds unsigned int crime_int = 0;
2371da177e4SLinus Torvalds
2384d2796f8SThomas Gleixner pr_debug("maceisa enable: %u\n", d->irq);
2391da177e4SLinus Torvalds
2404d2796f8SThomas Gleixner switch (d->irq) {
2411da177e4SLinus Torvalds case MACEISA_AUDIO_SW_IRQ ... MACEISA_AUDIO3_MERR_IRQ:
2421da177e4SLinus Torvalds crime_int = MACE_AUDIO_INT;
2431da177e4SLinus Torvalds break;
244cfbae5d3SThiemo Seufer case MACEISA_RTC_IRQ ... MACEISA_TIMER2_IRQ:
2451da177e4SLinus Torvalds crime_int = MACE_MISC_INT;
2461da177e4SLinus Torvalds break;
2471da177e4SLinus Torvalds case MACEISA_PARALLEL_IRQ ... MACEISA_SERIAL2_RDMAOR_IRQ:
2481da177e4SLinus Torvalds crime_int = MACE_SUPERIO_INT;
2491da177e4SLinus Torvalds break;
2501da177e4SLinus Torvalds }
2518a13ecd7SRalf Baechle pr_debug("crime_int %08x enabled\n", crime_int);
2521da177e4SLinus Torvalds crime_mask |= crime_int;
2531da177e4SLinus Torvalds crime->imask = crime_mask;
2544d2796f8SThomas Gleixner maceisa_mask |= 1 << (d->irq - MACEISA_AUDIO_SW_IRQ);
2551da177e4SLinus Torvalds mace->perif.ctrl.imask = maceisa_mask;
2561da177e4SLinus Torvalds }
2571da177e4SLinus Torvalds
disable_maceisa_irq(struct irq_data * d)2584d2796f8SThomas Gleixner static void disable_maceisa_irq(struct irq_data *d)
2591da177e4SLinus Torvalds {
2601da177e4SLinus Torvalds unsigned int crime_int = 0;
2611da177e4SLinus Torvalds
2624d2796f8SThomas Gleixner maceisa_mask &= ~(1 << (d->irq - MACEISA_AUDIO_SW_IRQ));
2631da177e4SLinus Torvalds if (!(maceisa_mask & MACEISA_AUDIO_INT))
2641da177e4SLinus Torvalds crime_int |= MACE_AUDIO_INT;
2651da177e4SLinus Torvalds if (!(maceisa_mask & MACEISA_MISC_INT))
2661da177e4SLinus Torvalds crime_int |= MACE_MISC_INT;
2671da177e4SLinus Torvalds if (!(maceisa_mask & MACEISA_SUPERIO_INT))
2681da177e4SLinus Torvalds crime_int |= MACE_SUPERIO_INT;
2691da177e4SLinus Torvalds crime_mask &= ~crime_int;
2701da177e4SLinus Torvalds crime->imask = crime_mask;
2711da177e4SLinus Torvalds flush_crime_bus();
2721da177e4SLinus Torvalds mace->perif.ctrl.imask = maceisa_mask;
2731da177e4SLinus Torvalds flush_mace_bus();
2741da177e4SLinus Torvalds }
2751da177e4SLinus Torvalds
mask_and_ack_maceisa_irq(struct irq_data * d)2764d2796f8SThomas Gleixner static void mask_and_ack_maceisa_irq(struct irq_data *d)
2771da177e4SLinus Torvalds {
2781603b5acSAtsushi Nemoto unsigned long mace_int;
2791da177e4SLinus Torvalds
2801da177e4SLinus Torvalds /* edge triggered */
2811da177e4SLinus Torvalds mace_int = mace->perif.ctrl.istat;
2824d2796f8SThomas Gleixner mace_int &= ~(1 << (d->irq - MACEISA_AUDIO_SW_IRQ));
2831da177e4SLinus Torvalds mace->perif.ctrl.istat = mace_int;
284c87e0909SRalf Baechle
2854d2796f8SThomas Gleixner disable_maceisa_irq(d);
2861da177e4SLinus Torvalds }
2871da177e4SLinus Torvalds
288c87e0909SRalf Baechle static struct irq_chip ip32_maceisa_level_interrupt = {
289c87e0909SRalf Baechle .name = "IP32 MACE ISA",
2904d2796f8SThomas Gleixner .irq_mask = disable_maceisa_irq,
2914d2796f8SThomas Gleixner .irq_unmask = enable_maceisa_irq,
292c87e0909SRalf Baechle };
293c87e0909SRalf Baechle
294c87e0909SRalf Baechle static struct irq_chip ip32_maceisa_edge_interrupt = {
29570d21cdeSAtsushi Nemoto .name = "IP32 MACE ISA",
2964d2796f8SThomas Gleixner .irq_ack = mask_and_ack_maceisa_irq,
2974d2796f8SThomas Gleixner .irq_mask = disable_maceisa_irq,
2984d2796f8SThomas Gleixner .irq_mask_ack = mask_and_ack_maceisa_irq,
2994d2796f8SThomas Gleixner .irq_unmask = enable_maceisa_irq,
3001da177e4SLinus Torvalds };
3011da177e4SLinus Torvalds
3021da177e4SLinus Torvalds /* This is used for regular non-ISA, non-PCI MACE interrupts. That means
3031da177e4SLinus Torvalds * bits 0-3 and 7 in the CRIME register.
3041da177e4SLinus Torvalds */
3051da177e4SLinus Torvalds
enable_mace_irq(struct irq_data * d)3064d2796f8SThomas Gleixner static void enable_mace_irq(struct irq_data *d)
3071da177e4SLinus Torvalds {
3084d2796f8SThomas Gleixner unsigned int bit = d->irq - CRIME_IRQ_BASE;
30998ce4721SRalf Baechle
31098ce4721SRalf Baechle crime_mask |= (1 << bit);
3111da177e4SLinus Torvalds crime->imask = crime_mask;
3121da177e4SLinus Torvalds }
3131da177e4SLinus Torvalds
disable_mace_irq(struct irq_data * d)3144d2796f8SThomas Gleixner static void disable_mace_irq(struct irq_data *d)
3151da177e4SLinus Torvalds {
3164d2796f8SThomas Gleixner unsigned int bit = d->irq - CRIME_IRQ_BASE;
31798ce4721SRalf Baechle
31898ce4721SRalf Baechle crime_mask &= ~(1 << bit);
3191da177e4SLinus Torvalds crime->imask = crime_mask;
3201da177e4SLinus Torvalds flush_crime_bus();
3211da177e4SLinus Torvalds }
3221da177e4SLinus Torvalds
32394dee171SRalf Baechle static struct irq_chip ip32_mace_interrupt = {
32470d21cdeSAtsushi Nemoto .name = "IP32 MACE",
3254d2796f8SThomas Gleixner .irq_mask = disable_mace_irq,
3264d2796f8SThomas Gleixner .irq_unmask = enable_mace_irq,
3271da177e4SLinus Torvalds };
3281da177e4SLinus Torvalds
ip32_unknown_interrupt(void)329937a8015SRalf Baechle static void ip32_unknown_interrupt(void)
3301da177e4SLinus Torvalds {
3311da177e4SLinus Torvalds printk("Unknown interrupt occurred!\n");
3321da177e4SLinus Torvalds printk("cp0_status: %08x\n", read_c0_status());
3331da177e4SLinus Torvalds printk("cp0_cause: %08x\n", read_c0_cause());
3341da177e4SLinus Torvalds printk("CRIME intr mask: %016lx\n", crime->imask);
3351da177e4SLinus Torvalds printk("CRIME intr status: %016lx\n", crime->istat);
3361da177e4SLinus Torvalds printk("CRIME hardware intr register: %016lx\n", crime->hard_int);
3371da177e4SLinus Torvalds printk("MACE ISA intr mask: %08lx\n", mace->perif.ctrl.imask);
3381da177e4SLinus Torvalds printk("MACE ISA intr status: %08lx\n", mace->perif.ctrl.istat);
3391da177e4SLinus Torvalds printk("MACE PCI control register: %08x\n", mace->pci.control);
3401da177e4SLinus Torvalds
3411da177e4SLinus Torvalds printk("Register dump:\n");
342937a8015SRalf Baechle show_regs(get_irq_regs());
3431da177e4SLinus Torvalds
344057a14d6SLukas Bulwahn printk("Please mail this report to linux-mips@vger.kernel.org\n");
3451da177e4SLinus Torvalds printk("Spinning...");
3461da177e4SLinus Torvalds while(1) ;
3471da177e4SLinus Torvalds }
3481da177e4SLinus Torvalds
3491da177e4SLinus Torvalds /* CRIME 1.1 appears to deliver all interrupts to this one pin. */
3501da177e4SLinus Torvalds /* change this to loop over all edge-triggered irqs, exception masked out ones */
ip32_irq0(void)351937a8015SRalf Baechle static void ip32_irq0(void)
3521da177e4SLinus Torvalds {
3531da177e4SLinus Torvalds uint64_t crime_int;
3541da177e4SLinus Torvalds int irq = 0;
3551da177e4SLinus Torvalds
356dd67b155SRalf Baechle /*
357dd67b155SRalf Baechle * Sanity check interrupt numbering enum.
358dd67b155SRalf Baechle * MACE got 32 interrupts and there are 32 MACE ISA interrupts daisy
359dd67b155SRalf Baechle * chained.
360dd67b155SRalf Baechle */
361dd67b155SRalf Baechle BUILD_BUG_ON(CRIME_VICE_IRQ - MACE_VID_IN1_IRQ != 31);
362dd67b155SRalf Baechle BUILD_BUG_ON(MACEISA_SERIAL2_RDMAOR_IRQ - MACEISA_AUDIO_SW_IRQ != 31);
363dd67b155SRalf Baechle
3641da177e4SLinus Torvalds crime_int = crime->istat & crime_mask;
3651faf7f25SThomas Bogendoerfer
3661faf7f25SThomas Bogendoerfer /* crime sometime delivers spurious interrupts, ignore them */
3671faf7f25SThomas Bogendoerfer if (unlikely(crime_int == 0))
3681faf7f25SThomas Bogendoerfer return;
3691faf7f25SThomas Bogendoerfer
370dd67b155SRalf Baechle irq = MACE_VID_IN1_IRQ + __ffs(crime_int);
3711da177e4SLinus Torvalds
3721da177e4SLinus Torvalds if (crime_int & CRIME_MACEISA_INT_MASK) {
3731da177e4SLinus Torvalds unsigned long mace_int = mace->perif.ctrl.istat;
374dd67b155SRalf Baechle irq = __ffs(mace_int & maceisa_mask) + MACEISA_AUDIO_SW_IRQ;
3751da177e4SLinus Torvalds }
376dd67b155SRalf Baechle
3778a13ecd7SRalf Baechle pr_debug("*irq %u*\n", irq);
378937a8015SRalf Baechle do_IRQ(irq);
3791da177e4SLinus Torvalds }
3801da177e4SLinus Torvalds
ip32_irq1(void)381937a8015SRalf Baechle static void ip32_irq1(void)
3821da177e4SLinus Torvalds {
383937a8015SRalf Baechle ip32_unknown_interrupt();
3841da177e4SLinus Torvalds }
3851da177e4SLinus Torvalds
ip32_irq2(void)386937a8015SRalf Baechle static void ip32_irq2(void)
3871da177e4SLinus Torvalds {
388937a8015SRalf Baechle ip32_unknown_interrupt();
3891da177e4SLinus Torvalds }
3901da177e4SLinus Torvalds
ip32_irq3(void)391937a8015SRalf Baechle static void ip32_irq3(void)
3921da177e4SLinus Torvalds {
393937a8015SRalf Baechle ip32_unknown_interrupt();
3941da177e4SLinus Torvalds }
3951da177e4SLinus Torvalds
ip32_irq4(void)396937a8015SRalf Baechle static void ip32_irq4(void)
3971da177e4SLinus Torvalds {
398937a8015SRalf Baechle ip32_unknown_interrupt();
3991da177e4SLinus Torvalds }
4001da177e4SLinus Torvalds
ip32_irq5(void)401937a8015SRalf Baechle static void ip32_irq5(void)
4021da177e4SLinus Torvalds {
403dd67b155SRalf Baechle do_IRQ(MIPS_CPU_IRQ_BASE + 7);
4041da177e4SLinus Torvalds }
4051da177e4SLinus Torvalds
plat_irq_dispatch(void)406937a8015SRalf Baechle asmlinkage void plat_irq_dispatch(void)
407e4ac58afSRalf Baechle {
408119537c0SThiemo Seufer unsigned int pending = read_c0_status() & read_c0_cause();
409e4ac58afSRalf Baechle
410e4ac58afSRalf Baechle if (likely(pending & IE_IRQ0))
411937a8015SRalf Baechle ip32_irq0();
412e4ac58afSRalf Baechle else if (unlikely(pending & IE_IRQ1))
413937a8015SRalf Baechle ip32_irq1();
414e4ac58afSRalf Baechle else if (unlikely(pending & IE_IRQ2))
415937a8015SRalf Baechle ip32_irq2();
416e4ac58afSRalf Baechle else if (unlikely(pending & IE_IRQ3))
417937a8015SRalf Baechle ip32_irq3();
418e4ac58afSRalf Baechle else if (unlikely(pending & IE_IRQ4))
419937a8015SRalf Baechle ip32_irq4();
420e4ac58afSRalf Baechle else if (likely(pending & IE_IRQ5))
421937a8015SRalf Baechle ip32_irq5();
422e4ac58afSRalf Baechle }
423e4ac58afSRalf Baechle
arch_init_irq(void)4241da177e4SLinus Torvalds void __init arch_init_irq(void)
4251da177e4SLinus Torvalds {
4261da177e4SLinus Torvalds unsigned int irq;
4271da177e4SLinus Torvalds
4281da177e4SLinus Torvalds /* Install our interrupt handler, then clear and disable all
4291da177e4SLinus Torvalds * CRIME and MACE interrupts. */
4301da177e4SLinus Torvalds crime->imask = 0;
4311da177e4SLinus Torvalds crime->hard_int = 0;
4321da177e4SLinus Torvalds crime->soft_int = 0;
4331da177e4SLinus Torvalds mace->perif.ctrl.istat = 0;
4341da177e4SLinus Torvalds mace->perif.ctrl.imask = 0;
4351da177e4SLinus Torvalds
436dd67b155SRalf Baechle mips_cpu_irq_init();
43798ce4721SRalf Baechle for (irq = CRIME_IRQ_BASE; irq <= IP32_IRQ_MAX; irq++) {
438dd67b155SRalf Baechle switch (irq) {
439dd67b155SRalf Baechle case MACE_VID_IN1_IRQ ... MACE_PCI_BRIDGE_IRQ:
440e4ec7989SThomas Gleixner irq_set_chip_and_handler_name(irq,
441e4ec7989SThomas Gleixner &ip32_mace_interrupt,
442e4ec7989SThomas Gleixner handle_level_irq,
443e4ec7989SThomas Gleixner "level");
444dd67b155SRalf Baechle break;
445c87e0909SRalf Baechle
446dd67b155SRalf Baechle case MACEPCI_SCSI0_IRQ ... MACEPCI_SHARED2_IRQ:
447e4ec7989SThomas Gleixner irq_set_chip_and_handler_name(irq,
448e4ec7989SThomas Gleixner &ip32_macepci_interrupt,
449e4ec7989SThomas Gleixner handle_level_irq,
450c87e0909SRalf Baechle "level");
451dd67b155SRalf Baechle break;
452c87e0909SRalf Baechle
4538a13ecd7SRalf Baechle case CRIME_CPUERR_IRQ:
4548a13ecd7SRalf Baechle case CRIME_MEMERR_IRQ:
455e4ec7989SThomas Gleixner irq_set_chip_and_handler_name(irq,
456e4ec7989SThomas Gleixner &crime_level_interrupt,
457e4ec7989SThomas Gleixner handle_level_irq,
458c87e0909SRalf Baechle "level");
4598a13ecd7SRalf Baechle break;
460c87e0909SRalf Baechle
4612fe06260SRoel Kluin case CRIME_GBE0_IRQ ... CRIME_GBE3_IRQ:
4628a13ecd7SRalf Baechle case CRIME_RE_EMPTY_E_IRQ ... CRIME_RE_IDLE_E_IRQ:
4638a13ecd7SRalf Baechle case CRIME_SOFT0_IRQ ... CRIME_SOFT2_IRQ:
4648a13ecd7SRalf Baechle case CRIME_VICE_IRQ:
465e4ec7989SThomas Gleixner irq_set_chip_and_handler_name(irq,
466e4ec7989SThomas Gleixner &crime_edge_interrupt,
467e4ec7989SThomas Gleixner handle_edge_irq,
468e4ec7989SThomas Gleixner "edge");
469dd67b155SRalf Baechle break;
470c87e0909SRalf Baechle
471c87e0909SRalf Baechle case MACEISA_PARALLEL_IRQ:
472c87e0909SRalf Baechle case MACEISA_SERIAL1_TDMAPR_IRQ:
473c87e0909SRalf Baechle case MACEISA_SERIAL2_TDMAPR_IRQ:
474e4ec7989SThomas Gleixner irq_set_chip_and_handler_name(irq,
475e4ec7989SThomas Gleixner &ip32_maceisa_edge_interrupt,
476e4ec7989SThomas Gleixner handle_edge_irq,
477c87e0909SRalf Baechle "edge");
478c87e0909SRalf Baechle break;
479c87e0909SRalf Baechle
480dd67b155SRalf Baechle default:
481e4ec7989SThomas Gleixner irq_set_chip_and_handler_name(irq,
482e4ec7989SThomas Gleixner &ip32_maceisa_level_interrupt,
483e4ec7989SThomas Gleixner handle_level_irq,
484c87e0909SRalf Baechle "level");
4858a13ecd7SRalf Baechle break;
486dd67b155SRalf Baechle }
4871da177e4SLinus Torvalds }
488ac8fd122Safzal mohammed if (request_irq(CRIME_MEMERR_IRQ, crime_memerr_intr, 0,
489ac8fd122Safzal mohammed "CRIME memory error", NULL))
490ac8fd122Safzal mohammed pr_err("Failed to register CRIME memory error interrupt\n");
491ac8fd122Safzal mohammed if (request_irq(CRIME_CPUERR_IRQ, crime_cpuerr_intr, 0,
492ac8fd122Safzal mohammed "CRIME CPU error", NULL))
493ac8fd122Safzal mohammed pr_err("Failed to register CRIME CPU error interrupt\n");
4941da177e4SLinus Torvalds
4951da177e4SLinus Torvalds #define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5)
4961da177e4SLinus Torvalds change_c0_status(ST0_IM, ALLINTS);
4971da177e4SLinus Torvalds }
498