[PATCH 2/2] clk: scmi: limit clocks to the rate range reported by the firmware
Ahmad Fatoum
a.fatoum at barebox.org
Wed Nov 25 09:33:45 PST 2026
From: Ahmad Fatoum <a.fatoum at pengutronix.de>
Linux clk-scmi driver registers the lowest and highest rate of each
clock as rate range and the clock core clamps all requests to it.
barebox didn't and so in the incoming Amlogic A9 support, TF-A would
report:
NOTICE: fclk_div2 does not allow modification through scmi-clk
because determine_rate returned the requested rate as is and the clock
framework assumed the clock can run at any rate.
Now that barebox supports rate ranges as well, do as Linux does.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
drivers/clk/clk-scmi.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c
index 79e2c65f847d..ddccd568b723 100644
--- a/drivers/clk/clk-scmi.c
+++ b/drivers/clk/clk-scmi.c
@@ -179,6 +179,7 @@ static int scmi_clk_is_enabled(struct clk_hw *hw)
static int scmi_clk_ops_init(struct device *dev, struct scmi_clk *sclk,
const struct clk_ops *scmi_ops)
{
+ unsigned long min_rate, max_rate;
int ret;
struct clk_init_data init = {
@@ -199,9 +200,18 @@ static int scmi_clk_ops_init(struct device *dev, struct scmi_clk *sclk,
if (num_rates <= 0)
return -EINVAL;
+
+ /* the rates are sorted in ascending order */
+ min_rate = sclk->info->list.rates[0];
+ max_rate = sclk->info->list.rates[num_rates - 1];
+ } else {
+ min_rate = sclk->info->range.min_rate;
+ max_rate = sclk->info->range.max_rate;
}
- return ret;
+ clk_hw_set_rate_range(&sclk->hw, min_rate, max_rate);
+
+ return 0;
}
/**
--
2.47.3
More information about the barebox
mailing list