mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Subject: [PATCH 2/2] clk: scmi: limit clocks to the rate range reported by the firmware
Date: Wed, 25 Nov 2026 18:33:45 +0100	[thread overview]
Message-ID: <20261125173348.1514894-2-a.fatoum@barebox.org> (raw)
In-Reply-To: <20261125173348.1514894-1-a.fatoum@barebox.org>

From: Ahmad Fatoum <a.fatoum@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@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




      reply	other threads:[~2026-11-25 17:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 17:33 [PATCH 1/2] clk: add clk_hw_set_rate_range() Ahmad Fatoum
2026-11-25 17:33 ` Ahmad Fatoum [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261125173348.1514894-2-a.fatoum@barebox.org \
    --to=a.fatoum@barebox.org \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox