Skip to contentSkip to conversation

rockchip: Always init clocks in SPL build for RK35xx

PATCH Superseded Jonas Karlman 3 participants 13 messages Oct 12 – Oct 13

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover rockchip: Always init clocks in SPL build for RK35xx

The RK35xx clock drivers typically initializes a few clocks when probed, with some clocks only in SPL. However, the clock driver is only probed on demand, so this initialization is fully skipped when no SPL consumer requests a clock, e.g. when booting from RAM/USB.

Prior to the commit c6bba31dbdd4 ("rockchip: spl-boot-order: Defer probe of boot device") all boot devices where typically probed, with a side effect that clock driver likely also where probed, prior to the SPL boot_from_devices() call.

This series flag RK35xx clock drivers to be probed after bind in SPL to help ensure a deterministic probe and clock initialization behavior prior to booting from devices.

This should help restore old behavior, e.g. that SPLL is initialized on RK3588 and CPU core rate is initialized on RK3576 when booting from RAM/USB.

The series may possible depend on the series "rockchip: Miscellaneous RK35xx clock fixes" [1] for a clean apply.

Changes in v2:
- Update cover letter and commit messages
- Collect r-b and t-b tags

[1] https://patch.msgid.link/[email protected]/

Jonas Karlman (4):
clk: rockchip: rk3568: Always initialize clocks in SPL
clk: rockchip: rk3588: Always initialize clocks in SPL
clk: rockchip: rk3576: Always initialize clocks in SPL
clk: rockchip: rk3528: Always initialize clocks in SPL

 drivers/clk/rockchip/clk_rk3528.c |  4 ++++
 drivers/clk/rockchip/clk_rk3568.c |  4 ++++
 drivers/clk/rockchip/clk_rk3576.c |  4 ++++
 drivers/clk/rockchip/clk_rk3588.c | 14 ++++++++++++++
 4 files changed, 26 insertions(+)
Signature · 1 line
2.55.0
#1 lore raw

PATCH v2 1/4 clk: rockchip: rk3568: Always initialize clocks in SPL

The RK3568 clock driver initializes ACLK_BUS to 150 MHz when probed in SPL. However, the driver is only probed on demand, so this initialization is skipped when no SPL consumer requests a clock, e.g. when booting from RAM/USB.

Prior to the commit c6bba31dbdd4 ("rockchip: spl-boot-order: Defer probe of boot device") all boot devices where typically probed, with a side effect that clock driver likely also where probed, prior to the boot_from_devices() call.

Flag the clock driver to be probed after bind in SPL to help ensure a deterministic probe and clock initialization behavior prior to booting from devices.

---
Changes in v2:
- Update commit message
- Collect r-b tag

---
 drivers/clk/rockchip/clk_rk3568.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/clk/rockchip/clk_rk3568.c +4 -0
index 9f3e9322161e..5a05f1b4de00 100644
@@ -2934,6 +2934,10 @@ static int rk3568_clk_bind(struct udevice *dev)
 	struct udevice *sys_child;
 	struct sysreset_reg *priv;
 
+	/* Ensure clocks are initialized after bind in SPL build */
+	if (IS_ENABLED(CONFIG_SPL_BUILD))
+		dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND);
+
 	/* The reset driver does not have a device node, so bind it here */
 	ret = device_bind_driver(dev, "rockchip_sysreset", "sysreset",
 				 &sys_child);
Signature · 1 line
2.55.0
#2 lore raw

Re: [PATCH v2 1/4] clk: rockchip: rk3568: Always initialize clocks in SPL

Hi Jonas,

Quoted 29 lines · Jonas Karlman

The RK3568 clock driver initializes ACLK_BUS to 150 MHz when probed in SPL. However, the driver is only probed on demand, so this initialization is skipped when no SPL consumer requests a clock, e.g. when booting from RAM/USB.

Prior to the commit c6bba31dbdd4 ("rockchip: spl-boot-order: Defer probe of boot device") all boot devices where typically probed, with a side effect that clock driver likely also where probed, prior to the boot_from_devices() call.

Flag the clock driver to be probed after bind in SPL to help ensure a deterministic probe and clock initialization behavior prior to booting from devices.

---
Changes in v2:
- Update commit message
- Collect r-b tag

---
  drivers/clk/rockchip/clk_rk3568.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/clk/rockchip/clk_rk3568.c +0 -0
index 9f3e9322161e..5a05f1b4de00 100644

