linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: dwc3: fix backwards compat with rockchip devices
@ 2022-04-09 15:21 Peter Geis
  2022-04-10 16:23 ` Heiko Stuebner
  2022-04-11 14:50 ` Sean Anderson
  0 siblings, 2 replies; 4+ messages in thread
From: Peter Geis @ 2022-04-09 15:21 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Robert Hancock, Sean Anderson
  Cc: linux-rockchip, heiko, Peter Geis, Frank Wunderlich, linux-usb,
	linux-kernel

Commit 33fb697ec7e5 ("usb: dwc3: Get clocks individually") moved from
the clk_bulk api to individual clocks, following the snps,dwc3.yaml
dt-binding for clock names.
Unfortunately the rk3328 (and upcoming rk356x support) use the
rockchip,dwc3.yaml which has different clock names, which are common on
devices using the glue layer.
The rk3328 does not use a glue layer, but attaches directly to the dwc3
core driver.
The offending patch series failed to account for this, thus dwc3 was
broken on rk3328.

To retain backwards compatibility with rk3328 device trees we must also
check for the alternate clock names.

Fixes: 33fb697ec7e5 ("usb: dwc3: Get clocks individually")

Reported-by: Frank Wunderlich <frank-w@public-files.de>
Signed-off-by: Peter Geis <pgwipeout@gmail.com>
---

This patch is standalone to fix the backwards compatibility, and is
necessary no matter if we decide to retain the clock names in
rockchip,dwc3.yaml as is or align with snps,dwc3.yaml.

 drivers/usb/dwc3/core.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index 1170b800acdc..5bfd3e88af35 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -1690,21 +1690,44 @@ static int dwc3_probe(struct platform_device *pdev)
 		/*
 		 * Clocks are optional, but new DT platforms should support all
 		 * clocks as required by the DT-binding.
+		 * Some devices have different clock names in legacy device trees,
+		 * check for them to retain backwards compatibility.
 		 */
 		dwc->bus_clk = devm_clk_get_optional(dev, "bus_early");
 		if (IS_ERR(dwc->bus_clk))
 			return dev_err_probe(dev, PTR_ERR(dwc->bus_clk),
 					     "could not get bus clock\n");
 
+		if (dwc->bus_clk == NULL) {
+			dwc->bus_clk = devm_clk_get_optional(dev, "bus_clk");
+			if (IS_ERR(dwc->bus_clk))
+				return dev_err_probe(dev, PTR_ERR(dwc->bus_clk),
+						     "could not get bus clock\n");
+		}
+
 		dwc->ref_clk = devm_clk_get_optional(dev, "ref");
 		if (IS_ERR(dwc->ref_clk))
 			return dev_err_probe(dev, PTR_ERR(dwc->ref_clk),
 					     "could not get ref clock\n");
 
+		if (dwc->ref_clk == NULL) {
+			dwc->ref_clk = devm_clk_get_optional(dev, "ref_clk");
+			if (IS_ERR(dwc->ref_clk))
+				return dev_err_probe(dev, PTR_ERR(dwc->ref_clk),
+						     "could not get ref clock\n");
+		}
+
 		dwc->susp_clk = devm_clk_get_optional(dev, "suspend");
 		if (IS_ERR(dwc->susp_clk))
 			return dev_err_probe(dev, PTR_ERR(dwc->susp_clk),
 					     "could not get suspend clock\n");
+
+		if (dwc->susp_clk == NULL) {
+			dwc->susp_clk = devm_clk_get_optional(dev, "suspend_clk");
+			if (IS_ERR(dwc->susp_clk))
+				return dev_err_probe(dev, PTR_ERR(dwc->susp_clk),
+						     "could not get suspend clock\n");
+		}
 	}
 
 	ret = reset_control_deassert(dwc->reset);
-- 
2.25.1


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

* Re: [PATCH] usb: dwc3: fix backwards compat with rockchip devices
  2022-04-09 15:21 [PATCH] usb: dwc3: fix backwards compat with rockchip devices Peter Geis
@ 2022-04-10 16:23 ` Heiko Stuebner
  2022-04-10 19:20   ` Aw: " Frank Wunderlich
  2022-04-11 14:50 ` Sean Anderson
  1 sibling, 1 reply; 4+ messages in thread
From: Heiko Stuebner @ 2022-04-10 16:23 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Robert Hancock, Sean Anderson,
	Peter Geis
  Cc: linux-rockchip, Peter Geis, Frank Wunderlich, linux-usb, linux-kernel

Am Samstag, 9. April 2022, 17:21:15 CEST schrieb Peter Geis:
> Commit 33fb697ec7e5 ("usb: dwc3: Get clocks individually") moved from
> the clk_bulk api to individual clocks, following the snps,dwc3.yaml
> dt-binding for clock names.
> Unfortunately the rk3328 (and upcoming rk356x support) use the
> rockchip,dwc3.yaml which has different clock names, which are common on
> devices using the glue layer.
> The rk3328 does not use a glue layer, but attaches directly to the dwc3
> core driver.
> The offending patch series failed to account for this, thus dwc3 was
> broken on rk3328.
> 
> To retain backwards compatibility with rk3328 device trees we must also
> check for the alternate clock names.
> 
> Fixes: 33fb697ec7e5 ("usb: dwc3: Get clocks individually")
> 
> Reported-by: Frank Wunderlich <frank-w@public-files.de>
> Signed-off-by: Peter Geis <pgwipeout@gmail.com>

Reviewed-by: Heiko Stuebner <heiko@sntech.de>

> ---
> 
> This patch is standalone to fix the backwards compatibility, and is
> necessary no matter if we decide to retain the clock names in
> rockchip,dwc3.yaml as is or align with snps,dwc3.yaml.
> 
>  drivers/usb/dwc3/core.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 1170b800acdc..5bfd3e88af35 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1690,21 +1690,44 @@ static int dwc3_probe(struct platform_device *pdev)
>  		/*
>  		 * Clocks are optional, but new DT platforms should support all
>  		 * clocks as required by the DT-binding.
> +		 * Some devices have different clock names in legacy device trees,
> +		 * check for them to retain backwards compatibility.
>  		 */
>  		dwc->bus_clk = devm_clk_get_optional(dev, "bus_early");
>  		if (IS_ERR(dwc->bus_clk))
>  			return dev_err_probe(dev, PTR_ERR(dwc->bus_clk),
>  					     "could not get bus clock\n");
>  
> +		if (dwc->bus_clk == NULL) {
> +			dwc->bus_clk = devm_clk_get_optional(dev, "bus_clk");
> +			if (IS_ERR(dwc->bus_clk))
> +				return dev_err_probe(dev, PTR_ERR(dwc->bus_clk),
> +						     "could not get bus clock\n");
> +		}
> +
>  		dwc->ref_clk = devm_clk_get_optional(dev, "ref");
>  		if (IS_ERR(dwc->ref_clk))
>  			return dev_err_probe(dev, PTR_ERR(dwc->ref_clk),
>  					     "could not get ref clock\n");
>  
> +		if (dwc->ref_clk == NULL) {
> +			dwc->ref_clk = devm_clk_get_optional(dev, "ref_clk");
> +			if (IS_ERR(dwc->ref_clk))
> +				return dev_err_probe(dev, PTR_ERR(dwc->ref_clk),
> +						     "could not get ref clock\n");
> +		}
> +
>  		dwc->susp_clk = devm_clk_get_optional(dev, "suspend");
>  		if (IS_ERR(dwc->susp_clk))
>  			return dev_err_probe(dev, PTR_ERR(dwc->susp_clk),
>  					     "could not get suspend clock\n");
> +
> +		if (dwc->susp_clk == NULL) {
> +			dwc->susp_clk = devm_clk_get_optional(dev, "suspend_clk");
> +			if (IS_ERR(dwc->susp_clk))
> +				return dev_err_probe(dev, PTR_ERR(dwc->susp_clk),
> +						     "could not get suspend clock\n");
> +		}
>  	}
>  
>  	ret = reset_control_deassert(dwc->reset);
> 





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

* Aw: Re: [PATCH] usb: dwc3: fix backwards compat with rockchip devices
  2022-04-10 16:23 ` Heiko Stuebner
@ 2022-04-10 19:20   ` Frank Wunderlich
  0 siblings, 0 replies; 4+ messages in thread
From: Frank Wunderlich @ 2022-04-10 19:20 UTC (permalink / raw)
  To: Heiko Stuebner
  Cc: Felipe Balbi, Greg Kroah-Hartman, Robert Hancock, Sean Anderson,
	Peter Geis, linux-rockchip, linux-usb, linux-kernel

Tested on rk3568 Bpi-R2 Pro V1.0 with RK356x USB-Support [1] and BPI-R2-Pro USB Support [2]

Tested-By: Frank Wunderlich <frank-w@public-files.de>

regards Frank

[1] https://patchwork.kernel.org/project/linux-rockchip/list/?series=630470
[2] https://patchwork.kernel.org/project/linux-rockchip/list/?series=630686

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

* Re: [PATCH] usb: dwc3: fix backwards compat with rockchip devices
  2022-04-09 15:21 [PATCH] usb: dwc3: fix backwards compat with rockchip devices Peter Geis
  2022-04-10 16:23 ` Heiko Stuebner
