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