Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[linux-2.6.git] / arch / mips / vr41xx / common / irq.c
index 61aa264..0975eb7 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  Interrupt handing routines for NEC VR4100 series.
  *
- *  Copyright (C) 2005  Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
+ *  Copyright (C) 2005-2007  Yoichi Yuasa <yuasa@linux-mips.org>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
  */
 #include <linux/interrupt.h>
 #include <linux/module.h>
+#include <linux/irq.h>
 
 #include <asm/irq_cpu.h>
 #include <asm/system.h>
-#include <asm/vr41xx/vr41xx.h>
+#include <asm/vr41xx/irq.h>
 
 typedef struct irq_cascade {
-       int (*get_irq)(unsigned int, struct pt_regs *);
+       int (*get_irq)(unsigned int);
 } irq_cascade_t;
 
 static irq_cascade_t irq_cascade[NR_IRQS] __cacheline_aligned;
 
 static struct irqaction cascade_irqaction = {
        .handler        = no_action,
-       .mask           = CPU_MASK_NONE,
        .name           = "cascade",
 };
 
-int cascade_irq(unsigned int irq, int (*get_irq)(unsigned int, struct pt_regs *))
+int cascade_irq(unsigned int irq, int (*get_irq)(unsigned int))
 {
        int retval = 0;
 
@@ -59,10 +59,10 @@ int cascade_irq(unsigned int irq, int (*get_irq)(unsigned int, struct pt_regs *)
 
 EXPORT_SYMBOL_GPL(cascade_irq);
 
-asmlinkage void irq_dispatch(unsigned int irq, struct pt_regs *regs)
+static void irq_dispatch(unsigned int irq)
 {
        irq_cascade_t *cascade;
-       irq_desc_t *desc;
+       struct irq_desc *desc;
 
        if (irq >= NR_IRQS) {
                atomic_inc(&irq_err_count);
@@ -72,23 +72,52 @@ asmlinkage void irq_dispatch(unsigned int irq, struct pt_regs *regs)
        cascade = irq_cascade + irq;
        if (cascade->get_irq != NULL) {
                unsigned int source_irq = irq;
+               int ret;
                desc = irq_desc + source_irq;
-               desc->handler->ack(source_irq);
-               irq = cascade->get_irq(irq, regs);
-               if (irq < 0)
+               if (desc->chip->mask_ack)
+                       desc->chip->mask_ack(source_irq);
+               else {
+                       desc->chip->mask(source_irq);
+                       desc->chip->ack(source_irq);
+               }
+               ret = cascade->get_irq(irq);
+               irq = ret;
+               if (ret < 0)
                        atomic_inc(&irq_err_count);
                else
-                       irq_dispatch(irq, regs);
-               desc->handler->end(source_irq);
+                       irq_dispatch(irq);
+               if (!(desc->status & IRQ_DISABLED) && desc->chip->unmask)
+                       desc->chip->unmask(source_irq);
        } else
-               do_IRQ(irq, regs);
+               do_IRQ(irq);
 }
 
-extern asmlinkage void vr41xx_handle_interrupt(void);
+asmlinkage void plat_irq_dispatch(void)
+{
+       unsigned int pending = read_c0_cause() & read_c0_status() & ST0_IM;
+
+       if (pending & CAUSEF_IP7)
+               do_IRQ(TIMER_IRQ);
+       else if (pending & 0x7800) {
+               if (pending & CAUSEF_IP3)
+                       irq_dispatch(INT1_IRQ);
+               else if (pending & CAUSEF_IP4)
+                       irq_dispatch(INT2_IRQ);
+               else if (pending & CAUSEF_IP5)
+                       irq_dispatch(INT3_IRQ);
+               else if (pending & CAUSEF_IP6)
+                       irq_dispatch(INT4_IRQ);
+       } else if (pending & CAUSEF_IP2)
+               irq_dispatch(INT0_IRQ);
+       else if (pending & CAUSEF_IP0)
+               do_IRQ(MIPS_SOFTINT0_IRQ);
+       else if (pending & CAUSEF_IP1)
+               do_IRQ(MIPS_SOFTINT1_IRQ);
+       else
+               spurious_interrupt();
+}
 
 void __init arch_init_irq(void)
 {
-       mips_cpu_irq_init(MIPS_CPU_IRQ_BASE);
-
-       set_except_vector(0, vr41xx_handle_interrupt);
+       mips_cpu_irq_init();
 }