Skip to contentSkip to conversation

Support multiple SDRAM configs in PX30 TPL

PATCH Superseded Massimo Pegorer 3 participants 21 messages Oct 25 – Nov 18 Arm Rockchip

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Support multiple SDRAM configs in PX30 TPL

TPL max size for Rockchip PX30 SoC is very low, but 10240 bytes are enough to store in two SDRAM configuration parameters sets if option CONFIG_RAM_ROCKCHIP_DEBUG is deselected.

The approach is trivial: apply the supported SDRAM config sets in alphabetical order (DDR3, DDR4, LPDDR2, LPDDR3) stopping at the first one that makes SDRAM initialization function to complete with success. The chosen order is debatable and not based on any specific reason. If a smarter cleverer or more reliable approach exists, suggestions are welcome.

The patches have been tested on two boards, one equipped with DDR3 and the other with DDR4. All possible sets selections have been tested, even with orders different from predefined one (e.g.: LPDDR2, DDR4, LPDDR3, DDR3). It would be useful if further tests will be run on other PX30 based boards.

The first patch improves clarity of SDRAM type support selection for Rockchip SoCs at Kconfig level. Not all the SDRAM type config options named in the Kconfig are supported by each of the Rockchip SoCs. And no more than one SDRAM type is supported at a time by current PX30 and RV1126 drivers.

The third patch slightly optimizes space of sdram driver debugging code, and the fourth add a new configuration option to allow limited debugging code to coexist with multiple SDRAM types support in the constrained PX30 TPL.

---
Changes in v2:
- Update and reword cover letter.
- Do not duplicate config options based on SoC.
- Add SDRAM config option for DDR3 explicit selection.
- Raise compile time error if no SDRAM type is selected.
- Raise compile time error if more than one type is selected but the driver does not support more than one at a time.
- Change order to alphabetical one, as the most trivial option.
- Slightly optimize sdram driver debugging code.
- Add config option for size-constrained driver debugging.
- Link to v1: https://patch.msgid.link/[email protected]

To: Simon Glass <[email protected]>
To: [email protected]
To: Quentin Schulz <[email protected]>
Cc: Kever Yang <[email protected]>
Cc: Tom Rini <[email protected]>
Cc: Massimo Pegorer <[email protected]>

---
Massimo Pegorer (4):
ram: rockchip: improve sdram type configs selection
ram: rockchip: px30: allow multiple SDRAM types selection
ram: rockchip: reduce debugging code size
ram: rockchip: add config option for tinier debug

 drivers/ram/rockchip/Kconfig        |  35 ++++++++++---
 drivers/ram/rockchip/sdram_common.c | 101 ++++++++++++++++--------------------
 drivers/ram/rockchip/sdram_px30.c   |  39 ++++++++------
 drivers/ram/rockchip/sdram_rv1126.c |  54 +++++++++++--------
 4 files changed, 125 insertions(+), 104 deletions(-)

---
base-commit: 8649a54d301a4d0ac526324c7a7ad2574939ff27
change-id: 20260828-ddr-multi-2c4fd64344c8

Best regards,

Signature · 1 line
Massimo Pegorer <[email protected]>
#1 lore raw

PATCH v2 1/4 ram: rockchip: improve sdram type configs selection

Not all the SDRAM types config options named in the Kconfig are supported by each of the Rockchip SoCs: improve clarity adding SoC dependencies to the options.

Add a new RAM_ROCKCHIP_DDR3 option and remove PX30 and RV1126 sdram drivers fallback behaviour when no SDRAM type option is selected, raising a compile time error in this case, instead. The new option has a default true value if no other SDRAM option is true to avoid impacts on defconfigs.

Moreover, these drivers support only one SDRAM type at a time: when more options are selected, avoid debatable preemption of one over the others, and raise a compile time error instead.

---
 drivers/ram/rockchip/Kconfig        | 24 +++++++++++------
 drivers/ram/rockchip/sdram_px30.c   | 17 +++++++++---
 drivers/ram/rockchip/sdram_rv1126.c | 54 +++++++++++++++++++++----------------
 3 files changed, 60 insertions(+), 35 deletions(-)
drivers/ram/rockchip/Kconfig +16 -8
index d707d09c1c8..f51ae6a4542 100644
@@ -24,28 +24,36 @@ config RAM_ROCKCHIP_DEBUG
 	  This is an option for developers to understand the ram drivers
 	  initialization, configurations and etc.
 
+config RAM_ROCKCHIP_DDR3
+	bool "DDR3 support for Rockchip SoCs"
+	depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126
+	default y if !RAM_ROCKCHIP_DDR4 && !RAM_ROCKCHIP_LPDDR2 && \
+		!RAM_ROCKCHIP_LPDDR3 && !RAM_ROCKCHIP_LPDDR4
+	help
+	  Enable DDR3 sdram support on Rockchip SoCs.
+
 config RAM_ROCKCHIP_DDR4
 	bool "DDR4 support for Rockchip SoCs"
+	depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126
 	help
-	  This enables DDR4 sdram support instead of the default DDR3 support
-	  on Rockchip SoCs.
+	  Enable DDR4 sdram support on Rockchip SoCs.
 
 config RAM_ROCKCHIP_LPDDR2
 	bool "LPDDR2 support for Rockchip SoCs"
+	depends on ROCKCHIP_PX30
 	help
-	  This enables LPDDR2 sdram support instead of the default DDR3 support
-	  on Rockchip SoCs.
+	  Enable LPDDR2 sdram support on Rockchip SoCs.
 
 config RAM_ROCKCHIP_LPDDR3
 	bool "LPDDR3 support for Rockchip SoCs"
+	depends on ROCKCHIP_PX30
 	help
-	  This enables LPDDR3 sdram support instead of the default DDR3 support
-	  on Rockchip SoCs.
+	  Enable LPDDR3 sdram support on Rockchip SoCs.
 
 config RAM_ROCKCHIP_LPDDR4
+	depends on ROCKCHIP_RK3399 || ROCKCHIP_RV1126
 	bool "LPDDR4 support for Rockchip SoCs"
 	help
-	  This enables LPDDR4 sdram code support for the platforms based
-	  on Rockchip SoCs.
+	  Enable LPDDR4 sdram support on Rockchip SoCs.
 
 endif # RAM_ROCKCHIP
drivers/ram/rockchip/sdram_px30.c +13 -4
index 37e62120504..c7ff924b2c5 100644
@@ -123,15 +123,24 @@ u32 addrmap[][8] = {
 
 struct dram_info dram_info;
 
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3) + \
+	IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4) + \
+	IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2) + \
+	IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3) > 1
+#error "This driver only supports one DRAM configuration at a time"
+#endif
+
 struct px30_sdram_params sdram_configs[] = {
-#if defined(CONFIG_RAM_ROCKCHIP_DDR4)
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3)
+#include	"sdram-px30-ddr3-detect-333.inc"
+#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
 #include	"sdram-px30-ddr4-detect-333.inc"
-#elif defined(CONFIG_RAM_ROCKCHIP_LPDDR2)
+#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
 #include	"sdram-px30-lpddr2-detect-333.inc"
-#elif defined(CONFIG_RAM_ROCKCHIP_LPDDR3)
+#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)
 #include	"sdram-px30-lpddr3-detect-333.inc"
 #else
-#include	"sdram-px30-ddr3-detect-333.inc"
+#error "Please select suitable DRAM type CONFIG_RAM_ROCKCHIP option"
 #endif
 };
 
drivers/ram/rockchip/sdram_rv1126.c +31 -23

62 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH v2 1/4] ram: rockchip: improve sdram type configs selection

Hi Massimo,

Quoted 27 lines · Massimo Pegorer

Not all the SDRAM types config options named in the Kconfig are supported by each of the Rockchip SoCs: improve clarity adding SoC dependencies to the options.

Add a new RAM_ROCKCHIP_DDR3 option and remove PX30 and RV1126 sdram drivers fallback behaviour when no SDRAM type option is selected, raising a compile time error in this case, instead. The new option has a default true value if no other SDRAM option is true to avoid impacts on defconfigs.

Moreover, these drivers support only one SDRAM type at a time: when more options are selected, avoid debatable preemption of one over the others, and raise a compile time error instead.

---
  drivers/ram/rockchip/Kconfig        | 24 +++++++++++------
  drivers/ram/rockchip/sdram_px30.c   | 17 +++++++++---
  drivers/ram/rockchip/sdram_rv1126.c | 54 +++++++++++++++++++++----------------
  3 files changed, 60 insertions(+), 35 deletions(-)
drivers/ram/rockchip/Kconfig +0 -0
index d707d09c1c8..f51ae6a4542 100644
@@ -24,28 +24,36 @@ config RAM_ROCKCHIP_DEBUG
  	  This is an option for developers to understand the ram drivers

drivers/ram/rockchip/Kconfig config RAM_ROCKCHIP_DEBUG · line 34

Quoted 10 lines
drivers/ram/rockchip/Kconfig +8 -0
  	  initialization, configurations and etc.
 
+config RAM_ROCKCHIP_DDR3
+	bool "DDR3 support for Rockchip SoCs"
+	depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126
+	default y if !RAM_ROCKCHIP_DDR4 && !RAM_ROCKCHIP_LPDDR2 && \
+		!RAM_ROCKCHIP_LPDDR3 && !RAM_ROCKCHIP_LPDDR4
+	help
+	  Enable DDR3 sdram support on Rockchip SoCs.
+

issue: too much done in one commit

Please split this into multiple commits. I could identify:
- add SoC dependency for existing DRAM Kconfig symbols (with the change to the helptext to make it generic)
- add new DDR3 symbol and gate existing code with it. That is, rv1126 and px30 should have their #else for their DDR3 timings gated by this symbol. A new #else can call #error so the build fails in case of incorrect configuration, like you did here,
- enforce only one selectable DRAM init for PX30 and RV1126,

Quoted 22 lines
drivers/ram/rockchip/Kconfig +5 -6
  config RAM_ROCKCHIP_DDR4
  	bool "DDR4 support for Rockchip SoCs"
+	depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126
  	help
-	  This enables DDR4 sdram support instead of the default DDR3 support
-	  on Rockchip SoCs.
+	  Enable DDR4 sdram support on Rockchip SoCs.
 
  config RAM_ROCKCHIP_LPDDR2
  	bool "LPDDR2 support for Rockchip SoCs"
+	depends on ROCKCHIP_PX30
  	help
-	  This enables LPDDR2 sdram support instead of the default DDR3 support
-	  on Rockchip SoCs.
+	  Enable LPDDR2 sdram support on Rockchip SoCs.
 
  config RAM_ROCKCHIP_LPDDR3
  	bool "LPDDR3 support for Rockchip SoCs"
+	depends on ROCKCHIP_PX30
  	help
-	  This enables LPDDR3 sdram support instead of the default DDR3 support
-	  on Rockchip SoCs.

drivers/ram/rockchip/Kconfig config RAM_ROCKCHIP_DEBUG · line 58

Quoted 10 lines
drivers/ram/rockchip/Kconfig +3 -2
+	  Enable LPDDR3 sdram support on Rockchip SoCs.
 
  config RAM_ROCKCHIP_LPDDR4
+	depends on ROCKCHIP_RK3399 || ROCKCHIP_RV1126
  	bool "LPDDR4 support for Rockchip SoCs"
  	help
-	  This enables LPDDR4 sdram code support for the platforms based
-	  on Rockchip SoCs.
+	  Enable LPDDR4 sdram support on Rockchip SoCs.
 

Because I checked, and for future reference:

PX30 supports LPDDR2/LPDDR3/DDR3/DDR4. Only one selectable at a time currently.
RK3368 only supports DDR3.
RK3066 supports DDR3/LPDDR3 but only DDR3 is used (MK808 device, configuration via Device Tree and OF_PLATDATA)
RK3188 supports DDR3/LPDDR3 but only DDR3 is used (Radxa Rock, configuration via Device Tree and OF_PLATDATA)
RK322x supports DDR3/LPDDR2/LPDDR3 but only DDR3 is used (RK3229 EVB, configuration via Device Tree and OF_PLATDATA)
RK3288 supports DDR3/LPDDR3, both used via e.g. Rock Pi N8 (LDDR3) and Rock2 Square (DDR3), configuration via device tree and OF_PLATDATA)
RK3328 supports DDR3/LPDDR3/DDR4, all used, via e.g. Rock Pi E (DDR3), Rock64 (LPDDR3) and Orange Pi R1S Plus (DDR4).
RK3399 supports DDR3/LPDDR3/LDDR4, all used, via e.g. Puma (DDR3), Gru Bob (LPDDR3), PinePhone Pro (LPDDR4). Either DDR3/LPDDR3 or LPDDR4, not both. We should check for this in the driver. RV1126 supports DDR3/DDR4/LPDDR3/LPDDR4, but no timings for LPDDR3. Only one selectable at a time currently.

The common theme though is that they are all configured via Device Tree (via OF_PLATDATA) where the dramtype is hardcoded, and this here would be the first to try to do autodetection of the DRAM and init properly.

Quoted 17 lines
drivers/ram/rockchip/Kconfig +0 -0
  endif # RAM_ROCKCHIP
