All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] phy: lantiq: rcu-usb2: wait after clock enable
@ 2021-01-07 22:49 Mathias Kresin
  2021-01-07 23:12 ` Hauke Mehrtens
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Mathias Kresin @ 2021-01-07 22:49 UTC (permalink / raw)
  To: Kishon Vijay Abraham I, Vinod Koul, Philipp Zabel, linux-kernel
  Cc: Martin Blumenstingl, Hauke Mehrtens, stable

Commit 65dc2e725286 ("usb: dwc2: Update Core Reset programming flow.")
revealed that the phy isn't ready immediately after enabling it's
clocks. The dwc2_check_core_version() fails and the dwc2 usb driver
errors out.

Add a short delay to let the phy get up and running. There isn't any
documentation how much time is required, the value was chosen based on
tests.

Cc: <stable@vger.kernel.org> # v5.7+
Signed-off-by: Mathias Kresin <dev@kresin.me>
---
 drivers/phy/lantiq/phy-lantiq-rcu-usb2.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/phy/lantiq/phy-lantiq-rcu-usb2.c b/drivers/phy/lantiq/phy-lantiq-rcu-usb2.c
index a7d126192cf1..29d246ea24b4 100644
--- a/drivers/phy/lantiq/phy-lantiq-rcu-usb2.c
+++ b/drivers/phy/lantiq/phy-lantiq-rcu-usb2.c
@@ -124,8 +124,16 @@ static int ltq_rcu_usb2_phy_power_on(struct phy *phy)
 	reset_control_deassert(priv->phy_reset);
 
 	ret = clk_prepare_enable(priv->phy_gate_clk);
-	if (ret)
+	if (ret) {
 		dev_err(dev, "failed to enable PHY gate\n");
+		return ret;
+	}
+
+	/*
+	 * at least the xrx200 usb2 phy requires some extra time to be
+	 * operational after enabling the clock
+	 */
+	usleep_range(100, 200);
 
 	return ret;
 }
-- 
2.25.1


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

* Re: [PATCH] phy: lantiq: rcu-usb2: wait after clock enable
  2021-01-07 22:49 [PATCH] phy: lantiq: rcu-usb2: wait after clock enable Mathias Kresin
@ 2021-01-07 23:12 ` Hauke Mehrtens
  2021-01-08 19:48 ` Martin Blumenstingl
  2021-01-13 13:59 ` Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Hauke Mehrtens @ 2021-01-07 23:12 UTC (permalink / raw)
  To: Mathias Kresin, Kishon Vijay Abraham I, Vinod Koul,
	Philipp Zabel, linux-kernel
  Cc: Martin Blumenstingl, stable

On 1/7/21 11:49 PM, Mathias Kresin wrote:
> Commit 65dc2e725286 ("usb: dwc2: Update Core Reset programming flow.")
> revealed that the phy isn't ready immediately after enabling it's
> clocks. The dwc2_check_core_version() fails and the dwc2 usb driver
> errors out.
> 
> Add a short delay to let the phy get up and running. There isn't any
> documentation how much time is required, the value was chosen based on
> tests.
> 
> Cc: <stable@vger.kernel.org> # v5.7+
> Signed-off-by: Mathias Kresin <dev@kresin.me>

Acked-by: Hauke Mehrtens <hauke@hauke-m.de>

I do not know how long you have to wait here, but this looks ok, when it 
works.

Hauke

> ---
>   drivers/phy/lantiq/phy-lantiq-rcu-usb2.c | 10 +++++++++-
>   1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/phy/lantiq/phy-lantiq-rcu-usb2.c b/drivers/phy/lantiq/phy-lantiq-rcu-usb2.c
> index a7d126192cf1..29d246ea24b4 100644
> --- a/drivers/phy/lantiq/phy-lantiq-rcu-usb2.c
> +++ b/drivers/phy/lantiq/phy-lantiq-rcu-usb2.c
> @@ -124,8 +124,16 @@ static int ltq_rcu_usb2_phy_power_on(struct phy *phy)
>   	reset_control_deassert(priv->phy_reset);
>   
>   	ret = clk_prepare_enable(priv->phy_gate_clk);
> -	if (ret)
> +	if (ret) {
>   		dev_err(dev, "failed to enable PHY gate\n");
> +		return ret;
> +	}
> +
> +	/*
> +	 * at least the xrx200 usb2 phy requires some extra time to be
> +	 * operational after enabling the clock
> +	 */
> +	usleep_range(100, 200);
>   
>   	return ret;
>   }
> 


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

* Re: [PATCH] phy: lantiq: rcu-usb2: wait after clock enable
  2021-01-07 22:49 [PATCH] phy: lantiq: rcu-usb2: wait after clock enable Mathias Kresin
  2021-01-07 23:12 ` Hauke Mehrtens
@ 2021-01-08 19:48 ` Martin Blumenstingl
  2021-01-13 13:59 ` Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Martin Blumenstingl @ 2021-01-08 19:48 UTC (permalink / raw)
  To: Mathias Kresin
  Cc: Kishon Vijay Abraham I, Vinod Koul, Philipp Zabel, linux-kernel,
	Hauke Mehrtens, stable

On Thu, Jan 7, 2021 at 11:49 PM Mathias Kresin <dev@kresin.me> wrote:
>
> Commit 65dc2e725286 ("usb: dwc2: Update Core Reset programming flow.")
> revealed that the phy isn't ready immediately after enabling it's
> clocks. The dwc2_check_core_version() fails and the dwc2 usb driver
> errors out.
>
> Add a short delay to let the phy get up and running. There isn't any
> documentation how much time is required, the value was chosen based on
> tests.
>
> Cc: <stable@vger.kernel.org> # v5.7+
> Signed-off-by: Mathias Kresin <dev@kresin.me>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

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

* Re: [PATCH] phy: lantiq: rcu-usb2: wait after clock enable
  2021-01-07 22:49 [PATCH] phy: lantiq: rcu-usb2: wait after clock enable Mathias Kresin
  2021-01-07 23:12 ` Hauke Mehrtens
  2021-01-08 19:48 ` Martin Blumenstingl
@ 2021-01-13 13:59 ` Vinod Koul
  2 siblings, 0 replies; 4+ messages in thread
From: Vinod Koul @ 2021-01-13 13:59 UTC (permalink / raw)
  To: Mathias Kresin
  Cc: Kishon Vijay Abraham I, Philipp Zabel, linux-kernel,
	Martin Blumenstingl, Hauke Mehrtens, stable

On 07-01-21, 23:49, Mathias Kresin wrote:
> Commit 65dc2e725286 ("usb: dwc2: Update Core Reset programming flow.")
> revealed that the phy isn't ready immediately after enabling it's
> clocks. The dwc2_check_core_version() fails and the dwc2 usb driver
> errors out.
> 
> Add a short delay to let the phy get up and running. There isn't any
> documentation how much time is required, the value was chosen based on
> tests.

Applied, thanks

-- 
~Vinod

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

end of thread, other threads:[~2021-01-13 14:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-07 22:49 [PATCH] phy: lantiq: rcu-usb2: wait after clock enable Mathias Kresin
2021-01-07 23:12 ` Hauke Mehrtens
2021-01-08 19:48 ` Martin Blumenstingl
2021-01-13 13:59 ` Vinod Koul

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.