atheros: USB support
[openwrt.git] / target / linux / atheros / files / arch / mips / atheros / ar5315 / irq.c
index 750c905..581b1a4 100644 (file)
 #include <linux/kernel.h>
 #include <linux/reboot.h>
 #include <linux/interrupt.h>
+#include <linux/bitops.h>
 #include <asm/bootinfo.h>
 #include <asm/irq_cpu.h>
 #include <asm/io.h>
-#include "../ar531x.h"
+
+#include <ar531x.h>
+#include <gpio.h>
 
 static u32 gpiointmask = 0, gpiointval = 0;
 
@@ -37,7 +40,7 @@ static inline void ar5315_gpio_irq(void)
        if (!pend)
                return;
 
-       do_IRQ(AR531X_GPIO_IRQ_BASE + 31 - clz(pend));
+       do_IRQ(AR531X_GPIO_IRQ_BASE + fls(pend) - 1);
 }
 
 
@@ -57,6 +60,10 @@ asmlinkage void ar5315_irq_dispatch(void)
                do_IRQ(AR5315_IRQ_WLAN0_INTRS);
        else if (pending & CAUSEF_IP4)
                do_IRQ(AR5315_IRQ_ENET0_INTRS);
+#ifdef CONFIG_PCI
+       else if (pending & CAUSEF_IP5)
+               ar5315_pci_irq(AR5315_IRQ_LCBUS_PCI);
+#endif
        else if (pending & CAUSEF_IP2) {
                unsigned int ar531x_misc_intrs = sysRegRead(AR5315_ISR) & sysRegRead(AR5315_IMR);
 
@@ -78,6 +85,30 @@ asmlinkage void ar5315_irq_dispatch(void)
                do_IRQ(AR531X_IRQ_CPU_CLOCK);
 }
 
+#ifdef CONFIG_PCI
+static inline void pci_abort_irq(void)
+{
+       sysRegWrite(AR5315_PCI_INT_STATUS, AR5315_PCI_ABORT_INT);
+       (void)sysRegRead(AR5315_PCI_INT_STATUS); /* flush write to hardware */
+}
+
+static inline void pci_ack_irq(void)
+{
+       sysRegWrite(AR5315_PCI_INT_STATUS, AR5315_PCI_EXT_INT);
+       (void)sysRegRead(AR5315_PCI_INT_STATUS); /* flush write to hardware */
+}
+
+void ar5315_pci_irq(int irq)
+{
+       if (sysRegRead(AR5315_PCI_INT_STATUS) == AR5315_PCI_ABORT_INT)
+               pci_abort_irq();
+       else {
+               do_IRQ(irq);
+               pci_ack_irq();
+       }
+}
+#endif
+
 static void ar5315_gpio_intr_enable(unsigned int irq)
 {
        u32 gpio, mask;
@@ -87,7 +118,7 @@ static void ar5315_gpio_intr_enable(unsigned int irq)
 
        /* reconfigure GPIO line as input */
        sysRegMask(AR5315_GPIO_CR, AR5315_GPIO_CR_M(gpio), AR5315_GPIO_CR_I(gpio));
-       
+
        /* Enable interrupt with edge detection */
        sysRegMask(AR5315_GPIO_INT, AR5315_GPIO_INT_M | AR5315_GPIO_INT_LVL_M, gpio | AR5315_GPIO_INT_LVL(3));
 }
@@ -201,7 +232,7 @@ ar5315_misc_intr_disable(unsigned int irq)
           case AR531X_MISC_IRQ_SPI:
                 imr &= ~AR5315_ISR_SPI;
                 break;
-                
+
           case AR531X_MISC_IRQ_TIMER:
             imr &= (~AR5315_ISR_TIMER);
             break;
This page took 0.024359 seconds and 4 git commands to generate.