Skip to content

Commit 6a8a9d1

Browse files
SuperKaliigorpecovnik
authored andcommitted
u-boot/rockchip-rk3588: raise CPU clocks through SCMI on mainline
Mainline U-Boot leaves the CPU clusters on the 24 MHz oscillator until kernel cpufreq init, a 23 MiB initramfs unpack took 64 seconds on a big core. Raise them to 1008 MHz via SCMI, general since every rk3588 board on v2026.04 is affected. Signed-off-by: SuperKali <hello@superkali.me>
1 parent 94e7236 commit 6a8a9d1

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: SuperKali <hello@superkali.me>
3+
Date: Sat, 4 Jul 2026 15:14:08 +0200
4+
Subject: clk: rockchip: rk3588: raise CPU clocks through SCMI in U-Boot proper
5+
6+
The CPU clusters leave reset on the 24 MHz oscillator and nothing
7+
raises them before OS cpufreq takes over, so early boot work landing
8+
on a big core crawls: a 23 MiB initramfs unpack took 64 seconds, 0.7
9+
after this change. Raise the clusters to 1008 MHz via SCMI, letting
10+
BL31 handle the PVTPLL sequencing, as the vendor U-Boot does.
11+
12+
Signed-off-by: SuperKali <hello@superkali.me>
13+
---
14+
arch/arm/include/asm/arch-rockchip/cru_rk3588.h | 6 ++
15+
drivers/clk/rockchip/clk_rk3588.c | 35 ++++++++++
16+
2 files changed, 41 insertions(+)
17+
18+
diff --git a/arch/arm/include/asm/arch-rockchip/cru_rk3588.h b/arch/arm/include/asm/arch-rockchip/cru_rk3588.h
19+
index 111111111111..222222222222 100644
20+
--- a/arch/arm/include/asm/arch-rockchip/cru_rk3588.h
21+
+++ b/arch/arm/include/asm/arch-rockchip/cru_rk3588.h
22+
@@ -17,6 +17,12 @@
23+
#define NPLL_HZ (850 * MHz)
24+
#define PPLL_HZ (1100 * MHz)
25+
#define SPLL_HZ (702 * MHz)
26+
+#define CPU_PVTPLL_HZ (1008 * MHz)
27+
+
28+
+/* SCMI clock ids, from dt-bindings/clock/rockchip,rk3588-cru.h */
29+
+#define SCMI_CLK_CPUL 0
30+
+#define SCMI_CLK_CPUB01 2
31+
+#define SCMI_CLK_CPUB23 3
32+
33+
/* RK3588 pll id */
34+
enum rk3588_pll_id {
35+
diff --git a/drivers/clk/rockchip/clk_rk3588.c b/drivers/clk/rockchip/clk_rk3588.c
36+
index 111111111111..222222222222 100644
37+
--- a/drivers/clk/rockchip/clk_rk3588.c
38+
+++ b/drivers/clk/rockchip/clk_rk3588.c
39+
@@ -1958,6 +1958,37 @@ static void rk3588_clk_init(struct rk3588_clk_priv *priv)
40+
(ACLK_TOP_S200_SEL_200M << ACLK_TOP_S200_SEL_SHIFT));
41+
}
42+
43+
+#if CONFIG_IS_ENABLED(CLK_SCMI) && !defined(CONFIG_XPL_BUILD)
44+
+/*
45+
+ * The CPU clusters leave reset clocked from the 24 MHz oscillator.
46+
+ * Raise them through SCMI so BL31 handles the PVTPLL sequencing.
47+
+ */
48+
+static void rk3588_clk_raise_cpu_clocks(void)
49+
+{
50+
+ const ulong scmi_cpu_clks[] = {
51+
+ SCMI_CLK_CPUL, SCMI_CLK_CPUB01, SCMI_CLK_CPUB23
52+
+ };
53+
+ struct udevice *scmi_dev;
54+
+ struct clk clk;
55+
+ int ret, i;
56+
+
57+
+ ret = uclass_get_device_by_driver(UCLASS_CLK,
58+
+ DM_DRIVER_GET(scmi_clock),
59+
+ &scmi_dev);
60+
+ if (ret)
61+
+ return;
62+
+
63+
+ clk.dev = scmi_dev;
64+
+ for (i = 0; i < ARRAY_SIZE(scmi_cpu_clks); i++) {
65+
+ clk.id = scmi_cpu_clks[i];
66+
+ ret = clk_set_rate(&clk, CPU_PVTPLL_HZ);
67+
+ if (ret < 0)
68+
+ printf("Failed to set SCMI cpu clk %lu: %d\n",
69+
+ clk.id, ret);
70+
+ }
71+
+}
72+
+#endif
73+
+
74+
static int rk3588_clk_probe(struct udevice *dev)
75+
{
76+
struct rk3588_clk_priv *priv = dev_get_priv(dev);
77+
@@ -1986,6 +2017,10 @@ static int rk3588_clk_probe(struct udevice *dev)
78+
79+
rk3588_clk_init(priv);
80+
81+
+#if CONFIG_IS_ENABLED(CLK_SCMI) && !defined(CONFIG_XPL_BUILD)
82+
+ rk3588_clk_raise_cpu_clocks();
83+
+#endif
84+
+
85+
/* Process 'assigned-{clocks/clock-parents/clock-rates}' properties */
86+
ret = clk_set_defaults(dev, 1);
87+
if (ret)
88+
--
89+
Armbian
90+

0 commit comments

Comments
 (0)