* [PATCH v1] clk: starfive: jh7110-sys: Set PLL0 rate to 1.5GHz
@ 2023-08-11 3:36 Xingyu Wu
2023-08-11 6:43 ` Conor Dooley
2023-08-14 7:34 ` Hal Feng
0 siblings, 2 replies; 6+ messages in thread
From: Xingyu Wu @ 2023-08-11 3:36 UTC (permalink / raw)
To: Michael Turquette, Stephen Boyd, Emil Renner Berthing
Cc: Conor Dooley, Hal Feng, Xingyu Wu, linux-kernel, linux-clk
Set PLL0 rate to 1.5GHz. Change the parent of cpu_root clock
and the divider of cpu_core before setting.
Signed-off-by: Xingyu Wu <xingyu.wu@starfivetech.com>
---
Hi Stephen and Emil,
This patch sets PLL0 rate to 1.5GHz. In order not to affect the cpu
operation, the cpu_root's parent clock should be changed first.
And the divider of the cpu_core clock should be set to 2 so they
won't crash when setting 1.5GHz without voltage regulation.
This patch is based on linux-next which has merge PLL driver on
StarFive JH7110 SoC.
Thanks,
Xingyu Wu
---
.../clk/starfive/clk-starfive-jh7110-sys.c | 47 ++++++++++++++++++-
1 file changed, 46 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/starfive/clk-starfive-jh7110-sys.c b/drivers/clk/starfive/clk-starfive-jh7110-sys.c
index 3884eff9fe93..b6b9e967dfc7 100644
--- a/drivers/clk/starfive/clk-starfive-jh7110-sys.c
+++ b/drivers/clk/starfive/clk-starfive-jh7110-sys.c
@@ -501,7 +501,52 @@ static int __init jh7110_syscrg_probe(struct platform_device *pdev)
if (ret)
return ret;
- return jh7110_reset_controller_register(priv, "rst-sys", 0);
+ ret = jh7110_reset_controller_register(priv, "rst-sys", 0);
+ if (ret)
+ return ret;
+
+ /*
+ * Set PLL0 rate to 1.5GHz
+ * In order to not affect the cpu when the PLL0 rate is changing,
+ * we need to switch the parent of cpu_root clock to osc clock first,
+ * and then switch back after setting the PLL0 rate.
+ */
+ pllclk = clk_get(priv->dev, "pll0_out");
+ if (!IS_ERR(pllclk)) {
+ struct clk *osc = clk_get(&pdev->dev, "osc");
+ struct clk *cpu_root = priv->reg[JH7110_SYSCLK_CPU_ROOT].hw.clk;
+ struct clk *cpu_core = priv->reg[JH7110_SYSCLK_CPU_CORE].hw.clk;
+
+ if (IS_ERR(osc)) {
+ clk_put(pllclk);
+ return PTR_ERR(osc);
+ }
+
+ /*
+ * CPU need voltage regulation by CPUfreq if set 1.5GHz.
+ * So in this driver, cpu_core need to be set the divider to be 2 first
+ * and will be 750M after setting parent.
+ */
+ ret = clk_set_rate(cpu_core, clk_get_rate(cpu_core) / 2);
+ if (ret)
+ goto failed_set;
+
+ ret = clk_set_parent(cpu_root, osc);
+ if (ret)
+ goto failed_set;
+
+ ret = clk_set_rate(pllclk, 1500000000);
+ if (ret)
+ goto failed_set;
+
+ ret = clk_set_parent(cpu_root, pllclk);
+
+failed_set:
+ clk_put(pllclk);
+ clk_put(osc);
+ }
+
+ return ret;
}
static const struct of_device_id jh7110_syscrg_match[] = {
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v1] clk: starfive: jh7110-sys: Set PLL0 rate to 1.5GHz
2023-08-11 3:36 [PATCH v1] clk: starfive: jh7110-sys: Set PLL0 rate to 1.5GHz Xingyu Wu
@ 2023-08-11 6:43 ` Conor Dooley
2023-08-14 3:06 ` Xingyu Wu
2023-08-14 7:34 ` Hal Feng
1 sibling, 1 reply; 6+ messages in thread
From: Conor Dooley @ 2023-08-11 6:43 UTC (permalink / raw)
To: Xingyu Wu
Cc: Michael Turquette, Stephen Boyd, Emil Renner Berthing,
Conor Dooley, Hal Feng, linux-kernel, linux-clk
[-- Attachment #1: Type: text/plain, Size: 705 bytes --]
On Fri, Aug 11, 2023 at 11:36:31AM +0800, Xingyu Wu wrote:
> Set PLL0 rate to 1.5GHz.
Why are you doing that though?
> Change the parent of cpu_root clock
> and the divider of cpu_core before setting.
>
> Signed-off-by: Xingyu Wu <xingyu.wu@starfivetech.com>
> ---
>
> Hi Stephen and Emil,
>
> This patch sets PLL0 rate to 1.5GHz. In order not to affect the cpu
> operation, the cpu_root's parent clock should be changed first.
> And the divider of the cpu_core clock should be set to 2 so they
> won't crash when setting 1.5GHz without voltage regulation.
>
> This patch is based on linux-next which has merge PLL driver on
> StarFive JH7110 SoC.
>
> Thanks,
> Xingyu Wu
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] clk: starfive: jh7110-sys: Set PLL0 rate to 1.5GHz
2023-08-11 6:43 ` Conor Dooley
@ 2023-08-14 3:06 ` Xingyu Wu
2023-08-14 6:57 ` Conor Dooley
0 siblings, 1 reply; 6+ messages in thread
From: Xingyu Wu @ 2023-08-14 3:06 UTC (permalink / raw)
To: Conor Dooley
Cc: Michael Turquette, Stephen Boyd, Emil Renner Berthing,
Conor Dooley, Hal Feng, linux-kernel, linux-clk
On 2023/8/11 14:43, Conor Dooley wrote:
> On Fri, Aug 11, 2023 at 11:36:31AM +0800, Xingyu Wu wrote:
>> Set PLL0 rate to 1.5GHz.
>
> Why are you doing that though?
Because the CPU frequency scaling is based on 1.5GHz rate on JH7110 SoC.
And now the PLL clock driver has been accepted and PLL0 is just 1GHz[1].
[1] https://github.com/starfive-tech/VisionFive2/issues/55
We should set the PLL0 rate to a correct rate (1.5GHz) and then
the CPUfreq will work normally.
Best regards,
Xingyu Wu
>
>
>> Change the parent of cpu_root clock
>> and the divider of cpu_core before setting.
>>
>> Signed-off-by: Xingyu Wu <xingyu.wu@starfivetech.com>
>> ---
>>
>> Hi Stephen and Emil,
>>
>> This patch sets PLL0 rate to 1.5GHz. In order not to affect the cpu
>> operation, the cpu_root's parent clock should be changed first.
>> And the divider of the cpu_core clock should be set to 2 so they
>> won't crash when setting 1.5GHz without voltage regulation.
>>
>> This patch is based on linux-next which has merge PLL driver on
>> StarFive JH7110 SoC.
>>
>> Thanks,
>> Xingyu Wu
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] clk: starfive: jh7110-sys: Set PLL0 rate to 1.5GHz
2023-08-14 3:06 ` Xingyu Wu
@ 2023-08-14 6:57 ` Conor Dooley
2023-08-14 7:28 ` Xingyu Wu
0 siblings, 1 reply; 6+ messages in thread
From: Conor Dooley @ 2023-08-14 6:57 UTC (permalink / raw)
To: Xingyu Wu
Cc: Michael Turquette, Stephen Boyd, Emil Renner Berthing,
Conor Dooley, Hal Feng, linux-kernel, linux-clk
[-- Attachment #1: Type: text/plain, Size: 1377 bytes --]
On Mon, Aug 14, 2023 at 11:06:05AM +0800, Xingyu Wu wrote:
> On 2023/8/11 14:43, Conor Dooley wrote:
> > On Fri, Aug 11, 2023 at 11:36:31AM +0800, Xingyu Wu wrote:
> >> Set PLL0 rate to 1.5GHz.
> >
> > Why are you doing that though?
>
> Because the CPU frequency scaling is based on 1.5GHz rate on JH7110 SoC.
> And now the PLL clock driver has been accepted and PLL0 is just 1GHz[1].
> [1] https://github.com/starfive-tech/VisionFive2/issues/55
>
> We should set the PLL0 rate to a correct rate (1.5GHz) and then
> the CPUfreq will work normally.
Please include an explanation in the commit message of the problem this
is addressing.
Also, a Fixes: tag + reported-by?
> Best regards,
> Xingyu Wu
>
> >
> >
> >> Change the parent of cpu_root clock
> >> and the divider of cpu_core before setting.
> >>
> >> Signed-off-by: Xingyu Wu <xingyu.wu@starfivetech.com>
> >> ---
> >>
> >> Hi Stephen and Emil,
> >>
> >> This patch sets PLL0 rate to 1.5GHz. In order not to affect the cpu
> >> operation, the cpu_root's parent clock should be changed first.
> >> And the divider of the cpu_core clock should be set to 2 so they
> >> won't crash when setting 1.5GHz without voltage regulation.
> >>
> >> This patch is based on linux-next which has merge PLL driver on
> >> StarFive JH7110 SoC.
> >>
> >> Thanks,
> >> Xingyu Wu
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] clk: starfive: jh7110-sys: Set PLL0 rate to 1.5GHz
2023-08-14 6:57 ` Conor Dooley
@ 2023-08-14 7:28 ` Xingyu Wu
0 siblings, 0 replies; 6+ messages in thread
From: Xingyu Wu @ 2023-08-14 7:28 UTC (permalink / raw)
To: Conor Dooley
Cc: Michael Turquette, Stephen Boyd, Emil Renner Berthing,
Conor Dooley, Hal Feng, linux-kernel, linux-clk
On 2023/8/14 14:57, Conor Dooley wrote:
> On Mon, Aug 14, 2023 at 11:06:05AM +0800, Xingyu Wu wrote:
>> On 2023/8/11 14:43, Conor Dooley wrote:
>> > On Fri, Aug 11, 2023 at 11:36:31AM +0800, Xingyu Wu wrote:
>> >> Set PLL0 rate to 1.5GHz.
>> >
>> > Why are you doing that though?
>>
>> Because the CPU frequency scaling is based on 1.5GHz rate on JH7110 SoC.
>> And now the PLL clock driver has been accepted and PLL0 is just 1GHz[1].
>> [1] https://github.com/starfive-tech/VisionFive2/issues/55
>>
>> We should set the PLL0 rate to a correct rate (1.5GHz) and then
>> the CPUfreq will work normally.
>
> Please include an explanation in the commit message of the problem this
> is addressing.
>
> Also, a Fixes: tag + reported-by?
>
OK, I will add the explanation in next version as a fixes patch.
Thanks,
Xingyu Wu
>> >
>> >
>> >> Change the parent of cpu_root clock
>> >> and the divider of cpu_core before setting.
>> >>
>> >> Signed-off-by: Xingyu Wu <xingyu.wu@starfivetech.com>
>> >> ---
>> >>
>> >> Hi Stephen and Emil,
>> >>
>> >> This patch sets PLL0 rate to 1.5GHz. In order not to affect the cpu
>> >> operation, the cpu_root's parent clock should be changed first.
>> >> And the divider of the cpu_core clock should be set to 2 so they
>> >> won't crash when setting 1.5GHz without voltage regulation.
>> >>
>> >> This patch is based on linux-next which has merge PLL driver on
>> >> StarFive JH7110 SoC.
>> >>
>> >> Thanks,
>> >> Xingyu Wu
>>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v1] clk: starfive: jh7110-sys: Set PLL0 rate to 1.5GHz
2023-08-11 3:36 [PATCH v1] clk: starfive: jh7110-sys: Set PLL0 rate to 1.5GHz Xingyu Wu
2023-08-11 6:43 ` Conor Dooley
@ 2023-08-14 7:34 ` Hal Feng
1 sibling, 0 replies; 6+ messages in thread
From: Hal Feng @ 2023-08-14 7:34 UTC (permalink / raw)
To: Xingyu Wu, Michael Turquette, Stephen Boyd, Emil Renner Berthing
Cc: Conor Dooley, linux-kernel, linux-clk
On Fri, 11 Aug 2023 11:36:31 +0800, Xingyu Wu wrote:
> Set PLL0 rate to 1.5GHz. Change the parent of cpu_root clock
> and the divider of cpu_core before setting.
>
> Signed-off-by: Xingyu Wu <xingyu.wu@starfivetech.com>
Reviewed-by: Hal Feng <hal.feng@starfivetech.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-08-14 7:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-11 3:36 [PATCH v1] clk: starfive: jh7110-sys: Set PLL0 rate to 1.5GHz Xingyu Wu
2023-08-11 6:43 ` Conor Dooley
2023-08-14 3:06 ` Xingyu Wu
2023-08-14 6:57 ` Conor Dooley
2023-08-14 7:28 ` Xingyu Wu
2023-08-14 7:34 ` Hal Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox