From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: Rob Herring <robh@kernel.org>,
Saravana Kannan <saravanak@google.com>,
Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Luca Ceresoli <luca.ceresoli@bootlin.com>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-clk@vger.kernel.org, Peng Fan <peng.fan@nxp.com>
Subject: [PATCH v3 2/2] clk: clk-conf: support assigned-clock-rates-u64
Date: Tue, 30 Jul 2024 16:57:55 +0800 [thread overview]
Message-ID: <20240730-clk-u64-v3-2-4d2b19edaa6e@nxp.com> (raw)
In-Reply-To: <20240730-clk-u64-v3-0-4d2b19edaa6e@nxp.com>
From: Peng Fan <peng.fan@nxp.com>
i.MX95 System Management Control Firmware(SCMI) manages the clock
function, it exposes PLL VCO which could support up to 5GHz rate that
exceeds UINT32_MAX. So add assigned-clock-rates-u64 support
to set rate that exceeds UINT32_MAX.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/clk/clk-conf.c | 42 +++++++++++++++++++++++++++++++++++++-----
1 file changed, 37 insertions(+), 5 deletions(-)
diff --git a/drivers/clk/clk-conf.c b/drivers/clk/clk-conf.c
index 058420562020..684e0c0738b3 100644
--- a/drivers/clk/clk-conf.c
+++ b/drivers/clk/clk-conf.c
@@ -81,11 +81,44 @@ static int __set_clk_parents(struct device_node *node, bool clk_supplier)
static int __set_clk_rates(struct device_node *node, bool clk_supplier)
{
struct of_phandle_args clkspec;
- int rc, index = 0;
+ int rc, count, index;
struct clk *clk;
- u32 rate;
+ u32 *rates __free(kfree);
+ bool rate_64 = false;
+
+ count = of_property_count_u64_elems(node, "assigned-clock-rates-u64");
+ if (count <= 0) {
+ count = of_property_count_u32_elems(node, "assigned-clock-rates");
+ if (count <= 0)
+ return 0;
+
+ rates = kcalloc(count, sizeof(u32), GFP_KERNEL);
+ if (!rates)
+ return -ENOMEM;
+ rc = of_property_read_variable_u32_array(node,
+ "assigned-clock-rates",
+ rates,
+ 1, count);
+ } else {
+ rates = kcalloc(count, sizeof(u64), GFP_KERNEL);
+ if (!rates)
+ return -ENOMEM;
+ rc = of_property_read_variable_u64_array(node,
+ "assigned-clock-rates-u64",
+ (u64 *)rates,
+ 1, count);
+ rate_64 = true;
+ }
+
+
+ for (index = 0; index < count; index++) {
+ unsigned long rate;
+
+ if (rate_64)
+ rate = ((u64 *)rates)[index];
+ else
+ rate = rates[index];
- of_property_for_each_u32(node, "assigned-clock-rates", rate) {
if (rate) {
rc = of_parse_phandle_with_args(node, "assigned-clocks",
"#clock-cells", index, &clkspec);
@@ -112,12 +145,11 @@ static int __set_clk_rates(struct device_node *node, bool clk_supplier)
rc = clk_set_rate(clk, rate);
if (rc < 0)
- pr_err("clk: couldn't set %s clk rate to %u (%d), current rate: %lu\n",
+ pr_err("clk: couldn't set %s clk rate to %lu (%d), current rate: %lu\n",
__clk_get_name(clk), rate, rc,
clk_get_rate(clk));
clk_put(clk);
}
- index++;
}
return 0;
}
--
2.37.1
next prev parent reply other threads:[~2024-07-30 8:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-30 8:57 [PATCH v3 0/2] clk: add assigned-clock-rates-u64 Peng Fan (OSS)
2024-07-30 8:57 ` [PATCH v3 1/2] of: property: add of_property_for_each_u64 Peng Fan (OSS)
2024-07-30 8:57 ` Peng Fan (OSS) [this message]
2024-07-31 22:23 ` [PATCH v3 2/2] clk: clk-conf: support assigned-clock-rates-u64 Stephen Boyd
2024-08-01 0:33 ` Peng Fan
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=20240730-clk-u64-v3-2-4d2b19edaa6e@nxp.com \
--to=peng.fan@oss.nxp.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luca.ceresoli@bootlin.com \
--cc=mturquette@baylibre.com \
--cc=peng.fan@nxp.com \
--cc=robh@kernel.org \
--cc=saravanak@google.com \
--cc=sboyd@kernel.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;
as well as URLs for NNTP newsgroup(s).