drivers/clk/rockchip/clk_rk3568.c static int rk3568_clk_bind(struct udevice *dev) · line 2940

Quoted 7 lines
drivers/clk/rockchip/clk_rk3568.c +4 -0
@@ -2934,6 +2934,10 @@ static int rk3568_clk_bind(struct udevice *dev)
  	struct udevice *sys_child;
  	struct sysreset_reg *priv;
 
+	/* Ensure clocks are initialized after bind in SPL build */
+	if (IS_ENABLED(CONFIG_SPL_BUILD))
+		dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND);
+

There's pmucru in this driver as well, shouldn't we also probe it after bind? Or how did you decide only the cru driver should be probed after bind and not pmucru?

As a general note for the commit log in v2, they are good enough for me. It clearly states we go back to what we used to do as a stop-gap measure to fix various issues we hadn't when we used to probe all boot devices, and hopefully we'll fix this properly once we know better. I don't really like it, but I think it's reasonable.

Cheers,
Quentin

#3 lore raw

Re: [PATCH v2 1/4] clk: rockchip: rk3568: Always initialize clocks in SPL

Hi Quentin,

Quoted 35 lines · Quentin Schulz

Hi Jonas,

Quoted 32 lines · Jonas Karlman

The RK3568 clock driver initializes ACLK_BUS to 150 MHz when probed in SPL. However, the driver is only probed on demand, so this initialization is skipped when no SPL consumer requests a clock, e.g. when booting from RAM/USB.

Prior to the commit c6bba31dbdd4 ("rockchip: spl-boot-order: Defer probe of boot device") all boot devices where typically probed, with a side effect that clock driver likely also where probed, prior to the boot_from_devices() call.

Flag the clock driver to be probed after bind in SPL to help ensure a deterministic probe and clock initialization behavior prior to booting from devices.

---
Changes in v2:
- Update commit message
- Collect r-b tag

---
  drivers/clk/rockchip/clk_rk3568.c | 4 ++++
  1 file changed, 4 insertions(+)
drivers/clk/rockchip/clk_rk3568.c +0 -0
index 9f3e9322161e..5a05f1b4de00 100644
@@ -2934,6 +2934,10 @@ static int rk3568_clk_bind(struct udevice *dev)
  	struct udevice *sys_child;
  	struct sysreset_reg *priv;
 
Quoted 8 lines

drivers/clk/rockchip/clk_rk3568.c static int rk3568_clk_bind(struct udevice *dev) · line 2940

Quoted 4 lines
drivers/clk/rockchip/clk_rk3568.c +4 -0
+	/* Ensure clocks are initialized after bind in SPL build */
+	if (IS_ENABLED(CONFIG_SPL_BUILD))
+		dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND);
+

There's pmucru in this driver as well, shouldn't we also probe it after bind? Or how did you decide only the cru driver should be probed after bind and not pmucru?

Good catch, I am not sure if I decided to exclude it or just missed it. Looking at the the code and DT references I do not think we need to probe pmucru other than to be consistent, at first glance it looks to be related to video and pcie. It most likely was not probed until U-Boot proper, but will look closer and run some tests.

Quoted 5 lines

As a general note for the commit log in v2, they are good enough for me. It clearly states we go back to what we used to do as a stop-gap measure to fix various issues we hadn't when we used to probe all boot devices, and hopefully we'll fix this properly once we know better. I don't really like it, but I think it's reasonable.

Fully agree. At this time I cannot see how we can solve this more properly but as you mention hopefully we will know better in future :-)

Regards,
Jonas

Quoted 3 lines

Cheers,
Quentin

#4 lore raw

PATCH v2 2/4 clk: rockchip: rk3588: Always initialize clocks in SPL

In reply to Jonas Karlman

The RK3588 clock driver configures the CPU PLLs and SPLL when probed in SPL. However, the driver is only probed on demand, so this configuration is skipped when no SPL consumer requests a clock, e.g. when booting from RAM/USB.

Prior to the commit c6bba31dbdd4 ("rockchip: spl-boot-order: Defer probe of boot device") all boot devices where typically probed, with a side effect that clock driver likely also where probed, prior to the boot_from_devices() call.

Flag the clock driver to be probed after bind in SPL to help ensure a deterministic probe and clock configuration behavior prior to booting from devices.

---
Changes in v2:
- Update commit message
- Collect t-b tag

