Merge tag 'usb-5.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
[linux-2.6-microblaze.git] / drivers / usb / dwc2 / core.c
index 6f70ab9..cf0bcd0 100644 (file)
@@ -295,7 +295,7 @@ void dwc2_hib_restore_common(struct dwc2_hsotg *hsotg, int rem_wakeup,
        if (dwc2_hsotg_wait_bit_set(hsotg, GINTSTS, GINTSTS_RESTOREDONE,
                                    20000)) {
                dev_dbg(hsotg->dev,
-                       "%s: Restore Done wan't generated here\n",
+                       "%s: Restore Done wasn't generated here\n",
                        __func__);
        } else {
                dev_dbg(hsotg->dev, "restore done  generated here\n");
@@ -1111,15 +1111,6 @@ static int dwc2_hs_phy_init(struct dwc2_hsotg *hsotg, bool select_phy)
                usbcfg &= ~(GUSBCFG_ULPI_UTMI_SEL | GUSBCFG_PHYIF16);
                if (hsotg->params.phy_utmi_width == 16)
                        usbcfg |= GUSBCFG_PHYIF16;
-
-               /* Set turnaround time */
-               if (dwc2_is_device_mode(hsotg)) {
-                       usbcfg &= ~GUSBCFG_USBTRDTIM_MASK;
-                       if (hsotg->params.phy_utmi_width == 16)
-                               usbcfg |= 5 << GUSBCFG_USBTRDTIM_SHIFT;
-                       else
-                               usbcfg |= 9 << GUSBCFG_USBTRDTIM_SHIFT;
-               }
                break;
        default:
                dev_err(hsotg->dev, "FS PHY selected at HS!\n");
@@ -1141,6 +1132,24 @@ static int dwc2_hs_phy_init(struct dwc2_hsotg *hsotg, bool select_phy)
        return retval;
 }
 
+static void dwc2_set_turnaround_time(struct dwc2_hsotg *hsotg)
+{
+       u32 usbcfg;
+
+       if (hsotg->params.phy_type != DWC2_PHY_TYPE_PARAM_UTMI)
+               return;
+
+       usbcfg = dwc2_readl(hsotg, GUSBCFG);
+
+       usbcfg &= ~GUSBCFG_USBTRDTIM_MASK;
+       if (hsotg->params.phy_utmi_width == 16)
+               usbcfg |= 5 << GUSBCFG_USBTRDTIM_SHIFT;
+       else
+               usbcfg |= 9 << GUSBCFG_USBTRDTIM_SHIFT;
+
+       dwc2_writel(hsotg, usbcfg, GUSBCFG);
+}
+
 int dwc2_phy_init(struct dwc2_hsotg *hsotg, bool select_phy)
 {
        u32 usbcfg;
@@ -1158,6 +1167,9 @@ int dwc2_phy_init(struct dwc2_hsotg *hsotg, bool select_phy)
                retval = dwc2_hs_phy_init(hsotg, select_phy);
                if (retval)
                        return retval;
+
+               if (dwc2_is_device_mode(hsotg))
+                       dwc2_set_turnaround_time(hsotg);
        }
 
        if (hsotg->hw_params.hs_phy_type == GHWCFG2_HS_PHY_TYPE_ULPI &&