Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[pandora-kernel.git] / arch / mips / sibyte / bcm1480 / irq.c
index ba0c4b7..10299ba 100644 (file)
@@ -76,7 +76,7 @@ __setup("nokgdb", nokgdb);
 
 /* Default to UART1 */
 int kgdb_port = 1;
-#ifdef CONFIG_SIBYTE_SB1250_DUART
+#ifdef CONFIG_SERIAL_SB1250_DUART
 extern char sb1250_duart_present[];
 #endif
 #endif
@@ -100,8 +100,8 @@ DEFINE_SPINLOCK(bcm1480_imr_lock);
 
 void bcm1480_mask_irq(int cpu, int irq)
 {
-       unsigned long flags;
-       u64 cur_ints,hl_spacing;
+       unsigned long flags, hl_spacing;
+       u64 cur_ints;
 
        spin_lock_irqsave(&bcm1480_imr_lock, flags);
        hl_spacing = 0;
@@ -117,8 +117,8 @@ void bcm1480_mask_irq(int cpu, int irq)
 
 void bcm1480_unmask_irq(int cpu, int irq)
 {
-       unsigned long flags;
-       u64 cur_ints,hl_spacing;
+       unsigned long flags, hl_spacing;
+       u64 cur_ints;
 
        spin_lock_irqsave(&bcm1480_imr_lock, flags);
        hl_spacing = 0;
@@ -289,7 +289,7 @@ int bcm1480_steal_irq(int irq)
        if (irq >= BCM1480_NR_IRQS)
                return -EINVAL;
 
-       spin_lock_irqsave(&desc->lock,flags);
+       spin_lock_irqsave(&desc->lock, flags);
        /* Don't allow sharing at all for these */
        if (desc->action != NULL)
                retval = -EBUSY;
@@ -297,7 +297,7 @@ int bcm1480_steal_irq(int irq)
                desc->action = &bcm1480_dummy_action;
                desc->depth = 0;
        }
-       spin_unlock_irqrestore(&desc->lock,flags);
+       spin_unlock_irqrestore(&desc->lock, flags);
        return 0;
 }
 
@@ -404,7 +404,7 @@ void __init arch_init_irq(void)
        if (kgdb_flag) {
                kgdb_irq = K_BCM1480_INT_UART_0 + kgdb_port;
 
-#ifdef CONFIG_SIBYTE_SB1250_DUART
+#ifdef CONFIG_SERIAL_SB1250_DUART
                sb1250_duart_present[kgdb_port] = 0;
 #endif
                /* Setup uart 1 settings, mapper */
@@ -431,8 +431,8 @@ void __init arch_init_irq(void)
 
 #include <linux/delay.h>
 
-#define duart_out(reg, val)     csr_out32(val, IOADDR(A_DUART_CHANREG(kgdb_port,reg)))
-#define duart_in(reg)           csr_in32(IOADDR(A_DUART_CHANREG(kgdb_port,reg)))
+#define duart_out(reg, val)     csr_out32(val, IOADDR(A_DUART_CHANREG(kgdb_port, reg)))
+#define duart_in(reg)           csr_in32(IOADDR(A_DUART_CHANREG(kgdb_port, reg)))
 
 static void bcm1480_kgdb_interrupt(void)
 {
@@ -450,9 +450,45 @@ static void bcm1480_kgdb_interrupt(void)
 
 #endif         /* CONFIG_KGDB */
 
-extern void bcm1480_timer_interrupt(void);
 extern void bcm1480_mailbox_interrupt(void);
 
+static inline void dispatch_ip4(void)
+{
+       int cpu = smp_processor_id();
+       int irq = K_BCM1480_INT_TIMER_0 + cpu;
+
+       /* Reset the timer */
+       __raw_writeq(M_SCD_TIMER_ENABLE|M_SCD_TIMER_MODE_CONTINUOUS,
+                   IOADDR(A_SCD_TIMER_REGISTER(cpu, R_SCD_TIMER_CFG)));
+
+       do_IRQ(irq);
+}
+
+static inline void dispatch_ip2(void)
+{
+       unsigned long long mask_h, mask_l;
+       unsigned int cpu = smp_processor_id();
+       unsigned long base;
+
+       /*
+        * Default...we've hit an IP[2] interrupt, which means we've got to
+        * check the 1480 interrupt registers to figure out what to do.  Need
+        * to detect which CPU we're on, now that smp_affinity is supported.
+        */
+       base = A_BCM1480_IMR_MAPPER(cpu);
+       mask_h = __raw_readq(
+               IOADDR(base + R_BCM1480_IMR_INTERRUPT_STATUS_BASE_H));
+       mask_l = __raw_readq(
+               IOADDR(base + R_BCM1480_IMR_INTERRUPT_STATUS_BASE_L));
+
+       if (mask_h) {
+               if (mask_h ^ 1)
+                       do_IRQ(fls64(mask_h) - 1);
+               else if (mask_l)
+                       do_IRQ(63 + fls64(mask_l));
+       }
+}
+
 asmlinkage void plat_irq_dispatch(void)
 {
        unsigned int pending;
@@ -471,8 +507,7 @@ asmlinkage void plat_irq_dispatch(void)
 #endif
 
        if (pending & CAUSEF_IP4)
-               bcm1480_timer_interrupt();
-
+               dispatch_ip4();
 #ifdef CONFIG_SMP
        else if (pending & CAUSEF_IP3)
                bcm1480_mailbox_interrupt();
@@ -483,27 +518,6 @@ asmlinkage void plat_irq_dispatch(void)
                bcm1480_kgdb_interrupt();               /* KGDB (uart 1) */
 #endif
 
-       else if (pending & CAUSEF_IP2) {
-               unsigned long long mask_h, mask_l;
-               unsigned long base;
-
-               /*
-                * Default...we've hit an IP[2] interrupt, which means we've
-                * got to check the 1480 interrupt registers to figure out what
-                * to do.  Need to detect which CPU we're on, now that
-                * smp_affinity is supported.
-                */
-               base = A_BCM1480_IMR_MAPPER(smp_processor_id());
-               mask_h = __raw_readq(
-                       IOADDR(base + R_BCM1480_IMR_INTERRUPT_STATUS_BASE_H));
-               mask_l = __raw_readq(
-                       IOADDR(base + R_BCM1480_IMR_INTERRUPT_STATUS_BASE_L));
-
-               if (mask_h) {
-                       if (mask_h ^ 1)
-                               do_IRQ(fls64(mask_h) - 1);
-                       else
-                               do_IRQ(63 + fls64(mask_l));
-               }
-       }
+       else if (pending & CAUSEF_IP2)
+               dispatch_ip2();
 }