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/slab.h> 191da177e4SLinus Torvalds #include <linux/mm.h> 201da177e4SLinus Torvalds #include <linux/random.h> 211da177e4SLinus Torvalds #include <linux/sched.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/system.h> 271da177e4SLinus Torvalds #include <asm/time.h> 281da177e4SLinus Torvalds #include <asm/ip32/crime.h> 291da177e4SLinus Torvalds #include <asm/ip32/mace.h> 301da177e4SLinus Torvalds #include <asm/ip32/ip32_ints.h> 311da177e4SLinus Torvalds 321da177e4SLinus Torvalds /* issue a PIO read to make sure no PIO writes are pending */ 331da177e4SLinus Torvalds static void inline flush_crime_bus(void) 341da177e4SLinus Torvalds { 35b6d7c7a9SRalf Baechle crime->control; 361da177e4SLinus Torvalds } 371da177e4SLinus Torvalds 381da177e4SLinus Torvalds static void inline flush_mace_bus(void) 391da177e4SLinus Torvalds { 40b6d7c7a9SRalf Baechle mace->perif.ctrl.misc; 411da177e4SLinus Torvalds } 421da177e4SLinus Torvalds 43dd67b155SRalf Baechle /* 44dd67b155SRalf Baechle * O2 irq map 451da177e4SLinus Torvalds * 461da177e4SLinus Torvalds * IP0 -> software (ignored) 471da177e4SLinus Torvalds * IP1 -> software (ignored) 481da177e4SLinus Torvalds * IP2 -> (irq0) C crime 1.1 all interrupts; crime 1.5 ??? 491da177e4SLinus Torvalds * IP3 -> (irq1) X unknown 501da177e4SLinus Torvalds * IP4 -> (irq2) X unknown 511da177e4SLinus Torvalds * IP5 -> (irq3) X unknown 521da177e4SLinus Torvalds * IP6 -> (irq4) X unknown 53dd67b155SRalf Baechle * IP7 -> (irq5) 7 CPU count/compare timer (system timer) 541da177e4SLinus Torvalds * 551da177e4SLinus Torvalds * crime: (C) 561da177e4SLinus Torvalds * 571da177e4SLinus Torvalds * CRIME_INT_STAT 31:0: 581da177e4SLinus Torvalds * 59dd67b155SRalf Baechle * 0 -> 8 Video in 1 60dd67b155SRalf Baechle * 1 -> 9 Video in 2 61dd67b155SRalf Baechle * 2 -> 10 Video out 62dd67b155SRalf Baechle * 3 -> 11 Mace ethernet 631da177e4SLinus Torvalds * 4 -> S SuperIO sub-interrupt 641da177e4SLinus Torvalds * 5 -> M Miscellaneous sub-interrupt 651da177e4SLinus Torvalds * 6 -> A Audio sub-interrupt 66dd67b155SRalf Baechle * 7 -> 15 PCI bridge errors 67dd67b155SRalf Baechle * 8 -> 16 PCI SCSI aic7xxx 0 68dd67b155SRalf Baechle * 9 -> 17 PCI SCSI aic7xxx 1 69dd67b155SRalf Baechle * 10 -> 18 PCI slot 0 70dd67b155SRalf Baechle * 11 -> 19 unused (PCI slot 1) 71dd67b155SRalf Baechle * 12 -> 20 unused (PCI slot 2) 72dd67b155SRalf Baechle * 13 -> 21 unused (PCI shared 0) 73dd67b155SRalf Baechle * 14 -> 22 unused (PCI shared 1) 74dd67b155SRalf Baechle * 15 -> 23 unused (PCI shared 2) 75dd67b155SRalf Baechle * 16 -> 24 GBE0 (E) 76dd67b155SRalf Baechle * 17 -> 25 GBE1 (E) 77dd67b155SRalf Baechle * 18 -> 26 GBE2 (E) 78dd67b155SRalf Baechle * 19 -> 27 GBE3 (E) 79dd67b155SRalf Baechle * 20 -> 28 CPU errors 80dd67b155SRalf Baechle * 21 -> 29 Memory errors 81dd67b155SRalf Baechle * 22 -> 30 RE empty edge (E) 82dd67b155SRalf Baechle * 23 -> 31 RE full edge (E) 83dd67b155SRalf Baechle * 24 -> 32 RE idle edge (E) 84dd67b155SRalf Baechle * 25 -> 33 RE empty level 85dd67b155SRalf Baechle * 26 -> 34 RE full level 86dd67b155SRalf Baechle * 27 -> 35 RE idle level 87dd67b155SRalf Baechle * 28 -> 36 unused (software 0) (E) 88dd67b155SRalf Baechle * 29 -> 37 unused (software 1) (E) 89dd67b155SRalf Baechle * 30 -> 38 unused (software 2) - crime 1.5 CPU SysCorError (E) 90dd67b155SRalf Baechle * 31 -> 39 VICE 911da177e4SLinus Torvalds * 921da177e4SLinus Torvalds * S, M, A: Use the MACE ISA interrupt register 931da177e4SLinus Torvalds * MACE_ISA_INT_STAT 31:0 941da177e4SLinus Torvalds * 95dd67b155SRalf Baechle * 0-7 -> 40-47 Audio 96dd67b155SRalf Baechle * 8 -> 48 RTC 97dd67b155SRalf Baechle * 9 -> 49 Keyboard 981da177e4SLinus Torvalds * 10 -> X Keyboard polled 99dd67b155SRalf Baechle * 11 -> 51 Mouse 1001da177e4SLinus Torvalds * 12 -> X Mouse polled 101dd67b155SRalf Baechle * 13-15 -> 53-55 Count/compare timers 102dd67b155SRalf Baechle * 16-19 -> 56-59 Parallel (16 E) 103dd67b155SRalf Baechle * 20-25 -> 60-62 Serial 1 (22 E) 104dd67b155SRalf Baechle * 26-31 -> 66-71 Serial 2 (28 E) 1051da177e4SLinus Torvalds * 106dd67b155SRalf Baechle * Note that this means IRQs 12-14, 50, and 52 do not exist. This is a 1071da177e4SLinus Torvalds * different IRQ map than IRIX uses, but that's OK as Linux irq handling 1081da177e4SLinus Torvalds * is quite different anyway. 1091da177e4SLinus Torvalds */ 1101da177e4SLinus Torvalds 1111da177e4SLinus Torvalds /* Some initial interrupts to set up */ 112937a8015SRalf Baechle extern irqreturn_t crime_memerr_intr(int irq, void *dev_id); 113937a8015SRalf Baechle extern irqreturn_t crime_cpuerr_intr(int irq, void *dev_id); 1141da177e4SLinus Torvalds 1154e45171cSThomas Gleixner struct irqaction memerr_irq = { 1164e45171cSThomas Gleixner .handler = crime_memerr_intr, 1174e45171cSThomas Gleixner .flags = IRQF_DISABLED, 1184e45171cSThomas Gleixner .mask = CPU_MASK_NONE, 1194e45171cSThomas Gleixner .name = "CRIME memory error", 1204e45171cSThomas Gleixner }; 1218a13ecd7SRalf Baechle 1224e45171cSThomas Gleixner struct irqaction cpuerr_irq = { 1234e45171cSThomas Gleixner .handler = crime_cpuerr_intr, 1244e45171cSThomas Gleixner .flags = IRQF_DISABLED, 1254e45171cSThomas Gleixner .mask = CPU_MASK_NONE, 1264e45171cSThomas Gleixner .name = "CRIME CPU error", 1274e45171cSThomas Gleixner }; 1281da177e4SLinus Torvalds 1291da177e4SLinus Torvalds /* 1301da177e4SLinus Torvalds * This is for pure CRIME interrupts - ie not MACE. The advantage? 1311da177e4SLinus Torvalds * We get to split the register in half and do faster lookups. 1321da177e4SLinus Torvalds */ 1331da177e4SLinus Torvalds 1341da177e4SLinus Torvalds static uint64_t crime_mask; 1351da177e4SLinus Torvalds 1368a13ecd7SRalf Baechle static inline void crime_enable_irq(unsigned int irq) 1371da177e4SLinus Torvalds { 1388a13ecd7SRalf Baechle unsigned int bit = irq - CRIME_IRQ_BASE; 1398a13ecd7SRalf Baechle 1408a13ecd7SRalf Baechle crime_mask |= 1 << bit; 1411da177e4SLinus Torvalds crime->imask = crime_mask; 1421da177e4SLinus Torvalds } 1431da177e4SLinus Torvalds 1448a13ecd7SRalf Baechle static inline void crime_disable_irq(unsigned int irq) 1451da177e4SLinus Torvalds { 1468a13ecd7SRalf Baechle unsigned int bit = irq - CRIME_IRQ_BASE; 1478a13ecd7SRalf Baechle 1488a13ecd7SRalf Baechle crime_mask &= ~(1 << bit); 1491da177e4SLinus Torvalds crime->imask = crime_mask; 1501da177e4SLinus Torvalds flush_crime_bus(); 1511da177e4SLinus Torvalds } 1521da177e4SLinus Torvalds 1538a13ecd7SRalf Baechle static void crime_level_mask_and_ack_irq(unsigned int irq) 1541da177e4SLinus Torvalds { 1558a13ecd7SRalf Baechle crime_disable_irq(irq); 1561da177e4SLinus Torvalds } 1571da177e4SLinus Torvalds 1588a13ecd7SRalf Baechle static void crime_level_end_irq(unsigned int irq) 1591da177e4SLinus Torvalds { 1601da177e4SLinus Torvalds if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) 1618a13ecd7SRalf Baechle crime_enable_irq(irq); 1621da177e4SLinus Torvalds } 1631da177e4SLinus Torvalds 1648a13ecd7SRalf Baechle static struct irq_chip crime_level_interrupt = { 16570d21cdeSAtsushi Nemoto .name = "IP32 CRIME", 1668a13ecd7SRalf Baechle .ack = crime_level_mask_and_ack_irq, 1678a13ecd7SRalf Baechle .mask = crime_disable_irq, 1688a13ecd7SRalf Baechle .mask_ack = crime_level_mask_and_ack_irq, 1698a13ecd7SRalf Baechle .unmask = crime_enable_irq, 1708a13ecd7SRalf Baechle .end = crime_level_end_irq, 1718a13ecd7SRalf Baechle }; 1728a13ecd7SRalf Baechle 1738a13ecd7SRalf Baechle static void crime_edge_mask_and_ack_irq(unsigned int irq) 1748a13ecd7SRalf Baechle { 1758a13ecd7SRalf Baechle unsigned int bit = irq - CRIME_IRQ_BASE; 1768a13ecd7SRalf Baechle uint64_t crime_int; 1778a13ecd7SRalf Baechle 1788a13ecd7SRalf Baechle /* Edge triggered interrupts must be cleared. */ 1798a13ecd7SRalf Baechle 1808a13ecd7SRalf Baechle crime_int = crime->hard_int; 1818a13ecd7SRalf Baechle crime_int &= ~(1 << bit); 1828a13ecd7SRalf Baechle crime->hard_int = crime_int; 1838a13ecd7SRalf Baechle 1848a13ecd7SRalf Baechle crime_disable_irq(irq); 1858a13ecd7SRalf Baechle } 1868a13ecd7SRalf Baechle 1878a13ecd7SRalf Baechle static void crime_edge_end_irq(unsigned int irq) 1888a13ecd7SRalf Baechle { 1898a13ecd7SRalf Baechle if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) 1908a13ecd7SRalf Baechle crime_enable_irq(irq); 1918a13ecd7SRalf Baechle } 1928a13ecd7SRalf Baechle 1938a13ecd7SRalf Baechle static struct irq_chip crime_edge_interrupt = { 1948a13ecd7SRalf Baechle .name = "IP32 CRIME", 1958a13ecd7SRalf Baechle .ack = crime_edge_mask_and_ack_irq, 1968a13ecd7SRalf Baechle .mask = crime_disable_irq, 1978a13ecd7SRalf Baechle .mask_ack = crime_edge_mask_and_ack_irq, 1988a13ecd7SRalf Baechle .unmask = crime_enable_irq, 1998a13ecd7SRalf Baechle .end = crime_edge_end_irq, 2001da177e4SLinus Torvalds }; 2011da177e4SLinus Torvalds 2021da177e4SLinus Torvalds /* 2031da177e4SLinus Torvalds * This is for MACE PCI interrupts. We can decrease bus traffic by masking 2041da177e4SLinus Torvalds * as close to the source as possible. This also means we can take the 2051da177e4SLinus Torvalds * next chunk of the CRIME register in one piece. 2061da177e4SLinus Torvalds */ 2071da177e4SLinus Torvalds 2081da177e4SLinus Torvalds static unsigned long macepci_mask; 2091da177e4SLinus Torvalds 2101da177e4SLinus Torvalds static void enable_macepci_irq(unsigned int irq) 2111da177e4SLinus Torvalds { 21298ce4721SRalf Baechle macepci_mask |= MACEPCI_CONTROL_INT(irq - MACEPCI_SCSI0_IRQ); 2131da177e4SLinus Torvalds mace->pci.control = macepci_mask; 21498ce4721SRalf Baechle crime_mask |= 1 << (irq - CRIME_IRQ_BASE); 2151da177e4SLinus Torvalds crime->imask = crime_mask; 2161da177e4SLinus Torvalds } 2171da177e4SLinus Torvalds 2181da177e4SLinus Torvalds static void disable_macepci_irq(unsigned int irq) 2191da177e4SLinus Torvalds { 22098ce4721SRalf Baechle crime_mask &= ~(1 << (irq - CRIME_IRQ_BASE)); 2211da177e4SLinus Torvalds crime->imask = crime_mask; 2221da177e4SLinus Torvalds flush_crime_bus(); 22398ce4721SRalf Baechle macepci_mask &= ~MACEPCI_CONTROL_INT(irq - MACEPCI_SCSI0_IRQ); 2241da177e4SLinus Torvalds mace->pci.control = macepci_mask; 2251da177e4SLinus Torvalds flush_mace_bus(); 2261da177e4SLinus Torvalds } 2271da177e4SLinus Torvalds 2281da177e4SLinus Torvalds static void end_macepci_irq(unsigned int irq) 2291da177e4SLinus Torvalds { 2301da177e4SLinus Torvalds if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) 2311da177e4SLinus Torvalds enable_macepci_irq(irq); 2321da177e4SLinus Torvalds } 2331da177e4SLinus Torvalds 23494dee171SRalf Baechle static struct irq_chip ip32_macepci_interrupt = { 23570d21cdeSAtsushi Nemoto .name = "IP32 MACE PCI", 2361603b5acSAtsushi Nemoto .ack = disable_macepci_irq, 2371603b5acSAtsushi Nemoto .mask = disable_macepci_irq, 2381603b5acSAtsushi Nemoto .mask_ack = disable_macepci_irq, 2391603b5acSAtsushi Nemoto .unmask = enable_macepci_irq, 2408ab00b9aSRalf Baechle .end = end_macepci_irq, 2411da177e4SLinus Torvalds }; 2421da177e4SLinus Torvalds 2431da177e4SLinus Torvalds /* This is used for MACE ISA interrupts. That means bits 4-6 in the 2441da177e4SLinus Torvalds * CRIME register. 2451da177e4SLinus Torvalds */ 2461da177e4SLinus Torvalds 2471da177e4SLinus Torvalds #define MACEISA_AUDIO_INT (MACEISA_AUDIO_SW_INT | \ 2481da177e4SLinus Torvalds MACEISA_AUDIO_SC_INT | \ 2491da177e4SLinus Torvalds MACEISA_AUDIO1_DMAT_INT | \ 2501da177e4SLinus Torvalds MACEISA_AUDIO1_OF_INT | \ 2511da177e4SLinus Torvalds MACEISA_AUDIO2_DMAT_INT | \ 2521da177e4SLinus Torvalds MACEISA_AUDIO2_MERR_INT | \ 2531da177e4SLinus Torvalds MACEISA_AUDIO3_DMAT_INT | \ 2541da177e4SLinus Torvalds MACEISA_AUDIO3_MERR_INT) 2551da177e4SLinus Torvalds #define MACEISA_MISC_INT (MACEISA_RTC_INT | \ 2561da177e4SLinus Torvalds MACEISA_KEYB_INT | \ 2571da177e4SLinus Torvalds MACEISA_KEYB_POLL_INT | \ 2581da177e4SLinus Torvalds MACEISA_MOUSE_INT | \ 2591da177e4SLinus Torvalds MACEISA_MOUSE_POLL_INT | \ 260cfbae5d3SThiemo Seufer MACEISA_TIMER0_INT | \ 261cfbae5d3SThiemo Seufer MACEISA_TIMER1_INT | \ 262cfbae5d3SThiemo Seufer MACEISA_TIMER2_INT) 2631da177e4SLinus Torvalds #define MACEISA_SUPERIO_INT (MACEISA_PARALLEL_INT | \ 2641da177e4SLinus Torvalds MACEISA_PAR_CTXA_INT | \ 2651da177e4SLinus Torvalds MACEISA_PAR_CTXB_INT | \ 2661da177e4SLinus Torvalds MACEISA_PAR_MERR_INT | \ 2671da177e4SLinus Torvalds MACEISA_SERIAL1_INT | \ 2681da177e4SLinus Torvalds MACEISA_SERIAL1_TDMAT_INT | \ 2691da177e4SLinus Torvalds MACEISA_SERIAL1_TDMAPR_INT | \ 2701da177e4SLinus Torvalds MACEISA_SERIAL1_TDMAME_INT | \ 2711da177e4SLinus Torvalds MACEISA_SERIAL1_RDMAT_INT | \ 2721da177e4SLinus Torvalds MACEISA_SERIAL1_RDMAOR_INT | \ 2731da177e4SLinus Torvalds MACEISA_SERIAL2_INT | \ 2741da177e4SLinus Torvalds MACEISA_SERIAL2_TDMAT_INT | \ 2751da177e4SLinus Torvalds MACEISA_SERIAL2_TDMAPR_INT | \ 2761da177e4SLinus Torvalds MACEISA_SERIAL2_TDMAME_INT | \ 2771da177e4SLinus Torvalds MACEISA_SERIAL2_RDMAT_INT | \ 2781da177e4SLinus Torvalds MACEISA_SERIAL2_RDMAOR_INT) 2791da177e4SLinus Torvalds 2801da177e4SLinus Torvalds static unsigned long maceisa_mask; 2811da177e4SLinus Torvalds 2821da177e4SLinus Torvalds static void enable_maceisa_irq(unsigned int irq) 2831da177e4SLinus Torvalds { 2841da177e4SLinus Torvalds unsigned int crime_int = 0; 2851da177e4SLinus Torvalds 2868a13ecd7SRalf Baechle pr_debug("maceisa enable: %u\n", irq); 2871da177e4SLinus Torvalds 2881da177e4SLinus Torvalds switch (irq) { 2891da177e4SLinus Torvalds case MACEISA_AUDIO_SW_IRQ ... MACEISA_AUDIO3_MERR_IRQ: 2901da177e4SLinus Torvalds crime_int = MACE_AUDIO_INT; 2911da177e4SLinus Torvalds break; 292cfbae5d3SThiemo Seufer case MACEISA_RTC_IRQ ... MACEISA_TIMER2_IRQ: 2931da177e4SLinus Torvalds crime_int = MACE_MISC_INT; 2941da177e4SLinus Torvalds break; 2951da177e4SLinus Torvalds case MACEISA_PARALLEL_IRQ ... MACEISA_SERIAL2_RDMAOR_IRQ: 2961da177e4SLinus Torvalds crime_int = MACE_SUPERIO_INT; 2971da177e4SLinus Torvalds break; 2981da177e4SLinus Torvalds } 2998a13ecd7SRalf Baechle pr_debug("crime_int %08x enabled\n", crime_int); 3001da177e4SLinus Torvalds crime_mask |= crime_int; 3011da177e4SLinus Torvalds crime->imask = crime_mask; 30298ce4721SRalf Baechle maceisa_mask |= 1 << (irq - MACEISA_AUDIO_SW_IRQ); 3031da177e4SLinus Torvalds mace->perif.ctrl.imask = maceisa_mask; 3041da177e4SLinus Torvalds } 3051da177e4SLinus Torvalds 3061da177e4SLinus Torvalds static void disable_maceisa_irq(unsigned int irq) 3071da177e4SLinus Torvalds { 3081da177e4SLinus Torvalds unsigned int crime_int = 0; 3091da177e4SLinus Torvalds 31098ce4721SRalf Baechle maceisa_mask &= ~(1 << (irq - MACEISA_AUDIO_SW_IRQ)); 3111da177e4SLinus Torvalds if (!(maceisa_mask & MACEISA_AUDIO_INT)) 3121da177e4SLinus Torvalds crime_int |= MACE_AUDIO_INT; 3131da177e4SLinus Torvalds if (!(maceisa_mask & MACEISA_MISC_INT)) 3141da177e4SLinus Torvalds crime_int |= MACE_MISC_INT; 3151da177e4SLinus Torvalds if (!(maceisa_mask & MACEISA_SUPERIO_INT)) 3161da177e4SLinus Torvalds crime_int |= MACE_SUPERIO_INT; 3171da177e4SLinus Torvalds crime_mask &= ~crime_int; 3181da177e4SLinus Torvalds crime->imask = crime_mask; 3191da177e4SLinus Torvalds flush_crime_bus(); 3201da177e4SLinus Torvalds mace->perif.ctrl.imask = maceisa_mask; 3211da177e4SLinus Torvalds flush_mace_bus(); 3221da177e4SLinus Torvalds } 3231da177e4SLinus Torvalds 3241da177e4SLinus Torvalds static void mask_and_ack_maceisa_irq(unsigned int irq) 3251da177e4SLinus Torvalds { 3261603b5acSAtsushi Nemoto unsigned long mace_int; 3271da177e4SLinus Torvalds 3281da177e4SLinus Torvalds switch (irq) { 3291da177e4SLinus Torvalds case MACEISA_PARALLEL_IRQ: 3301da177e4SLinus Torvalds case MACEISA_SERIAL1_TDMAPR_IRQ: 3311da177e4SLinus Torvalds case MACEISA_SERIAL2_TDMAPR_IRQ: 3321da177e4SLinus Torvalds /* edge triggered */ 3331da177e4SLinus Torvalds mace_int = mace->perif.ctrl.istat; 33498ce4721SRalf Baechle mace_int &= ~(1 << (irq - MACEISA_AUDIO_SW_IRQ)); 3351da177e4SLinus Torvalds mace->perif.ctrl.istat = mace_int; 3361da177e4SLinus Torvalds break; 3371da177e4SLinus Torvalds } 3381da177e4SLinus Torvalds disable_maceisa_irq(irq); 3391da177e4SLinus Torvalds } 3401da177e4SLinus Torvalds 3411da177e4SLinus Torvalds static void end_maceisa_irq(unsigned irq) 3421da177e4SLinus Torvalds { 3431da177e4SLinus Torvalds if (!(irq_desc[irq].status & (IRQ_DISABLED | IRQ_INPROGRESS))) 3441da177e4SLinus Torvalds enable_maceisa_irq(irq); 3451da177e4SLinus Torvalds } 3461da177e4SLinus Torvalds 34794dee171SRalf Baechle static struct irq_chip ip32_maceisa_interrupt = { 34870d21cdeSAtsushi Nemoto .name = "IP32 MACE ISA", 3498ab00b9aSRalf Baechle .ack = mask_and_ack_maceisa_irq, 3501603b5acSAtsushi Nemoto .mask = disable_maceisa_irq, 3511603b5acSAtsushi Nemoto .mask_ack = mask_and_ack_maceisa_irq, 3521603b5acSAtsushi Nemoto .unmask = enable_maceisa_irq, 3538ab00b9aSRalf Baechle .end = end_maceisa_irq, 3541da177e4SLinus Torvalds }; 3551da177e4SLinus Torvalds 3561da177e4SLinus Torvalds /* This is used for regular non-ISA, non-PCI MACE interrupts. That means 3571da177e4SLinus Torvalds * bits 0-3 and 7 in the CRIME register. 3581da177e4SLinus Torvalds */ 3591da177e4SLinus Torvalds 3601da177e4SLinus Torvalds static void enable_mace_irq(unsigned int irq) 3611da177e4SLinus Torvalds { 36298ce4721SRalf Baechle unsigned int bit = irq - CRIME_IRQ_BASE; 36398ce4721SRalf Baechle 36498ce4721SRalf Baechle crime_mask |= (1 << bit); 3651da177e4SLinus Torvalds crime->imask = crime_mask; 3661da177e4SLinus Torvalds } 3671da177e4SLinus Torvalds 3681da177e4SLinus Torvalds static void disable_mace_irq(unsigned int irq) 3691da177e4SLinus Torvalds { 37098ce4721SRalf Baechle unsigned int bit = irq - CRIME_IRQ_BASE; 37198ce4721SRalf Baechle 37298ce4721SRalf Baechle crime_mask &= ~(1 << bit); 3731da177e4SLinus Torvalds crime->imask = crime_mask; 3741da177e4SLinus Torvalds flush_crime_bus(); 3751da177e4SLinus Torvalds } 3761da177e4SLinus Torvalds 3771da177e4SLinus Torvalds static void end_mace_irq(unsigned int irq) 3781da177e4SLinus Torvalds { 3791da177e4SLinus Torvalds if (!(irq_desc[irq].status & (IRQ_DISABLED|IRQ_INPROGRESS))) 3801da177e4SLinus Torvalds enable_mace_irq(irq); 3811da177e4SLinus Torvalds } 3821da177e4SLinus Torvalds 38394dee171SRalf Baechle static struct irq_chip ip32_mace_interrupt = { 38470d21cdeSAtsushi Nemoto .name = "IP32 MACE", 3851603b5acSAtsushi Nemoto .ack = disable_mace_irq, 3861603b5acSAtsushi Nemoto .mask = disable_mace_irq, 3871603b5acSAtsushi Nemoto .mask_ack = disable_mace_irq, 3881603b5acSAtsushi Nemoto .unmask = enable_mace_irq, 3898ab00b9aSRalf Baechle .end = end_mace_irq, 3901da177e4SLinus Torvalds }; 3911da177e4SLinus Torvalds 392937a8015SRalf Baechle static void ip32_unknown_interrupt(void) 3931da177e4SLinus Torvalds { 3941da177e4SLinus Torvalds printk("Unknown interrupt occurred!\n"); 3951da177e4SLinus Torvalds printk("cp0_status: %08x\n", read_c0_status()); 3961da177e4SLinus Torvalds printk("cp0_cause: %08x\n", read_c0_cause()); 3971da177e4SLinus Torvalds printk("CRIME intr mask: %016lx\n", crime->imask); 3981da177e4SLinus Torvalds printk("CRIME intr status: %016lx\n", crime->istat); 3991da177e4SLinus Torvalds printk("CRIME hardware intr register: %016lx\n", crime->hard_int); 4001da177e4SLinus Torvalds printk("MACE ISA intr mask: %08lx\n", mace->perif.ctrl.imask); 4011da177e4SLinus Torvalds printk("MACE ISA intr status: %08lx\n", mace->perif.ctrl.istat); 4021da177e4SLinus Torvalds printk("MACE PCI control register: %08x\n", mace->pci.control); 4031da177e4SLinus Torvalds 4041da177e4SLinus Torvalds printk("Register dump:\n"); 405937a8015SRalf Baechle show_regs(get_irq_regs()); 4061da177e4SLinus Torvalds 4071da177e4SLinus Torvalds printk("Please mail this report to linux-mips@linux-mips.org\n"); 4081da177e4SLinus Torvalds printk("Spinning..."); 4091da177e4SLinus Torvalds while(1) ; 4101da177e4SLinus Torvalds } 4111da177e4SLinus Torvalds 4121da177e4SLinus Torvalds /* CRIME 1.1 appears to deliver all interrupts to this one pin. */ 4131da177e4SLinus Torvalds /* change this to loop over all edge-triggered irqs, exception masked out ones */ 414937a8015SRalf Baechle static void ip32_irq0(void) 4151da177e4SLinus Torvalds { 4161da177e4SLinus Torvalds uint64_t crime_int; 4171da177e4SLinus Torvalds int irq = 0; 4181da177e4SLinus Torvalds 419dd67b155SRalf Baechle /* 420dd67b155SRalf Baechle * Sanity check interrupt numbering enum. 421dd67b155SRalf Baechle * MACE got 32 interrupts and there are 32 MACE ISA interrupts daisy 422dd67b155SRalf Baechle * chained. 423dd67b155SRalf Baechle */ 424dd67b155SRalf Baechle BUILD_BUG_ON(CRIME_VICE_IRQ - MACE_VID_IN1_IRQ != 31); 425dd67b155SRalf Baechle BUILD_BUG_ON(MACEISA_SERIAL2_RDMAOR_IRQ - MACEISA_AUDIO_SW_IRQ != 31); 426dd67b155SRalf Baechle 4271da177e4SLinus Torvalds crime_int = crime->istat & crime_mask; 428*1faf7f25SThomas Bogendoerfer 429*1faf7f25SThomas Bogendoerfer /* crime sometime delivers spurious interrupts, ignore them */ 430*1faf7f25SThomas Bogendoerfer if (unlikely(crime_int == 0)) 431*1faf7f25SThomas Bogendoerfer return; 432*1faf7f25SThomas Bogendoerfer 433dd67b155SRalf Baechle irq = MACE_VID_IN1_IRQ + __ffs(crime_int); 4341da177e4SLinus Torvalds 4351da177e4SLinus Torvalds if (crime_int & CRIME_MACEISA_INT_MASK) { 4361da177e4SLinus Torvalds unsigned long mace_int = mace->perif.ctrl.istat; 437dd67b155SRalf Baechle irq = __ffs(mace_int & maceisa_mask) + MACEISA_AUDIO_SW_IRQ; 4381da177e4SLinus Torvalds } 439dd67b155SRalf Baechle 4408a13ecd7SRalf Baechle pr_debug("*irq %u*\n", irq); 441937a8015SRalf Baechle do_IRQ(irq); 4421da177e4SLinus Torvalds } 4431da177e4SLinus Torvalds 444937a8015SRalf Baechle static void ip32_irq1(void) 4451da177e4SLinus Torvalds { 446937a8015SRalf Baechle ip32_unknown_interrupt(); 4471da177e4SLinus Torvalds } 4481da177e4SLinus Torvalds 449937a8015SRalf Baechle static void ip32_irq2(void) 4501da177e4SLinus Torvalds { 451937a8015SRalf Baechle ip32_unknown_interrupt(); 4521da177e4SLinus Torvalds } 4531da177e4SLinus Torvalds 454937a8015SRalf Baechle static void ip32_irq3(void) 4551da177e4SLinus Torvalds { 456937a8015SRalf Baechle ip32_unknown_interrupt(); 4571da177e4SLinus Torvalds } 4581da177e4SLinus Torvalds 459937a8015SRalf Baechle static void ip32_irq4(void) 4601da177e4SLinus Torvalds { 461937a8015SRalf Baechle ip32_unknown_interrupt(); 4621da177e4SLinus Torvalds } 4631da177e4SLinus Torvalds 464937a8015SRalf Baechle static void ip32_irq5(void) 4651da177e4SLinus Torvalds { 466dd67b155SRalf Baechle do_IRQ(MIPS_CPU_IRQ_BASE + 7); 4671da177e4SLinus Torvalds } 4681da177e4SLinus Torvalds 469937a8015SRalf Baechle asmlinkage void plat_irq_dispatch(void) 470e4ac58afSRalf Baechle { 471119537c0SThiemo Seufer unsigned int pending = read_c0_status() & read_c0_cause(); 472e4ac58afSRalf Baechle 473e4ac58afSRalf Baechle if (likely(pending & IE_IRQ0)) 474937a8015SRalf Baechle ip32_irq0(); 475e4ac58afSRalf Baechle else if (unlikely(pending & IE_IRQ1)) 476937a8015SRalf Baechle ip32_irq1(); 477e4ac58afSRalf Baechle else if (unlikely(pending & IE_IRQ2)) 478937a8015SRalf Baechle ip32_irq2(); 479e4ac58afSRalf Baechle else if (unlikely(pending & IE_IRQ3)) 480937a8015SRalf Baechle ip32_irq3(); 481e4ac58afSRalf Baechle else if (unlikely(pending & IE_IRQ4)) 482937a8015SRalf Baechle ip32_irq4(); 483e4ac58afSRalf Baechle else if (likely(pending & IE_IRQ5)) 484937a8015SRalf Baechle ip32_irq5(); 485e4ac58afSRalf Baechle } 486e4ac58afSRalf Baechle 4871da177e4SLinus Torvalds void __init arch_init_irq(void) 4881da177e4SLinus Torvalds { 4891da177e4SLinus Torvalds unsigned int irq; 4901da177e4SLinus Torvalds 4911da177e4SLinus Torvalds /* Install our interrupt handler, then clear and disable all 4921da177e4SLinus Torvalds * CRIME and MACE interrupts. */ 4931da177e4SLinus Torvalds crime->imask = 0; 4941da177e4SLinus Torvalds crime->hard_int = 0; 4951da177e4SLinus Torvalds crime->soft_int = 0; 4961da177e4SLinus Torvalds mace->perif.ctrl.istat = 0; 4971da177e4SLinus Torvalds mace->perif.ctrl.imask = 0; 4981da177e4SLinus Torvalds 499dd67b155SRalf Baechle mips_cpu_irq_init(); 50098ce4721SRalf Baechle for (irq = CRIME_IRQ_BASE; irq <= IP32_IRQ_MAX; irq++) { 501dd67b155SRalf Baechle switch (irq) { 502dd67b155SRalf Baechle case MACE_VID_IN1_IRQ ... MACE_PCI_BRIDGE_IRQ: 5038a13ecd7SRalf Baechle set_irq_chip(irq, &ip32_mace_interrupt); 504dd67b155SRalf Baechle break; 505dd67b155SRalf Baechle case MACEPCI_SCSI0_IRQ ... MACEPCI_SHARED2_IRQ: 5068a13ecd7SRalf Baechle set_irq_chip(irq, &ip32_macepci_interrupt); 507dd67b155SRalf Baechle break; 5088a13ecd7SRalf Baechle case CRIME_GBE0_IRQ ... CRIME_GBE3_IRQ: 5098a13ecd7SRalf Baechle set_irq_chip(irq, &crime_edge_interrupt); 5108a13ecd7SRalf Baechle break; 5118a13ecd7SRalf Baechle case CRIME_CPUERR_IRQ: 5128a13ecd7SRalf Baechle case CRIME_MEMERR_IRQ: 5138a13ecd7SRalf Baechle set_irq_chip(irq, &crime_level_interrupt); 5148a13ecd7SRalf Baechle break; 5158a13ecd7SRalf Baechle case CRIME_RE_EMPTY_E_IRQ ... CRIME_RE_IDLE_E_IRQ: 5168a13ecd7SRalf Baechle case CRIME_SOFT0_IRQ ... CRIME_SOFT2_IRQ: 5178a13ecd7SRalf Baechle set_irq_chip(irq, &crime_edge_interrupt); 5188a13ecd7SRalf Baechle break; 5198a13ecd7SRalf Baechle case CRIME_VICE_IRQ: 5208a13ecd7SRalf Baechle set_irq_chip(irq, &crime_edge_interrupt); 521dd67b155SRalf Baechle break; 522dd67b155SRalf Baechle default: 5238a13ecd7SRalf Baechle set_irq_chip(irq, &ip32_maceisa_interrupt); 5248a13ecd7SRalf Baechle break; 525dd67b155SRalf Baechle } 5261da177e4SLinus Torvalds } 5271da177e4SLinus Torvalds setup_irq(CRIME_MEMERR_IRQ, &memerr_irq); 5281da177e4SLinus Torvalds setup_irq(CRIME_CPUERR_IRQ, &cpuerr_irq); 5291da177e4SLinus Torvalds 5301da177e4SLinus Torvalds #define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5) 5311da177e4SLinus Torvalds change_c0_status(ST0_IM, ALLINTS); 5321da177e4SLinus Torvalds } 533