ar71xx: don't init PCI irqs on the AR7240 if the PCIe subsystem are in reset
[openwrt-10.03/.git] / target / linux / ar71xx / files / arch / mips / ar71xx / irq.c
index 8acc3344f649e9c1d6ea7e453b72fc76946672c5..13d25c43fd30fd024802df6cb77c5b7d606ef760 100644 (file)
@@ -21,6 +21,8 @@
 
 #include <asm/mach-ar71xx/ar71xx.h>
 
+static void (* ar71xx_ip2_irq_handler)(void) = spurious_interrupt;
+
 #ifdef CONFIG_PCI
 static void ar71xx_pci_irq_dispatch(void)
 {
@@ -81,6 +83,8 @@ static void __init ar71xx_pci_irq_init(void)
 {
        int i;
 
+       ar71xx_ip2_irq_handler = ar71xx_pci_irq_dispatch;
+
        ar71xx_reset_wr(AR71XX_RESET_REG_PCI_INT_ENABLE, 0);
        ar71xx_reset_wr(AR71XX_RESET_REG_PCI_INT_STATUS, 0);
 
@@ -154,8 +158,17 @@ static struct irqaction ar724x_pci_irqaction = {
 
 static void __init ar724x_pci_irq_init(void)
 {
+       u32 t;
        int i;
 
+       t = ar71xx_reset_rr(AR724X_RESET_REG_RESET_MODULE);
+       if (t & (AR724X_RESET_PCIE | AR724X_RESET_PCIE_PHY |
+                AR724X_RESET_PCIE_PHY_SERIAL)) {
+               return;
+       }
+
+       ar71xx_ip2_irq_handler = ar724x_pci_irq_dispatch;
+
        ar724x_pci_wr(AR724X_PCI_REG_INT_MASK, 0);
        ar724x_pci_wr(AR724X_PCI_REG_INT_STATUS, 0);
 
@@ -168,6 +181,9 @@ static void __init ar724x_pci_irq_init(void)
 
        setup_irq(AR71XX_CPU_IRQ_PCI, &ar724x_pci_irqaction);
 }
+#else
+static inline void ar71xx_pci_irq_init(void) {};
+static inline void ar724x_pci_irq_init(void) {};
 #endif /* CONFIG_PCI */
 
 static void ar71xx_gpio_irq_dispatch(void)
@@ -213,7 +229,7 @@ static int ar71xx_gpio_irq_set_type(unsigned int irq, unsigned int flow_type)
 #define ar71xx_gpio_irq_set_type       NULL
 #endif
 
-struct irq_chip ar71xx_gpio_irq_chip = {
+static struct irq_chip ar71xx_gpio_irq_chip = {
        .name           = "AR71XX GPIO",
        .unmask         = ar71xx_gpio_irq_unmask,
        .mask           = ar71xx_gpio_irq_mask,
@@ -307,11 +323,20 @@ static void ar71xx_misc_irq_mask(unsigned int irq)
        ar71xx_reset_rr(AR71XX_RESET_REG_MISC_INT_ENABLE);
 }
 
-struct irq_chip ar71xx_misc_irq_chip = {
+static void ar724x_misc_irq_ack(unsigned int irq)
+{
+       irq -= AR71XX_MISC_IRQ_BASE;
+       ar71xx_reset_wr(AR71XX_RESET_REG_MISC_INT_STATUS,
+               ar71xx_reset_rr(AR71XX_RESET_REG_MISC_INT_STATUS) & ~(1 << irq));
+
+       /* flush write */
+       ar71xx_reset_rr(AR71XX_RESET_REG_MISC_INT_STATUS);
+}
+
+static struct irq_chip ar71xx_misc_irq_chip = {
        .name           = "AR71XX MISC",
        .unmask         = ar71xx_misc_irq_unmask,
        .mask           = ar71xx_misc_irq_mask,
-       .mask_ack       = ar71xx_misc_irq_mask,
 };
 
 static struct irqaction ar71xx_misc_irqaction = {
@@ -326,6 +351,11 @@ static void __init ar71xx_misc_irq_init(void)
        ar71xx_reset_wr(AR71XX_RESET_REG_MISC_INT_ENABLE, 0);
        ar71xx_reset_wr(AR71XX_RESET_REG_MISC_INT_STATUS, 0);
 
+       if (ar71xx_soc == AR71XX_SOC_AR7240)
+               ar71xx_misc_irq_chip.ack = ar724x_misc_irq_ack;
+       else
+               ar71xx_misc_irq_chip.mask_ack = ar71xx_misc_irq_mask;
+
        for (i = AR71XX_MISC_IRQ_BASE;
             i < AR71XX_MISC_IRQ_BASE + AR71XX_MISC_IRQ_COUNT; i++) {
                irq_desc[i].status = IRQ_DISABLED;
@@ -341,8 +371,6 @@ static void ar913x_wmac_irq_dispatch(void)
        do_IRQ(AR71XX_CPU_IRQ_WMAC);
 }
 
-static void (* ar71xx_ip2_irq_handler)(void) = spurious_interrupt;
-
 asmlinkage void plat_irq_dispatch(void)
 {
        unsigned long pending;
@@ -381,15 +409,10 @@ void __init arch_init_irq(void)
        case AR71XX_SOC_AR7130:
        case AR71XX_SOC_AR7141:
        case AR71XX_SOC_AR7161:
-#ifdef CONFIG_PCI
                ar71xx_pci_irq_init();
-               ar71xx_ip2_irq_handler = ar71xx_pci_irq_dispatch;
-#endif
+               break;
        case AR71XX_SOC_AR7240:
-#ifdef CONFIG_PCI
                ar724x_pci_irq_init();
-               ar71xx_ip2_irq_handler = ar724x_pci_irq_dispatch;
-#endif
                break;
        case AR71XX_SOC_AR9130:
        case AR71XX_SOC_AR9132: