Skip to contentSkip to conversation

rockchip: Always init clocks in SPL build for RK35xx

PATCH In review Jonas Karlman 4 participants 14 messages Oct 15 – Nov 20

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

The RK35xx clock drivers typically initialize 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 there is 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 RK3506 clock driver is initializing a few clocks in bind() ops so it is not affected, or rather it worked around similar issue for USB/RAM boot using a slightly different approach.

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

Changes in v3:
- Add an optional patch to delay ungate of PCIE30PHY_REF clocks
- Collect r-b tags

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 (5):
clk: rockchip: rk3568: Ungate PCIE30PHY_REF clocks when PCI is enabled
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 | 19 +++++++++++++++----
 drivers/clk/rockchip/clk_rk3576.c |  4 ++++
 drivers/clk/rockchip/clk_rk3588.c | 14 ++++++++++++++
 4 files changed, 37 insertions(+), 4 deletions(-)
Signature · 1 line
2.55.0
#1 lore raw

PATCH v3 1/5 clk: rockchip: rk3568: Ungate PCIE30PHY_REF clocks when PCI is enabled

The CLK_PCIE30PHY_REF_M and CLK_PCIE30PHY_REF_N clocks are by default gated coming out from system reset. The probe() ops of the PMUCRU driver unconditionally ungate these clocks to help ensure PCIe works in U-Boot proper.

Change to only ungate these clocks when the PCI Kconfig option is enabled for current boot phase to delay the ungate as late as possible.

---
Changes in v3:
- New optional patch to help delay the ungate of PCIe ref clocks until U-Boot proper

This patch is strictly not needed, however it seems very unnecessary to ungate PCIe ref clocks in SPL when PCIe typically only is used in proper.

Ideally this should be moved to enable()/disable() ops, however that would also require working implementation of enable_count for these clocks as they can be shared between both PCIe controllers. Something that can be deferred to a planned future clock driver refactor series.

---
 drivers/clk/rockchip/clk_rk3568.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/rockchip/clk_rk3568.c +3 -1
index 9f3e9322161e..ce17d42ea0f0 100644
@@ -477,7 +477,9 @@ static int rk3568_pmuclk_probe(struct udevice *dev)
 	}
 
 	/* Ungate PCIe30phy refclk_m and refclk_n */
-	rk_clrsetreg(&priv->pmucru->pmu_clkgate_con[2], 0x3 << 13, 0 << 13);
+	if (CONFIG_IS_ENABLED(PCI))
+		rk_clrreg(&priv->pmucru->pmu_clkgate_con[2], 0x3 << 13);
+
 	return 0;
 }
 
Signature · 1 line
2.55.0
#2 lore raw

Re: [PATCH v3 1/5] clk: rockchip: rk3568: Ungate PCIE30PHY_REF clocks when PCI is enabled

Hi Jonas,

Quoted 2 lines · Jonas Karlman

The CLK_PCIE30PHY_REF_M and CLK_PCIE30PHY_REF_N clocks are by default gated coming out from system reset. The probe() ops of the PMUCRU driver

Are they? I don't have an RK3568 board so cannot test this, but the TRM says the bitfields are 0 at reset with "When high, disable clock", so I am not sure what exactly this is for (except after a reboot where the Linux kernel has disabled the PCIe clocks maybe?).

Quoted 6 lines

unconditionally ungate these clocks to help ensure PCIe works in U-Boot proper.

Change to only ungate these clocks when the PCI Kconfig option is enabled for current boot phase to delay the ungate as late as possible.

Quoted 9 lines

---
Changes in v3:
- New optional patch to help delay the ungate of PCIe ref clocks until U-Boot proper

This patch is strictly not needed, however it seems very unnecessary to ungate PCIe ref clocks in SPL when PCIe typically only is used in proper.

Considering the kernel seems (I had a cursory look) to be able to control those clocks and have them handled via the pcie node, it seems fine to me to possibly not have the clock enabled by U-Boot (e.g. with U-Boot proper or xPL not enabling PCI).

So, I'm fine with the content of the patch, not the commit log. Can you please confirm that they are indeed not at 0 when reset (and/or that we do this to be safe when doing reboots) and rework the commit log?

If you want, I can merge patches 2-5 from this series for 2027.01 and we can defer patch 1 here to 2027.04 if you don't have time to send a v4 in the next couple of days.

Cheers,
Quentin

#3 lore raw

Re: [PATCH v3 1/5] clk: rockchip: rk3568: Ungate PCIE30PHY_REF clocks when PCI is enabled

Hi Quentin,

Quoted 10 lines · Quentin Schulz

Hi Jonas,

Quoted 2 lines · Jonas Karlman

The CLK_PCIE30PHY_REF_M and CLK_PCIE30PHY_REF_N clocks are by default gated coming out from system reset. The probe() ops of the PMUCRU driver

Are they? I don't have an RK3568 board so cannot test this, but the TRM says the bitfields are 0 at reset with "When high, disable clock", so I am not sure what exactly this is for (except after a reboot where the Linux kernel has disabled the PCIe clocks maybe?).

I guess the TRM is incorrect, because as I mention in my commit message these clocks comes gated out from system reset, or I would never have phrased the commit message as such.

See below runtime log on a Radxa ROCK 3B (from power off state):

DDR 5c7dbc4d49 kwin.chen 26/05/21-10:58:25,fwver: v1.26 [...]
out
PRE: pmu_clkgate_con[2]=6000
POST: pmu_clkgate_con[2]=6000

U-Boot SPL 2027.01-rc1-00097-gec7e6bacaadc-dirty (Oct 28 2026 - 16:35:51 +0000) Trying to boot from RAM
[...]
U-Boot 2027.01-rc1-00097-gec7e6bacaadc-dirty (Oct 28 2026 - 16:35:51 +0000)

Model: Radxa ROCK 3B
SoC: RK3568
DRAM: 8 GiB (total 7.7 GiB)
PRE: pmu_clkgate_con[2]=6000
POST: pmu_clkgate_con[2]=0

Using following code in probe() ops:

	printf("PRE: pmu_clkgate_con[2]=%x\n", readl(&priv->pmucru->pmu_clkgate_con[2]));

	/* Ungate PCIe30phy refclk_m and refclk_n */
	if (CONFIG_IS_ENABLED(PCI))
		rk_clrreg(&priv->pmucru->pmu_clkgate_con[2], 0x3 << 13);

	printf("POST: pmu_clkgate_con[2]=%x\n", readl(&priv->pmucru->pmu_clkgate_con[2]));

I guess theoretically it could be the DDR init blob that gates the refclks, however running bare minimal TPL on same board show same:

U-Boot TPL 2026.10-01297-g83bfcb8d6e91-dirty (Oct 28 2026 - 16:45:25)
x0: 00000000 fdcc0098
x1: 00000000 00000008
x2: 00000000 fdcc1000
x3: 00000000 00000006
x4: 00000000 00000050
x5: 00000000 00000000
x6: 00000000 00020002
sp: 00000000 fdcc0f30
BOOTSOURCE_ID fdcc0010: 0000000a
PMU_CRU fdd00000: 00004064
PMU_CRU fdd00004: 000014c1
PMU_CRU fdd0000c: 00000007
PMU_CRU fdd00010: 00007f00
PMU_CRU fdd00040: 00002063
PMU_CRU fdd00044: 00001481
PMU_CRU fdd0004c: 00000007
PMU_CRU fdd00050: 00007f00
PMU_CRU fdd00100: 00000080
PMU_CRU fdd00108: 00000001
PMU_CRU fdd0010c: 00000001
PMU_CRU fdd00110: 00000800
PMU_CRU fdd00118: 00000001
PMU_CRU fdd0011c: 00000009
PMU_CRU fdd00120: 0000050f
PMU_CRU fdd00124: 00008bbb
PMU_CRU fdd00188: 00006000 (pmu_clkgate_con[2])
PMU_CRU fdd00240: 00040020
DRAM init failed

Above should hopefully make it clear that the reset value in TRM is likely incorrect ;-)

Quoted 17 lines
Quoted 7 lines

unconditionally ungate these clocks to help ensure PCIe works in U-Boot proper.

Change to only ungate these clocks when the PCI Kconfig option is enabled for current boot phase to delay the ungate as late as possible.

Quoted 9 lines

---
Changes in v3:
- New optional patch to help delay the ungate of PCIe ref clocks until U-Boot proper

