lkml.org 
[lkml]   [2022]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 1/2] clk: add support for critical always-on clocks
Date
Add support to mark specific clocks as always-on (critical), like the
regulator-alawys-on property. So the platform integrators can specify
the property on a per device basis by specifying it within the firmware
and not only within the driver. Unlike the regulator framework the clock
framework uses a 1:n matching, which means 1 firmware node can provide
up to n clock providers. Therefore the binding uses a string-array so we
can specify n clock providers as critical.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
drivers/clk/clk.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 7fc191c15507..c3651bf96f90 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -3825,6 +3825,22 @@ static int clk_cpy_name(const char **dst_p, const char *src, bool must_exist)
return 0;
}

+static void clk_core_check_critical(struct clk_core *core)
+{
+ struct fwnode_handle *fwnode = of_fwnode_handle(core->of_node);
+ const char *prop = "clocks-always-on";
+ int ret;
+
+ /* Very early added clocks don't have a fwnode */
+ if (!fwnode || !fwnode_property_present(fwnode, prop))
+ return;
+
+ /* Mark clock as critical if listed within the clocks-always-on array */
+ ret = fwnode_property_match_string(fwnode, prop, core->name);
+ if (!ret)
+ core->flags |= CLK_IS_CRITICAL;
+}
+
static int clk_core_populate_parent_map(struct clk_core *core,
const struct clk_init_data *init)
{
@@ -3946,6 +3962,8 @@ __clk_register(struct device *dev, struct device_node *np, struct clk_hw *hw)
core->min_rate = 0;
core->max_rate = ULONG_MAX;

+ clk_core_check_critical(core);
+
ret = clk_core_populate_parent_map(core, init);
if (ret)
goto fail_parents;
--
2.30.2
\
 
 \ /
  Last update: 2022-09-13 12:23    [W:0.070 / U:0.068 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site