drivers/ram/rockchip/sdram_px30.c +7 -0
index 37e62120504..c7ff924b2c5 100644
@@ -123,15 +123,24 @@ u32 addrmap[][8] = {
 
  struct dram_info dram_info;
 
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3) + \
+	IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4) + \
+	IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2) + \
+	IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3) > 1
+#error "This driver only supports one DRAM configuration at a time"
+#endif
+
  struct px30_sdram_params sdram_configs[] = {

drivers/ram/rockchip/sdram_px30.c u32 addrmap[][8] = { · line 140

Quoted 10 lines
drivers/ram/rockchip/sdram_px30.c +5 -3
-#if defined(CONFIG_RAM_ROCKCHIP_DDR4)
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3)
+#include	"sdram-px30-ddr3-detect-333.inc"
+#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
  #include	"sdram-px30-ddr4-detect-333.inc"
-#elif defined(CONFIG_RAM_ROCKCHIP_LPDDR2)
+#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
  #include	"sdram-px30-lpddr2-detect-333.inc"
-#elif defined(CONFIG_RAM_ROCKCHIP_LPDDR3)
+#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)

question: what's the benefit to switch defined() to IS_ENABLED?

It almost made me miss the fact this reorders the DRAM timings array.

I think the reordering should be made in a separate commit, possibly the one where it's possible to select more than one

Cheers,
Quentin

#3 lore raw

Re: [PATCH v2 1/4] ram: rockchip: improve sdram type configs selection

Quoted 84 lines · Quentin Schulz

Hi Massimo,

Quoted 29 lines · Massimo Pegorer

Not all the SDRAM types config options named in the Kconfig are supported by each of the Rockchip SoCs: improve clarity adding SoC dependencies to the options.

Add a new RAM_ROCKCHIP_DDR3 option and remove PX30 and RV1126 sdram drivers fallback behaviour when no SDRAM type option is selected, raising a compile time error in this case, instead. The new option has a default true value if no other SDRAM option is true to avoid impacts on defconfigs.

Moreover, these drivers support only one SDRAM type at a time: when more options are selected, avoid debatable preemption of one over the others, and raise a compile time error instead.

---
  drivers/ram/rockchip/Kconfig        | 24 +++++++++++------ drivers/ram/rockchip/sdram_px30.c   | 17 +++++++++--- drivers/ram/rockchip/sdram_rv1126.c | 54 ++++++++++++++++++++
+----------------

  3 files changed, 60 insertions(+), 35 deletions(-)
drivers/ram/rockchip/Kconfig +0 -0
index d707d09c1c8..f51ae6a4542 100644
@@ -24,28 +24,36 @@ config RAM_ROCKCHIP_DEBUG

        This is an option for developers to understand the ram drivers initialization, configurations and etc.

drivers/ram/rockchip/Kconfig config RAM_ROCKCHIP_DEBUG · line 34

Quoted 8 lines
drivers/ram/rockchip/Kconfig +8 -0
+config RAM_ROCKCHIP_DDR3
+    bool "DDR3 support for Rockchip SoCs"
+    depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126
+    default y if !RAM_ROCKCHIP_DDR4 && !RAM_ROCKCHIP_LPDDR2 && \
+        !RAM_ROCKCHIP_LPDDR3 && !RAM_ROCKCHIP_LPDDR4
+    help
+      Enable DDR3 sdram support on Rockchip SoCs.
+

issue: too much done in one commit

Please split this into multiple commits. I could identify:
- add SoC dependency for existing DRAM Kconfig symbols (with the change
to the helptext to make it generic)
- add new DDR3 symbol and gate existing code with it. That is, rv1126
and px30 should have their #else for their DDR3 timings gated by this symbol. A new #else can call #error so the build fails in case of incorrect configuration, like you did here,
- enforce only one selectable DRAM init for PX30 and RV1126,

Quoted 23 lines

  config RAM_ROCKCHIP_DDR4
      bool "DDR4 support for Rockchip SoCs"
+    depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126
      help
-      This enables DDR4 sdram support instead of the default DDR3 support
-      on Rockchip SoCs.
+      Enable DDR4 sdram support on Rockchip SoCs.
  config RAM_ROCKCHIP_LPDDR2
      bool "LPDDR2 support for Rockchip SoCs"
+    depends on ROCKCHIP_PX30
      help
-      This enables LPDDR2 sdram support instead of the default DDR3 support
-      on Rockchip SoCs.
+      Enable LPDDR2 sdram support on Rockchip SoCs. config RAM_ROCKCHIP_LPDDR3
      bool "LPDDR3 support for Rockchip SoCs"
+    depends on ROCKCHIP_PX30
      help
-      This enables LPDDR3 sdram support instead of the default DDR3 support
-      on Rockchip SoCs.

Quoted 8 lines

+      Enable LPDDR3 sdram support on Rockchip SoCs. config RAM_ROCKCHIP_LPDDR4
+    depends on ROCKCHIP_RK3399 || ROCKCHIP_RV1126
      bool "LPDDR4 support for Rockchip SoCs"
      help
-      This enables LPDDR4 sdram code support for the platforms based -      on Rockchip SoCs.
+      Enable LPDDR4 sdram support on Rockchip SoCs.

Because I checked, and for future reference:

Quoted 10 lines

PX30 supports LPDDR2/LPDDR3/DDR3/DDR4. Only one selectable at a time currently.
RK3368 only supports DDR3.
RK3066 supports DDR3/LPDDR3 but only DDR3 is used (MK808 device, configuration via Device Tree and OF_PLATDATA)
RK3188 supports DDR3/LPDDR3 but only DDR3 is used (Radxa Rock, configuration via Device Tree and OF_PLATDATA)
RK322x supports DDR3/LPDDR2/LPDDR3 but only DDR3 is used (RK3229 EVB, configuration via Device Tree and OF_PLATDATA)
RK3288 supports DDR3/LPDDR3, both used via e.g. Rock Pi N8 (LDDR3) and Rock2 Square (DDR3), configuration via device tree and OF_PLATDATA)
RK3328 supports DDR3/LPDDR3/DDR4, all used, via e.g. Rock Pi E (DDR3), Rock64 (LPDDR3) and Orange Pi R1S Plus (DDR4).
RK3399 supports DDR3/LPDDR3/LDDR4, all used, via e.g. Puma (DDR3), Gru Bob (LPDDR3), PinePhone Pro (LPDDR4). Either DDR3/LPDDR3 or LPDDR4, not both. We should check for this in the driver. RV1126 supports DDR3/DDR4/LPDDR3/LPDDR4, but no timings for LPDDR3. Only one selectable at a time currently.

And RK3036 only has DDR3 boards supported.

Quoted 36 lines

The common theme though is that they are all configured via Device Tree (via OF_PLATDATA) where the dramtype is hardcoded, and this here would be the first to try to do autodetection of the DRAM and init properly.

Quoted 15 lines

  endif # RAM_ROCKCHIP

drivers/ram/rockchip/sdram_px30.c +7 -0
index 37e62120504..c7ff924b2c5 100644
@@ -123,15 +123,24 @@ u32 addrmap[][8] = {
   struct dram_info dram_info;
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3) + \
+    IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4) + \
+    IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2) + \
+    IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3) > 1
+#error "This driver only supports one DRAM configuration at a time"
+#endif
+
   struct px30_sdram_params sdram_configs[] = {

drivers/ram/rockchip/sdram_px30.c u32 addrmap[][8] = { · line 138

Quoted 10 lines
drivers/ram/rockchip/sdram_px30.c +5 -3
-#if defined(CONFIG_RAM_ROCKCHIP_DDR4)
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3)
+#include    "sdram-px30-ddr3-detect-333.inc"
+#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
   #include    "sdram-px30-ddr4-detect-333.inc"
-#elif defined(CONFIG_RAM_ROCKCHIP_LPDDR2)
+#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
   #include    "sdram-px30-lpddr2-detect-333.inc"
-#elif defined(CONFIG_RAM_ROCKCHIP_LPDDR3)
+#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)

question: what's the benefit to switch defined() to IS_ENABLED?

It almost made me miss the fact this reorders the DRAM timings array.

I think the reordering should be made in a separate commit, possibly the one where it's possible to select more than one

Cheers,
Quentin

#4 lore raw

Re: [PATCH v2 1/4] ram: rockchip: improve sdram type configs selection

Hi Quentin

Il giorno mer 11 nov 2026 alle ore 17:08 Quentin Schulz ha scritto:

Quoted 44 lines · Quentin Schulz
Quoted 43 lines

Hi Massimo,

Quoted 27 lines · Massimo Pegorer

Not all the SDRAM types config options named in the Kconfig are supported by each of the Rockchip SoCs: improve clarity adding SoC dependencies to the options.

Add a new RAM_ROCKCHIP_DDR3 option and remove PX30 and RV1126 sdram drivers fallback behaviour when no SDRAM type option is selected, raising a compile time error in this case, instead. The new option has a default true value if no other SDRAM option is true to avoid impacts on defconfigs.

Moreover, these drivers support only one SDRAM type at a time: when more options are selected, avoid debatable preemption of one over the others, and raise a compile time error instead.

---
  drivers/ram/rockchip/Kconfig        | 24 +++++++++++------
  drivers/ram/rockchip/sdram_px30.c   | 17 +++++++++---
  drivers/ram/rockchip/sdram_rv1126.c | 54 ++++++++++++++++++++
+----------------
  3 files changed, 60 insertions(+), 35 deletions(-)
drivers/ram/rockchip/Kconfig +0 -0
index d707d09c1c8..f51ae6a4542 100644

drivers/ram/rockchip/Kconfig config RAM_ROCKCHIP_DEBUG · line 33

Quoted 10 lines
drivers/ram/rockchip/Kconfig +8 -0
@@ -24,28 +24,36 @@ config RAM_ROCKCHIP_DEBUG
        This is an option for developers to understand the ram drivers
        initialization, configurations and etc.
+config RAM_ROCKCHIP_DDR3
+    bool "DDR3 support for Rockchip SoCs"
+    depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126
+    default y if !RAM_ROCKCHIP_DDR4 && !RAM_ROCKCHIP_LPDDR2 && \
+        !RAM_ROCKCHIP_LPDDR3 && !RAM_ROCKCHIP_LPDDR4
+    help
+      Enable DDR3 sdram support on Rockchip SoCs.
+

issue: too much done in one commit

Quoted 3 lines
Quoted 3 lines

Please split this into multiple commits. I could identify:
- add SoC dependency for existing DRAM Kconfig symbols (with the change to the helptext to make it generic)

I will do it in v3.

Quoted 4 lines
Quoted 4 lines

- add new DDR3 symbol and gate existing code with it. That is, rv1126 and px30 should have their #else for their DDR3 timings gated by this symbol. A new #else can call #error so the build fails in case of incorrect configuration, like you did here,

I will do it in v3. Do you agree on keeping in this commit the default y for the new DDR3 symbol if none of the other RAM_ROCKCHIP symbols are selected? This should avoid affecting defconfigs.

I will also drop defined/IS_ENABLED substitutions, see below about this topic.

Quoted 1 line
Quoted 1 line

- enforce only one selectable DRAM init for PX30 and RV1126,

I will do it in v3.

Quoted 55 lines
Quoted 45 lines
Quoted 23 lines
drivers/ram/rockchip/Kconfig +1 -1
  config RAM_ROCKCHIP_DDR4
      bool "DDR4 support for Rockchip SoCs"
+    depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126
      help
-      This enables DDR4 sdram support instead of the default DDR3

support

drivers/ram/rockchip/Kconfig +2 -2
-      on Rockchip SoCs.
+      Enable DDR4 sdram support on Rockchip SoCs.
  config RAM_ROCKCHIP_LPDDR2
      bool "LPDDR2 support for Rockchip SoCs"
+    depends on ROCKCHIP_PX30
      help
-      This enables LPDDR2 sdram support instead of the default DDR3

support

drivers/ram/rockchip/Kconfig +2 -2
-      on Rockchip SoCs.
+      Enable LPDDR2 sdram support on Rockchip SoCs.
  config RAM_ROCKCHIP_LPDDR3
      bool "LPDDR3 support for Rockchip SoCs"
+    depends on ROCKCHIP_PX30
      help
-      This enables LPDDR3 sdram support instead of the default DDR3

support

drivers/ram/rockchip/Kconfig config RAM_ROCKCHIP_DEBUG · line 57

Quoted 9 lines
drivers/ram/rockchip/Kconfig +3 -3
-      on Rockchip SoCs.
+      Enable LPDDR3 sdram support on Rockchip SoCs.
  config RAM_ROCKCHIP_LPDDR4
+    depends on ROCKCHIP_RK3399 || ROCKCHIP_RV1126
      bool "LPDDR4 support for Rockchip SoCs"
      help
-      This enables LPDDR4 sdram code support for the platforms based
-      on Rockchip SoCs.
+      Enable LPDDR4 sdram support on Rockchip SoCs.

Because I checked, and for future reference:

PX30 supports LPDDR2/LPDDR3/DDR3/DDR4. Only one selectable at a time currently.
RK3368 only supports DDR3.
RK3066 supports DDR3/LPDDR3 but only DDR3 is used (MK808 device, configuration via Device Tree and OF_PLATDATA)
RK3188 supports DDR3/LPDDR3 but only DDR3 is used (Radxa Rock, configuration via Device Tree and OF_PLATDATA)
RK322x supports DDR3/LPDDR2/LPDDR3 but only DDR3 is used (RK3229 EVB, configuration via Device Tree and OF_PLATDATA)
RK3288 supports DDR3/LPDDR3, both used via e.g. Rock Pi N8 (LDDR3) and

Quoted 9 lines

Rock2 Square (DDR3), configuration via device tree and OF_PLATDATA) RK3328 supports DDR3/LPDDR3/DDR4, all used, via e.g. Rock Pi E (DDR3), Rock64 (LPDDR3) and Orange Pi R1S Plus (DDR4).
RK3399 supports DDR3/LPDDR3/LDDR4, all used, via e.g. Puma (DDR3), Gru Bob (LPDDR3), PinePhone Pro (LPDDR4). Either DDR3/LPDDR3 or LPDDR4, not both. We should check for this in the driver.
RV1126 supports DDR3/DDR4/LPDDR3/LPDDR4, but no timings for LPDDR3. Only one selectable at a time currently.

Quoted 1 line

And RK3036 only has DDR3 boards supported.

I think this information, even if available in the public domain, could be useful also in U-Boot Rockchip documentation: would you like me to try to add it to the documentation within another series? It could be useful to know if these drivers have ever been tested/used in the past with RAM types currently not used by any of the boards maintained in U-Boot.

Quoted 25 lines
Quoted 25 lines

The common theme though is that they are all configured via Device Tree (via OF_PLATDATA) where the dramtype is hardcoded, and this here would be the first to try to do autodetection of the DRAM and init properly.

Quoted 20 lines

endif # RAM_ROCKCHIP

drivers/ram/rockchip/ renamed from drivers/ram/rockchip/sdram_px30.c +0 -0

sdram_px30.c
index 37e62120504..c7ff924b2c5 100644

