blob: 93103f81bf57577aea804b445b65d33e2e32b81a [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>
Paul Burton237036d2014-01-15 10:31:54 +000029#include <asm/mips-cm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <asm/mips-boards/malta.h>
31#include <asm/mips-boards/maltaint.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <asm/gt64120.h>
33#include <asm/mips-boards/generic.h>
34#include <asm/mips-boards/msc01_pci.h>
Ralf Baechlee01402b2005-07-14 15:57:16 +000035#include <asm/msc01_ic.h>
Ralf Baechle39b8d522008-04-28 17:14:26 +010036#include <asm/gic.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
Ralf Baechle39b8d522008-04-28 17:14:26 +010040static unsigned long _msc01_biu_base;
Ralf Baechle39b8d522008-04-28 17:14:26 +010041static unsigned int ipi_map[NR_CPUS];
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
Ralf Baechlea963dc72010-02-27 12:53:32 +010043static DEFINE_RAW_SPINLOCK(mips_irq_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
45static inline int mips_pcibios_iack(void)
46{
47 int irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49 /*
50 * Determine highest priority pending interrupt by performing
51 * a PCI Interrupt Acknowledge cycle.
52 */
Chris Dearmanb72c0522007-04-27 15:58:41 +010053 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 Vorobievaf825582008-01-24 19:52:45 +030058 MSC_READ(MSC01_PCI_IACK, irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 irq &= 0xff;
60 break;
Chris Dearmanb72c0522007-04-27 15:58:41 +010061 case MIPS_REVISION_SCON_GT64120:
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 irq = GT_READ(GT_PCI0_IACK_OFS);
63 irq &= 0xff;
64 break;
Chris Dearmanb72c0522007-04-27 15:58:41 +010065 case MIPS_REVISION_SCON_BONITO:
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 /* 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 Baechle6be63bb2011-03-29 11:48:22 +020074 (void) BONITO_PCIMAP_CFG;
Ralf Baechle70342282013-01-22 12:59:30 +010075 iob(); /* sync */
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Chris Dearmanaccfd352009-07-10 01:53:54 -070077 irq = __raw_readl((u32 *)_pcictrl_bonito_pcicfg);
Ralf Baechle70342282013-01-22 12:59:30 +010078 iob(); /* sync */
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 irq &= 0xff;
80 BONITO_PCIMAP_CFG = 0;
81 break;
82 default:
Steven J. Hill5792bf62014-01-01 16:35:32 +010083 pr_emerg("Unknown system controller.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 return -1;
85 }
86 return irq;
87}
88
Ralf Baechlee01402b2005-07-14 15:57:16 +000089static inline int get_int(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070090{
91 unsigned long flags;
Ralf Baechlee01402b2005-07-14 15:57:16 +000092 int irq;
Ralf Baechlea963dc72010-02-27 12:53:32 +010093 raw_spin_lock_irqsave(&mips_irq_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094
Ralf Baechlee01402b2005-07-14 15:57:16 +000095 irq = mips_pcibios_iack();
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
97 /*
Ralf Baechle479a0e32005-08-16 15:44:06 +000098 * 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 Torvalds1da177e2005-04-16 15:20:36 -0700101 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
Ralf Baechlea963dc72010-02-27 12:53:32 +0100103 raw_spin_unlock_irqrestore(&mips_irq_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
Ralf Baechlee01402b2005-07-14 15:57:16 +0000105 return irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106}
107
Ralf Baechle937a8012006-10-07 19:44:33 +0100108static void malta_hw0_irqdispatch(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109{
110 int irq;
111
Ralf Baechlee01402b2005-07-14 15:57:16 +0000112 irq = get_int();
Ralf Baechle41c594a2006-04-05 09:45:45 +0100113 if (irq < 0) {
Dmitri Vorobievcd80d542008-01-24 19:52:54 +0300114 /* interrupt has already been cleared */
115 return;
Ralf Baechle41c594a2006-04-05 09:45:45 +0100116 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
Ralf Baechle937a8012006-10-07 19:44:33 +0100118 do_IRQ(MALTA_INT_BASE + irq);
Deng-Cheng Zhu13361132013-10-30 15:52:10 -0500119
120#ifdef MIPS_VPE_APSP_API
121 if (aprp_hook)
122 aprp_hook();
123#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124}
125
Ralf Baechle39b8d522008-04-28 17:14:26 +0100126static void malta_ipi_irqdispatch(void)
127{
128 int irq;
129
Raghu Gandham0ab2b7d2013-04-10 16:30:12 -0500130 if (gic_compare_int())
131 do_IRQ(MIPS_GIC_IRQ_BASE);
132
Ralf Baechle39b8d522008-04-28 17:14:26 +0100133 irq = gic_get_int();
134 if (irq < 0)
Ralf Baechle70342282013-01-22 12:59:30 +0100135 return; /* interrupt has already been cleared */
Ralf Baechle39b8d522008-04-28 17:14:26 +0100136
137 do_IRQ(MIPS_GIC_IRQ_BASE + irq);
138}
139
Ralf Baechle937a8012006-10-07 19:44:33 +0100140static void corehi_irqdispatch(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141{
Ralf Baechle937a8012006-10-07 19:44:33 +0100142 unsigned int intedge, intsteer, pcicmd, pcibadaddr;
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300143 unsigned int pcimstat, intisr, inten, intpol;
Ralf Baechle21a151d2007-10-11 23:46:15 +0100144 unsigned int intrcause, datalo, datahi;
Ralf Baechleba38cdf2006-10-15 09:17:43 +0100145 struct pt_regs *regs = get_irq_regs();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Steven J. Hill5792bf62014-01-01 16:35:32 +0100147 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 Baechlee01402b2005-07-14 15:57:16 +0000152
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 Dearmanb72c0522007-04-27 15:58:41 +0100158 switch (mips_revision_sconid) {
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300159 case MIPS_REVISION_SCON_SOCIT:
Chris Dearmanb72c0522007-04-27 15:58:41 +0100160 case MIPS_REVISION_SCON_ROCIT:
161 case MIPS_REVISION_SCON_SOCITSC:
162 case MIPS_REVISION_SCON_SOCITSCP:
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300163 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. Hill5792bf62014-01-01 16:35:32 +0100169 pr_emerg("GT_INTRCAUSE = %08x\n", intrcause);
170 pr_emerg("GT_CPUERR_ADDR = %02x%08x\n",
Dmitri Vorobiev8216d342008-01-24 19:52:42 +0300171 datahi, datalo);
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300172 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. Hill5792bf62014-01-01 16:35:32 +0100182 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 Vorobievaf825582008-01-24 19:52:45 +0300190 break;
191 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300193 die("CoreHi interrupt", regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194}
195
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100196static inline int clz(unsigned long x)
197{
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100198 __asm__(
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100199 " .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 */
212static 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 Baechle0118c3c2006-06-05 11:54:41 +0100220 t0 = pending & 0xf000;
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100221 t0 = t0 < 1;
222 t0 = t0 << 2;
223 a0 = a0 - t0;
Ralf Baechle0118c3c2006-06-05 11:54:41 +0100224 pending = pending << t0;
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100225
Ralf Baechle0118c3c2006-06-05 11:54:41 +0100226 t0 = pending & 0xc000;
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100227 t0 = t0 < 1;
228 t0 = t0 << 1;
229 a0 = a0 - t0;
Ralf Baechle0118c3c2006-06-05 11:54:41 +0100230 pending = pending << t0;
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100231
Ralf Baechle0118c3c2006-06-05 11:54:41 +0100232 t0 = pending & 0x8000;
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100233 t0 = t0 < 1;
Dmitri Vorobievae9cef02008-01-24 19:52:52 +0300234 /* t0 = t0 << 2; */
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100235 a0 = a0 - t0;
Dmitri Vorobievae9cef02008-01-24 19:52:52 +0300236 /* pending = pending << t0; */
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100237
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 Baechle70342282013-01-22 12:59:30 +0100248 * -------- ------
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 Baechlee4ac58a2006-04-03 17:56:36 +0100257 *
258 * We handle the IRQ according to _our_ priority which is:
259 *
Ralf Baechle70342282013-01-22 12:59:30 +0100260 * Highest ---- R4k Timer
261 * Lowest ---- Combined hardware interrupt
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100262 *
263 * then we just return, if multiple IRQs are pending then we will just take
264 * another exception, big deal.
265 */
266
Ralf Baechle937a8012006-10-07 19:44:33 +0100267asmlinkage void plat_irq_dispatch(void)
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100268{
269 unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM;
270 int irq;
271
Ralf Baechlee376fdf2012-09-17 01:23:21 +0200272 if (unlikely(!pending)) {
273 spurious_interrupt();
274 return;
275 }
276
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100277 irq = irq_ffs(pending);
278
279 if (irq == MIPSCPU_INT_I8259A)
Ralf Baechle937a8012006-10-07 19:44:33 +0100280 malta_hw0_irqdispatch();
Ralf Baechle39b8d522008-04-28 17:14:26 +0100281 else if (gic_present && ((1 << irq) & ipi_map[smp_processor_id()]))
282 malta_ipi_irqdispatch();
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100283 else
Ralf Baechlee376fdf2012-09-17 01:23:21 +0200284 do_IRQ(MIPS_CPU_IRQ_BASE + irq);
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100285}
286
Ralf Baechle39b8d522008-04-28 17:14:26 +0100287#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
297static int cpu_ipi_resched_irq, cpu_ipi_call_irq;
298
299static void ipi_resched_dispatch(void)
300{
301 do_IRQ(MIPS_CPU_IRQ_BASE + MIPS_CPU_IPI_RESCHED_IRQ);
302}
303
304static void ipi_call_dispatch(void)
305{
306 do_IRQ(MIPS_CPU_IRQ_BASE + MIPS_CPU_IPI_CALL_IRQ);
307}
308
309static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id)
310{
Deng-Cheng Zhu13361132013-10-30 15:52:10 -0500311#ifdef MIPS_VPE_APSP_API
312 if (aprp_hook)
313 aprp_hook();
314#endif
315
Peter Zijlstra184748c2011-04-05 17:23:39 +0200316 scheduler_ipi();
317
Ralf Baechle39b8d522008-04-28 17:14:26 +0100318 return IRQ_HANDLED;
319}
320
321static irqreturn_t ipi_call_interrupt(int irq, void *dev_id)
322{
323 smp_call_function_interrupt();
324
325 return IRQ_HANDLED;
326}
327
328static struct irqaction irq_resched = {
329 .handler = ipi_resched_interrupt,
Yong Zhang8b5690f2011-11-22 14:38:03 +0000330 .flags = IRQF_PERCPU,
Ralf Baechle39b8d522008-04-28 17:14:26 +0100331 .name = "IPI_resched"
332};
333
334static struct irqaction irq_call = {
335 .handler = ipi_call_interrupt,
Yong Zhang8b5690f2011-11-22 14:38:03 +0000336 .flags = IRQF_PERCPU,
Ralf Baechle39b8d522008-04-28 17:14:26 +0100337 .name = "IPI_call"
338};
Raghu Gandham008ee962009-07-08 17:00:44 -0700339#endif /* CONFIG_MIPS_MT_SMP */
Tim Andersona214cef2009-06-17 16:22:25 -0700340
341static int gic_resched_int_base;
342static 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 Anderson03650702009-06-17 16:22:53 -0700345
346unsigned int plat_ipi_call_int_xlate(unsigned int cpu)
347{
348 return GIC_CALL_INT(cpu);
349}
350
351unsigned int plat_ipi_resched_int_xlate(unsigned int cpu)
352{
353 return GIC_RESCHED_INT(cpu);
354}
Ralf Baechle39b8d522008-04-28 17:14:26 +0100355
Ralf Baechlee01402b2005-07-14 15:57:16 +0000356static struct irqaction i8259irq = {
357 .handler = no_action,
Wu Zhangjin5a4a4ad2011-07-23 12:41:24 +0000358 .name = "XT-PIC cascade",
359 .flags = IRQF_NO_THREAD,
Ralf Baechlee01402b2005-07-14 15:57:16 +0000360};
361
362static struct irqaction corehi_irqaction = {
363 .handler = no_action,
Wu Zhangjin5a4a4ad2011-07-23 12:41:24 +0000364 .name = "CoreHi",
365 .flags = IRQF_NO_THREAD,
Ralf Baechlee01402b2005-07-14 15:57:16 +0000366};
367
Steven J. Hill5792bf62014-01-01 16:35:32 +0100368static msc_irqmap_t msc_irqmap[] __initdata = {
Ralf Baechlee01402b2005-07-14 15:57:16 +0000369 {MSC01C_INT_TMR, MSC01_IRQ_EDGE, 0},
370 {MSC01C_INT_PCI, MSC01_IRQ_LEVEL, 0},
371};
Steven J. Hill5792bf62014-01-01 16:35:32 +0100372static int msc_nr_irqs __initdata = ARRAY_SIZE(msc_irqmap);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000373
Steven J. Hill5792bf62014-01-01 16:35:32 +0100374static msc_irqmap_t msc_eicirqmap[] __initdata = {
Ralf Baechlee01402b2005-07-14 15:57:16 +0000375 {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 Baechle39b8d522008-04-28 17:14:26 +0100386
Steven J. Hill5792bf62014-01-01 16:35:32 +0100387static int msc_nr_eicirqs __initdata = ARRAY_SIZE(msc_eicirqmap);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000388
Ralf Baechle39b8d522008-04-28 17:14:26 +0100389/*
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 Dearman7098f742009-07-10 01:54:09 -0700394
395#define GIC_CPU_NMI GIC_MAP_TO_NMI_MSK
Ralf Baechle863cb9b2010-09-17 17:07:48 +0100396#define X GIC_UNUSED
397
Tim Andersona214cef2009-06-17 16:22:25 -0700398static struct gic_intr_map gic_intr_map[GIC_NUM_INTRS] = {
Chris Dearman7098f742009-07-10 01:54:09 -0700399 { X, X, X, X, 0 },
Ralf Baechle70342282013-01-22 12:59:30 +0100400 { X, X, X, X, 0 },
Chris Dearman7098f742009-07-10 01:54:09 -0700401 { 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 Baechle70342282013-01-22 12:59:30 +0100414 { X, X, X, X, 0 },
Chris Dearman7098f742009-07-10 01:54:09 -0700415 /* The remainder of this table is initialised by fill_ipi_map */
Ralf Baechle39b8d522008-04-28 17:14:26 +0100416};
Ralf Baechle863cb9b2010-09-17 17:07:48 +0100417#undef X
Ralf Baechle39b8d522008-04-28 17:14:26 +0100418
Dmitri Vorobiev7afed6a2008-06-18 10:18:21 +0300419#if defined(CONFIG_MIPS_MT_SMP)
Tim Andersona214cef2009-06-17 16:22:25 -0700420static void __init fill_ipi_map1(int baseintr, int cpu, int cpupin)
421{
422 int intr = baseintr + cpu;
Tim Andersona214cef2009-06-17 16:22:25 -0700423 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 Dearman7098f742009-07-10 01:54:09 -0700427 gic_intr_map[intr].flags = GIC_FLAG_IPI;
Tim Andersona214cef2009-06-17 16:22:25 -0700428 ipi_map[cpu] |= (1 << (cpupin + 2));
429}
430
Dmitri Vorobiev7afed6a2008-06-18 10:18:21 +0300431static void __init fill_ipi_map(void)
Ralf Baechle39b8d522008-04-28 17:14:26 +0100432{
Tim Andersona214cef2009-06-17 16:22:25 -0700433 int cpu;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100434
Markos Chandras13b7ea62013-10-30 14:27:48 +0000435 for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
Tim Andersona214cef2009-06-17 16:22:25 -0700436 fill_ipi_map1(gic_resched_int_base, cpu, GIC_CPU_INT1);
437 fill_ipi_map1(gic_call_int_base, cpu, GIC_CPU_INT2);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100438 }
439}
Dmitri Vorobiev7afed6a2008-06-18 10:18:21 +0300440#endif
Ralf Baechle39b8d522008-04-28 17:14:26 +0100441
Chris Dearman7098f742009-07-10 01:54:09 -0700442void __init arch_init_ipiirq(int irq, struct irqaction *action)
443{
444 setup_irq(irq, action);
Thomas Gleixnere4ec7982011-03-27 15:19:28 +0200445 irq_set_handler(irq, handle_percpu_irq);
Chris Dearman7098f742009-07-10 01:54:09 -0700446}
447
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448void __init arch_init_irq(void)
449{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 init_i8259_irqs();
Ralf Baechlee01402b2005-07-14 15:57:16 +0000451
452 if (!cpu_has_veic)
Atsushi Nemoto97dcb822007-01-08 02:14:29 +0900453 mips_cpu_irq_init();
Ralf Baechlee01402b2005-07-14 15:57:16 +0000454
Paul Burton237036d2014-01-15 10:31:54 +0000455 if (mips_cm_present()) {
456 write_gcr_gic_base(GIC_BASE_ADDR | CM_GCR_GIC_BASE_GICEN_MSK);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100457 gic_present = 1;
458 } else {
Jaidev Patwardhan05cf2072009-07-10 01:54:25 -0700459 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 Baechle39b8d522008-04-28 17:14:26 +0100467 }
468 if (gic_present)
Chris Dearman7098f742009-07-10 01:54:09 -0700469 pr_debug("GIC present\n");
Ralf Baechle39b8d522008-04-28 17:14:26 +0100470
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300471 switch (mips_revision_sconid) {
472 case MIPS_REVISION_SCON_SOCIT:
473 case MIPS_REVISION_SCON_ROCIT:
Ralf Baechlee01402b2005-07-14 15:57:16 +0000474 if (cpu_has_veic)
Dmitri Vorobievf8071492008-01-24 19:52:47 +0300475 init_msc_irqs(MIPS_MSC01_IC_REG_BASE,
476 MSC01E_INT_BASE, msc_eicirqmap,
477 msc_nr_eicirqs);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000478 else
Dmitri Vorobievf8071492008-01-24 19:52:47 +0300479 init_msc_irqs(MIPS_MSC01_IC_REG_BASE,
480 MSC01C_INT_BASE, msc_irqmap,
481 msc_nr_irqs);
Chris Dearmand725cf32007-05-08 14:05:39 +0100482 break;
483
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300484 case MIPS_REVISION_SCON_SOCITSC:
485 case MIPS_REVISION_SCON_SOCITSCP:
Chris Dearmand725cf32007-05-08 14:05:39 +0100486 if (cpu_has_veic)
Dmitri Vorobievf8071492008-01-24 19:52:47 +0300487 init_msc_irqs(MIPS_SOCITSC_IC_REG_BASE,
488 MSC01E_INT_BASE, msc_eicirqmap,
489 msc_nr_eicirqs);
Chris Dearmand725cf32007-05-08 14:05:39 +0100490 else
Dmitri Vorobievf8071492008-01-24 19:52:47 +0300491 init_msc_irqs(MIPS_SOCITSC_IC_REG_BASE,
492 MSC01C_INT_BASE, msc_irqmap,
493 msc_nr_irqs);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000494 }
495
496 if (cpu_has_veic) {
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100497 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 Vorobiev52b3fc02008-01-24 19:52:51 +0300501 } else if (cpu_has_vint) {
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100502 set_vi_handler(MIPSCPU_INT_I8259A, malta_hw0_irqdispatch);
503 set_vi_handler(MIPSCPU_INT_COREHI, corehi_irqdispatch);
Ralf Baechle41c594a2006-04-05 09:45:45 +0100504#ifdef CONFIG_MIPS_MT_SMTC
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100505 setup_irq_smtc(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_I8259A, &i8259irq,
Ralf Baechle41c594a2006-04-05 09:45:45 +0100506 (0x100 << MIPSCPU_INT_I8259A));
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100507 setup_irq_smtc(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_COREHI,
Ralf Baechle41c594a2006-04-05 09:45:45 +0100508 &corehi_irqaction, (0x100 << MIPSCPU_INT_COREHI));
Kevin D. Kissellc3a005f2007-07-27 18:45:25 +0100509 /*
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 Baechle41c594a2006-04-05 09:45:45 +0100521#else /* Not SMTC */
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100522 setup_irq(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_I8259A, &i8259irq);
Dmitri Vorobievf8071492008-01-24 19:52:47 +0300523 setup_irq(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_COREHI,
524 &corehi_irqaction);
Ralf Baechle41c594a2006-04-05 09:45:45 +0100525#endif /* CONFIG_MIPS_MT_SMTC */
Dmitri Vorobiev52b3fc02008-01-24 19:52:51 +0300526 } else {
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100527 setup_irq(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_I8259A, &i8259irq);
Dmitri Vorobievf8071492008-01-24 19:52:47 +0300528 setup_irq(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_COREHI,
529 &corehi_irqaction);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000530 }
Ralf Baechle39b8d522008-04-28 17:14:26 +0100531
Ralf Baechle39b8d522008-04-28 17:14:26 +0100532 if (gic_present) {
533 /* FIXME */
534 int i;
Chris Dearman7098f742009-07-10 01:54:09 -0700535#if defined(CONFIG_MIPS_MT_SMP)
Markos Chandras13b7ea62013-10-30 14:27:48 +0000536 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 Baechle39b8d522008-04-28 17:14:26 +0100539 fill_ipi_map();
Chris Dearman7098f742009-07-10 01:54:09 -0700540#endif
541 gic_init(GIC_BASE_ADDR, GIC_ADDRSPACE_SZ, gic_intr_map,
542 ARRAY_SIZE(gic_intr_map), MIPS_GIC_IRQ_BASE);
Paul Burton237036d2014-01-15 10:31:54 +0000543 if (!mips_cm_present()) {
Ralf Baechle39b8d522008-04-28 17:14:26 +0100544 /* 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 Dearman7098f742009-07-10 01:54:09 -0700550#if defined(CONFIG_MIPS_MT_SMP)
Ralf Baechle39b8d522008-04-28 17:14:26 +0100551 /* 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. Hill5792bf62014-01-01 16:35:32 +0100557 pr_info("CPU%d: status register was %08x\n",
558 smp_processor_id(), read_c0_status());
Ralf Baechle39b8d522008-04-28 17:14:26 +0100559 write_c0_status(read_c0_status() | STATUSF_IP3 | STATUSF_IP4);
Steven J. Hill5792bf62014-01-01 16:35:32 +0100560 pr_info("CPU%d: status register now %08x\n",
561 smp_processor_id(), read_c0_status());
Ralf Baechle39b8d522008-04-28 17:14:26 +0100562 write_c0_status(0x1100dc00);
Steven J. Hill5792bf62014-01-01 16:35:32 +0100563 pr_info("CPU%d: status register frc %08x\n",
564 smp_processor_id(), read_c0_status());
Markos Chandras13b7ea62013-10-30 14:27:48 +0000565 for (i = 0; i < nr_cpu_ids; i++) {
Chris Dearman7098f742009-07-10 01:54:09 -0700566 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 Baechle39b8d522008-04-28 17:14:26 +0100570 }
Chris Dearman7098f742009-07-10 01:54:09 -0700571#endif
Ralf Baechle39b8d522008-04-28 17:14:26 +0100572 } else {
Chris Dearman7098f742009-07-10 01:54:09 -0700573#if defined(CONFIG_MIPS_MT_SMP)
Ralf Baechle39b8d522008-04-28 17:14:26 +0100574 /* 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. Hill5792bf62014-01-01 16:35:32 +0100582 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 Baechle39b8d522008-04-28 17:14:26 +0100586 }
Steven J. Hill5792bf62014-01-01 16:35:32 +0100587 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 Baechle39b8d522008-04-28 17:14:26 +0100591 }
Chris Dearman7098f742009-07-10 01:54:09 -0700592 arch_init_ipiirq(cpu_ipi_resched_irq, &irq_resched);
593 arch_init_ipiirq(cpu_ipi_call_irq, &irq_call);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100594#endif
Chris Dearman7098f742009-07-10 01:54:09 -0700595 }
Ralf Baechle39b8d522008-04-28 17:14:26 +0100596}
597
598void malta_be_init(void)
599{
Steven J. Hill5792bf62014-01-01 16:35:32 +0100600 /* Could change CM error mask register. */
Ralf Baechle39b8d522008-04-28 17:14:26 +0100601}
602
603
604static char *tr[8] = {
605 "mem", "gcr", "gic", "mmio",
Ralf Baechle70342282013-01-22 12:59:30 +0100606 "0x04", "0x05", "0x06", "0x07"
Ralf Baechle39b8d522008-04-28 17:14:26 +0100607};
608
609static 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
644static char *core[8] = {
Ralf Baechle70342282013-01-22 12:59:30 +0100645 "Invalid/OK", "Invalid/Data",
Ralf Baechle39b8d522008-04-28 17:14:26 +0100646 "Shared/OK", "Shared/Data",
647 "Modified/OK", "Modified/Data",
Ralf Baechle70342282013-01-22 12:59:30 +0100648 "Exclusive/OK", "Exclusive/Data"
Ralf Baechle39b8d522008-04-28 17:14:26 +0100649};
650
651static 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
662int 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 Burton237036d2014-01-15 10:31:54 +0000667 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 Baechle39b8d522008-04-28 17:14:26 +0100671 unsigned long cause, ocause;
672 char buf[256];
673
Paul Burton237036d2014-01-15 10:31:54 +0000674 cause = cm_error & CM_GCR_ERROR_CAUSE_ERRTYPE_MSK;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100675 if (cause != 0) {
Paul Burton237036d2014-01-15 10:31:54 +0000676 cause >>= CM_GCR_ERROR_CAUSE_ERRTYPE_SHF;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100677 if (cause < 16) {
678 unsigned long cca_bits = (cm_error >> 15) & 7;
679 unsigned long tr_bits = (cm_error >> 12) & 7;
Steven J. Hill5792bf62014-01-01 16:35:32 +0100680 unsigned long cmd_bits = (cm_error >> 7) & 0x1f;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100681 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. Hill5792bf62014-01-01 16:35:32 +0100687 cca_bits, tr[tr_bits], mcmd[cmd_bits],
Ralf Baechle39b8d522008-04-28 17:14:26 +0100688 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. Hill5792bf62014-01-01 16:35:32 +0100696 unsigned long cmd_bits = (cm_error >> 3) & 0x1f;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100697 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. Hill5792bf62014-01-01 16:35:32 +0100704 mcmd[cmd_bits], sport_bits);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100705 }
706
Paul Burton237036d2014-01-15 10:31:54 +0000707 ocause = (cm_other & CM_GCR_ERROR_MULT_ERR2ND_MSK) >>
708 CM_GCR_ERROR_MULT_ERR2ND_SHF;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100709
Steven J. Hill5792bf62014-01-01 16:35:32 +0100710 pr_err("CM_ERROR=%08lx %s <%s>\n", cm_error,
Ralf Baechle39b8d522008-04-28 17:14:26 +0100711 causes[cause], buf);
Steven J. Hill5792bf62014-01-01 16:35:32 +0100712 pr_err("CM_ADDR =%08lx\n", cm_addr);
713 pr_err("CM_OTHER=%08lx %s\n", cm_other, causes[ocause]);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100714
715 /* reprime cause register */
Paul Burton237036d2014-01-15 10:31:54 +0000716 write_gcr_error_cause(0);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100717 }
718 }
719
720 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721}
Steven J. Hill0b271f52012-08-31 16:05:37 -0500722
723void gic_enable_interrupt(int irq_vec)
724{
725 GIC_SET_INTR_MASK(irq_vec);
726}
727
728void gic_disable_interrupt(int irq_vec)
729{
730 GIC_CLR_INTR_MASK(irq_vec);
731}
732
733void 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
743void gic_finish_irq(struct irq_data *d)
744{
745 /* Enable interrupts. */
746 GIC_SET_INTR_MASK(d->irq - gic_irq_base);
747}
748
749void __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}