All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] usb: dwc2: Use clk bulk API for supporting multiple clocks
@ 2021-01-11 15:13 Sascha Hauer
  2021-01-11 15:13 ` [PATCH 1/2] dt-bindings: usb: dwc2: Add support for additional clock Sascha Hauer
  2021-01-11 15:13 ` [PATCH 2/2] usb: dwc2: use clk bulk API for supporting additional clocks Sascha Hauer
  0 siblings, 2 replies; 5+ messages in thread
From: Sascha Hauer @ 2021-01-11 15:13 UTC (permalink / raw)
  To: linux-usb; +Cc: Minas Harutyunyan, devicetree, Sascha Hauer

Currently the dwc2 driver only supports a single clock. I have a board
here which has a dwc2 controller with a somewhat special clock routing
to the phy. Both the dwc2 controller and the ULPI phy get their phy
clock from a SI5351 clock generator. This clock generator has multiple
clock outputs which each is modelled as a separate clk in Linux.
Unfortunately the clock to the phy and the clock to the dwc2 core are on
two different output pins of the SI5351, so we have two clocks which
must be enabled.  The phy is driven by the usb-nop-xceiver driver which
supports a single clock. My first approach was to add support for a
second clock to that driver, but technically the other clock is
connected to the dwc2 core, so instead I added support for a second
clock to the dwc2 driver.  This can easily be archieved with the clk
bulk API as done in this series.

Sascha

Sascha Hauer (2):
  dt-bindings: usb: dwc2: Add support for additional clock
  usb: dwc2: use clk bulk API for supporting additional clocks

 .../devicetree/bindings/usb/dwc2.yaml          |  3 ++-
 drivers/usb/dwc2/core.h                        |  2 ++
 drivers/usb/dwc2/platform.c                    | 18 ++++++++----------
 3 files changed, 12 insertions(+), 11 deletions(-)

-- 
2.20.1


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

* [PATCH 1/2] dt-bindings: usb: dwc2: Add support for additional clock
  2021-01-11 15:13 [PATCH 0/2] usb: dwc2: Use clk bulk API for supporting multiple clocks Sascha Hauer
@ 2021-01-11 15:13 ` Sascha Hauer
  2021-01-11 17:41   ` Rob Herring
  2021-01-11 15:13 ` [PATCH 2/2] usb: dwc2: use clk bulk API for supporting additional clocks Sascha Hauer
  1 sibling, 1 reply; 5+ messages in thread
From: Sascha Hauer @ 2021-01-11 15:13 UTC (permalink / raw)
  To: linux-usb; +Cc: Minas Harutyunyan, devicetree, Sascha Hauer

This adds support for an additional clock for the dwc2 core in case
there is another clock to the phy which must be enabled.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 Documentation/devicetree/bindings/usb/dwc2.yaml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/usb/dwc2.yaml b/Documentation/devicetree/bindings/usb/dwc2.yaml
index e5ee51b7b470..20d0847c7b01 100644
--- a/Documentation/devicetree/bindings/usb/dwc2.yaml
+++ b/Documentation/devicetree/bindings/usb/dwc2.yaml
@@ -57,11 +57,12 @@ properties:
     maxItems: 1
 
   clocks:
-    maxItems: 1
+    maxItems: 2
 
   clock-names:
     items:
       - const: otg
+      - const: phy
 
   resets:
     items:
-- 
2.20.1


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

* [PATCH 2/2] usb: dwc2: use clk bulk API for supporting additional clocks
  2021-01-11 15:13 [PATCH 0/2] usb: dwc2: Use clk bulk API for supporting multiple clocks Sascha Hauer
  2021-01-11 15:13 ` [PATCH 1/2] dt-bindings: usb: dwc2: Add support for additional clock Sascha Hauer
@ 2021-01-11 15:13 ` Sascha Hauer
  1 sibling, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2021-01-11 15:13 UTC (permalink / raw)
  To: linux-usb; +Cc: Minas Harutyunyan, devicetree, Sascha Hauer

This switches to the clk bulk API for the dwc2 driver. With this
additional clocks can be supported.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/usb/dwc2/core.h     |  2 ++
 drivers/usb/dwc2/platform.c | 18 ++++++++----------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index 7161344c6522..4c9e2c75f3dd 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -1075,6 +1075,8 @@ struct dwc2_hsotg {
 	spinlock_t lock;
 	void *priv;
 	int     irq;
+	struct clk_bulk_data *clocks;
+	int num_clocks;
 	struct clk *clk;
 	struct reset_control *reset;
 	struct reset_control *reset_ecc;
diff --git a/drivers/usb/dwc2/platform.c b/drivers/usb/dwc2/platform.c
index 5f18acac7406..d4a1a26103da 100644
--- a/drivers/usb/dwc2/platform.c
+++ b/drivers/usb/dwc2/platform.c
@@ -143,11 +143,9 @@ static int __dwc2_lowlevel_hw_enable(struct dwc2_hsotg *hsotg)
 	if (ret)
 		return ret;
 
-	if (hsotg->clk) {
-		ret = clk_prepare_enable(hsotg->clk);
-		if (ret)
-			return ret;
-	}
+	ret = clk_bulk_prepare_enable(hsotg->num_clocks, hsotg->clocks);
+	if (ret)
+		return ret;
 
 	if (hsotg->uphy) {
 		ret = usb_phy_init(hsotg->uphy);
@@ -195,8 +193,7 @@ static int __dwc2_lowlevel_hw_disable(struct dwc2_hsotg *hsotg)
 	if (ret)
 		return ret;
 
-	if (hsotg->clk)
-		clk_disable_unprepare(hsotg->clk);
+	clk_bulk_disable_unprepare(hsotg->num_clocks, hsotg->clocks);
 
 	return 0;
 }
@@ -281,11 +278,12 @@ static int dwc2_lowlevel_hw_init(struct dwc2_hsotg *hsotg)
 	hsotg->plat = dev_get_platdata(hsotg->dev);
 
 	/* Clock */
-	hsotg->clk = devm_clk_get_optional(hsotg->dev, "otg");
-	if (IS_ERR(hsotg->clk)) {
+	ret = devm_clk_bulk_get_all(hsotg->dev, &hsotg->clocks);
+	if (ret < 0) {
 		dev_err(hsotg->dev, "cannot get otg clock\n");
-		return PTR_ERR(hsotg->clk);
+		return ret;
 	}
+	hsotg->num_clocks = ret;
 
 	/* Regulators */
 	for (i = 0; i < ARRAY_SIZE(hsotg->supplies); i++)
-- 
2.20.1


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

* Re: [PATCH 1/2] dt-bindings: usb: dwc2: Add support for additional clock
  2021-01-11 15:13 ` [PATCH 1/2] dt-bindings: usb: dwc2: Add support for additional clock Sascha Hauer
@ 2021-01-11 17:41   ` Rob Herring
  2021-01-13  8:43     ` Sascha Hauer
  0 siblings, 1 reply; 5+ messages in thread
From: Rob Herring @ 2021-01-11 17:41 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: devicetree, linux-usb, Minas Harutyunyan

On Mon, 11 Jan 2021 16:13:36 +0100, Sascha Hauer wrote:
> This adds support for an additional clock for the dwc2 core in case
> there is another clock to the phy which must be enabled.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  Documentation/devicetree/bindings/usb/dwc2.yaml | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.example.dt.yaml: usb@ff400000: clocks: [[4294967295]] is too short
	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/dwc2.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.example.dt.yaml: usb@ff400000: clock-names: ['otg'] is too short
	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/dwc2.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/dwc2.example.dt.yaml: usb@101c0000: clocks: [[4294967295]] is too short
	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/dwc2.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/dwc2.example.dt.yaml: usb@101c0000: clock-names: ['otg'] is too short
	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/dwc2.yaml

See https://patchwork.ozlabs.org/patch/1424674

This check can fail if there are any dependencies. The base for a patch
series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit.


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

* Re: [PATCH 1/2] dt-bindings: usb: dwc2: Add support for additional clock
  2021-01-11 17:41   ` Rob Herring
@ 2021-01-13  8:43     ` Sascha Hauer
  0 siblings, 0 replies; 5+ messages in thread
From: Sascha Hauer @ 2021-01-13  8:43 UTC (permalink / raw)
  To: Rob Herring; +Cc: devicetree, linux-usb, Minas Harutyunyan

On Mon, Jan 11, 2021 at 11:41:09AM -0600, Rob Herring wrote:
> On Mon, 11 Jan 2021 16:13:36 +0100, Sascha Hauer wrote:
> > This adds support for an additional clock for the dwc2 core in case
> > there is another clock to the phy which must be enabled.
> > 
> > Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> > ---
> >  Documentation/devicetree/bindings/usb/dwc2.yaml | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> 
> My bot found errors running 'make dt_binding_check' on your patch:
> 
> yamllint warnings/errors:
> 
> dtschema/dtc warnings/errors:
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.example.dt.yaml: usb@ff400000: clocks: [[4294967295]] is too short
> 	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/dwc2.yaml
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/amlogic,meson-g12a-usb-ctrl.example.dt.yaml: usb@ff400000: clock-names: ['otg'] is too short
> 	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/dwc2.yaml
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/usb/dwc2.example.dt.yaml: usb@101c0000: clocks: [[4294967295]] is too short

Ok, this can be fixed by adding a "minItems" property to clocks and
clock-names. Will do next round.

Anything more to say to this series?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-11 15:13 [PATCH 0/2] usb: dwc2: Use clk bulk API for supporting multiple clocks Sascha Hauer
2021-01-11 15:13 ` [PATCH 1/2] dt-bindings: usb: dwc2: Add support for additional clock Sascha Hauer
2021-01-11 17:41   ` Rob Herring
2021-01-13  8:43     ` Sascha Hauer
2021-01-11 15:13 ` [PATCH 2/2] usb: dwc2: use clk bulk API for supporting additional clocks Sascha Hauer

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.