drivers/ram/rockchip/sdram_px30.c +10 -1
@@ -123,15 +123,24 @@ u32 addrmap[][8] = {
  struct dram_info dram_info;
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3) + \
+    IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4) + \
+    IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2) + \
+    IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3) > 1
+#error "This driver only supports one DRAM configuration at a time"
+#endif
+
  struct px30_sdram_params sdram_configs[] = {
-#if defined(CONFIG_RAM_ROCKCHIP_DDR4)
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3)
+#include    "sdram-px30-ddr3-detect-333.inc"
+#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
Quoted 8 lines
Quoted 8 lines

drivers/ram/rockchip/sdram_px30.c u32 addrmap[][8] = { · line 140

Quoted 6 lines
drivers/ram/rockchip/sdram_px30.c +2 -2
  #include    "sdram-px30-ddr4-detect-333.inc"
-#elif defined(CONFIG_RAM_ROCKCHIP_LPDDR2)
+#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
  #include    "sdram-px30-lpddr2-detect-333.inc"
-#elif defined(CONFIG_RAM_ROCKCHIP_LPDDR3)
+#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)

question: what's the benefit to switch defined() to IS_ENABLED?

None. Having checkpatch complain with - WARNING: Use 'if (IS_ENABLED(CONFIG...))'
instead of '#if or #ifdef' where possible - I misinterpreted and supposed to make
it quiet in this way. I was wrong and I did not notice checkpatch was not quieter
at all, obviously. Sorry. I will avoid in v3.

Quoted 2 lines
Quoted 2 lines

It almost made me miss the fact this reorders the DRAM timings array.

I wrote about the reordering based on alphabetical criteria in the cover letter description, and cited it in the v2 changes list, too. Can I help if I put the version changes list per patch instead of grouped in the cover letter?

Quoted 3 lines
Quoted 3 lines

I think the reordering should be made in a separate commit, possibly the one where it's possible to select more than one

In v3, the reordering will be within the "more than one" commit. Right now, that commit affects PX30 only, but reordering will impact RV116 code, too:
I would prefer to keep the ordering criteria (alphabetical) shared between all Rockchip SoCs.

If you prefer reordering in a dedicated commit instead, let me know and I will split reordering from "more than one".

I will send the v3 rebased on next after Monday merging.

Thanks for your time and your support. I really appreciate.

Regards,
Massimo

Quoted 4 lines
Quoted 3 lines

Cheers,
Quentin

#5 lore raw

Re: [PATCH v2 1/4] ram: rockchip: improve sdram type configs selection

Hi Massimo,

Quoted 53 lines · Massimo Pegorer

Hi Quentin

Il giorno mer 11 nov 2026 alle ore 17:08 Quentin Schulz ha scritto:

Quoted 44 lines · Quentin Schulz
Quoted 43 lines

Hi Massimo,

Quoted 27 lines · Massimo Pegorer

Not all the SDRAM types config options named in the Kconfig are supported by each of the Rockchip SoCs: improve clarity adding SoC dependencies to the options.

Add a new RAM_ROCKCHIP_DDR3 option and remove PX30 and RV1126 sdram drivers fallback behaviour when no SDRAM type option is selected, raising a compile time error in this case, instead. The new option has a default true value if no other SDRAM option is true to avoid impacts on defconfigs.

Moreover, these drivers support only one SDRAM type at a time: when more options are selected, avoid debatable preemption of one over the others, and raise a compile time error instead.

---
   drivers/ram/rockchip/Kconfig        | 24 +++++++++++------
   drivers/ram/rockchip/sdram_px30.c   | 17 +++++++++---
   drivers/ram/rockchip/sdram_rv1126.c | 54 ++++++++++++++++++++
+----------------
   3 files changed, 60 insertions(+), 35 deletions(-)
drivers/ram/rockchip/Kconfig +0 -0
index d707d09c1c8..f51ae6a4542 100644

drivers/ram/rockchip/Kconfig config RAM_ROCKCHIP_DEBUG · line 33

Quoted 10 lines
drivers/ram/rockchip/Kconfig +8 -0
@@ -24,28 +24,36 @@ config RAM_ROCKCHIP_DEBUG
         This is an option for developers to understand the ram drivers
         initialization, configurations and etc.
+config RAM_ROCKCHIP_DDR3
+    bool "DDR3 support for Rockchip SoCs"
+    depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126
+    default y if !RAM_ROCKCHIP_DDR4 && !RAM_ROCKCHIP_LPDDR2 && \
+        !RAM_ROCKCHIP_LPDDR3 && !RAM_ROCKCHIP_LPDDR4
+    help
+      Enable DDR3 sdram support on Rockchip SoCs.
+

issue: too much done in one commit

Quoted 3 lines
Quoted 3 lines

Please split this into multiple commits. I could identify:
- add SoC dependency for existing DRAM Kconfig symbols (with the change to the helptext to make it generic)

I will do it in v3.

Quoted 9 lines
Quoted 4 lines
Quoted 4 lines

- add new DDR3 symbol and gate existing code with it. That is, rv1126 and px30 should have their #else for their DDR3 timings gated by this symbol. A new #else can call #error so the build fails in case of incorrect configuration, like you did here,

I will do it in v3. Do you agree on keeping in this commit the default y for the new DDR3 symbol if none of the other RAM_ROCKCHIP symbols are selected? This should avoid affecting defconfigs.

For now yes, but we should think mid-term/long-term about just enabling the symbol in the defconfigs then it makes explicit what the board is supposed to use?

Looking at qconfig.py output:

$ ./tools/qconfig.py -f SPL_RAM RAM_ROCKCHIP '~ROCKCHIP_EXTERNAL_TPL' '~RAM_ROCKCHIP_DDR4' '~RAM_ROCKCHIP_LPDDR2' '~RAM_ROCKCHIP_LPDDR3' '~RAM_ROCKCHIP_LPDDR4'
47 matches
chromebit_mickey chromebook_bob chromebook_jerry chromebook_kevin chromebook_minnie chromebook_speedy eaidk-610-rk3399 evb-px30 evb-px5 evb-rk3229 evb-rk3288-rk808 evb-rk3328 evb-rk3399 ficus-rk3399 firefly-px30 firefly-rk3288 firefly-rk3399 miqi-rk3288 mk808 nanopc-t4-rk3399 nanopi-m4-2gb-rk3399 nanopi-m4-rk3399 nanopi-m4b-rk3399 nanopi-neo4-rk3399 nanopi-r2c-plus-rk3328 nanopi-r2c-rk3328 nanopi-r2s-plus-rk3328 nanopi-r2s-rk3328 odroid-go2 orangepi-r1-plus-lts-rk3328 orangepi-r1-plus-rk3328 orangepi-rk3399 phycore-rk3288 popmetal-rk3288 puma-rk3399 roc-cc-rk3328 rock-pi-e-rk3328 rock-pi-e-v3-rk3328 rock-pi-n10-rk3399pro rock-pi-n8-rk3288 rock2 rock64-rk3328 rock960-rk3399 rock tinker-rk3288 tinker-s-rk3288 vyasa-rk3288

For RK3288/RK3328, it doesn't seem to matter which DDR type is enabled in Kconfig as all is compiled, and the DDR type is detected from the boards' Device Tree (via OF_PLATDATA) at runtime. If we want to be pedantic, we can check the dram type selected in the Device Tree via the rockchip,sdram-params property and select that in the defconfig as well.

For RK3399, the only thing that matters right now is "LPDDR4 enabled or not", the "not" part seemingly means "DDR3/LPDDR3". We can know which applies to which board by looking at which of arch/arm/dts/rk3399-sdram-* dtsi is included in the Device Tree used in U-Boot, and then update the defconfigs to reflect that.

For PX30, it's explicitly DDR3 when nothing else is selected, so we can simply enable it in all defconfigs that don't enable any other, so evb-px30, firefly-px30, odroid-go2).

For PX5/RK3368, only DDR3 is supported, so we could enable it for all defconfigs.

For RK322x, while the driver supports multiple DDR types, we only have DDR3 used in the EVB, so we can simply enable it on that device tree.

Quoted 61 lines

I will also drop defined/IS_ENABLED substitutions, see below about this topic.

Quoted 1 line
Quoted 1 line

- enforce only one selectable DRAM init for PX30 and RV1126,

I will do it in v3.

Quoted 55 lines
Quoted 54 lines
Quoted 23 lines
drivers/ram/rockchip/Kconfig +1 -1
   config RAM_ROCKCHIP_DDR4
       bool "DDR4 support for Rockchip SoCs"
+    depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126
       help
-      This enables DDR4 sdram support instead of the default DDR3

support

drivers/ram/rockchip/Kconfig +2 -2
-      on Rockchip SoCs.
+      Enable DDR4 sdram support on Rockchip SoCs.
   config RAM_ROCKCHIP_LPDDR2
       bool "LPDDR2 support for Rockchip SoCs"
+    depends on ROCKCHIP_PX30
       help
-      This enables LPDDR2 sdram support instead of the default DDR3

support

drivers/ram/rockchip/Kconfig +2 -2
-      on Rockchip SoCs.
+      Enable LPDDR2 sdram support on Rockchip SoCs.
   config RAM_ROCKCHIP_LPDDR3
       bool "LPDDR3 support for Rockchip SoCs"
+    depends on ROCKCHIP_PX30
       help
-      This enables LPDDR3 sdram support instead of the default DDR3

support

drivers/ram/rockchip/Kconfig config RAM_ROCKCHIP_DEBUG · line 57

Quoted 9 lines
drivers/ram/rockchip/Kconfig +3 -3
-      on Rockchip SoCs.
+      Enable LPDDR3 sdram support on Rockchip SoCs.
   config RAM_ROCKCHIP_LPDDR4
+    depends on ROCKCHIP_RK3399 || ROCKCHIP_RV1126
       bool "LPDDR4 support for Rockchip SoCs"
       help
-      This enables LPDDR4 sdram code support for the platforms based
-      on Rockchip SoCs.
+      Enable LPDDR4 sdram support on Rockchip SoCs.

Because I checked, and for future reference:

PX30 supports LPDDR2/LPDDR3/DDR3/DDR4. Only one selectable at a time currently.
RK3368 only supports DDR3.
RK3066 supports DDR3/LPDDR3 but only DDR3 is used (MK808 device, configuration via Device Tree and OF_PLATDATA)
RK3188 supports DDR3/LPDDR3 but only DDR3 is used (Radxa Rock, configuration via Device Tree and OF_PLATDATA)
RK322x supports DDR3/LPDDR2/LPDDR3 but only DDR3 is used (RK3229 EVB, configuration via Device Tree and OF_PLATDATA)
RK3288 supports DDR3/LPDDR3, both used via e.g. Rock Pi N8 (LDDR3) and Rock2 Square (DDR3), configuration via device tree and OF_PLATDATA) RK3328 supports DDR3/LPDDR3/DDR4, all used, via e.g. Rock Pi E (DDR3), Rock64 (LPDDR3) and Orange Pi R1S Plus (DDR4).
RK3399 supports DDR3/LPDDR3/LDDR4, all used, via e.g. Puma (DDR3), Gru Bob (LPDDR3), PinePhone Pro (LPDDR4). Either DDR3/LPDDR3 or LPDDR4, not both. We should check for this in the driver.
RV1126 supports DDR3/DDR4/LPDDR3/LPDDR4, but no timings for LPDDR3. Only one selectable at a time currently.

Quoted 8 lines
Quoted 1 line

And RK3036 only has DDR3 boards supported.

I think this information, even if available in the public domain, could be useful also in U-Boot Rockchip documentation: would you like me to try to add it to the documentation within another series? It could be useful to know if these drivers have ever been tested/used in the past with RAM types currently not used by any of the boards maintained in U-Boot.

The reported support is for the DDR driver, not the DDR controller, just to be clear. There may be more supported by the controller (or fewer if the DDR driver was copied over from another SoC's DDR driver). I also didn't do an in-depth check, just that the code checks for the dram_type/dramtype and does something remotely useful with it.

I don't know where you'd want to put this information, even less so if it's really relevant? Can you tell me what you're thinking, maybe that'll give me some idea or inspiration where to put this section :)

But in general, more documentation = better from my side :)

Quoted 34 lines
Quoted 25 lines
Quoted 25 lines

The common theme though is that they are all configured via Device Tree (via OF_PLATDATA) where the dramtype is hardcoded, and this here would be the first to try to do autodetection of the DRAM and init properly.

Quoted 20 lines

endif # RAM_ROCKCHIP

drivers/ram/rockchip/ renamed from drivers/ram/rockchip/sdram_px30.c +0 -0

sdram_px30.c
index 37e62120504..c7ff924b2c5 100644

drivers/ram/rockchip/sdram_px30.c +10 -1
@@ -123,15 +123,24 @@ u32 addrmap[][8] = {
   struct dram_info dram_info;
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3) + \
+    IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4) + \
+    IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2) + \
+    IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3) > 1
+#error "This driver only supports one DRAM configuration at a time"
+#endif
+
   struct px30_sdram_params sdram_configs[] = {
-#if defined(CONFIG_RAM_ROCKCHIP_DDR4)
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3)
+#include    "sdram-px30-ddr3-detect-333.inc"
+#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
Quoted 8 lines
Quoted 8 lines

drivers/ram/rockchip/sdram_px30.c u32 addrmap[][8] = { · line 140

Quoted 6 lines
drivers/ram/rockchip/sdram_px30.c +2 -2
   #include    "sdram-px30-ddr4-detect-333.inc"
-#elif defined(CONFIG_RAM_ROCKCHIP_LPDDR2)
+#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
   #include    "sdram-px30-lpddr2-detect-333.inc"
-#elif defined(CONFIG_RAM_ROCKCHIP_LPDDR3)
+#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)

question: what's the benefit to switch defined() to IS_ENABLED?

Quoted 8 lines

None. Having checkpatch complain with - WARNING: Use 'if (IS_ENABLED(CONFIG...))'
instead of '#if or #ifdef' where possible - I misinterpreted and supposed to make
it quiet in this way. I was wrong and I did not notice checkpatch was not quieter
at all, obviously. Sorry. I will avoid in v3.

Yeah, sometimes we cannot avoid the checkpatch warning, the usecase here for example. But no worries, I was just wondering if I had missed something :)

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

It almost made me miss the fact this reorders the DRAM timings array.

I wrote about the reordering based on alphabetical criteria in the cover letter description, and cited it in the v2 changes list, too. Can I help if I put the version changes list per patch instead of grouped in the cover letter?

Yes but it'd be best if we don't have to look at the cover letter to understand why a specific change was made.

Quoted 9 lines
Quoted 3 lines
Quoted 3 lines

I think the reordering should be made in a separate commit, possibly the one where it's possible to select more than one

In v3, the reordering will be within the "more than one" commit. Right now, that commit affects PX30 only, but reordering will impact RV116 code, too:
I would prefer to keep the ordering criteria (alphabetical) shared between all Rockchip SoCs.

I think it may be premature to do the same for the RV1126 as we don't know if it's going to work with multiple DDR types, except if you have access to boards with an RV1126 with different DRAM? I agree it'd be best if we had the same order for DDR types... for drivers that actually try to auto-detect the DDR type at runtime, which none do at the moment except PX30 with this series.

I think we need to document which configurations are tested for which SoCs. So for example, for PX30 we could say in the docs that DDR3+DDR4 enabled in the same config is tested, but nothing else. At least it'd set the expectations.

Quoted 7 lines

If you prefer reordering in a dedicated commit instead, let me know and I will split reordering from "more than one".

I will send the v3 rebased on next after Monday merging.

Thanks for your time and your support. I really appreciate.

And thanks for reviewing other people's patches :)

Cheers,
Quentin

#6 lore raw

PATCH v2 2/4 ram: rockchip: px30: allow multiple SDRAM types selection

In reply to Massimo Pegorer

Allow the inclusion of more than one SDRAM parameters set in the PX30 sdram driver. The driver applies included sets in alphabetical order (DDR3, DDR4, LPDDR2, LPDDR3), stopping at the first one that makes SDRAM initialization function to complete with success. This order is debatable and not based on any specific reason.

Due to limited PX30 TPL maximum size, including support for more than one SDRAM type can require disabling some configuration options such as CONFIG_RAM_ROCKCHIP_DEBUG.

---
 drivers/ram/rockchip/sdram_px30.c | 40 +++++++++++++++++----------------------
 1 file changed, 17 insertions(+), 23 deletions(-)
drivers/ram/rockchip/sdram_px30.c +17 -23
index c7ff924b2c5..7f51b9c4f8f 100644
@@ -123,27 +123,24 @@ u32 addrmap[][8] = {
 
 struct dram_info dram_info;
 
-#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3) + \
-	IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4) + \
-	IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2) + \
-	IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3) > 1
-#error "This driver only supports one DRAM configuration at a time"
-#endif
-
 struct px30_sdram_params sdram_configs[] = {
 #if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3)
 #include	"sdram-px30-ddr3-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
 #include	"sdram-px30-ddr4-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
 #include	"sdram-px30-lpddr2-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)
 #include	"sdram-px30-lpddr3-detect-333.inc"
-#else
-#error "Please select suitable DRAM type CONFIG_RAM_ROCKCHIP option"
 #endif
 };
 
+static_assert(ARRAY_SIZE(sdram_configs) > 0,
+	      "Please select suitable DRAM type CONFIG_RAM_ROCKCHIP options");
+
 struct ddr_phy_skew skew = {
 #include	"sdram-px30-ddr_skew.inc"
 };
@@ -691,19 +688,11 @@ out:
 	return ret;
 }
 
-struct px30_sdram_params
-		*get_default_sdram_config(void)
-{
-	sdram_configs[0].skew = &skew;
-
-	return &sdram_configs[0];
-}
-
 /* return: 0 = success, other = fail */
 int sdram_init(void)
 {
 	struct px30_sdram_params *sdram_params;
-	int ret = 0;
+	int ret = 1;
 
 	dram_info.phy = (void *)DDR_PHY_BASE_ADDR;
 	dram_info.pctl = (void *)DDRC_BASE_ADDR;
@@ -713,8 +702,13 @@ int sdram_init(void)
 	dram_info.ddr_grf = (void *)DDR_GRF_BASE_ADDR;
 	dram_info.pmugrf = (void *)PMUGRF_BASE_ADDR;
 
-	sdram_params = get_default_sdram_config();
-	ret = sdram_init_detect(&dram_info, sdram_params);
+	for (int i = 0; i < ARRAY_SIZE(sdram_configs); i++) {
+		sdram_configs[i].skew = &skew;
+		sdram_params = &sdram_configs[i];
+		ret = sdram_init_detect(&dram_info, sdram_params);
+		if (ret == 0)
+			break;
+	}
 
 	if (ret)
 		goto error;
Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH v2 2/4] ram: rockchip: px30: allow multiple SDRAM types selection

Hi Massimo, Joseph,

Quoted 10 lines · Massimo Pegorer

Allow the inclusion of more than one SDRAM parameters set in the PX30 sdram driver. The driver applies included sets in alphabetical order (DDR3, DDR4, LPDDR2, LPDDR3), stopping at the first one that makes SDRAM initialization function to complete with success. This order is debatable and not based on any specific reason.

Due to limited PX30 TPL maximum size, including support for more than one SDRAM type can require disabling some configuration options such as CONFIG_RAM_ROCKCHIP_DEBUG.

@Joseph, can you help us out here?

We are trying to do the same thing that px30_ddr_333MHz_v*.bin from Rockchip's rkbin is doing: do DDR initialization without knowing which kind of DDR is soldered on the PX30-based device. Is there something special we need to do or know? For now, we are trying to initialize with DDR3 first, then DDR4 if it fails, then LPDDR2 if that fails too, then LPDDR3 if all fails. The first DDR init that doesn't fail is deemed successful. I do not know if this is correct, can you please provide some guidance?

Quoted 54 lines
---
  drivers/ram/rockchip/sdram_px30.c | 40 +++++++++++++++++----------------------
  1 file changed, 17 insertions(+), 23 deletions(-)
drivers/ram/rockchip/sdram_px30.c +9 -16
index c7ff924b2c5..7f51b9c4f8f 100644
@@ -123,27 +123,24 @@ u32 addrmap[][8] = {
 
  struct dram_info dram_info;
 
-#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3) + \
-	IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4) + \
-	IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2) + \
-	IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3) > 1
-#error "This driver only supports one DRAM configuration at a time"
-#endif
-
  struct px30_sdram_params sdram_configs[] = {
  #if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3)
  #include	"sdram-px30-ddr3-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
  #include	"sdram-px30-ddr4-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
  #include	"sdram-px30-lpddr2-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)
  #include	"sdram-px30-lpddr3-detect-333.inc"
-#else
-#error "Please select suitable DRAM type CONFIG_RAM_ROCKCHIP option"
  #endif
  };
 
+static_assert(ARRAY_SIZE(sdram_configs) > 0,
+	      "Please select suitable DRAM type CONFIG_RAM_ROCKCHIP options");
+
  struct ddr_phy_skew skew = {
  #include	"sdram-px30-ddr_skew.inc"
  };
@@ -691,19 +688,11 @@ out:
  	return ret;
  }
 
-struct px30_sdram_params
-		*get_default_sdram_config(void)
-{
-	sdram_configs[0].skew = &skew;

drivers/ram/rockchip/sdram_px30.c out: · line 695

Quoted 10 lines
drivers/ram/rockchip/sdram_px30.c +1 -5
-
-	return &sdram_configs[0];
-}
-
  /* return: 0 = success, other = fail */
  int sdram_init(void)
  {
  	struct px30_sdram_params *sdram_params;
-	int ret = 0;
+	int ret = 1;

@Massimo: question: why the need to change ret to 1?

Because the driver enforces sdram_configs array to be non-empty, we're guaranteed to do at least one loop and thus ret is guaranteed to be set properly.

Cheers,
Quentin

#8 lore raw

Re: [PATCH v2 2/4] ram: rockchip: px30: allow multiple SDRAM types selection

Hi Quentin,

Il giorno mer 11 nov 2026 alle ore 16:41 Quentin Schulz ha scritto:

Quoted 93 lines

Hi Massimo, Joseph,

Quoted 10 lines · Massimo Pegorer

Allow the inclusion of more than one SDRAM parameters set in the PX30 sdram driver. The driver applies included sets in alphabetical order (DDR3, DDR4, LPDDR2, LPDDR3), stopping at the first one that makes SDRAM initialization function to complete with success. This order is debatable and not based on any specific reason.

Due to limited PX30 TPL maximum size, including support for more than one SDRAM type can require disabling some configuration options such as CONFIG_RAM_ROCKCHIP_DEBUG.

@Joseph, can you help us out here?

We are trying to do the same thing that px30_ddr_333MHz_v*.bin from Rockchip's rkbin is doing: do DDR initialization without knowing which kind of DDR is soldered on the PX30-based device. Is there something special we need to do or know? For now, we are trying to initialize with DDR3 first, then DDR4 if it fails, then LPDDR2 if that fails too, then LPDDR3 if all fails. The first DDR init that doesn't fail is deemed successful. I do not know if this is correct, can you please provide some guidance?

Quoted 54 lines
---
  drivers/ram/rockchip/sdram_px30.c | 40 +++++++++++++++++----------------------
  1 file changed, 17 insertions(+), 23 deletions(-)
drivers/ram/rockchip/sdram_px30.c +9 -16
index c7ff924b2c5..7f51b9c4f8f 100644
@@ -123,27 +123,24 @@ u32 addrmap[][8] = {
 
  struct dram_info dram_info;
 
-#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3) + \
-     IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4) + \
-     IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2) + \
-     IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3) > 1
-#error "This driver only supports one DRAM configuration at a time"
-#endif
-
  struct px30_sdram_params sdram_configs[] = {
  #if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3)
  #include    "sdram-px30-ddr3-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
  #include    "sdram-px30-ddr4-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
  #include    "sdram-px30-lpddr2-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)
  #include    "sdram-px30-lpddr3-detect-333.inc"
-#else
-#error "Please select suitable DRAM type CONFIG_RAM_ROCKCHIP option"
  #endif
  };
 
+static_assert(ARRAY_SIZE(sdram_configs) > 0,
+           "Please select suitable DRAM type CONFIG_RAM_ROCKCHIP options");
+
  struct ddr_phy_skew skew = {
  #include    "sdram-px30-ddr_skew.inc"
  };
@@ -691,19 +688,11 @@ out:
      return ret;
  }
 
-struct px30_sdram_params
-             *get_default_sdram_config(void)
-{
-     sdram_configs[0].skew = &skew;

drivers/ram/rockchip/sdram_px30.c out: · line 695

Quoted 10 lines
drivers/ram/rockchip/sdram_px30.c +1 -5
-
-     return &sdram_configs[0];
-}
-
  /* return: 0 = success, other = fail */
  int sdram_init(void)
  {
      struct px30_sdram_params *sdram_params;
-     int ret = 0;
+     int ret = 1;

@Massimo: question: why the need to change ret to 1?

Quoted 3 lines

Because the driver enforces sdram_configs array to be non-empty, we're guaranteed to do at least one loop and thus ret is guaranteed to be set properly.

You are right, the static assert guarantees ret to be set at least once.

For variables - and logic in general - which are in the local scope, I'm used to rely as little as possible on conditions and assumptions out of that local scope. But I respect different opinions and approaches, so if you prefer I can drop the initialization at all, or restore the zero init.

By the way, in the original code, which is the need to init ret to zero? In that case, there is a local scope evidence and guarantee that it will be set before using.

Regards,
Massimo

Quoted 3 lines

Cheers,
Quentin

#9 lore raw

Re: [PATCH v2 2/4] ram: rockchip: px30: allow multiple SDRAM types selection

Quoted 100 lines · Massimo Pegorer

Hi Quentin,

Il giorno mer 11 nov 2026 alle ore 16:41 Quentin Schulz ha scritto:

Quoted 93 lines

Hi Massimo, Joseph,

Quoted 10 lines · Massimo Pegorer

Allow the inclusion of more than one SDRAM parameters set in the PX30 sdram driver. The driver applies included sets in alphabetical order (DDR3, DDR4, LPDDR2, LPDDR3), stopping at the first one that makes SDRAM initialization function to complete with success. This order is debatable and not based on any specific reason.

Due to limited PX30 TPL maximum size, including support for more than one SDRAM type can require disabling some configuration options such as CONFIG_RAM_ROCKCHIP_DEBUG.

@Joseph, can you help us out here?

We are trying to do the same thing that px30_ddr_333MHz_v*.bin from Rockchip's rkbin is doing: do DDR initialization without knowing which kind of DDR is soldered on the PX30-based device. Is there something special we need to do or know? For now, we are trying to initialize with DDR3 first, then DDR4 if it fails, then LPDDR2 if that fails too, then LPDDR3 if all fails. The first DDR init that doesn't fail is deemed successful. I do not know if this is correct, can you please provide some guidance?

Quoted 54 lines
---
   drivers/ram/rockchip/sdram_px30.c | 40 +++++++++++++++++----------------------
   1 file changed, 17 insertions(+), 23 deletions(-)
drivers/ram/rockchip/sdram_px30.c +9 -16
index c7ff924b2c5..7f51b9c4f8f 100644
@@ -123,27 +123,24 @@ u32 addrmap[][8] = {
 
   struct dram_info dram_info;
 
-#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3) + \
-     IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4) + \
-     IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2) + \
-     IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3) > 1
-#error "This driver only supports one DRAM configuration at a time"
-#endif
-
   struct px30_sdram_params sdram_configs[] = {
   #if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3)
   #include    "sdram-px30-ddr3-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
   #include    "sdram-px30-ddr4-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
   #include    "sdram-px30-lpddr2-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)
   #include    "sdram-px30-lpddr3-detect-333.inc"
-#else
-#error "Please select suitable DRAM type CONFIG_RAM_ROCKCHIP option"
   #endif
   };
 
+static_assert(ARRAY_SIZE(sdram_configs) > 0,
+           "Please select suitable DRAM type CONFIG_RAM_ROCKCHIP options");
+
   struct ddr_phy_skew skew = {
   #include    "sdram-px30-ddr_skew.inc"
   };