---
 drivers/clk/rockchip/clk_rk3588.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
drivers/clk/rockchip/clk_rk3588.c +14 -0
index 9e26ca669fc5..fe3fc695c15f 100644
@@ -2004,6 +2004,10 @@ static int rk3588_clk_bind(struct udevice *dev)
 	struct udevice *sys_child;
 	struct sysreset_reg *priv;
 
+	/* Ensure clocks are initialized after bind in SPL build */
+	if (IS_ENABLED(CONFIG_SPL_BUILD))
+		dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND);
+
 	/* The reset driver does not have a device node, so bind it here */
 	ret = device_bind_driver(dev, "rockchip_sysreset", "sysreset",
 				 &sys_child);
@@ -2133,6 +2137,15 @@ static int rk3588_scru_clk_probe(struct udevice *dev)
 	return 0;
 }
 
+static int rk3588_scru_clk_bind(struct udevice *dev)
+{
+	/* Ensure clocks are initialized after bind in SPL build */
+	if (IS_ENABLED(CONFIG_SPL_BUILD))
+		dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND);
+
+	return 0;
+}
+
 static const struct clk_ops rk3588_scru_clk_ops = {
 	.get_rate = rk3588_scru_clk_get_rate,
 	.set_rate = rk3588_scru_clk_set_rate,
@@ -2142,6 +2155,7 @@ U_BOOT_DRIVER(rockchip_rk3588_scru) = {
 	.name	= "rockchip_rk3588_scru",
 	.id	= UCLASS_CLK,
 	.ops	= &rk3588_scru_clk_ops,
+	.bind	= rk3588_scru_clk_bind,
 	.probe	= rk3588_scru_clk_probe,
 };
 
Signature · 1 line
2.55.0
Reviewed-by on v2 2/4
#5 lore raw

Re: [PATCH v2 2/4] clk: rockchip: rk3588: Always initialize clocks in SPL

Hi Jonas,

Quoted 10 lines · Jonas Karlman

The RK3588 clock driver configures the CPU PLLs and SPLL when probed in SPL. However, the driver is only probed on demand, so this configuration is skipped when no SPL consumer requests a clock, e.g. when booting from RAM/USB.

Prior to the commit c6bba31dbdd4 ("rockchip: spl-boot-order: Defer probe of boot device") all boot devices where typically probed, with a side effect that clock driver likely also where probed, prior to the boot_from_devices() call.

Quoted 6 lines

Flag the clock driver to be probed after bind in SPL to help ensure a deterministic probe and clock configuration behavior prior to booting from devices.

Thanks!
Quentin

#6 lore raw

PATCH v2 3/4 clk: rockchip: rk3576: Always initialize clocks in SPL

In reply to Jonas Karlman

The RK3576 clock driver configures the CPU PLLs and CPU clocks when probed in SPL. However, the driver is only probed on demand, so this configuration is skipped when no SPL consumer requests a clock, e.g. when booting from RAM/USB.

Prior to the commit c6bba31dbdd4 ("rockchip: spl-boot-order: Defer probe of boot device") all boot devices where typically probed, with a side effect that clock driver likely also where probed, prior to the boot_from_devices() call.

Flag the clock driver to be probed after bind in SPL to help ensure a deterministic probe and clock configuration behavior prior to booting from devices.

---
Changes in v2:
- Update commit message
- Collect t-b and r-b tags

---
 drivers/clk/rockchip/clk_rk3576.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/clk/rockchip/clk_rk3576.c +4 -0
index 75b705ffba2f..1988f0472dec 100644
@@ -2526,6 +2526,10 @@ static int rk3576_clk_bind(struct udevice *dev)
 	struct udevice *sys_child;
 	struct sysreset_reg *priv;
 
+	/* Ensure clocks are initialized after bind in SPL build */
+	if (IS_ENABLED(CONFIG_SPL_BUILD))
+		dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND);
+
 	/* The reset driver does not have a device node, so bind it here */
 	ret = device_bind_driver(dev, "rockchip_sysreset", "sysreset",
 				 &sys_child);
Signature · 1 line
2.55.0
Reviewed-by on v2 3/4
#7 lore raw

Re: [PATCH v2 3/4] clk: rockchip: rk3576: Always initialize clocks in SPL

Hi Jonas,

Quoted 10 lines · Jonas Karlman