@ 2022-04-11 14:50 ` Sean Anderson
  1 sibling, 0 replies; 4+ messages in thread
From: Sean Anderson @ 2022-04-11 14:50 UTC (permalink / raw)
  To: Peter Geis, Felipe Balbi, Greg Kroah-Hartman, Robert Hancock
  Cc: linux-rockchip, heiko, Frank Wunderlich, linux-usb, linux-kernel



On 4/9/22 11:21 AM, Peter Geis wrote:
> Commit 33fb697ec7e5 ("usb: dwc3: Get clocks individually") moved from
> the clk_bulk api to individual clocks, following the snps,dwc3.yaml
> dt-binding for clock names.
> Unfortunately the rk3328 (and upcoming rk356x support) use the
> rockchip,dwc3.yaml which has different clock names, which are common on
> devices using the glue layer.
> The rk3328 does not use a glue layer, but attaches directly to the dwc3
> core driver.
> The offending patch series failed to account for this, thus dwc3 was
> broken on rk3328.
> 
> To retain backwards compatibility with rk3328 device trees we must also
> check for the alternate clock names.
> 
> Fixes: 33fb697ec7e5 ("usb: dwc3: Get clocks individually")
> 
> Reported-by: Frank Wunderlich <frank-w@public-files.de>
> Signed-off-by: Peter Geis <pgwipeout@gmail.com>
> ---
> 
> This patch is standalone to fix the backwards compatibility, and is
> necessary no matter if we decide to retain the clock names in
> rockchip,dwc3.yaml as is or align with snps,dwc3.yaml.
> 
>  drivers/usb/dwc3/core.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
> index 1170b800acdc..5bfd3e88af35 100644
> --- a/drivers/usb/dwc3/core.c
> +++ b/drivers/usb/dwc3/core.c
> @@ -1690,21 +1690,44 @@ static int dwc3_probe(struct platform_device *pdev)
>  		/*
>  		 * Clocks are optional, but new DT platforms should support all
>  		 * clocks as required by the DT-binding.
> +		 * Some devices have different clock names in legacy device trees,
> +		 * check for them to retain backwards compatibility.
>  		 */
>  		dwc->bus_clk = devm_clk_get_optional(dev, "bus_early");
>  		if (IS_ERR(dwc->bus_clk))
>  			return dev_err_probe(dev, PTR_ERR(dwc->bus_clk),
>  					     "could not get bus clock\n");
>  
> +		if (dwc->bus_clk == NULL) {
> +			dwc->bus_clk = devm_clk_get_optional(dev, "bus_clk");
> +			if (IS_ERR(dwc->bus_clk))
> +				return dev_err_probe(dev, PTR_ERR(dwc->bus_clk),
> +						     "could not get bus clock\n");
> +		}
> +
>  		dwc->ref_clk = devm_clk_get_optional(dev, "ref");
>  		if (IS_ERR(dwc->ref_clk))
>  			return dev_err_probe(dev, PTR_ERR(dwc->ref_clk),
>  					     "could not get ref clock\n");
>  
> +		if (dwc->ref_clk == NULL) {
> +			dwc->ref_clk = devm_clk_get_optional(dev, "ref_clk");
> +			if (IS_ERR(dwc->ref_clk))
> +				return dev_err_probe(dev, PTR_ERR(dwc->ref_clk),
> +						     "could not get ref clock\n");
> +		}
> +
>  		dwc->susp_clk = devm_clk_get_optional(dev, "suspend");
>  		if (IS_ERR(dwc->susp_clk))
>  			return dev_err_probe(dev, PTR_ERR(dwc->susp_clk),
>  					     "could not get suspend clock\n");
> +
> +		if (dwc->susp_clk == NULL) {
> +			dwc->susp_clk = devm_clk_get_optional(dev, "suspend_clk");
> +			if (IS_ERR(dwc->susp_clk))
> +				return dev_err_probe(dev, PTR_ERR(dwc->susp_clk),
> +						     "could not get suspend clock\n");
> +		}
>  	}
>  
>  	ret = reset_control_deassert(dwc->reset);
> 

Acked-by: Sean Anderson <sean.anderson@seco.com>

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

end of thread, other threads:[~2022-04-11 14:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-09 15:21 [PATCH] usb: dwc3: fix backwards compat with rockchip devices Peter Geis
2022-04-10 16:23 ` Heiko Stuebner
2022-04-10 19:20   ` Aw: " Frank Wunderlich
2022-04-11 14:50 ` Sean Anderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).