blob: e4f43baa8f676e3c561f3cc1825888b40136e89b [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
Jeffrey Deans1c772b52014-07-17 09:20:58 +010045#ifdef CONFIG_MIPS_GIC_IPI
46DECLARE_BITMAP(ipi_ints, GIC_NUM_INTRS);
47#endif
48
Linus Torvalds1da177e2005-04-16 15:20:36 -070049static inline int mips_pcibios_iack(void)
50{
51 int irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53 /*
54 * Determine highest priority pending interrupt by performing
55 * a PCI Interrupt Acknowledge cycle.
56 */
Chris Dearmanb72c0522007-04-27 15:58:41 +010057 switch (mips_revision_sconid) {
58 case MIPS_REVISION_SCON_SOCIT:
59 case MIPS_REVISION_SCON_ROCIT:
60 case MIPS_REVISION_SCON_SOCITSC:
61 case MIPS_REVISION_SCON_SOCITSCP:
Dmitri Vorobievaf825582008-01-24 19:52:45 +030062 MSC_READ(MSC01_PCI_IACK, irq);
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 irq &= 0xff;
64 break;
Chris Dearmanb72c0522007-04-27 15:58:41 +010065 case MIPS_REVISION_SCON_GT64120:
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 irq = GT_READ(GT_PCI0_IACK_OFS);
67 irq &= 0xff;
68 break;
Chris Dearmanb72c0522007-04-27 15:58:41 +010069 case MIPS_REVISION_SCON_BONITO:
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 /* The following will generate a PCI IACK cycle on the
71 * Bonito controller. It's a little bit kludgy, but it
72 * was the easiest way to implement it in hardware at
73 * the given time.
74 */
75 BONITO_PCIMAP_CFG = 0x20000;
76
77 /* Flush Bonito register block */
Ralf Baechle6be63bb2011-03-29 11:48:22 +020078 (void) BONITO_PCIMAP_CFG;
Ralf Baechle70342282013-01-22 12:59:30 +010079 iob(); /* sync */
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
Chris Dearmanaccfd352009-07-10 01:53:54 -070081 irq = __raw_readl((u32 *)_pcictrl_bonito_pcicfg);
Ralf Baechle70342282013-01-22 12:59:30 +010082 iob(); /* sync */
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 irq &= 0xff;
84 BONITO_PCIMAP_CFG = 0;
85 break;
86 default:
Steven J. Hill5792bf62014-01-01 16:35:32 +010087 pr_emerg("Unknown system controller.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 return -1;
89 }
90 return irq;
91}
92
Ralf Baechlee01402b2005-07-14 15:57:16 +000093static inline int get_int(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070094{
95 unsigned long flags;
Ralf Baechlee01402b2005-07-14 15:57:16 +000096 int irq;
Ralf Baechlea963dc72010-02-27 12:53:32 +010097 raw_spin_lock_irqsave(&mips_irq_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
Ralf Baechlee01402b2005-07-14 15:57:16 +000099 irq = mips_pcibios_iack();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
101 /*
Ralf Baechle479a0e32005-08-16 15:44:06 +0000102 * The only way we can decide if an interrupt is spurious
103 * is by checking the 8259 registers. This needs a spinlock
104 * on an SMP system, so leave it up to the generic code...
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
Ralf Baechlea963dc72010-02-27 12:53:32 +0100107 raw_spin_unlock_irqrestore(&mips_irq_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108
Ralf Baechlee01402b2005-07-14 15:57:16 +0000109 return irq;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110}
111
Ralf Baechle937a8012006-10-07 19:44:33 +0100112static void malta_hw0_irqdispatch(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113{
114 int irq;
115
Ralf Baechlee01402b2005-07-14 15:57:16 +0000116 irq = get_int();
Ralf Baechle41c594a2006-04-05 09:45:45 +0100117 if (irq < 0) {
Dmitri Vorobievcd80d542008-01-24 19:52:54 +0300118 /* interrupt has already been cleared */
119 return;
Ralf Baechle41c594a2006-04-05 09:45:45 +0100120 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121
Ralf Baechle937a8012006-10-07 19:44:33 +0100122 do_IRQ(MALTA_INT_BASE + irq);
Deng-Cheng Zhu13361132013-10-30 15:52:10 -0500123
Deng-Cheng Zhu9c1f6e02014-02-28 10:23:01 -0800124#ifdef CONFIG_MIPS_VPE_APSP_API_MT
Deng-Cheng Zhu13361132013-10-30 15:52:10 -0500125 if (aprp_hook)
126 aprp_hook();
127#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128}
129
Ralf Baechle39b8d522008-04-28 17:14:26 +0100130static void malta_ipi_irqdispatch(void)
131{
Jeffrey Deans1c772b52014-07-17 09:20:58 +0100132#ifdef CONFIG_MIPS_GIC_IPI
133 unsigned long irq;
134 DECLARE_BITMAP(pending, GIC_NUM_INTRS);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100135
Jeffrey Deans1c772b52014-07-17 09:20:58 +0100136 gic_get_int_mask(pending, ipi_ints);
137
138 irq = find_first_bit(pending, GIC_NUM_INTRS);
139
140 while (irq < GIC_NUM_INTRS) {
141 do_IRQ(MIPS_GIC_IRQ_BASE + irq);
142
143 irq = find_next_bit(pending, GIC_NUM_INTRS, irq + 1);
144 }
145#endif
Raghu Gandham0ab2b7d2013-04-10 16:30:12 -0500146 if (gic_compare_int())
147 do_IRQ(MIPS_GIC_IRQ_BASE);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100148}
149
Ralf Baechle937a8012006-10-07 19:44:33 +0100150static void corehi_irqdispatch(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151{
Ralf Baechle937a8012006-10-07 19:44:33 +0100152 unsigned int intedge, intsteer, pcicmd, pcibadaddr;
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300153 unsigned int pcimstat, intisr, inten, intpol;
Ralf Baechle21a151d2007-10-11 23:46:15 +0100154 unsigned int intrcause, datalo, datahi;
Ralf Baechleba38cdf2006-10-15 09:17:43 +0100155 struct pt_regs *regs = get_irq_regs();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156
Steven J. Hill5792bf62014-01-01 16:35:32 +0100157 pr_emerg("CoreHI interrupt, shouldn't happen, we die here!\n");
158 pr_emerg("epc : %08lx\nStatus: %08lx\n"
159 "Cause : %08lx\nbadVaddr : %08lx\n",
160 regs->cp0_epc, regs->cp0_status,
161 regs->cp0_cause, regs->cp0_badvaddr);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000162
163 /* Read all the registers and then print them as there is a
164 problem with interspersed printk's upsetting the Bonito controller.
165 Do it for the others too.
166 */
167
Chris Dearmanb72c0522007-04-27 15:58:41 +0100168 switch (mips_revision_sconid) {
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300169 case MIPS_REVISION_SCON_SOCIT:
Chris Dearmanb72c0522007-04-27 15:58:41 +0100170 case MIPS_REVISION_SCON_ROCIT:
171 case MIPS_REVISION_SCON_SOCITSC:
172 case MIPS_REVISION_SCON_SOCITSCP:
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300173 ll_msc_irq();
174 break;
175 case MIPS_REVISION_SCON_GT64120:
176 intrcause = GT_READ(GT_INTRCAUSE_OFS);
177 datalo = GT_READ(GT_CPUERR_ADDRLO_OFS);
178 datahi = GT_READ(GT_CPUERR_ADDRHI_OFS);
Steven J. Hill5792bf62014-01-01 16:35:32 +0100179 pr_emerg("GT_INTRCAUSE = %08x\n", intrcause);
180 pr_emerg("GT_CPUERR_ADDR = %02x%08x\n",
Dmitri Vorobiev8216d342008-01-24 19:52:42 +0300181 datahi, datalo);
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300182 break;
183 case MIPS_REVISION_SCON_BONITO:
184 pcibadaddr = BONITO_PCIBADADDR;
185 pcimstat = BONITO_PCIMSTAT;
186 intisr = BONITO_INTISR;
187 inten = BONITO_INTEN;
188 intpol = BONITO_INTPOL;
189 intedge = BONITO_INTEDGE;
190 intsteer = BONITO_INTSTEER;
191 pcicmd = BONITO_PCICMD;
Steven J. Hill5792bf62014-01-01 16:35:32 +0100192 pr_emerg("BONITO_INTISR = %08x\n", intisr);
193 pr_emerg("BONITO_INTEN = %08x\n", inten);
194 pr_emerg("BONITO_INTPOL = %08x\n", intpol);
195 pr_emerg("BONITO_INTEDGE = %08x\n", intedge);
196 pr_emerg("BONITO_INTSTEER = %08x\n", intsteer);
197 pr_emerg("BONITO_PCICMD = %08x\n", pcicmd);
198 pr_emerg("BONITO_PCIBADADDR = %08x\n", pcibadaddr);
199 pr_emerg("BONITO_PCIMSTAT = %08x\n", pcimstat);
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300200 break;
201 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300203 die("CoreHi interrupt", regs);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204}
205
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100206static inline int clz(unsigned long x)
207{
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100208 __asm__(
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100209 " .set push \n"
210 " .set mips32 \n"
211 " clz %0, %1 \n"
212 " .set pop \n"
213 : "=r" (x)
214 : "r" (x));
215
216 return x;
217}
218
219/*
220 * Version of ffs that only looks at bits 12..15.
221 */
222static inline unsigned int irq_ffs(unsigned int pending)
223{
224#if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64)
225 return -clz(pending) + 31 - CAUSEB_IP;
226#else
227 unsigned int a0 = 7;
228 unsigned int t0;
229
Ralf Baechle0118c3c2006-06-05 11:54:41 +0100230 t0 = pending & 0xf000;
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100231 t0 = t0 < 1;
232 t0 = t0 << 2;
233 a0 = a0 - t0;
Ralf Baechle0118c3c2006-06-05 11:54:41 +0100234 pending = pending << t0;
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100235
Ralf Baechle0118c3c2006-06-05 11:54:41 +0100236 t0 = pending & 0xc000;
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100237 t0 = t0 < 1;
238 t0 = t0 << 1;
239 a0 = a0 - t0;
Ralf Baechle0118c3c2006-06-05 11:54:41 +0100240 pending = pending << t0;
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100241
Ralf Baechle0118c3c2006-06-05 11:54:41 +0100242 t0 = pending & 0x8000;
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100243 t0 = t0 < 1;
Dmitri Vorobievae9cef02008-01-24 19:52:52 +0300244 /* t0 = t0 << 2; */
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100245 a0 = a0 - t0;
Dmitri Vorobievae9cef02008-01-24 19:52:52 +0300246 /* pending = pending << t0; */
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100247
248 return a0;
249#endif
250}
251
252/*
253 * IRQs on the Malta board look basically (barring software IRQs which we
254 * don't use at all and all external interrupt sources are combined together
255 * on hardware interrupt 0 (MIPS IRQ 2)) like:
256 *
257 * MIPS IRQ Source
Ralf Baechle70342282013-01-22 12:59:30 +0100258 * -------- ------
259 * 0 Software (ignored)
260 * 1 Software (ignored)
261 * 2 Combined hardware interrupt (hw0)
262 * 3 Hardware (ignored)
263 * 4 Hardware (ignored)
264 * 5 Hardware (ignored)
265 * 6 Hardware (ignored)
266 * 7 R4k timer (what we use)
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100267 *
268 * We handle the IRQ according to _our_ priority which is:
269 *
Ralf Baechle70342282013-01-22 12:59:30 +0100270 * Highest ---- R4k Timer
271 * Lowest ---- Combined hardware interrupt
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100272 *
273 * then we just return, if multiple IRQs are pending then we will just take
274 * another exception, big deal.
275 */
276
Ralf Baechle937a8012006-10-07 19:44:33 +0100277asmlinkage void plat_irq_dispatch(void)
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100278{
279 unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM;
280 int irq;
281
Ralf Baechlee376fdf2012-09-17 01:23:21 +0200282 if (unlikely(!pending)) {
283 spurious_interrupt();
284 return;
285 }
286
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100287 irq = irq_ffs(pending);
288
289 if (irq == MIPSCPU_INT_I8259A)
Ralf Baechle937a8012006-10-07 19:44:33 +0100290 malta_hw0_irqdispatch();
Ralf Baechle39b8d522008-04-28 17:14:26 +0100291 else if (gic_present && ((1 << irq) & ipi_map[smp_processor_id()]))
292 malta_ipi_irqdispatch();
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100293 else
Ralf Baechlee376fdf2012-09-17 01:23:21 +0200294 do_IRQ(MIPS_CPU_IRQ_BASE + irq);
Ralf Baechlee4ac58a2006-04-03 17:56:36 +0100295}
296
Ralf Baechle39b8d522008-04-28 17:14:26 +0100297#ifdef CONFIG_MIPS_MT_SMP
298
Ralf Baechle39b8d522008-04-28 17:14:26 +0100299#define MIPS_CPU_IPI_RESCHED_IRQ 0 /* SW int 0 for resched */
300#define C_RESCHED C_SW0
301#define MIPS_CPU_IPI_CALL_IRQ 1 /* SW int 1 for resched */
302#define C_CALL C_SW1
303static int cpu_ipi_resched_irq, cpu_ipi_call_irq;
304
305static void ipi_resched_dispatch(void)
306{
307 do_IRQ(MIPS_CPU_IRQ_BASE + MIPS_CPU_IPI_RESCHED_IRQ);
308}
309
310static void ipi_call_dispatch(void)
311{
312 do_IRQ(MIPS_CPU_IRQ_BASE + MIPS_CPU_IPI_CALL_IRQ);
313}
314
Paul Burton45b29572014-03-24 10:19:32 +0000315#endif /* CONFIG_MIPS_MT_SMP */
316
317#ifdef CONFIG_MIPS_GIC_IPI
318
319#define GIC_MIPS_CPU_IPI_RESCHED_IRQ 3
320#define GIC_MIPS_CPU_IPI_CALL_IRQ 4
321
Ralf Baechle39b8d522008-04-28 17:14:26 +0100322static irqreturn_t ipi_resched_interrupt(int irq, void *dev_id)
323{
Deng-Cheng Zhu9c1f6e02014-02-28 10:23:01 -0800324#ifdef CONFIG_MIPS_VPE_APSP_API_CMP
Deng-Cheng Zhu13361132013-10-30 15:52:10 -0500325 if (aprp_hook)
326 aprp_hook();
327#endif
328
Peter Zijlstra184748c2011-04-05 17:23:39 +0200329 scheduler_ipi();
330
Ralf Baechle39b8d522008-04-28 17:14:26 +0100331 return IRQ_HANDLED;
332}
333
334static irqreturn_t ipi_call_interrupt(int irq, void *dev_id)
335{
336 smp_call_function_interrupt();
337
338 return IRQ_HANDLED;
339}
340
341static struct irqaction irq_resched = {
342 .handler = ipi_resched_interrupt,
Yong Zhang8b5690f2011-11-22 14:38:03 +0000343 .flags = IRQF_PERCPU,
Ralf Baechle39b8d522008-04-28 17:14:26 +0100344 .name = "IPI_resched"
345};
346
347static struct irqaction irq_call = {
348 .handler = ipi_call_interrupt,
Yong Zhang8b5690f2011-11-22 14:38:03 +0000349 .flags = IRQF_PERCPU,
Ralf Baechle39b8d522008-04-28 17:14:26 +0100350 .name = "IPI_call"
351};
Paul Burton45b29572014-03-24 10:19:32 +0000352#endif /* CONFIG_MIPS_GIC_IPI */
Tim Andersona214cef2009-06-17 16:22:25 -0700353
354static int gic_resched_int_base;
355static int gic_call_int_base;
356#define GIC_RESCHED_INT(cpu) (gic_resched_int_base+(cpu))
357#define GIC_CALL_INT(cpu) (gic_call_int_base+(cpu))
Tim Anderson03650702009-06-17 16:22:53 -0700358
359unsigned int plat_ipi_call_int_xlate(unsigned int cpu)
360{
361 return GIC_CALL_INT(cpu);
362}
363
364unsigned int plat_ipi_resched_int_xlate(unsigned int cpu)
365{
366 return GIC_RESCHED_INT(cpu);
367}
Ralf Baechle39b8d522008-04-28 17:14:26 +0100368
Ralf Baechlee01402b2005-07-14 15:57:16 +0000369static struct irqaction i8259irq = {
370 .handler = no_action,
Wu Zhangjin5a4a4ad2011-07-23 12:41:24 +0000371 .name = "XT-PIC cascade",
372 .flags = IRQF_NO_THREAD,
Ralf Baechlee01402b2005-07-14 15:57:16 +0000373};
374
375static struct irqaction corehi_irqaction = {
376 .handler = no_action,
Wu Zhangjin5a4a4ad2011-07-23 12:41:24 +0000377 .name = "CoreHi",
378 .flags = IRQF_NO_THREAD,
Ralf Baechlee01402b2005-07-14 15:57:16 +0000379};
380
Steven J. Hill5792bf62014-01-01 16:35:32 +0100381static msc_irqmap_t msc_irqmap[] __initdata = {
Ralf Baechlee01402b2005-07-14 15:57:16 +0000382 {MSC01C_INT_TMR, MSC01_IRQ_EDGE, 0},
383 {MSC01C_INT_PCI, MSC01_IRQ_LEVEL, 0},
384};
Steven J. Hill5792bf62014-01-01 16:35:32 +0100385static int msc_nr_irqs __initdata = ARRAY_SIZE(msc_irqmap);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000386
Steven J. Hill5792bf62014-01-01 16:35:32 +0100387static msc_irqmap_t msc_eicirqmap[] __initdata = {
Ralf Baechlee01402b2005-07-14 15:57:16 +0000388 {MSC01E_INT_SW0, MSC01_IRQ_LEVEL, 0},
389 {MSC01E_INT_SW1, MSC01_IRQ_LEVEL, 0},
390 {MSC01E_INT_I8259A, MSC01_IRQ_LEVEL, 0},
391 {MSC01E_INT_SMI, MSC01_IRQ_LEVEL, 0},
392 {MSC01E_INT_COREHI, MSC01_IRQ_LEVEL, 0},
393 {MSC01E_INT_CORELO, MSC01_IRQ_LEVEL, 0},
394 {MSC01E_INT_TMR, MSC01_IRQ_EDGE, 0},
395 {MSC01E_INT_PCI, MSC01_IRQ_LEVEL, 0},
396 {MSC01E_INT_PERFCTR, MSC01_IRQ_LEVEL, 0},
397 {MSC01E_INT_CPUCTR, MSC01_IRQ_LEVEL, 0}
398};
Ralf Baechle39b8d522008-04-28 17:14:26 +0100399
Steven J. Hill5792bf62014-01-01 16:35:32 +0100400static int msc_nr_eicirqs __initdata = ARRAY_SIZE(msc_eicirqmap);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000401
Ralf Baechle39b8d522008-04-28 17:14:26 +0100402/*
403 * This GIC specific tabular array defines the association between External
404 * Interrupts and CPUs/Core Interrupts. The nature of the External
405 * Interrupts is also defined here - polarity/trigger.
406 */
Chris Dearman7098f742009-07-10 01:54:09 -0700407
408#define GIC_CPU_NMI GIC_MAP_TO_NMI_MSK
Ralf Baechle863cb9b2010-09-17 17:07:48 +0100409#define X GIC_UNUSED
410
Tim Andersona214cef2009-06-17 16:22:25 -0700411static struct gic_intr_map gic_intr_map[GIC_NUM_INTRS] = {
Chris Dearman7098f742009-07-10 01:54:09 -0700412 { X, X, X, X, 0 },
Ralf Baechle70342282013-01-22 12:59:30 +0100413 { X, X, X, X, 0 },
Chris Dearman7098f742009-07-10 01:54:09 -0700414 { X, X, X, X, 0 },
415 { 0, GIC_CPU_INT0, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },
416 { 0, GIC_CPU_INT1, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },
417 { 0, GIC_CPU_INT2, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },
418 { 0, GIC_CPU_INT3, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },
419 { 0, GIC_CPU_INT4, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },
420 { 0, GIC_CPU_INT3, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },
421 { 0, GIC_CPU_INT3, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },
422 { X, X, X, X, 0 },
423 { X, X, X, X, 0 },
424 { 0, GIC_CPU_INT3, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },
425 { 0, GIC_CPU_NMI, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },
426 { 0, GIC_CPU_NMI, GIC_POL_POS, GIC_TRIG_LEVEL, GIC_FLAG_TRANSPARENT },
Ralf Baechle70342282013-01-22 12:59:30 +0100427 { X, X, X, X, 0 },
Chris Dearman7098f742009-07-10 01:54:09 -0700428 /* The remainder of this table is initialised by fill_ipi_map */
Ralf Baechle39b8d522008-04-28 17:14:26 +0100429};
Ralf Baechle863cb9b2010-09-17 17:07:48 +0100430#undef X
Ralf Baechle39b8d522008-04-28 17:14:26 +0100431
Paul Burton45b29572014-03-24 10:19:32 +0000432#ifdef CONFIG_MIPS_GIC_IPI
Tim Andersona214cef2009-06-17 16:22:25 -0700433static void __init fill_ipi_map1(int baseintr, int cpu, int cpupin)
434{
435 int intr = baseintr + cpu;
Tim Andersona214cef2009-06-17 16:22:25 -0700436 gic_intr_map[intr].cpunum = cpu;
437 gic_intr_map[intr].pin = cpupin;
438 gic_intr_map[intr].polarity = GIC_POL_POS;
439 gic_intr_map[intr].trigtype = GIC_TRIG_EDGE;
Jeffrey Deansb0a88ae2014-07-17 09:20:55 +0100440 gic_intr_map[intr].flags = 0;
Tim Andersona214cef2009-06-17 16:22:25 -0700441 ipi_map[cpu] |= (1 << (cpupin + 2));
Jeffrey Deans1c772b52014-07-17 09:20:58 +0100442 bitmap_set(ipi_ints, intr, 1);
Tim Andersona214cef2009-06-17 16:22:25 -0700443}
444
Dmitri Vorobiev7afed6a2008-06-18 10:18:21 +0300445static void __init fill_ipi_map(void)
Ralf Baechle39b8d522008-04-28 17:14:26 +0100446{
Tim Andersona214cef2009-06-17 16:22:25 -0700447 int cpu;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100448
Markos Chandras13b7ea62013-10-30 14:27:48 +0000449 for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
Tim Andersona214cef2009-06-17 16:22:25 -0700450 fill_ipi_map1(gic_resched_int_base, cpu, GIC_CPU_INT1);
451 fill_ipi_map1(gic_call_int_base, cpu, GIC_CPU_INT2);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100452 }
453}
Dmitri Vorobiev7afed6a2008-06-18 10:18:21 +0300454#endif
Ralf Baechle39b8d522008-04-28 17:14:26 +0100455
Chris Dearman7098f742009-07-10 01:54:09 -0700456void __init arch_init_ipiirq(int irq, struct irqaction *action)
457{
458 setup_irq(irq, action);
Thomas Gleixnere4ec7982011-03-27 15:19:28 +0200459 irq_set_handler(irq, handle_percpu_irq);
Chris Dearman7098f742009-07-10 01:54:09 -0700460}
461
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462void __init arch_init_irq(void)
463{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 init_i8259_irqs();
Ralf Baechlee01402b2005-07-14 15:57:16 +0000465
466 if (!cpu_has_veic)
Atsushi Nemoto97dcb822007-01-08 02:14:29 +0900467 mips_cpu_irq_init();
Ralf Baechlee01402b2005-07-14 15:57:16 +0000468
Paul Burton237036d2014-01-15 10:31:54 +0000469 if (mips_cm_present()) {
470 write_gcr_gic_base(GIC_BASE_ADDR | CM_GCR_GIC_BASE_GICEN_MSK);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100471 gic_present = 1;
472 } else {
Jaidev Patwardhan05cf2072009-07-10 01:54:25 -0700473 if (mips_revision_sconid == MIPS_REVISION_SCON_ROCIT) {
474 _msc01_biu_base = (unsigned long)
475 ioremap_nocache(MSC01_BIU_REG_BASE,
476 MSC01_BIU_ADDRSPACE_SZ);
477 gic_present = (REG(_msc01_biu_base, MSC01_SC_CFG) &
478 MSC01_SC_CFG_GICPRES_MSK) >>
479 MSC01_SC_CFG_GICPRES_SHF;
480 }
Ralf Baechle39b8d522008-04-28 17:14:26 +0100481 }
482 if (gic_present)
Chris Dearman7098f742009-07-10 01:54:09 -0700483 pr_debug("GIC present\n");
Ralf Baechle39b8d522008-04-28 17:14:26 +0100484
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300485 switch (mips_revision_sconid) {
486 case MIPS_REVISION_SCON_SOCIT:
487 case MIPS_REVISION_SCON_ROCIT:
Ralf Baechlee01402b2005-07-14 15:57:16 +0000488 if (cpu_has_veic)
Dmitri Vorobievf8071492008-01-24 19:52:47 +0300489 init_msc_irqs(MIPS_MSC01_IC_REG_BASE,
490 MSC01E_INT_BASE, msc_eicirqmap,
491 msc_nr_eicirqs);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000492 else
Dmitri Vorobievf8071492008-01-24 19:52:47 +0300493 init_msc_irqs(MIPS_MSC01_IC_REG_BASE,
494 MSC01C_INT_BASE, msc_irqmap,
495 msc_nr_irqs);
Chris Dearmand725cf32007-05-08 14:05:39 +0100496 break;
497
Dmitri Vorobievaf825582008-01-24 19:52:45 +0300498 case MIPS_REVISION_SCON_SOCITSC:
499 case MIPS_REVISION_SCON_SOCITSCP:
Chris Dearmand725cf32007-05-08 14:05:39 +0100500 if (cpu_has_veic)
Dmitri Vorobievf8071492008-01-24 19:52:47 +0300501 init_msc_irqs(MIPS_SOCITSC_IC_REG_BASE,
502 MSC01E_INT_BASE, msc_eicirqmap,
503 msc_nr_eicirqs);
Chris Dearmand725cf32007-05-08 14:05:39 +0100504 else
Dmitri Vorobievf8071492008-01-24 19:52:47 +0300505 init_msc_irqs(MIPS_SOCITSC_IC_REG_BASE,
506 MSC01C_INT_BASE, msc_irqmap,
507 msc_nr_irqs);
Ralf Baechlee01402b2005-07-14 15:57:16 +0000508 }
509
510 if (cpu_has_veic) {
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100511 set_vi_handler(MSC01E_INT_I8259A, malta_hw0_irqdispatch);
512 set_vi_handler(MSC01E_INT_COREHI, corehi_irqdispatch);
513 setup_irq(MSC01E_INT_BASE+MSC01E_INT_I8259A, &i8259irq);
514 setup_irq(MSC01E_INT_BASE+MSC01E_INT_COREHI, &corehi_irqaction);
Dmitri Vorobiev52b3fc02008-01-24 19:52:51 +0300515 } else if (cpu_has_vint) {
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100516 set_vi_handler(MIPSCPU_INT_I8259A, malta_hw0_irqdispatch);
517 set_vi_handler(MIPSCPU_INT_COREHI, corehi_irqdispatch);
Ralf Baechle49a89ef2007-10-11 23:46:15 +0100518 setup_irq(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_I8259A, &i8259irq);
Dmitri Vorobievf8071492008-01-24 19:52:47 +0300519 setup_irq(MIPS_CPU_IRQ_BASE+MIPSCPU_INT_COREHI,
520 &corehi_irqaction);
Dmitri Vorobiev52b3fc02008-01-24 19:52:51 +0300521 } else {
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 Baechlee01402b2005-07-14 15:57:16 +0000525 }
Ralf Baechle39b8d522008-04-28 17:14:26 +0100526
Ralf Baechle39b8d522008-04-28 17:14:26 +0100527 if (gic_present) {
528 /* FIXME */
529 int i;
Paul Burton45b29572014-03-24 10:19:32 +0000530#if defined(CONFIG_MIPS_GIC_IPI)
Markos Chandras13b7ea62013-10-30 14:27:48 +0000531 gic_call_int_base = GIC_NUM_INTRS -
532 (NR_CPUS - nr_cpu_ids) * 2 - nr_cpu_ids;
533 gic_resched_int_base = gic_call_int_base - nr_cpu_ids;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100534 fill_ipi_map();
Chris Dearman7098f742009-07-10 01:54:09 -0700535#endif
536 gic_init(GIC_BASE_ADDR, GIC_ADDRSPACE_SZ, gic_intr_map,
537 ARRAY_SIZE(gic_intr_map), MIPS_GIC_IRQ_BASE);
Paul Burton237036d2014-01-15 10:31:54 +0000538 if (!mips_cm_present()) {
Ralf Baechle39b8d522008-04-28 17:14:26 +0100539 /* Enable the GIC */
540 i = REG(_msc01_biu_base, MSC01_SC_CFG);
541 REG(_msc01_biu_base, MSC01_SC_CFG) =
542 (i | (0x1 << MSC01_SC_CFG_GICENA_SHF));
543 pr_debug("GIC Enabled\n");
544 }
Paul Burton45b29572014-03-24 10:19:32 +0000545#if defined(CONFIG_MIPS_GIC_IPI)
Ralf Baechle39b8d522008-04-28 17:14:26 +0100546 /* set up ipi interrupts */
547 if (cpu_has_vint) {
548 set_vi_handler(MIPSCPU_INT_IPI0, malta_ipi_irqdispatch);
549 set_vi_handler(MIPSCPU_INT_IPI1, malta_ipi_irqdispatch);
550 }
551 /* Argh.. this really needs sorting out.. */
Steven J. Hill5792bf62014-01-01 16:35:32 +0100552 pr_info("CPU%d: status register was %08x\n",
553 smp_processor_id(), read_c0_status());
Ralf Baechle39b8d522008-04-28 17:14:26 +0100554 write_c0_status(read_c0_status() | STATUSF_IP3 | STATUSF_IP4);
Steven J. Hill5792bf62014-01-01 16:35:32 +0100555 pr_info("CPU%d: status register now %08x\n",
556 smp_processor_id(), read_c0_status());
Ralf Baechle39b8d522008-04-28 17:14:26 +0100557 write_c0_status(0x1100dc00);
Steven J. Hill5792bf62014-01-01 16:35:32 +0100558 pr_info("CPU%d: status register frc %08x\n",
559 smp_processor_id(), read_c0_status());
Markos Chandras13b7ea62013-10-30 14:27:48 +0000560 for (i = 0; i < nr_cpu_ids; i++) {
Chris Dearman7098f742009-07-10 01:54:09 -0700561 arch_init_ipiirq(MIPS_GIC_IRQ_BASE +
562 GIC_RESCHED_INT(i), &irq_resched);
563 arch_init_ipiirq(MIPS_GIC_IRQ_BASE +
564 GIC_CALL_INT(i), &irq_call);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100565 }
Chris Dearman7098f742009-07-10 01:54:09 -0700566#endif
Ralf Baechle39b8d522008-04-28 17:14:26 +0100567 } else {
Chris Dearman7098f742009-07-10 01:54:09 -0700568#if defined(CONFIG_MIPS_MT_SMP)
Ralf Baechle39b8d522008-04-28 17:14:26 +0100569 /* set up ipi interrupts */
570 if (cpu_has_veic) {
571 set_vi_handler (MSC01E_INT_SW0, ipi_resched_dispatch);
572 set_vi_handler (MSC01E_INT_SW1, ipi_call_dispatch);
573 cpu_ipi_resched_irq = MSC01E_INT_SW0;
574 cpu_ipi_call_irq = MSC01E_INT_SW1;
575 } else {
576 if (cpu_has_vint) {
Steven J. Hill5792bf62014-01-01 16:35:32 +0100577 set_vi_handler (MIPS_CPU_IPI_RESCHED_IRQ,
578 ipi_resched_dispatch);
579 set_vi_handler (MIPS_CPU_IPI_CALL_IRQ,
580 ipi_call_dispatch);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100581 }
Steven J. Hill5792bf62014-01-01 16:35:32 +0100582 cpu_ipi_resched_irq = MIPS_CPU_IRQ_BASE +
583 MIPS_CPU_IPI_RESCHED_IRQ;
584 cpu_ipi_call_irq = MIPS_CPU_IRQ_BASE +
585 MIPS_CPU_IPI_CALL_IRQ;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100586 }
Chris Dearman7098f742009-07-10 01:54:09 -0700587 arch_init_ipiirq(cpu_ipi_resched_irq, &irq_resched);
588 arch_init_ipiirq(cpu_ipi_call_irq, &irq_call);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100589#endif
Chris Dearman7098f742009-07-10 01:54:09 -0700590 }
Ralf Baechle39b8d522008-04-28 17:14:26 +0100591}
592
593void malta_be_init(void)
594{
Steven J. Hill5792bf62014-01-01 16:35:32 +0100595 /* Could change CM error mask register. */
Ralf Baechle39b8d522008-04-28 17:14:26 +0100596}
597
598
599static char *tr[8] = {
600 "mem", "gcr", "gic", "mmio",
Ralf Baechle70342282013-01-22 12:59:30 +0100601 "0x04", "0x05", "0x06", "0x07"
Ralf Baechle39b8d522008-04-28 17:14:26 +0100602};
603
604static char *mcmd[32] = {
605 [0x00] = "0x00",
606 [0x01] = "Legacy Write",
607 [0x02] = "Legacy Read",
608 [0x03] = "0x03",
609 [0x04] = "0x04",
610 [0x05] = "0x05",
611 [0x06] = "0x06",
612 [0x07] = "0x07",
613 [0x08] = "Coherent Read Own",
614 [0x09] = "Coherent Read Share",
615 [0x0a] = "Coherent Read Discard",
616 [0x0b] = "Coherent Ready Share Always",
617 [0x0c] = "Coherent Upgrade",
618 [0x0d] = "Coherent Writeback",
619 [0x0e] = "0x0e",
620 [0x0f] = "0x0f",
621 [0x10] = "Coherent Copyback",
622 [0x11] = "Coherent Copyback Invalidate",
623 [0x12] = "Coherent Invalidate",
624 [0x13] = "Coherent Write Invalidate",
625 [0x14] = "Coherent Completion Sync",
626 [0x15] = "0x15",
627 [0x16] = "0x16",
628 [0x17] = "0x17",
629 [0x18] = "0x18",
630 [0x19] = "0x19",
631 [0x1a] = "0x1a",
632 [0x1b] = "0x1b",
633 [0x1c] = "0x1c",
634 [0x1d] = "0x1d",
635 [0x1e] = "0x1e",
636 [0x1f] = "0x1f"
637};
638
639static char *core[8] = {
Ralf Baechle70342282013-01-22 12:59:30 +0100640 "Invalid/OK", "Invalid/Data",
Ralf Baechle39b8d522008-04-28 17:14:26 +0100641 "Shared/OK", "Shared/Data",
642 "Modified/OK", "Modified/Data",
Ralf Baechle70342282013-01-22 12:59:30 +0100643 "Exclusive/OK", "Exclusive/Data"
Ralf Baechle39b8d522008-04-28 17:14:26 +0100644};
645
646static char *causes[32] = {
647 "None", "GC_WR_ERR", "GC_RD_ERR", "COH_WR_ERR",
648 "COH_RD_ERR", "MMIO_WR_ERR", "MMIO_RD_ERR", "0x07",
649 "0x08", "0x09", "0x0a", "0x0b",
650 "0x0c", "0x0d", "0x0e", "0x0f",
651 "0x10", "0x11", "0x12", "0x13",
652 "0x14", "0x15", "0x16", "INTVN_WR_ERR",
653 "INTVN_RD_ERR", "0x19", "0x1a", "0x1b",
654 "0x1c", "0x1d", "0x1e", "0x1f"
655};
656
657int malta_be_handler(struct pt_regs *regs, int is_fixup)
658{
659 /* This duplicates the handling in do_be which seems wrong */
660 int retval = is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL;
661
Paul Burton237036d2014-01-15 10:31:54 +0000662 if (mips_cm_present()) {
663 unsigned long cm_error = read_gcr_error_cause();
664 unsigned long cm_addr = read_gcr_error_addr();
665 unsigned long cm_other = read_gcr_error_mult();
Ralf Baechle39b8d522008-04-28 17:14:26 +0100666 unsigned long cause, ocause;
667 char buf[256];
668
Paul Burton237036d2014-01-15 10:31:54 +0000669 cause = cm_error & CM_GCR_ERROR_CAUSE_ERRTYPE_MSK;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100670 if (cause != 0) {
Paul Burton237036d2014-01-15 10:31:54 +0000671 cause >>= CM_GCR_ERROR_CAUSE_ERRTYPE_SHF;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100672 if (cause < 16) {
673 unsigned long cca_bits = (cm_error >> 15) & 7;
674 unsigned long tr_bits = (cm_error >> 12) & 7;
Steven J. Hill5792bf62014-01-01 16:35:32 +0100675 unsigned long cmd_bits = (cm_error >> 7) & 0x1f;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100676 unsigned long stag_bits = (cm_error >> 3) & 15;
677 unsigned long sport_bits = (cm_error >> 0) & 7;
678
679 snprintf(buf, sizeof(buf),
680 "CCA=%lu TR=%s MCmd=%s STag=%lu "
681 "SPort=%lu\n",
Steven J. Hill5792bf62014-01-01 16:35:32 +0100682 cca_bits, tr[tr_bits], mcmd[cmd_bits],
Ralf Baechle39b8d522008-04-28 17:14:26 +0100683 stag_bits, sport_bits);
684 } else {
685 /* glob state & sresp together */
686 unsigned long c3_bits = (cm_error >> 18) & 7;
687 unsigned long c2_bits = (cm_error >> 15) & 7;
688 unsigned long c1_bits = (cm_error >> 12) & 7;
689 unsigned long c0_bits = (cm_error >> 9) & 7;
690 unsigned long sc_bit = (cm_error >> 8) & 1;
Steven J. Hill5792bf62014-01-01 16:35:32 +0100691 unsigned long cmd_bits = (cm_error >> 3) & 0x1f;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100692 unsigned long sport_bits = (cm_error >> 0) & 7;
693 snprintf(buf, sizeof(buf),
694 "C3=%s C2=%s C1=%s C0=%s SC=%s "
695 "MCmd=%s SPort=%lu\n",
696 core[c3_bits], core[c2_bits],
697 core[c1_bits], core[c0_bits],
698 sc_bit ? "True" : "False",
Steven J. Hill5792bf62014-01-01 16:35:32 +0100699 mcmd[cmd_bits], sport_bits);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100700 }
701
Paul Burton237036d2014-01-15 10:31:54 +0000702 ocause = (cm_other & CM_GCR_ERROR_MULT_ERR2ND_MSK) >>
703 CM_GCR_ERROR_MULT_ERR2ND_SHF;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100704
Steven J. Hill5792bf62014-01-01 16:35:32 +0100705 pr_err("CM_ERROR=%08lx %s <%s>\n", cm_error,
Ralf Baechle39b8d522008-04-28 17:14:26 +0100706 causes[cause], buf);
Steven J. Hill5792bf62014-01-01 16:35:32 +0100707 pr_err("CM_ADDR =%08lx\n", cm_addr);
708 pr_err("CM_OTHER=%08lx %s\n", cm_other, causes[ocause]);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100709
710 /* reprime cause register */
Paul Burton237036d2014-01-15 10:31:54 +0000711 write_gcr_error_cause(0);
Ralf Baechle39b8d522008-04-28 17:14:26 +0100712 }
713 }
714
715 return retval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716}
Steven J. Hill0b271f52012-08-31 16:05:37 -0500717
718void gic_enable_interrupt(int irq_vec)
719{
720 GIC_SET_INTR_MASK(irq_vec);
721}
722
723void gic_disable_interrupt(int irq_vec)
724{
725 GIC_CLR_INTR_MASK(irq_vec);
726}
727
728void gic_irq_ack(struct irq_data *d)
729{
730 int irq = (d->irq - gic_irq_base);
731
732 GIC_CLR_INTR_MASK(irq);
733
734 if (gic_irq_flags[irq] & GIC_TRIG_EDGE)
735 GICWRITE(GIC_REG(SHARED, GIC_SH_WEDGE), irq);
736}
737
738void gic_finish_irq(struct irq_data *d)
739{
740 /* Enable interrupts. */
741 GIC_SET_INTR_MASK(d->irq - gic_irq_base);
742}
743
744void __init gic_platform_init(int irqs, struct irq_chip *irq_controller)
745{
746 int i;
747
748 for (i = gic_irq_base; i < (gic_irq_base + irqs); i++)
749 irq_set_chip(i, irq_controller);
750}