The RK3576 clock driver configures the CPU PLLs and CPU clocks when probed in SPL. However, the driver is only probed on demand, so this configuration is skipped when no SPL consumer requests a clock, e.g. when booting from RAM/USB.

Prior to the commit c6bba31dbdd4 ("rockchip: spl-boot-order: Defer probe of boot device") all boot devices where typically probed, with a side effect that clock driver likely also where probed, prior to the boot_from_devices() call.

Quoted 7 lines

Flag the clock driver to be probed after bind in SPL to help ensure a deterministic probe and clock configuration behavior prior to booting from devices.

Thanks!
Quentin

#8 lore raw

PATCH v2 4/4 clk: rockchip: rk3528: Always initialize clocks in SPL

In reply to Jonas Karlman

The RK3528 clock driver configures the CPU PLLs, clock matrix rates and default PWM rates when probed in SPL. However, the driver is only probed on demand, so this configuration is skipped when no SPL consumer requests a clock, e.g. when booting from RAM/USB.

Prior to the commit c6bba31dbdd4 ("rockchip: spl-boot-order: Defer probe of boot device") all boot devices where typically probed, with a side effect that clock driver likely also where probed, prior to the boot_from_devices() call.

Flag the clock driver to be probed after bind in SPL to help ensure a deterministic probe and clock configuration behavior prior to booting from devices.

---
v2: Update commit message

---
 drivers/clk/rockchip/clk_rk3528.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/clk/rockchip/clk_rk3528.c +4 -0
index 83e302dbc3c4..976ef0e0a919 100644
@@ -1715,6 +1715,10 @@ static int rk3528_clk_bind(struct udevice *dev)
 	struct sysreset_reg *priv;
 	int ret;
 
+	/* Ensure clocks are initialized after bind in SPL build */
+	if (IS_ENABLED(CONFIG_SPL_BUILD))
+		dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND);
+
 	/* The reset driver does not have a device node, so bind it here */
 	ret = device_bind_driver(dev, "rockchip_sysreset", "sysreset",
 				 &sys_child);
Signature · 1 line
2.55.0
Reviewed-by on v2 4/4
#9 lore raw

Re: [PATCH v2 4/4] clk: rockchip: rk3528: Always initialize clocks in SPL

Hi Jonas,

Quoted 10 lines · Jonas Karlman

The RK3528 clock driver configures the CPU PLLs, clock matrix rates and default PWM rates when probed in SPL. However, the driver is only probed on demand, so this configuration is skipped when no SPL consumer requests a clock, e.g. when booting from RAM/USB.

Prior to the commit c6bba31dbdd4 ("rockchip: spl-boot-order: Defer probe of boot device") all boot devices where typically probed, with a side effect that clock driver likely also where probed, prior to the boot_from_devices() call.

Quoted 5 lines

Flag the clock driver to be probed after bind in SPL to help ensure a deterministic probe and clock configuration behavior prior to booting from devices.

Thanks!
Quentin

#10 lore raw
In reply to Jonas Karlman

Hi Jonas,

Quoted 25 lines · Jonas Karlman

The RK35xx clock drivers typically initializes a few clocks when probed, with some clocks only in SPL. However, the clock driver is only probed on demand, so this initialization is fully skipped when no SPL consumer requests a clock, e.g. when booting from RAM/USB.

Prior to the commit c6bba31dbdd4 ("rockchip: spl-boot-order: Defer probe of boot device") all boot devices where typically probed, with a side effect that clock driver likely also where probed, prior to the SPL boot_from_devices() call.

This series flag RK35xx clock drivers to be probed after bind in SPL to help ensure a deterministic probe and clock initialization behavior prior to booting from devices.

This should help restore old behavior, e.g. that SPLL is initialized on RK3588 and CPU core rate is initialized on RK3576 when booting from RAM/USB.

The series may possible depend on the series "rockchip: Miscellaneous RK35xx clock fixes" [1] for a clean apply.

Changes in v2:
- Update cover letter and commit messages
- Collect r-b and t-b tags

Quoted 8 lines

[1] https://patch.msgid.link/[email protected]/

Jonas Karlman (4):
clk: rockchip: rk3568: Always initialize clocks in SPL
clk: rockchip: rk3588: Always initialize clocks in SPL
clk: rockchip: rk3576: Always initialize clocks in SPL
clk: rockchip: rk3528: Always initialize clocks in SPL

