mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] simple-pm-bus: deassert resets if possible
@ 2024-02-23 10:10 Yang Xiwen via B4 Relay
  2024-02-23 10:10 ` [PATCH v2 1/2] dt-bindings: simple-pm-bus: Add optional resets Yang Xiwen via B4 Relay
  2024-02-23 10:10 ` [PATCH v2 2/2] drivers: bus: simple-pm-bus: Get and deassert resets exclusively Yang Xiwen via B4 Relay
  0 siblings, 2 replies; 4+ messages in thread
From: Yang Xiwen via B4 Relay @ 2024-02-23 10:10 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Philipp Zabel
  Cc: devicetree, linux-kernel, Yang Xiwen

simple power-managed buses can also have resets. Get and deassert them
if possible.

Signed-off-by: Yang Xiwen <forbidden405@outlook.com>
---
Changes in v2:
- use wrapper
- Link to v1: https://lore.kernel.org/r/20240223-b4-bus-v1-0-2803c3ac4673@outlook.com

---
Yang Xiwen (2):
      dt-bindings: simple-pm-bus: Add optional resets
      drivers: bus: simple-pm-bus: Get and deassert resets exclusively

 Documentation/devicetree/bindings/bus/simple-pm-bus.yaml |  7 +++++--
 drivers/bus/simple-pm-bus.c                              | 16 ++++++++++++++--
 2 files changed, 19 insertions(+), 4 deletions(-)
---
base-commit: 8d3dea210042f54b952b481838c1e7dfc4ec751d
change-id: 20240223-b4-bus-d5c6f75a251a

Best regards,
-- 
Yang Xiwen <forbidden405@outlook.com>


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

* [PATCH v2 1/2] dt-bindings: simple-pm-bus: Add optional resets
  2024-02-23 10:10 [PATCH v2 0/2] simple-pm-bus: deassert resets if possible Yang Xiwen via B4 Relay
@ 2024-02-23 10:10 ` Yang Xiwen via B4 Relay
  2024-02-26  8:01   ` Krzysztof Kozlowski
  2024-02-23 10:10 ` [PATCH v2 2/2] drivers: bus: simple-pm-bus: Get and deassert resets exclusively Yang Xiwen via B4 Relay
  1 sibling, 1 reply; 4+ messages in thread
From: Yang Xiwen via B4 Relay @ 2024-02-23 10:10 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Philipp Zabel
  Cc: devicetree, linux-kernel, Yang Xiwen

From: Yang Xiwen <forbidden405@outlook.com>

For some on-soc buses, it is also needed to deassert the resets before
access. Document it in the binding.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Yang Xiwen <forbidden405@outlook.com>
---
 Documentation/devicetree/bindings/bus/simple-pm-bus.yaml | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/bus/simple-pm-bus.yaml b/Documentation/devicetree/bindings/bus/simple-pm-bus.yaml
index 182134d7a6a3..430638104980 100644
--- a/Documentation/devicetree/bindings/bus/simple-pm-bus.yaml
+++ b/Documentation/devicetree/bindings/bus/simple-pm-bus.yaml
@@ -14,8 +14,9 @@ description: |
   driver, as it's typically initialized by the boot loader.
 
   However, its bus controller is part of a PM domain, or under the control
-  of a functional clock.  Hence, the bus controller's PM domain and/or
-  clock must be enabled for child devices connected to the bus (either
+  of a functional clock, and it might have a reset control signal.  Hence,
+  the bus controller's PM domain and/or clock must be enabled, reset control
+  signal must be deasserted for child devices connected to the bus (either
   on-SoC or externally) to function.
 
   While "simple-pm-bus" follows the "simple-bus" set of properties, as
@@ -49,6 +50,8 @@ properties:
     # Required if clocks is absent, optional otherwise
     minItems: 1
 
+  resets: true
+
 required:
   - compatible
   - '#address-cells'

-- 
2.43.0


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

* [PATCH v2 2/2] drivers: bus: simple-pm-bus: Get and deassert resets exclusively
  2024-02-23 10:10 [PATCH v2 0/2] simple-pm-bus: deassert resets if possible Yang Xiwen via B4 Relay
  2024-02-23 10:10 ` [PATCH v2 1/2] dt-bindings: simple-pm-bus: Add optional resets Yang Xiwen via B4 Relay
@ 2024-02-23 10:10 ` Yang Xiwen via B4 Relay
  1 sibling, 0 replies; 4+ messages in thread
From: Yang Xiwen via B4 Relay @ 2024-02-23 10:10 UTC (permalink / raw)
  To: Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Philipp Zabel
  Cc: devicetree, linux-kernel, Yang Xiwen

From: Yang Xiwen <forbidden405@outlook.com>

Simple Power-Managed bus controller may need functional reset(s)
to be deasserted before child devices connected to the bus can be
accessed.  Get the reset(s) as an array and assert/deassert the
reset(s) when the bus is being power managed.

One example is that HiSilicon USB2 INNO PHY test bus needs to deassert
the reset to the bus before accessing its registers.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Yang Xiwen <forbidden405@outlook.com>
---
 drivers/bus/simple-pm-bus.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/simple-pm-bus.c b/drivers/bus/simple-pm-bus.c
index 50870c827889..f2e98eac0bb4 100644
--- a/drivers/bus/simple-pm-bus.c
+++ b/drivers/bus/simple-pm-bus.c
@@ -16,15 +16,17 @@
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/reset.h>
 
 struct simple_pm_bus {
 	struct clk_bulk_data *clks;
+	struct reset_control *rsts;
 	int num_clks;
 };
 
 static int simple_pm_bus_probe(struct platform_device *pdev)
 {
-	const struct device *dev = &pdev->dev;
+	struct device *dev = &pdev->dev;
 	const struct of_dev_auxdata *lookup = dev_get_platdata(dev);
 	struct device_node *np = dev->of_node;
 	const struct of_device_id *match;
@@ -62,6 +64,10 @@ static int simple_pm_bus_probe(struct platform_device *pdev)
 	if (bus->num_clks < 0)
 		return dev_err_probe(&pdev->dev, bus->num_clks, "failed to get clocks\n");
 
+	bus->rsts = devm_reset_control_array_get_optional_exclusive(dev);
+	if (IS_ERR(bus->rsts))
+		return dev_err_probe(&pdev->dev, PTR_ERR(bus->rsts), "failed to get resets\n");
+
 	dev_set_drvdata(&pdev->dev, bus);
 
 	dev_dbg(&pdev->dev, "%s\n", __func__);
@@ -92,7 +98,7 @@ static int simple_pm_bus_runtime_suspend(struct device *dev)
 
 	clk_bulk_disable_unprepare(bus->num_clks, bus->clks);
 
-	return 0;
+	return reset_control_assert(bus->rsts);
 }
 
 static int simple_pm_bus_runtime_resume(struct device *dev)
@@ -106,6 +112,12 @@ static int simple_pm_bus_runtime_resume(struct device *dev)
 		return ret;
 	}
 
+	ret = reset_control_deassert(bus->rsts);
+	if (ret) {
+		dev_err(dev, "failed to deassert resets: %d\n", ret);
+		return ret;
+	}
+
 	return 0;
 }
 

-- 
2.43.0


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

* Re: [PATCH v2 1/2] dt-bindings: simple-pm-bus: Add optional resets
  2024-02-23 10:10 ` [PATCH v2 1/2] dt-bindings: simple-pm-bus: Add optional resets Yang Xiwen via B4 Relay
@ 2024-02-26  8:01   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2024-02-26  8:01 UTC (permalink / raw)
  To: forbidden405, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
	Geert Uytterhoeven, Philipp Zabel
  Cc: devicetree, linux-kernel

On 23/02/2024 11:10, Yang Xiwen via B4 Relay wrote:
> From: Yang Xiwen <forbidden405@outlook.com>
> 
> For some on-soc buses, it is also needed to deassert the resets before
> access. Document it in the binding.
> 
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> Signed-off-by: Yang Xiwen <forbidden405@outlook.com>
> ---
>  Documentation/devicetree/bindings/bus/simple-pm-bus.yaml | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/bus/simple-pm-bus.yaml b/Documentation/devicetree/bindings/bus/simple-pm-bus.yaml
> index 182134d7a6a3..430638104980 100644
> --- a/Documentation/devicetree/bindings/bus/simple-pm-bus.yaml
> +++ b/Documentation/devicetree/bindings/bus/simple-pm-bus.yaml
> @@ -14,8 +14,9 @@ description: |
>    driver, as it's typically initialized by the boot loader.
>  
>    However, its bus controller is part of a PM domain, or under the control
> -  of a functional clock.  Hence, the bus controller's PM domain and/or
> -  clock must be enabled for child devices connected to the bus (either
> +  of a functional clock, and it might have a reset control signal.  Hence,
> +  the bus controller's PM domain and/or clock must be enabled, reset control
> +  signal must be deasserted for child devices connected to the bus (either
>    on-SoC or externally) to function.
>  
>    While "simple-pm-bus" follows the "simple-bus" set of properties, as
> @@ -49,6 +50,8 @@ properties:
>      # Required if clocks is absent, optional otherwise
>      minItems: 1
>  
> +  resets: true

If you have to toggle some resets (and often actually in some order),
then it is not a simple-bus anymore.

This looks more and more like a one-binding-to-rule-them-all.

Especially that description clearly states: "does not need real driver"
and "typically initialized by the boot loader", but here I see more and
more of a driver, and more and more of doing things by Linux.

Best regards,
Krzysztof


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

end of thread, other threads:[~2024-02-26  8:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-23 10:10 [PATCH v2 0/2] simple-pm-bus: deassert resets if possible Yang Xiwen via B4 Relay
2024-02-23 10:10 ` [PATCH v2 1/2] dt-bindings: simple-pm-bus: Add optional resets Yang Xiwen via B4 Relay
2024-02-26  8:01   ` Krzysztof Kozlowski
2024-02-23 10:10 ` [PATCH v2 2/2] drivers: bus: simple-pm-bus: Get and deassert resets exclusively Yang Xiwen via B4 Relay

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

all inboxes | Powered by JetHome®