This patch is strictly not needed, however it seems very unnecessary to ungate PCIe ref clocks in SPL when PCIe typically only is used in proper.

Quoted 8 lines

Considering the kernel seems (I had a cursory look) to be able to control those clocks and have them handled via the pcie node, it seems fine to me to possibly not have the clock enabled by U-Boot (e.g. with U-Boot proper or xPL not enabling PCI).

So, I'm fine with the content of the patch, not the commit log. Can you please confirm that they are indeed not at 0 when reset (and/or that we do this to be safe when doing reboots) and rework the commit log?

As mentioned above, the commit message has been correct from start, so please be explicit about what you think is unclear and needs to change.

Regards,
Jonas

Quoted 7 lines

If you want, I can merge patches 2-5 from this series for 2027.01 and we can defer patch 1 here to 2027.04 if you don't have time to send a v4 in the next couple of days.

Cheers,
Quentin

Reviewed-by
#4 lore raw

Re: [PATCH v3 1/5] clk: rockchip: rk3568: Ungate PCIE30PHY_REF clocks when PCI is enabled

Hi Jonas,

Quoted 9 lines · Jonas Karlman

Hi Quentin,

Quoted 6 lines · Quentin Schulz

Hi Jonas,

Quoted 2 lines · Jonas Karlman

The CLK_PCIE30PHY_REF_M and CLK_PCIE30PHY_REF_N clocks are by default gated coming out from system reset. The probe() ops of the PMUCRU driver

Quoted 9 lines
Quoted 4 lines

Are they? I don't have an RK3568 board so cannot test this, but the TRM says the bitfields are 0 at reset with "When high, disable clock", so I am not sure what exactly this is for (except after a reboot where the Linux kernel has disabled the PCIe clocks maybe?).

I guess the TRM is incorrect, because as I mention in my commit message these clocks comes gated out from system reset, or I would never have phrased the commit message as such.

Well, it could also be inferred from the fact Rockchip enabled it in the CRU driver unconditionally. So I wanted to make sure it was indeed checked rather than simply inferred. Thank you for the confirmation.

Quoted 62 lines

See below runtime log on a Radxa ROCK 3B (from power off state):

   DDR 5c7dbc4d49 kwin.chen 26/05/21-10:58:25,fwver: v1.26
   [...]
   out
   PRE: pmu_clkgate_con[2]=6000
   POST: pmu_clkgate_con[2]=6000
   
   U-Boot SPL 2027.01-rc1-00097-gec7e6bacaadc-dirty (Oct 28 2026 - 16:35:51 +0000)
   Trying to boot from RAM
   [...]
   U-Boot 2027.01-rc1-00097-gec7e6bacaadc-dirty (Oct 28 2026 - 16:35:51 +0000)
   
   Model: Radxa ROCK 3B
   SoC:   RK3568
   DRAM:  8 GiB (total 7.7 GiB)
   PRE: pmu_clkgate_con[2]=6000
   POST: pmu_clkgate_con[2]=0

Using following code in probe() ops:

	printf("PRE: pmu_clkgate_con[2]=%x\n", readl(&priv->pmucru->pmu_clkgate_con[2]));

	/* Ungate PCIe30phy refclk_m and refclk_n */
	if (CONFIG_IS_ENABLED(PCI))
		rk_clrreg(&priv->pmucru->pmu_clkgate_con[2], 0x3 << 13);

	printf("POST: pmu_clkgate_con[2]=%x\n", readl(&priv->pmucru->pmu_clkgate_con[2]));

I guess theoretically it could be the DDR init blob that gates the refclks, however running bare minimal TPL on same board show same:

   U-Boot TPL 2026.10-01297-g83bfcb8d6e91-dirty (Oct 28 2026 - 16:45:25)
   x0: 00000000 fdcc0098
   x1: 00000000 00000008
   x2: 00000000 fdcc1000
   x3: 00000000 00000006
   x4: 00000000 00000050
   x5: 00000000 00000000
   x6: 00000000 00020002
   sp: 00000000 fdcc0f30
   BOOTSOURCE_ID fdcc0010: 0000000a
   PMU_CRU fdd00000: 00004064
   PMU_CRU fdd00004: 000014c1
   PMU_CRU fdd0000c: 00000007
   PMU_CRU fdd00010: 00007f00
   PMU_CRU fdd00040: 00002063
   PMU_CRU fdd00044: 00001481
   PMU_CRU fdd0004c: 00000007
   PMU_CRU fdd00050: 00007f00
   PMU_CRU fdd00100: 00000080
   PMU_CRU fdd00108: 00000001
   PMU_CRU fdd0010c: 00000001
   PMU_CRU fdd00110: 00000800
   PMU_CRU fdd00118: 00000001
   PMU_CRU fdd0011c: 00000009
   PMU_CRU fdd00120: 0000050f
   PMU_CRU fdd00124: 00008bbb
   PMU_CRU fdd00188: 00006000  (pmu_clkgate_con[2])
   PMU_CRU fdd00240: 00040020
   DRAM init failed
