Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / arch / mips / au1000 / common / irq.c
index d1eb5a4..afe05ec 100644 (file)
@@ -66,9 +66,9 @@
 #define EXT_INTC1_REQ1 5 /* IP 5 */
 #define MIPS_TIMER_IP  7 /* IP 7 */
 
-extern asmlinkage void au1000_IRQ(void);
 extern void set_debug_traps(void);
 extern irq_cpustat_t irq_stat [NR_CPUS];
+extern void mips_timer_interrupt(struct pt_regs *regs);
 
 static void setup_local_irq(unsigned int irq, int type, int int_req);
 static unsigned int startup_irq(unsigned int irq);
@@ -83,7 +83,7 @@ inline void local_disable_irq(unsigned int irq_nr);
 void   (*board_init_irq)(void);
 
 #ifdef CONFIG_PM
-extern void counter0_irq(int irq, void *dev_id, struct pt_regs *regs);
+extern irqreturn_t counter0_irq(int irq, void *dev_id, struct pt_regs *regs);
 #endif
 
 static DEFINE_SPINLOCK(irq_lock);
@@ -253,52 +253,72 @@ void restore_local_and_enable(int controller, unsigned long mask)
 
 
 static struct hw_interrupt_type rise_edge_irq_type = {
-       "Au1000 Rise Edge",
-       startup_irq,
-       shutdown_irq,
-       local_enable_irq,
-       local_disable_irq,
-       mask_and_ack_rise_edge_irq,
-       end_irq,
-       NULL
+       .typename = "Au1000 Rise Edge",
+       .startup = startup_irq,
+       .shutdown = shutdown_irq,
+       .enable = local_enable_irq,
+       .disable = local_disable_irq,
+       .ack = mask_and_ack_rise_edge_irq,
+       .end = end_irq,
 };
 
 static struct hw_interrupt_type fall_edge_irq_type = {
-       "Au1000 Fall Edge",
-       startup_irq,
-       shutdown_irq,
-       local_enable_irq,
-       local_disable_irq,
-       mask_and_ack_fall_edge_irq,
-       end_irq,
-       NULL
+       .typename = "Au1000 Fall Edge",
+       .startup = startup_irq,
+       .shutdown = shutdown_irq,
+       .enable = local_enable_irq,
+       .disable = local_disable_irq,
+       .ack = mask_and_ack_fall_edge_irq,
+       .end = end_irq,
 };
 
 static struct hw_interrupt_type either_edge_irq_type = {
-       "Au1000 Rise or Fall Edge",
-       startup_irq,
-       shutdown_irq,
-       local_enable_irq,
-       local_disable_irq,
-       mask_and_ack_either_edge_irq,
-       end_irq,
-       NULL
+       .typename = "Au1000 Rise or Fall Edge",
+       .startup = startup_irq,
+       .shutdown = shutdown_irq,
+       .enable = local_enable_irq,
+       .disable = local_disable_irq,
+       .ack = mask_and_ack_either_edge_irq,
+       .end = end_irq,
 };
 
 static struct hw_interrupt_type level_irq_type = {
-       "Au1000 Level",
-       startup_irq,
-       shutdown_irq,
-       local_enable_irq,
-       local_disable_irq,
-       mask_and_ack_level_irq,
-       end_irq,
-       NULL
+       .typename = "Au1000 Level",
+       .startup = startup_irq,
+       .shutdown = shutdown_irq,
+       .enable = local_enable_irq,
+       .disable = local_disable_irq,
+       .ack = mask_and_ack_level_irq,
+       .end = end_irq,
 };
 
 #ifdef CONFIG_PM
-void startup_match20_interrupt(void)
+void startup_match20_interrupt(irqreturn_t (*handler)(int, void *, struct pt_regs *))
 {
+       struct irq_desc *desc = &irq_desc[AU1000_TOY_MATCH2_INT];
+
+       static struct irqaction action;
+       memset(&action, 0, sizeof(struct irqaction));
+
+       /* This is a big problem.... since we didn't use request_irq
+        * when kernel/irq.c calls probe_irq_xxx this interrupt will
+        * be probed for usage. This will end up disabling the device :(
+        * Give it a bogus "action" pointer -- this will keep it from
+        * getting auto-probed!
+        *
+        * By setting the status to match that of request_irq() we
+        * can avoid it.  --cgray
+       */
+       action.dev_id = handler;
+       action.flags = SA_INTERRUPT;
+       cpus_clear(action.mask);
+       action.name = "Au1xxx TOY";
+       action.handler = handler;
+       action.next = NULL;
+
+       desc->action = &action;
+       desc->status &= ~(IRQ_DISABLED | IRQ_AUTODETECT | IRQ_WAITING | IRQ_INPROGRESS);
+
        local_enable_irq(AU1000_TOY_MATCH2_INT);
 }
 #endif
@@ -426,8 +446,6 @@ void __init arch_init_irq(void)
        extern int au1xxx_ic0_nr_irqs;
 
        cp0_status = read_c0_status();
-       memset(irq_desc, 0, sizeof(irq_desc));
-       set_except_vector(0, au1000_IRQ);
 
        /* Initialize interrupt controllers to a safe state.
        */
@@ -492,7 +510,7 @@ void intc0_req0_irqdispatch(struct pt_regs *regs)
        intc0_req0 |= au_readl(IC0_REQ0INT);
 
        if (!intc0_req0) return;
-
+#ifdef AU1000_USB_DEV_REQ_INT
        /*
         * Because of the tight timing of SETUP token to reply
         * transactions, the USB devices-side packet complete
@@ -503,7 +521,7 @@ void intc0_req0_irqdispatch(struct pt_regs *regs)
                do_IRQ(AU1000_USB_DEV_REQ_INT, regs);
                return;
        }
-
+#endif
        irq = au_ffs(intc0_req0) - 1;
        intc0_req0 &= ~(1<<irq);
        do_IRQ(irq, regs);
@@ -521,17 +539,7 @@ void intc0_req1_irqdispatch(struct pt_regs *regs)
 
        irq = au_ffs(intc0_req1) - 1;
        intc0_req1 &= ~(1<<irq);
-#ifdef CONFIG_PM
-       if (irq == AU1000_TOY_MATCH2_INT) {
-               mask_and_ack_rise_edge_irq(irq);
-               counter0_irq(irq, NULL, regs);
-               local_enable_irq(irq);
-       }
-       else
-#endif
-       {
-               do_IRQ(irq, regs);
-       }
+       do_IRQ(irq, regs);
 }
 
 
@@ -652,3 +660,21 @@ restore_au1xxx_intctl(void)
        au_writel(sleep_intctl_mask[0], IC0_MASKSET); au_sync();
 }
 #endif /* CONFIG_PM */
+
+asmlinkage void plat_irq_dispatch(struct pt_regs *regs)
+{
+       unsigned int pending = read_c0_status() & read_c0_cause() & ST0_IM;
+
+       if (pending & CAUSEF_IP7)
+               mips_timer_interrupt(regs);
+       else if (pending & CAUSEF_IP2)
+               intc0_req0_irqdispatch(regs);
+       else if (pending & CAUSEF_IP3)
+               intc0_req1_irqdispatch(regs);
+       else if (pending & CAUSEF_IP4)
+               intc1_req0_irqdispatch(regs);
+       else if (pending  & CAUSEF_IP5)
+               intc1_req1_irqdispatch(regs);
+       else
+               spurious_interrupt(regs);
+}