Skip to contentSkip to conversation

Support multiple DDR configs in PX30 TPL

PATCH Superseded Massimo Pegorer 2 participants 9 messages Aug 29 – Oct 28 Arm Rockchip

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Support multiple DDR configs in PX30 TPL

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

The approach is trivial: apply supported DDR config sets in a predefined order (DDR4, LPDDR2, LPDDR3, DDR3) stopping at the first one that makes SDRAM initialization function to complete with success. 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. DDR3, LPDDR2, LPDDR3, DDR4). It would be useful if further tests will be run on other PX30 based boards.

The patches does not affect binary code of TPL for any of the existing U-Boot configurations.

The first patch improves clarity of DDR type support selection for Rockchip SoCs at Kconfig level. Not all the DDR type config options named in the Kconfig are supported by each one of the Rockchip SoCs. Moreover, the LPDDR4 option has a different meaning in the context of the RK3399 SoC than in the RV1126 one. Thus, split options with ad-hoc specific help sections and use depends on conditionals.

The second patch splits RV1126 options (at most one should be selected) from PX30 options (more options can be selected), and adds DDR3 option for PX30. The PX30 sdram driver includes all of the selected DDR type sets or just the DDR3 one if none is selected: not like it too much but I preferred to preserve default fallback behavior (include DDR3 support if no option is selected) to avoid modifing boards configs relying on it. The parameters sets are applied as already described.

---
Massimo Pegorer (2):
ram: rockchip: improve ddr type configs selection
ram: rockchip: px30: allow multiple DDR types selection

 drivers/ram/rockchip/Kconfig      | 78 ++++++++++++++++++++++++++++++++++++---
 drivers/ram/rockchip/sdram_px30.c | 35 +++++++++++-------
 2 files changed, 93 insertions(+), 20 deletions(-)

---
base-commit: 964ad5b5c91b7be56e443e899d7f873e6aa8c9fc
change-id: 20260828-ddr-multi-2c4fd64344c8

Best regards,

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

PATCH 1/2 ram: rockchip: improve ddr type configs selection

Not all the DDR type config options named in the Kconfig are supported by each one of the Rockchip SoCs. Moreover, the LPDDR4 option has a different meaning in the context of the RK3399 SoC than in the RV1126 one. Improve clarity splitting config options, using SoC specific help sections and adding depends on conditionals.

Involved Rockchip SoCs are: RK3399, PX30, RV1126.

---
 drivers/ram/rockchip/Kconfig | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)
drivers/ram/rockchip/Kconfig +28 -1
index d707d09c1c8..61a3193b3f5 100644
@@ -26,26 +26,53 @@ config RAM_ROCKCHIP_DEBUG
 
 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.
 
+	  Note that even if multiple DDR/LPDDR types are selected, support is
+	  enabled only for the selected one that comes first in the following
+	  list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+
 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.
 
+	  Note that even if multiple DDR/LPDDR types are selected, support is
+	  enabled only for the selected one that comes first in the following
+	  list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+
 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.
 
+	  Note that even if multiple DDR/LPDDR types are selected, support is
+	  enabled only for the selected one that comes first in the following
+	  list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+
 config RAM_ROCKCHIP_LPDDR4
+	depends on ROCKCHIP_RV1126
 	bool "LPDDR4 support for Rockchip SoCs"
 	help
-	  This enables LPDDR4 sdram code support for the platforms based
+	  This enables LPDDR4 sdram support instead of the default DDR3 support
 	  on Rockchip SoCs.
 
+	  Note that even if multiple DDR/LPDDR types are selected, support is
+	  enabled only for the selected one that comes first in the following
+	  list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+
+config RAM_ROCKCHIP_LPDDR4
+	bool "LPDDR4 support for Rockchip SoCs"
+	depends on ROCKCHIP_RK3399
+	help
+	  This enables LPDDR4 sdram code support for the platforms based
+	  on Rockchip RK3399 SoC.
+
 endif # RAM_ROCKCHIP
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 1/2] ram: rockchip: improve ddr type configs selection

Hi Massimo,

Thanks for the patches. Note that the timing is interesting as we were considering having two variants of the same product, one with DDR3 and one with DDR4 and we don't want to have with deal with multiple binaries just for that.

Quoted 5 lines · Massimo Pegorer

Not all the DDR type config options named in the Kconfig are supported by each one of the Rockchip SoCs. Moreover, the LPDDR4 option has a different meaning in the context of the RK3399 SoC than in the RV1126 one. Improve clarity splitting config options, using SoC specific help sections and adding depends on conditionals.

Yeah, we shouldn't do that.

Quoted 13 lines

Involved Rockchip SoCs are: RK3399, PX30, RV1126.

---
  drivers/ram/rockchip/Kconfig | 29 ++++++++++++++++++++++++++++-
  1 file changed, 28 insertions(+), 1 deletion(-)
drivers/ram/rockchip/Kconfig +0 -0
index d707d09c1c8..61a3193b3f5 100644

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

Quoted 4 lines
drivers/ram/rockchip/Kconfig +1 -0
@@ -26,26 +26,53 @@ config RAM_ROCKCHIP_DEBUG
 
  config RAM_ROCKCHIP_DDR4
  	bool "DDR4 support for Rockchip SoCs"
+	depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126

This kind of change is very welcome.

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

Quoted 4 lines
drivers/ram/rockchip/Kconfig +0 -0
  	help
  	  This enables DDR4 sdram support instead of the default DDR3 support
  	  on Rockchip SoCs.
 

We should get rid of the part that says "instead of the default DDR3 support". We should have instead an option for DDR3 which is enabled by default and then we don't have to care about that part.

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

Quoted 3 lines
drivers/ram/rockchip/Kconfig +3 -0
+	  Note that even if multiple DDR/LPDDR types are selected, support is
+	  enabled only for the selected one that comes first in the following
+	  list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.

This one change though is less welcome. I don't want to have this in the Kconfig help text. I suspect nobody will maintain this in the long term.

Quoted 32 lines
drivers/ram/rockchip/Kconfig +14 -1
+
  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.
 
+	  Note that even if multiple DDR/LPDDR types are selected, support is
+	  enabled only for the selected one that comes first in the following
+	  list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+
  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.
 
+	  Note that even if multiple DDR/LPDDR types are selected, support is
+	  enabled only for the selected one that comes first in the following
+	  list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+
  config RAM_ROCKCHIP_LPDDR4
+	depends on ROCKCHIP_RV1126
  	bool "LPDDR4 support for Rockchip SoCs"
  	help