@@ -691,19 +688,11 @@ out:
       return ret;
   }
 
-struct px30_sdram_params
-             *get_default_sdram_config(void)
-{
-     sdram_configs[0].skew = &skew;

drivers/ram/rockchip/sdram_px30.c out: · line 695

Quoted 10 lines
drivers/ram/rockchip/sdram_px30.c +1 -5
-
-     return &sdram_configs[0];
-}
-
   /* return: 0 = success, other = fail */
   int sdram_init(void)
   {
       struct px30_sdram_params *sdram_params;
-     int ret = 0;
+     int ret = 1;

@Massimo: question: why the need to change ret to 1?

Quoted 3 lines

Because the driver enforces sdram_configs array to be non-empty, we're guaranteed to do at least one loop and thus ret is guaranteed to be set properly.

Quoted 7 lines

You are right, the static assert guarantees ret to be set at least once.

For variables - and logic in general - which are in the local scope, I'm used to rely as little as possible on conditions and assumptions out of that local scope. But I respect different opinions and approaches, so if you prefer I can drop the initialization at all, or restore the zero init.

Up to you, but if you keep a change to ret, have it at least -1 so it obviously shows when reading that an error is expected to be returned by default.

You can also check if not setting ret doesn't actually save you some bytes in the final binary.

suggestion: Maybe:

	for (int i = 0; i < ARRAY_SIZE(sdram_configs); i++) {
		sdram_configs[i].skew = &skew;
		sdram_params = &sdram_configs[i];
		if(sdram_init_detect(&dram_info, sdram_params))
			continue;

		sdram_print_ddr_info(&sdram_params->ch.cap_info, &sdram_params->base, 0);
		return 0;
	}

	return -1;
}

can make the binary even smaller without the need for the ret variable at all and removes a bunch of if conditions/jumps and is also valid without the static_assert on the sdram_configs array.

thought: I'm also not sure why we have a global dram_info? If it's not needed, then we can have it as a function-local variable in sdram_init and initialized in one go:

struct dram_info dram_info = {
	.phy = (void *)DDR_PHY_BASE_ADDR,
	.pctl = [...]
};

if it needs to be global, we can still initialize it in one go and avoid the multiple assignments in sdram_init.

Quoted 4 lines

By the way, in the original code, which is the need to init ret to zero? In that case, there is a local scope evidence and guarantee that it will be set before using.

Yeah, let's agree we've got a lot of unused and non-optimal code in U-Boot for Rockchip boards :) We can always improve :)

Cheers,
Quentin

#10 lore raw

Re: [PATCH v2 2/4] ram: rockchip: px30: allow multiple SDRAM types selection

Hi Quentin,

Il giorno mer 11 nov 2026 alle ore 19:08 Quentin Schulz ha scritto:

Quoted 109 lines · Massimo Pegorer
Quoted 100 lines

Hi Quentin,

Il giorno mer 11 nov 2026 alle ore 16:41 Quentin Schulz ha scritto:

Quoted 93 lines

Hi Massimo, Joseph,

Quoted 10 lines · Massimo Pegorer

Allow the inclusion of more than one SDRAM parameters set in the PX30 sdram driver. The driver applies included sets in alphabetical order (DDR3, DDR4, LPDDR2, LPDDR3), stopping at the first one that makes SDRAM initialization function to complete with success. This order is debatable and not based on any specific reason.

Due to limited PX30 TPL maximum size, including support for more than one SDRAM type can require disabling some configuration options such as CONFIG_RAM_ROCKCHIP_DEBUG.

@Joseph, can you help us out here?

We are trying to do the same thing that px30_ddr_333MHz_v*.bin from Rockchip's rkbin is doing: do DDR initialization without knowing which kind of DDR is soldered on the PX30-based device. Is there something special we need to do or know? For now, we are trying to initialize with DDR3 first, then DDR4 if it fails, then LPDDR2 if that fails too, then LPDDR3 if all fails. The first DDR init that doesn't fail is deemed successful. I do not know if this is correct, can you please provide some guidance?

Quoted 54 lines
---
   drivers/ram/rockchip/sdram_px30.c | 40 +++++++++++++++++----------------------
   1 file changed, 17 insertions(+), 23 deletions(-)
drivers/ram/rockchip/sdram_px30.c +9 -16
index c7ff924b2c5..7f51b9c4f8f 100644
@@ -123,27 +123,24 @@ u32 addrmap[][8] = {
 
   struct dram_info dram_info;
 
-#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3) + \
-     IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4) + \
-     IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2) + \
-     IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3) > 1
-#error "This driver only supports one DRAM configuration at a time"
-#endif
-
   struct px30_sdram_params sdram_configs[] = {
   #if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3)
   #include    "sdram-px30-ddr3-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
   #include    "sdram-px30-ddr4-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
   #include    "sdram-px30-lpddr2-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)
   #include    "sdram-px30-lpddr3-detect-333.inc"
-#else
-#error "Please select suitable DRAM type CONFIG_RAM_ROCKCHIP option"
   #endif
   };
 
+static_assert(ARRAY_SIZE(sdram_configs) > 0,
+           "Please select suitable DRAM type CONFIG_RAM_ROCKCHIP options");
+
   struct ddr_phy_skew skew = {
   #include    "sdram-px30-ddr_skew.inc"
   };
@@ -691,19 +688,11 @@ out:
       return ret;
   }
 
-struct px30_sdram_params
-             *get_default_sdram_config(void)
-{
-     sdram_configs[0].skew = &skew;

drivers/ram/rockchip/sdram_px30.c out: · line 695

Quoted 10 lines
drivers/ram/rockchip/sdram_px30.c +1 -5
-
-     return &sdram_configs[0];
-}
-
   /* return: 0 = success, other = fail */
   int sdram_init(void)
   {
       struct px30_sdram_params *sdram_params;
-     int ret = 0;
+     int ret = 1;

@Massimo: question: why the need to change ret to 1?

Quoted 3 lines

Because the driver enforces sdram_configs array to be non-empty, we're guaranteed to do at least one loop and thus ret is guaranteed to be set properly.

Quoted 7 lines

You are right, the static assert guarantees ret to be set at least once.

For variables - and logic in general - which are in the local scope, I'm used to rely as little as possible on conditions and assumptions out of that local scope. But I respect different opinions and approaches, so if you prefer I can drop the initialization at all, or restore the zero init.

Quoted 3 lines

Up to you, but if you keep a change to ret, have it at least -1 so it obviously shows when reading that an error is expected to be returned by default.

Right. BTW, the line just above sdram_init() definition says:
/* return: 0 = success, other = fail */
...so 1 should be considered a valid error return value too... ;)

Quoted 6 lines

You can also check if not setting ret doesn't actually save you some bytes in the final binary.

suggestion: Maybe:

Quoted 12 lines
        for (int i = 0; i < ARRAY_SIZE(sdram_configs); i++) {
                sdram_configs[i].skew = &skew;
                sdram_params = &sdram_configs[i];
                if(sdram_init_detect(&dram_info, sdram_params))
                        continue;

                sdram_print_ddr_info(&sdram_params->ch.cap_info, &sdram_params->base, 0);
                return 0;
        }

        return -1;
}

I will try some alternatives to find the best in size, thanks for the suggestion.

BTW, do you mean that I can also drop the printascii("out\n")? Really?! More than six years ago Miquel Rynal provided a patch that Kever accepted [1][2] but it has never landed into main (master at that time) branch really. That "out" on console really annoys me!

[1] https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
[2] https://lore.kernel.org/u-boot/[email protected]/

Quoted 9 lines

can make the binary even smaller without the need for the ret variable at all and removes a bunch of if conditions/jumps and is also valid without the static_assert on the sdram_configs array.

thought: I'm also not sure why we have a global dram_info? If it's not needed, then we can have it as a function-local variable in sdram_init and initialized in one go:

Quoted 7 lines
struct dram_info dram_info = {
        .phy = (void *)DDR_PHY_BASE_ADDR,
        .pctl = [...]
};

if it needs to be global, we can still initialize it in one go and avoid the multiple assignments in sdram_init.

I have a few other optimizations, as mentioned. I will send a dedicated series for them, after this one.

Quoted 8 lines
Quoted 5 lines

By the way, in the original code, which is the need to init ret to zero? In that case, there is a local scope evidence and guarantee that it will be set before using.

Yeah, let's agree we've got a lot of unused and non-optimal code in U-Boot for Rockchip boards :) We can always improve :)

Yes! Thanks. Regards,
Massimo

Quoted 3 lines

Cheers,
Quentin

#11 lore raw

Re: [PATCH v2 2/4] ram: rockchip: px30: allow multiple SDRAM types selection

Hi Massimo.

Quoted 112 lines · Massimo Pegorer

Hi Quentin,

Il giorno mer 11 nov 2026 alle ore 19:08 Quentin Schulz ha scritto:

Quoted 109 lines · Massimo Pegorer
Quoted 107 lines

Hi Quentin,

Il giorno mer 11 nov 2026 alle ore 16:41 Quentin Schulz ha scritto:

Quoted 93 lines

Hi Massimo, Joseph,

Quoted 10 lines · Massimo Pegorer

Allow the inclusion of more than one SDRAM parameters set in the PX30 sdram driver. The driver applies included sets in alphabetical order (DDR3, DDR4, LPDDR2, LPDDR3), stopping at the first one that makes SDRAM initialization function to complete with success. This order is debatable and not based on any specific reason.

Due to limited PX30 TPL maximum size, including support for more than one SDRAM type can require disabling some configuration options such as CONFIG_RAM_ROCKCHIP_DEBUG.

@Joseph, can you help us out here?

We are trying to do the same thing that px30_ddr_333MHz_v*.bin from Rockchip's rkbin is doing: do DDR initialization without knowing which kind of DDR is soldered on the PX30-based device. Is there something special we need to do or know? For now, we are trying to initialize with DDR3 first, then DDR4 if it fails, then LPDDR2 if that fails too, then LPDDR3 if all fails. The first DDR init that doesn't fail is deemed successful. I do not know if this is correct, can you please provide some guidance?

Quoted 54 lines
---
    drivers/ram/rockchip/sdram_px30.c | 40 +++++++++++++++++----------------------
    1 file changed, 17 insertions(+), 23 deletions(-)
drivers/ram/rockchip/sdram_px30.c +9 -16
index c7ff924b2c5..7f51b9c4f8f 100644
@@ -123,27 +123,24 @@ u32 addrmap[][8] = {
 
    struct dram_info dram_info;
 
-#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3) + \
-     IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4) + \
-     IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2) + \
-     IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3) > 1
-#error "This driver only supports one DRAM configuration at a time"
-#endif
-
    struct px30_sdram_params sdram_configs[] = {
    #if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3)
    #include    "sdram-px30-ddr3-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
    #include    "sdram-px30-ddr4-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
    #include    "sdram-px30-lpddr2-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)
    #include    "sdram-px30-lpddr3-detect-333.inc"
-#else
-#error "Please select suitable DRAM type CONFIG_RAM_ROCKCHIP option"
    #endif
    };
 
+static_assert(ARRAY_SIZE(sdram_configs) > 0,
+           "Please select suitable DRAM type CONFIG_RAM_ROCKCHIP options");
+
    struct ddr_phy_skew skew = {
    #include    "sdram-px30-ddr_skew.inc"
    };
@@ -691,19 +688,11 @@ out:
        return ret;
    }
 
-struct px30_sdram_params
-             *get_default_sdram_config(void)
-{
-     sdram_configs[0].skew = &skew;

drivers/ram/rockchip/sdram_px30.c out: · line 695

Quoted 10 lines
drivers/ram/rockchip/sdram_px30.c +1 -5
-
-     return &sdram_configs[0];
-}
-
    /* return: 0 = success, other = fail */
    int sdram_init(void)
    {
        struct px30_sdram_params *sdram_params;
-     int ret = 0;
+     int ret = 1;

@Massimo: question: why the need to change ret to 1?

Quoted 3 lines

Because the driver enforces sdram_configs array to be non-empty, we're guaranteed to do at least one loop and thus ret is guaranteed to be set properly.

You are right, the static assert guarantees ret to be set at least once.

For variables - and logic in general - which are in the local scope, I'm used to rely as little as possible on conditions and assumptions out of that local scope. But I respect different opinions and approaches, so if you prefer I can drop the initialization at all, or restore the zero init.

Quoted 8 lines
Quoted 3 lines

Up to you, but if you keep a change to ret, have it at least -1 so it obviously shows when reading that an error is expected to be returned by default.

Right. BTW, the line just above sdram_init() definition says:
/* return: 0 = success, other = fail */
...so 1 should be considered a valid error return value too... ;)

Yeah but having this documented in the C file instead of the header is the wrong place, but fair enough :)

Quoted 16 lines
Quoted 16 lines

You can also check if not setting ret doesn't actually save you some bytes in the final binary.

suggestion: Maybe:

         for (int i = 0; i < ARRAY_SIZE(sdram_configs); i++) {
                 sdram_configs[i].skew = &skew;
                 sdram_params = &sdram_configs[i];
                 if(sdram_init_detect(&dram_info, sdram_params))
                         continue;

                 sdram_print_ddr_info(&sdram_params->ch.cap_info, &sdram_params->base, 0);
                 return 0;
         }
Quoted 7 lines
Quoted 2 lines
         return -1;
}

I will try some alternatives to find the best in size, thanks for the suggestion.

BTW, do you mean that I can also drop the printascii("out\n")? Really?! More

Yes.

Quoted 1 line

than six years ago Miquel Rynal provided a patch that Kever accepted [1][2]

Probably was forgotten :)

Quoted 20 lines

but it has never landed into main (master at that time) branch really. That "out" on console really annoys me!

[1] https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
[2] https://lore.kernel.org/u-boot/[email protected]/

Quoted 14 lines

can make the binary even smaller without the need for the ret variable at all and removes a bunch of if conditions/jumps and is also valid without the static_assert on the sdram_configs array.

thought: I'm also not sure why we have a global dram_info? If it's not needed, then we can have it as a function-local variable in sdram_init and initialized in one go:

struct dram_info dram_info = {
         .phy = (void *)DDR_PHY_BASE_ADDR,
         .pctl = [...]
};
Quoted 6 lines
Quoted 2 lines

