From: Chuan Liu via B4 Relay <devnull+chuan.liu.amlogic.com@kernel.org>
To: Viresh Kumar <vireshk@kernel.org>, Nishanth Menon <nm@ti.com>,
Stephen Boyd <sboyd@kernel.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Chuan Liu <chuan.liu@amlogic.com>
Subject: [PATCH] opp: Allow multiple clocks for primary clock operations
Date: Tue, 01 Dec 2026 17:34:08 +0800 [thread overview]
Message-ID: <20261201-opp_core-v1-1-c43c8f010b5f@amlogic.com> (raw)
From: Chuan Liu <chuan.liu@amlogic.com>
The OPP core supports configuring multiple clocks through the
config_clks callback, but some of its helpers still require the
OPP table to have only one clock.
The CPUFreq helpers use the primary clock (index 0) to build the
frequency table and find the target OPP. They don't require the
OPP table to contain only one clock.
Use assert_clk_index() instead of assert_single_clk() in these
helpers to allow CPUFreq to work with multi-clock OPP tables.
Also, keep the primary clock in opp_table->clk for OPP helpers
that use it to round the target frequency and find the current
OPP. The additional clocks continue to be managed through
opp_table->clks and the config_clks callback.
Signed-off-by: Chuan Liu <chuan.liu@amlogic.com>
---
This change is motivated by the Amlogic CPUFreq support discussed in the
following series:
https://lore.kernel.org/all/awgLGFpH73_fcnbC@vireshk-B250M-D3H/
Some Amlogic SoCs require the DSU clock to scale alongside the CPU
clock. The OPP core already provides multi-clock configuration through
config_clks, but the single-clock checks in the CPUFreq OPP lookup path
prevent this functionality from being used with cpufreq-dt.
This patch removes that limitation for the primary-clock lookup path,
allowing cpufreq-dt to benefit from the existing multi-clock OPP
support.
The changes are kept intentionally narrow. Other uses of
assert_single_clk() are left unchanged, as they may rely on single-clock
semantics and are not required for this use case. This avoids changing
the behavior of unrelated OPP paths.
---
drivers/opp/core.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index 4ccce7b6afcb..089d7327d70f 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -766,7 +766,7 @@ static noinline struct dev_pm_opp *_find_freq_ceil(struct opp_table *opp_table,
unsigned long *freq)
{
return _opp_table_find_key_ceil(opp_table, freq, 0, true, _read_freq,
- assert_single_clk);
+ assert_clk_index);
}
/**
@@ -790,7 +790,7 @@ static noinline struct dev_pm_opp *_find_freq_ceil(struct opp_table *opp_table,
struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev,
unsigned long *freq)
{
- return _find_key_ceil(dev, freq, 0, true, _read_freq, assert_single_clk);
+ return _find_key_ceil(dev, freq, 0, true, _read_freq, assert_clk_index);
}
EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_ceil);
@@ -2376,24 +2376,24 @@ static int _opp_set_clknames(struct opp_table *opp_table, struct device *dev,
opp_table->clk_count = count;
opp_table->config_clks = config_clks;
+ /*
+ * We could have just dropped the "clk" field and used "clks"
+ * everywhere. Instead we kept the "clk" field around for
+ * following reasons:
+ *
+ * - avoiding clks[0] everywhere else.
+ * - not running single clk helpers for multiple clk usecase by
+ * mistake.
+ *
+ * Since some OPP helpers still rely on the primary clock, update
+ * the "clk" pointer to the first clock.
+ */
+ opp_table->clk = opp_table->clks[0];
+
/* Set generic single clk set here */
if (count == 1) {
if (!opp_table->config_clks)
opp_table->config_clks = _opp_config_clk_single;
-
- /*
- * We could have just dropped the "clk" field and used "clks"
- * everywhere. Instead we kept the "clk" field around for
- * following reasons:
- *
- * - avoiding clks[0] everywhere else.
- * - not running single clk helpers for multiple clk usecase by
- * mistake.
- *
- * Since this is single-clk case, just update the clk pointer
- * too.
- */
- opp_table->clk = opp_table->clks[0];
}
return 0;
---
base-commit: e237d3ab5ea30ff98c8ca66457863454ec60e4a8
change-id: 20261130-opp_core-1011347b946d
Best regards,
--
Chuan Liu <chuan.liu@amlogic.com>
next reply other threads:[~2026-12-01 9:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 9:34 Chuan Liu via B4 Relay [this message]
2026-12-01 10:12 ` Viresh Kumar
2026-12-01 13:01 ` Chuan Liu
2026-12-01 13:50 ` Zhongqiu Han
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=20261201-opp_core-v1-1-c43c8f010b5f@amlogic.com \
--to=devnull+chuan.liu.amlogic.com@kernel.org \
--cc=chuan.liu@amlogic.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=nm@ti.com \
--cc=sboyd@kernel.org \
--cc=vireshk@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
all inboxes | Powered by JetHome®