usb: dwc2: Reorder AHBIDLE and CSFTRST in dwc2_core_reset()
authorJohn Youn <John.Youn@synopsys.com>
Thu, 17 Dec 2015 19:15:35 +0000 (11:15 -0800)
committerFelipe Balbi <balbi@ti.com>
Tue, 22 Dec 2015 17:54:45 +0000 (11:54 -0600)
According to the databook, the core soft reset should be done before
checking for AHBIDLE. The gadget version of core reset had it correct
but the hcd version did not. This fixes the hcd version.

Signed-off-by: John Youn <johnyoun@synopsys.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/dwc2/core.c

index c8f66ad48a55ceba5b00488484b947634ab9986f..62505068abf2e2a90daf38807ca3e0d73c5e6cfa 100644 (file)
@@ -489,32 +489,33 @@ int dwc2_core_reset(struct dwc2_hsotg *hsotg)
 
        dev_vdbg(hsotg->dev, "%s()\n", __func__);
 
-       /* Wait for AHB master IDLE state */
+       /* Core Soft Reset */
+       greset = dwc2_readl(hsotg->regs + GRSTCTL);
+       greset |= GRSTCTL_CSFTRST;
+       dwc2_writel(greset, hsotg->regs + GRSTCTL);
        do {
                udelay(1);
                greset = dwc2_readl(hsotg->regs + GRSTCTL);
                if (++count > 50) {
                        dev_warn(hsotg->dev,
-                                "%s() HANG! AHB Idle GRSTCTL=%0x\n",
+                                "%s() HANG! Soft Reset GRSTCTL=%0x\n",
                                 __func__, greset);
                        return -EBUSY;
                }
-       } while (!(greset & GRSTCTL_AHBIDLE));
+       } while (greset & GRSTCTL_CSFTRST);
 
-       /* Core Soft Reset */
+       /* Wait for AHB master IDLE state */
        count = 0;
-       greset |= GRSTCTL_CSFTRST;
-       dwc2_writel(greset, hsotg->regs + GRSTCTL);
        do {
                udelay(1);
                greset = dwc2_readl(hsotg->regs + GRSTCTL);
                if (++count > 50) {
                        dev_warn(hsotg->dev,
-                                "%s() HANG! Soft Reset GRSTCTL=%0x\n",
+                                "%s() HANG! AHB Idle GRSTCTL=%0x\n",
                                 __func__, greset);
                        return -EBUSY;
                }
-       } while (greset & GRSTCTL_CSFTRST);
+       } while (!(greset & GRSTCTL_AHBIDLE));
 
        if (hsotg->dr_mode == USB_DR_MODE_HOST) {
                gusbcfg = dwc2_readl(hsotg->regs + GUSBCFG);