]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
usb: dwc2: gadget: Fix enter to hibernation for UTMI+ PHY
authorMinas Harutyunyan <Minas.Harutyunyan@synopsys.com>
Mon, 7 Jul 2025 09:54:19 +0000 (09:54 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 24 Jul 2025 06:56:20 +0000 (08:56 +0200)
commit 5724ff190b22bd04fcfd7287a39c6e5494e40f0b upstream.

For UTMI+ PHY, according to programming guide, first should be set
PMUACTV bit then STOPPCLK bit. Otherwise, when the device issues
Remote Wakeup, then host notices disconnect instead.
For ULPI PHY, above mentioned bits must be set in reversed order:
STOPPCLK then PMUACTV.

Fixes: 4483ef3c1685 ("usb: dwc2: Add hibernation updates for ULPI PHY")
Cc: stable <stable@kernel.org>
Signed-off-by: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
Link: https://lore.kernel.org/r/692110d3c3d9bb2a91cedf24528a7710adc55452.1751881374.git.Minas.Harutyunyan@synopsys.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc2/gadget.c

index d3d0d75ab1f594a85c7c6dbfce18abeb6f7deb40..834fc02610a2dccacd0c522d8aa23398332b3a97 100644 (file)
@@ -5352,20 +5352,34 @@ int dwc2_gadget_enter_hibernation(struct dwc2_hsotg *hsotg)
        if (gusbcfg & GUSBCFG_ULPI_UTMI_SEL) {
                /* ULPI interface */
                gpwrdn |= GPWRDN_ULPI_LATCH_EN_DURING_HIB_ENTRY;
-       }
-       dwc2_writel(hsotg, gpwrdn, GPWRDN);
-       udelay(10);
+               dwc2_writel(hsotg, gpwrdn, GPWRDN);
+               udelay(10);
 
-       /* Suspend the Phy Clock */
-       pcgcctl = dwc2_readl(hsotg, PCGCTL);
-       pcgcctl |= PCGCTL_STOPPCLK;
-       dwc2_writel(hsotg, pcgcctl, PCGCTL);
-       udelay(10);
+               /* Suspend the Phy Clock */
+               pcgcctl = dwc2_readl(hsotg, PCGCTL);
+               pcgcctl |= PCGCTL_STOPPCLK;
+               dwc2_writel(hsotg, pcgcctl, PCGCTL);
+               udelay(10);
 
-       gpwrdn = dwc2_readl(hsotg, GPWRDN);
-       gpwrdn |= GPWRDN_PMUACTV;
-       dwc2_writel(hsotg, gpwrdn, GPWRDN);
-       udelay(10);
+               gpwrdn = dwc2_readl(hsotg, GPWRDN);
+               gpwrdn |= GPWRDN_PMUACTV;
+               dwc2_writel(hsotg, gpwrdn, GPWRDN);
+               udelay(10);
+       } else {
+               /* UTMI+ Interface */
+               dwc2_writel(hsotg, gpwrdn, GPWRDN);
+               udelay(10);
+
+               gpwrdn = dwc2_readl(hsotg, GPWRDN);
+               gpwrdn |= GPWRDN_PMUACTV;
+               dwc2_writel(hsotg, gpwrdn, GPWRDN);
+               udelay(10);
+
+               pcgcctl = dwc2_readl(hsotg, PCGCTL);
+               pcgcctl |= PCGCTL_STOPPCLK;
+               dwc2_writel(hsotg, pcgcctl, PCGCTL);
+               udelay(10);
+       }
 
        /* Set flag to indicate that we are in hibernation */
        hsotg->hibernated = 1;