2 * arch/ppc/kernel/mv64360_pic.c
4 * Interrupt controller support for Marvell's MV64360.
6 * Author: Rabeeh Khoury <rabeeh@galileo.co.il>
7 * Based on MV64360 PIC written by
8 * Chris Zankel <chris@mvista.com>
9 * Mark A. Greer <mgreer@mvista.com>
11 * Copyright 2004 MontaVista Software, Inc.
13 * This program is free software; you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the
15 * Free Software Foundation; either version 2 of the License, or (at your
16 * option) any later version.
20 * This file contains the specific functions to support the MV64360
21 * interrupt controller.
23 * The MV64360 has two main interrupt registers (high and low) that
24 * summarizes the interrupts generated by the units of the MV64360.
25 * Each bit is assigned to an interrupt number, where the low register
26 * are assigned from IRQ0 to IRQ31 and the high cause register
28 * The GPP (General Purpose Pins) interrupts are assigned from IRQ64 (GPP0)
30 * get_irq() returns the lowest interrupt number that is currently asserted.
33 * - This driver does not initialize the GPP when used as an interrupt
37 #include <linux/stddef.h>
38 #include <linux/init.h>
39 #include <linux/sched.h>
40 #include <linux/signal.h>
41 #include <linux/stddef.h>
42 #include <linux/delay.h>
43 #include <linux/irq.h>
44 #include <linux/interrupt.h>
47 #include <asm/processor.h>
48 #include <asm/system.h>
50 #include <asm/mv64x60.h>
52 #ifdef CONFIG_IRQ_ALL_CPUS
53 #error "The mv64360 does not support distribution of IRQs on all CPUs"
55 /* ========================== forward declaration ========================== */
57 static void mv64360_unmask_irq(unsigned int);
58 static void mv64360_mask_irq(unsigned int);
59 static irqreturn_t mv64360_cpu_error_int_handler(int, void *, struct pt_regs *);
60 static irqreturn_t mv64360_sram_error_int_handler(int, void *,
62 static irqreturn_t mv64360_pci_error_int_handler(int, void *, struct pt_regs *);
64 /* ========================== local declarations =========================== */
66 struct hw_interrupt_type mv64360_pic = {
67 .typename = " mv64360_pic ",
68 .enable = mv64360_unmask_irq,
69 .disable = mv64360_mask_irq,
70 .ack = mv64360_mask_irq,
71 .end = mv64360_unmask_irq,
74 #define CPU_INTR_STR "mv64360 cpu interface error"
75 #define SRAM_INTR_STR "mv64360 internal sram error"
76 #define PCI0_INTR_STR "mv64360 pci 0 error"
77 #define PCI1_INTR_STR "mv64360 pci 1 error"
79 static struct mv64x60_handle bh;
81 u32 mv64360_irq_base = 0; /* MV64360 handles the next 96 IRQs from here */
85 * This function initializes the interrupt controller. It assigns
86 * all interrupts from IRQ0 to IRQ95 to the mv64360 interrupt controller.
98 * We register all GPP inputs as interrupt source, but disable them.
101 mv64360_init_irq(void)
106 ppc_md.progress("mv64360_init_irq: enter", 0x0);
108 bh.v_base = mv64x60_get_bridge_vbase();
110 ppc_cached_irq_mask[0] = 0;
111 ppc_cached_irq_mask[1] = 0x0f000000; /* Enable GPP intrs */
112 ppc_cached_irq_mask[2] = 0;
114 /* disable all interrupts and clear current interrupts */
115 mv64x60_write(&bh, MV64x60_GPP_INTR_CAUSE, 0);
116 mv64x60_write(&bh, MV64x60_GPP_INTR_MASK, ppc_cached_irq_mask[2]);
117 mv64x60_write(&bh, MV64360_IC_CPU0_INTR_MASK_LO,ppc_cached_irq_mask[0]);
118 mv64x60_write(&bh, MV64360_IC_CPU0_INTR_MASK_HI,ppc_cached_irq_mask[1]);
120 /* All interrupts are level interrupts */
121 for (i = mv64360_irq_base; i < (mv64360_irq_base + 96); i++) {
122 irq_desc[i].status |= IRQ_LEVEL;
123 irq_desc[i].handler = &mv64360_pic;
127 ppc_md.progress("mv64360_init_irq: exit", 0x0);
132 * This function returns the lowest interrupt number of all interrupts that
133 * are currently asserted.
136 * struct pt_regs* not used
138 * Output Variable(s):
142 * int <interrupt number> or -2 (bogus interrupt)
146 mv64360_get_irq(struct pt_regs *regs)
153 * Second CPU gets only doorbell (message) interrupts.
154 * The doorbell interrupt is BIT28 in the main interrupt low cause reg.
156 int cpu_nr = smp_processor_id();
158 if (!(mv64x60_read(&bh, MV64360_IC_MAIN_CAUSE_LO) & (1 << 28)))
164 irq = mv64x60_read(&bh, MV64360_IC_MAIN_CAUSE_LO);
165 irq = __ilog2((irq & 0x3dfffffe) & ppc_cached_irq_mask[0]);
168 irq = mv64x60_read(&bh, MV64360_IC_MAIN_CAUSE_HI);
169 irq = __ilog2((irq & 0x1f0003f7) & ppc_cached_irq_mask[1]);
172 irq = -2; /* bogus interrupt, should never happen */
174 if ((irq >= 24) && (irq < 28)) {
175 irq_gpp = mv64x60_read(&bh,
176 MV64x60_GPP_INTR_CAUSE);
177 irq_gpp = __ilog2(irq_gpp &
178 ppc_cached_irq_mask[2]);
185 MV64x60_GPP_INTR_CAUSE,
194 (void)mv64x60_read(&bh, MV64x60_GPP_INTR_CAUSE);
199 return (mv64360_irq_base + irq);
202 /* mv64360_unmask_irq()
204 * This function enables an interrupt.
207 * unsigned int interrupt number (IRQ0...IRQ95).
209 * Output Variable(s):
216 mv64360_unmask_irq(unsigned int irq)
219 /* second CPU gets only doorbell interrupts */
220 if ((irq - mv64360_irq_base) == 28) {
221 mv64x60_set_bits(&bh, MV64360_IC_CPU1_INTR_MASK_LO, (1 << 28));
225 irq -= mv64360_irq_base;
228 if (irq > 63) /* unmask GPP irq */
229 mv64x60_write(&bh, MV64x60_GPP_INTR_MASK,
230 ppc_cached_irq_mask[2] |= (1 << (irq - 64)));
231 else /* mask high interrupt register */
232 mv64x60_write(&bh, MV64360_IC_CPU0_INTR_MASK_HI,
233 ppc_cached_irq_mask[1] |= (1 << (irq - 32)));
235 else /* mask low interrupt register */
236 mv64x60_write(&bh, MV64360_IC_CPU0_INTR_MASK_LO,
237 ppc_cached_irq_mask[0] |= (1 << irq));
239 (void)mv64x60_read(&bh, MV64x60_GPP_INTR_MASK);
243 /* mv64360_mask_irq()
245 * This function disables the requested interrupt.
248 * unsigned int interrupt number (IRQ0...IRQ95).
250 * Output Variable(s):
257 mv64360_mask_irq(unsigned int irq)
260 if ((irq - mv64360_irq_base) == 28) {
261 mv64x60_clr_bits(&bh, MV64360_IC_CPU1_INTR_MASK_LO, (1 << 28));
265 irq -= mv64360_irq_base;
268 if (irq > 63) /* mask GPP irq */
269 mv64x60_write(&bh, MV64x60_GPP_INTR_MASK,
270 ppc_cached_irq_mask[2] &= ~(1 << (irq - 64)));
271 else /* mask high interrupt register */
272 mv64x60_write(&bh, MV64360_IC_CPU0_INTR_MASK_HI,
273 ppc_cached_irq_mask[1] &= ~(1 << (irq - 32)));
275 else /* mask low interrupt register */
276 mv64x60_write(&bh, MV64360_IC_CPU0_INTR_MASK_LO,
277 ppc_cached_irq_mask[0] &= ~(1 << irq));
279 (void)mv64x60_read(&bh, MV64x60_GPP_INTR_MASK);
284 mv64360_cpu_error_int_handler(int irq, void *dev_id, struct pt_regs *regs)
286 printk(KERN_ERR "mv64360_cpu_error_int_handler: %s 0x%08x\n",
287 "Error on CPU interface - Cause regiser",
288 mv64x60_read(&bh, MV64x60_CPU_ERR_CAUSE));
289 printk(KERN_ERR "\tCPU error register dump:\n");
290 printk(KERN_ERR "\tAddress low 0x%08x\n",
291 mv64x60_read(&bh, MV64x60_CPU_ERR_ADDR_LO));
292 printk(KERN_ERR "\tAddress high 0x%08x\n",
293 mv64x60_read(&bh, MV64x60_CPU_ERR_ADDR_HI));
294 printk(KERN_ERR "\tData low 0x%08x\n",
295 mv64x60_read(&bh, MV64x60_CPU_ERR_DATA_LO));
296 printk(KERN_ERR "\tData high 0x%08x\n",
297 mv64x60_read(&bh, MV64x60_CPU_ERR_DATA_HI));
298 printk(KERN_ERR "\tParity 0x%08x\n",
299 mv64x60_read(&bh, MV64x60_CPU_ERR_PARITY));
300 mv64x60_write(&bh, MV64x60_CPU_ERR_CAUSE, 0);
305 mv64360_sram_error_int_handler(int irq, void *dev_id, struct pt_regs *regs)
307 printk(KERN_ERR "mv64360_sram_error_int_handler: %s 0x%08x\n",
308 "Error in internal SRAM - Cause register",
309 mv64x60_read(&bh, MV64360_SRAM_ERR_CAUSE));
310 printk(KERN_ERR "\tSRAM error register dump:\n");
311 printk(KERN_ERR "\tAddress Low 0x%08x\n",
312 mv64x60_read(&bh, MV64360_SRAM_ERR_ADDR_LO));
313 printk(KERN_ERR "\tAddress High 0x%08x\n",
314 mv64x60_read(&bh, MV64360_SRAM_ERR_ADDR_HI));
315 printk(KERN_ERR "\tData Low 0x%08x\n",
316 mv64x60_read(&bh, MV64360_SRAM_ERR_DATA_LO));
317 printk(KERN_ERR "\tData High 0x%08x\n",
318 mv64x60_read(&bh, MV64360_SRAM_ERR_DATA_HI));
319 printk(KERN_ERR "\tParity 0x%08x\n",
320 mv64x60_read(&bh, MV64360_SRAM_ERR_PARITY));
321 mv64x60_write(&bh, MV64360_SRAM_ERR_CAUSE, 0);
326 mv64360_pci_error_int_handler(int irq, void *dev_id, struct pt_regs *regs)
329 unsigned int pci_bus = (unsigned int)dev_id;
331 if (pci_bus == 0) { /* Error on PCI 0 */
332 val = mv64x60_read(&bh, MV64x60_PCI0_ERR_CAUSE);
333 printk(KERN_ERR "%s: Error in PCI %d Interface\n",
334 "mv64360_pci_error_int_handler", pci_bus);
335 printk(KERN_ERR "\tPCI %d error register dump:\n", pci_bus);
336 printk(KERN_ERR "\tCause register 0x%08x\n", val);
337 printk(KERN_ERR "\tAddress Low 0x%08x\n",
338 mv64x60_read(&bh, MV64x60_PCI0_ERR_ADDR_LO));
339 printk(KERN_ERR "\tAddress High 0x%08x\n",
340 mv64x60_read(&bh, MV64x60_PCI0_ERR_ADDR_HI));
341 printk(KERN_ERR "\tAttribute 0x%08x\n",
342 mv64x60_read(&bh, MV64x60_PCI0_ERR_DATA_LO));
343 printk(KERN_ERR "\tCommand 0x%08x\n",
344 mv64x60_read(&bh, MV64x60_PCI0_ERR_CMD));
345 mv64x60_write(&bh, MV64x60_PCI0_ERR_CAUSE, ~val);
347 if (pci_bus == 1) { /* Error on PCI 1 */
348 val = mv64x60_read(&bh, MV64x60_PCI1_ERR_CAUSE);
349 printk(KERN_ERR "%s: Error in PCI %d Interface\n",
350 "mv64360_pci_error_int_handler", pci_bus);
351 printk(KERN_ERR "\tPCI %d error register dump:\n", pci_bus);
352 printk(KERN_ERR "\tCause register 0x%08x\n", val);
353 printk(KERN_ERR "\tAddress Low 0x%08x\n",
354 mv64x60_read(&bh, MV64x60_PCI1_ERR_ADDR_LO));
355 printk(KERN_ERR "\tAddress High 0x%08x\n",
356 mv64x60_read(&bh, MV64x60_PCI1_ERR_ADDR_HI));
357 printk(KERN_ERR "\tAttribute 0x%08x\n",
358 mv64x60_read(&bh, MV64x60_PCI1_ERR_DATA_LO));
359 printk(KERN_ERR "\tCommand 0x%08x\n",
360 mv64x60_read(&bh, MV64x60_PCI1_ERR_CMD));
361 mv64x60_write(&bh, MV64x60_PCI1_ERR_CAUSE, ~val);
367 mv64360_register_hdlrs(void)
372 /* Clear old errors and register CPU interface error intr handler */
373 mv64x60_write(&bh, MV64x60_CPU_ERR_CAUSE, 0);
374 if ((rc = request_irq(MV64x60_IRQ_CPU_ERR,
375 mv64360_cpu_error_int_handler, SA_INTERRUPT, CPU_INTR_STR, 0)))
376 printk(KERN_WARNING "Can't register cpu error handler: %d", rc);
378 mv64x60_write(&bh, MV64x60_CPU_ERR_MASK, 0);
379 mv64x60_write(&bh, MV64x60_CPU_ERR_MASK, 0x000000ff);
381 /* Clear old errors and register internal SRAM error intr handler */
382 mv64x60_write(&bh, MV64360_SRAM_ERR_CAUSE, 0);
383 if ((rc = request_irq(MV64360_IRQ_SRAM_PAR_ERR,
384 mv64360_sram_error_int_handler,SA_INTERRUPT,SRAM_INTR_STR, 0)))
385 printk(KERN_WARNING "Can't register SRAM error handler: %d",rc);
388 * Bit 0 reserved on 64360 and erratum FEr PCI-#11 (PCI internal
389 * data parity error set incorrectly) on rev 0 & 1 of 64460 requires
390 * bit 0 to be cleared.
394 if ((mv64x60_get_bridge_type() == MV64x60_TYPE_MV64460) &&
395 (mv64x60_get_bridge_rev() > 1))
396 mask |= 0x1; /* enable DPErr on 64460 */
398 /* Clear old errors and register PCI 0 error intr handler */
399 mv64x60_write(&bh, MV64x60_PCI0_ERR_CAUSE, 0);
400 if ((rc = request_irq(MV64360_IRQ_PCI0, mv64360_pci_error_int_handler,
401 SA_INTERRUPT, PCI0_INTR_STR, (void *)0)))
402 printk(KERN_WARNING "Can't register pci 0 error handler: %d",
405 mv64x60_write(&bh, MV64x60_PCI0_ERR_MASK, 0);
406 mv64x60_write(&bh, MV64x60_PCI0_ERR_MASK, mask);
408 /* Clear old errors and register PCI 1 error intr handler */
409 mv64x60_write(&bh, MV64x60_PCI1_ERR_CAUSE, 0);
410 if ((rc = request_irq(MV64360_IRQ_PCI1, mv64360_pci_error_int_handler,
411 SA_INTERRUPT, PCI1_INTR_STR, (void *)1)))
412 printk(KERN_WARNING "Can't register pci 1 error handler: %d",
415 mv64x60_write(&bh, MV64x60_PCI1_ERR_MASK, 0);
416 mv64x60_write(&bh, MV64x60_PCI1_ERR_MASK, mask);
421 arch_initcall(mv64360_register_hdlrs);