Quoted 3 lines

Above should hopefully make it clear that the reset value in TRM is likely incorrect ;-)

Wouldn't be the first nor the last time this happens :)

Quoted 22 lines
Quoted 22 lines
Quoted 7 lines

unconditionally ungate these clocks to help ensure PCIe works in U-Boot proper.

Change to only ungate these clocks when the PCI Kconfig option is enabled for current boot phase to delay the ungate as late as possible.

Quoted 9 lines

---
Changes in v3:
- New optional patch to help delay the ungate of PCIe ref clocks until U-Boot proper

This patch is strictly not needed, however it seems very unnecessary to ungate PCIe ref clocks in SPL when PCIe typically only is used in proper.

Considering the kernel seems (I had a cursory look) to be able to control those clocks and have them handled via the pcie node, it seems fine to me to possibly not have the clock enabled by U-Boot (e.g. with U-Boot proper or xPL not enabling PCI).

Quoted 7 lines
Quoted 3 lines

So, I'm fine with the content of the patch, not the commit log. Can you please confirm that they are indeed not at 0 when reset (and/or that we do this to be safe when doing reboots) and rework the commit log?

As mentioned above, the commit message has been correct from start, so please be explicit about what you think is unclear and needs to change.

You could have just said that it doesn't match the TRM, that would have told me that it was checked IRL.

I can reword the first sentence to

The CLK_PCIE30PHY_REF_M and CLK_PCIE30PHY_REF_N clocks are by default gated coming out from system reset unlike stated in the TRM.

when applying, does that work for you?

Thanks!
Quentin

#5 lore raw

Re: [PATCH v3 1/5] clk: rockchip: rk3568: Ungate PCIE30PHY_REF clocks when PCI is enabled

Hi Quentin,

Quoted 17 lines · Quentin Schulz

Hi Jonas,

Quoted 14 lines · Jonas Karlman

Hi Quentin,

Quoted 10 lines · Quentin Schulz

Hi Jonas,

Quoted 2 lines · Jonas Karlman

The CLK_PCIE30PHY_REF_M and CLK_PCIE30PHY_REF_N clocks are by default gated coming out from system reset. The probe() ops of the PMUCRU driver

Are they? I don't have an RK3568 board so cannot test this, but the TRM says the bitfields are 0 at reset with "When high, disable clock", so I am not sure what exactly this is for (except after a reboot where the Linux kernel has disabled the PCIe clocks maybe?).

Quoted 8 lines
Quoted 4 lines

I guess the TRM is incorrect, because as I mention in my commit message these clocks comes gated out from system reset, or I would never have phrased the commit message as such.

Well, it could also be inferred from the fact Rockchip enabled it in the CRU driver unconditionally. So I wanted to make sure it was indeed checked rather than simply inferred. Thank you for the confirmation.

I would most likely have phrased the message very differently if the out of system reset state was not tested, or at least mention that it would have been a refactor based on current code if that was the case.

My expectation (and practice) are that when something is definitively worded in commit message it has been verified to be true, else there is a note and/or the wording is much more relaxed.

Quoted 95 lines
Quoted 63 lines

See below runtime log on a Radxa ROCK 3B (from power off state):

   DDR 5c7dbc4d49 kwin.chen 26/05/21-10:58:25,fwver: v1.26
   [...]
   out
   PRE: pmu_clkgate_con[2]=6000
   POST: pmu_clkgate_con[2]=6000
   
   U-Boot SPL 2027.01-rc1-00097-gec7e6bacaadc-dirty (Oct 28 2026 - 16:35:51 +0000)
   Trying to boot from RAM
   [...]
   U-Boot 2027.01-rc1-00097-gec7e6bacaadc-dirty (Oct 28 2026 - 16:35:51 +0000)
   
   Model: Radxa ROCK 3B
   SoC:   RK3568
   DRAM:  8 GiB (total 7.7 GiB)
   PRE: pmu_clkgate_con[2]=6000
   POST: pmu_clkgate_con[2]=0

