[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240223-b4-bus-v1-2-2803c3ac4673@outlook.com>
Date: Fri, 23 Feb 2024 11:49:47 +0800
From: Yang Xiwen via B4 Relay <devnull+forbidden405.outlook.com@...nel.org>
To: Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>,
Geert Uytterhoeven <geert+renesas@...der.be>,
Philipp Zabel <p.zabel@...gutronix.de>
Cc: devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
Yang Xiwen <forbidden405@...look.com>
Subject: [PATCH 2/2] drivers: bus: simple-pm-bus: Get and deassert resets
exclusively
From: Yang Xiwen <forbidden405@...look.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.
Signed-off-by: Yang Xiwen <forbidden405@...look.com>
---
drivers/bus/simple-pm-bus.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/drivers/bus/simple-pm-bus.c b/drivers/bus/simple-pm-bus.c
index 50870c827889..d84dbd61c02b 100644
--- a/drivers/bus/simple-pm-bus.c
+++ b/drivers/bus/simple-pm-bus.c
@@ -16,9 +16,11 @@
#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;
};
@@ -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(dev, false, true);
+ 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
Powered by blists - more mailing lists