Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | * Carsten Langgaard, carstenl@mips.com |
| 7 | * Copyright (C) 2000, 2001, 2004 MIPS Technologies, Inc. |
| 8 | * Copyright (C) 2001 Ralf Baechle |
Deng-Cheng Zhu | 1336113 | 2013-10-30 15:52:10 -0500 | [diff] [blame] | 9 | * Copyright (C) 2013 Imagination Technologies Ltd. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | * Routines for generic manipulation of the interrupts found on the MIPS |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 12 | * Malta board. The interrupt controller is located in the South Bridge |
| 13 | * a PIIX4 device with two internal 82C95 interrupt controllers. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | */ |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/irq.h> |
| 17 | #include <linux/sched.h> |
Ralf Baechle | 631330f | 2009-06-19 14:05:26 +0100 | [diff] [blame] | 18 | #include <linux/smp.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include <linux/interrupt.h> |
Dmitri Vorobiev | 54bf038 | 2008-01-24 19:52:49 +0300 | [diff] [blame] | 20 | #include <linux/io.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <linux/kernel_stat.h> |
Ahmed S. Darwish | 25b8ac3 | 2007-02-05 04:42:11 +0200 | [diff] [blame] | 22 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | #include <linux/random.h> |
| 24 | |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 25 | #include <asm/traps.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | #include <asm/i8259.h> |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 27 | #include <asm/irq_cpu.h> |
Ralf Baechle | ba38cdf | 2006-10-15 09:17:43 +0100 | [diff] [blame] | 28 | #include <asm/irq_regs.h> |
Paul Burton | 237036d | 2014-01-15 10:31:54 +0000 | [diff] [blame] | 29 | #include <asm/mips-cm.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | #include <asm/mips-boards/malta.h> |
| 31 | #include <asm/mips-boards/maltaint.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <asm/gt64120.h> |
| 33 | #include <asm/mips-boards/generic.h> |
| 34 | #include <asm/mips-boards/msc01_pci.h> |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 35 | #include <asm/msc01_ic.h> |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 36 | #include <asm/gic.h> |
David Howells | b81947c | 2012-03-28 18:30:02 +0100 | [diff] [blame] | 37 | #include <asm/setup.h> |
Deng-Cheng Zhu | 1336113 | 2013-10-30 15:52:10 -0500 | [diff] [blame] | 38 | #include <asm/rtlx.h> |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 39 | |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 40 | static unsigned long _msc01_biu_base; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 41 | static unsigned int ipi_map[NR_CPUS]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | |
Ralf Baechle | a963dc7 | 2010-02-27 12:53:32 +0100 | [diff] [blame] | 43 | static DEFINE_RAW_SPINLOCK(mips_irq_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | |
| 45 | static inline int mips_pcibios_iack(void) |
| 46 | { |
| 47 | int irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
| 49 | /* |
| 50 | * Determine highest priority pending interrupt by performing |
| 51 | * a PCI Interrupt Acknowledge cycle. |
| 52 | */ |
Chris Dearman | b72c052 | 2007-04-27 15:58:41 +0100 | [diff] [blame] | 53 | switch (mips_revision_sconid) { |
| 54 | case MIPS_REVISION_SCON_SOCIT: |
| 55 | case MIPS_REVISION_SCON_ROCIT: |
| 56 | case MIPS_REVISION_SCON_SOCITSC: |
| 57 | case MIPS_REVISION_SCON_SOCITSCP: |
Dmitri Vorobiev | af82558 | 2008-01-24 19:52:45 +0300 | [diff] [blame] | 58 | MSC_READ(MSC01_PCI_IACK, irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | irq &= 0xff; |
| 60 | break; |
Chris Dearman | b72c052 | 2007-04-27 15:58:41 +0100 | [diff] [blame] | 61 | case MIPS_REVISION_SCON_GT64120: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | irq = GT_READ(GT_PCI0_IACK_OFS); |
| 63 | irq &= 0xff; |
| 64 | break; |
Chris Dearman | b72c052 | 2007-04-27 15:58:41 +0100 | [diff] [blame] | 65 | case MIPS_REVISION_SCON_BONITO: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | /* The following will generate a PCI IACK cycle on the |
| 67 | * Bonito controller. It's a little bit kludgy, but it |
| 68 | * was the easiest way to implement it in hardware at |
| 69 | * the given time. |
| 70 | */ |
| 71 | BONITO_PCIMAP_CFG = 0x20000; |
| 72 | |
| 73 | /* Flush Bonito register block */ |
Ralf Baechle | 6be63bb | 2011-03-29 11:48:22 +0200 | [diff] [blame] | 74 | (void) BONITO_PCIMAP_CFG; |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 75 | iob(); /* sync */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
Chris Dearman | accfd35 | 2009-07-10 01:53:54 -0700 | [diff] [blame] | 77 | irq = __raw_readl((u32 *)_pcictrl_bonito_pcicfg); |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 78 | iob(); /* sync */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | irq &= 0xff; |
| 80 | BONITO_PCIMAP_CFG = 0; |
| 81 | break; |
| 82 | default: |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 83 | pr_emerg("Unknown system controller.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | return -1; |
| 85 | } |
| 86 | return irq; |
| 87 | } |
| 88 | |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 89 | static inline int get_int(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | { |
| 91 | unsigned long flags; |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 92 | int irq; |
Ralf Baechle | a963dc7 | 2010-02-27 12:53:32 +0100 | [diff] [blame] | 93 | raw_spin_lock_irqsave(&mips_irq_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 95 | irq = mips_pcibios_iack(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
| 97 | /* |
Ralf Baechle | 479a0e3 | 2005-08-16 15:44:06 +0000 | [diff] [blame] | 98 | * The only way we can decide if an interrupt is spurious |
| 99 | * is by checking the 8259 registers. This needs a spinlock |
| 100 | * on an SMP system, so leave it up to the generic code... |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
Ralf Baechle | a963dc7 | 2010-02-27 12:53:32 +0100 | [diff] [blame] | 103 | raw_spin_unlock_irqrestore(&mips_irq_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 105 | return irq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 108 | static void malta_hw0_irqdispatch(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | { |
| 110 | int irq; |
| 111 | |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 112 | irq = get_int(); |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 113 | if (irq < 0) { |
Dmitri Vorobiev | cd80d54 | 2008-01-24 19:52:54 +0300 | [diff] [blame] | 114 | /* interrupt has already been cleared */ |
| 115 | return; |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 116 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 118 | do_IRQ(MALTA_INT_BASE + irq); |
Deng-Cheng Zhu | 1336113 | 2013-10-30 15:52:10 -0500 | [diff] [blame] | 119 | |
| 120 | #ifdef MIPS_VPE_APSP_API |
| 121 | if (aprp_hook) |
| 122 | aprp_hook(); |
| 123 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | } |
| 125 | |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 126 | static void malta_ipi_irqdispatch(void) |
| 127 | { |
| 128 | int irq; |
| 129 | |
Raghu Gandham | 0ab2b7d | 2013-04-10 16:30:12 -0500 | [diff] [blame] | 130 | if (gic_compare_int()) |
| 131 | do_IRQ(MIPS_GIC_IRQ_BASE); |
| 132 | |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 133 | irq = gic_get_int(); |
| 134 | if (irq < 0) |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 135 | return; /* interrupt has already been cleared */ |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 136 | |
| 137 | do_IRQ(MIPS_GIC_IRQ_BASE + irq); |
| 138 | } |
| 139 | |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 140 | static void corehi_irqdispatch(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | { |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 142 | unsigned int intedge, intsteer, pcicmd, pcibadaddr; |
Dmitri Vorobiev | af82558 | 2008-01-24 19:52:45 +0300 | [diff] [blame] | 143 | unsigned int pcimstat, intisr, inten, intpol; |
Ralf Baechle | 21a151d | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 144 | unsigned int intrcause, datalo, datahi; |
Ralf Baechle | ba38cdf | 2006-10-15 09:17:43 +0100 | [diff] [blame] | 145 | struct pt_regs *regs = get_irq_regs(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 147 | pr_emerg("CoreHI interrupt, shouldn't happen, we die here!\n"); |
| 148 | pr_emerg("epc : %08lx\nStatus: %08lx\n" |
| 149 | "Cause : %08lx\nbadVaddr : %08lx\n", |
| 150 | regs->cp0_epc, regs->cp0_status, |
| 151 | regs->cp0_cause, regs->cp0_badvaddr); |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 152 | |
| 153 | /* Read all the registers and then print them as there is a |
| 154 | problem with interspersed printk's upsetting the Bonito controller. |
| 155 | Do it for the others too. |
| 156 | */ |
| 157 | |
Chris Dearman | b72c052 | 2007-04-27 15:58:41 +0100 | [diff] [blame] | 158 | switch (mips_revision_sconid) { |
Dmitri Vorobiev | af82558 | 2008-01-24 19:52:45 +0300 | [diff] [blame] | 159 | case MIPS_REVISION_SCON_SOCIT: |
Chris Dearman | b72c052 | 2007-04-27 15:58:41 +0100 | [diff] [blame] | 160 | case MIPS_REVISION_SCON_ROCIT: |
| 161 | case MIPS_REVISION_SCON_SOCITSC: |
| 162 | case MIPS_REVISION_SCON_SOCITSCP: |
Dmitri Vorobiev | af82558 | 2008-01-24 19:52:45 +0300 | [diff] [blame] | 163 | ll_msc_irq(); |
| 164 | break; |
| 165 | case MIPS_REVISION_SCON_GT64120: |
| 166 | intrcause = GT_READ(GT_INTRCAUSE_OFS); |
| 167 | datalo = GT_READ(GT_CPUERR_ADDRLO_OFS); |
| 168 | datahi = GT_READ(GT_CPUERR_ADDRHI_OFS); |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 169 | pr_emerg("GT_INTRCAUSE = %08x\n", intrcause); |
| 170 | pr_emerg("GT_CPUERR_ADDR = %02x%08x\n", |
Dmitri Vorobiev | 8216d34 | 2008-01-24 19:52:42 +0300 | [diff] [blame] | 171 | datahi, datalo); |
Dmitri Vorobiev | af82558 | 2008-01-24 19:52:45 +0300 | [diff] [blame] | 172 | break; |
| 173 | case MIPS_REVISION_SCON_BONITO: |
| 174 | pcibadaddr = BONITO_PCIBADADDR; |
| 175 | pcimstat = BONITO_PCIMSTAT; |
| 176 | intisr = BONITO_INTISR; |
| 177 | inten = BONITO_INTEN; |
| 178 | intpol = BONITO_INTPOL; |
| 179 | intedge = BONITO_INTEDGE; |
| 180 | intsteer = BONITO_INTSTEER; |
| 181 | pcicmd = BONITO_PCICMD; |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 182 | pr_emerg("BONITO_INTISR = %08x\n", intisr); |
| 183 | pr_emerg("BONITO_INTEN = %08x\n", inten); |
| 184 | pr_emerg("BONITO_INTPOL = %08x\n", intpol); |
| 185 | pr_emerg("BONITO_INTEDGE = %08x\n", intedge); |
| 186 | pr_emerg("BONITO_INTSTEER = %08x\n", intsteer); |
| 187 | pr_emerg("BONITO_PCICMD = %08x\n", pcicmd); |
| 188 | pr_emerg("BONITO_PCIBADADDR = %08x\n", pcibadaddr); |
| 189 | pr_emerg("BONITO_PCIMSTAT = %08x\n", pcimstat); |
Dmitri Vorobiev | af82558 | 2008-01-24 19:52:45 +0300 | [diff] [blame] | 190 | break; |
| 191 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | |
Dmitri Vorobiev | af82558 | 2008-01-24 19:52:45 +0300 | [diff] [blame] | 193 | die("CoreHi interrupt", regs); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | } |
| 195 | |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 196 | static inline int clz(unsigned long x) |
| 197 | { |
Ralf Baechle | 49a89ef | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 198 | __asm__( |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 199 | " .set push \n" |
| 200 | " .set mips32 \n" |
| 201 | " clz %0, %1 \n" |
| 202 | " .set pop \n" |
| 203 | : "=r" (x) |
| 204 | : "r" (x)); |
| 205 | |
| 206 | return x; |
| 207 | } |
| 208 | |
| 209 | /* |
| 210 | * Version of ffs that only looks at bits 12..15. |
| 211 | */ |
| 212 | static inline unsigned int irq_ffs(unsigned int pending) |
| 213 | { |
| 214 | #if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64) |
| 215 | return -clz(pending) + 31 - CAUSEB_IP; |
| 216 | #else |
| 217 | unsigned int a0 = 7; |
| 218 | unsigned int t0; |
| 219 | |
Ralf Baechle | 0118c3c | 2006-06-05 11:54:41 +0100 | [diff] [blame] | 220 | t0 = pending & 0xf000; |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 221 | t0 = t0 < 1; |
| 222 | t0 = t0 << 2; |
| 223 | a0 = a0 - t0; |
Ralf Baechle | 0118c3c | 2006-06-05 11:54:41 +0100 | [diff] [blame] | 224 | pending = pending << t0; |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 225 | |
Ralf Baechle | 0118c3c | 2006-06-05 11:54:41 +0100 | [diff] [blame] | 226 | t0 = pending & 0xc000; |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 227 | t0 = t0 < 1; |
| 228 | t0 = t0 << 1; |
| 229 | a0 = a0 - t0; |
Ralf Baechle | 0118c3c | 2006-06-05 11:54:41 +0100 | [diff] [blame] | 230 | pending = pending << t0; |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 231 | |
Ralf Baechle | 0118c3c | 2006-06-05 11:54:41 +0100 | [diff] [blame] | 232 | t0 = pending & 0x8000; |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 233 | t0 = t0 < 1; |
Dmitri Vorobiev | ae9cef0 | 2008-01-24 19:52:52 +0300 | [diff] [blame] | 234 | /* t0 = t0 << 2; */ |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 235 | a0 = a0 - t0; |
Dmitri Vorobiev | ae9cef0 | 2008-01-24 19:52:52 +0300 | [diff] [blame] | 236 | /* pending = pending << t0; */ |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 237 | |
| 238 | return a0; |
| 239 | #endif |
| 240 | } |
| 241 | |
| 242 | /* |
| 243 | * IRQs on the Malta board look basically (barring software IRQs which we |
| 244 | * don't use at all and all external interrupt sources are combined together |
| 245 | * on hardware interrupt 0 (MIPS IRQ 2)) like: |
| 246 | * |
| 247 | * MIPS IRQ Source |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 248 | * -------- ------ |
| 249 | * 0 Software (ignored) |
| 250 | * 1 Software (ignored) |
| 251 | * 2 Combined hardware interrupt (hw0) |
| 252 | * 3 Hardware (ignored) |
| 253 | * 4 Hardware (ignored) |
| 254 | * 5 Hardware (ignored) |
| 255 | * 6 Hardware (ignored) |
| 256 | * 7 R4k timer (what we use) |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 257 | * |
| 258 | * We handle the IRQ according to _our_ priority which is: |
| 259 | * |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 260 | * Highest ---- R4k Timer |
| 261 | * Lowest ---- Combined hardware interrupt |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 262 | * |
| 263 | * then we just return, if multiple IRQs are pending then we will just take |
| 264 | * another exception, big deal. |
| 265 | */ |
| 266 | |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 267 | asmlinkage void plat_irq_dispatch(void) |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 268 | { |
| 269 | unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM; |
| 270 | int irq; |
| 271 | |
Ralf Baechle | e376fdf | 2012-09-17 01:23:21 +0200 | [diff] [blame] | 272 | if (unlikely(!pending)) { |
| 273 | spurious_interrupt(); |
| 274 | return; |
| 275 | } |
| 276 | |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 277 | irq = irq_ffs(pending); |
| 278 | |
| 279 | if (irq == MIPSCPU_INT_I8259A) |
Ralf Baechle | 937a801 | 2006-10-07 19:44:33 +0100 | [diff] [blame] | 280 | malta_hw0_irqdispatch(); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 281 | else if (gic_present && ((1 << irq) & ipi_map[smp_processor_id()])) |
| 282 | malta_ipi_irqdispatch(); |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 283 | else |
Ralf Baechle | e376fdf | 2012-09-17 01:23:21 +0200 | [diff] [blame] | 284 | do_IRQ(MIPS_CPU_IRQ_BASE + irq); |
Ralf Baechle | e4ac58a | 2006-04-03 17:56:36 +0100 | [diff] [blame] | 285 | } |
| 286 | |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 287 | #ifdef CONFIG_MIPS_MT_SMP |
| 288 | |
| 289 | |
| 290 | #define GIC_MIPS_CPU_IPI_RESCHED_IRQ 3 |
| 291 | #define GIC_MIPS_CPU_IPI_CALL_IRQ 4 |
| 292 | |
| 293 | #define MIPS_CPU_IPI_RESCHED_IRQ 0 /* SW int 0 for resched */ |
| 294 | #define C_RESCHED C_SW0 |
| 295 | #define MIPS_CPU_IPI_CALL_IRQ 1 /* SW int 1 for resched */ |
| 296 | #define C_CALL C_SW1 |
| 297 | static int cpu_ipi_resched_irq, cpu_ipi_call_irq; |
| 298 | |
| 299 | static void ipi_resched_dispatch(void) |
| 300 | { |
| 301 | do_IRQ(MIPS_CPU_IRQ_BASE + MIPS_CPU_IPI_RESCHED_IRQ); |
| 302 | } |
| 303 | |
| 304 | static void ipi_call_dispatch(void) |
| 305 | { |
| 306 | do_IRQ(MIPS_CPU_IRQ_BASE + MIPS_CPU_IPI_CALL_IRQ); |
| 307 | } |
| 308 | |
| 309 | static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id) |
| 310 | { |
Deng-Cheng Zhu | 1336113 | 2013-10-30 15:52:10 -0500 | [diff] [blame] | 311 | #ifdef MIPS_VPE_APSP_API |
| 312 | if (aprp_hook) |
| 313 | aprp_hook(); |
| 314 | #endif |
| 315 | |
Peter Zijlstra | 184748c | 2011-04-05 17:23:39 +0200 | [diff] [blame] | 316 | scheduler_ipi(); |
| 317 | |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 318 | return IRQ_HANDLED; |
| 319 | } |
| 320 | |
| 321 | static irqreturn_t ipi_call_interrupt(int irq, void *dev_id) |
| 322 | { |
| 323 | smp_call_function_interrupt(); |
| 324 | |
| 325 | return IRQ_HANDLED; |
| 326 | } |
| 327 | |
| 328 | static struct irqaction irq_resched = { |
| 329 | .handler = ipi_resched_interrupt, |
Yong Zhang | 8b5690f | 2011-11-22 14:38:03 +0000 | [diff] [blame] | 330 | .flags = IRQF_PERCPU, |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 331 | .name = "IPI_resched" |
| 332 | }; |
| 333 | |
| 334 | static struct irqaction irq_call = { |
| 335 | .handler = ipi_call_interrupt, |
Yong Zhang | 8b5690f | 2011-11-22 14:38:03 +0000 | [diff] [blame] | 336 | .flags = IRQF_PERCPU, |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 337 | .name = "IPI_call" |
| 338 | }; |
Raghu Gandham | 008ee96 | 2009-07-08 17:00:44 -0700 | [diff] [blame] | 339 | #endif /* CONFIG_MIPS_MT_SMP */ |
Tim Anderson | a214cef | 2009-06-17 16:22:25 -0700 | [diff] [blame] | 340 | |
| 341 | static int gic_resched_int_base; |
| 342 | static int gic_call_int_base; |
| 343 | #define GIC_RESCHED_INT(cpu) (gic_resched_int_base+(cpu)) |
| 344 | #define GIC_CALL_INT(cpu) (gic_call_int_base+(cpu)) |
Tim Anderson | 0365070 | 2009-06-17 16:22:53 -0700 | [diff] [blame] | 345 | |
| 346 | unsigned int plat_ipi_call_int_xlate(unsigned int cpu) |
| 347 | { |
| 348 | return GIC_CALL_INT(cpu); |
| 349 | } |
| 350 | |
| 351 | unsigned int plat_ipi_resched_int_xlate(unsigned int cpu) |
| 352 | { |
| 353 | return GIC_RESCHED_INT(cpu); |
| 354 | } |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 355 | |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 356 | static struct irqaction i8259irq = { |
| 357 | .handler = no_action, |
Wu Zhangjin | 5a4a4ad | 2011-07-23 12:41:24 +0000 | [diff] [blame] | 358 | .name = "XT-PIC cascade", |
| 359 | .flags = IRQF_NO_THREAD, |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 360 | }; |
| 361 | |
| 362 | static struct irqaction corehi_irqaction = { |
| 363 | .handler = no_action, |
Wu Zhangjin | 5a4a4ad | 2011-07-23 12:41:24 +0000 | [diff] [blame] | 364 | .name = "CoreHi", |
| 365 | .flags = IRQF_NO_THREAD, |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 366 | }; |
| 367 | |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 368 | static msc_irqmap_t msc_irqmap[] __initdata = { |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 369 | {MSC01C_INT_TMR, MSC01_IRQ_EDGE, 0}, |
| 370 | {MSC01C_INT_PCI, MSC01_IRQ_LEVEL, 0}, |
| 371 | }; |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 372 | static int msc_nr_irqs __initdata = ARRAY_SIZE(msc_irqmap); |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 373 | |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 374 | static msc_irqmap_t msc_eicirqmap[] __initdata = { |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 375 | {MSC01E_INT_SW0, MSC01_IRQ_LEVEL, 0}, |
| 376 | {MSC01E_INT_SW1, MSC01_IRQ_LEVEL, 0}, |
| 377 | {MSC01E_INT_I8259A, MSC01_IRQ_LEVEL, 0}, |
| 378 | {MSC01E_INT_SMI, MSC01_IRQ_LEVEL, 0}, |
| 379 | {MSC01E_INT_COREHI, MSC01_IRQ_LEVEL, 0}, |
| 380 | {MSC01E_INT_CORELO, MSC01_IRQ_LEVEL, 0}, |
| 381 | {MSC01E_INT_TMR, MSC01_IRQ_EDGE, 0}, |
| 382 | {MSC01E_INT_PCI, MSC01_IRQ_LEVEL, 0}, |
| 383 | {MSC01E_INT_PERFCTR, MSC01_IRQ_LEVEL, 0}, |
| 384 | {MSC01E_INT_CPUCTR, MSC01_IRQ_LEVEL, 0} |
| 385 | }; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 386 | |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 387 | static int msc_nr_eicirqs __initdata = ARRAY_SIZE(msc_eicirqmap); |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 388 | |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 389 | /* |
| 390 | * This GIC specific tabular array defines the association between External |
| 391 | * Interrupts and CPUs/Core Interrupts. The nature of the External |
| 392 | * Interrupts is also defined here - polarity/trigger. |
| 393 | */ |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 394 | |
| 395 | #define GIC_CPU_NMI GIC_MAP_TO_NMI_MSK |
Ralf Baechle | 863cb9b | 2010-09-17 17:07:48 +0100 | [diff] [blame] | 396 | #define X GIC_UNUSED |
| 397 | |
Tim Anderson | a214cef | 2009-06-17 16:22:25 -0700 | [diff] [blame] | 398 | static struct gic_intr_map gic_intr_map[GIC_NUM_INTRS] = { |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 399 | { X, X, X, X, 0 }, |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 400 | { X, X, X, X, 0 }, |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 401 | { X, X, X, X, 0 }, |
| 402 | { 0, GIC_CPU_INT0, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT }, |
| 403 | { 0, GIC_CPU_INT1, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT }, |
| 404 | { 0, GIC_CPU_INT2, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT }, |
| 405 | { 0, GIC_CPU_INT3, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT }, |
| 406 | { 0, GIC_CPU_INT4, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT }, |
| 407 | { 0, GIC_CPU_INT3, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT }, |
| 408 | { 0, GIC_CPU_INT3, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT }, |
| 409 | { X, X, X, X, 0 }, |
| 410 | { X, X, X, X, 0 }, |
| 411 | { 0, GIC_CPU_INT3, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT }, |
| 412 | { 0, GIC_CPU_NMI, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT }, |
| 413 | { 0, GIC_CPU_NMI, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT }, |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 414 | { X, X, X, X, 0 }, |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 415 | /* The remainder of this table is initialised by fill_ipi_map */ |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 416 | }; |
Ralf Baechle | 863cb9b | 2010-09-17 17:07:48 +0100 | [diff] [blame] | 417 | #undef X |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 418 | |
Dmitri Vorobiev | 7afed6a | 2008-06-18 10:18:21 +0300 | [diff] [blame] | 419 | #if defined(CONFIG_MIPS_MT_SMP) |
Tim Anderson | a214cef | 2009-06-17 16:22:25 -0700 | [diff] [blame] | 420 | static void __init fill_ipi_map1(int baseintr, int cpu, int cpupin) |
| 421 | { |
| 422 | int intr = baseintr + cpu; |
Tim Anderson | a214cef | 2009-06-17 16:22:25 -0700 | [diff] [blame] | 423 | gic_intr_map[intr].cpunum = cpu; |
| 424 | gic_intr_map[intr].pin = cpupin; |
| 425 | gic_intr_map[intr].polarity = GIC_POL_POS; |
| 426 | gic_intr_map[intr].trigtype = GIC_TRIG_EDGE; |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 427 | gic_intr_map[intr].flags = GIC_FLAG_IPI; |
Tim Anderson | a214cef | 2009-06-17 16:22:25 -0700 | [diff] [blame] | 428 | ipi_map[cpu] |= (1 << (cpupin + 2)); |
| 429 | } |
| 430 | |
Dmitri Vorobiev | 7afed6a | 2008-06-18 10:18:21 +0300 | [diff] [blame] | 431 | static void __init fill_ipi_map(void) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 432 | { |
Tim Anderson | a214cef | 2009-06-17 16:22:25 -0700 | [diff] [blame] | 433 | int cpu; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 434 | |
Markos Chandras | 13b7ea6 | 2013-10-30 14:27:48 +0000 | [diff] [blame] | 435 | for (cpu = 0; cpu < nr_cpu_ids; cpu++) { |
Tim Anderson | a214cef | 2009-06-17 16:22:25 -0700 | [diff] [blame] | 436 | fill_ipi_map1(gic_resched_int_base, cpu, GIC_CPU_INT1); |
| 437 | fill_ipi_map1(gic_call_int_base, cpu, GIC_CPU_INT2); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 438 | } |
| 439 | } |
Dmitri Vorobiev | 7afed6a | 2008-06-18 10:18:21 +0300 | [diff] [blame] | 440 | #endif |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 441 | |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 442 | void __init arch_init_ipiirq(int irq, struct irqaction *action) |
| 443 | { |
| 444 | setup_irq(irq, action); |
Thomas Gleixner | e4ec798 | 2011-03-27 15:19:28 +0200 | [diff] [blame] | 445 | irq_set_handler(irq, handle_percpu_irq); |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 446 | } |
| 447 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 448 | void __init arch_init_irq(void) |
| 449 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | init_i8259_irqs(); |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 451 | |
| 452 | if (!cpu_has_veic) |
Atsushi Nemoto | 97dcb82 | 2007-01-08 02:14:29 +0900 | [diff] [blame] | 453 | mips_cpu_irq_init(); |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 454 | |
Paul Burton | 237036d | 2014-01-15 10:31:54 +0000 | [diff] [blame] | 455 | if (mips_cm_present()) { |
| 456 | write_gcr_gic_base(GIC_BASE_ADDR | CM_GCR_GIC_BASE_GICEN_MSK); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 457 | gic_present = 1; |
| 458 | } else { |
Jaidev Patwardhan | 05cf207 | 2009-07-10 01:54:25 -0700 | [diff] [blame] | 459 | if (mips_revision_sconid == MIPS_REVISION_SCON_ROCIT) { |
| 460 | _msc01_biu_base = (unsigned long) |
| 461 | ioremap_nocache(MSC01_BIU_REG_BASE, |
| 462 | MSC01_BIU_ADDRSPACE_SZ); |
| 463 | gic_present = (REG(_msc01_biu_base, MSC01_SC_CFG) & |
| 464 | MSC01_SC_CFG_GICPRES_MSK) >> |
| 465 | MSC01_SC_CFG_GICPRES_SHF; |
| 466 | } |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 467 | } |
| 468 | if (gic_present) |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 469 | pr_debug("GIC present\n"); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 470 | |
Dmitri Vorobiev | af82558 | 2008-01-24 19:52:45 +0300 | [diff] [blame] | 471 | switch (mips_revision_sconid) { |
| 472 | case MIPS_REVISION_SCON_SOCIT: |
| 473 | case MIPS_REVISION_SCON_ROCIT: |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 474 | if (cpu_has_veic) |
Dmitri Vorobiev | f807149 | 2008-01-24 19:52:47 +0300 | [diff] [blame] | 475 | init_msc_irqs(MIPS_MSC01_IC_REG_BASE, |
| 476 | MSC01E_INT_BASE, msc_eicirqmap, |
| 477 | msc_nr_eicirqs); |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 478 | else |
Dmitri Vorobiev | f807149 | 2008-01-24 19:52:47 +0300 | [diff] [blame] | 479 | init_msc_irqs(MIPS_MSC01_IC_REG_BASE, |
| 480 | MSC01C_INT_BASE, msc_irqmap, |
| 481 | msc_nr_irqs); |
Chris Dearman | d725cf3 | 2007-05-08 14:05:39 +0100 | [diff] [blame] | 482 | break; |
| 483 | |
Dmitri Vorobiev | af82558 | 2008-01-24 19:52:45 +0300 | [diff] [blame] | 484 | case MIPS_REVISION_SCON_SOCITSC: |
| 485 | case MIPS_REVISION_SCON_SOCITSCP: |
Chris Dearman | d725cf3 | 2007-05-08 14:05:39 +0100 | [diff] [blame] | 486 | if (cpu_has_veic) |
Dmitri Vorobiev | f807149 | 2008-01-24 19:52:47 +0300 | [diff] [blame] | 487 | init_msc_irqs(MIPS_SOCITSC_IC_REG_BASE, |
| 488 | MSC01E_INT_BASE, msc_eicirqmap, |
| 489 | msc_nr_eicirqs); |
Chris Dearman | d725cf3 | 2007-05-08 14:05:39 +0100 | [diff] [blame] | 490 | else |
Dmitri Vorobiev | f807149 | 2008-01-24 19:52:47 +0300 | [diff] [blame] | 491 | init_msc_irqs(MIPS_SOCITSC_IC_REG_BASE, |
| 492 | MSC01C_INT_BASE, msc_irqmap, |
| 493 | msc_nr_irqs); |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | if (cpu_has_veic) { |
Ralf Baechle | 49a89ef | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 497 | set_vi_handler(MSC01E_INT_I8259A, malta_hw0_irqdispatch); |
| 498 | set_vi_handler(MSC01E_INT_COREHI, corehi_irqdispatch); |
| 499 | setup_irq(MSC01E_INT_BASE+MSC01E_INT_I8259A, &i8259irq); |
| 500 | setup_irq(MSC01E_INT_BASE+MSC01E_INT_COREHI, &corehi_irqaction); |
Dmitri Vorobiev | 52b3fc0 | 2008-01-24 19:52:51 +0300 | [diff] [blame] | 501 | } else if (cpu_has_vint) { |
Ralf Baechle | 49a89ef | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 502 | set_vi_handler(MIPSCPU_INT_I8259A, malta_hw0_irqdispatch); |
| 503 | set_vi_handler(MIPSCPU_INT_COREHI, corehi_irqdispatch); |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 504 | #ifdef CONFIG_MIPS_MT_SMTC |
Ralf Baechle | 49a89ef | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 505 | setup_irq_smtc(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_I8259A, &i8259irq, |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 506 | (0x100 << MIPSCPU_INT_I8259A)); |
Ralf Baechle | 49a89ef | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 507 | setup_irq_smtc(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_COREHI, |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 508 | &corehi_irqaction, (0x100 << MIPSCPU_INT_COREHI)); |
Kevin D. Kissell | c3a005f | 2007-07-27 18:45:25 +0100 | [diff] [blame] | 509 | /* |
| 510 | * Temporary hack to ensure that the subsidiary device |
| 511 | * interrupts coing in via the i8259A, but associated |
| 512 | * with low IRQ numbers, will restore the Status.IM |
| 513 | * value associated with the i8259A. |
| 514 | */ |
| 515 | { |
| 516 | int i; |
| 517 | |
| 518 | for (i = 0; i < 16; i++) |
| 519 | irq_hwmask[i] = (0x100 << MIPSCPU_INT_I8259A); |
| 520 | } |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 521 | #else /* Not SMTC */ |
Ralf Baechle | 49a89ef | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 522 | setup_irq(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_I8259A, &i8259irq); |
Dmitri Vorobiev | f807149 | 2008-01-24 19:52:47 +0300 | [diff] [blame] | 523 | setup_irq(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_COREHI, |
| 524 | &corehi_irqaction); |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 525 | #endif /* CONFIG_MIPS_MT_SMTC */ |
Dmitri Vorobiev | 52b3fc0 | 2008-01-24 19:52:51 +0300 | [diff] [blame] | 526 | } else { |
Ralf Baechle | 49a89ef | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 527 | setup_irq(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_I8259A, &i8259irq); |
Dmitri Vorobiev | f807149 | 2008-01-24 19:52:47 +0300 | [diff] [blame] | 528 | setup_irq(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_COREHI, |
| 529 | &corehi_irqaction); |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 530 | } |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 531 | |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 532 | if (gic_present) { |
| 533 | /* FIXME */ |
| 534 | int i; |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 535 | #if defined(CONFIG_MIPS_MT_SMP) |
Markos Chandras | 13b7ea6 | 2013-10-30 14:27:48 +0000 | [diff] [blame] | 536 | gic_call_int_base = GIC_NUM_INTRS - |
| 537 | (NR_CPUS - nr_cpu_ids) * 2 - nr_cpu_ids; |
| 538 | gic_resched_int_base = gic_call_int_base - nr_cpu_ids; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 539 | fill_ipi_map(); |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 540 | #endif |
| 541 | gic_init(GIC_BASE_ADDR, GIC_ADDRSPACE_SZ, gic_intr_map, |
| 542 | ARRAY_SIZE(gic_intr_map), MIPS_GIC_IRQ_BASE); |
Paul Burton | 237036d | 2014-01-15 10:31:54 +0000 | [diff] [blame] | 543 | if (!mips_cm_present()) { |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 544 | /* Enable the GIC */ |
| 545 | i = REG(_msc01_biu_base, MSC01_SC_CFG); |
| 546 | REG(_msc01_biu_base, MSC01_SC_CFG) = |
| 547 | (i | (0x1 << MSC01_SC_CFG_GICENA_SHF)); |
| 548 | pr_debug("GIC Enabled\n"); |
| 549 | } |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 550 | #if defined(CONFIG_MIPS_MT_SMP) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 551 | /* set up ipi interrupts */ |
| 552 | if (cpu_has_vint) { |
| 553 | set_vi_handler(MIPSCPU_INT_IPI0, malta_ipi_irqdispatch); |
| 554 | set_vi_handler(MIPSCPU_INT_IPI1, malta_ipi_irqdispatch); |
| 555 | } |
| 556 | /* Argh.. this really needs sorting out.. */ |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 557 | pr_info("CPU%d: status register was %08x\n", |
| 558 | smp_processor_id(), read_c0_status()); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 559 | write_c0_status(read_c0_status() | STATUSF_IP3 | STATUSF_IP4); |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 560 | pr_info("CPU%d: status register now %08x\n", |
| 561 | smp_processor_id(), read_c0_status()); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 562 | write_c0_status(0x1100dc00); |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 563 | pr_info("CPU%d: status register frc %08x\n", |
| 564 | smp_processor_id(), read_c0_status()); |
Markos Chandras | 13b7ea6 | 2013-10-30 14:27:48 +0000 | [diff] [blame] | 565 | for (i = 0; i < nr_cpu_ids; i++) { |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 566 | arch_init_ipiirq(MIPS_GIC_IRQ_BASE + |
| 567 | GIC_RESCHED_INT(i), &irq_resched); |
| 568 | arch_init_ipiirq(MIPS_GIC_IRQ_BASE + |
| 569 | GIC_CALL_INT(i), &irq_call); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 570 | } |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 571 | #endif |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 572 | } else { |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 573 | #if defined(CONFIG_MIPS_MT_SMP) |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 574 | /* set up ipi interrupts */ |
| 575 | if (cpu_has_veic) { |
| 576 | set_vi_handler (MSC01E_INT_SW0, ipi_resched_dispatch); |
| 577 | set_vi_handler (MSC01E_INT_SW1, ipi_call_dispatch); |
| 578 | cpu_ipi_resched_irq = MSC01E_INT_SW0; |
| 579 | cpu_ipi_call_irq = MSC01E_INT_SW1; |
| 580 | } else { |
| 581 | if (cpu_has_vint) { |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 582 | set_vi_handler (MIPS_CPU_IPI_RESCHED_IRQ, |
| 583 | ipi_resched_dispatch); |
| 584 | set_vi_handler (MIPS_CPU_IPI_CALL_IRQ, |
| 585 | ipi_call_dispatch); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 586 | } |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 587 | cpu_ipi_resched_irq = MIPS_CPU_IRQ_BASE + |
| 588 | MIPS_CPU_IPI_RESCHED_IRQ; |
| 589 | cpu_ipi_call_irq = MIPS_CPU_IRQ_BASE + |
| 590 | MIPS_CPU_IPI_CALL_IRQ; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 591 | } |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 592 | arch_init_ipiirq(cpu_ipi_resched_irq, &irq_resched); |
| 593 | arch_init_ipiirq(cpu_ipi_call_irq, &irq_call); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 594 | #endif |
Chris Dearman | 7098f74 | 2009-07-10 01:54:09 -0700 | [diff] [blame] | 595 | } |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 596 | } |
| 597 | |
| 598 | void malta_be_init(void) |
| 599 | { |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 600 | /* Could change CM error mask register. */ |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 601 | } |
| 602 | |
| 603 | |
| 604 | static char *tr[8] = { |
| 605 | "mem", "gcr", "gic", "mmio", |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 606 | "0x04", "0x05", "0x06", "0x07" |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 607 | }; |
| 608 | |
| 609 | static char *mcmd[32] = { |
| 610 | [0x00] = "0x00", |
| 611 | [0x01] = "Legacy Write", |
| 612 | [0x02] = "Legacy Read", |
| 613 | [0x03] = "0x03", |
| 614 | [0x04] = "0x04", |
| 615 | [0x05] = "0x05", |
| 616 | [0x06] = "0x06", |
| 617 | [0x07] = "0x07", |
| 618 | [0x08] = "Coherent Read Own", |
| 619 | [0x09] = "Coherent Read Share", |
| 620 | [0x0a] = "Coherent Read Discard", |
| 621 | [0x0b] = "Coherent Ready Share Always", |
| 622 | [0x0c] = "Coherent Upgrade", |
| 623 | [0x0d] = "Coherent Writeback", |
| 624 | [0x0e] = "0x0e", |
| 625 | [0x0f] = "0x0f", |
| 626 | [0x10] = "Coherent Copyback", |
| 627 | [0x11] = "Coherent Copyback Invalidate", |
| 628 | [0x12] = "Coherent Invalidate", |
| 629 | [0x13] = "Coherent Write Invalidate", |
| 630 | [0x14] = "Coherent Completion Sync", |
| 631 | [0x15] = "0x15", |
| 632 | [0x16] = "0x16", |
| 633 | [0x17] = "0x17", |
| 634 | [0x18] = "0x18", |
| 635 | [0x19] = "0x19", |
| 636 | [0x1a] = "0x1a", |
| 637 | [0x1b] = "0x1b", |
| 638 | [0x1c] = "0x1c", |
| 639 | [0x1d] = "0x1d", |
| 640 | [0x1e] = "0x1e", |
| 641 | [0x1f] = "0x1f" |
| 642 | }; |
| 643 | |
| 644 | static char *core[8] = { |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 645 | "Invalid/OK", "Invalid/Data", |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 646 | "Shared/OK", "Shared/Data", |
| 647 | "Modified/OK", "Modified/Data", |
Ralf Baechle | 7034228 | 2013-01-22 12:59:30 +0100 | [diff] [blame] | 648 | "Exclusive/OK", "Exclusive/Data" |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 649 | }; |
| 650 | |
| 651 | static char *causes[32] = { |
| 652 | "None", "GC_WR_ERR", "GC_RD_ERR", "COH_WR_ERR", |
| 653 | "COH_RD_ERR", "MMIO_WR_ERR", "MMIO_RD_ERR", "0x07", |
| 654 | "0x08", "0x09", "0x0a", "0x0b", |
| 655 | "0x0c", "0x0d", "0x0e", "0x0f", |
| 656 | "0x10", "0x11", "0x12", "0x13", |
| 657 | "0x14", "0x15", "0x16", "INTVN_WR_ERR", |
| 658 | "INTVN_RD_ERR", "0x19", "0x1a", "0x1b", |
| 659 | "0x1c", "0x1d", "0x1e", "0x1f" |
| 660 | }; |
| 661 | |
| 662 | int malta_be_handler(struct pt_regs *regs, int is_fixup) |
| 663 | { |
| 664 | /* This duplicates the handling in do_be which seems wrong */ |
| 665 | int retval = is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL; |
| 666 | |
Paul Burton | 237036d | 2014-01-15 10:31:54 +0000 | [diff] [blame] | 667 | if (mips_cm_present()) { |
| 668 | unsigned long cm_error = read_gcr_error_cause(); |
| 669 | unsigned long cm_addr = read_gcr_error_addr(); |
| 670 | unsigned long cm_other = read_gcr_error_mult(); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 671 | unsigned long cause, ocause; |
| 672 | char buf[256]; |
| 673 | |
Paul Burton | 237036d | 2014-01-15 10:31:54 +0000 | [diff] [blame] | 674 | cause = cm_error & CM_GCR_ERROR_CAUSE_ERRTYPE_MSK; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 675 | if (cause != 0) { |
Paul Burton | 237036d | 2014-01-15 10:31:54 +0000 | [diff] [blame] | 676 | cause >>= CM_GCR_ERROR_CAUSE_ERRTYPE_SHF; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 677 | if (cause < 16) { |
| 678 | unsigned long cca_bits = (cm_error >> 15) & 7; |
| 679 | unsigned long tr_bits = (cm_error >> 12) & 7; |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 680 | unsigned long cmd_bits = (cm_error >> 7) & 0x1f; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 681 | unsigned long stag_bits = (cm_error >> 3) & 15; |
| 682 | unsigned long sport_bits = (cm_error >> 0) & 7; |
| 683 | |
| 684 | snprintf(buf, sizeof(buf), |
| 685 | "CCA=%lu TR=%s MCmd=%s STag=%lu " |
| 686 | "SPort=%lu\n", |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 687 | cca_bits, tr[tr_bits], mcmd[cmd_bits], |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 688 | stag_bits, sport_bits); |
| 689 | } else { |
| 690 | /* glob state & sresp together */ |
| 691 | unsigned long c3_bits = (cm_error >> 18) & 7; |
| 692 | unsigned long c2_bits = (cm_error >> 15) & 7; |
| 693 | unsigned long c1_bits = (cm_error >> 12) & 7; |
| 694 | unsigned long c0_bits = (cm_error >> 9) & 7; |
| 695 | unsigned long sc_bit = (cm_error >> 8) & 1; |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 696 | unsigned long cmd_bits = (cm_error >> 3) & 0x1f; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 697 | unsigned long sport_bits = (cm_error >> 0) & 7; |
| 698 | snprintf(buf, sizeof(buf), |
| 699 | "C3=%s C2=%s C1=%s C0=%s SC=%s " |
| 700 | "MCmd=%s SPort=%lu\n", |
| 701 | core[c3_bits], core[c2_bits], |
| 702 | core[c1_bits], core[c0_bits], |
| 703 | sc_bit ? "True" : "False", |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 704 | mcmd[cmd_bits], sport_bits); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 705 | } |
| 706 | |
Paul Burton | 237036d | 2014-01-15 10:31:54 +0000 | [diff] [blame] | 707 | ocause = (cm_other & CM_GCR_ERROR_MULT_ERR2ND_MSK) >> |
| 708 | CM_GCR_ERROR_MULT_ERR2ND_SHF; |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 709 | |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 710 | pr_err("CM_ERROR=%08lx %s <%s>\n", cm_error, |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 711 | causes[cause], buf); |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 712 | pr_err("CM_ADDR =%08lx\n", cm_addr); |
| 713 | pr_err("CM_OTHER=%08lx %s\n", cm_other, causes[ocause]); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 714 | |
| 715 | /* reprime cause register */ |
Paul Burton | 237036d | 2014-01-15 10:31:54 +0000 | [diff] [blame] | 716 | write_gcr_error_cause(0); |
Ralf Baechle | 39b8d52 | 2008-04-28 17:14:26 +0100 | [diff] [blame] | 717 | } |
| 718 | } |
| 719 | |
| 720 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 721 | } |
Steven J. Hill | 0b271f5 | 2012-08-31 16:05:37 -0500 | [diff] [blame] | 722 | |
| 723 | void gic_enable_interrupt(int irq_vec) |
| 724 | { |
| 725 | GIC_SET_INTR_MASK(irq_vec); |
| 726 | } |
| 727 | |
| 728 | void gic_disable_interrupt(int irq_vec) |
| 729 | { |
| 730 | GIC_CLR_INTR_MASK(irq_vec); |
| 731 | } |
| 732 | |
| 733 | void gic_irq_ack(struct irq_data *d) |
| 734 | { |
| 735 | int irq = (d->irq - gic_irq_base); |
| 736 | |
| 737 | GIC_CLR_INTR_MASK(irq); |
| 738 | |
| 739 | if (gic_irq_flags[irq] & GIC_TRIG_EDGE) |
| 740 | GICWRITE(GIC_REG(SHARED, GIC_SH_WEDGE), irq); |
| 741 | } |
| 742 | |
| 743 | void gic_finish_irq(struct irq_data *d) |
| 744 | { |
| 745 | /* Enable interrupts. */ |
| 746 | GIC_SET_INTR_MASK(d->irq - gic_irq_base); |
| 747 | } |
| 748 | |
| 749 | void __init gic_platform_init(int irqs, struct irq_chip *irq_controller) |
| 750 | { |
| 751 | int i; |
| 752 | |
| 753 | for (i = gic_irq_base; i < (gic_irq_base + irqs); i++) |
| 754 | irq_set_chip(i, irq_controller); |
| 755 | } |