Using following code in probe() ops:

	printf("PRE: pmu_clkgate_con[2]=%x\n", readl(&priv->pmucru->pmu_clkgate_con[2]));

	/* Ungate PCIe30phy refclk_m and refclk_n */
	if (CONFIG_IS_ENABLED(PCI))
		rk_clrreg(&priv->pmucru->pmu_clkgate_con[2], 0x3 << 13);

	printf("POST: pmu_clkgate_con[2]=%x\n", readl(&priv->pmucru->pmu_clkgate_con[2]));

I guess theoretically it could be the DDR init blob that gates the refclks, however running bare minimal TPL on same board show same:

   U-Boot TPL 2026.10-01297-g83bfcb8d6e91-dirty (Oct 28 2026 - 16:45:25)
   x0: 00000000 fdcc0098
   x1: 00000000 00000008
   x2: 00000000 fdcc1000
   x3: 00000000 00000006
   x4: 00000000 00000050
   x5: 00000000 00000000
   x6: 00000000 00020002
   sp: 00000000 fdcc0f30
   BOOTSOURCE_ID fdcc0010: 0000000a
   PMU_CRU fdd00000: 00004064
   PMU_CRU fdd00004: 000014c1
   PMU_CRU fdd0000c: 00000007
   PMU_CRU fdd00010: 00007f00
   PMU_CRU fdd00040: 00002063
   PMU_CRU fdd00044: 00001481
   PMU_CRU fdd0004c: 00000007
   PMU_CRU fdd00050: 00007f00
   PMU_CRU fdd00100: 00000080
   PMU_CRU fdd00108: 00000001
   PMU_CRU fdd0010c: 00000001
   PMU_CRU fdd00110: 00000800
   PMU_CRU fdd00118: 00000001
   PMU_CRU fdd0011c: 00000009
   PMU_CRU fdd00120: 0000050f
   PMU_CRU fdd00124: 00008bbb
   PMU_CRU fdd00188: 00006000  (pmu_clkgate_con[2])
   PMU_CRU fdd00240: 00040020
   DRAM init failed
Quoted 3 lines

Above should hopefully make it clear that the reset value in TRM is likely incorrect ;-)

Wouldn't be the first nor the last time this happens :)

Quoted 26 lines
Quoted 25 lines
Quoted 7 lines

unconditionally ungate these clocks to help ensure PCIe works in U-Boot proper.

Change to only ungate these clocks when the PCI Kconfig option is enabled for current boot phase to delay the ungate as late as possible.

Quoted 9 lines

---
Changes in v3:
- New optional patch to help delay the ungate of PCIe ref clocks until U-Boot proper

This patch is strictly not needed, however it seems very unnecessary to ungate PCIe ref clocks in SPL when PCIe typically only is used in proper.

Considering the kernel seems (I had a cursory look) to be able to control those clocks and have them handled via the pcie node, it seems fine to me to possibly not have the clock enabled by U-Boot (e.g. with U-Boot proper or xPL not enabling PCI).

So, I'm fine with the content of the patch, not the commit log. Can you please confirm that they are indeed not at 0 when reset (and/or that we do this to be safe when doing reboots) and rework the commit log?

Quoted 6 lines
Quoted 3 lines

As mentioned above, the commit message has been correct from start, so please be explicit about what you think is unclear and needs to change.

You could have just said that it doesn't match the TRM, that would have told me that it was checked IRL.

I did not even notice that the reset state in TRM was different, all my changes are typically confirmed using runtime testing ;-)

Quoted 7 lines

I can reword the first sentence to

The CLK_PCIE30PHY_REF_M and CLK_PCIE30PHY_REF_N clocks are by default gated coming out from system reset unlike stated in the TRM.

when applying, does that work for you?

Sure, please feel free to make any change you see fit to any of my patches :-)

Regards,
Jonas

Quoted 5 lines

