From: Chuan Liu <chuan.liu@amlogic.com>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: "Christian Hewitt" <christianshewitt@gmail.com>,
"Viresh Kumar" <viresh.kumar@linaro.org>,
"Jerome Brunet" <jbrunet@baylibre.com>,
christian.koever-draxl@student.uibk.ac.at,
neil.armstrong@linaro.org, sboyd@kernel.org,
bmasney+clk@redhat.com, khilman@baylibre.com, rafael@kernel.org,
robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org,
linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
"Christian Stefan Kövér-Draxl" <ckoever@outlook.de>
Subject: Re: [PATCH 4/4] cpufreq: add an Amlogic speed-bin driver
Date: Mon, 23 Nov 2026 20:23:59 +0800 [thread overview]
Message-ID: <b606819a-661e-4488-b5fb-9e786de463c6@amlogic.com> (raw)
In-Reply-To: <CAFBinCCgmRmk--W53wqdJhF-SzJbai--s7wyzDNt3LpfN00spw@mail.gmail.com>
Hi Viresh, Cc Martin,
I've run into some issues while adapting the Amlogic A9 to
cpufreq-dt to support the coordinated adjustment of multiple clocks, and
I'd like to ask for your opinion.
On 11/9/2026 5:45 AM, Martin Blumenstingl wrote:
> [ EXTERNAL EMAIL ]
>
> On Tue, Nov 3, 2026 at 10:46 AM Chuan Liu <chuan.liu@amlogic.com> wrote:
>>
>> Hi Martin,
>> Thank you for joining this discussion. :)
>>
>> I have re-examined the capabilities provided by pm_opp and cpufreq-dt,
>> and it seems that we may also be able to adapt A9 fairly well based on
>> the amlogic-cpufreq.c here. So we have no objections to the driver
>> implementation in amlogic-cpufreq.c here.
>>
>> I was most worried about before was that cpufreq-dt might not fully
>> handle the complicated clock and supply adjustment logic between
>> multiple clusters, which would have required adding a separate
>> cpufreq_driver. But it now looks like this can be solved by adding the
>> corresponding config_clks() and config_regulators() callbacks in
>> dev_pm_opp_set_config().
Our original intention was to try to structure our Amlogic cpufreq
driver around cpufreq-dt.
> That's great news, indeed!
>
> [...]
>> All in all, it looks like we can currently support all Amlogic SoCs in a
>> single amlogic-cpufreq.c? Then, for the specific characteristics of
>> different SoCs, we can differentiate them through the "compatible"
>> property and add the corresponding drvdata for each.
>>
>> I'll also try to support S7/A9 with representative differences based on
>> this patch.
I have already completed the support on A9, but cpufreq-dt currently
only supports the single-clock case, for example:
dt_cpufreq_early_init()
->dev_pm_opp_init_cpufreq_table()
->dev_pm_opp_find_freq_ceil()
->_find_key_ceil()
->assert_single_clk()
set_target()
->dev_pm_opp_set_rate()
->_find_freq_ceil()
->assert_single_clk()
Both of the interfaces above are limited to "single_clk", so SoCs that
need to adjust the DSU clock in coordination with the CPU clock (such as
SM1, S7, A9, etc. mentioned above) cannot directly work on top of
cpufreq-dt.
I changed assert_single_clk() to assert_clk_index() in the two functions
above and it works, but I'm afraid such a brute-force change may break
the semantics of the original APIs.
To support the Amlogic cpufreq driver coordinating the adjustment of
multiple clocks as specified, We can currently think of three approaches:
1) Extend the cpufreq-dt/OPP function interfaces, for example:
- Add dev_pm_opp_init_cpufreq_table_indexed() and
dev_pm_opp_set_rate_indexed()
- Adapt cpufreq-dt to these newly added functions, sample changes:
diff --git a/drivers/cpufreq/cpufreq-dt.c b/drivers/cpufreq/cpufreq-dt.c
index 7d5079fd16882..8940d36f2371d 100644
--- a/drivers/cpufreq/cpufreq-dt.c
+++ b/drivers/cpufreq/cpufreq-dt.c
@@ -53,7 +53,7 @@ static int set_target(struct cpufreq_policy *policy,
unsigned int index)
struct private_data *priv = policy->driver_data;
unsigned long freq = policy->freq_table[index].frequency;
- return dev_pm_opp_set_rate(priv->cpu_dev, freq * 1000);
+ return dev_pm_opp_set_rate_indexed(priv->cpu_dev, freq * 1000, 0);
}
/*
@@ -245,7 +245,7 @@ static int dt_cpufreq_early_init(struct device *dev,
int cpu)
__func__, ret);
}
- ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &priv->freq_table);
+ ret = dev_pm_opp_init_cpufreq_table_indexed(cpu_dev,
&priv->freq_table, 0);
if (ret) {
dev_err(cpu_dev, "failed to init cpufreq table: %d\n",
ret);
goto out;
2) Keep cpufreq-dt and adjust the DSU clock synchronously when adjusting
the CPU clock in config_clks(), only a single CPU clock is kept in
"struct dev_pm_opp_config config.clk_names".
3) Create a separate Amlogic cpufreq driver independent of cpufreq-dt
(similar to mediatek-cpufreq.c)
Which approach would you prefer? Do you have any better suggestions?
> Great, let's look at some code rather than discussing theory on how to
> write code :-)
>
> There's one last detail that we have to manage in case we also want to
> include the Meson8* code into the same file:
> config MESON_SM depends on ARM64_4K_PAGES
> 32-bit kernel builds can't satisfy this (meaning: we end up with
> linker errors). I think a simple way to get around this is to add stub
> functions to include/linux/firmware/meson/meson_sm.h.
> I'll take care of that once I can submit Meson8 support patches for
> your upcoming amlogic-cpufreq.c!
>
>
> Best regards,
> Martin
--
Best regards,
Chuan
next prev parent reply other threads:[~2026-11-23 12:24 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 19:22 [PATCH 0/4] arm64: amlogic: S4 CPU frequency scaling christian.koever-draxl
2026-10-25 19:22 ` [PATCH 1/4] dt-bindings: clock: amlogic,s4-pll-clkc: add the CPU clock christian.koever-draxl
2026-10-30 11:15 ` Krzysztof Kozlowski
2026-10-25 19:22 ` [PATCH 2/4] clk: meson: s4-pll: " christian.koever-draxl
2026-10-25 19:22 ` [PATCH 3/4] firmware: meson: sm: add the CPU speed bin call christian.koever-draxl
2026-10-25 19:22 ` [PATCH 4/4] cpufreq: add an Amlogic speed-bin driver christian.koever-draxl
2026-10-26 5:30 ` Viresh Kumar
2026-10-26 8:57 ` Jerome Brunet
2026-10-26 8:59 ` Viresh Kumar
2026-10-26 10:08 ` Christain Stefan Köver-Draxl
2026-10-27 9:26 ` Chuan Liu
2026-10-27 10:22 ` Christian Hewitt
2026-10-29 5:29 ` Chuan Liu
2026-11-01 22:51 ` Martin Blumenstingl
2026-11-03 9:45 ` Chuan Liu
2026-11-08 21:45 ` Martin Blumenstingl
2026-11-09 8:44 ` neil.armstrong
2026-11-13 14:32 ` Jerome Brunet
2026-11-23 12:23 ` Chuan Liu [this message]
2026-11-06 8:56 ` Christain Stefan Köver-Draxl
2026-10-26 10:10 ` Christain Stefan Köver-Draxl
2026-10-27 9:31 ` Chuan Liu
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=b606819a-661e-4488-b5fb-9e786de463c6@amlogic.com \
--to=chuan.liu@amlogic.com \
--cc=bmasney+clk@redhat.com \
--cc=christian.koever-draxl@student.uibk.ac.at \
--cc=christianshewitt@gmail.com \
--cc=ckoever@outlook.de \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=neil.armstrong@linaro.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=sboyd@kernel.org \
--cc=viresh.kumar@linaro.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®