]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[ARM] Orion: fix ->map_irq() PCIe bus number check
authorLennert Buytenhek <buytenh@wantstofly.org>
Fri, 25 Apr 2008 20:28:33 +0000 (16:28 -0400)
committerNicolas Pitre <nico@cam.org>
Mon, 28 Apr 2008 19:58:23 +0000 (15:58 -0400)
The current orion5x board ->map_irq() routines check whether a
given bus number lives on the PCIe controller by comparing it with
the PCIe controller's primary bus number.  This doesn't work in
case there are multiple buses in the PCIe domain, i.e. if there
exists a PCIe bridge on the primary PCIe bus.

This patch adds a helper function (orion5x_pci_map_irq()) that
returns the IRQ number for the given PCI device if that device has
a hard-wired IRQ, or -1 otherwise, and makes each board's
->map_irq() function use this helper function.

Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
Signed-off-by: Nicolas Pitre <nico@marvell.com>
arch/arm/mach-orion5x/common.h
arch/arm/mach-orion5x/db88f5281-setup.c
arch/arm/mach-orion5x/dns323-setup.c
arch/arm/mach-orion5x/kurobox_pro-setup.c
arch/arm/mach-orion5x/pci.c
arch/arm/mach-orion5x/rd88f5182-setup.c
arch/arm/mach-orion5x/ts209-setup.c

index f4c4c9a72a7c772ba26eb6091b553fff548d661e..14adf8d1a54ac8d96f33e23a8a92b98369faab72 100644 (file)
@@ -33,10 +33,9 @@ struct pci_sys_data;
 struct pci_bus;
 
 void orion5x_pcie_id(u32 *dev, u32 *rev);
-int orion5x_pcie_local_bus_nr(void);
-int orion5x_pci_local_bus_nr(void);
 int orion5x_pci_sys_setup(int nr, struct pci_sys_data *sys);
 struct pci_bus *orion5x_pci_sys_scan_bus(int nr, struct pci_sys_data *sys);
+int orion5x_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin);
 
 /*
  * Valid GPIO pins according to MPP setup, used by machine-setup.
index 872aed372327de33c6aa481bf74f753b20328ba1..83e9ad4cf1907fadc0f2beafd74504c29b44045d 100644 (file)
@@ -241,14 +241,17 @@ void __init db88f5281_pci_preinit(void)
 
 static int __init db88f5281_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
+       int irq;
+
        /*
-        * PCIE IRQ is connected internally (not GPIO)
+        * Check for devices with hard-wired IRQs.
         */
-       if (dev->bus->number == orion5x_pcie_local_bus_nr())
-               return IRQ_ORION5X_PCIE0_INT;
+       irq = orion5x_pci_map_irq(dev, slot, pin);
+       if (irq != -1)
+               return irq;
 
        /*
-        * PCI IRQs are connected via GPIOs
+        * PCI IRQs are connected via GPIOs.
         */
        switch (slot - DB88F5281_PCI_SLOT0_OFFS) {
        case 0:
index d67790ef236e13863c20c53b8b24412a0555c2dd..46181737fb75e1bf2825b876c33a537578d34dd5 100644 (file)
 
 static int __init dns323_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
-       /* PCI-E */
-       if (dev->bus->number == orion5x_pcie_local_bus_nr())
-               return IRQ_ORION5X_PCIE0_INT;
+       int irq;
 
-       pr_err("%s: requested mapping for unknown bus\n", __func__);
+       /*
+        * Check for devices with hard-wired IRQs.
+        */
+       irq = orion5x_pci_map_irq(dev, slot, pin);
+       if (irq != -1)
+               return irq;
+
+       pr_err("%s: requested mapping for unknown device\n", __func__);
 
        return -1;
 }
index 91413455beba0ca35f3f22d3ddad4b5d3b6f31ac..36cf763886931e27a9ee160635063c7ad3ff0cf8 100644 (file)
@@ -120,13 +120,19 @@ static struct platform_device kurobox_pro_nor_flash = {
 
 static int __init kurobox_pro_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
+       int irq;
+
+       /*
+        * Check for devices with hard-wired IRQs.
+        */
+       irq = orion5x_pci_map_irq(dev, slot, pin);
+       if (irq != -1)
+               return irq;
+
        /*
         * PCI isn't used on the Kuro
         */
-       if (dev->bus->number == orion5x_pcie_local_bus_nr())
-               return IRQ_ORION5X_PCIE0_INT;
-       else
-               printk(KERN_ERR "kurobox_pro_pci_map_irq failed, unknown bus\n");
+       printk(KERN_ERR "kurobox_pro_pci_map_irq failed, unknown bus\n");
 
        return -1;
 }
index fdf99fca85b30081e1d9b5bede09ac0bd5d32d71..9d5d39fa19c36f7490ef3ad0700f2a133b4b8ccb 100644 (file)
@@ -41,11 +41,6 @@ void __init orion5x_pcie_id(u32 *dev, u32 *rev)
        *rev = orion_pcie_rev(PCIE_BASE);
 }
 
-int __init orion5x_pcie_local_bus_nr(void)
-{
-       return orion_pcie_get_local_bus_nr(PCIE_BASE);
-}
-
 static int pcie_valid_config(int bus, int dev)
 {
        /*
@@ -269,7 +264,7 @@ static int __init pcie_setup(struct pci_sys_data *sys)
  */
 static DEFINE_SPINLOCK(orion5x_pci_lock);
 
-int orion5x_pci_local_bus_nr(void)
+static int orion5x_pci_local_bus_nr(void)
 {
        u32 conf = orion5x_read(PCI_P2P_CONF);
        return((conf & PCI_P2P_BUS_MASK) >> PCI_P2P_BUS_OFFS);
@@ -557,3 +552,16 @@ struct pci_bus __init *orion5x_pci_sys_scan_bus(int nr, struct pci_sys_data *sys
 
        return bus;
 }
+
+int __init orion5x_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
+{
+       int bus = dev->bus->number;
+
+       /*
+        * PCIe endpoint?
+        */
+       if (bus < orion5x_pci_local_bus_nr())
+               return IRQ_ORION5X_PCIE0_INT;
+
+       return -1;
+}
index 37e8b2dc3ed57eaef7e601464adaad03ec6ea10d..b4315dfd4a354930ae997e4958d1ca3b4a7d8300 100644 (file)
@@ -172,11 +172,14 @@ void __init rd88f5182_pci_preinit(void)
 
 static int __init rd88f5182_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
+       int irq;
+
        /*
-        * PCI-E isn't used on the RD2
+        * Check for devices with hard-wired IRQs.
         */
-       if (dev->bus->number == orion5x_pcie_local_bus_nr())
-               return IRQ_ORION5X_PCIE0_INT;
+       irq = orion5x_pci_map_irq(dev, slot, pin);
+       if (irq != -1)
+               return irq;
 
        /*
         * PCI IRQs are connected via GPIOs
index fd43863a86f6dbc0479bb22264db087a12c4ba42..d3a892283dd0f11d740f394aa8f269a5e073dd89 100644 (file)
@@ -141,14 +141,17 @@ void __init qnap_ts209_pci_preinit(void)
 
 static int __init qnap_ts209_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
+       int irq;
+
        /*
-        * PCIE IRQ is connected internally (not GPIO)
+        * Check for devices with hard-wired IRQs.
         */
-       if (dev->bus->number == orion5x_pcie_local_bus_nr())
-               return IRQ_ORION5X_PCIE0_INT;
+       irq = orion5x_pci_map_irq(dev, slot, pin);
+       if (irq != -1)
+               return irq;
 
        /*
-        * PCI IRQs are connected via GPIOs
+        * PCI IRQs are connected via GPIOs.
         */
        switch (slot - QNAP_TS209_PCI_SLOT0_OFFS) {
        case 0: