[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250814-platform-delay-clk-defaults-v1-1-4aae5b33512f@linaro.org>
Date: Thu, 14 Aug 2025 11:18:06 +0200
From: Stephan Gerhold <stephan.gerhold@...aro.org>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Rafael J. Wysocki" <rafael@...nel.org>, Danilo Krummrich <dakr@...nel.org>,
Stephen Boyd <sboyd@...nel.org>,
Michael Turquette <mturquette@...libre.com>,
Dmitry Baryshkov <lumag@...nel.org>
Cc: Rob Clark <robin.clark@....qualcomm.com>,
Abhinav Kumar <abhinav.kumar@...ux.dev>,
Jessica Zhang <jessica.zhang@....qualcomm.com>, Sean Paul <sean@...rly.run>,
Marijn Suijten <marijn.suijten@...ainline.org>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
Rob Herring <robh@...nel.org>, Conor Dooley <conor+dt@...nel.org>,
linux-kernel@...r.kernel.org, linux-clk@...r.kernel.org,
devicetree@...r.kernel.org, linux-arm-msm@...r.kernel.org,
dri-devel@...ts.freedesktop.org, freedreno@...ts.freedesktop.org,
Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
Abel Vesa <abel.vesa@...aro.org>, Michael Walle <mwalle@...nel.org>,
Bjorn Andersson <andersson@...nel.org>,
Konrad Dybcio <konradybcio@...nel.org>,
Neil Armstrong <neil.armstrong@...aro.org>
Subject: [PATCH 1/2] driver core: platform: Add option to skip/delay
applying clock defaults
Currently, the platform driver core always calls of_clk_set_defaults()
before calling the driver probe() function. This will apply any
"assigned-clock-parents" and "assigned-clock-rates" specified in the device
tree. However, in some situations, these defaults cannot be safely applied
before the driver has performed some early initialization. Otherwise, the
clock operations might fail or the device could malfunction.
Add a "driver_managed_clk_defaults" option to the platform_driver struct,
similar to the existing "driver_managed_dma" option. If this option is set,
applying the clock defaults is skipped in the platform driver core and the
driver must do this itself when ready.
Signed-off-by: Stephan Gerhold <stephan.gerhold@...aro.org>
---
drivers/base/platform.c | 8 +++++---
include/linux/platform_device.h | 6 ++++++
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 09450349cf32364bcb3c8dd94023406442ec204d..c7278ace71d3f6d473fdea35bf79bcf80a56ee21 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1392,9 +1392,11 @@ static int platform_probe(struct device *_dev)
if (unlikely(drv->probe == platform_probe_fail))
return -ENXIO;
- ret = of_clk_set_defaults(_dev->of_node, false);
- if (ret < 0)
- return ret;
+ if (!drv->driver_managed_clk_defaults) {
+ ret = of_clk_set_defaults(_dev->of_node, false);
+ if (ret < 0)
+ return ret;
+ }
ret = dev_pm_domain_attach(_dev, PD_FLAG_ATTACH_POWER_ON |
PD_FLAG_DETACH_POWER_OFF);
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 074754c23d330c9a099e20eecfeb6cbd5025e04f..fa561dae2f106b61d868a870e10d9656542b1c7e 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -250,6 +250,12 @@ struct platform_driver {
* to setup and manage their own I/O address space.
*/
bool driver_managed_dma;
+ /*
+ * Skip calling of_clk_set_defaults() before calling the probe function.
+ * Use this if the driver needs to perform some initialization before
+ * clock defaults (parent, rates) are applied.
+ */
+ bool driver_managed_clk_defaults;
};
#define to_platform_driver(drv) (container_of((drv), struct platform_driver, \
--
2.50.1
Powered by blists - more mailing lists