blob: ca3e3a46a42f90dedc359c1729d7b3c55365fc92 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Steven J. Hill5792bf62014-01-01 16:35:32 +01002 * 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 Torvalds1da177e2005-04-16 15:20:36 -07006 * Carsten Langgaard, carstenl@mips.com
7 * Copyright (C) 2000, 2001, 2004 MIPS Technologies, Inc.
8 * Copyright (C) 2001 Ralf Baechle
Deng-Cheng Zhu13361132013-10-30 15:52:10 -05009 * Copyright (C) 2013 Imagination Technologies Ltd.
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070011 * Routines for generic manipulation of the interrupts found on the MIPS
Steven J. Hill5792bf62014-01-01 16:35:32 +010012 * Malta board. The interrupt controller is located in the South Bridge
13 * a PIIX4 device with two internal 82C95 interrupt controllers.
Linus Torvalds1da177e2005-04-16 15:20:36 -070014 */
15#include <linux/init.h>
16#include <linux/irq.h>
17#include <linux/sched.h>
Ralf Baechle631330f2009-06-19 14:05:26 +010018#include <linux/smp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <linux/interrupt.h>
Dmitri Vorobiev54bf0382008-01-24 19:52:49 +030020#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/kernel_stat.h>
Ahmed S. Darwish25b8ac32007-02-05 04:42:11 +020022#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/random.h>
24
Ralf Baechle39b8d522008-04-28 17:14:26 +010025#include <asm/traps.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <asm/i8259.h>
Ralf Baechlee01402b2005-07-14 15:57:16 +000027#include <asm/irq_cpu.h>
Ralf Baechleba38cdf2006-10-15 09:17:43 +010028#include <asm/irq_regs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <asm/mips-boards/malta.h>
30#include <asm/mips-boards/maltaint.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <asm/gt64120.h>
32#include <asm/mips-boards/generic.h>
33#include <asm/mips-boards/msc01_pci.h>
Ralf Baechlee01402b2005-07-14 15:57:16 +000034#include <asm/msc01_ic.h>
Ralf Baechle39b8d522008-04-28 17:14:26 +010035#include <asm/gic.h>
36#include <asm/gcmpregs.h>
David Howellsb81947c2012-03-28 18:30:02 +010037#include <asm/setup.h>
Deng-Cheng Zhu13361132013-10-30 15:52:10 -050038#include <asm/rtlx.h>
Ralf Baechle39b8d522008-04-28 17:14:26 +010039
40int gcmp_present = -1;
Ralf Baechle39b8d522008-04-28 17:14:26 +010041static unsigned long _msc01_biu_base;
42static unsigned long _gcmp_base;
43static unsigned int ipi_map[NR_CPUS];
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Ralf Baechlea963dc72010-02-27 12:53:32 +010045static DEFINE_RAW_SPINLOCK(mips_irq_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
47static inline int mips_pcibios_iack(void)
48{
49 int irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51 /*
52 * Determine highest priority pending interrupt by performing
53 * a PCI Interrupt Acknowledge cycle.
54 */
Chris Dearmanb72c0522007-04-27 15:58:41 +010055 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 Vorobievaf825582008-01-24 19:52:45 +030060 MSC_READ(MSC01_PCI_IACK, irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 irq &= 0xff;
62 break;
Chris Dearmanb72c0522007-04-27 15:58:41 +010063 case MIPS_REVISION_SCON_GT64120:
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 irq = GT_READ(GT_PCI0_IACK_OFS);
65 irq &= 0xff;
66 break;
Chris Dearmanb72c0522007-04-27 15:58:41 +010067 case MIPS_REVISION_SCON_BONITO:
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 /* 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 Baechle6be63bb2011-03-29 11:48:22 +020076 (void) BONITO_PCIMAP_CFG;
Ralf Baechle70342282013-01-22 12:59:30 +010077 iob(); /* sync */
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
Chris Dearmanaccfd352009-07-10 01:53:54 -070079 irq = __raw_readl((u32 *)_pcictrl_bonito_pcicfg);
Ralf Baechle70342282013-01-22 12:59:30 +010080 iob(); /* sync */
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 irq &= 0xff;
82 BONITO_PCIMAP_CFG = 0;
83 break;
84 default:
Steven J. Hill5792bf62014-01-01 16:35:32 +010085 pr_emerg("Unknown system controller.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -070086 return -1;
87 }
88 return irq;
89}
90
Ralf Baechlee01402b2005-07-14 15:57:16 +000091static inline int get_int(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070092{
93 unsigned long flags;
Ralf Baechlee01402b2005-07-14 15:57:16 +000094 int irq;
Ralf Baechlea963dc72010-02-27 12:53:32 +010095 raw_spin_lock_irqsave(&mips_irq_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
Ralf Baechlee01402b2005-07-14 15:57:16 +000097 irq = mips_pcibios_iack();
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
99 /*
Ralf Baechle479a0e32005-08-16 15:44:06 +0000100 * 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 Torvalds1da177e2005-04-16 15:20:36 -0700103 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
Ralf Baechlea963dc72010-02-27 12:53:32 +0100105 raw_spin_unlock_irqrestore(&mips_irq_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
Ralf Baechlee01402b2005-07-14 15:57:16 +0000107 return irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108}
109
Ralf Baechle937a8012006-10-07 19:44:33 +0100110static void malta_hw0_irqdispatch(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111{
112 int irq;
113
Ralf Baechlee01402b2005-07-14 15:57:16 +0000114 irq = get_int();
Ralf Baechle41c594a2006-04-05 09:45:45 +0100115 if (irq < 0) {
Dmitri Vorobievcd80d542008-01-24 19:52:54 +0300116 /* interrupt has already been cleared */
117 return;
Ralf Baechle41c594a2006-04-05 09:45:45 +0100118 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
Ralf Baechle937a8012006-10-07 19:44:33 +0100120 do_IRQ(MALTA_INT_BASE + irq);
Deng-Cheng Zhu13361132013-10-30 15:52:10 -0500121
122#ifdef MIPS_VPE_APSP_API
123 if (aprp_hook)
124 aprp_hook();
125#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126}
127
Ralf Baechle39b8d522008-04-28 17:14:26 +0100128static void malta_ipi_irqdispatch(void)
129{
130 int irq;
131
Raghu Gandham0ab2b7d2013-04-10 16:30:12 -0500132 if (gic_compare_int())
133 do_IRQ(MIPS_GIC_IRQ_BASE);
134
Ralf Baechle39b8d522008-04-28 17:14:26 +0100135 irq = gic_get_int();
136 if (irq < 0)
Ralf Baechle70342282013-01-22 12:59:30 +0100137 return; /* interrupt has already been cleared */
Ralf Baechle39b8d522008-04-28 17:14:26 +0100138
139 do_IRQ(MIPS_GIC_IRQ_BASE + irq);
140}
141
Ralf Baechle937a8012006-10-07 19:44:33 +0100142static void corehi_irqdispatch(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143{
Ralf Baechle937a8012006-10-07 19:44:33 +0100144 unsigned int intedge, intsteer, pcicmd, pcibadaddr;
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300145 unsigned int pcimstat, intisr, inten, intpol;
Ralf Baechle21a151d2007-10-11 23:46:15 +0100146 unsigned int intrcause, datalo, datahi;
Ralf Baechleba38cdf2006-10-15 09:17:43 +0100147 struct pt_regs *regs = get_irq_regs();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148
Steven J. Hill5792bf62014-01-01 16:35:32 +0100149 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 Baechlee01402b2005-07-14 15:57:16 +0000154
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 Dearmanb72c0522007-04-27 15:58:41 +0100160 switch (mips_revision_sconid) {
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300161 case MIPS_REVISION_SCON_SOCIT:
Chris Dearmanb72c0522007-04-27 15:58:41 +0100162 case MIPS_REVISION_SCON_ROCIT:
163 case MIPS_REVISION_SCON_SOCITSC:
164 case MIPS_REVISION_SCON_SOCITSCP:
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300165 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. Hill5792bf62014-01-01 16:35:32 +0100171 pr_emerg("GT_INTRCAUSE = %08x\n", intrcause);
172 pr_emerg("GT_CPUERR_ADDR = %02x%08x\n",
Dmitri Vorobiev8216d342008-01-24 19:52:42 +0300173 datahi, datalo);
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300174 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. Hill5792bf62014-01-01 16:35:32 +0100184 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 Vorobievaf825582008-01-24 19:52:45 +0300192 break;
193 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300195 die("CoreHi interrupt", regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196}
197
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100198static inline int clz(unsigned long x)
199{
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100200 __asm__(
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100201 " .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 */
214static 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 Baechle0118c3c2006-06-05 11:54:41 +0100222 t0 = pending & 0xf000;
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100223 t0 = t0 < 1;
224 t0 = t0 << 2;
225 a0 = a0 - t0;
Ralf Baechle0118c3c2006-06-05 11:54:41 +0100226 pending = pending << t0;
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100227
Ralf Baechle0118c3c2006-06-05 11:54:41 +0100228 t0 = pending & 0xc000;
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100229 t0 = t0 < 1;
230 t0 = t0 << 1;
231 a0 = a0 - t0;
Ralf Baechle0118c3c2006-06-05 11:54:41 +0100232 pending = pending << t0;
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100233
Ralf Baechle0118c3c2006-06-05 11:54:41 +0100234 t0 = pending & 0x8000;
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100235 t0 = t0 < 1;
Dmitri Vorobievae9cef02008-01-24 19:52:52 +0300236 /* t0 = t0 << 2; */
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100237 a0 = a0 - t0;
Dmitri Vorobievae9cef02008-01-24 19:52:52 +0300238 /* pending = pending << t0; */
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100239
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 Baechle70342282013-01-22 12:59:30 +0100250 * -------- ------
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 Baechlee4ac58a2006-04-03 17:56:36 +0100259 *
260 * We handle the IRQ according to _our_ priority which is:
261 *
Ralf Baechle70342282013-01-22 12:59:30 +0100262 * Highest ---- R4k Timer
263 * Lowest ---- Combined hardware interrupt
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100264 *
265 * then we just return, if multiple IRQs are pending then we will just take
266 * another exception, big deal.
267 */
268
Ralf Baechle937a8012006-10-07 19:44:33 +0100269asmlinkage void plat_irq_dispatch(void)
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100270{
271 unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM;
272 int irq;
273
Ralf Baechlee376fdf2012-09-17 01:23:21 +0200274 if (unlikely(!pending)) {
275 spurious_interrupt();
276 return;
277 }
278
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100279 irq = irq_ffs(pending);
280
281 if (irq == MIPSCPU_INT_I8259A)
Ralf Baechle937a8012006-10-07 19:44:33 +0100282 malta_hw0_irqdispatch();
Ralf Baechle39b8d522008-04-28 17:14:26 +0100283 else if (gic_present && ((1 << irq) & ipi_map[smp_processor_id()]))
284 malta_ipi_irqdispatch();
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100285 else
Ralf Baechlee376fdf2012-09-17 01:23:21 +0200286 do_IRQ(MIPS_CPU_IRQ_BASE + irq);
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100287}
288
Ralf Baechle39b8d522008-04-28 17:14:26 +0100289#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
299static int cpu_ipi_resched_irq, cpu_ipi_call_irq;
300
301static void ipi_resched_dispatch(void)
302{
303 do_IRQ(MIPS_CPU_IRQ_BASE + MIPS_CPU_IPI_RESCHED_IRQ);
304}
305
306static void ipi_call_dispatch(void)
307{
308 do_IRQ(MIPS_CPU_IRQ_BASE + MIPS_CPU_IPI_CALL_IRQ);
309}
310
311static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id)
312{
Deng-Cheng Zhu13361132013-10-30 15:52:10 -0500313#ifdef MIPS_VPE_APSP_API
314 if (aprp_hook)
315 aprp_hook();
316#endif
317
Peter Zijlstra184748c2011-04-05 17:23:39 +0200318 scheduler_ipi();
319
Ralf Baechle39b8d522008-04-28 17:14:26 +0100320 return IRQ_HANDLED;
321}
322
323static irqreturn_t ipi_call_interrupt(int irq, void *dev_id)
324{
325 smp_call_function_interrupt();
326
327 return IRQ_HANDLED;
328}
329
330static struct irqaction irq_resched = {
331 .handler = ipi_resched_interrupt,
Yong Zhang8b5690f2011-11-22 14:38:03 +0000332 .flags = IRQF_PERCPU,
Ralf Baechle39b8d522008-04-28 17:14:26 +0100333 .name = "IPI_resched"
334};
335
336static struct irqaction irq_call = {
337 .handler = ipi_call_interrupt,
Yong Zhang8b5690f2011-11-22 14:38:03 +0000338 .flags = IRQF_PERCPU,
Ralf Baechle39b8d522008-04-28 17:14:26 +0100339 .name = "IPI_call"
340};
Raghu Gandham008ee962009-07-08 17:00:44 -0700341#endif /* CONFIG_MIPS_MT_SMP */
Tim Andersona214cef2009-06-17 16:22:25 -0700342
343static int gic_resched_int_base;
344static 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 Anderson03650702009-06-17 16:22:53 -0700347
348unsigned int plat_ipi_call_int_xlate(unsigned int cpu)
349{
350 return GIC_CALL_INT(cpu);
351}
352
353unsigned int plat_ipi_resched_int_xlate(unsigned int cpu)
354{
355 return GIC_RESCHED_INT(cpu);
356}
Ralf Baechle39b8d522008-04-28 17:14:26 +0100357
Ralf Baechlee01402b2005-07-14 15:57:16 +0000358static struct irqaction i8259irq = {
359 .handler = no_action,
Wu Zhangjin5a4a4ad2011-07-23 12:41:24 +0000360 .name = "XT-PIC cascade",
361 .flags = IRQF_NO_THREAD,
Ralf Baechlee01402b2005-07-14 15:57:16 +0000362};
363
364static struct irqaction corehi_irqaction = {
365 .handler = no_action,
Wu Zhangjin5a4a4ad2011-07-23 12:41:24 +0000366 .name = "CoreHi",
367 .flags = IRQF_NO_THREAD,
Ralf Baechlee01402b2005-07-14 15:57:16 +0000368};
369
Steven J. Hill5792bf62014-01-01 16:35:32 +0100370static msc_irqmap_t msc_irqmap[] __initdata = {
Ralf Baechlee01402b2005-07-14 15:57:16 +0000371 {MSC01C_INT_TMR, MSC01_IRQ_EDGE, 0},
372 {MSC01C_INT_PCI, MSC01_IRQ_LEVEL, 0},
373};
Steven J. Hill5792bf62014-01-01 16:35:32 +0100374static int msc_nr_irqs __initdata = ARRAY_SIZE(msc_irqmap);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000375
Steven J. Hill5792bf62014-01-01 16:35:32 +0100376static msc_irqmap_t msc_eicirqmap[] __initdata = {
Ralf Baechlee01402b2005-07-14 15:57:16 +0000377 {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 Baechle39b8d522008-04-28 17:14:26 +0100388
Steven J. Hill5792bf62014-01-01 16:35:32 +0100389static int msc_nr_eicirqs __initdata = ARRAY_SIZE(msc_eicirqmap);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000390
Ralf Baechle39b8d522008-04-28 17:14:26 +0100391/*
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 Dearman7098f742009-07-10 01:54:09 -0700396
397#define GIC_CPU_NMI GIC_MAP_TO_NMI_MSK
Ralf Baechle863cb9b2010-09-17 17:07:48 +0100398#define X GIC_UNUSED
399
Tim Andersona214cef2009-06-17 16:22:25 -0700400static struct gic_intr_map gic_intr_map[GIC_NUM_INTRS] = {
Chris Dearman7098f742009-07-10 01:54:09 -0700401 { X, X, X, X, 0 },
Ralf Baechle70342282013-01-22 12:59:30 +0100402 { X, X, X, X, 0 },
Chris Dearman7098f742009-07-10 01:54:09 -0700403 { 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 Baechle70342282013-01-22 12:59:30 +0100416 { X, X, X, X, 0 },
Chris Dearman7098f742009-07-10 01:54:09 -0700417 /* The remainder of this table is initialised by fill_ipi_map */
Ralf Baechle39b8d522008-04-28 17:14:26 +0100418};
Ralf Baechle863cb9b2010-09-17 17:07:48 +0100419#undef X
Ralf Baechle39b8d522008-04-28 17:14:26 +0100420
421/*
422 * GCMP needs to be detected before any SMP initialisation
423 */
Tim Anderson47b178b2009-06-17 16:25:18 -0700424int __init gcmp_probe(unsigned long addr, unsigned long size)
Ralf Baechle39b8d522008-04-28 17:14:26 +0100425{
Leonid Yegoshin78276202013-06-20 14:36:42 +0000426 if ((mips_revision_sconid != MIPS_REVISION_SCON_ROCIT) &&
427 (mips_revision_sconid != MIPS_REVISION_SCON_GT64120)) {
Jaidev Patwardhan05cf2072009-07-10 01:54:25 -0700428 gcmp_present = 0;
Leonid Yegoshin78276202013-06-20 14:36:42 +0000429 pr_debug("GCMP NOT present\n");
Jaidev Patwardhan05cf2072009-07-10 01:54:25 -0700430 return gcmp_present;
431 }
432
Ralf Baechle39b8d522008-04-28 17:14:26 +0100433 if (gcmp_present >= 0)
434 return gcmp_present;
435
Steven J. Hill5792bf62014-01-01 16:35:32 +0100436 _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 Baechle39b8d522008-04-28 17:14:26 +0100442
443 if (gcmp_present)
Chris Dearman7098f742009-07-10 01:54:09 -0700444 pr_debug("GCMP present\n");
Ralf Baechle39b8d522008-04-28 17:14:26 +0100445 return gcmp_present;
446}
447
Chris Dearman7098f742009-07-10 01:54:09 -0700448/* Return the number of IOCU's present */
449int __init gcmp_niocu(void)
450{
Steven J. Hill5792bf62014-01-01 16:35:32 +0100451 return gcmp_present ? ((GCMPGCB(GC) & GCMP_GCB_GC_NUMIOCU_MSK) >>
452 GCMP_GCB_GC_NUMIOCU_SHF) : 0;
Chris Dearman7098f742009-07-10 01:54:09 -0700453}
454
455/* Set GCMP region attributes */
456void __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 Vorobiev7afed6a2008-06-18 10:18:21 +0300463#if defined(CONFIG_MIPS_MT_SMP)
Tim Andersona214cef2009-06-17 16:22:25 -0700464static void __init fill_ipi_map1(int baseintr, int cpu, int cpupin)
465{
466 int intr = baseintr + cpu;
Tim Andersona214cef2009-06-17 16:22:25 -0700467 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 Dearman7098f742009-07-10 01:54:09 -0700471 gic_intr_map[intr].flags = GIC_FLAG_IPI;
Tim Andersona214cef2009-06-17 16:22:25 -0700472 ipi_map[cpu] |= (1 << (cpupin + 2));
473}
474
Dmitri Vorobiev7afed6a2008-06-18 10:18:21 +0300475static void __init fill_ipi_map(void)
Ralf Baechle39b8d522008-04-28 17:14:26 +0100476{
Tim Andersona214cef2009-06-17 16:22:25 -0700477 int cpu;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100478
Markos Chandras13b7ea62013-10-30 14:27:48 +0000479 for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
Tim Andersona214cef2009-06-17 16:22:25 -0700480 fill_ipi_map1(gic_resched_int_base, cpu, GIC_CPU_INT1);
481 fill_ipi_map1(gic_call_int_base, cpu, GIC_CPU_INT2);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100482 }
483}
Dmitri Vorobiev7afed6a2008-06-18 10:18:21 +0300484#endif
Ralf Baechle39b8d522008-04-28 17:14:26 +0100485
Chris Dearman7098f742009-07-10 01:54:09 -0700486void __init arch_init_ipiirq(int irq, struct irqaction *action)
487{
488 setup_irq(irq, action);
Thomas Gleixnere4ec7982011-03-27 15:19:28 +0200489 irq_set_handler(irq, handle_percpu_irq);
Chris Dearman7098f742009-07-10 01:54:09 -0700490}
491
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492void __init arch_init_irq(void)
493{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 init_i8259_irqs();
Ralf Baechlee01402b2005-07-14 15:57:16 +0000495
496 if (!cpu_has_veic)
Atsushi Nemoto97dcb822007-01-08 02:14:29 +0900497 mips_cpu_irq_init();
Ralf Baechlee01402b2005-07-14 15:57:16 +0000498
Ralf Baechle39b8d522008-04-28 17:14:26 +0100499 if (gcmp_present) {
500 GCMPGCB(GICBA) = GIC_BASE_ADDR | GCMP_GCB_GICBA_EN_MSK;
501 gic_present = 1;
502 } else {
Jaidev Patwardhan05cf2072009-07-10 01:54:25 -0700503 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 Baechle39b8d522008-04-28 17:14:26 +0100511 }
512 if (gic_present)
Chris Dearman7098f742009-07-10 01:54:09 -0700513 pr_debug("GIC present\n");
Ralf Baechle39b8d522008-04-28 17:14:26 +0100514
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300515 switch (mips_revision_sconid) {
516 case MIPS_REVISION_SCON_SOCIT:
517 case MIPS_REVISION_SCON_ROCIT:
Ralf Baechlee01402b2005-07-14 15:57:16 +0000518 if (cpu_has_veic)
Dmitri Vorobievf8071492008-01-24 19:52:47 +0300519 init_msc_irqs(MIPS_MSC01_IC_REG_BASE,
520 MSC01E_INT_BASE, msc_eicirqmap,
521 msc_nr_eicirqs);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000522 else
Dmitri Vorobievf8071492008-01-24 19:52:47 +0300523 init_msc_irqs(MIPS_MSC01_IC_REG_BASE,
524 MSC01C_INT_BASE, msc_irqmap,
525 msc_nr_irqs);
Chris Dearmand725cf32007-05-08 14:05:39 +0100526 break;
527
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300528 case MIPS_REVISION_SCON_SOCITSC:
529 case MIPS_REVISION_SCON_SOCITSCP:
Chris Dearmand725cf32007-05-08 14:05:39 +0100530 if (cpu_has_veic)
Dmitri Vorobievf8071492008-01-24 19:52:47 +0300531 init_msc_irqs(MIPS_SOCITSC_IC_REG_BASE,
532 MSC01E_INT_BASE, msc_eicirqmap,
533 msc_nr_eicirqs);
Chris Dearmand725cf32007-05-08 14:05:39 +0100534 else
Dmitri Vorobievf8071492008-01-24 19:52:47 +0300535 init_msc_irqs(MIPS_SOCITSC_IC_REG_BASE,
536 MSC01C_INT_BASE, msc_irqmap,
537 msc_nr_irqs);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000538 }
539
540 if (cpu_has_veic) {
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100541 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 Vorobiev52b3fc02008-01-24 19:52:51 +0300545 } else if (cpu_has_vint) {
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100546 set_vi_handler(MIPSCPU_INT_I8259A, malta_hw0_irqdispatch);
547 set_vi_handler(MIPSCPU_INT_COREHI, corehi_irqdispatch);
Ralf Baechle41c594a2006-04-05 09:45:45 +0100548#ifdef CONFIG_MIPS_MT_SMTC
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100549 setup_irq_smtc(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_I8259A, &i8259irq,
Ralf Baechle41c594a2006-04-05 09:45:45 +0100550 (0x100 << MIPSCPU_INT_I8259A));
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100551 setup_irq_smtc(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_COREHI,
Ralf Baechle41c594a2006-04-05 09:45:45 +0100552 &corehi_irqaction, (0x100 << MIPSCPU_INT_COREHI));
Kevin D. Kissellc3a005f2007-07-27 18:45:25 +0100553 /*
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 Baechle41c594a2006-04-05 09:45:45 +0100565#else /* Not SMTC */
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100566 setup_irq(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_I8259A, &i8259irq);
Dmitri Vorobievf8071492008-01-24 19:52:47 +0300567 setup_irq(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_COREHI,
568 &corehi_irqaction);
Ralf Baechle41c594a2006-04-05 09:45:45 +0100569#endif /* CONFIG_MIPS_MT_SMTC */
Dmitri Vorobiev52b3fc02008-01-24 19:52:51 +0300570 } else {
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100571 setup_irq(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_I8259A, &i8259irq);
Dmitri Vorobievf8071492008-01-24 19:52:47 +0300572 setup_irq(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_COREHI,
573 &corehi_irqaction);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000574 }
Ralf Baechle39b8d522008-04-28 17:14:26 +0100575
Ralf Baechle39b8d522008-04-28 17:14:26 +0100576 if (gic_present) {
577 /* FIXME */
578 int i;
Chris Dearman7098f742009-07-10 01:54:09 -0700579#if defined(CONFIG_MIPS_MT_SMP)
Markos Chandras13b7ea62013-10-30 14:27:48 +0000580 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 Baechle39b8d522008-04-28 17:14:26 +0100583 fill_ipi_map();
Chris Dearman7098f742009-07-10 01:54:09 -0700584#endif
585 gic_init(GIC_BASE_ADDR, GIC_ADDRSPACE_SZ, gic_intr_map,
586 ARRAY_SIZE(gic_intr_map), MIPS_GIC_IRQ_BASE);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100587 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 Dearman7098f742009-07-10 01:54:09 -0700594#if defined(CONFIG_MIPS_MT_SMP)
Ralf Baechle39b8d522008-04-28 17:14:26 +0100595 /* 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. Hill5792bf62014-01-01 16:35:32 +0100601 pr_info("CPU%d: status register was %08x\n",
602 smp_processor_id(), read_c0_status());
Ralf Baechle39b8d522008-04-28 17:14:26 +0100603 write_c0_status(read_c0_status() | STATUSF_IP3 | STATUSF_IP4);
Steven J. Hill5792bf62014-01-01 16:35:32 +0100604 pr_info("CPU%d: status register now %08x\n",
605 smp_processor_id(), read_c0_status());
Ralf Baechle39b8d522008-04-28 17:14:26 +0100606 write_c0_status(0x1100dc00);
Steven J. Hill5792bf62014-01-01 16:35:32 +0100607 pr_info("CPU%d: status register frc %08x\n",
608 smp_processor_id(), read_c0_status());
Markos Chandras13b7ea62013-10-30 14:27:48 +0000609 for (i = 0; i < nr_cpu_ids; i++) {
Chris Dearman7098f742009-07-10 01:54:09 -0700610 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 Baechle39b8d522008-04-28 17:14:26 +0100614 }
Chris Dearman7098f742009-07-10 01:54:09 -0700615#endif
Ralf Baechle39b8d522008-04-28 17:14:26 +0100616 } else {
Chris Dearman7098f742009-07-10 01:54:09 -0700617#if defined(CONFIG_MIPS_MT_SMP)
Ralf Baechle39b8d522008-04-28 17:14:26 +0100618 /* 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. Hill5792bf62014-01-01 16:35:32 +0100626 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 Baechle39b8d522008-04-28 17:14:26 +0100630 }
Steven J. Hill5792bf62014-01-01 16:35:32 +0100631 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 Baechle39b8d522008-04-28 17:14:26 +0100635 }
Chris Dearman7098f742009-07-10 01:54:09 -0700636 arch_init_ipiirq(cpu_ipi_resched_irq, &irq_resched);
637 arch_init_ipiirq(cpu_ipi_call_irq, &irq_call);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100638#endif
Chris Dearman7098f742009-07-10 01:54:09 -0700639 }
Ralf Baechle39b8d522008-04-28 17:14:26 +0100640}
641
642void malta_be_init(void)
643{
Steven J. Hill5792bf62014-01-01 16:35:32 +0100644 /* Could change CM error mask register. */
Ralf Baechle39b8d522008-04-28 17:14:26 +0100645}
646
647
648static char *tr[8] = {
649 "mem", "gcr", "gic", "mmio",
Ralf Baechle70342282013-01-22 12:59:30 +0100650 "0x04", "0x05", "0x06", "0x07"
Ralf Baechle39b8d522008-04-28 17:14:26 +0100651};
652
653static 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
688static char *core[8] = {
Ralf Baechle70342282013-01-22 12:59:30 +0100689 "Invalid/OK", "Invalid/Data",
Ralf Baechle39b8d522008-04-28 17:14:26 +0100690 "Shared/OK", "Shared/Data",
691 "Modified/OK", "Modified/Data",
Ralf Baechle70342282013-01-22 12:59:30 +0100692 "Exclusive/OK", "Exclusive/Data"
Ralf Baechle39b8d522008-04-28 17:14:26 +0100693};
694
695static 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
706int 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. Hill5792bf62014-01-01 16:35:32 +0100724 unsigned long cmd_bits = (cm_error >> 7) & 0x1f;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100725 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. Hill5792bf62014-01-01 16:35:32 +0100731 cca_bits, tr[tr_bits], mcmd[cmd_bits],
Ralf Baechle39b8d522008-04-28 17:14:26 +0100732 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. Hill5792bf62014-01-01 16:35:32 +0100740 unsigned long cmd_bits = (cm_error >> 3) & 0x1f;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100741 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. Hill5792bf62014-01-01 16:35:32 +0100748 mcmd[cmd_bits], sport_bits);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100749 }
750
751 ocause = (cm_other & GCMP_GCB_GMEO_ERROR_2ND_MSK) >>
752 GCMP_GCB_GMEO_ERROR_2ND_SHF;
753
Steven J. Hill5792bf62014-01-01 16:35:32 +0100754 pr_err("CM_ERROR=%08lx %s <%s>\n", cm_error,
Ralf Baechle39b8d522008-04-28 17:14:26 +0100755 causes[cause], buf);
Steven J. Hill5792bf62014-01-01 16:35:32 +0100756 pr_err("CM_ADDR =%08lx\n", cm_addr);
757 pr_err("CM_OTHER=%08lx %s\n", cm_other, causes[ocause]);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100758
759 /* reprime cause register */
760 GCMPGCB(GCMEC) = 0;
761 }
762 }
763
764 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765}
Steven J. Hill0b271f52012-08-31 16:05:37 -0500766
767void gic_enable_interrupt(int irq_vec)
768{
769 GIC_SET_INTR_MASK(irq_vec);
770}
771
772void gic_disable_interrupt(int irq_vec)
773{
774 GIC_CLR_INTR_MASK(irq_vec);
775}
776
777void 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
787void gic_finish_irq(struct irq_data *d)
788{
789 /* Enable interrupts. */
790 GIC_SET_INTR_MASK(d->irq - gic_irq_base);
791}
792
793void __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}