USB: ehci-platform: Support ehci reset after resume quirk
[firefly-linux-kernel-4.4.55.git] / drivers / usb / host / ehci-platform.c
index 2f5b9ce3e042f7473b359740a73bf782090ba936..db5c29edf6dbaa067b73943b9b179925cf5fd9c8 100644 (file)
@@ -164,11 +164,6 @@ static int ehci_platform_probe(struct platform_device *dev)
                dev_err(&dev->dev, "no irq provided");
                return irq;
        }
-       res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
-       if (!res_mem) {
-               dev_err(&dev->dev, "no memory resource provided");
-               return -ENXIO;
-       }
 
        hcd = usb_create_hcd(&ehci_platform_hc_driver, &dev->dev,
                             dev_name(&dev->dev));
@@ -190,6 +185,10 @@ static int ehci_platform_probe(struct platform_device *dev)
                if (of_property_read_bool(dev->dev.of_node, "big-endian"))
                        ehci->big_endian_mmio = ehci->big_endian_desc = 1;
 
+               if (of_property_read_bool(dev->dev.of_node,
+                                         "needs-reset-on-resume"))
+                       pdata->reset_on_resume = 1;
+
                priv->phy = devm_phy_get(&dev->dev, "usb");
                if (IS_ERR(priv->phy)) {
                        err = PTR_ERR(priv->phy);
@@ -250,14 +249,15 @@ static int ehci_platform_probe(struct platform_device *dev)
                        goto err_reset;
        }
 
-       hcd->rsrc_start = res_mem->start;
-       hcd->rsrc_len = resource_size(res_mem);
-
+       res_mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
        hcd->regs = devm_ioremap_resource(&dev->dev, res_mem);
        if (IS_ERR(hcd->regs)) {
                err = PTR_ERR(hcd->regs);
                goto err_power;
        }
+       hcd->rsrc_start = res_mem->start;
+       hcd->rsrc_len = resource_size(res_mem);
+
        err = usb_add_hcd(hcd, irq, IRQF_SHARED);
        if (err)
                goto err_power;
@@ -311,8 +311,7 @@ static int ehci_platform_remove(struct platform_device *dev)
        return 0;
 }
 
-#ifdef CONFIG_PM
-
+#ifdef CONFIG_PM_SLEEP
 static int ehci_platform_suspend(struct device *dev)
 {
        struct usb_hcd *hcd = dev_get_drvdata(dev);
@@ -345,14 +344,10 @@ static int ehci_platform_resume(struct device *dev)
                        return err;
        }
 
-       ehci_resume(hcd, false);
+       ehci_resume(hcd, pdata->reset_on_resume);
        return 0;
 }
-
-#else /* !CONFIG_PM */
-#define ehci_platform_suspend  NULL
-#define ehci_platform_resume   NULL
-#endif /* CONFIG_PM */
+#endif /* CONFIG_PM_SLEEP */
 
 static const struct of_device_id vt8500_ehci_ids[] = {
        { .compatible = "via,vt8500-ehci", },
@@ -368,10 +363,8 @@ static const struct platform_device_id ehci_platform_table[] = {
 };
 MODULE_DEVICE_TABLE(platform, ehci_platform_table);
 
-static const struct dev_pm_ops ehci_platform_pm_ops = {
-       .suspend        = ehci_platform_suspend,
-       .resume         = ehci_platform_resume,
-};
+static SIMPLE_DEV_PM_OPS(ehci_platform_pm_ops, ehci_platform_suspend,
+       ehci_platform_resume);
 
 static struct platform_driver ehci_platform_driver = {
        .id_table       = ehci_platform_table,
@@ -379,7 +372,6 @@ static struct platform_driver ehci_platform_driver = {
        .remove         = ehci_platform_remove,
        .shutdown       = usb_hcd_platform_shutdown,
        .driver         = {
-               .owner  = THIS_MODULE,
                .name   = "ehci-platform",
                .pm     = &ehci_platform_pm_ops,
                .of_match_table = vt8500_ehci_ids,