Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 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> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <linux/mm.h> |
| 19 | #include <linux/random.h> |
| 20 | #include <linux/sched.h> |
| 21 | |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 22 | #include <asm/irq_cpu.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <asm/mipsregs.h> |
| 24 | #include <asm/signal.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | #include <asm/time.h> |
| 26 | #include <asm/ip32/crime.h> |
| 27 | #include <asm/ip32/mace.h> |
| 28 | #include <asm/ip32/ip32_ints.h> |
| 29 | |
| 30 | /* issue a PIO read to make sure no PIO writes are pending */ |
| 31 | static void inline flush_crime_bus(void) |
| 32 | { |
Ralf Baechle | b6d7c7a | 2006-05-30 02:13:16 +0100 | [diff] [blame] | 33 | crime->control; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | static void inline flush_mace_bus(void) |
| 37 | { |
Ralf Baechle | b6d7c7a | 2006-05-30 02:13:16 +0100 | [diff] [blame] | 38 | mace->perif.ctrl.misc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | } |
| 40 | |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 41 | /* |
| 42 | * O2 irq map |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | * |
| 44 | * IP0 -> software (ignored) |
| 45 | * IP1 -> software (ignored) |
| 46 | * IP2 -> (irq0) C crime 1.1 all interrupts; crime 1.5 ??? |
| 47 | * IP3 -> (irq1) X unknown |
| 48 | * IP4 -> (irq2) X unknown |
| 49 | * IP5 -> (irq3) X unknown |
| 50 | * IP6 -> (irq4) X unknown |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 51 | * IP7 -> (irq5) 7 CPU count/compare timer (system timer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | * |
| 53 | * crime: (C) |
| 54 | * |
| 55 | * CRIME_INT_STAT 31:0: |
| 56 | * |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 57 | * 0 -> 8 Video in 1 |
| 58 | * 1 -> 9 Video in 2 |
| 59 | * 2 -> 10 Video out |
| 60 | * 3 -> 11 Mace ethernet |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | * 4 -> S SuperIO sub-interrupt |
| 62 | * 5 -> M Miscellaneous sub-interrupt |
| 63 | * 6 -> A Audio sub-interrupt |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 64 | * 7 -> 15 PCI bridge errors |
| 65 | * 8 -> 16 PCI SCSI aic7xxx 0 |
| 66 | * 9 -> 17 PCI SCSI aic7xxx 1 |
| 67 | * 10 -> 18 PCI slot 0 |
| 68 | * 11 -> 19 unused (PCI slot 1) |
| 69 | * 12 -> 20 unused (PCI slot 2) |
| 70 | * 13 -> 21 unused (PCI shared 0) |
| 71 | * 14 -> 22 unused (PCI shared 1) |
| 72 | * 15 -> 23 unused (PCI shared 2) |
| 73 | * 16 -> 24 GBE0 (E) |
| 74 | * 17 -> 25 GBE1 (E) |
| 75 | * 18 -> 26 GBE2 (E) |
| 76 | * 19 -> 27 GBE3 (E) |
| 77 | * 20 -> 28 CPU errors |
| 78 | * 21 -> 29 Memory errors |
| 79 | * 22 -> 30 RE empty edge (E) |
| 80 | * 23 -> 31 RE full edge (E) |
| 81 | * 24 -> 32 RE idle edge (E) |
| 82 | * 25 -> 33 RE empty level |
| 83 | * 26 -> 34 RE full level |
| 84 | * 27 -> 35 RE idle level |
| 85 | * 28 -> 36 unused (software 0) (E) |
| 86 | * 29 -> 37 unused (software 1) (E) |
| 87 | * 30 -> 38 unused (software 2) - crime 1.5 CPU SysCorError (E) |
| 88 | * 31 -> 39 VICE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | * |
| 90 | * S, M, A: Use the MACE ISA interrupt register |
| 91 | * MACE_ISA_INT_STAT 31:0 |
| 92 | * |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 93 | * 0-7 -> 40-47 Audio |
| 94 | * 8 -> 48 RTC |
| 95 | * 9 -> 49 Keyboard |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | * 10 -> X Keyboard polled |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 97 | * 11 -> 51 Mouse |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | * 12 -> X Mouse polled |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 99 | * 13-15 -> 53-55 Count/compare timers |
| 100 | * 16-19 -> 56-59 Parallel (16 E) |
| 101 | * 20-25 -> 60-62 Serial 1 (22 E) |
| 102 | * 26-31 -> 66-71 Serial 2 (28 E) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | * |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 104 | * Note that this means IRQs 12-14, 50, and 52 do not exist. This is a |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | * different IRQ map than IRIX uses, but that's OK as Linux irq handling |
| 106 | * is quite different anyway. |
| 107 | */ |
| 108 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | /* Some initial interrupts to set up */ |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 110 | extern irqreturn_t crime_memerr_intr(int irq, void *dev_id); |
| 111 | extern irqreturn_t crime_cpuerr_intr(int irq, void *dev_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
Dmitri Vorobiev | ae53738 | 2009-03-30 22:53:25 +0300 | [diff] [blame] | 113 | static struct irqaction memerr_irq = { |
Thomas Gleixner | 4e45171 | 2007-08-28 09:03:01 +0000 | [diff] [blame] | 114 | .handler = crime_memerr_intr, |
Thomas Gleixner | 4e45171 | 2007-08-28 09:03:01 +0000 | [diff] [blame] | 115 | .name = "CRIME memory error", |
| 116 | }; |
Ralf Baechle | 8a13ecd | 2007-10-28 18:46:39 +0000 | [diff] [blame] | 117 | |
Dmitri Vorobiev | ae53738 | 2009-03-30 22:53:25 +0300 | [diff] [blame] | 118 | static struct irqaction cpuerr_irq = { |
Thomas Gleixner | 4e45171 | 2007-08-28 09:03:01 +0000 | [diff] [blame] | 119 | .handler = crime_cpuerr_intr, |
Thomas Gleixner | 4e45171 | 2007-08-28 09:03:01 +0000 | [diff] [blame] | 120 | .name = "CRIME CPU error", |
| 121 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | * This is for pure CRIME interrupts - ie not MACE. The advantage? |
| 125 | * We get to split the register in half and do faster lookups. |
| 126 | */ |
| 127 | |
| 128 | static uint64_t crime_mask; |
| 129 | |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 130 | static inline void crime_enable_irq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | { |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 132 | unsigned int bit = d->irq - CRIME_IRQ_BASE; |
Ralf Baechle | 8a13ecd | 2007-10-28 18:46:39 +0000 | [diff] [blame] | 133 | |
| 134 | crime_mask |= 1 << bit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | crime->imask = crime_mask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | } |
| 137 | |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 138 | static inline void crime_disable_irq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | { |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 140 | unsigned int bit = d->irq - CRIME_IRQ_BASE; |
Ralf Baechle | 8a13ecd | 2007-10-28 18:46:39 +0000 | [diff] [blame] | 141 | |
| 142 | crime_mask &= ~(1 << bit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | crime->imask = crime_mask; |
| 144 | flush_crime_bus(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | } |
| 146 | |
Ralf Baechle | 8a13ecd | 2007-10-28 18:46:39 +0000 | [diff] [blame] | 147 | static struct irq_chip crime_level_interrupt = { |
| 148 | .name = "IP32 CRIME", |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 149 | .irq_mask = crime_disable_irq, |
| 150 | .irq_unmask = crime_enable_irq, |
Ralf Baechle | 8a13ecd | 2007-10-28 18:46:39 +0000 | [diff] [blame] | 151 | }; |
| 152 | |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 153 | static void crime_edge_mask_and_ack_irq(struct irq_data *d) |
Ralf Baechle | 8a13ecd | 2007-10-28 18:46:39 +0000 | [diff] [blame] | 154 | { |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 155 | unsigned int bit = d->irq - CRIME_IRQ_BASE; |
Ralf Baechle | 8a13ecd | 2007-10-28 18:46:39 +0000 | [diff] [blame] | 156 | uint64_t crime_int; |
| 157 | |
| 158 | /* Edge triggered interrupts must be cleared. */ |
Ralf Baechle | 8a13ecd | 2007-10-28 18:46:39 +0000 | [diff] [blame] | 159 | crime_int = crime->hard_int; |
| 160 | crime_int &= ~(1 << bit); |
| 161 | crime->hard_int = crime_int; |
| 162 | |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 163 | crime_disable_irq(d); |
Ralf Baechle | 8a13ecd | 2007-10-28 18:46:39 +0000 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | static struct irq_chip crime_edge_interrupt = { |
| 167 | .name = "IP32 CRIME", |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 168 | .irq_ack = crime_edge_mask_and_ack_irq, |
| 169 | .irq_mask = crime_disable_irq, |
| 170 | .irq_mask_ack = crime_edge_mask_and_ack_irq, |
| 171 | .irq_unmask = crime_enable_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | }; |
| 173 | |
| 174 | /* |
| 175 | * This is for MACE PCI interrupts. We can decrease bus traffic by masking |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 176 | * as close to the source as possible. This also means we can take the |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | * next chunk of the CRIME register in one piece. |
| 178 | */ |
| 179 | |
| 180 | static unsigned long macepci_mask; |
| 181 | |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 182 | static void enable_macepci_irq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | { |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 184 | macepci_mask |= MACEPCI_CONTROL_INT(d->irq - MACEPCI_SCSI0_IRQ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | mace->pci.control = macepci_mask; |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 186 | crime_mask |= 1 << (d->irq - CRIME_IRQ_BASE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | crime->imask = crime_mask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | } |
| 189 | |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 190 | static void disable_macepci_irq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | { |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 192 | crime_mask &= ~(1 << (d->irq - CRIME_IRQ_BASE)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 193 | crime->imask = crime_mask; |
| 194 | flush_crime_bus(); |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 195 | macepci_mask &= ~MACEPCI_CONTROL_INT(d->irq - MACEPCI_SCSI0_IRQ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | mace->pci.control = macepci_mask; |
| 197 | flush_mace_bus(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | } |
| 199 | |
Ralf Baechle | 94dee17 | 2006-07-02 14:41:42 +0100 | [diff] [blame] | 200 | static struct irq_chip ip32_macepci_interrupt = { |
Atsushi Nemoto | 70d21cd | 2007-01-15 00:07:25 +0900 | [diff] [blame] | 201 | .name = "IP32 MACE PCI", |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 202 | .irq_mask = disable_macepci_irq, |
| 203 | .irq_unmask = enable_macepci_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | }; |
| 205 | |
| 206 | /* This is used for MACE ISA interrupts. That means bits 4-6 in the |
| 207 | * CRIME register. |
| 208 | */ |
| 209 | |
| 210 | #define MACEISA_AUDIO_INT (MACEISA_AUDIO_SW_INT | \ |
| 211 | MACEISA_AUDIO_SC_INT | \ |
| 212 | MACEISA_AUDIO1_DMAT_INT | \ |
| 213 | MACEISA_AUDIO1_OF_INT | \ |
| 214 | MACEISA_AUDIO2_DMAT_INT | \ |
| 215 | MACEISA_AUDIO2_MERR_INT | \ |
| 216 | MACEISA_AUDIO3_DMAT_INT | \ |
| 217 | MACEISA_AUDIO3_MERR_INT) |
| 218 | #define MACEISA_MISC_INT (MACEISA_RTC_INT | \ |
| 219 | MACEISA_KEYB_INT | \ |
| 220 | MACEISA_KEYB_POLL_INT | \ |
| 221 | MACEISA_MOUSE_INT | \ |
| 222 | MACEISA_MOUSE_POLL_INT | \ |
Thiemo Seufer | cfbae5d | 2006-07-05 18:43:29 +0100 | [diff] [blame] | 223 | MACEISA_TIMER0_INT | \ |
| 224 | MACEISA_TIMER1_INT | \ |
| 225 | MACEISA_TIMER2_INT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | #define MACEISA_SUPERIO_INT (MACEISA_PARALLEL_INT | \ |
| 227 | MACEISA_PAR_CTXA_INT | \ |
| 228 | MACEISA_PAR_CTXB_INT | \ |
| 229 | MACEISA_PAR_MERR_INT | \ |
| 230 | MACEISA_SERIAL1_INT | \ |
| 231 | MACEISA_SERIAL1_TDMAT_INT | \ |
| 232 | MACEISA_SERIAL1_TDMAPR_INT | \ |
| 233 | MACEISA_SERIAL1_TDMAME_INT | \ |
| 234 | MACEISA_SERIAL1_RDMAT_INT | \ |
| 235 | MACEISA_SERIAL1_RDMAOR_INT | \ |
| 236 | MACEISA_SERIAL2_INT | \ |
| 237 | MACEISA_SERIAL2_TDMAT_INT | \ |
| 238 | MACEISA_SERIAL2_TDMAPR_INT | \ |
| 239 | MACEISA_SERIAL2_TDMAME_INT | \ |
| 240 | MACEISA_SERIAL2_RDMAT_INT | \ |
| 241 | MACEISA_SERIAL2_RDMAOR_INT) |
| 242 | |
| 243 | static unsigned long maceisa_mask; |
| 244 | |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 245 | static void enable_maceisa_irq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | { |
| 247 | unsigned int crime_int = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 249 | pr_debug("maceisa enable: %u\n", d->irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 251 | switch (d->irq) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | case MACEISA_AUDIO_SW_IRQ ... MACEISA_AUDIO3_MERR_IRQ: |
| 253 | crime_int = MACE_AUDIO_INT; |
| 254 | break; |
Thiemo Seufer | cfbae5d | 2006-07-05 18:43:29 +0100 | [diff] [blame] | 255 | case MACEISA_RTC_IRQ ... MACEISA_TIMER2_IRQ: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | crime_int = MACE_MISC_INT; |
| 257 | break; |
| 258 | case MACEISA_PARALLEL_IRQ ... MACEISA_SERIAL2_RDMAOR_IRQ: |
| 259 | crime_int = MACE_SUPERIO_INT; |
| 260 | break; |
| 261 | } |
Ralf Baechle | 8a13ecd | 2007-10-28 18:46:39 +0000 | [diff] [blame] | 262 | pr_debug("crime_int %08x enabled\n", crime_int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | crime_mask |= crime_int; |
| 264 | crime->imask = crime_mask; |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 265 | maceisa_mask |= 1 << (d->irq - MACEISA_AUDIO_SW_IRQ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | mace->perif.ctrl.imask = maceisa_mask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | } |
| 268 | |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 269 | static void disable_maceisa_irq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | { |
| 271 | unsigned int crime_int = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 273 | maceisa_mask &= ~(1 << (d->irq - MACEISA_AUDIO_SW_IRQ)); |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 274 | if (!(maceisa_mask & MACEISA_AUDIO_INT)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | crime_int |= MACE_AUDIO_INT; |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 276 | if (!(maceisa_mask & MACEISA_MISC_INT)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | crime_int |= MACE_MISC_INT; |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 278 | if (!(maceisa_mask & MACEISA_SUPERIO_INT)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | crime_int |= MACE_SUPERIO_INT; |
| 280 | crime_mask &= ~crime_int; |
| 281 | crime->imask = crime_mask; |
| 282 | flush_crime_bus(); |
| 283 | mace->perif.ctrl.imask = maceisa_mask; |
| 284 | flush_mace_bus(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | } |
| 286 | |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 287 | static void mask_and_ack_maceisa_irq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | { |
Atsushi Nemoto | 1603b5a | 2006-11-02 02:08:36 +0900 | [diff] [blame] | 289 | unsigned long mace_int; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | |
Ralf Baechle | c87e090 | 2009-03-30 14:49:44 +0200 | [diff] [blame] | 291 | /* edge triggered */ |
| 292 | mace_int = mace->perif.ctrl.istat; |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 293 | mace_int &= ~(1 << (d->irq - MACEISA_AUDIO_SW_IRQ)); |
Ralf Baechle | c87e090 | 2009-03-30 14:49:44 +0200 | [diff] [blame] | 294 | mace->perif.ctrl.istat = mace_int; |
| 295 | |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 296 | disable_maceisa_irq(d); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | } |
| 298 | |
Ralf Baechle | c87e090 | 2009-03-30 14:49:44 +0200 | [diff] [blame] | 299 | static struct irq_chip ip32_maceisa_level_interrupt = { |
| 300 | .name = "IP32 MACE ISA", |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 301 | .irq_mask = disable_maceisa_irq, |
| 302 | .irq_unmask = enable_maceisa_irq, |
Ralf Baechle | c87e090 | 2009-03-30 14:49:44 +0200 | [diff] [blame] | 303 | }; |
| 304 | |
| 305 | static struct irq_chip ip32_maceisa_edge_interrupt = { |
Ralf Baechle | 8a13ecd | 2007-10-28 18:46:39 +0000 | [diff] [blame] | 306 | .name = "IP32 MACE ISA", |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 307 | .irq_ack = mask_and_ack_maceisa_irq, |
| 308 | .irq_mask = disable_maceisa_irq, |
| 309 | .irq_mask_ack = mask_and_ack_maceisa_irq, |
| 310 | .irq_unmask = enable_maceisa_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | }; |
| 312 | |
| 313 | /* This is used for regular non-ISA, non-PCI MACE interrupts. That means |
| 314 | * bits 0-3 and 7 in the CRIME register. |
| 315 | */ |
| 316 | |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 317 | static void enable_mace_irq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | { |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 319 | unsigned int bit = d->irq - CRIME_IRQ_BASE; |
Ralf Baechle | 98ce472 | 2007-10-30 15:43:44 +0000 | [diff] [blame] | 320 | |
| 321 | crime_mask |= (1 << bit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | crime->imask = crime_mask; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | } |
| 324 | |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 325 | static void disable_mace_irq(struct irq_data *d) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | { |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 327 | unsigned int bit = d->irq - CRIME_IRQ_BASE; |
Ralf Baechle | 98ce472 | 2007-10-30 15:43:44 +0000 | [diff] [blame] | 328 | |
| 329 | crime_mask &= ~(1 << bit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | crime->imask = crime_mask; |
| 331 | flush_crime_bus(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | } |
| 333 | |
Ralf Baechle | 94dee17 | 2006-07-02 14:41:42 +0100 | [diff] [blame] | 334 | static struct irq_chip ip32_mace_interrupt = { |
Atsushi Nemoto | 70d21cd | 2007-01-15 00:07:25 +0900 | [diff] [blame] | 335 | .name = "IP32 MACE", |
Thomas Gleixner | 4d2796f | 2011-03-23 21:09:13 +0000 | [diff] [blame] | 336 | .irq_mask = disable_mace_irq, |
| 337 | .irq_unmask = enable_mace_irq, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | }; |
| 339 | |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 340 | static void ip32_unknown_interrupt(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | { |
Ralf Baechle | 49a89ef | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 342 | printk("Unknown interrupt occurred!\n"); |
| 343 | printk("cp0_status: %08x\n", read_c0_status()); |
| 344 | printk("cp0_cause: %08x\n", read_c0_cause()); |
| 345 | printk("CRIME intr mask: %016lx\n", crime->imask); |
| 346 | printk("CRIME intr status: %016lx\n", crime->istat); |
| 347 | printk("CRIME hardware intr register: %016lx\n", crime->hard_int); |
| 348 | printk("MACE ISA intr mask: %08lx\n", mace->perif.ctrl.imask); |
| 349 | printk("MACE ISA intr status: %08lx\n", mace->perif.ctrl.istat); |
| 350 | printk("MACE PCI control register: %08x\n", mace->pci.control); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | |
| 352 | printk("Register dump:\n"); |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 353 | show_regs(get_irq_regs()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | |
| 355 | printk("Please mail this report to linux-mips@linux-mips.org\n"); |
| 356 | printk("Spinning..."); |
| 357 | while(1) ; |
| 358 | } |
| 359 | |
| 360 | /* CRIME 1.1 appears to deliver all interrupts to this one pin. */ |
| 361 | /* change this to loop over all edge-triggered irqs, exception masked out ones */ |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 362 | static void ip32_irq0(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | { |
| 364 | uint64_t crime_int; |
| 365 | int irq = 0; |
| 366 | |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 367 | /* |
| 368 | * Sanity check interrupt numbering enum. |
| 369 | * MACE got 32 interrupts and there are 32 MACE ISA interrupts daisy |
| 370 | * chained. |
| 371 | */ |
| 372 | BUILD_BUG_ON(CRIME_VICE_IRQ - MACE_VID_IN1_IRQ != 31); |
| 373 | BUILD_BUG_ON(MACEISA_SERIAL2_RDMAOR_IRQ - MACEISA_AUDIO_SW_IRQ != 31); |
| 374 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | crime_int = crime->istat & crime_mask; |
Thomas Bogendoerfer | 1faf7f2 | 2008-06-24 00:48:05 +0200 | [diff] [blame] | 376 | |
| 377 | /* crime sometime delivers spurious interrupts, ignore them */ |
| 378 | if (unlikely(crime_int == 0)) |
| 379 | return; |
| 380 | |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 381 | irq = MACE_VID_IN1_IRQ + __ffs(crime_int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | |
| 383 | if (crime_int & CRIME_MACEISA_INT_MASK) { |
| 384 | unsigned long mace_int = mace->perif.ctrl.istat; |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 385 | irq = __ffs(mace_int & maceisa_mask) + MACEISA_AUDIO_SW_IRQ; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | } |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 387 | |
Ralf Baechle | 8a13ecd | 2007-10-28 18:46:39 +0000 | [diff] [blame] | 388 | pr_debug("*irq %u*\n", irq); |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 389 | do_IRQ(irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 390 | } |
| 391 | |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 392 | static void ip32_irq1(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | { |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 394 | ip32_unknown_interrupt(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | } |
| 396 | |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 397 | static void ip32_irq2(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | { |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 399 | ip32_unknown_interrupt(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | } |
| 401 | |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 402 | static void ip32_irq3(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | { |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 404 | ip32_unknown_interrupt(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | } |
| 406 | |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 407 | static void ip32_irq4(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 408 | { |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 409 | ip32_unknown_interrupt(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | } |
| 411 | |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 412 | static void ip32_irq5(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | { |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 414 | do_IRQ(MIPS_CPU_IRQ_BASE + 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | } |
| 416 | |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 417 | asmlinkage void plat_irq_dispatch(void) |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 418 | { |
Thiemo Seufer | 119537c | 2007-03-19 00:13:37 +0000 | [diff] [blame] | 419 | unsigned int pending = read_c0_status() & read_c0_cause(); |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 420 | |
| 421 | if (likely(pending & IE_IRQ0)) |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 422 | ip32_irq0(); |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 423 | else if (unlikely(pending & IE_IRQ1)) |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 424 | ip32_irq1(); |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 425 | else if (unlikely(pending & IE_IRQ2)) |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 426 | ip32_irq2(); |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 427 | else if (unlikely(pending & IE_IRQ3)) |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 428 | ip32_irq3(); |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 429 | else if (unlikely(pending & IE_IRQ4)) |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 430 | ip32_irq4(); |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 431 | else if (likely(pending & IE_IRQ5)) |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 432 | ip32_irq5(); |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 433 | } |
| 434 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | void __init arch_init_irq(void) |
| 436 | { |
| 437 | unsigned int irq; |
| 438 | |
| 439 | /* Install our interrupt handler, then clear and disable all |
| 440 | * CRIME and MACE interrupts. */ |
| 441 | crime->imask = 0; |
| 442 | crime->hard_int = 0; |
| 443 | crime->soft_int = 0; |
| 444 | mace->perif.ctrl.istat = 0; |
| 445 | mace->perif.ctrl.imask = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 447 | mips_cpu_irq_init(); |
Ralf Baechle | 98ce472 | 2007-10-30 15:43:44 +0000 | [diff] [blame] | 448 | for (irq = CRIME_IRQ_BASE; irq <= IP32_IRQ_MAX; irq++) { |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 449 | switch (irq) { |
| 450 | case MACE_VID_IN1_IRQ ... MACE_PCI_BRIDGE_IRQ: |
Thomas Gleixner | e4ec798 | 2011-03-27 15:19:28 +0200 | [diff] [blame] | 451 | irq_set_chip_and_handler_name(irq, |
| 452 | &ip32_mace_interrupt, |
| 453 | handle_level_irq, |
| 454 | "level"); |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 455 | break; |
Ralf Baechle | c87e090 | 2009-03-30 14:49:44 +0200 | [diff] [blame] | 456 | |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 457 | case MACEPCI_SCSI0_IRQ ... MACEPCI_SHARED2_IRQ: |
Thomas Gleixner | e4ec798 | 2011-03-27 15:19:28 +0200 | [diff] [blame] | 458 | irq_set_chip_and_handler_name(irq, |
| 459 | &ip32_macepci_interrupt, |
| 460 | handle_level_irq, |
| 461 | "level"); |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 462 | break; |
Ralf Baechle | c87e090 | 2009-03-30 14:49:44 +0200 | [diff] [blame] | 463 | |
Ralf Baechle | 8a13ecd | 2007-10-28 18:46:39 +0000 | [diff] [blame] | 464 | case CRIME_CPUERR_IRQ: |
| 465 | case CRIME_MEMERR_IRQ: |
Thomas Gleixner | e4ec798 | 2011-03-27 15:19:28 +0200 | [diff] [blame] | 466 | irq_set_chip_and_handler_name(irq, |
| 467 | &crime_level_interrupt, |
| 468 | handle_level_irq, |
| 469 | "level"); |
Ralf Baechle | 8a13ecd | 2007-10-28 18:46:39 +0000 | [diff] [blame] | 470 | break; |
Ralf Baechle | c87e090 | 2009-03-30 14:49:44 +0200 | [diff] [blame] | 471 | |
Roel Kluin | 2fe0626 | 2010-01-20 00:59:27 +0100 | [diff] [blame] | 472 | case CRIME_GBE0_IRQ ... CRIME_GBE3_IRQ: |
Ralf Baechle | 8a13ecd | 2007-10-28 18:46:39 +0000 | [diff] [blame] | 473 | case CRIME_RE_EMPTY_E_IRQ ... CRIME_RE_IDLE_E_IRQ: |
| 474 | case CRIME_SOFT0_IRQ ... CRIME_SOFT2_IRQ: |
Ralf Baechle | 8a13ecd | 2007-10-28 18:46:39 +0000 | [diff] [blame] | 475 | case CRIME_VICE_IRQ: |
Thomas Gleixner | e4ec798 | 2011-03-27 15:19:28 +0200 | [diff] [blame] | 476 | irq_set_chip_and_handler_name(irq, |
| 477 | &crime_edge_interrupt, |
| 478 | handle_edge_irq, |
| 479 | "edge"); |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 480 | break; |
Ralf Baechle | c87e090 | 2009-03-30 14:49:44 +0200 | [diff] [blame] | 481 | |
| 482 | case MACEISA_PARALLEL_IRQ: |
| 483 | case MACEISA_SERIAL1_TDMAPR_IRQ: |
| 484 | case MACEISA_SERIAL2_TDMAPR_IRQ: |
Thomas Gleixner | e4ec798 | 2011-03-27 15:19:28 +0200 | [diff] [blame] | 485 | irq_set_chip_and_handler_name(irq, |
| 486 | &ip32_maceisa_edge_interrupt, |
| 487 | handle_edge_irq, |
| 488 | "edge"); |
Ralf Baechle | c87e090 | 2009-03-30 14:49:44 +0200 | [diff] [blame] | 489 | break; |
| 490 | |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 491 | default: |
Thomas Gleixner | e4ec798 | 2011-03-27 15:19:28 +0200 | [diff] [blame] | 492 | irq_set_chip_and_handler_name(irq, |
| 493 | &ip32_maceisa_level_interrupt, |
| 494 | handle_level_irq, |
| 495 | "level"); |
Ralf Baechle | 8a13ecd | 2007-10-28 18:46:39 +0000 | [diff] [blame] | 496 | break; |
Ralf Baechle | dd67b15 | 2007-10-14 14:02:26 +0100 | [diff] [blame] | 497 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | } |
| 499 | setup_irq(CRIME_MEMERR_IRQ, &memerr_irq); |
| 500 | setup_irq(CRIME_CPUERR_IRQ, &cpuerr_irq); |
| 501 | |
| 502 | #define ALLINTS (IE_IRQ0 | IE_IRQ1 | IE_IRQ2 | IE_IRQ3 | IE_IRQ4 | IE_IRQ5) |
| 503 | change_c0_status(ST0_IM, ALLINTS); |
| 504 | } |