Thanks!
Quentin

#6 lore raw

Re: [PATCH v3 1/5] clk: rockchip: rk3568: Ungate PCIE30PHY_REF clocks when PCI is enabled

Hi,

Il giorno mer 28 ott 2026 alle ore 23:53 Jonas Karlman ha scritto:

Quoted 137 lines

Hi Quentin,

Quoted 17 lines · Quentin Schulz

Hi Jonas,

Quoted 14 lines · Jonas Karlman

Hi Quentin,

Quoted 10 lines · Quentin Schulz

Hi Jonas,

Quoted 2 lines · Jonas Karlman

The CLK_PCIE30PHY_REF_M and CLK_PCIE30PHY_REF_N clocks are by default gated coming out from system reset. The probe() ops of the PMUCRU driver

Are they? I don't have an RK3568 board so cannot test this, but the TRM says the bitfields are 0 at reset with "When high, disable clock", so I am not sure what exactly this is for (except after a reboot where the Linux kernel has disabled the PCIe clocks maybe?).

Quoted 8 lines
Quoted 4 lines

I guess the TRM is incorrect, because as I mention in my commit message these clocks comes gated out from system reset, or I would never have phrased the commit message as such.

Well, it could also be inferred from the fact Rockchip enabled it in the CRU driver unconditionally. So I wanted to make sure it was indeed checked rather than simply inferred. Thank you for the confirmation.

I would most likely have phrased the message very differently if the out of system reset state was not tested, or at least mention that it would have been a refactor based on current code if that was the case.

My expectation (and practice) are that when something is definitively worded in commit message it has been verified to be true, else there is a note and/or the wording is much more relaxed.

Quoted 99 lines
Quoted 63 lines

See below runtime log on a Radxa ROCK 3B (from power off state):

   DDR 5c7dbc4d49 kwin.chen 26/05/21-10:58:25,fwver: v1.26
   [...]
   out
   PRE: pmu_clkgate_con[2]=6000
   POST: pmu_clkgate_con[2]=6000

   U-Boot SPL 2027.01-rc1-00097-gec7e6bacaadc-dirty (Oct 28 2026 - 16:35:51 +0000)
   Trying to boot from RAM
   [...]
   U-Boot 2027.01-rc1-00097-gec7e6bacaadc-dirty (Oct 28 2026 - 16:35:51 +0000)

   Model: Radxa ROCK 3B
   SoC:   RK3568
   DRAM:  8 GiB (total 7.7 GiB)
   PRE: pmu_clkgate_con[2]=6000
   POST: pmu_clkgate_con[2]=0

Using following code in probe() ops:

     printf("PRE: pmu_clkgate_con[2]=%x\n", readl(&priv->pmucru->pmu_clkgate_con[2]));

     /* Ungate PCIe30phy refclk_m and refclk_n */
     if (CONFIG_IS_ENABLED(PCI))
             rk_clrreg(&priv->pmucru->pmu_clkgate_con[2], 0x3 << 13);

     printf("POST: pmu_clkgate_con[2]=%x\n", readl(&priv->pmucru->pmu_clkgate_con[2]));

I guess theoretically it could be the DDR init blob that gates the refclks, however running bare minimal TPL on same board show same:

   U-Boot TPL 2026.10-01297-g83bfcb8d6e91-dirty (Oct 28 2026 - 16:45:25)
   x0: 00000000 fdcc0098
   x1: 00000000 00000008
   x2: 00000000 fdcc1000
   x3: 00000000 00000006
   x4: 00000000 00000050
   x5: 00000000 00000000
   x6: 00000000 00020002
   sp: 00000000 fdcc0f30
   BOOTSOURCE_ID fdcc0010: 0000000a
   PMU_CRU fdd00000: 00004064
   PMU_CRU fdd00004: 000014c1
   PMU_CRU fdd0000c: 00000007
   PMU_CRU fdd00010: 00007f00
   PMU_CRU fdd00040: 00002063
   PMU_CRU fdd00044: 00001481
   PMU_CRU fdd0004c: 00000007
   PMU_CRU fdd00050: 00007f00
   PMU_CRU fdd00100: 00000080
   PMU_CRU fdd00108: 00000001
   PMU_CRU fdd0010c: 00000001
   PMU_CRU fdd00110: 00000800
   PMU_CRU fdd00118: 00000001
   PMU_CRU fdd0011c: 00000009
   PMU_CRU fdd00120: 0000050f
   PMU_CRU fdd00124: 00008bbb
   PMU_CRU fdd00188: 00006000  (pmu_clkgate_con[2])
   PMU_CRU fdd00240: 00040020
   DRAM init failed
