usb: dwc_otg_310: fix usb vbus power controlled by pmic
[firefly-linux-kernel-4.4.55.git] / drivers / usb / dwc3 / host.c
index b973138c7a819dd3c4afdbb36cda1f6cf388247b..489ab425e177a431ada294c2e47d85f78ed83f3d 100644 (file)
@@ -24,7 +24,48 @@ int dwc3_host_init(struct dwc3 *dwc)
 {
        struct platform_device  *xhci;
        struct usb_xhci_pdata   pdata;
-       int                     ret;
+       int                     ret, irq;
+       struct resource         *res;
+       struct platform_device  *dwc3_pdev = to_platform_device(dwc->dev);
+
+       irq = platform_get_irq_byname(dwc3_pdev, "host");
+       if (irq == -EPROBE_DEFER)
+               return irq;
+
+       if (irq <= 0) {
+               irq = platform_get_irq_byname(dwc3_pdev, "dwc_usb3");
+               if (irq == -EPROBE_DEFER)
+                       return irq;
+
+               if (irq <= 0) {
+                       irq = platform_get_irq(dwc3_pdev, 0);
+                       if (irq <= 0) {
+                               if (irq != -EPROBE_DEFER) {
+                                       dev_err(dwc->dev,
+                                               "missing host IRQ\n");
+                               }
+                               if (!irq)
+                                       irq = -EINVAL;
+                               return irq;
+                       } else {
+                               res = platform_get_resource(dwc3_pdev,
+                                                           IORESOURCE_IRQ, 0);
+                       }
+               } else {
+                       res = platform_get_resource_byname(dwc3_pdev,
+                                                          IORESOURCE_IRQ,
+                                                          "dwc_usb3");
+               }
+
+       } else {
+               res = platform_get_resource_byname(dwc3_pdev, IORESOURCE_IRQ,
+                                                  "host");
+       }
+
+       dwc->xhci_resources[1].start = irq;
+       dwc->xhci_resources[1].end = irq;
+       dwc->xhci_resources[1].flags = res->flags;
+       dwc->xhci_resources[1].name = res->name;
 
        xhci = platform_device_alloc("xhci-hcd", PLATFORM_DEVID_AUTO);
        if (!xhci) {
@@ -50,8 +91,9 @@ int dwc3_host_init(struct dwc3 *dwc)
 
        memset(&pdata, 0, sizeof(pdata));
 
+       pdata.usb3_disable_autosuspend = dwc->dis_u3_autosuspend_quirk;
        pdata.usb3_lpm_capable = dwc->usb3_lpm_capable;
-       pdata.xhci_slow_suspend = dwc->xhci_slow_suspend_quirk;
+       pdata.xhci_slow_suspend = dwc->xhci_slow_suspend_quirk;
 
        ret = platform_device_add_data(xhci, &pdata, sizeof(pdata));
        if (ret) {