USB: isp1760: use a specific PLX bridge instead of any bdridge
[safe/jmp/linux-2.6] / drivers / usb / host / isp1760-if.c
index 73fb2a3..a53114c 100644 (file)
 #include "../core/hcd.h"
 #include "isp1760-hcd.h"
 
-#ifdef CONFIG_USB_ISP1760_OF
+#ifdef CONFIG_PPC_OF
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #endif
 
-#ifdef CONFIG_USB_ISP1760_PCI
+#ifdef CONFIG_PCI
 #include <linux/pci.h>
 #endif
 
-#ifdef CONFIG_USB_ISP1760_OF
+#ifdef CONFIG_PPC_OF
 static int of_isp1760_probe(struct of_device *dev,
                const struct of_device_id *match)
 {
@@ -35,13 +35,15 @@ static int of_isp1760_probe(struct of_device *dev,
        int virq;
        u64 res_len;
        int ret;
+       const unsigned int *prop;
+       unsigned int devflags = 0;
 
        ret = of_address_to_resource(dp, 0, &memory);
        if (ret)
                return -ENXIO;
 
        res = request_mem_region(memory.start, memory.end - memory.start + 1,
-                       dev->dev.bus_id);
+                       dev_name(&dev->dev));
        if (!res)
                return -EBUSY;
 
@@ -55,8 +57,32 @@ static int of_isp1760_probe(struct of_device *dev,
        virq = irq_create_of_mapping(oirq.controller, oirq.specifier,
                        oirq.size);
 
+       if (of_device_is_compatible(dp, "nxp,usb-isp1761"))
+               devflags |= ISP1760_FLAG_ISP1761;
+
+       if (of_get_property(dp, "port1-disable", NULL) != NULL)
+               devflags |= ISP1760_FLAG_PORT1_DIS;
+
+       /* Some systems wire up only 16 of the 32 data lines */
+       prop = of_get_property(dp, "bus-width", NULL);
+       if (prop && *prop == 16)
+               devflags |= ISP1760_FLAG_BUS_WIDTH_16;
+
+       if (of_get_property(dp, "port1-otg", NULL) != NULL)
+               devflags |= ISP1760_FLAG_OTG_EN;
+
+       if (of_get_property(dp, "analog-oc", NULL) != NULL)
+               devflags |= ISP1760_FLAG_ANALOG_OC;
+
+       if (of_get_property(dp, "dack-polarity", NULL) != NULL)
+               devflags |= ISP1760_FLAG_DACK_POL_HIGH;
+
+       if (of_get_property(dp, "dreq-polarity", NULL) != NULL)
+               devflags |= ISP1760_FLAG_DREQ_POL_HIGH;
+
        hcd = isp1760_register(memory.start, res_len, virq,
-               IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev->dev.bus_id);
+               IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev_name(&dev->dev),
+               devflags);
        if (IS_ERR(hcd)) {
                ret = PTR_ERR(hcd);
                goto release_reg;
@@ -87,6 +113,9 @@ static struct of_device_id of_isp1760_match[] = {
        {
                .compatible = "nxp,usb-isp1760",
        },
+       {
+               .compatible = "nxp,usb-isp1761",
+       },
        { },
 };
 MODULE_DEVICE_TABLE(of, of_isp1760_match);
@@ -99,13 +128,13 @@ static struct of_platform_driver isp1760_of_driver = {
 };
 #endif
 
-#ifdef CONFIG_USB_ISP1760_PCI
+#ifdef CONFIG_PCI
 static u32 nxp_pci_io_base;
 static u32 iolength;
 static u32 pci_mem_phy0;
 static u32 length;
-static u8 *chip_addr;
-static u8 *iobase;
+static u8 __iomem *chip_addr;
+static u8 __iomem *iobase;
 
 static int __devinit isp1761_pci_probe(struct pci_dev *dev,
                const struct pci_device_id *id)
@@ -116,6 +145,7 @@ static int __devinit isp1761_pci_probe(struct pci_dev *dev,
        int length;
        int status = 1;
        struct usb_hcd *hcd;
+       unsigned int devflags = 0;
 
        if (usb_disabled())
                return -ENODEV;
@@ -188,7 +218,7 @@ static int __devinit isp1761_pci_probe(struct pci_dev *dev,
         * and reading back and checking the contents are same or not
         */
        if (reg_data != 0xFACE) {
-               err("scratch register mismatch %x", reg_data);
+               dev_err(&dev->dev, "scratch register mismatch %x\n", reg_data);
                goto clean;
        }
 
@@ -200,10 +230,12 @@ static int __devinit isp1761_pci_probe(struct pci_dev *dev,
 
        dev->dev.dma_mask = NULL;
        hcd = isp1760_register(pci_mem_phy0, length, dev->irq,
-               IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev->dev.bus_id);
-       pci_set_drvdata(dev, hcd);
-       if (!hcd)
+               IRQF_SHARED | IRQF_DISABLED, &dev->dev, dev_name(&dev->dev),
+               devflags);
+       if (!IS_ERR(hcd)) {
+               pci_set_drvdata(dev, hcd);
                return 0;
+       }
 clean:
        status = -ENODEV;
        iounmap(iobase);
@@ -236,12 +268,16 @@ static void isp1761_pci_shutdown(struct pci_dev *dev)
        printk(KERN_ERR "ips1761_pci_shutdown\n");
 }
 
-static const struct pci_device_id isp1760_plx [] = { {
-       /* handle any USB 2.0 EHCI controller */
-       PCI_DEVICE_CLASS(((PCI_CLASS_BRIDGE_OTHER << 8) | (0x06 << 16)), ~0),
-               .driver_data = 0,
-},
-{ /* end: all zeroes */ }
+static const struct pci_device_id isp1760_plx [] = {
+       {
+               .class          = PCI_CLASS_BRIDGE_OTHER << 8,
+               .class_mask     = ~0,
+               .vendor         = PCI_VENDOR_ID_PLX,
+               .device         = 0x5406,
+               .subvendor      = PCI_VENDOR_ID_PLX,
+               .subdevice      = 0x9054,
+       },
+       { }
 };
 MODULE_DEVICE_TABLE(pci, isp1760_plx);
 
@@ -260,24 +296,24 @@ static int __init isp1760_init(void)
 
        init_kmem_once();
 
-#ifdef CONFIG_USB_ISP1760_OF
+#ifdef CONFIG_PPC_OF
        ret = of_register_platform_driver(&isp1760_of_driver);
        if (ret) {
                deinit_kmem_cache();
                return ret;
        }
 #endif
-#ifdef CONFIG_USB_ISP1760_PCI
+#ifdef CONFIG_PCI
        ret = pci_register_driver(&isp1761_pci_driver);
        if (ret)
                goto unreg_of;
 #endif
        return ret;
 
-#ifdef CONFIG_USB_ISP1760_PCI
+#ifdef CONFIG_PCI
 unreg_of:
 #endif
-#ifdef CONFIG_USB_ISP1760_OF
+#ifdef CONFIG_PPC_OF
        of_unregister_platform_driver(&isp1760_of_driver);
 #endif
        deinit_kmem_cache();
@@ -287,10 +323,10 @@ module_init(isp1760_init);
 
 static void __exit isp1760_exit(void)
 {
-#ifdef CONFIG_USB_ISP1760_OF
+#ifdef CONFIG_PPC_OF
        of_unregister_platform_driver(&isp1760_of_driver);
 #endif
-#ifdef CONFIG_USB_ISP1760_PCI
+#ifdef CONFIG_PCI
        pci_unregister_driver(&isp1761_pci_driver);
 #endif
        deinit_kmem_cache();