Quoted 3 lines

Above should hopefully make it clear that the reset value in TRM is likely incorrect ;-)

Wouldn't be the first nor the last time this happens :)

Quoted 29 lines
Quoted 17 lines
Quoted 7 lines

unconditionally ungate these clocks to help ensure PCIe works in U-Boot proper.

Change to only ungate these clocks when the PCI Kconfig option is enabled for current boot phase to delay the ungate as late as possible.

Quoted 9 lines

---
Changes in v3:
- New optional patch to help delay the ungate of PCIe ref clocks until U-Boot proper

This patch is strictly not needed, however it seems very unnecessary to ungate PCIe ref clocks in SPL when PCIe typically only is used in proper.

Quoted 8 lines

Considering the kernel seems (I had a cursory look) to be able to control those clocks and have them handled via the pcie node, it seems fine to me to possibly not have the clock enabled by U-Boot (e.g. with U-Boot proper or xPL not enabling PCI).

So, I'm fine with the content of the patch, not the commit log. Can you please confirm that they are indeed not at 0 when reset (and/or that we do this to be safe when doing reboots) and rework the commit log?

As mentioned above, the commit message has been correct from start, so please be explicit about what you think is unclear and needs to change.

Quoted 11 lines
Quoted 2 lines

You could have just said that it doesn't match the TRM, that would have told me that it was checked IRL.

I did not even notice that the reset state in TRM was different, all my changes are typically confirmed using runtime testing ;-)

Quoted 5 lines

I can reword the first sentence to

The CLK_PCIE30PHY_REF_M and CLK_PCIE30PHY_REF_N clocks are by default gated coming out from system reset unlike stated in the TRM.

In case, I would add TRM document version (1.3 ?) too.

Regards,
Massimo

Quoted 15 lines
Quoted 2 lines

when applying, does that work for you?

Sure, please feel free to make any change you see fit to any of my patches :-)

Regards,
Jonas

Quoted 5 lines

Thanks!
Quentin

#7 lore raw

Re: [PATCH v3 1/5] clk: rockchip: rk3568: Ungate PCIE30PHY_REF clocks when PCI is enabled

In reply to Jonas Karlman

Hi Jonas,

Quoted 29 lines · Jonas Karlman

Hi Quentin,

Quoted 17 lines · Quentin Schulz

Hi Jonas,

Quoted 14 lines · Jonas Karlman

Hi Quentin,

Quoted 10 lines · Quentin Schulz

Hi Jonas,

Quoted 2 lines · Jonas Karlman

The CLK_PCIE30PHY_REF_M and CLK_PCIE30PHY_REF_N clocks are by default gated coming out from system reset. The probe() ops of the PMUCRU driver

Are they? I don't have an RK3568 board so cannot test this, but the TRM says the bitfields are 0 at reset with "When high, disable clock", so I am not sure what exactly this is for (except after a reboot where the Linux kernel has disabled the PCIe clocks maybe?).

Quoted 8 lines
Quoted 4 lines

I guess the TRM is incorrect, because as I mention in my commit message these clocks comes gated out from system reset, or I would never have phrased the commit message as such.

Well, it could also be inferred from the fact Rockchip enabled it in the CRU driver unconditionally. So I wanted to make sure it was indeed checked rather than simply inferred. Thank you for the confirmation.

Quoted 8 lines

I would most likely have phrased the message very differently if the out of system reset state was not tested, or at least mention that it would have been a refactor based on current code if that was the case.

My expectation (and practice) are that when something is definitively worded in commit message it has been verified to be true, else there is a note and/or the wording is much more relaxed.

Those expectations have been heavily tested in the last few months (not by you) and proven multiple times wrong, unfortunately. In many cases, words don't mean much anymore and they just make plausible sentences. Such is the state of the industry in the last couple of years and especially more in the last few months. I used to be skeptical but I'm near paranoid nowadays. Please rest assured it's not personal, though I understand the frustration of having to justify something you've spent time debugging and investigating yourself. It sucks for you, it sucks for me, it sucks for everybody. I wish it wasn't like that. I'll try to be more mindful in my future interactions with you.