The RK3506 clock driver is notably missing from this list of "RK35xx clock drivers". I'm assuming this is because support for the RK3506 clock driver got merged after commit c6bba31dbdd4 ("rockchip: spl-boot-order: Defer probe of boot device"), so it means if it's broken, it just never worked in the first place and we should rather dig into the problem instead of doing what we do for the other RK35xx SoCs, was this your conclusion as well or did I just incorrectly extrapolate?

Cheers,
Quentin

#11 lore raw

Hi Quentin,

Quoted 37 lines · Quentin Schulz

Hi Jonas,

Quoted 25 lines · Jonas Karlman

The RK35xx clock drivers typically initializes a few clocks when probed, with some clocks only in SPL. However, the clock driver is only probed on demand, so this initialization is fully skipped when no SPL consumer requests a clock, e.g. when booting from RAM/USB.

Prior to the commit c6bba31dbdd4 ("rockchip: spl-boot-order: Defer probe of boot device") all boot devices where typically probed, with a side effect that clock driver likely also where probed, prior to the SPL boot_from_devices() call.

This series flag RK35xx clock drivers to be probed after bind in SPL to help ensure a deterministic probe and clock initialization behavior prior to booting from devices.

This should help restore old behavior, e.g. that SPLL is initialized on RK3588 and CPU core rate is initialized on RK3576 when booting from RAM/USB.

The series may possible depend on the series "rockchip: Miscellaneous RK35xx clock fixes" [1] for a clean apply.

Changes in v2:
- Update cover letter and commit messages
- Collect r-b and t-b tags

Quoted 8 lines

[1] https://patch.msgid.link/[email protected]/

Jonas Karlman (4):
clk: rockchip: rk3568: Always initialize clocks in SPL
clk: rockchip: rk3588: Always initialize clocks in SPL
clk: rockchip: rk3576: Always initialize clocks in SPL
clk: rockchip: rk3528: Always initialize clocks in SPL

Quoted 7 lines

The RK3506 clock driver is notably missing from this list of "RK35xx clock drivers". I'm assuming this is because support for the RK3506 clock driver got merged after commit c6bba31dbdd4 ("rockchip:
spl-boot-order: Defer probe of boot device"), so it means if it's broken, it just never worked in the first place and we should rather dig into the problem instead of doing what we do for the other RK35xx SoCs, was this your conclusion as well or did I just incorrectly extrapolate?

The RK3506 clock driver currently initialize a few clocks from bind() in XPL :-S

So it is not affected, or rather it worked around the issue for USB/RAM boot in a different way. Should probably have mentioned something about the RK3506 situation in cover letter.

In my work-in-progress branch at [1] I have a "WIP: clk: rockchip:
rk3506: Rework early clock init" commit that re-work that clock init to use similar probe-after-bind style. I likely just deferred rk3506 for a future refactor series as it was already "working" and the diff to change it was very different to the patches in this series.

[1] https://git.u-boot-project.org/u-boot/contributors/kwiboo/u-boot/-/commits/rk3562/drivers/clk/rockchip/clk_rk3506.c

Regards,
Jonas

Quoted 3 lines

Cheers,
Quentin

#12 lore raw
Quoted 6 lines · Jonas Karlman

Hi Quentin,

Quoted 3 lines · Quentin Schulz

Hi Jonas,

On 10/12/26 1:15 PM, Jonas Karlman wrote:

[...]

Quoted 15 lines
Quoted 7 lines

The RK3506 clock driver is notably missing from this list of "RK35xx clock drivers". I'm assuming this is because support for the RK3506 clock driver got merged after commit c6bba31dbdd4 ("rockchip:
spl-boot-order: Defer probe of boot device"), so it means if it's broken, it just never worked in the first place and we should rather dig into the problem instead of doing what we do for the other RK35xx SoCs, was this your conclusion as well or did I just incorrectly extrapolate?

The RK3506 clock driver currently initialize a few clocks from bind() in XPL :-S

So it is not affected, or rather it worked around the issue for USB/RAM boot in a different way. Should probably have mentioned something about the RK3506 situation in cover letter.

Quoted 6 lines

In my work-in-progress branch at [1] I have a "WIP: clk: rockchip:
rk3506: Rework early clock init" commit that re-work that clock init to use similar probe-after-bind style. I likely just deferred rk3506 for a future refactor series as it was already "working" and the diff to change it was very different to the patches in this series.

ACK, thanks for the heads up. Marking this series as Changes Requested on patchwork as you said you'd send a v2.

Cheers,
Quentin