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> 211da177e4SLinus Torvalds 22dd67b155SRalf Baechle #include <asm/irq_cpu.h> 231da177e4SLinus Torvalds #include <asm/mipsregs.h> 241da177e4SLinus Torvalds #include <asm/signal.h> 251da177e4SLinus Torvalds #include <asm/system.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 311da177e4SLinus Torvalds /* issue a PIO read to make sure no PIO writes are pending */ 321da177e4SLinus Torvalds static void inline flush_crime_bus(void) 331da177e4SLinus Torvalds { 34b6d7c7a9SRalf Baechle crime->control; 351da177e4SLinus Torvalds } 361da177e4SLinus Torvalds 371da177e4SLinus Torvalds static void inline flush_mace_bus(void) 381da177e4SLinus Torvalds { 39b6d7c7a9SRalf Baechle mace->perif.ctrl.misc; 401da177e4SLinus Torvalds } 411da177e4SLinus Torvalds 42dd67b155SRalf Baechle /* 43dd67b155SRalf Baechle * O2 irq map 441da177e4SLinus Torvalds * 451da177e4SLinus Torvalds * IP0 -> software (ignored) 461da177e4SLinus Torvalds * IP1 -> software (ignored) 471da177e4SLinus Torvalds * IP2 -> (irq0) C crime 1.1 all interrupts; crime 1.5 ??? 481da177e4SLinus Torvalds * IP3 -> (irq1) X unknown 491da177e4SLinus Torvalds * IP4 -> (irq2) X unknown 501da177e4SLinus Torvalds * IP5 -> (irq3) X unknown 511da177e4SLinus Torvalds * IP6 -> (irq4) X unknown 52dd67b155SRalf Baechle * IP7 -> (irq5) 7 CPU count/compare timer (system timer) 531da177e4SLinus Torvalds * 541da177e4SLinus Torvalds * crime: (C) 551da177e4SLinus Torvalds * 561da177e4SLinus Torvalds * CRIME_INT_STAT 31:0: 571da177e4SLinus Torvalds * 58dd67b155SRalf Baechle * 0 -> 8 Video in 1 59dd67b155SRalf Baechle * 1 -> 9 Video in 2 60dd67b155SRalf Baechle * 2 -> 10 Video out 61dd67b155SRalf Baechle * 3 -> 11 Mace ethernet 621da177e4SLinus Torvalds * 4 -> S SuperIO sub-interrupt 631da177e4SLinus Torvalds * 5 -> M Miscellaneous sub-interrupt 641da177e4SLinus Torvalds * 6 -> A Audio sub-interrupt 65dd67b155SRalf Baechle * 7 -> 15 PCI bridge errors 66dd67b155SRalf Baechle * 8 -> 16 PCI SCSI aic7xxx 0 67dd67b155SRalf Baechle * 9 -> 17 PCI SCSI aic7xxx 1 68dd67b155SRalf Baechle * 10 -> 18 PCI slot 0 69dd67b155SRalf Baechle * 11 -> 19 unused (PCI slot 1) 70dd67b155SRalf Baechle * 12 -> 20 unused (PCI slot 2) 71dd67b155SRalf Baechle * 13 -> 21 unused (PCI shared 0) 72dd67b155SRalf Baechle * 14 -> 22 unused (PCI shared 1) 73dd67b155SRalf Baechle * 15 -> 23 unused (PCI shared 2) 74dd67b155SRalf Baechle * 16 -> 24 GBE0 (E) 75dd67b155SRalf Baechle * 17 -> 25 GBE1 (E) 76dd67b155SRalf Baechle * 18 -> 26 GBE2 (E) 77dd67b155SRalf Baechle * 19 -> 27 GBE3 (E) 78dd67b155SRalf Baechle * 20 -> 28 CPU errors 79dd67b155SRalf Baechle * 21 -> 29 Memory errors 80dd67b155SRalf Baechle * 22 -> 30 RE empty edge (E) 81dd67b155SRalf Baechle * 23 -> 31 RE full edge (E) 82dd67b155SRalf Baechle * 24 -> 32 RE idle edge (E) 83dd67b155SRalf Baechle * 25 -> 33 RE empty level 84dd67b155SRalf Baechle * 26 -> 34 RE full level 85dd67b155SRalf Baechle * 27 -> 35 RE idle level 86dd67b155SRalf Baechle * 28 -> 36 unused (software 0) (E) 87dd67b155SRalf Baechle * 29 -> 37 unused (software 1) (E) 88dd67b155SRalf Baechle * 30 -> 38 unused (software 2) - crime 1.5 CPU SysCorError (E) 89dd67b155SRalf Baechle * 31 -> 39 VICE 901da177e4SLinus Torvalds * 911da177e4SLinus Torvalds * S, M, A: Use the MACE ISA interrupt register 921da177e4SLinus Torvalds * MACE_ISA_INT_STAT 31:0 931da177e4SLinus Torvalds * 94dd67b155SRalf Baechle * 0-7 -> 40-47 Audio 95dd67b155SRalf Baechle * 8 -> 48 RTC 96dd67b155SRalf Baechle * 9 -> 49 Keyboard 971da177e4SLinus Torvalds * 10 -> X Keyboard polled 98dd67b155SRalf Baechle * 11 -> 51 Mouse 991da177e4SLinus Torvalds * 12 -> X Mouse polled 100dd67b155SRalf Baechle * 13-15 -> 53-55 Count/compare timers 101dd67b155SRalf Baechle * 16-19 -> 56-59 Parallel (16 E) 102dd67b155SRalf Baechle * 20-25 -> 60-62 Serial 1 (22 E) 103dd67b155SRalf Baechle * 26-31 -> 66-71 Serial 2 (28 E) 1041da177e4SLinus Torvalds * 105dd67b155SRalf Baechle * Note that this means IRQs 12-14, 50, and 52 do not exist. This is a 1061da177e4SLinus Torvalds * different IRQ map than IRIX uses, but that's OK as Linux irq handling 1071da177e4SLinus Torvalds * is quite different anyway. 1081da177e4SLinus Torvalds */ 1091da177e4SLinus Torvalds 1101da177e4SLinus Torvalds /* Some initial interrupts to set up */ 111937a8015SRalf Baechle extern irqreturn_t crime_memerr_intr(int irq, void *dev_id); 112937a8015SRalf Baechle extern irqreturn_t crime_cpuerr_intr(int irq, void *dev_id); 1131da177e4SLinus Torvalds 114ae537387SDmitri Vorobiev static struct irqaction memerr_irq = { 1154e45171cSThomas Gleixner .handler = crime_memerr_intr, 1164e45171cSThomas Gleixner .flags = IRQF_DISABLED, 1174e45171cSThomas Gleixner .name = "CRIME memory error", 1184e45171cSThomas Gleixner }; 1198a13ecd7SRalf Baechle 120ae537387SDmitri Vorobiev static struct irqaction cpuerr_irq = { 1214e45171cSThomas Gleixner .handler = crime_cpuerr_intr, 1224e45171cSThomas Gleixner .flags = IRQF_DISABLED, 1234e45171cSThomas Gleixner .name = "CRIME CPU error", 1244e45171cSThomas Gleixner }; 1251da177e4SLinus Torvalds 1261da177e4SLinus Torvalds /* 1271da177e4SLinus Torvalds * This is for pure CRIME interrupts - ie not MACE. The advantage? 1281da177e4SLinus Torvalds * We get to split the register in half and do faster lookups. 1291da177e4SLinus Torvalds */ 1301da177e4SLinus Torvalds 1311da177e4SLinus Torvalds static uint64_t crime_mask; 1321da177e4SLinus Torvalds 133*4d2796f8SThomas Gleixner static inline void crime_enable_irq(struct irq_data *d) 1341da177e4SLinus Torvalds { 135*4d2796f8SThomas Gleixner unsigned int bit = d->irq - CRIME_IRQ_BASE; 1368a13ecd7SRalf Baechle 1378a13ecd7SRalf Baechle crime_mask |= 1 << bit; 1381da177e4SLinus Torvalds crime->imask = crime_mask; 1391da177e4SLinus Torvalds } 1401da177e4SLinus Torvalds 141*4d2796f8SThomas Gleixner static inline void crime_disable_irq(struct irq_data *d) 1421da177e4SLinus Torvalds { 143*4d2796f8SThomas Gleixner unsigned int bit = d->irq - CRIME_IRQ_BASE; 1448a13ecd7SRalf Baechle 1458a13ecd7SRalf Baechle crime_mask &= ~(1 << bit); 1461da177e4SLinus Torvalds crime->imask = crime_mask; 1471da177e4SLinus Torvalds flush_crime_bus(); 1481da177e4SLinus Torvalds } 1491da177e4SLinus Torvalds 1508a13ecd7SRalf Baechle static struct irq_chip crime_level_interrupt = { 15170d21cdeSAtsushi Nemoto .name = "IP32 CRIME", 152*4d2796f8SThomas Gleixner .irq_mask = crime_disable_irq, 153*4d2796f8SThomas Gleixner .irq_unmask = crime_enable_irq, 1548a13ecd7SRalf Baechle }; 1558a13ecd7SRalf Baechle 156*4d2796f8SThomas Gleixner static void crime_edge_mask_and_ack_irq(struct irq_data *d) 1578a13ecd7SRalf Baechle { 158*4d2796f8SThomas Gleixner unsigned int bit = d->irq - CRIME_IRQ_BASE; 1598a13ecd7SRalf Baechle uint64_t crime_int; 1608a13ecd7SRalf Baechle 1618a13ecd7SRalf Baechle /* Edge triggered interrupts must be cleared. */ 1628a13ecd7SRalf Baechle crime_int = crime->hard_int; 1638a13ecd7SRalf Baechle crime_int &= ~(1 << bit); 1648a13ecd7SRalf Baechle crime->hard_int = crime_int; 1658a13ecd7SRalf Baechle 166*4d2796f8SThomas Gleixner crime_disable_irq(d); 1678a13ecd7SRalf Baechle } 1688a13ecd7SRalf Baechle 1698a13ecd7SRalf Baechle static struct irq_chip crime_edge_interrupt = { 1708a13ecd7SRalf Baechle .name = "IP32 CRIME", 171*4d2796f8SThomas Gleixner .irq_ack = crime_edge_mask_and_ack_irq, 172*4d2796f8SThomas Gleixner .irq_mask = crime_disable_irq, 173*4d2796f8SThomas Gleixner .irq_mask_ack = crime_edge_mask_and_ack_irq, 174*4d2796f8SThomas Gleixner .irq_unmask = crime_enable_irq, 1751da177e4SLinus Torvalds }; 1761da177e4SLinus Torvalds 1771da177e4SLinus Torvalds /* 1781da177e4SLinus Torvalds * This is for MACE PCI interrupts. We can decrease bus traffic by masking 1791da177e4SLinus Torvalds * as close to the source as possible. This also means we can take the 1801da177e4SLinus Torvalds * next chunk of the CRIME register in one piece. 1811da177e4SLinus Torvalds */ 1821da177e4SLinus Torvalds 1831da177e4SLinus Torvalds static unsigned long macepci_mask; 1841da177e4SLinus Torvalds 185*4d2796f8SThomas Gleixner static void enable_macepci_irq(struct irq_data *d) 1861da177e4SLinus Torvalds { 187*4d2796f8SThomas Gleixner macepci_mask |= MACEPCI_CONTROL_INT(d->irq - MACEPCI_SCSI0_IRQ); 1881da177e4SLinus Torvalds mace->pci.control = macepci_mask; 189*4d2796f8SThomas Gleixner crime_mask |= 1 << (d->irq - CRIME_IRQ_BASE); 1901da177e4SLinus Torvalds crime->imask = crime_mask; 1911da177e4SLinus Torvalds } 1921da177e4SLinus Torvalds 193*4d2796f8SThomas Gleixner static void disable_macepci_irq(struct irq_data *d) 1941da177e4SLinus Torvalds { 195*4d2796f8SThomas Gleixner crime_mask &= ~(1 << (d->irq - CRIME_IRQ_BASE)); 1961da177e4SLinus Torvalds crime->imask = crime_mask; 1971da177e4SLinus Torvalds flush_crime_bus(); 198*4d2796f8SThomas Gleixner macepci_mask &= ~MACEPCI_CONTROL_INT(d->irq - MACEPCI_SCSI0_IRQ); 1991da177e4SLinus Torvalds mace->pci.control = macepci_mask; 2001da177e4SLinus Torvalds flush_mace_bus(); 2011da177e4SLinus Torvalds } 2021da177e4SLinus Torvalds 20394dee171SRalf Baechle static struct irq_chip ip32_macepci_interrupt = { 20470d21cdeSAtsushi Nemoto .name = "IP32 MACE PCI", 205*4d2796f8SThomas Gleixner .irq_mask = disable_macepci_irq, 206*4d2796f8SThomas Gleixner .irq_unmask = enable_macepci_irq, 2071da177e4SLinus Torvalds }; 2081da177e4SLinus Torvalds 2091da177e4SLinus Torvalds /* This is used for MACE ISA interrupts. That means bits 4-6 in the 2101da177e4SLinus Torvalds * CRIME register. 2111da177e4SLinus Torvalds */ 2121da177e4SLinus Torvalds 2131da177e4SLinus Torvalds #define MACEISA_AUDIO_INT (MACEISA_AUDIO_SW_INT | \ 2141da177e4SLinus Torvalds MACEISA_AUDIO_SC_INT | \ 2151da177e4SLinus Torvalds MACEISA_AUDIO1_DMAT_INT | \ 2161da177e4SLinus Torvalds MACEISA_AUDIO1_OF_INT | \ 2171da177e4SLinus Torvalds MACEISA_AUDIO2_DMAT_INT | \ 2181da177e4SLinus Torvalds MACEISA_AUDIO2_MERR_INT | \ 2191da177e4SLinus Torvalds MACEISA_AUDIO3_DMAT_INT | \ 2201da177e4SLinus Torvalds MACEISA_AUDIO3_MERR_INT) 2211da177e4SLinus Torvalds #define MACEISA_MISC_INT (MACEISA_RTC_INT | \ 2221da177e4SLinus Torvalds MACEISA_KEYB_INT | \ 2231da177e4SLinus Torvalds MACEISA_KEYB_POLL_INT | \ 2241da177e4SLinus Torvalds MACEISA_MOUSE_INT | \ 2251da177e4SLinus Torvalds MACEISA_MOUSE_POLL_INT | \ 226cfbae5d3SThiemo Seufer MACEISA_TIMER0_INT | \ 227cfbae5d3SThiemo Seufer MACEISA_TIMER1_INT | \ 228cfbae5d3SThiemo Seufer MACEISA_TIMER2_INT) 2291da177e4SLinus Torvalds #define MACEISA_SUPERIO_INT (MACEISA_PARALLEL_INT | \ 2301da177e4SLinus Torvalds MACEISA_PAR_CTXA_INT | \ 2311da177e4SLinus Torvalds MACEISA_PAR_CTXB_INT | \ 2321da177e4SLinus Torvalds MACEISA_PAR_MERR_INT | \ 2331da177e4SLinus Torvalds MACEISA_SERIAL1_INT | \ 2341da177e4SLinus Torvalds MACEISA_SERIAL1_TDMAT_INT | \ 2351da177e4SLinus Torvalds MACEISA_SERIAL1_TDMAPR_INT | \ 2361da177e4SLinus Torvalds MACEISA_SERIAL1_TDMAME_INT | \ 2371da177e4SLinus Torvalds MACEISA_SERIAL1_RDMAT_INT | \ 2381da177e4SLinus Torvalds MACEISA_SERIAL1_RDMAOR_INT | \ 2391da177e4SLinus Torvalds MACEISA_SERIAL2_INT | \ 2401da177e4SLinus Torvalds MACEISA_SERIAL2_TDMAT_INT | \ 2411da177e4SLinus Torvalds MACEISA_SERIAL2_TDMAPR_INT | \ 2421da177e4SLinus Torvalds MACEISA_SERIAL2_TDMAME_INT | \ 2431da177e4SLinus Torvalds MACEISA_SERIAL2_RDMAT_INT | \ 2441da177e4SLinus Torvalds MACEISA_SERIAL2_RDMAOR_INT) 2451da177e4SLinus Torvalds 2461da177e4SLinus Torvalds static unsigned long maceisa_mask; 2471da177e4SLinus Torvalds 248*4d2796f8SThomas Gleixner static void enable_maceisa_irq(struct irq_data *d) 2491da177e4SLinus Torvalds { 2501da177e4SLinus Torvalds unsigned int crime_int = 0; 2511da177e4SLinus Torvalds 252*4d2796f8SThomas Gleixner pr_debug("maceisa enable: %u\n", d->irq); 2531da177e4SLinus Torvalds 254*4d2796f8SThomas Gleixner switch (d->irq) { 2551da177e4SLinus Torvalds case MACEISA_AUDIO_SW_IRQ ... MACEISA_AUDIO3_MERR_IRQ: 2561da177e4SLinus Torvalds crime_int = MACE_AUDIO_INT; 2571da177e4SLinus Torvalds break; 258cfbae5d3SThiemo Seufer case MACEISA_RTC_IRQ ... MACEISA_TIMER2_IRQ: 2591da177e4SLinus Torvalds crime_int = MACE_MISC_INT; 2601da177e4SLinus Torvalds break; 2611da177e4SLinus Torvalds case MACEISA_PARALLEL_IRQ ... MACEISA_SERIAL2_RDMAOR_IRQ: 2621da177e4SLinus Torvalds crime_int = MACE_SUPERIO_INT; 2631da177e4SLinus Torvalds break; 2641da177e4SLinus Torvalds } 2658a13ecd7SRalf Baechle pr_debug("crime_int %08x enabled\n", crime_int); 2661da177e4SLinus Torvalds crime_mask |= crime_int; 2671da177e4SLinus Torvalds crime->imask = crime_mask; 268*4d2796f8SThomas Gleixner maceisa_mask |= 1 << (d->irq - MACEISA_AUDIO_SW_IRQ); 2691da177e4SLinus Torvalds mace->perif.ctrl.imask = maceisa_mask; 2701da177e4SLinus Torvalds } 2711da177e4SLinus Torvalds 272*4d2796f8SThomas Gleixner static void disable_maceisa_irq(struct irq_data *d) 2731da177e4SLinus Torvalds { 2741da177e4SLinus Torvalds unsigned int crime_int = 0; 2751da177e4SLinus Torvalds 276*4d2796f8SThomas Gleixner maceisa_mask &= ~(1 << (d->irq - MACEISA_AUDIO_SW_IRQ)); 2771da177e4SLinus Torvalds if (!(maceisa_mask & MACEISA_AUDIO_INT)) 2781da177e4SLinus Torvalds crime_int |= MACE_AUDIO_INT; 2791da177e4SLinus Torvalds if (!(maceisa_mask & MACEISA_MISC_INT)) 2801da177e4SLinus Torvalds crime_int |= MACE_MISC_INT; 2811da177e4SLinus Torvalds if (!(maceisa_mask & MACEISA_SUPERIO_INT)) 2821da177e4SLinus Torvalds crime_int |= MACE_SUPERIO_INT; 2831da177e4SLinus Torvalds crime_mask &= ~crime_int; 2841da177e4SLinus Torvalds crime->imask = crime_mask; 2851da177e4SLinus Torvalds flush_crime_bus(); 2861da177e4SLinus Torvalds mace->perif.ctrl.imask = maceisa_mask; 2871da177e4SLinus Torvalds flush_mace_bus(); 2881da177e4SLinus Torvalds } 2891da177e4SLinus Torvalds 290*4d2796f8SThomas Gleixner static void mask_and_ack_maceisa_irq(struct irq_data *d) 2911da177e4SLinus Torvalds { 2921603b5acSAtsushi Nemoto unsigned long mace_int; 2931da177e4SLinus Torvalds 2941da177e4SLinus Torvalds /* edge triggered */ 2951da177e4SLinus Torvalds mace_int = mace->perif.ctrl.istat; 296*4d2796f8SThomas Gleixner mace_int &= ~(1 << (d->irq - MACEISA_AUDIO_SW_IRQ)); 2971da177e4SLinus Torvalds mace->perif.ctrl.istat = mace_int; 298c87e0909SRalf Baechle 299*4d2796f8SThomas Gleixner disable_maceisa_irq(d); 3001da177e4SLinus Torvalds } 3011da177e4SLinus Torvalds 302c87e0909SRalf Baechle static struct irq_chip ip32_maceisa_level_interrupt = { 303c87e0909SRalf Baechle .name = "IP32 MACE ISA", 304*4d2796f8SThomas Gleixner .irq_mask = disable_maceisa_irq, 305*4d2796f8SThomas Gleixner .irq_unmask = enable_maceisa_irq, 306c87e0909SRalf Baechle }; 307c87e0909SRalf Baechle 308c87e0909SRalf Baechle static struct irq_chip ip32_maceisa_edge_interrupt = { 30970d21cdeSAtsushi Nemoto .name = "IP32 MACE ISA", 310*4d2796f8SThomas Gleixner .irq_ack = mask_and_ack_maceisa_irq, 311*4d2796f8SThomas Gleixner .irq_mask = disable_maceisa_irq, 312*4d2796f8SThomas Gleixner .irq_mask_ack = mask_and_ack_maceisa_irq, 313*4d2796f8SThomas Gleixner .irq_unmask = enable_maceisa_irq, 3141da177e4SLinus Torvalds }; 3151da177e4SLinus Torvalds 3161da177e4SLinus Torvalds /* This is used for regular non-ISA, non-PCI MACE interrupts. That means 3171da177e4SLinus Torvalds * bits 0-3 and 7 in the CRIME register. 3181da177e4SLinus Torvalds */ 3191da177e4SLinus Torvalds 320*4d2796f8SThomas Gleixner static void enable_mace_irq(struct irq_data *d) 3211da177e4SLinus Torvalds { 322*4d2796f8SThomas Gleixner unsigned int bit = d->irq - CRIME_IRQ_BASE; 32398ce4721SRalf Baechle 32498ce4721SRalf Baechle crime_mask |= (1 << bit); 3251da177e4SLinus Torvalds crime->imask = crime_mask; 3261da177e4SLinus Torvalds } 3271da177e4SLinus Torvalds 328*4d2796f8SThomas Gleixner static void disable_mace_irq(struct irq_data *d) 3291da177e4SLinus Torvalds { 330*4d2796f8SThomas Gleixner unsigned int bit = d->irq - CRIME_IRQ_BASE; 33198ce4721SRalf Baechle 33298ce4721SRalf Baechle crime_mask &= ~(1 << bit); 3331da177e4SLinus Torvalds crime->imask = crime_mask; 3341da177e4SLinus Torvalds flush_crime_bus(); 3351da177e4SLinus Torvalds } 3361da177e4SLinus Torvalds 33794dee171SRalf Baechle static struct irq_chip ip32_mace_interrupt = { 33870d21cdeSAtsushi Nemoto .name = "IP32 MACE", 339*4d2796f8SThomas Gleixner .irq_mask = disable_mace_irq, 340*4d2796f8SThomas Gleixner .irq_unmask = enable_mace_irq, 3411da177e4SLinus Torvalds }; 3421da177e4SLinus Torvalds 343937a8015SRalf Baechle static void ip32_unknown_interrupt(void) 3441da177e4SLinus Torvalds { 3451da177e4SLinus Torvalds printk("Unknown interrupt occurred!\n"); 3461da177e4SLinus Torvalds printk("cp0_status: %08x\n", read_c0_status()); 3471da177e4SLinus Torvalds printk("cp0_cause: %08x\n", read_c0_cause()); 3481da177e4SLinus Torvalds printk("CRIME intr mask: %016lx\n", crime->imask); 3491da177e4SLinus Torvalds printk("CRIME intr status: %016lx\n", crime->istat); 3501da177e4SLinus Torvalds printk("CRIME hardware intr register: %016lx\n", crime->hard_int); 3511da177e4SLinus Torvalds printk("MACE ISA intr mask: %08lx\n", mace->perif.ctrl.imask); 3521da177e4SLinus Torvalds printk("MACE ISA intr status: %08lx\n", mace->perif.ctrl.istat); 3531da177e4SLinus Torvalds printk("MACE PCI control register: %08x\n", mace->pci.control); 3541da177e4SLinus Torvalds 3551da177e4SLinus Torvalds printk("Register dump:\n"); 356937a8015SRalf Baechle show_regs(get_irq_regs()); 3571da177e4SLinus Torvalds 3581da177e4SLinus Torvalds printk("Please mail this report to linux-mips@linux-mips.org\n"); 3591da177e4SLinus Torvalds printk("Spinning..."); 3601da177e4SLinus Torvalds while(1) ; 3611da177e4SLinus Torvalds } 3621da177e4SLinus Torvalds 3631da177e4SLinus Torvalds /* CRIME 1.1 appears to deliver all interrupts to this one pin. */ 3641da177e4SLinus Torvalds /* change this to loop over all edge-triggered irqs, exception masked out ones */ 365937a8015SRalf Baechle static void ip32_irq0(void) 3661da177e4SLinus Torvalds { 3671da177e4SLinus Torvalds uint64_t crime_int; 3681da177e4SLinus Torvalds int irq = 0; 3691da177e4SLinus Torvalds 370dd67b155SRalf Baechle /* 371dd67b155SRalf Baechle * Sanity check interrupt numbering enum. 372dd67b155SRalf Baechle * MACE got 32 interrupts and there are 32 MACE ISA interrupts daisy 373dd67b155SRalf Baechle * chained. 374dd67b155SRalf Baechle */ 375dd67b155SRalf Baechle BUILD_BUG_ON(CRIME_VICE_IRQ - MACE_VID_IN1_IRQ != 31); 376dd67b155SRalf Baechle BUILD_BUG_ON(MACEISA_SERIAL2_RDMAOR_IRQ - MACEISA_AUDIO_SW_IRQ != 31); 377dd67b155SRalf Baechle 3781da177e4SLinus Torvalds crime_int = crime->istat & crime_mask; 3791faf7f25SThomas Bogendoerfer 3801faf7f25SThomas Bogendoerfer /* crime sometime delivers spurious interrupts, ignore them */ 3811faf7f25SThomas Bogendoerfer if (unlikely(crime_int == 0)) 3821faf7f25SThomas Bogendoerfer return; 3831faf7f25SThomas Bogendoerfer 384dd67b155SRalf Baechle irq = MACE_VID_IN1_IRQ + __ffs(crime_int); 3851da177e4SLinus Torvalds 3861da177e4SLinus Torvalds if (crime_int & CRIME_MACEISA_INT_MASK) { 3871da177e4SLinus Torvalds unsigned long mace_int = mace->perif.ctrl.istat; 388dd67b155SRalf Baechle irq = __ffs(mace_int & maceisa_mask) + MACEISA_AUDIO_SW_IRQ; 3891da177e4SLinus Torvalds } 390dd67b155SRalf Baechle 3918a13ecd7SRalf Baechle pr_debug("*irq %u*\n", irq); 392937a8015SRalf Baechle do_IRQ(irq); 3931da177e4SLinus Torvalds } 3941da177e4SLinus Torvalds 395937a8015SRalf Baechle static void ip32_irq1(void) 3961da177e4SLinus Torvalds { 397937a8015SRalf Baechle ip32_unknown_interrupt(); 3981da177e4SLinus Torvalds } 3991da177e4SLinus Torvalds 400937a8015SRalf Baechle static void ip32_irq2(void) 4011da177e4SLinus Torvalds { 402937a8015SRalf Baechle ip32_unknown_interrupt(); 4031da177e4SLinus Torvalds } 4041da177e4SLinus Torvalds 405937a8015SRalf Baechle static void ip32_irq3(void) 4061da177e4SLinus Torvalds { 407937a8015SRalf Baechle ip32_unknown_interrupt(); 4081da177e4SLinus Torvalds } 4091da177e4SLinus Torvalds 410937a8015SRalf Baechle static void ip32_irq4(void) 4111da177e4SLinus Torvalds { 412937a8015SRalf Baechle ip32_unknown_interrupt(); 4131da177e4SLinus Torvalds } 4141da177e4SLinus Torvalds 415937a8015SRalf Baechle static void ip32_irq5(void) 4161da177e4SLinus Torvalds { 417dd67b155SRalf Baechle do_IRQ(MIPS_CPU_IRQ_BASE + 7); 4181da177e4SLinus Torvalds } 4191da177e4SLinus Torvalds 420937a8015SRalf Baechle asmlinkage void plat_irq_dispatch(void) 421e4ac58afSRalf Baechle { 422119537c0SThiemo Seufer unsigned int pending = read_c0_status() & read_c0_cause(); 423e4ac58afSRalf Baechle 424e4ac58afSRalf Baechle if (likely(pending & IE_IRQ0)) 425937a8015SRalf Baechle ip32_irq0(); 426e4ac58afSRalf Baechle else if (unlikely(pending & IE_IRQ1)) 427937a8015SRalf Baechle ip32_irq1(); 428e4ac58afSRalf Baechle else if (unlikely(pending & IE_IRQ2)) 429937a8015SRalf Baechle ip32_irq2(); 430e4ac58afSRalf Baechle else if (unlikely(pending & IE_IRQ3)) 431937a8015SRalf Baechle ip32_irq3(); 432e4ac58afSRalf Baechle else if (unlikely(pending & IE_IRQ4)) 433937a8015SRalf Baechle ip32_irq4(); 434e4ac58afSRalf Baechle else if (likely(pending & IE_IRQ5)) 435937a8015SRalf Baechle ip32_irq5(); 436e4ac58afSRalf Baechle } 437e4ac58afSRalf Baechle 4381da177e4SLinus Torvalds void __init arch_init_irq(void) 4391da177e4SLinus Torvalds { 4401da177e4SLinus Torvalds unsigned int irq; 4411da177e4SLinus Torvalds 4421da177e4SLinus Torvalds /* Install our interrupt handler, then clear and disable all 4431da177e4SLinus Torvalds * CRIME and MACE interrupts. */ 4441da177e4SLinus Torvalds crime->imask = 0; 4451da177e4SLinus Torvalds crime->hard_int = 0; 4461da177e4SLinus Torvalds crime->soft_int = 0; 4471da177e4SLinus Torvalds mace->perif.ctrl.istat = 0; 4481da177e4SLinus Torvalds mace->perif.ctrl.imask = 0; 4491da177e4SLinus Torvalds 450dd67b155SRalf Baechle mips_cpu_irq_init(); 45198ce4721SRalf Baechle for (irq = CRIME_IRQ_BASE; irq <= IP32_IRQ_MAX; irq++) { 452dd67b155SRalf Baechle switch (irq) { 453dd67b155SRalf Baechle case MACE_VID_IN1_IRQ ... MACE_PCI_BRIDGE_IRQ: 454c87e0909SRalf Baechle set_irq_chip_and_handler_name(irq,&ip32_mace_interrupt, 455c87e0909SRalf Baechle handle_level_irq, "level"); 456dd67b155SRalf Baechle break; 457c87e0909SRalf Baechle 458dd67b155SRalf Baechle case MACEPCI_SCSI0_IRQ ... MACEPCI_SHARED2_IRQ: 459c87e0909SRalf Baechle set_irq_chip_and_handler_name(irq, 460c87e0909SRalf Baechle &ip32_macepci_interrupt, handle_level_irq, 461c87e0909SRalf Baechle "level"); 462dd67b155SRalf Baechle break; 463c87e0909SRalf Baechle 4648a13ecd7SRalf Baechle case CRIME_CPUERR_IRQ: 4658a13ecd7SRalf Baechle case CRIME_MEMERR_IRQ: 466c87e0909SRalf Baechle set_irq_chip_and_handler_name(irq, 467c87e0909SRalf Baechle &crime_level_interrupt, handle_level_irq, 468c87e0909SRalf Baechle "level"); 4698a13ecd7SRalf Baechle break; 470c87e0909SRalf Baechle 4712fe06260SRoel Kluin case CRIME_GBE0_IRQ ... CRIME_GBE3_IRQ: 4728a13ecd7SRalf Baechle case CRIME_RE_EMPTY_E_IRQ ... CRIME_RE_IDLE_E_IRQ: 4738a13ecd7SRalf Baechle case CRIME_SOFT0_IRQ ... CRIME_SOFT2_IRQ: 4748a13ecd7SRalf Baechle case CRIME_VICE_IRQ: 475c87e0909SRalf Baechle set_irq_chip_and_handler_name(irq, 476c87e0909SRalf Baechle &crime_edge_interrupt, handle_edge_irq, "edge"); 477dd67b155SRalf Baechle break; 478c87e0909SRalf Baechle 479c87e0909SRalf Baechle case MACEISA_PARALLEL_IRQ: 480c87e0909SRalf Baechle case MACEISA_SERIAL1_TDMAPR_IRQ: 481c87e0909SRalf Baechle case MACEISA_SERIAL2_TDMAPR_IRQ: 482c87e0909SRalf Baechle set_irq_chip_and_handler_name(irq, 483c87e0909SRalf Baechle &ip32_maceisa_edge_interrupt, handle_edge_irq, 484c87e0909SRalf Baechle "edge"); 485c87e0909SRalf Baechle break; 486c87e0909SRalf Baechle 487dd67b155SRalf Baechle default: 488c87e0909SRalf Baechle set_irq_chip_and_handler_name(irq, 489c87e0909SRalf Baechle &ip32_maceisa_level_interrupt, handle_level_irq, 490c87e0909SRalf Baechle "level"); 4918a13ecd7SRalf Baechle break; 492dd67b155SRalf Baechle } 4931da177e4SLinus Torvalds } 4941da177e4SLinus Torvalds setup_irq(CRIME_MEMERR_IRQ, &memerr_irq); 4951da177e4SLinus Torvalds setup_irq(CRIME_CPUERR_IRQ, &cpuerr_irq); 4961da177e4SLinus Torvalds 4971da177e4SLinus Torvalds #define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5) 4981da177e4SLinus Torvalds change_c0_status(ST0_IM, ALLINTS); 4991da177e4SLinus Torvalds } 500