[...]

Quoted 6 lines
Quoted 2 lines

You could have just said that it doesn't match the TRM, that would have told me that it was checked IRL.

I did not even notice that the reset state in TRM was different, all my changes are typically confirmed using runtime testing ;-)

I unfortunately own very few devices, so I don't have much except the TRM to help me review code :) Hopefully, this should change soon as I'm slowly building my own labgrid lab and collecting boards, but nothing will happen quickly, I'm pretty slow :)

Quoted 11 lines
Quoted 7 lines

I can reword the first sentence to

The CLK_PCIE30PHY_REF_M and CLK_PCIE30PHY_REF_N clocks are by default gated coming out from system reset unlike stated in the TRM.

when applying, does that work for you?

Sure, please feel free to make any change you see fit to any of my patches :-)

I value your input on my suggestions and I am capable of making mistakes, so I'll keep asking for confirmation for changes I'm planning to make when applying, thanks for the cart blanche though :)

Cheers,
Quentin

#8 lore raw

PATCH v3 2/5 clk: rockchip: rk3568: Always initialize clocks in SPL

In reply to 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 drivers to be probed after bind in SPL to help ensure a deterministic probe and clock initialization behavior prior to booting from devices.

---
Changes in v3:
- Also add probe-after-bind to the pmucru driver for consistency. The PPLL default rate is 24 MHz and is changed to 200 MHz in probe(), this also happens in proper so probe() in SPL is strictly not needed.

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

---
 drivers/clk/rockchip/clk_rk3568.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/clk/rockchip/clk_rk3568.c +12 -3
index ce17d42ea0f0..c3973215c37e 100644
@@ -494,14 +494,19 @@ static int rk3568_pmuclk_ofdata_to_platdata(struct udevice *dev)
 
 static int rk3568_pmuclk_bind(struct udevice *dev)
 {
-#if CONFIG_IS_ENABLED(RESET_ROCKCHIP)
-	int ret = 0;
+	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);
+
+	if (!CONFIG_IS_ENABLED(RESET_ROCKCHIP))
+		return 0;
 
 	ret = offsetof(struct rk3568_pmucru, pmu_softrst_con[0]);
 	ret = rockchip_reset_bind(dev, ret, 1);
 	if (ret)
 		debug("Warning: pmucru software reset driver bind failed\n");
-#endif
 
 	return 0;
 }
@@ -2936,6 +2941,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
Reviewed-by on v3 2/5
#9 lore raw

Re: [PATCH v3 2/5] clk: rockchip: rk3568: Always initialize clocks in SPL

Hi Jonas,

Quoted 10 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.

Quoted 6 lines

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

Thanks!
Quentin

#10 lore raw

PATCH v3 3/5 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 v3:
- Collect t-b tag

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
#11 lore raw

PATCH v3 4/5 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 v3:
- Collect r-b tag

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
#12 lore raw

PATCH v3 5/5 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.

---
v3: Collect r-b tag
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
#13 lore raw
In reply to Jonas Karlman
Quoted 11 lines · Jonas Karlman

The RK35xx clock drivers typically initialize 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 there is 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.

[...]

Applied to https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip (u-boot-rockchip-2027.01), thanks!

[1/5] clk: rockchip: rk3568: Ungate PCIE30PHY_REF clocks when PCI is enabled

      https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/1d28b4d1e2c164d03953a5ce5efe1732046401de
[2/5] clk: rockchip: rk3568: Always initialize clocks in SPL
      https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/fffeb5318d01427fcca8218ea853b6f43f8f9d34
[3/5] clk: rockchip: rk3588: Always initialize clocks in SPL
      https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/514663543ecf9aa24320efb68994b7ec87b1cdf5
[4/5] clk: rockchip: rk3576: Always initialize clocks in SPL
      https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/62cbf47dc054e4d3b1e7768bf6e854e4d8cd0f53
[5/5] clk: rockchip: rk3528: Always initialize clocks in SPL
      https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/41da99375dde5645941df10a0bf407bf623132a1

Best regards,

Signature · 1 line
Quentin Schulz <[email protected]>