-	  This enables LPDDR4 sdram code support for the platforms based
+	  This enables LPDDR4 sdram support instead of the default DDR3 support
  	  on Rockchip SoCs.
 
+	  Note that even if multiple DDR/LPDDR types are selected, support is

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

Quoted 10 lines
drivers/ram/rockchip/Kconfig +10 -0
+	  enabled only for the selected one that comes first in the following
+	  list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+
+config RAM_ROCKCHIP_LPDDR4
+	bool "LPDDR4 support for Rockchip SoCs"
+	depends on ROCKCHIP_RK3399
+	help
+	  This enables LPDDR4 sdram code support for the platforms based
+	  on Rockchip RK3399 SoC.
+

Please do not duplicate the same symbol twice just to change its helptext.

For drivers that support multiple DRAM types but not at the same time, the easiest answer would be to enforce that outside of Kconfig with something like:

#if defined(CONFIG_RAM_ROCKCHIP_LPDDR4) + defined(CONFIG_RAM_ROCKCHIP_DDR4) + defined(CONFIG_RAM_ROCKCHIP_LPDDR2) > 1 #error "This driver only supports one DRAM configuration at a time"
#endif

in the driver. I don't like it too much as this should really be in the Kconfig symbol but I couldn't think of a way to easily have only one symbol among a list to be allowed to be selected (that's typically a choice Kconfig) and also have the same symbols allowed to be selected as many as possible, depending on the SoC. I think it's a good compromise for now to fail the build by having this kind of check in the driver. However, this won't play nice with COMPILE_TEST so not sure if it's acceptable to Tom.

Ideally, we should also figure out which DRAM type(s) are supported by DRAM drivers that do not make use of the Kconfig symbols. e.g. RK3066 for example, and have them explicitly enabled in Kconfig for completeness. That isn't required for this series.

Cheers,
Quentin

#3 lore raw

Re: [PATCH 1/2] ram: rockchip: improve ddr type configs selection

Hi Quentin,

Il giorno gio 8 ott 2026 alle ore 22:49 Quentin Schulz ha scritto:

Quoted 7 lines

Hi Massimo,

Thanks for the patches. Note that the timing is interesting as we were considering having two variants of the same product, one with DDR3 and one with DDR4 and we don't want to have with deal with multiple binaries just for that.

Good to know!

Quoted 30 lines · Massimo Pegorer
Quoted 5 lines

Not all the DDR type config options named in the Kconfig are supported by each one of the Rockchip SoCs. Moreover, the LPDDR4 option has a different meaning in the context of the RK3399 SoC than in the RV1126 one. Improve clarity splitting config options, using SoC specific help sections and adding depends on conditionals.

Yeah, we shouldn't do that.

Quoted 13 lines

Involved Rockchip SoCs are: RK3399, PX30, RV1126.

---
  drivers/ram/rockchip/Kconfig | 29 ++++++++++++++++++++++++++++-
  1 file changed, 28 insertions(+), 1 deletion(-)
drivers/ram/rockchip/Kconfig +0 -0
index d707d09c1c8..61a3193b3f5 100644

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

Quoted 4 lines
drivers/ram/rockchip/Kconfig +1 -0
@@ -26,26 +26,53 @@ config RAM_ROCKCHIP_DEBUG
 
  config RAM_ROCKCHIP_DDR4
      bool "DDR4 support for Rockchip SoCs"
+     depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126

This kind of change is very welcome.

Quoted 8 lines

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

Quoted 4 lines
drivers/ram/rockchip/Kconfig +0 -0
      help
        This enables DDR4 sdram support instead of the default DDR3 support
        on Rockchip SoCs.
 

We should get rid of the part that says "instead of the default DDR3 support". We should have instead an option for DDR3 which is enabled by default and then we don't have to care about that part.

OK, I can add a new config option for DDR3. But in this case, we will also need to check at build time that at least one config option has been selected.

Quoted 7 lines

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

Quoted 4 lines
drivers/ram/rockchip/Kconfig +3 -0
+       Note that even if multiple DDR/LPDDR types are selected, support is
+       enabled only for the selected one that comes first in the following
+       list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.

This one change though is less welcome. I don't want to have this in the Kconfig help text. I suspect nobody will maintain this in the long term.

I'm just describing the status quo. I agree there is a risk, but what do we prefer? The risk that nobody will maintain this in the long term, or the certainty the config options help is providing wrong information?

A trivial Kconfig choice would solve the issue, of course, but as I would like to support multiple DDR configurations with the next patch, it is not the way.

Quoted 32 lines
Quoted 32 lines
drivers/ram/rockchip/Kconfig +13 -1
+
  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.
 
+       Note that even if multiple DDR/LPDDR types are selected, support is
+       enabled only for the selected one that comes first in the following
+       list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+
  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.
 
+       Note that even if multiple DDR/LPDDR types are selected, support is
+       enabled only for the selected one that comes first in the following
+       list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+
  config RAM_ROCKCHIP_LPDDR4
+     depends on ROCKCHIP_RV1126
      bool "LPDDR4 support for Rockchip SoCs"
      help
-       This enables LPDDR4 sdram code support for the platforms based
+       This enables LPDDR4 sdram support instead of the default DDR3 support
        on Rockchip SoCs.
 
Quoted 13 lines

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

Quoted 11 lines
drivers/ram/rockchip/Kconfig +11 -0
+       Note that even if multiple DDR/LPDDR types are selected, support is
+       enabled only for the selected one that comes first in the following
+       list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+
+config RAM_ROCKCHIP_LPDDR4
+     bool "LPDDR4 support for Rockchip SoCs"
+     depends on ROCKCHIP_RK3399
+     help
+       This enables LPDDR4 sdram code support for the platforms based
+       on Rockchip RK3399 SoC.
+

Please do not duplicate the same symbol twice just to change its helptext.

Ok, but please consider that RAM_ROCKCHIP_LPDDR4 has two different meanings, one in the context of RK339 and another in the context of RV1126.

Within RV1126, it means including LPDDR4 support and not including neither the support for DDR4 nor the one for DDR3 (RV1126 can support: LPDDR4, DDR4, DDR3). This is like all other DDR config options that apply to PX30 and/or RV1126.

Within RK3399, it means including LPDDR4 support and... ...not clear to me (indeed I left its help text unchanged): the RK3399 SDRAM driver seems able to support multiple DDR types by default (which ones I do not know, DDR3 and LPDDR3 at least), and LPDDR4 support seems to have been added on top. I would say that with this config option selected DDR types other than LPDDR4 will not work, but I am not sure.

Therefore, would you prefer a single help text with two paragraphs, one describing the RV1126 scenario and another for the RK3399 one? But for the RK3399 default case, what config option should be used? The suggested new DDR3 one would not fit. For all these reasons, I would suggest having an RK3399 specific LPDDR4 config option, something like RAM_ROCKCHIP_LPDDR4_RK3399, because it is a really different scenario.

Quoted 10 lines

For drivers that support multiple DRAM types but not at the same time, the easiest answer would be to enforce that outside of Kconfig with something like:

#if defined(CONFIG_RAM_ROCKCHIP_LPDDR4) + defined(CONFIG_RAM_ROCKCHIP_DDR4) + defined(CONFIG_RAM_ROCKCHIP_LPDDR2) > 1 #error "This driver only supports one DRAM configuration at a time" #endif

Quoted 6 lines

in the driver. I don't like it too much as this should really be in the Kconfig symbol but I couldn't think of a way to easily have only one symbol among a list to be allowed to be selected (that's typically a choice Kconfig) and also have the same symbols allowed to be selected as many as possible, depending on the SoC. I think it's a good compromise for now to fail the build by having this kind of check in the driver.

I agree with you, both on what you do not like and on what should really be, too. I will follow the suggested approach in v2.

Quoted 2 lines

However, this won't play nice with COMPILE_TEST so not sure if it's acceptable to Tom.

I know nothing about COMPILE_TEST, but I see xPL builds depends on !COMPILE_TEST. And PX30 and RV1126 SDRAM support code is part of xPL, therefore could not be a problem, maybe.

Quoted 5 lines

Ideally, we should also figure out which DRAM type(s) are supported by DRAM drivers that do not make use of the Kconfig symbols. e.g. RK3066 for example, and have them explicitly enabled in Kconfig for completeness. That isn't required for this series.

With which purpose? If there is nothing to select/deselect at configuration level, I would avoid this. Instead, I would add the information in the documentation.

Thanks. Regards,
Massimo

Quoted 3 lines

Cheers,
Quentin

#4 lore raw

Re: [PATCH 1/2] ram: rockchip: improve ddr type configs selection

Hi Massimo,

Quoted 48 lines · Massimo Pegorer

Hi Quentin,

Il giorno gio 8 ott 2026 alle ore 22:49 Quentin Schulz ha scritto:

Quoted 7 lines

Hi Massimo,

Thanks for the patches. Note that the timing is interesting as we were considering having two variants of the same product, one with DDR3 and one with DDR4 and we don't want to have with deal with multiple binaries just for that.

Good to know!

Quoted 35 lines · Massimo Pegorer
Quoted 5 lines

Not all the DDR type config options named in the Kconfig are supported by each one of the Rockchip SoCs. Moreover, the LPDDR4 option has a different meaning in the context of the RK3399 SoC than in the RV1126 one. Improve clarity splitting config options, using SoC specific help sections and adding depends on conditionals.

Yeah, we shouldn't do that.

Quoted 13 lines

Involved Rockchip SoCs are: RK3399, PX30, RV1126.

---
   drivers/ram/rockchip/Kconfig | 29 ++++++++++++++++++++++++++++-
   1 file changed, 28 insertions(+), 1 deletion(-)
drivers/ram/rockchip/Kconfig +0 -0
index d707d09c1c8..61a3193b3f5 100644

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

Quoted 4 lines
drivers/ram/rockchip/Kconfig +1 -0
@@ -26,26 +26,53 @@ config RAM_ROCKCHIP_DEBUG
 
   config RAM_ROCKCHIP_DDR4
       bool "DDR4 support for Rockchip SoCs"
+     depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126

This kind of change is very welcome.

Quoted 4 lines
drivers/ram/rockchip/Kconfig +0 -0
       help
         This enables DDR4 sdram support instead of the default DDR3 support
         on Rockchip SoCs.
 
Quoted 7 lines
Quoted 3 lines

We should get rid of the part that says "instead of the default DDR3 support". We should have instead an option for DDR3 which is enabled by default and then we don't have to care about that part.

OK, I can add a new config option for DDR3. But in this case, we will also need to check at build time that at least one config option has been selected.

That could easily be done by having an invisible Kconfig symbol which is selected by all of the DRAM types. Then we can have a

ifneq (CONFIG_ROCKCHIP_AT_LEAST_ONE_DRAM_TYPE,y) $(error At least one DRAM type needs to be selected) endif

in drivers/ram/rockchip/Makefile or something like that.

Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
drivers/ram/rockchip/Kconfig +3 -0
+       Note that even if multiple DDR/LPDDR types are selected, support is
+       enabled only for the selected one that comes first in the following
+       list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
Quoted 7 lines
Quoted 2 lines

This one change though is less welcome. I don't want to have this in the Kconfig help text. I suspect nobody will maintain this in the long term.

I'm just describing the status quo. I agree there is a risk, but what do we prefer? The risk that nobody will maintain this in the long term, or the certainty the config options help is providing wrong information?

Fail the build if there's more than one selected in a driver that only supports one at a time.

Quoted 3 lines

A trivial Kconfig choice would solve the issue, of course, but as I would like to support multiple DDR configurations with the next patch, it is not the way.

Yes, that's not the right choice indeed.

Quoted 60 lines
Quoted 32 lines
Quoted 32 lines
drivers/ram/rockchip/Kconfig +13 -1
+
   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.
 
+       Note that even if multiple DDR/LPDDR types are selected, support is
+       enabled only for the selected one that comes first in the following
+       list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+
   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.
 
+       Note that even if multiple DDR/LPDDR types are selected, support is
+       enabled only for the selected one that comes first in the following
+       list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+
   config RAM_ROCKCHIP_LPDDR4
+     depends on ROCKCHIP_RV1126
       bool "LPDDR4 support for Rockchip SoCs"
       help
-       This enables LPDDR4 sdram code support for the platforms based
+       This enables LPDDR4 sdram support instead of the default DDR3 support
         on Rockchip SoCs.
 
Quoted 13 lines

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

Quoted 11 lines
drivers/ram/rockchip/Kconfig +11 -0
+       Note that even if multiple DDR/LPDDR types are selected, support is
+       enabled only for the selected one that comes first in the following
+       list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+
+config RAM_ROCKCHIP_LPDDR4
+     bool "LPDDR4 support for Rockchip SoCs"
+     depends on ROCKCHIP_RK3399
+     help
+       This enables LPDDR4 sdram code support for the platforms based
+       on Rockchip RK3399 SoC.
+

Please do not duplicate the same symbol twice just to change its helptext.

Ok, but please consider that RAM_ROCKCHIP_LPDDR4 has two different meanings, one in the context of RK339 and another in the context of RV1126.

Within RV1126, it means including LPDDR4 support and not including neither the support for DDR4 nor the one for DDR3 (RV1126 can support: LPDDR4, DDR4, DDR3). This is like all other DDR config options that apply to PX30 and/or RV1126.

Within RK3399, it means including LPDDR4 support and... ...not clear to me (indeed I left its help text unchanged): the RK3399 SDRAM driver seems able to support multiple DDR types by default (which ones I do not know, DDR3 and LPDDR3 at least), and LPDDR4 support seems to have been added on top. I would say that with this config option selected DDR types other than LPDDR4 will not work, but I am not sure.

Quoted 7 lines

Therefore, would you prefer a single help text with two paragraphs, one describing the RV1126 scenario and another for the RK3399 one? But for the RK3399 default case, what config option should be used? The suggested new DDR3 one would not fit. For all these reasons, I would suggest having an RK3399 specific LPDDR4 config option, something like RAM_ROCKCHIP_LPDDR4_RK3399, because it is a really different scenario.

Just don't describe any of it outside of "DDR4 support". The symbol should only be selectable if the SoC supports the DRAM type. For drivers that support multiple types at once, let them be all selectable. Otherwise, have the build fail if more than one are selected (e.g. from within the driver directly). I would say most boards will only select one anyway and you likely know which one you need for your board.

Quoted 20 lines
Quoted 10 lines

For drivers that support multiple DRAM types but not at the same time, the easiest answer would be to enforce that outside of Kconfig with something like:

#if defined(CONFIG_RAM_ROCKCHIP_LPDDR4) + defined(CONFIG_RAM_ROCKCHIP_DDR4) + defined(CONFIG_RAM_ROCKCHIP_LPDDR2) > 1 #error "This driver only supports one DRAM configuration at a time" #endif

Quoted 6 lines

in the driver. I don't like it too much as this should really be in the Kconfig symbol but I couldn't think of a way to easily have only one symbol among a list to be allowed to be selected (that's typically a choice Kconfig) and also have the same symbols allowed to be selected as many as possible, depending on the SoC. I think it's a good compromise for now to fail the build by having this kind of check in the driver.

I agree with you, both on what you do not like and on what should really be, too. I will follow the suggested approach in v2.

Quoted 7 lines
Quoted 2 lines

However, this won't play nice with COMPILE_TEST so not sure if it's acceptable to Tom.

I know nothing about COMPILE_TEST, but I see xPL builds depends on !COMPILE_TEST. And PX30 and RV1126 SDRAM support code is part of xPL, therefore could not be a problem, maybe.

CONFIG_RAM exists, so it's also available in proper, where COMPILE_TEST could be selected?

Quoted 10 lines
Quoted 5 lines

Ideally, we should also figure out which DRAM type(s) are supported by DRAM drivers that do not make use of the Kconfig symbols. e.g. RK3066 for example, and have them explicitly enabled in Kconfig for completeness. That isn't required for this series.

With which purpose? If there is nothing to select/deselect at configuration level, I would avoid this. Instead, I would add the information in the documentation.

Consistency but also to prepare the driver for more types to be supported in the future. But again, nothing required for this series.

Cheers,
Quentin

#5 lore raw

PATCH 2/2 ram: rockchip: px30: allow multiple DDR types selection

In reply to Massimo Pegorer

Allow the inclusion of more than one DDR parameters set in the PX30 SDRAM driver. The driver applies included sets in a predefined order (DDR4, LPDDR2, LPDDR3, DDR3), stopping at the first one that makes SDRAM initialization function to complete with success.

The default fallback behaviour is preserved: if no DDR configuration option is selected, DDR3 parameters set is included.

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

---
 drivers/ram/rockchip/Kconfig      | 67 +++++++++++++++++++++++++++++++--------
 drivers/ram/rockchip/sdram_px30.c | 35 ++++++++++++--------
 2 files changed, 74 insertions(+), 28 deletions(-)
drivers/ram/rockchip/Kconfig +53 -14
index 61a3193b3f5..d74980402ad 100644
@@ -24,38 +24,77 @@ 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
+	help
+	  Enable DDR3 sdram support on Rockchip SoCs.
+
+	  Note that enabling support for multiple DDR/LPDDR types may cause TPL
+	  to exceed its maximum size constraint (TPL_MAX_SIZE), depending on
+	  other configuration options selection (such as RAM_ROCKCHIP_DEBUG).
+
+	  The driver applies selected sdram parameters sets in the following
+	  order - DDR4 LPDDR2 LPDDR3 DDR3 - stopping at first set that makes
+	  sdram_init_detect() to complete successfully.
+
+	  If no DDR/LPDDR option is selected, DDR3 sdram support is enabled by
+	  default for backward compatibility with existing board configurations.
+	  Therefore this option is only useful for multiple DDR/LPDDR types
+	  selection.
+
 config RAM_ROCKCHIP_DDR4
 	bool "DDR4 support for Rockchip SoCs"
-	depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126
+	depends on ROCKCHIP_PX30
 	help
-	  This enables DDR4 sdram support instead of the default DDR3 support
-	  on Rockchip SoCs.
+	  Enable DDR4 sdram support on Rockchip SoCs.
 
-	  Note that even if multiple DDR/LPDDR types are selected, support is
-	  enabled only for the selected one that comes first in the following
-	  list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+	  Note that enabling support for multiple DDR/LPDDR types may cause TPL
+	  to exceed its maximum size constraint (TPL_MAX_SIZE), depending on
+	  other configuration options selection (such as RAM_ROCKCHIP_DEBUG).
+
+	  The driver applies selected sdram parameters sets in the following
+	  order - DDR4 LPDDR2 LPDDR3 DDR3 - stopping at first set that makes
+	  sdram_init_detect() to complete successfully.
 
 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.
 
-	  Note that even if multiple DDR/LPDDR types are selected, support is
-	  enabled only for the selected one that comes first in the following
-	  list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+	  Note that enabling support for multiple DDR/LPDDR types may cause TPL
+	  to exceed its maximum size constraint (TPL_MAX_SIZE), depending on
+	  other configuration options selection (such as RAM_ROCKCHIP_DEBUG).
+
+	  The driver applies selected sdram parameters sets in the following
+	  order - DDR4 LPDDR2 LPDDR3 DDR3 - stopping at first set that makes
+	  sdram_init_detect() to complete successfully.
 
 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
+	  Enable LPDDR3 sdram support on Rockchip SoCs.
+
+	  Note that enabling support for multiple DDR/LPDDR types may cause TPL
+	  to exceed its maximum size constraint (TPL_MAX_SIZE), depending on
+	  other configuration options selection (such as RAM_ROCKCHIP_DEBUG).
+
+	  The driver applies selected sdram parameters sets in the following
+	  order - DDR4 LPDDR2 LPDDR3 DDR3 - stopping at first set that makes
+	  sdram_init_detect() to complete successfully.
+
+config RAM_ROCKCHIP_DDR4
+	bool "DDR4 support for Rockchip SoCs"
+	depends on ROCKCHIP_RV1126
+	help
+	  This enables DDR4 sdram support instead of the default DDR3 support
 	  on Rockchip SoCs.
 
 	  Note that even if multiple DDR/LPDDR types are selected, support is
 	  enabled only for the selected one that comes first in the following
-	  list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+	  list: LPDDR4, DDR4, DDR3.
 
 config RAM_ROCKCHIP_LPDDR4
 	depends on ROCKCHIP_RV1126
@@ -66,7 +105,7 @@ config RAM_ROCKCHIP_LPDDR4
 
 	  Note that even if multiple DDR/LPDDR types are selected, support is
 	  enabled only for the selected one that comes first in the following
-	  list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+	  list: LPDDR4, DDR4, DDR3.
 
 config RAM_ROCKCHIP_LPDDR4
 	bool "LPDDR4 support for Rockchip SoCs"
drivers/ram/rockchip/sdram_px30.c +21 -14
index 37e62120504..ac9f5827d1d 100644
@@ -126,11 +126,17 @@ struct dram_info dram_info;
 struct px30_sdram_params sdram_configs[] = {
 #if defined(CONFIG_RAM_ROCKCHIP_DDR4)
 #include	"sdram-px30-ddr4-detect-333.inc"
-#elif defined(CONFIG_RAM_ROCKCHIP_LPDDR2)
+#endif
+#if defined(CONFIG_RAM_ROCKCHIP_LPDDR2)
 #include	"sdram-px30-lpddr2-detect-333.inc"
-#elif defined(CONFIG_RAM_ROCKCHIP_LPDDR3)
+#endif
+#if defined(CONFIG_RAM_ROCKCHIP_LPDDR3)
 #include	"sdram-px30-lpddr3-detect-333.inc"
-#else
+#endif
+#if defined(CONFIG_RAM_ROCKCHIP_DDR3) ||         \
+	(!defined(CONFIG_RAM_ROCKCHIP_DDR4) &&   \
+	 !defined(CONFIG_RAM_ROCKCHIP_LPDDR2) && \
+	 !defined(CONFIG_RAM_ROCKCHIP_LPDDR3))
 #include	"sdram-px30-ddr3-detect-333.inc"
 #endif
 };
@@ -682,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, i = 0;
 
 	dram_info.phy = (void *)DDR_PHY_BASE_ADDR;
 	dram_info.pctl = (void *)DDRC_BASE_ADDR;
@@ -704,12 +702,21 @@ 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);
+	do {
+		sdram_configs[i].skew = &skew;
+		sdram_params = &sdram_configs[i];
+		ret = sdram_init_detect(&dram_info, sdram_params);
+	} while (ret && ++i < ARRAY_SIZE(sdram_configs));
 
 	if (ret)
 		goto error;
 
+	if (ARRAY_SIZE(sdram_configs) > 1) {
+		printascii("Applied sdram config: ");
+		printdec(i);
+		printascii("\n");
+	}
+
 	sdram_print_ddr_info(&sdram_params->ch.cap_info, &sdram_params->base, 0);
 
 	printascii("out\n");
Signature · 1 line
2.34.1
#6 lore raw

Re: [PATCH 2/2] ram: rockchip: px30: allow multiple DDR types selection

Hi Massimo,

Quoted 3 lines · Massimo Pegorer

Allow the inclusion of more than one DDR parameters set in the PX30 SDRAM driver. The driver applies included sets in a predefined order (DDR4, LPDDR2, LPDDR3, DDR3), stopping at the first one that makes

What made you decide on this order?

Quoted 4 lines

SDRAM initialization function to complete with success.

The default fallback behaviour is preserved: if no DDR configuration option is selected, DDR3 parameters set is included.

We shouldn't do that, we instead should have the DDR3 symbol default to y for PX30 (and other SoCs if applicable), to preserve the current state. I don't like hidden defaults like that because you may end up with RAM_ROCKCHIP_DDR3 not selected and build a DRAM driver that only supports DDR3, which is kinda odd to be honest.

Quoted 5 lines

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

Good to know, thanks. But i'm assuming this likely means we can only have up to two DRAM configurations enabled at the same time?

I think the information printed by sdram_print_dram_type() is still interesting. Maybe we should have some log level for the DRAM init so we can select the verbosity of the debug output. In any case, just a thought and not a blocker for this series at all.

Quoted 3 lines
---
  drivers/ram/rockchip/Kconfig      | 67 +++++++++++++++++++++++++++++++--------

No to those changes. Keep it simple please, no redefinition of the symbol based on the SoC. For the RAM_ROCKCHIP_DEBUG needing to be disabled, the information is quite nice for end users so i could see it being added to all RAM_ROCKCHIP_ symbols as a hint (or have it somewhere in doc/board/rockchip for example).

Quoted 154 lines
  drivers/ram/rockchip/sdram_px30.c | 35 ++++++++++++--------
  2 files changed, 74 insertions(+), 28 deletions(-)
drivers/ram/rockchip/Kconfig +53 -14
index 61a3193b3f5..d74980402ad 100644
@@ -24,38 +24,77 @@ 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
+	help
+	  Enable DDR3 sdram support on Rockchip SoCs.
+
+	  Note that enabling support for multiple DDR/LPDDR types may cause TPL
+	  to exceed its maximum size constraint (TPL_MAX_SIZE), depending on
+	  other configuration options selection (such as RAM_ROCKCHIP_DEBUG).
+
+	  The driver applies selected sdram parameters sets in the following
+	  order - DDR4 LPDDR2 LPDDR3 DDR3 - stopping at first set that makes
+	  sdram_init_detect() to complete successfully.
+
+	  If no DDR/LPDDR option is selected, DDR3 sdram support is enabled by
+	  default for backward compatibility with existing board configurations.
+	  Therefore this option is only useful for multiple DDR/LPDDR types
+	  selection.
+
  config RAM_ROCKCHIP_DDR4
  	bool "DDR4 support for Rockchip SoCs"
-	depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126
+	depends on ROCKCHIP_PX30
  	help
-	  This enables DDR4 sdram support instead of the default DDR3 support
-	  on Rockchip SoCs.
+	  Enable DDR4 sdram support on Rockchip SoCs.
 
-	  Note that even if multiple DDR/LPDDR types are selected, support is
-	  enabled only for the selected one that comes first in the following
-	  list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+	  Note that enabling support for multiple DDR/LPDDR types may cause TPL
+	  to exceed its maximum size constraint (TPL_MAX_SIZE), depending on
+	  other configuration options selection (such as RAM_ROCKCHIP_DEBUG).
+
+	  The driver applies selected sdram parameters sets in the following
+	  order - DDR4 LPDDR2 LPDDR3 DDR3 - stopping at first set that makes
+	  sdram_init_detect() to complete successfully.
 
  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.
 
-	  Note that even if multiple DDR/LPDDR types are selected, support is
-	  enabled only for the selected one that comes first in the following
-	  list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+	  Note that enabling support for multiple DDR/LPDDR types may cause TPL
+	  to exceed its maximum size constraint (TPL_MAX_SIZE), depending on
+	  other configuration options selection (such as RAM_ROCKCHIP_DEBUG).
+
+	  The driver applies selected sdram parameters sets in the following
+	  order - DDR4 LPDDR2 LPDDR3 DDR3 - stopping at first set that makes
+	  sdram_init_detect() to complete successfully.
 
  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
+	  Enable LPDDR3 sdram support on Rockchip SoCs.
+
+	  Note that enabling support for multiple DDR/LPDDR types may cause TPL
+	  to exceed its maximum size constraint (TPL_MAX_SIZE), depending on
+	  other configuration options selection (such as RAM_ROCKCHIP_DEBUG).
+
+	  The driver applies selected sdram parameters sets in the following
+	  order - DDR4 LPDDR2 LPDDR3 DDR3 - stopping at first set that makes
+	  sdram_init_detect() to complete successfully.
+
+config RAM_ROCKCHIP_DDR4
+	bool "DDR4 support for Rockchip SoCs"
+	depends on ROCKCHIP_RV1126
+	help
+	  This enables DDR4 sdram support instead of the default DDR3 support
  	  on Rockchip SoCs.
 
  	  Note that even if multiple DDR/LPDDR types are selected, support is
  	  enabled only for the selected one that comes first in the following
-	  list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+	  list: LPDDR4, DDR4, DDR3.
 
  config RAM_ROCKCHIP_LPDDR4
  	depends on ROCKCHIP_RV1126
@@ -66,7 +105,7 @@ config RAM_ROCKCHIP_LPDDR4
 
  	  Note that even if multiple DDR/LPDDR types are selected, support is
  	  enabled only for the selected one that comes first in the following
-	  list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+	  list: LPDDR4, DDR4, DDR3.
 
  config RAM_ROCKCHIP_LPDDR4
  	bool "LPDDR4 support for Rockchip SoCs"
drivers/ram/rockchip/sdram_px30.c +10 -12
index 37e62120504..ac9f5827d1d 100644
@@ -126,11 +126,17 @@ struct dram_info dram_info;
  struct px30_sdram_params sdram_configs[] = {
  #if defined(CONFIG_RAM_ROCKCHIP_DDR4)
  #include	"sdram-px30-ddr4-detect-333.inc"
-#elif defined(CONFIG_RAM_ROCKCHIP_LPDDR2)
+#endif
+#if defined(CONFIG_RAM_ROCKCHIP_LPDDR2)
  #include	"sdram-px30-lpddr2-detect-333.inc"
-#elif defined(CONFIG_RAM_ROCKCHIP_LPDDR3)
+#endif
+#if defined(CONFIG_RAM_ROCKCHIP_LPDDR3)
  #include	"sdram-px30-lpddr3-detect-333.inc"
-#else
+#endif
+#if defined(CONFIG_RAM_ROCKCHIP_DDR3) ||         \
+	(!defined(CONFIG_RAM_ROCKCHIP_DDR4) &&   \
+	 !defined(CONFIG_RAM_ROCKCHIP_LPDDR2) && \
+	 !defined(CONFIG_RAM_ROCKCHIP_LPDDR3))
  #include	"sdram-px30-ddr3-detect-333.inc"
  #endif
  };
@@ -682,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, i = 0;
 
  	dram_info.phy = (void *)DDR_PHY_BASE_ADDR;
  	dram_info.pctl = (void *)DDRC_BASE_ADDR;

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

Quoted 10 lines
drivers/ram/rockchip/sdram_px30.c +5 -2
@@ -704,12 +702,21 @@ 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);
+	do {
+		sdram_configs[i].skew = &skew;
+		sdram_params = &sdram_configs[i];
+		ret = sdram_init_detect(&dram_info, sdram_params);
+	} while (ret && ++i < ARRAY_SIZE(sdram_configs));

A simple for-loop on the ARRAY_SIZE() would be easier to read. Once you have a match (ret = 0), break out of the loop and check ret before continuing in the code.

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

Quoted 8 lines
drivers/ram/rockchip/sdram_px30.c +4 -0
  	if (ret)
  		goto error;
 
+	if (ARRAY_SIZE(sdram_configs) > 1) {
+		printascii("Applied sdram config: ");
+		printdec(i);
+		printascii("\n");

This is not useful to the user as it's reflecting the index in an array that is not stable by design. We should instead report the DDR type (if we really want to). You can do this by simply calling sdram_print_dram_type(sdram_params->base.dramtype); Of course, this won't do anything right now since we need to disable RAM_ROCKCHIP_DEBUG to be able to compile support for more than one DRAM type.

I will only be able to test your series in November once I'm back in office, but I for sure will. In the meantime, you can always send a v2 and/or discuss the feedback :)

Cheers,
Quentin

#7 lore raw

Re: [PATCH 2/2] ram: rockchip: px30: allow multiple DDR types selection

Hi Quentin,

Il giorno gio 8 ott 2026 alle ore 22:49 Quentin Schulz ha scritto:

Quoted 9 lines

Hi Massimo,

Quoted 3 lines · Massimo Pegorer

Allow the inclusion of more than one DDR parameters set in the PX30 SDRAM driver. The driver applies included sets in a predefined order (DDR4, LPDDR2, LPDDR3, DDR3), stopping at the first one that makes

What made you decide on this order?

I've just followed the original order the data header files are included and thus added to sdram_configs[] array. I have no hints to do any fine reasoning about this. Maybe Rockchip could help.

Quoted 13 lines
Quoted 5 lines

SDRAM initialization function to complete with success.

The default fallback behaviour is preserved: if no DDR configuration option is selected, DDR3 parameters set is included.

We shouldn't do that, we instead should have the DDR3 symbol default to y for PX30 (and other SoCs if applicable), to preserve the current state. I don't like hidden defaults like that because you may end up with RAM_ROCKCHIP_DDR3 not selected and build a DRAM driver that only supports DDR3, which is kinda odd to be honest.

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

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

Good to know, thanks. But i'm assuming this likely means we can only have up to two DRAM configurations enabled at the same time?

There are some optimizations that can be made to include all four DDR configurations. I will provide them as a further patch if these are merged. Moreover, with the work done by Jonas, we would have more space in PX30 TPL:
I need to test these on top of his patches.

Quoted 10 lines

I think the information printed by sdram_print_dram_type() is still interesting. Maybe we should have some log level for the DRAM init so we can select the verbosity of the debug output. In any case, just a thought and not a blocker for this series at all.

Quoted 3 lines
---
  drivers/ram/rockchip/Kconfig      | 67 +++++++++++++++++++++++++++++++--------
Quoted 5 lines

No to those changes. Keep it simple please, no redefinition of the symbol based on the SoC. For the RAM_ROCKCHIP_DEBUG needing to be disabled, the information is quite nice for end users so i could see it being added to all RAM_ROCKCHIP_ symbols as a hint (or have it somewhere in doc/board/rockchip for example).

OK, but I'm providing multi DDR support just for PX30, not for RV1126. Therefore, the logic behind DDR config options common to both of them (such as DDR4) will be different in the two scenarios. Would you prefer a single config option with two paragraphs in the help text, one describing the PX30 scenario and another for the RV1126 one?

Quoted 158 lines
Quoted 158 lines
  drivers/ram/rockchip/sdram_px30.c | 35 ++++++++++++--------
  2 files changed, 74 insertions(+), 28 deletions(-)
drivers/ram/rockchip/Kconfig +53 -14
index 61a3193b3f5..d74980402ad 100644
@@ -24,38 +24,77 @@ 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
+     help
+       Enable DDR3 sdram support on Rockchip SoCs.
+
+       Note that enabling support for multiple DDR/LPDDR types may cause TPL
+       to exceed its maximum size constraint (TPL_MAX_SIZE), depending on
+       other configuration options selection (such as RAM_ROCKCHIP_DEBUG).
+
+       The driver applies selected sdram parameters sets in the following
+       order - DDR4 LPDDR2 LPDDR3 DDR3 - stopping at first set that makes
+       sdram_init_detect() to complete successfully.
+
+       If no DDR/LPDDR option is selected, DDR3 sdram support is enabled by
+       default for backward compatibility with existing board configurations.
+       Therefore this option is only useful for multiple DDR/LPDDR types
+       selection.
+
  config RAM_ROCKCHIP_DDR4
      bool "DDR4 support for Rockchip SoCs"
-     depends on ROCKCHIP_PX30 || ROCKCHIP_RV1126
+     depends on ROCKCHIP_PX30
      help
-       This enables DDR4 sdram support instead of the default DDR3 support
-       on Rockchip SoCs.
+       Enable DDR4 sdram support on Rockchip SoCs.
 
-       Note that even if multiple DDR/LPDDR types are selected, support is
-       enabled only for the selected one that comes first in the following
-       list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+       Note that enabling support for multiple DDR/LPDDR types may cause TPL
+       to exceed its maximum size constraint (TPL_MAX_SIZE), depending on
+       other configuration options selection (such as RAM_ROCKCHIP_DEBUG).
+
+       The driver applies selected sdram parameters sets in the following
+       order - DDR4 LPDDR2 LPDDR3 DDR3 - stopping at first set that makes
+       sdram_init_detect() to complete successfully.
 
  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.
 
-       Note that even if multiple DDR/LPDDR types are selected, support is
-       enabled only for the selected one that comes first in the following
-       list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+       Note that enabling support for multiple DDR/LPDDR types may cause TPL
+       to exceed its maximum size constraint (TPL_MAX_SIZE), depending on
+       other configuration options selection (such as RAM_ROCKCHIP_DEBUG).
+
+       The driver applies selected sdram parameters sets in the following
+       order - DDR4 LPDDR2 LPDDR3 DDR3 - stopping at first set that makes
+       sdram_init_detect() to complete successfully.
 
  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
+       Enable LPDDR3 sdram support on Rockchip SoCs.
+
+       Note that enabling support for multiple DDR/LPDDR types may cause TPL
+       to exceed its maximum size constraint (TPL_MAX_SIZE), depending on
+       other configuration options selection (such as RAM_ROCKCHIP_DEBUG).
+
+       The driver applies selected sdram parameters sets in the following
+       order - DDR4 LPDDR2 LPDDR3 DDR3 - stopping at first set that makes
+       sdram_init_detect() to complete successfully.
+
+config RAM_ROCKCHIP_DDR4
+     bool "DDR4 support for Rockchip SoCs"
+     depends on ROCKCHIP_RV1126
+     help
+       This enables DDR4 sdram support instead of the default DDR3 support
        on Rockchip SoCs.
 
        Note that even if multiple DDR/LPDDR types are selected, support is
        enabled only for the selected one that comes first in the following
-       list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+       list: LPDDR4, DDR4, DDR3.
 
  config RAM_ROCKCHIP_LPDDR4
      depends on ROCKCHIP_RV1126
@@ -66,7 +105,7 @@ config RAM_ROCKCHIP_LPDDR4
 
        Note that even if multiple DDR/LPDDR types are selected, support is
        enabled only for the selected one that comes first in the following
-       list: LPDDR4, DDR4, LPDDR2, LPDDR3, DDR3.
+       list: LPDDR4, DDR4, DDR3.
 
  config RAM_ROCKCHIP_LPDDR4
      bool "LPDDR4 support for Rockchip SoCs"
drivers/ram/rockchip/sdram_px30.c +10 -12
index 37e62120504..ac9f5827d1d 100644
@@ -126,11 +126,17 @@ struct dram_info dram_info;
  struct px30_sdram_params sdram_configs[] = {
  #if defined(CONFIG_RAM_ROCKCHIP_DDR4)
  #include    "sdram-px30-ddr4-detect-333.inc"
-#elif defined(CONFIG_RAM_ROCKCHIP_LPDDR2)
+#endif
+#if defined(CONFIG_RAM_ROCKCHIP_LPDDR2)
  #include    "sdram-px30-lpddr2-detect-333.inc"
-#elif defined(CONFIG_RAM_ROCKCHIP_LPDDR3)
+#endif
+#if defined(CONFIG_RAM_ROCKCHIP_LPDDR3)
  #include    "sdram-px30-lpddr3-detect-333.inc"
-#else
+#endif
+#if defined(CONFIG_RAM_ROCKCHIP_DDR3) ||         \
+     (!defined(CONFIG_RAM_ROCKCHIP_DDR4) &&   \
+      !defined(CONFIG_RAM_ROCKCHIP_LPDDR2) && \
+      !defined(CONFIG_RAM_ROCKCHIP_LPDDR3))
  #include    "sdram-px30-ddr3-detect-333.inc"
  #endif
  };
@@ -682,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, i = 0;
 
      dram_info.phy = (void *)DDR_PHY_BASE_ADDR;
      dram_info.pctl = (void *)DDRC_BASE_ADDR;
@@ -704,12 +702,21 @@ int sdram_init(void)
      dram_info.ddr_grf = (void *)DDR_GRF_BASE_ADDR;
      dram_info.pmugrf = (void *)PMUGRF_BASE_ADDR;
 
Quoted 11 lines

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

Quoted 7 lines
drivers/ram/rockchip/sdram_px30.c +5 -2
-     sdram_params = get_default_sdram_config();
-     ret = sdram_init_detect(&dram_info, sdram_params);
+     do {
+             sdram_configs[i].skew = &skew;
+             sdram_params = &sdram_configs[i];
+             ret = sdram_init_detect(&dram_info, sdram_params);
+     } while (ret && ++i < ARRAY_SIZE(sdram_configs));

A simple for-loop on the ARRAY_SIZE() would be easier to read. Once you have a match (ret = 0), break out of the loop and check ret before continuing in the code.

OK.

Quoted 10 lines

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

Quoted 9 lines
drivers/ram/rockchip/sdram_px30.c +4 -0
      if (ret)
              goto error;
 
+     if (ARRAY_SIZE(sdram_configs) > 1) {
+             printascii("Applied sdram config: ");
+             printdec(i);
+             printascii("\n");
Quoted 6 lines

This is not useful to the user as it's reflecting the index in an array that is not stable by design. We should instead report the DDR type (if we really want to). You can do this by simply calling sdram_print_dram_type(sdram_params->base.dramtype); Of course, this won't do anything right now since we need to disable RAM_ROCKCHIP_DEBUG to be able to compile support for more than one DRAM type.

I will drop these lines.

Quoted 4 lines

I will only be able to test your series in November once I'm back in office, but I for sure will. In the meantime, you can always send a v2 and/or discuss the feedback :)

Thanks, it would be really useful to have further test results as feedback. In the meantime, a will send a v2.

Regards,
Massimo

Quoted 3 lines

Cheers,
Quentin

#8 lore raw

Re: [PATCH 2/2] ram: rockchip: px30: allow multiple DDR types selection

Hi Massimo,

Quoted 11 lines · Massimo Pegorer

Hi Quentin,

Il giorno gio 8 ott 2026 alle ore 22:49 Quentin Schulz ha scritto:

Quoted 8 lines

Hi Massimo,

Quoted 3 lines · Massimo Pegorer

Allow the inclusion of more than one DDR parameters set in the PX30 SDRAM driver. The driver applies included sets in a predefined order (DDR4, LPDDR2, LPDDR3, DDR3), stopping at the first one that makes

Quoted 6 lines
Quoted 1 line

What made you decide on this order?

I've just followed the original order the data header files are included and thus added to sdram_configs[] array. I have no hints to do any fine reasoning about this. Maybe Rockchip could help.

Rockchip's DRAM init blob is usually unique for the SoC, regardless of the populated DRAM type. I'm thinking they do something similar we want to do in here, but I suspect this is "secret sauce". Ideally, someone could reverse the blob and figure out in which order they test the DRAM types. I know some people reversed RK356x's (and I vaguely remember RK3576 and RK3588 being looked at as well?), so maybe they could help, but who knows.

Quoted 42 lines
Quoted 13 lines
Quoted 5 lines

SDRAM initialization function to complete with success.

The default fallback behaviour is preserved: if no DDR configuration option is selected, DDR3 parameters set is included.

We shouldn't do that, we instead should have the DDR3 symbol default to y for PX30 (and other SoCs if applicable), to preserve the current state. I don't like hidden defaults like that because you may end up with RAM_ROCKCHIP_DDR3 not selected and build a DRAM driver that only supports DDR3, which is kinda odd to be honest.

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

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

Good to know, thanks. But i'm assuming this likely means we can only have up to two DRAM configurations enabled at the same time?

There are some optimizations that can be made to include all four DDR configurations. I will provide them as a further patch if these are merged. Moreover, with the work done by Jonas, we would have more space in PX30 TPL:
I need to test these on top of his patches.

Quoted 10 lines

I think the information printed by sdram_print_dram_type() is still interesting. Maybe we should have some log level for the DRAM init so we can select the verbosity of the debug output. In any case, just a thought and not a blocker for this series at all.

Quoted 3 lines
---
   drivers/ram/rockchip/Kconfig      | 67 +++++++++++++++++++++++++++++++--------
Quoted 5 lines

No to those changes. Keep it simple please, no redefinition of the symbol based on the SoC. For the RAM_ROCKCHIP_DEBUG needing to be disabled, the information is quite nice for end users so i could see it being added to all RAM_ROCKCHIP_ symbols as a hint (or have it somewhere in doc/board/rockchip for example).

Quoted 6 lines

OK, but I'm providing multi DDR support just for PX30, not for RV1126. Therefore, the logic behind DDR config options common to both of them (such as DDR4) will be different in the two scenarios. Would you prefer a single config option with two paragraphs in the help text, one describing the PX30 scenario and another for the RV1126 one?

Just say what this symbol means "support for X DRAM type" and that would be enough, the "depends on" part of the symbol should be enough for people to figure out whether it applies to their SoC or not.

Cheers,
Quentin