powerpc: Update currituck pci/usb fixup for new board revision
authorAlistair Popple <alistair@popple.id.au>
Thu, 9 May 2013 00:42:13 +0000 (10:42 +1000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Thu, 20 Jun 2013 06:55:13 +0000 (16:55 +1000)
The currituck board uses a different IRQ for the pci usb host
controller depending on the board revision. This patch adds support
for newer board revisions by retrieving the board revision from the
FPGA and mapping the appropriate IRQ.

Signed-off-by: Alistair Popple <alistair@popple.id.au>
Acked-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/boot/dts/currituck.dts
arch/powerpc/platforms/44x/currituck.c

index b801dd06e5733206a51469845a9b21a8a9f423de..d2c8a872308e64d29665b1f5aada5d533fd36c5c 100644 (file)
                                interrupts = <34 2>;
                        };
 
+                       FPGA0: fpga@50000000 {
+                               compatible = "ibm,currituck-fpga";
+                               reg = <0x50000000 0x4>;
+                       };
+
                        IIC0: i2c@00000000 {
                                compatible = "ibm,iic-currituck", "ibm,iic";
                                reg = <0x0 0x00000014>;
index ecd3890c40d72f11147a642fdb39c3389a6a7a38..c52e1b3c9be528f68cd0dd251b3fd6d29d2396b8 100644 (file)
@@ -176,13 +176,48 @@ static int __init ppc47x_probe(void)
        return 1;
 }
 
+static int board_rev = -1;
+static int __init ppc47x_get_board_rev(void)
+{
+       u8 fpga_reg0;
+       void *fpga;
+       struct device_node *np;
+
+       np = of_find_compatible_node(NULL, NULL, "ibm,currituck-fpga");
+       if (!np)
+               goto fail;
+
+       fpga = of_iomap(np, 0);
+       of_node_put(np);
+       if (!fpga)
+               goto fail;
+
+       fpga_reg0 = ioread8(fpga);
+       board_rev = fpga_reg0 & 0x03;
+       pr_info("%s: Found board revision %d\n", __func__, board_rev);
+       iounmap(fpga);
+       return 0;
+
+fail:
+       pr_info("%s: Unable to find board revision\n", __func__);
+       return 0;
+}
+machine_arch_initcall(ppc47x, ppc47x_get_board_rev);
+
 /* Use USB controller should have been hardware swizzled but it wasn't :( */
 static void ppc47x_pci_irq_fixup(struct pci_dev *dev)
 {
        if (dev->vendor == 0x1033 && (dev->device == 0x0035 ||
                                      dev->device == 0x00e0)) {
-               dev->irq = irq_create_mapping(NULL, 47);
-               pr_info("%s: Mapping irq 47 %d\n", __func__, dev->irq);
+               if (board_rev == 0) {
+                       dev->irq = irq_create_mapping(NULL, 47);
+                       pr_info("%s: Mapping irq %d\n", __func__, dev->irq);
+               } else if (board_rev == 2) {
+                       dev->irq = irq_create_mapping(NULL, 49);
+                       pr_info("%s: Mapping irq %d\n", __func__, dev->irq);
+               } else {
+                       pr_alert("%s: Unknown board revision\n", __func__);
+               }
        }
 }