usb: dwc3: add dis_u3_autosuspend_quirk
[firefly-linux-kernel-4.4.55.git] / drivers / usb / dwc3 / core.c
index 9840df83fe6102fdbb2cffa4df0e793129324669..db5f8e056d293c30cf73f5b20f3885e1b8ff7953 100644 (file)
@@ -448,6 +448,9 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
        if (dwc->dis_u3_susphy_quirk)
                reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
 
+       if (dwc->dis_del_phy_power_chg_quirk)
+               reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE;
+
        dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
 
        reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
@@ -686,6 +689,18 @@ static int dwc3_core_init(struct dwc3 *dwc)
                goto err4;
        }
 
+       switch (dwc->dr_mode) {
+       case USB_DR_MODE_PERIPHERAL:
+               dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
+               break;
+       case USB_DR_MODE_HOST:
+               dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_HOST);
+               break;
+       default:
+               dev_dbg(dwc->dev, "Unsupported mode %d\n", dwc->dr_mode);
+               break;
+       }
+
        return 0;
 
 err4:
@@ -952,6 +967,8 @@ static int dwc3_probe(struct platform_device *pdev)
                                "snps,lfps_filter_quirk");
        dwc->rx_detect_poll_quirk = device_property_read_bool(dev,
                                "snps,rx_detect_poll_quirk");
+       dwc->dis_u3_autosuspend_quirk = device_property_read_bool(dev,
+                               "snps,dis-u3-autosuspend-quirk");
        dwc->dis_u3_susphy_quirk = device_property_read_bool(dev,
                                "snps,dis_u3_susphy_quirk");
        dwc->dis_u2_susphy_quirk = device_property_read_bool(dev,
@@ -962,6 +979,10 @@ static int dwc3_probe(struct platform_device *pdev)
                                "snps,dis_rxdet_inp3_quirk");
        dwc->dis_u2_freeclk_exists_quirk = device_property_read_bool(dev,
                                "snps,dis-u2-freeclk-exists-quirk");
+       dwc->dis_del_phy_power_chg_quirk = device_property_read_bool(dev,
+                               "snps,dis-del-phy-power-chg-quirk");
+       dwc->xhci_slow_suspend_quirk = device_property_read_bool(dev,
+                               "snps,xhci-slow-suspend-quirk");
 
        dwc->tx_de_emphasis_quirk = device_property_read_bool(dev,
                                "snps,tx_de_emphasis_quirk");
@@ -1240,6 +1261,9 @@ static int dwc3_suspend(struct device *dev)
        struct dwc3     *dwc = dev_get_drvdata(dev);
        int             ret;
 
+       if (pm_runtime_suspended(dwc->dev))
+               return 0;
+
        ret = dwc3_suspend_common(dwc);
        if (ret)
                return ret;
@@ -1254,6 +1278,9 @@ static int dwc3_resume(struct device *dev)
        struct dwc3     *dwc = dev_get_drvdata(dev);
        int             ret;
 
+       if (pm_runtime_suspended(dwc->dev))
+               return 0;
+
        pinctrl_pm_select_default_state(dev);
 
        ret = dwc3_resume_common(dwc);