move pci_irq_map definitions into the board specific files
authorGabor Juhos <juhosg@openwrt.org>
Mon, 24 Sep 2007 16:59:23 +0000 (16:59 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Mon, 24 Sep 2007 16:59:23 +0000 (16:59 +0000)
SVN-Revision: 9009

12 files changed:
target/linux/adm5120/files/arch/mips/adm5120/board.c
target/linux/adm5120/files/arch/mips/adm5120/boards/cellvision.c
target/linux/adm5120/files/arch/mips/adm5120/boards/compex.c
target/linux/adm5120/files/arch/mips/adm5120/boards/edimax.c
target/linux/adm5120/files/arch/mips/adm5120/boards/generic.c
target/linux/adm5120/files/arch/mips/adm5120/boards/infineon.c
target/linux/adm5120/files/arch/mips/adm5120/boards/mikrotik.c
target/linux/adm5120/files/arch/mips/adm5120/boards/zyxel.c
target/linux/adm5120/files/arch/mips/adm5120/platform.c
target/linux/adm5120/files/arch/mips/pci/pci-adm5120.c
target/linux/adm5120/files/include/asm-mips/mach-adm5120/adm5120_board.h
target/linux/adm5120/files/include/asm-mips/mach-adm5120/adm5120_platform.h

index 376a11966c14b0b3bb020678d4d3681ef5b4ff61..e124d7b5f12fa1ebe884e811fc7d0f15217318a8 100644 (file)
@@ -96,9 +96,8 @@ static int __init adm5120_board_setup(void)
        amba_device_register(&adm5120_uart0_device, &iomem_resource);
        amba_device_register(&adm5120_uart1_device, &iomem_resource);
 
-       /* register PCI controller */
-       if (adm5120_package_bga())
-               platform_device_register(&adm5120_pci_device);
+       /* setup PCI irq map */
+       adm5120_pci_set_irq_map(board->pci_nr_irqs, board->pci_irq_map);
 
        /* register board devices */
        if (board->num_devices > 0 && board->devices != NULL ) {
@@ -109,6 +108,7 @@ static int __init adm5120_board_setup(void)
 
        return 0;
 }
+postcore_initcall(adm5120_board_setup);
 
 void __init adm5120_board_register(struct adm5120_board *board)
 {
@@ -125,4 +125,3 @@ void __init adm5120_register_boards(struct adm5120_board **boards,
                adm5120_board_register(boards[i]);
 }
 
-arch_initcall(adm5120_board_setup);
index f7d44e25749dc3a89e8727499baf4b911f3d4302..d4baee05e3f1556bb58ea57555baa695eaf30138 100644 (file)
@@ -29,8 +29,9 @@
 #include <asm/bootinfo.h>
 #include <asm/gpio.h>
 
-#include <asm/mach-adm5120/adm5120_board.h>
-#include <asm/mach-adm5120/adm5120_platform.h>
+#include <adm5120_board.h>
+#include <adm5120_platform.h>
+#include <adm5120_irq.h>
 
 static void switch_bank_gpio5(unsigned bank)
 {
@@ -44,6 +45,12 @@ static void switch_bank_gpio5(unsigned bank)
        }
 }
 
+static struct adm5120_pci_irq cas771_pci_irqs[] __initdata = {
+       PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
+       PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI1),
+       PCIIRQ(3, 2, 3, ADM5120_IRQ_PCI2)
+};
+
 static struct mtd_partition cas6xx_partitions[] = {
        {
                .name   = "admboot",
@@ -158,6 +165,8 @@ static struct adm5120_board cas771_board __initdata = {
        .eth_num_ports  = 1,
        .num_devices    = ARRAY_SIZE(cas7xx_devices),
        .devices        = cas7xx_devices,
+       .pci_nr_irqs    = ARRAY_SIZE(cas771_pci_irqs),
+       .pci_irq_map    = cas771_pci_irqs,
 };
 
 static struct adm5120_board cas790_board __initdata = {
index 893baf46313a967e02922979a95b6ad79b113d1f..bcc4ee71defded653f43e54fd4e15ddbe2d30917 100644 (file)
@@ -29,8 +29,9 @@
 #include <asm/bootinfo.h>
 #include <asm/gpio.h>
 
-#include <asm/mach-adm5120/adm5120_board.h>
-#include <asm/mach-adm5120/adm5120_platform.h>
+#include <adm5120_board.h>
+#include <adm5120_platform.h>
+#include <adm5120_irq.h>
 
 static void switch_bank_gpio5(unsigned bank)
 {
@@ -49,6 +50,17 @@ static void wp54_reset(void)
        gpio_set_value(ADM5120_GPIO_PIN3, 0);
 }
 
+static struct adm5120_pci_irq wp54_pci_irqs[] __initdata = {
+       PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
+};
+
+static struct adm5120_pci_irq np28g_pci_irqs[] __initdata = {
+       PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
+       PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI0),
+       PCIIRQ(3, 1, 2, ADM5120_IRQ_PCI1),
+       PCIIRQ(3, 2, 3, ADM5120_IRQ_PCI2)
+};
+
 static struct mtd_partition wp54g_wrt_partitions[] = {
        {
                .name   = "cfe",
@@ -148,6 +160,8 @@ static struct adm5120_board np28g_board __initdata = {
        .eth_vlans      = np28g_vlans,
        .num_devices    = ARRAY_SIZE(np2xg_devices),
        .devices        = np2xg_devices,
+       .pci_nr_irqs    = ARRAY_SIZE(np28g_pci_irqs),
+       .pci_irq_map    = np28g_pci_irqs,
 };
 
 static struct adm5120_board wp54ag_board __initdata = {
@@ -159,6 +173,8 @@ static struct adm5120_board wp54ag_board __initdata = {
        .eth_vlans      = wp54_vlans,
        .num_devices    = ARRAY_SIZE(wp54_devices),
        .devices        = wp54_devices,
+       .pci_nr_irqs    = ARRAY_SIZE(wp54_pci_irqs),
+       .pci_irq_map    = wp54_pci_irqs,
 };
 
 static struct adm5120_board wp54g_board __initdata = {
@@ -170,6 +186,8 @@ static struct adm5120_board wp54g_board __initdata = {
        .eth_vlans      = wp54_vlans,
        .num_devices    = ARRAY_SIZE(wp54_devices),
        .devices        = wp54_devices,
+       .pci_nr_irqs    = ARRAY_SIZE(wp54_pci_irqs),
+       .pci_irq_map    = wp54_pci_irqs,
 };
 
 static struct adm5120_board wp54g_wrt_board __initdata = {
@@ -181,6 +199,8 @@ static struct adm5120_board wp54g_wrt_board __initdata = {
        .eth_vlans      = wp54_vlans,
        .num_devices    = ARRAY_SIZE(wp54_devices),
        .devices        = wp54_devices,
+       .pci_nr_irqs    = ARRAY_SIZE(wp54_pci_irqs),
+       .pci_irq_map    = wp54_pci_irqs,
 };
 
 static struct adm5120_board wpp54ag_board __initdata = {
@@ -192,6 +212,8 @@ static struct adm5120_board wpp54ag_board __initdata = {
        .eth_vlans      = wp54_vlans,
        .num_devices    = ARRAY_SIZE(wp54_devices),
        .devices        = wp54_devices,
+       .pci_nr_irqs    = ARRAY_SIZE(wp54_pci_irqs),
+       .pci_irq_map    = wp54_pci_irqs,
 };
 
 static struct adm5120_board wpp54g_board __initdata = {
@@ -203,6 +225,8 @@ static struct adm5120_board wpp54g_board __initdata = {
        .eth_vlans      = wp54_vlans,
        .num_devices    = ARRAY_SIZE(wp54_devices),
        .devices        = wp54_devices,
+       .pci_nr_irqs    = ARRAY_SIZE(wp54_pci_irqs),
+       .pci_irq_map    = wp54_pci_irqs,
 };
 
 static int __init register_boards(void)
index d4b1b7442ea34930b6b47eb59919132a0e982622..6b7e7e696a7b3e1ab1377772c3c727020991b28f 100644 (file)
@@ -29,8 +29,8 @@
 #include <asm/bootinfo.h>
 #include <asm/gpio.h>
 
-#include <asm/mach-adm5120/adm5120_board.h>
-#include <asm/mach-adm5120/adm5120_platform.h>
+#include <adm5120_board.h>
+#include <adm5120_platform.h>
 
 static struct mtd_partition br6104k_partitions[] = {
        {
index 044490e50252e68d8907a34d89913257eb978224..735dda34a55b8467432e839c8f3e37aae6623f90 100644 (file)
@@ -29,8 +29,8 @@
 #include <asm/bootinfo.h>
 #include <asm/gpio.h>
 
-#include <asm/mach-adm5120/adm5120_board.h>
-#include <asm/mach-adm5120/adm5120_platform.h>
+#include <adm5120_board.h>
+#include <adm5120_platform.h>
 
 static struct platform_device *generic_devices[] __initdata = {
        &adm5120_flash0_device,
index f0c682bcbcf7a214ce6fc1713d92c6e9a0e15418..c927f003072653ac751fb4cc75738099d9212044 100644 (file)
@@ -29,8 +29,8 @@
 #include <asm/bootinfo.h>
 #include <asm/gpio.h>
 
-#include <asm/mach-adm5120/adm5120_board.h>
-#include <asm/mach-adm5120/adm5120_platform.h>
+#include <adm5120_board.h>
+#include <adm5120_platform.h>
 
 static void switch_bank_gpio3(unsigned bank)
 {
index 570ffb0cec4fe389c33ed540257b3ea4c4a4f371..88cccd5be67523b677e018374ff767766420677f 100644 (file)
 #include <asm/bootinfo.h>
 #include <asm/gpio.h>
 
-#include <asm/mach-adm5120/adm5120_board.h>
-#include <asm/mach-adm5120/adm5120_platform.h>
+#include <adm5120_board.h>
+#include <adm5120_platform.h>
+#include <adm5120_irq.h>
+
+static struct adm5120_pci_irq rb1xx_pci_irqs[] __initdata = {
+       PCIIRQ(1, 0, 1, ADM5120_IRQ_PCI0),
+       PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI1),
+       PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI2)
+};
 
 static struct mtd_partition rb1xx_partitions[] = {
        {
@@ -111,6 +118,8 @@ static struct adm5120_board rb111_board __initdata = {
        .eth_vlans      = rb11x_vlans,
        .num_devices    = ARRAY_SIZE(rb1xx_devices),
        .devices        = rb1xx_devices,
+       .pci_nr_irqs    = ARRAY_SIZE(rb1xx_pci_irqs),
+       .pci_irq_map    = rb1xx_pci_irqs,
 };
 
 static struct adm5120_board rb112_board __initdata = {
@@ -121,6 +130,8 @@ static struct adm5120_board rb112_board __initdata = {
        .eth_vlans      = rb11x_vlans,
        .num_devices    = ARRAY_SIZE(rb1xx_devices),
        .devices        = rb1xx_devices,
+       .pci_nr_irqs    = ARRAY_SIZE(rb1xx_pci_irqs),
+       .pci_irq_map    = rb1xx_pci_irqs,
 };
 
 static struct adm5120_board rb133_board __initdata = {
@@ -141,6 +152,8 @@ static struct adm5120_board rb133c_board __initdata = {
        .eth_vlans      = rb133c_vlans,
        .num_devices    = ARRAY_SIZE(rb1xx_devices),
        .devices        = rb1xx_devices,
+       .pci_nr_irqs    = ARRAY_SIZE(rb1xx_pci_irqs),
+       .pci_irq_map    = rb1xx_pci_irqs,
 };
 
 static struct adm5120_board rb150_board __initdata = {
@@ -161,6 +174,8 @@ static struct adm5120_board rb153_board __initdata = {
        .eth_vlans      = rb15x_vlans,
        .num_devices    = ARRAY_SIZE(rb1xx_devices),
        .devices        = rb1xx_devices,
+       .pci_nr_irqs    = ARRAY_SIZE(rb1xx_pci_irqs),
+       .pci_irq_map    = rb1xx_pci_irqs,
 };
 
 static struct adm5120_board rb192_board __initdata = {
@@ -171,6 +186,8 @@ static struct adm5120_board rb192_board __initdata = {
        .eth_vlans      = rb192_vlans,
        .num_devices    = ARRAY_SIZE(rb1xx_devices),
        .devices        = rb1xx_devices,
+       .pci_nr_irqs    = ARRAY_SIZE(rb1xx_pci_irqs),
+       .pci_irq_map    = rb1xx_pci_irqs,
 };
 
 static int __init register_boards(void)
index f6c3183dfa424bc07f2d3c747652cf7cc11e85da..0e766a85683d0a0a8df4cd348b1631823586f90f 100644 (file)
@@ -29,8 +29,9 @@
 #include <asm/bootinfo.h>
 #include <asm/gpio.h>
 
-#include <asm/mach-adm5120/adm5120_board.h>
-#include <asm/mach-adm5120/adm5120_platform.h>
+#include <adm5120_board.h>
+#include <adm5120_platform.h>
+#include <adm5120_irq.h>
 
 static void switch_bank_gpio5(unsigned bank)
 {
@@ -44,6 +45,10 @@ static void switch_bank_gpio5(unsigned bank)
        }
 }
 
+static struct adm5120_pci_irq p33x_pci_irqs[] __initdata = {
+       PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
+};
+
 static struct mtd_partition p33x_partitions[] = {
        {
                .name   = "bootbase",
@@ -105,6 +110,8 @@ static struct adm5120_board p334wt_board __initdata = {
        .eth_vlans      = p33x_vlans,
        .num_devices    = ARRAY_SIZE(p334_devices),
        .devices        = p334_devices,
+       .pci_nr_irqs    = ARRAY_SIZE(p33x_pci_irqs),
+       .pci_irq_map    = p33x_pci_irqs,
 };
 
 static struct adm5120_board p335_board __initdata = {
@@ -115,6 +122,8 @@ static struct adm5120_board p335_board __initdata = {
        .eth_vlans      = p33x_vlans,
        .num_devices    = ARRAY_SIZE(p335_devices),
        .devices        = p335_devices,
+       .pci_nr_irqs    = ARRAY_SIZE(p33x_pci_irqs),
+       .pci_irq_map    = p33x_pci_irqs,
 };
 
 static int __init register_boards(void)
index e4353a00a71e30cf588f9f3ec6e827299e37c625..2a795c950ee97649074da3d93390e0c979cec62a 100644 (file)
@@ -74,14 +74,6 @@ struct platform_device adm5120_switch_device = {
 };
 #endif
 
-/* PCI Host Controller */
-struct adm5120_pci_platform_data adm5120_pci_data;
-struct platform_device adm5120_pci_device = {
-       .name   = "adm5120-pci",
-       .id     = -1,
-       .dev.platform_data = &adm5120_pci_data,
-};
-
 /* USB Host Controller */
 struct resource adm5120_hcd_resources[] = {
        [0] = {
index 005b8dfab1cffc3c735663c918f1ad897ba8282e..01132343988fb56319aa2d28496bcbdbbca7dd23 100644 (file)
@@ -40,7 +40,7 @@
 #include <adm5120_defs.h>
 #include <adm5120_info.h>
 #include <adm5120_defs.h>
-#include <adm5120_irq.h>
+#include <adm5120_platform.h>
 
 #undef DEBUG
 
 
 #define PCI_ENABLE 0x80000000
 
+/* -------------------------------------------------------------------------*/
+
+static unsigned int adm5120_pci_nr_irqs __initdata = 0;
+static struct adm5120_pci_irq *adm5120_pci_irq_map __initdata = NULL;
+
 static spinlock_t pci_lock = SPIN_LOCK_UNLOCKED;
 
 /* -------------------------------------------------------------------------*/
@@ -187,99 +192,34 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ADMTEK, PCI_DEVICE_ID_ADMTEK_ADM5120,
 
 /* -------------------------------------------------------------------------*/
 
-struct adm5120_pci_irq {
-       u8      slot;
-       u8      func;
-       u8      pin;
-       unsigned irq;
-};
-
-#define PCIIRQ(s,f,p,i) {      \
-       .slot = (s),            \
-       .func = (f),            \
-       .pin  = (p),            \
-       .irq  = (i)             \
-       }
-
-static struct adm5120_pci_irq default_pci_irqs[] __initdata = {
-       PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
-};
-
-static struct adm5120_pci_irq rb1xx_pci_irqs[] __initdata = {
-       PCIIRQ(1, 0, 1, ADM5120_IRQ_PCI0),
-       PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI1),
-       PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI2)
-};
-
-static struct adm5120_pci_irq cas771_pci_irqs[] __initdata = {
-       PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
-       PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI1),
-       PCIIRQ(3, 2, 3, ADM5120_IRQ_PCI2)
-};
-
-static struct adm5120_pci_irq np28g_pci_irqs[] __initdata = {
-       PCIIRQ(2, 0, 1, ADM5120_IRQ_PCI0),
-       PCIIRQ(3, 0, 1, ADM5120_IRQ_PCI0),
-       PCIIRQ(3, 1, 2, ADM5120_IRQ_PCI1),
-       PCIIRQ(3, 2, 3, ADM5120_IRQ_PCI2)
-};
-
-#define GETMAP(n) do {                                 \
-               nr_irqs = ARRAY_SIZE(n ## _pci_irqs);   \
-               p = n ## _pci_irqs;                     \
-       } while (0)
+void __init adm5120_pci_set_irq_map(unsigned int nr_irqs,
+               struct adm5120_pci_irq *map)
+{
+       adm5120_pci_nr_irqs = nr_irqs;
+       adm5120_pci_irq_map = map;
+}
 
 int __init pcibios_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
 {
-       struct adm5120_pci_irq  *p;
-       int nr_irqs;
+       int irq = -1;
        int i;
-       int irq;
 
-       irq = -1;
+       if ((!adm5120_pci_nr_irqs) || (!adm5120_pci_irq_map)) {
+               printk(KERN_ALERT "PCI: pci_irq_map is not initialized\n");
+               goto out;
+       }
+
        if (slot < 1 || slot > 3) {
                printk(KERN_ALERT "PCI: slot number %u is not supported\n",
                        slot);
                goto out;
        }
 
-       GETMAP(default);
-
-       switch (mips_machtype) {
-       case MACH_ADM5120_RB_111:
-       case MACH_ADM5120_RB_112:
-       case MACH_ADM5120_RB_133:
-       case MACH_ADM5120_RB_133C:
-       case MACH_ADM5120_RB_153:
-               GETMAP(rb1xx);
-               break;
-       case MACH_ADM5120_NP28G:
-               GETMAP(np28g);
-               break;
-       case MACH_ADM5120_P335:
-       case MACH_ADM5120_P334WT:
-               /* using default mapping */
-               break;
-       case MACH_ADM5120_CAS771:
-               GETMAP(cas771);
-               break;
-
-       case MACH_ADM5120_NP27G:
-       case MACH_ADM5120_NP28GHS:
-       case MACH_ADM5120_WP54AG:
-       case MACH_ADM5120_WP54G:
-       case MACH_ADM5120_WP54G_WRT:
-       case MACH_ADM5120_WPP54AG:
-       case MACH_ADM5120_WPP54G:
-       default:
-               printk(KERN_ALERT "PCI: irq map is unknown, using defaults.\n");
-               break;
-       }
-
-       for (i = 0; i < nr_irqs; i++, p++) {
-               if ((p->slot == slot) && (PCI_FUNC(dev->devfn) == p->func) &&
-                   (p->pin == pin)) {
-                       irq = p->irq;
+       for (i = 0; i < adm5120_pci_nr_irqs; i++) {
+               if ((adm5120_pci_irq_map[i].slot == slot)
+                       && (adm5120_pci_irq_map[i].func == PCI_FUNC(dev->devfn))
+                       && (adm5120_pci_irq_map[i].pin == pin)) {
+                       irq = adm5120_pci_irq_map[i].irq;
                        break;
                }
        }
index 23f62a2932b8607af9c847d2837595f9b78fd25c..d6ac096037d7d4805a3c5822561454dd1f6b0e57 100644 (file)
@@ -41,6 +41,8 @@ struct adm5120_board {
        unsigned char           *eth_vlans;
        unsigned int            num_devices;
        struct platform_device  **devices;
+       unsigned int            pci_nr_irqs;
+       struct adm5120_pci_irq  *pci_irq_map;
 
        struct list_head        list;
 };
index 863d988cbebed9b871326b948246e58530e2d92e..90c18ce5dfee4d9b213aaaef511584ad5077ef06 100644 (file)
@@ -59,10 +59,17 @@ struct adm5120_pci_irq {
        unsigned irq;
 };
 
-struct adm5120_pci_platform_data {
-       unsigned int    nr_irqs;
-       struct adm5120_pci_irq  *irqs;
-};
+#define PCIIRQ(s,f,p,i) {.slot = (s), .func = (f), .pin  = (p), .irq  = (i)}
+
+#ifdef CONFIG_PCI
+extern void adm5120_pci_set_irq_map(unsigned int nr_irqs,
+               struct adm5120_pci_irq *map) __init;
+#else
+static inline void adm5120_pci_set_irq_map(unsigned int nr_irqs,
+               struct adm5120_pci_irq *map)
+{
+}
+#endif
 
 extern struct adm5120_flash_platform_data adm5120_flash0_data;
 extern struct adm5120_flash_platform_data adm5120_flash1_data;