public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v 5] usb: dwc2: gadget: Fix enter to hibernation for UTMI+ PHY
@ 2025-06-25  5:50 Minas Harutyunyan
  2025-06-28 15:15 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Minas Harutyunyan @ 2025-06-25  5:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Minas Harutyunyan
  Cc: John Youn, Minas Harutyunyan, linux-usb@vger.kernel.org,
	stable@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 2793 bytes --]

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@vger.kernel.org
Signed-off-by: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
---
 Changes in v5:
 - Rebased on top of Linux 6.16-rc2
 Changes in v4:
 - Rebased on top of Linux 6.15-rc6
 Changes in v3:
 - Rebased on top of Linux 6.15-rc4
 Changes in v2:
 - Added Cc: stable@vger.kernel.org

 drivers/usb/dwc2/gadget.c | 38 ++++++++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index d5b622f78cf3..0637bfbc054e 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -5389,20 +5389,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;

base-commit: 7aed15379db9c6ec67999cdaf5c443b7be06ea73
--
2.41.0

[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 14898 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v 5] usb: dwc2: gadget: Fix enter to hibernation for UTMI+ PHY
  2025-06-25  5:50 [PATCH v 5] usb: dwc2: gadget: Fix enter to hibernation for UTMI+ PHY Minas Harutyunyan
@ 2025-06-28 15:15 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2025-06-28 15:15 UTC (permalink / raw)
  To: Minas Harutyunyan
  Cc: John Youn, linux-usb@vger.kernel.org, stable@vger.kernel.org

On Wed, Jun 25, 2025 at 05:50:21AM +0000, Minas Harutyunyan wrote:
> 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@vger.kernel.org
> Signed-off-by: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
> ---
>  Changes in v5:
>  - Rebased on top of Linux 6.16-rc2
>  Changes in v4:
>  - Rebased on top of Linux 6.15-rc6
>  Changes in v3:
>  - Rebased on top of Linux 6.15-rc4
>  Changes in v2:
>  - Added Cc: stable@vger.kernel.org
> 
>  drivers/usb/dwc2/gadget.c | 38 ++++++++++++++++++++++++++------------
>  1 file changed, 26 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index d5b622f78cf3..0637bfbc054e 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -5389,20 +5389,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;
> 
> base-commit: 7aed15379db9c6ec67999cdaf5c443b7be06ea73
> --
> 2.41.0



Something is really wrong here, this doesn't apply at all to 6.16-rc2,
or my usb-linus branch or my usb-next branch.  Are you sure you made
this properly?  That "base commit" feels really odd...

confused.

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-06-28 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-25  5:50 [PATCH v 5] usb: dwc2: gadget: Fix enter to hibernation for UTMI+ PHY Minas Harutyunyan
2025-06-28 15:15 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox