Skip to content

Commit 032f229

Browse files
Minas Harutyunyangregkh
authored andcommitted
usb: dwc2: gadget: Fix enter to hibernation for UTMI+ PHY
commit 5724ff1 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: 4483ef3 ("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>
1 parent 231bf7e commit 032f229

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

drivers/usb/dwc2/gadget.c

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5352,20 +5352,34 @@ int dwc2_gadget_enter_hibernation(struct dwc2_hsotg *hsotg)
53525352
if (gusbcfg & GUSBCFG_ULPI_UTMI_SEL) {
53535353
/* ULPI interface */
53545354
gpwrdn |= GPWRDN_ULPI_LATCH_EN_DURING_HIB_ENTRY;
5355-
}
5356-
dwc2_writel(hsotg, gpwrdn, GPWRDN);
5357-
udelay(10);
5355+
dwc2_writel(hsotg, gpwrdn, GPWRDN);
5356+
udelay(10);
53585357

5359-
/* Suspend the Phy Clock */
5360-
pcgcctl = dwc2_readl(hsotg, PCGCTL);
5361-
pcgcctl |= PCGCTL_STOPPCLK;
5362-
dwc2_writel(hsotg, pcgcctl, PCGCTL);
5363-
udelay(10);
5358+
/* Suspend the Phy Clock */
5359+
pcgcctl = dwc2_readl(hsotg, PCGCTL);
5360+
pcgcctl |= PCGCTL_STOPPCLK;
5361+
dwc2_writel(hsotg, pcgcctl, PCGCTL);
5362+
udelay(10);
53645363

5365-
gpwrdn = dwc2_readl(hsotg, GPWRDN);
5366-
gpwrdn |= GPWRDN_PMUACTV;
5367-
dwc2_writel(hsotg, gpwrdn, GPWRDN);
5368-
udelay(10);
5364+
gpwrdn = dwc2_readl(hsotg, GPWRDN);
5365+
gpwrdn |= GPWRDN_PMUACTV;
5366+
dwc2_writel(hsotg, gpwrdn, GPWRDN);
5367+
udelay(10);
5368+
} else {
5369+
/* UTMI+ Interface */
5370+
dwc2_writel(hsotg, gpwrdn, GPWRDN);
5371+
udelay(10);
5372+
5373+
gpwrdn = dwc2_readl(hsotg, GPWRDN);
5374+
gpwrdn |= GPWRDN_PMUACTV;
5375+
dwc2_writel(hsotg, gpwrdn, GPWRDN);
5376+
udelay(10);
5377+
5378+
pcgcctl = dwc2_readl(hsotg, PCGCTL);
5379+
pcgcctl |= PCGCTL_STOPPCLK;
5380+
dwc2_writel(hsotg, pcgcctl, PCGCTL);
5381+
udelay(10);
5382+
}
53695383

53705384
/* Set flag to indicate that we are in hibernation */
53715385
hsotg->hibernated = 1;

0 commit comments

Comments
 (0)