if it needs to be global, we can still initialize it in one go and avoid the multiple assignments in sdram_init.

I have a few other optimizations, as mentioned. I will send a dedicated series for them, after this one.

So... I would really like to have someone with knowledge about DRAM init in general (and/or someone at Rockchip) tell us how to correctly init the DRAM if we don't know its type before merging the "support multiple DRAM type at once and try all types to find one that works" part of the series. At the same time, I don't think we should make all improvements to DRAM init/drivers in U-Boot depend on that part being merged, so I think we can maybe split this into two series. One for preparing for support for multiple DRAM types, and one (a single patch I'm guessing) for enabling multiple DRAM types on PX30 so that it can take more time and not block the rest? What do you think?

Cheers,
Quentin

#12 lore raw

Re: [PATCH v2 2/4] ram: rockchip: px30: allow multiple SDRAM types selection

Hi Quentin,

Il giorno lun 16 nov 2026 alle ore 11:32 Quentin Schulz ha scritto:

Quoted 184 lines

Hi Massimo.

Quoted 112 lines · Massimo Pegorer

Hi Quentin,

Il giorno mer 11 nov 2026 alle ore 19:08 Quentin Schulz ha scritto:

Quoted 109 lines · Massimo Pegorer
Quoted 107 lines

Hi Quentin,

Il giorno mer 11 nov 2026 alle ore 16:41 Quentin Schulz ha scritto:

Quoted 93 lines

Hi Massimo, Joseph,

Quoted 10 lines · Massimo Pegorer

Allow the inclusion of more than one SDRAM parameters set in the PX30 sdram driver. The driver applies included sets in alphabetical order (DDR3, DDR4, LPDDR2, LPDDR3), stopping at the first one that makes SDRAM initialization function to complete with success. This order is debatable and not based on any specific reason.

Due to limited PX30 TPL maximum size, including support for more than one SDRAM type can require disabling some configuration options such as CONFIG_RAM_ROCKCHIP_DEBUG.

@Joseph, can you help us out here?

We are trying to do the same thing that px30_ddr_333MHz_v*.bin from Rockchip's rkbin is doing: do DDR initialization without knowing which kind of DDR is soldered on the PX30-based device. Is there something special we need to do or know? For now, we are trying to initialize with DDR3 first, then DDR4 if it fails, then LPDDR2 if that fails too, then LPDDR3 if all fails. The first DDR init that doesn't fail is deemed successful. I do not know if this is correct, can you please provide some guidance?

Quoted 54 lines
---
    drivers/ram/rockchip/sdram_px30.c | 40 +++++++++++++++++----------------------
    1 file changed, 17 insertions(+), 23 deletions(-)
drivers/ram/rockchip/sdram_px30.c +9 -16
index c7ff924b2c5..7f51b9c4f8f 100644
@@ -123,27 +123,24 @@ u32 addrmap[][8] = {
 
    struct dram_info dram_info;
 
-#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3) + \
-     IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4) + \
-     IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2) + \
-     IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3) > 1
-#error "This driver only supports one DRAM configuration at a time"
-#endif
-
    struct px30_sdram_params sdram_configs[] = {
    #if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3)
    #include    "sdram-px30-ddr3-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
    #include    "sdram-px30-ddr4-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
    #include    "sdram-px30-lpddr2-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)
    #include    "sdram-px30-lpddr3-detect-333.inc"
-#else
-#error "Please select suitable DRAM type CONFIG_RAM_ROCKCHIP option"
    #endif
    };
 
+static_assert(ARRAY_SIZE(sdram_configs) > 0,
+           "Please select suitable DRAM type CONFIG_RAM_ROCKCHIP options");
+
    struct ddr_phy_skew skew = {
    #include    "sdram-px30-ddr_skew.inc"
    };
@@ -691,19 +688,11 @@ out:
        return ret;
    }
 
-struct px30_sdram_params
-             *get_default_sdram_config(void)
-{
-     sdram_configs[0].skew = &skew;

drivers/ram/rockchip/sdram_px30.c out: · line 695

Quoted 10 lines
drivers/ram/rockchip/sdram_px30.c +1 -5
-
-     return &sdram_configs[0];
-}
-
    /* return: 0 = success, other = fail */
    int sdram_init(void)
    {
        struct px30_sdram_params *sdram_params;
-     int ret = 0;
+     int ret = 1;

@Massimo: question: why the need to change ret to 1?

Quoted 3 lines

Because the driver enforces sdram_configs array to be non-empty, we're guaranteed to do at least one loop and thus ret is guaranteed to be set properly.

You are right, the static assert guarantees ret to be set at least once.

For variables - and logic in general - which are in the local scope, I'm used to rely as little as possible on conditions and assumptions out of that local scope. But I respect different opinions and approaches, so if you prefer I can drop the initialization at all, or restore the zero init.

Quoted 8 lines
Quoted 3 lines

Up to you, but if you keep a change to ret, have it at least -1 so it obviously shows when reading that an error is expected to be returned by default.

Right. BTW, the line just above sdram_init() definition says:
/* return: 0 = success, other = fail */
...so 1 should be considered a valid error return value too... ;)

Yeah but having this documented in the C file instead of the header is the wrong place, but fair enough :)

Quoted 16 lines
Quoted 16 lines

You can also check if not setting ret doesn't actually save you some bytes in the final binary.

suggestion: Maybe:

         for (int i = 0; i < ARRAY_SIZE(sdram_configs); i++) {
                 sdram_configs[i].skew = &skew;
                 sdram_params = &sdram_configs[i];
                 if(sdram_init_detect(&dram_info, sdram_params))
                         continue;

                 sdram_print_ddr_info(&sdram_params->ch.cap_info, &sdram_params->base, 0);
                 return 0;
         }
Quoted 7 lines
Quoted 2 lines
         return -1;
}

I will try some alternatives to find the best in size, thanks for the suggestion.

BTW, do you mean that I can also drop the printascii("out\n")? Really?! More

Yes.

Quoted 1 line

than six years ago Miquel Rynal provided a patch that Kever accepted [1][2]

Probably was forgotten :)

Quoted 20 lines

but it has never landed into main (master at that time) branch really. That "out" on console really annoys me!

[1] https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/
[2] https://lore.kernel.org/u-boot/[email protected]/

Quoted 14 lines

can make the binary even smaller without the need for the ret variable at all and removes a bunch of if conditions/jumps and is also valid without the static_assert on the sdram_configs array.

thought: I'm also not sure why we have a global dram_info? If it's not needed, then we can have it as a function-local variable in sdram_init and initialized in one go:

struct dram_info dram_info = {
         .phy = (void *)DDR_PHY_BASE_ADDR,
         .pctl = [...]
};
Quoted 6 lines
Quoted 2 lines

if it needs to be global, we can still initialize it in one go and avoid the multiple assignments in sdram_init.

I have a few other optimizations, as mentioned. I will send a dedicated series for them, after this one.

Quoted 10 lines

So... I would really like to have someone with knowledge about DRAM init in general (and/or someone at Rockchip) tell us how to correctly init the DRAM if we don't know its type before merging the "support multiple DRAM type at once and try all types to find one that works" part of the series. At the same time, I don't think we should make all improvements to DRAM init/drivers in U-Boot depend on that part being merged, so I think we can maybe split this into two series. One for preparing for support for multiple DRAM types, and one (a single patch I'm guessing) for enabling multiple DRAM types on PX30 so that it can take more time and not block the rest? What do you think?

Agree, no problem. I would have done before if this is the preferred approach. Just sent v3 with the preliminary improvements only.

Regards,
Massimo

Quoted 3 lines

Cheers,
Quentin

#13 lore raw

Re: [PATCH v2 2/4] ram: rockchip: px30: allow multiple SDRAM types selection

In reply to Quentin Schulz

Hi Quentin,

Quoted 9 lines · Quentin Schulz

Hi Massimo, Joseph,

Quoted 6 lines · Massimo Pegorer

Allow the inclusion of more than one SDRAM parameters set in the PX30 sdram driver. The driver applies included sets in alphabetical order (DDR3, DDR4, LPDDR2, LPDDR3), stopping at the first one that makes SDRAM initialization function to complete with success. This order is debatable and not based on any specific reason.

Quoted 8 lines
Quoted 4 lines

Due to limited PX30 TPL maximum size, including support for more than one SDRAM type can require disabling some configuration options such as CONFIG_RAM_ROCKCHIP_DEBUG.

@Joseph, can you help us out here?

We are trying to do the same thing that px30_ddr_333MHz_v*.bin from Rockchip's rkbin is doing: do DDR initialization without knowing which kind of DDR is soldered on the PX30-based device. Is there something special we need to do or know? For now, we are trying to initialize with DDR3 first, then DDR4 if it fails, then LPDDR2 if that fails too, then LPDDR3 if all fails. The first DDR init that doesn't fail is deemed successful. I do not know if this is correct, can you please provide some guidance?

Sorry, I can't offer much guidance on this topic.

Quoted 70 lines
Quoted 57 lines

---
  drivers/ram/rockchip/sdram_px30.c | 40
+++++++++++++++++----------------------

  1 file changed, 17 insertions(+), 23 deletions(-)
drivers/ram/rockchip/sdram_px30.c +8 -11
index c7ff924b2c5..7f51b9c4f8f 100644
@@ -123,27 +123,24 @@ u32 addrmap[][8] = {
     struct dram_info dram_info;
   -#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3) + \
-    IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4) + \
-    IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2) + \
-    IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3) > 1
-#error "This driver only supports one DRAM configuration at a time"
-#endif
-
   struct px30_sdram_params sdram_configs[] = {
   #if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR3)
   #include    "sdram-px30-ddr3-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_DDR4)
   #include    "sdram-px30-ddr4-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR2)
   #include    "sdram-px30-lpddr2-detect-333.inc"
-#elif IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)
+#endif
+#if IS_ENABLED(CONFIG_RAM_ROCKCHIP_LPDDR3)
   #include    "sdram-px30-lpddr3-detect-333.inc"
-#else
-#error "Please select suitable DRAM type CONFIG_RAM_ROCKCHIP option"
   #endif
   };
   +static_assert(ARRAY_SIZE(sdram_configs) > 0,
+          "Please select suitable DRAM type CONFIG_RAM_ROCKCHIP 
 options");
+
   struct ddr_phy_skew skew = {
   #include    "sdram-px30-ddr_skew.inc"
   };
@@ -691,19 +688,11 @@ out:
       return ret;
   }

  -struct px30_sdram_params
-        *get_default_sdram_config(void)

drivers/ram/rockchip/sdram_px30.c +0 -6
-{
-    sdram_configs[0].skew = &skew;
-
-    return &sdram_configs[0];
-}
-
Quoted 6 lines

  /* return: 0 = success, other = fail */
  int sdram_init(void)
  {
      struct px30_sdram_params *sdram_params;
-    int ret = 0;
+    int ret = 1;

@Massimo: question: why the need to change ret to 1?

Because the driver enforces sdram_configs array to be non-empty, we're guaranteed to do at least one loop and thus ret is guaranteed to be set properly.

Cheers,
Quentin

Signature · 9 lines
Best regards,

陈健洪 (Joseph Chen)
[email protected]
福州瑞芯微电子股份有限公司
Fuzhou Rockchip Electronics Co.Ltd
福建省福州市铜盘路软件大道89号软件园A区17号楼 (350003)
No. 17 Building, A District, No.89,software Boulevard Fuzhou,Fujian,PRC
TEL:0591-83991906/07-8573
#14 lore raw

PATCH v2 3/4 ram: rockchip: reduce debugging code size

In reply to Massimo Pegorer

Slightly optimize SDRAM driver debugging code to reduce required space in the case of PX30 SoC TPL, allowing further code to be included such as multiple SDRAM types support.

---
 drivers/ram/rockchip/sdram_common.c | 49 ++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 30 deletions(-)
drivers/ram/rockchip/sdram_common.c +19 -30
index b7a8fce607c..b46de5d9044 100644
@@ -11,39 +11,34 @@
 #include <asm/arch-rockchip/sdram_common.h>
 
 #ifdef CONFIG_RAM_ROCKCHIP_DEBUG
-void sdram_print_dram_type(unsigned char dramtype)
+static const char *sdram_get_dram_type_string(unsigned char dramtype)
 {
 	switch (dramtype) {
-	case DDR3:
-		printascii("DDR3");
-		break;
-	case DDR4:
-		printascii("DDR4");
-		break;
-	case LPDDR2:
-		printascii("LPDDR2");
-		break;
-	case LPDDR3:
-		printascii("LPDDR3");
-		break;
-	case LPDDR4:
-		printascii("LPDDR4");
-		break;
-	default:
-		printascii("Unknown Device");
-		break;
+	case DDR3:	return "DDR3";
+	case DDR4:	return "DDR4";
+	case LPDDR2:	return "LPDDR2";
+	case LPDDR3:	return "LPDDR3";
+	case LPDDR4:	return "LPDDR4";
+	default:	return "Unknown Device";
 	}
 }
 
+void sdram_print_dram_type(unsigned char dramtype)
+{
+	printascii(sdram_get_dram_type_string(dramtype));
+}
+
 void sdram_print_ddr_info(struct sdram_cap_info *cap_info,
 			  struct sdram_base_params *base, u32 split)
 {
-	u64 cap;
-	u32 bg;
+	u64 cap = sdram_get_cs_cap(cap_info, 3, base->dramtype);
 
-	bg = (cap_info->dbw == 0) ? 2 : 1;
+	if (cap_info->row_3_4)
+		cap = cap * 3 / 4;
+	else if (split)
+		cap = cap / 2 + (split << 24) / 2;
 
-	sdram_print_dram_type(base->dramtype);
+	printascii(sdram_get_dram_type_string(base->dramtype));
 
 	printascii(", ");
 	printdec(base->ddr_freq);
@@ -57,7 +52,7 @@ void sdram_print_ddr_info(struct sdram_cap_info *cap_info,
 	printdec(0x1 << cap_info->bk);
 	if (base->dramtype == DDR4) {
 		printascii(" BG=");
-		printdec(1 << bg);
+		printdec(1 << ((cap_info->dbw == 0) ? 2 : 1));
 	}
 	printascii(" CS0 Row=");
 	printdec(cap_info->cs0_row);
@@ -80,12 +75,6 @@ void sdram_print_ddr_info(struct sdram_cap_info *cap_info,
 	printascii(" Die BW=");
 	printdec(8 << cap_info->dbw);
 
-	cap = sdram_get_cs_cap(cap_info, 3, base->dramtype);
-	if (cap_info->row_3_4)
-		cap = cap * 3 / 4;
-	else if (split)
-		cap = cap / 2 + (split << 24) / 2;
-
 	printascii(" Size=");
 	printdec(cap >> 20);
 	printascii("MB\n");
Signature · 1 line
2.34.1
#15 lore raw

Re: [PATCH v2 3/4] ram: rockchip: reduce debugging code size

Hi Massimo,

Quoted 43 lines · Massimo Pegorer

Slightly optimize SDRAM driver debugging code to reduce required space in the case of PX30 SoC TPL, allowing further code to be included such as multiple SDRAM types support.

---
  drivers/ram/rockchip/sdram_common.c | 49 ++++++++++++++-----------------------
  1 file changed, 19 insertions(+), 30 deletions(-)
drivers/ram/rockchip/sdram_common.c +5 -19
index b7a8fce607c..b46de5d9044 100644
@@ -11,39 +11,34 @@
  #include <asm/arch-rockchip/sdram_common.h>
 
  #ifdef CONFIG_RAM_ROCKCHIP_DEBUG
-void sdram_print_dram_type(unsigned char dramtype)
+static const char *sdram_get_dram_type_string(unsigned char dramtype)
  {
  	switch (dramtype) {
-	case DDR3:
-		printascii("DDR3");
-		break;
-	case DDR4:
-		printascii("DDR4");
-		break;
-	case LPDDR2:
-		printascii("LPDDR2");
-		break;
-	case LPDDR3:
-		printascii("LPDDR3");
-		break;
-	case LPDDR4:
-		printascii("LPDDR4");
-		break;
-	default:
-		printascii("Unknown Device");
-		break;
+	case DDR3:	return "DDR3";
+	case DDR4:	return "DDR4";
+	case LPDDR2:	return "LPDDR2";
+	case LPDDR3:	return "LPDDR3";

drivers/ram/rockchip/sdram_common.c line 30

Quoted 10 lines
drivers/ram/rockchip/sdram_common.c +7 -0
+	case LPDDR4:	return "LPDDR4";
+	default:	return "Unknown Device";
  	}
  }
 
+void sdram_print_dram_type(unsigned char dramtype)
+{
+	printascii(sdram_get_dram_type_string(dramtype));
+}
+

issue: make the above a separate patch

It makes it easier to see individual changes and the impact each change has on the final size.

drivers/ram/rockchip/sdram_common.c line 44

Quoted 8 lines
drivers/ram/rockchip/sdram_common.c +1 -3
  void sdram_print_ddr_info(struct sdram_cap_info *cap_info,
  			  struct sdram_base_params *base, u32 split)
  {
-	u64 cap;
-	u32 bg;
+	u64 cap = sdram_get_cs_cap(cap_info, 3, base->dramtype);
 
-	bg = (cap_info->dbw == 0) ? 2 : 1;

issue: make the removal of the bg variable its own patch

Same reasons as above.

drivers/ram/rockchip/sdram_common.c line 41

Quoted 7 lines
drivers/ram/rockchip/sdram_common.c +5 -1
+	if (cap_info->row_3_4)
+		cap = cap * 3 / 4;
+	else if (split)
+		cap = cap / 2 + (split << 24) / 2;
 
-	sdram_print_dram_type(base->dramtype);
+	printascii(sdram_get_dram_type_string(base->dramtype));

question: why this oneline change here?

Isn't that exactly what sdram_print_dram_type() is doing? You can always forcefully inline it, even though I'm not sure it's necessary

Quoted 13 lines
drivers/ram/rockchip/sdram_common.c +1 -1
  	printascii(", ");
  	printdec(base->ddr_freq);
@@ -57,7 +52,7 @@ void sdram_print_ddr_info(struct sdram_cap_info *cap_info,
  	printdec(0x1 << cap_info->bk);
  	if (base->dramtype == DDR4) {
  		printascii(" BG=");
-		printdec(1 << bg);
+		printdec(1 << ((cap_info->dbw == 0) ? 2 : 1));
  	}
  	printascii(" CS0 Row=");
  	printdec(cap_info->cs0_row);

drivers/ram/rockchip/sdram_common.c void sdram_print_ddr_info(struct sdram_cap_info *cap_info, · line 88

Quoted 9 lines
drivers/ram/rockchip/sdram_common.c +0 -6
@@ -80,12 +75,6 @@ void sdram_print_ddr_info(struct sdram_cap_info *cap_info,
  	printascii(" Die BW=");
  	printdec(8 << cap_info->dbw);
 
-	cap = sdram_get_cs_cap(cap_info, 3, base->dramtype);
-	if (cap_info->row_3_4)
-		cap = cap * 3 / 4;
-	else if (split)
-		cap = cap / 2 + (split << 24) / 2;
-

question: does the move of those 5 lines at the beginning of the function actually help with anything?

thought: I'm thinking there are additional ways to make functions in this file smaller

There's a bunch of checks scattered all over the file on dram_type. Considering we know what we want to support via the CONFIG_RAM_ROCKCHIP_* symbols, I'm thinking we could have a bunch of #ifdef/IS_ENABLED in there and make the functions smaller. It needs to be done carefully though. Maybe in a future commit, not necessarily for you to do.

todo: split this into its own series, we don't need to have it depend on the PX30 DDR auto-detect thing. We can merge improvements and bug fixes separately from new features. The next patch could be part of that series, but I'll only start reviewing it now :)

Cheers,
Quentin

#16 lore raw

Re: [PATCH v2 3/4] ram: rockchip: reduce debugging code size

Hi Quentin,

Il giorno mer 11 nov 2026 alle ore 16:54 Quentin Schulz ha scritto:

Quoted 59 lines

Hi Massimo,

Quoted 43 lines · Massimo Pegorer

Slightly optimize SDRAM driver debugging code to reduce required space in the case of PX30 SoC TPL, allowing further code to be included such as multiple SDRAM types support.

---
  drivers/ram/rockchip/sdram_common.c | 49 ++++++++++++++-----------------------
  1 file changed, 19 insertions(+), 30 deletions(-)
drivers/ram/rockchip/sdram_common.c +5 -19
index b7a8fce607c..b46de5d9044 100644
@@ -11,39 +11,34 @@
  #include <asm/arch-rockchip/sdram_common.h>
 
  #ifdef CONFIG_RAM_ROCKCHIP_DEBUG
-void sdram_print_dram_type(unsigned char dramtype)
+static const char *sdram_get_dram_type_string(unsigned char dramtype)
  {
      switch (dramtype) {
-     case DDR3:
-             printascii("DDR3");
-             break;
-     case DDR4:
-             printascii("DDR4");
-             break;
-     case LPDDR2:
-             printascii("LPDDR2");
-             break;
-     case LPDDR3:
-             printascii("LPDDR3");
-             break;
-     case LPDDR4:
-             printascii("LPDDR4");
-             break;
-     default:
-             printascii("Unknown Device");
-             break;
+     case DDR3:      return "DDR3";
+     case DDR4:      return "DDR4";
+     case LPDDR2:    return "LPDDR2";
+     case LPDDR3:    return "LPDDR3";

drivers/ram/rockchip/sdram_common.c line 30

Quoted 10 lines
drivers/ram/rockchip/sdram_common.c +7 -0
+     case LPDDR4:    return "LPDDR4";
+     default:        return "Unknown Device";
      }
  }
 
+void sdram_print_dram_type(unsigned char dramtype)
+{
+     printascii(sdram_get_dram_type_string(dramtype));
+}
+

issue: make the above a separate patch

Quoted 2 lines

It makes it easier to see individual changes and the impact each change has on the final size.

I agree. I will drop this and the next one from v3 of this series, and will evaluate rewriting them after running some tests on TPL size, taking care of your suggestions. Thanks.

Regards,
Massimo

Quoted 70 lines

drivers/ram/rockchip/sdram_common.c line 44

Quoted 9 lines
drivers/ram/rockchip/sdram_common.c +1 -3
  void sdram_print_ddr_info(struct sdram_cap_info *cap_info,
                        struct sdram_base_params *base, u32 split)
  {
-     u64 cap;
-     u32 bg;
+     u64 cap = sdram_get_cs_cap(cap_info, 3, base->dramtype);
 
-     bg = (cap_info->dbw == 0) ? 2 : 1;

issue: make the removal of the bg variable its own patch

Same reasons as above.

drivers/ram/rockchip/sdram_common.c line 41

Quoted 7 lines
drivers/ram/rockchip/sdram_common.c +5 -1
+     if (cap_info->row_3_4)
+             cap = cap * 3 / 4;
+     else if (split)
+             cap = cap / 2 + (split << 24) / 2;
 
-     sdram_print_dram_type(base->dramtype);
+     printascii(sdram_get_dram_type_string(base->dramtype));

question: why this oneline change here?

Isn't that exactly what sdram_print_dram_type() is doing? You can always forcefully inline it, even though I'm not sure it's necessary

Quoted 13 lines
drivers/ram/rockchip/sdram_common.c +1 -1
      printascii(", ");
      printdec(base->ddr_freq);
@@ -57,7 +52,7 @@ void sdram_print_ddr_info(struct sdram_cap_info *cap_info,
      printdec(0x1 << cap_info->bk);
      if (base->dramtype == DDR4) {
              printascii(" BG=");
-             printdec(1 << bg);
+             printdec(1 << ((cap_info->dbw == 0) ? 2 : 1));
      }
      printascii(" CS0 Row=");
      printdec(cap_info->cs0_row);

drivers/ram/rockchip/sdram_common.c void sdram_print_ddr_info(struct sdram_cap_info *cap_info, · line 88

Quoted 9 lines
drivers/ram/rockchip/sdram_common.c +0 -6
@@ -80,12 +75,6 @@ void sdram_print_ddr_info(struct sdram_cap_info *cap_info,
      printascii(" Die BW=");
      printdec(8 << cap_info->dbw);
 
-     cap = sdram_get_cs_cap(cap_info, 3, base->dramtype);
-     if (cap_info->row_3_4)
-             cap = cap * 3 / 4;
-     else if (split)
-             cap = cap / 2 + (split << 24) / 2;
-

question: does the move of those 5 lines at the beginning of the function actually help with anything?

thought: I'm thinking there are additional ways to make functions in this file smaller

There's a bunch of checks scattered all over the file on dram_type. Considering we know what we want to support via the CONFIG_RAM_ROCKCHIP_* symbols, I'm thinking we could have a bunch of #ifdef/IS_ENABLED in there and make the functions smaller. It needs to be done carefully though. Maybe in a future commit, not necessarily for you to do.

todo: split this into its own series, we don't need to have it depend on the PX30 DDR auto-detect thing. We can merge improvements and bug fixes separately from new features. The next patch could be part of that series, but I'll only start reviewing it now :)

Cheers,
Quentin

#17 lore raw

PATCH v2 4/4 ram: rockchip: add config option for tinier debug

In reply to Massimo Pegorer

Selecting the RAM_ROCKCHIP_DEBUG_TINY new configuration option, the debugging code prints only the SDRAM type, frequency and size, limiting the required space. In this way, the debugging code can coexist with support for multiple SDRAM types without exceeding the output size limit, such as in the case of the PX30 SoC TPL.

---
 drivers/ram/rockchip/Kconfig        | 11 ++++++++
 drivers/ram/rockchip/sdram_common.c | 54 ++++++++++++++++++-------------------
 drivers/ram/rockchip/sdram_px30.c   |  4 ++-
 3 files changed, 41 insertions(+), 28 deletions(-)
drivers/ram/rockchip/Kconfig +11 -0
index f51ae6a4542..98770659cd2 100644
@@ -24,6 +24,17 @@ config RAM_ROCKCHIP_DEBUG
 	  This is an option for developers to understand the ram drivers
 	  initialization, configurations and etc.
 
+config RAM_ROCKCHIP_DEBUG_TINY
+	bool "Rockchip ram drivers tiny debugging"
+	depends on RAM_ROCKCHIP_DEBUG
+	help
+	  Limit ram driver debugging info to sdram type, frequency and size.
+
+	  Help to keep basic debugging information while minimizing consequences
+	  to ram driver footprint. This can be useful when configuring the ram
+	  driver to support multiple sdram types in a very constrained context,
+	  such as TPL for PX30 SoC.
+
 config RAM_ROCKCHIP_DDR3
 	bool "DDR3 support for Rockchip SoCs"
 	depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126
drivers/ram/rockchip/sdram_common.c +27 -27

63 lines not on this page · raw message

drivers/ram/rockchip/sdram_px30.c +3 -1
index 7f51b9c4f8f..2b25a0124ed 100644
@@ -715,7 +715,9 @@ int sdram_init(void)
 
 	sdram_print_ddr_info(&sdram_params->ch.cap_info, &sdram_params->base, 0);
 
-	printascii("out\n");
+	if (!IS_ENABLED(CONFIG_RAM_ROCKCHIP_DEBUG_TINY))
+		printascii("out\n");
+
 	return ret;
 error:
 	return (-1);
Signature · 1 line
2.34.1
#18 lore raw

Re: [PATCH v2 4/4] ram: rockchip: add config option for tinier debug

Hi Massimo,

Quoted 18 lines · Massimo Pegorer

Selecting the RAM_ROCKCHIP_DEBUG_TINY new configuration option, the debugging code prints only the SDRAM type, frequency and size, limiting the required space. In this way, the debugging code can coexist with support for multiple SDRAM types without exceeding the output size limit, such as in the case of the PX30 SoC TPL.

---
  drivers/ram/rockchip/Kconfig        | 11 ++++++++
  drivers/ram/rockchip/sdram_common.c | 54 ++++++++++++++++++-------------------
  drivers/ram/rockchip/sdram_px30.c   |  4 ++-
  3 files changed, 41 insertions(+), 28 deletions(-)
drivers/ram/rockchip/Kconfig +0 -0
index f51ae6a4542..98770659cd2 100644

drivers/ram/rockchip/Kconfig config RAM_ROCKCHIP_DEBUG · line 29

Quoted 6 lines
drivers/ram/rockchip/Kconfig +3 -0
@@ -24,6 +24,17 @@ config RAM_ROCKCHIP_DEBUG
  	  This is an option for developers to understand the ram drivers
  	  initialization, configurations and etc.
 
+config RAM_ROCKCHIP_DEBUG_TINY
+	bool "Rockchip ram drivers tiny debugging"
+	depends on RAM_ROCKCHIP_DEBUG

question: do we really need a new symbol for that?

Maybe we can simply have a constant (e.g. DEBUG) defined at the top of the file and check on that. I am trying to think if anyone would want to have this configurable in a defconfig? If it's only useful for quick debugging, I don't think it makes sense to have a symbol for it.

Quoted 84 lines
drivers/ram/rockchip/Kconfig +8 -0
+	help
+	  Limit ram driver debugging info to sdram type, frequency and size.
+
+	  Help to keep basic debugging information while minimizing consequences
+	  to ram driver footprint. This can be useful when configuring the ram
+	  driver to support multiple sdram types in a very constrained context,
+	  such as TPL for PX30 SoC.
+
  config RAM_ROCKCHIP_DDR3
  	bool "DDR3 support for Rockchip SoCs"
  	depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126
drivers/ram/rockchip/sdram_common.c +27 -27
index b46de5d9044..519bbdb4e60 100644
@@ -44,36 +44,36 @@ void sdram_print_ddr_info(struct sdram_cap_info *cap_info,
  	printdec(base->ddr_freq);
  	printascii("MHz\n");
 
-	printascii("BW=");
-	printdec(8 << cap_info->bw);
-	printascii(" Col=");
-	printdec(cap_info->col);
-	printascii(" Bk=");
-	printdec(0x1 << cap_info->bk);
-	if (base->dramtype == DDR4) {
-		printascii(" BG=");
-		printdec(1 << ((cap_info->dbw == 0) ? 2 : 1));
-	}
-	printascii(" CS0 Row=");
-	printdec(cap_info->cs0_row);
-	if (cap_info->cs0_high16bit_row !=
-		cap_info->cs0_row) {
-		printascii("/");
-		printdec(cap_info->cs0_high16bit_row);
-	}
-	if (cap_info->rank > 1) {
-		printascii(" CS1 Row=");
-		printdec(cap_info->cs1_row);
-		if (cap_info->cs1_high16bit_row !=
-			cap_info->cs1_row) {
+	if (!IS_ENABLED(CONFIG_RAM_ROCKCHIP_DEBUG_TINY)) {
+		printascii("BW=");
+		printdec(8 << cap_info->bw);
+		printascii(" Col=");
+		printdec(cap_info->col);
+		printascii(" Bk=");
+		printdec(0x1 << cap_info->bk);
+		if (base->dramtype == DDR4) {
+			printascii(" BG=");
+			printdec(1 << ((cap_info->dbw == 0) ? 2 : 1));
+		}
+		printascii(" CS0 Row=");
+		printdec(cap_info->cs0_row);
+		if (cap_info->cs0_high16bit_row != cap_info->cs0_row) {
  			printascii("/");
-			printdec(cap_info->cs1_high16bit_row);
+			printdec(cap_info->cs0_high16bit_row);
+		}
+		if (cap_info->rank > 1) {
+			printascii(" CS1 Row=");
+			printdec(cap_info->cs1_row);
+			if (cap_info->cs1_high16bit_row != cap_info->cs1_row) {
+				printascii("/");
+				printdec(cap_info->cs1_high16bit_row);
+			}
  		}
+		printascii(" CS=");
+		printdec(cap_info->rank);
+		printascii(" Die BW=");
+		printdec(8 << cap_info->dbw);
  	}
-	printascii(" CS=");
-	printdec(cap_info->rank);
-	printascii(" Die BW=");
-	printdec(8 << cap_info->dbw);
 
  	printascii(" Size=");
  	printdec(cap >> 20);
drivers/ram/rockchip/sdram_px30.c +0 -0
index 7f51b9c4f8f..2b25a0124ed 100644

drivers/ram/rockchip/sdram_px30.c int sdram_init(void) · line 720

Quoted 7 lines
drivers/ram/rockchip/sdram_px30.c +3 -1
@@ -715,7 +715,9 @@ int sdram_init(void)
 
  	sdram_print_ddr_info(&sdram_params->ch.cap_info, &sdram_params->base, 0);
 
-	printascii("out\n");
+	if (!IS_ENABLED(CONFIG_RAM_ROCKCHIP_DEBUG_TINY))
+		printascii("out\n");
+

suggestion: just get rid of it

In a separate patch. Considering sdram_print_ddr_info() always print something, there's no need to say when we've exited that function I think?

Cheers,
Quentin

#19 lore raw

Re: [PATCH v2 4/4] ram: rockchip: add config option for tinier debug

Hi Quentin,

Il giorno mer 11 nov 2026 alle ore 17:23 Quentin Schulz ha scritto:

Quoted 30 lines

Hi Massimo,

Quoted 18 lines · Massimo Pegorer

Selecting the RAM_ROCKCHIP_DEBUG_TINY new configuration option, the debugging code prints only the SDRAM type, frequency and size, limiting the required space. In this way, the debugging code can coexist with support for multiple SDRAM types without exceeding the output size limit, such as in the case of the PX30 SoC TPL.

---
  drivers/ram/rockchip/Kconfig        | 11 ++++++++
  drivers/ram/rockchip/sdram_common.c | 54 ++++++++++++++++++-------------------
  drivers/ram/rockchip/sdram_px30.c   |  4 ++-
  3 files changed, 41 insertions(+), 28 deletions(-)
drivers/ram/rockchip/Kconfig +0 -0
index f51ae6a4542..98770659cd2 100644

drivers/ram/rockchip/Kconfig config RAM_ROCKCHIP_DEBUG · line 29

Quoted 6 lines
drivers/ram/rockchip/Kconfig +3 -0
@@ -24,6 +24,17 @@ config RAM_ROCKCHIP_DEBUG
        This is an option for developers to understand the ram drivers
        initialization, configurations and etc.
 
+config RAM_ROCKCHIP_DEBUG_TINY
+     bool "Rockchip ram drivers tiny debugging"
+     depends on RAM_ROCKCHIP_DEBUG

question: do we really need a new symbol for that?

Quoted 4 lines

Maybe we can simply have a constant (e.g. DEBUG) defined at the top of the file and check on that. I am trying to think if anyone would want to have this configurable in a defconfig? If it's only useful for quick debugging, I don't think it makes sense to have a symbol for it.

Quite true, indeed. But RAM_ROCKCHIP_DEBUG defaults to 'y', and 143 of the 152 configurations that have RAM_ROCKCHIP defined also have RAM_ROCKCHIP_DEBUG defined. Therefore I have thought about a Kconfig option, but we can consider a different solution: will do in a next series.

Quoted 95 lines
Quoted 85 lines
drivers/ram/rockchip/Kconfig +8 -0
+     help
+       Limit ram driver debugging info to sdram type, frequency and size.
+
+       Help to keep basic debugging information while minimizing consequences
+       to ram driver footprint. This can be useful when configuring the ram
+       driver to support multiple sdram types in a very constrained context,
+       such as TPL for PX30 SoC.
+
  config RAM_ROCKCHIP_DDR3
      bool "DDR3 support for Rockchip SoCs"
      depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126
drivers/ram/rockchip/sdram_common.c +27 -27
index b46de5d9044..519bbdb4e60 100644
@@ -44,36 +44,36 @@ void sdram_print_ddr_info(struct sdram_cap_info *cap_info,
      printdec(base->ddr_freq);
      printascii("MHz\n");
 
-     printascii("BW=");
-     printdec(8 << cap_info->bw);
-     printascii(" Col=");
-     printdec(cap_info->col);
-     printascii(" Bk=");
-     printdec(0x1 << cap_info->bk);
-     if (base->dramtype == DDR4) {
-             printascii(" BG=");
-             printdec(1 << ((cap_info->dbw == 0) ? 2 : 1));
-     }
-     printascii(" CS0 Row=");
-     printdec(cap_info->cs0_row);
-     if (cap_info->cs0_high16bit_row !=
-             cap_info->cs0_row) {
-             printascii("/");
-             printdec(cap_info->cs0_high16bit_row);
-     }
-     if (cap_info->rank > 1) {
-             printascii(" CS1 Row=");
-             printdec(cap_info->cs1_row);
-             if (cap_info->cs1_high16bit_row !=
-                     cap_info->cs1_row) {
+     if (!IS_ENABLED(CONFIG_RAM_ROCKCHIP_DEBUG_TINY)) {
+             printascii("BW=");
+             printdec(8 << cap_info->bw);
+             printascii(" Col=");
+             printdec(cap_info->col);
+             printascii(" Bk=");
+             printdec(0x1 << cap_info->bk);
+             if (base->dramtype == DDR4) {
+                     printascii(" BG=");
+                     printdec(1 << ((cap_info->dbw == 0) ? 2 : 1));
+             }
+             printascii(" CS0 Row=");
+             printdec(cap_info->cs0_row);
+             if (cap_info->cs0_high16bit_row != cap_info->cs0_row) {
                      printascii("/");
-                     printdec(cap_info->cs1_high16bit_row);
+                     printdec(cap_info->cs0_high16bit_row);
+             }
+             if (cap_info->rank > 1) {
+                     printascii(" CS1 Row=");
+                     printdec(cap_info->cs1_row);
+                     if (cap_info->cs1_high16bit_row != cap_info->cs1_row) {
+                             printascii("/");
+                             printdec(cap_info->cs1_high16bit_row);
+                     }
              }
+             printascii(" CS=");
+             printdec(cap_info->rank);
+             printascii(" Die BW=");
+             printdec(8 << cap_info->dbw);
      }
-     printascii(" CS=");
-     printdec(cap_info->rank);
-     printascii(" Die BW=");
-     printdec(8 << cap_info->dbw);
 
      printascii(" Size=");
      printdec(cap >> 20);
drivers/ram/rockchip/sdram_px30.c +0 -0
index 7f51b9c4f8f..2b25a0124ed 100644

drivers/ram/rockchip/sdram_px30.c int sdram_init(void) · line 720

Quoted 7 lines
drivers/ram/rockchip/sdram_px30.c +3 -1
@@ -715,7 +715,9 @@ int sdram_init(void)
 
      sdram_print_ddr_info(&sdram_params->ch.cap_info, &sdram_params->base, 0);
 
-     printascii("out\n");
+     if (!IS_ENABLED(CONFIG_RAM_ROCKCHIP_DEBUG_TINY))
+             printascii("out\n");
+

suggestion: just get rid of it

Quoted 2 lines

In a separate patch. Considering sdram_print_ddr_info() always print something, there's no need to say when we've exited that function I think?

I will be really happy to get rid of it! See my comments about this in the reply related to patch [2/4].

Regards,
Massimo

Quoted 3 lines

Cheers,
Quentin

#20 lore raw

Re: [PATCH v2 4/4] ram: rockchip: add config option for tinier debug

Hi Massimo,

Quoted 38 lines · Massimo Pegorer

Hi Quentin,

Il giorno mer 11 nov 2026 alle ore 17:23 Quentin Schulz ha scritto:

Quoted 30 lines

Hi Massimo,

Quoted 18 lines · Massimo Pegorer

Selecting the RAM_ROCKCHIP_DEBUG_TINY new configuration option, the debugging code prints only the SDRAM type, frequency and size, limiting the required space. In this way, the debugging code can coexist with support for multiple SDRAM types without exceeding the output size limit, such as in the case of the PX30 SoC TPL.

---
   drivers/ram/rockchip/Kconfig        | 11 ++++++++
   drivers/ram/rockchip/sdram_common.c | 54 ++++++++++++++++++-------------------
   drivers/ram/rockchip/sdram_px30.c   |  4 ++-
   3 files changed, 41 insertions(+), 28 deletions(-)
drivers/ram/rockchip/Kconfig +0 -0
index f51ae6a4542..98770659cd2 100644

drivers/ram/rockchip/Kconfig config RAM_ROCKCHIP_DEBUG · line 29

Quoted 6 lines
drivers/ram/rockchip/Kconfig +3 -0
@@ -24,6 +24,17 @@ config RAM_ROCKCHIP_DEBUG
         This is an option for developers to understand the ram drivers
         initialization, configurations and etc.
 
+config RAM_ROCKCHIP_DEBUG_TINY
+     bool "Rockchip ram drivers tiny debugging"
+     depends on RAM_ROCKCHIP_DEBUG

question: do we really need a new symbol for that?

Quoted 4 lines

Maybe we can simply have a constant (e.g. DEBUG) defined at the top of the file and check on that. I am trying to think if anyone would want to have this configurable in a defconfig? If it's only useful for quick debugging, I don't think it makes sense to have a symbol for it.

Quoted 5 lines

Quite true, indeed. But RAM_ROCKCHIP_DEBUG defaults to 'y', and 143 of the 152 configurations that have RAM_ROCKCHIP defined also have RAM_ROCKCHIP_DEBUG defined. Therefore I have thought about a Kconfig option, but we can consider a different solution: will do in a next series.

Do you have an idea about the size impact of RAM_ROCKCHIP_DEBUG=y compared to RAM_ROCKCHIP_DEBUG=n, both with your series applied?

I'm wondering if we cannot change the meaning of RAM_ROCKCHIP_DEBUG. Essentially, always print the few infos we have about DDR, and have RAM_ROCKCHIP_DEBUG decide whether we print *more* instead of *all*.

From ./tools/qconfig.py -f ARCH_ROCKCHIP '~RAM_ROCKCHIP_DEBUG', I think the problematic ones could be RV1108 and RK3036 boards which have very limited SRAM (12KB, 8KB). RK3566 and RV1126 have 64KB, RK3399 200KB and RK3588 almost 1MiB so they should be fine?

Cheers,
Quentin