sunxi: H616: dram: fix LPDDR3 TRP6 parsing
Subsystems (3)
PATCH v2 1/1 sunxi: H616: dram: fix LPDDR3 TRP6 parsing
From: Jernej Skrabec <[email protected]>
Allwinner's BSP DRAM code uses parameter TPR6, presumably containing some "Vref" parameter, to encode the values for *all* four supported DRAM types. The code selects one byte based on the DRAM type used at runtime. To allow copying DRAM parameters from vendor firmware, we used this value and its encoding, but wrongly: the proper order of bytes is DDR3, DDR4, LPDDR3, LPDDR4, from LSB to MSB, cf. the A523 and A133 DRAM code.
Correct the masking for LPDDR3 to fix DRAM operation on some boards using this DRAM type.
With LPDDR3 TRP6 parsing fixed, adapt default DRAM_SUNXI_TPR6 value. Also change LPDDR4 default value to 0x38 used by A523 boards.
--- arch/arm/mach-sunxi/Kconfig | 2 +- arch/arm/mach-sunxi/dram_sun50i_h616.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-sunxi/Kconfig +1 -1
@@ -144,7 +144,7 @@ config DRAM_SUNXI_TPR3 config DRAM_SUNXI_TPR6 hex "DRAM TPR6 parameter" - default 0x3300c080 + default 0x38c00080 help TPR6 value from vendor DRAM settings.
arch/arm/mach-sunxi/dram_sun50i_h616.c +1 -1
@@ -975,7 +975,7 @@ static bool mctl_phy_init(const struct dram_para *para, val = para->tpr6 &0xff ;break ;case SUNXI_DRAM_TYPE_LPDDR3 : - val = para->tpr6 >>8 &0xff ; + val = para->tpr6 >>16 &0xff ;break ;case SUNXI_DRAM_TYPE_LPDDR4 : val = para->tpr6 >>24 &0xff ;
Signature · 1 line
2.53.0
Quoted 28 lines · Philippe Simons
From: Jernej Skrabec <[email protected]>
Allwinner's BSP DRAM code uses parameter TPR6, presumably containing some "Vref" parameter, to encode the values for *all* four supported DRAM types. The code selects one byte based on the DRAM type used at runtime. To allow copying DRAM parameters from vendor firmware, we used this value and its encoding, but wrongly: the proper order of bytes is DDR3, DDR4, LPDDR3, LPDDR4, from LSB to MSB, cf. the A523 and A133 DRAM code.
Correct the masking for LPDDR3 to fix DRAM operation on some boards using this DRAM type.
With LPDDR3 TRP6 parsing fixed, adapt default
DRAM_SUNXI_TPR6value. Also change LPDDR4 default value to0x38used by A523 boards.Signed-off-by Jernej Skrabec <[email protected]>[adjusted commit message, update default value]Signed-off-by Philippe Simons <[email protected]>--- arch/arm/mach-sunxi/Kconfig | 2 +- arch/arm/mach-sunxi/dram_sun50i_h616.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)arch/arm/mach-sunxi/Kconfig +0
-0
arch/arm/mach-sunxi/Kconfig config DRAM_SUNXI_TPR3 · line 147
Quoted 5 lines
arch/arm/mach-sunxi/Kconfig +1
-1@@ -144,7 +144,7 @@ config DRAM_SUNXI_TPR3 config DRAM_SUNXI_TPR6 hex "DRAM TPR6 parameter" - default 0x3300c080 + default 0x38c00080
I don't think this will be a good solution. The changes in this series were originally made to improve compatibility with the vendor driver, but now you are introducing an additional inconsistency by closing the previous one. The default values are not just arbitrary values — they are part of the vendor code that was obtained through binary analysis.
https://lore.kernel.org/all/[email protected]/
There are several options here:
1. If our goal is to improve compatibility, then we should not change the default values for LPDDR4, and only keep the changes for LPDDR3.
2. Add the changes from option 2, and additionally introduce the default values for the A523 platform that I made during the initial binary analysis but for some reason did not get merged into mainline.
(https://github.com/iuncuim/u-boot/blob/b17c5c8911a4fce328b01e6332632a9ccd88ebc6/arch/arm/mach-sunxi/Kconfig#L102)
3. If we accept the incompatibility between the vendor driver and the mainline driver, then this patch series is unnecessary because they introduce additional inconsistency with the vendor driver.
I think option two is the most correct, but option one is also suitable, since the DRAM driver for the A523 only supports DDR3 and LPDDR4, and the default values in this case are the same as for the H616 (A523 is 0x33808080, H616 is 0x33c00080).
Quoted 16 lines
arch/arm/mach-sunxi/Kconfig +0
-0help TPR6 value from vendor DRAM settings.arch/arm/mach-sunxi/dram_sun50i_h616.c +1
-1@@ -975,7 +975,7 @@ static bool mctl_phy_init(const struct dram_para *para, val = para->tpr6 &0xff ;break ;case SUNXI_DRAM_TYPE_LPDDR3 : - val = para->tpr6 >>8 &0xff ; + val = para->tpr6 >>16 &0xff ;break ;case SUNXI_DRAM_TYPE_LPDDR4 : val = para->tpr6 >>24 &0xff ;
Hi,
Quoted 24 lines · Mikhail Kalashnikov
Quoted 23 lines · Philippe Simons
From: Jernej Skrabec <[email protected]>
Allwinner's BSP DRAM code uses parameter TPR6, presumably containing some "Vref" parameter, to encode the values for *all* four supported DRAM types. The code selects one byte based on the DRAM type used at runtime. To allow copying DRAM parameters from vendor firmware, we used this value and its encoding, but wrongly: the proper order of bytes is DDR3, DDR4, LPDDR3, LPDDR4, from LSB to MSB, cf. the A523 and A133 DRAM code.
Correct the masking for LPDDR3 to fix DRAM operation on some boards using this DRAM type.
With LPDDR3 TRP6 parsing fixed, adapt default
DRAM_SUNXI_TPR6value. Also change LPDDR4 default value to0x38used by A523 boards.Signed-off-by Jernej Skrabec <[email protected]>[adjusted commit message, update default value]Signed-off-by Philippe Simons <[email protected]>--- arch/arm/mach-sunxi/Kconfig | 2 +- arch/arm/mach-sunxi/dram_sun50i_h616.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 15 lines
arch/arm/mach-sunxi/Kconfig config DRAM_SUNXI_TPR3 · line 146
Quoted 9 lines
arch/arm/mach-sunxi/Kconfig +1
-1@@ -144,7 +144,7 @@ config DRAM_SUNXI_TPR3 config DRAM_SUNXI_TPR6 hex "DRAM TPR6 parameter" - default 0x3300c080 + default 0x38c00080I don't think this will be a good solution. The changes in this series were originally made to improve compatibility with the vendor driver, but now you are introducing an additional inconsistency by closing the previous one. The default values are not just arbitrary values — they are part of the vendor code that was obtained through binary analysis.
https://lore.kernel.org/all/[email protected]/
I tend to agree with you, it feels like the default value was taken from the reference code while the field parsing was just an issue that was introduced with the h616 code. So it should not affect the defaut value, which was likely mistakenly parsed before.
Quoted 7 lines
There are several options here:
1. If our goal is to improve compatibility, then we should not change the default values for LPDDR4, and only keep the changes for LPDDR3.
2. Add the changes from option 2, and additionally introduce the default values for the A523 platform that I made during the initial binary analysis but for some reason did not get merged into mainline.
(https://github.com/iuncuim/u-boot/blob/b17c5c8911a4fce328b01e6332632a9ccd88ebc6/arch/arm/mach-sunxi/Kconfig#L102)
It would be good to have different defaults for different platforms yes. Note that the a133 code has some fallback with defaults when the extracted field in tpr6 is zero. Maybe they should be used as default value for a133. We probably still need to keep these fallbacks in the code in case some board-specific tpr6 value does have zeroes and relies on this behavior.
Quoted 3 lines
3. If we accept the incompatibility between the vendor driver and the mainline driver, then this patch series is unnecessary because they introduce additional inconsistency with the vendor driver.
We definitely want to be able to take the dram parameter values straight from the BSP and put them directly into our Kconfig. Changing the order of fields would make porting new boards very painful so it should be avoided.
Quoted 4 lines
I think option two is the most correct, but option one is also suitable, since the DRAM driver for the A523 only supports DDR3 and LPDDR4, and the default values in this case are the same as for the H616 (A523 is
0x33808080, H616 is0x33c00080).
I suggest we keep the current default (without moving the lpddr3 bits) for h616 and add new defaults in Kconfig for a523 and a133.
Quoted 4 lines
Quoted 4 lines
arch/arm/mach-sunxi/Kconfig +0
-0help TPR6 value from vendor DRAM settings.arch/arm/mach-sunxi/dram_sun50i_h616.c +0
-0
Quoted 8 lines
arch/arm/mach-sunxi/dram_sun50i_h616.c static bool mctl_phy_init(const struct dram_para *para, · line 978
Quoted 8 lines
arch/arm/mach-sunxi/dram_sun50i_h616.c +1
-1@@ -975,7 +975,7 @@ static bool mctl_phy_init(const struct dram_para *para, val = para->tpr6 &0xff ;break ;case SUNXI_DRAM_TYPE_LPDDR3 : - val = para->tpr6 >>8 &0xff ; + val = para->tpr6 >>16 &0xff ;
This change is definitely necessary though.
Quoted 3 lines
arch/arm/mach-sunxi/dram_sun50i_h616.c static bool mctl_phy_init(const struct dram_para *para, · line 981
Quoted 3 lines
arch/arm/mach-sunxi/dram_sun50i_h616.c +0
-0break ;case SUNXI_DRAM_TYPE_LPDDR4 : val = para->tpr6 >>24 &0xff ;
All the best,
Paul
Signature · 6 lines
Paul Kocialkowski, Free software developer - https://www.paulk.fr/ Independent contractor - sys-base - https://www.sys-base.io/ Contributor to fully free software support for selected hardware.
On Thu, 9 Apr 2026 17:10:19 +0200
Paul Kocialkowski <[email protected]> wrote:
Hi Paul, Mikhail,
thanks for the reply!
Quoted 43 lines
Hi,
Quoted 24 lines · Mikhail Kalashnikov
Quoted 23 lines · Philippe Simons
From: Jernej Skrabec <[email protected]>
Allwinner's BSP DRAM code uses parameter TPR6, presumably containing some "Vref" parameter, to encode the values for *all* four supported DRAM types. The code selects one byte based on the DRAM type used at runtime. To allow copying DRAM parameters from vendor firmware, we used this value and its encoding, but wrongly: the proper order of bytes is DDR3, DDR4, LPDDR3, LPDDR4, from LSB to MSB, cf. the A523 and A133 DRAM code.
Correct the masking for LPDDR3 to fix DRAM operation on some boards using this DRAM type.
With LPDDR3 TRP6 parsing fixed, adapt default
DRAM_SUNXI_TPR6value. Also change LPDDR4 default value to0x38used by A523 boards.Signed-off-by Jernej Skrabec <[email protected]>[adjusted commit message, update default value]Signed-off-by Philippe Simons <[email protected]>--- arch/arm/mach-sunxi/Kconfig | 2 +- arch/arm/mach-sunxi/dram_sun50i_h616.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)Quoted 15 lines
arch/arm/mach-sunxi/Kconfig config DRAM_SUNXI_TPR3 · line 146
Quoted 9 lines
arch/arm/mach-sunxi/Kconfig +1
-1@@ -144,7 +144,7 @@ config DRAM_SUNXI_TPR3 config DRAM_SUNXI_TPR6 hex "DRAM TPR6 parameter" - default 0x3300c080 + default 0x38c00080I don't think this will be a good solution. The changes in this series were originally made to improve compatibility with the vendor driver, but now you are introducing an additional inconsistency by closing the previous one. The default values are not just arbitrary values — they are part of the vendor code that was obtained through binary analysis.
https://lore.kernel.org/all/[email protected]/
Quoted 4 lines
I tend to agree with you, it feels like the default value was taken from the reference code while the field parsing was just an issue that was introduced with the h616 code. So it should not affect the defaut value, which was likely mistakenly parsed before.
Yes, that Tanix TX1 uses a wrong value because of this, but that's about the only effect, I'd say.
It seems like at this point the "default" value is just a convenience value we introduced to avoid naming the same repeated TPR6 value in every defconfig, as per my email. But it's a pure mainline U-Boot technicality at this point, and we could easily just provide an explicit value in each defconfig. I came up with this table, for the currently mainline supported boards:
board name SoC TPR6 value type Vref value
------------------------------------------------------------------
liontron-h-a133l A133 0x48000000 LPDDR4 48xxxxxxanbernic_rg35xx_h700 H616 0x40808080 LPDDR4 40xxxxxxorangepi_zero2 H616 0x3300c080 d DDR3 xxxxxx80orangepi_zero2w H616 0x48808080 LPDDR4 48xxxxxxorangepi_zero3 H616 0x44000000 LPDDR4 44xxxxxxtanix_tx1 H616 0x2fb08080 LPDDR3 xxb0xxxx
transpeed-8k618-t H616 0x3300c080 d DDR3 xxxxxx80x96_mate H616 0x3300c080 d DDR3 xxxxxx80
x96q H616 0x3300c080 d DDR3 xxxxxx80
yuzukihd-chameleon H616 0x33808080 DDR3 xxxxxx80
avaota-a1 A523 0x38000000 LPDDR4 38xxxxxxorangepi_4a A523 0x38000000 LPDDR4 38xxxxxx
radxa-cubie-a5e A523 0x38000000 LPDDR4 38xxxxxxx96q_pro_plus A523 0x3380807e DDR3 xxxxxx7e
So the default value is just used for the old H616 DDR3 boards, where only the LSB matters.
So what about dropping the default completely, since now it spans three SoCs already, and finding some reasonable default for all of them will become more complicated?
And maybe you can confirm: this should not affect compatibility with vendor parameters at all, I think they always contain an explicit TPR6 value, and "no TPR6 value provided" is not a thing?
Quoted 3 lines
Quoted 3 lines
There are several options here:
1. If our goal is to improve compatibility, then we should not change the default values for LPDDR4, and only keep the changes for LPDDR3.
Fair, I don't really care about the MSB, the new value I suggested seemed just like the most common value (see the table above). But it's pointless, since those boards provide an explicit value, and don't use the default.
Quoted 4 lines
Quoted 4 lines
2. Add the changes from option 2, and additionally introduce the default values for the A523 platform that I made during the initial binary analysis but for some reason did not get merged into mainline.
(https://github.com/iuncuim/u-boot/blob/b17c5c8911a4fce328b01e6332632a9ccd88ebc6/arch/arm/mach-sunxi/Kconfig#L102)
Sorry, but this value doesn't seem right: The LPDDR4 boards use 0x38, not 0x33, and the DDR3 board uses 0x7e, not 0x80. I don't know about other boards, but this value don't seem to help - and it's unneeded anyway, as the A523 board already provide an explicit TPR6 - and new boards could do as well.
Quoted 6 lines
It would be good to have different defaults for different platforms yes. Note that the a133 code has some fallback with defaults when the extracted field in tpr6 is zero. Maybe they should be used as default value for a133. We probably still need to keep these fallbacks in the code in case some board-specific tpr6 value does have zeroes and relies on this behavior.
Quoted 7 lines
Quoted 3 lines
3. If we accept the incompatibility between the vendor driver and the mainline driver, then this patch series is unnecessary because they introduce additional inconsistency with the vendor driver.
We definitely want to be able to take the dram parameter values straight from the BSP and put them directly into our
Kconfig. Changing the order of fields would make porting new boards very painful so it should be avoided.
Yes, I agree, we should take the DRAM parameters values verbatim. But as explained above, I think the Kconfig default is a different matter. For simplicity, I'd say we drop it and add TPR6 values into the affected defconfigs. Providing separate defaults for different SoC just makes things more complicated - for no reason.
Quoted 9 lines
Quoted 5 lines
I think option two is the most correct, but option one is also suitable, since the DRAM driver for the A523 only supports DDR3 and LPDDR4, and the default values in this case are the same as for the H616 (A523 is
0x33808080, H616 is0x33c00080).I suggest we keep the current default (without moving the lpddr3 bits) for h616 and add new defaults in
Kconfigfor a523 and a133.
Quoted 14 lines
Quoted 4 lines
Quoted 4 lines
arch/arm/mach-sunxi/Kconfig +0
-0help TPR6 value from vendor DRAM settings.arch/arm/mach-sunxi/dram_sun50i_h616.c +0
-0Quoted 8 lines
arch/arm/mach-sunxi/dram_sun50i_h616.c static bool mctl_phy_init(const struct dram_para *para, · line 978
Quoted 8 lines
arch/arm/mach-sunxi/dram_sun50i_h616.c +1
-1@@ -975,7 +975,7 @@ static bool mctl_phy_init(const struct dram_para *para, val = para->tpr6 &0xff ;break ;case SUNXI_DRAM_TYPE_LPDDR3 : - val = para->tpr6 >>8 &0xff ; + val = para->tpr6 >>16 &0xff ;This change is definitely necessary though.
Yes, absolutely.
Cheers,
Andre
Quoted 9 lines
Quoted 4 lines
arch/arm/mach-sunxi/dram_sun50i_h616.c static bool mctl_phy_init(const struct dram_para *para, · line 981
Quoted 4 lines
arch/arm/mach-sunxi/dram_sun50i_h616.c +0
-0break ;case SUNXI_DRAM_TYPE_LPDDR4 : val = para->tpr6 >>24 &0xff ;All the best,
Paul
Hi Andre,
Quoted 65 lines · Andre Przywara
On Thu, 9 Apr 2026 17:10:19 +0200
Paul Kocialkowski <[email protected]> wrote:Hi Paul, Mikhail,
thanks for the reply!
Quoted 43 lines
Hi,
Quoted 24 lines · Mikhail Kalashnikov
Quoted 23 lines · Philippe Simons
From: Jernej Skrabec <[email protected]>
Allwinner's BSP DRAM code uses parameter TPR6, presumably containing some "Vref" parameter, to encode the values for *all* four supported DRAM types. The code selects one byte based on the DRAM type used at runtime. To allow copying DRAM parameters from vendor firmware, we used this value and its encoding, but wrongly: the proper order of bytes is DDR3, DDR4, LPDDR3, LPDDR4, from LSB to MSB, cf. the A523 and A133 DRAM code.
Correct the masking for LPDDR3 to fix DRAM operation on some boards using this DRAM type.
With LPDDR3 TRP6 parsing fixed, adapt default
DRAM_SUNXI_TPR6value. Also change LPDDR4 default value to0x38used by A523 boards.Signed-off-by Jernej Skrabec <[email protected]>[adjusted commit message, update default value]Signed-off-by Philippe Simons <[email protected]>--- arch/arm/mach-sunxi/Kconfig | 2 +- arch/arm/mach-sunxi/dram_sun50i_h616.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)Quoted 15 lines
arch/arm/mach-sunxi/Kconfig config DRAM_SUNXI_TPR3 · line 146
Quoted 9 lines
arch/arm/mach-sunxi/Kconfig +1
-1@@ -144,7 +144,7 @@ config DRAM_SUNXI_TPR3 config DRAM_SUNXI_TPR6 hex "DRAM TPR6 parameter" - default 0x3300c080 + default 0x38c00080I don't think this will be a good solution. The changes in this series were originally made to improve compatibility with the vendor driver, but now you are introducing an additional inconsistency by closing the previous one. The default values are not just arbitrary values — they are part of the vendor code that was obtained through binary analysis.
https://lore.kernel.org/all/[email protected]/Quoted 4 lines
I tend to agree with you, it feels like the default value was taken from the reference code while the field parsing was just an issue that was introduced with the h616 code. So it should not affect the defaut value, which was likely mistakenly parsed before.
Yes, that Tanix TX1 uses a wrong value because of this, but that's about the only effect, I'd say.
It seems like at this point the "default" value is just a convenience value we introduced to avoid naming the same repeated TPR6 value in every defconfig, as per my email. But it's a pure mainline U-Boot technicality at this point, and we could easily just provide an explicit value in each defconfig. I came up with this table, for the currently mainline supported boards:
Quoted 16 lines
board name SoC TPR6 value type Vref value
------------------------------------------------------------------
liontron-h-a133l A1330x48000000LPDDR4 48xxxxxxanbernic_rg35xx_h700H6160x40808080LPDDR4 40xxxxxxorangepi_zero2H6160x3300c080d DDR3 xxxxxx80orangepi_zero2wH6160x48808080LPDDR4 48xxxxxxorangepi_zero3H6160x44000000LPDDR4 44xxxxxxtanix_tx1H6160x2fb08080LPDDR3 xxb0xxxx
transpeed-8k618-t H6160x3300c080d DDR3 xxxxxx80x96_mateH6160x3300c080d DDR3 xxxxxx80
x96q H6160x3300c080d DDR3 xxxxxx80
yuzukihd-chameleon H6160x33808080DDR3 xxxxxx80
avaota-a1 A5230x38000000LPDDR4 38xxxxxxorangepi_4aA5230x38000000LPDDR4 38xxxxxx
radxa-cubie-a5e A5230x38000000LPDDR4 38xxxxxxx96q_pro_plusA5230x3380807eDDR3 xxxxxx7e
A few more entries for board I could get running (not submitted yet):
board name SoC TPR6 value type Vref value
------------------------------------------------------------------
baijie-helperboard-a133 A133 0x48000000 LPDDR4 48xxxxxx
logicom-la-tab-129 A133 0x2fb88080 LPDDR3 xxb8xxxx
kickpi-k5c A133 0x33808080 DDR3 xxxxxx80
dshanpi-rosx R818 0x48000000 LPDDR4 48xxxxxx
Quoted 6 lines
So the default value is just used for the old H616 DDR3 boards, where only the LSB matters.
So what about dropping the default completely, since now it spans three SoCs already, and finding some reasonable default for all of them will become more complicated?
Yes honestly this is the only DRAM TPR value that has a non-zero default in Kconfig and it feels a bit weird. I'm in favor of explicitly defining all the board-specific parameters in the configs and using zero as Kconfig default.
Quoted 3 lines
And maybe you can confirm: this should not affect compatibility with vendor parameters at all, I think they always contain an explicit TPR6 value, and "no TPR6 value provided" is not a thing?
Yes I've always seen an explicit value defined, and since it's part of the dram_para array, there has to be something. However the A133 code has fallback values when it gets a zero from dram_para:
https://source.denx.de/u-boot/custodians/u-boot-sunxi/-/blob/master/arch/arm/mach-sunxi/dram_sun50i_a133.c?ref_type=heads#L598
This doesn't seem to be the case in the H616 and A523 code. The default is 0x80 for DDR3/DDR4/LPDDR3 and 0x33 for LPDDR4. I'm not sure this is really a thing that boards might actually rely on though. I would rather be in favor of removing it too to avoid confusion.
Quoted 14 lines
Quoted 3 lines
Quoted 3 lines
There are several options here:
1. If our goal is to improve compatibility, then we should not change the default values for LPDDR4, and only keep the changes for LPDDR3.Fair, I don't really care about the MSB, the new value I suggested seemed just like the most common value (see the table above). But it's pointless, since those boards provide an explicit value, and don't use the default.
Quoted 4 lines
Quoted 4 lines
2. Add the changes from option 2, and additionally introduce the default values for the A523 platform that I made during the initial binary analysis but for some reason did not get merged into mainline.
(https://github.com/iuncuim/u-boot/blob/b17c5c8911a4fce328b01e6332632a9ccd88ebc6/arch/arm/mach-sunxi/Kconfig#L102)
Quoted 5 lines
Sorry, but this value doesn't seem right: The LPDDR4 boards use
0x38, not0x33, and the DDR3 board uses0x7e, not0x80. I don't know about other boards, but this value don't seem to help - and it's unneeded anyway, as the A523 board already provide an explicit TPR6 - and new boards could do as well.
I think we should just drop the default value instead of trying to make sense of what that default should be for different platforms.
Quoted 14 lines
Quoted 6 lines
It would be good to have different defaults for different platforms yes. Note that the a133 code has some fallback with defaults when the extracted field in tpr6 is zero. Maybe they should be used as default value for a133. We probably still need to keep these fallbacks in the code in case some board-specific tpr6 value does have zeroes and relies on this behavior.
Quoted 7 lines
Quoted 3 lines
3. If we accept the incompatibility between the vendor driver and the mainline driver, then this patch series is unnecessary because they introduce additional inconsistency with the vendor driver.
We definitely want to be able to take the dram parameter values straight from the BSP and put them directly into our
Kconfig. Changing the order of fields would make porting new boards very painful so it should be avoided.
Quoted 5 lines
Yes, I agree, we should take the DRAM parameters values verbatim. But as explained above, I think the
Kconfigdefault is a different matter. For simplicity, I'd say we drop it and add TPR6 values into the affected defconfigs. Providing separate defaults for different SoC just makes things more complicated - for no reason.
Agreed.
All the best,
Paul
Quoted 40 lines
Quoted 9 lines
Quoted 5 lines
I think option two is the most correct, but option one is also suitable, since the DRAM driver for the A523 only supports DDR3 and LPDDR4, and the default values in this case are the same as for the H616 (A523 is
0x33808080, H616 is0x33c00080).I suggest we keep the current default (without moving the lpddr3 bits) for h616 and add new defaults in
Kconfigfor a523 and a133.Quoted 14 lines
Quoted 4 lines
Quoted 4 lines
arch/arm/mach-sunxi/Kconfig +0
-0help TPR6 value from vendor DRAM settings.arch/arm/mach-sunxi/dram_sun50i_h616.c +0
-0Quoted 8 lines
arch/arm/mach-sunxi/dram_sun50i_h616.c static bool mctl_phy_init(const struct dram_para *para, · line 978
Quoted 8 lines
arch/arm/mach-sunxi/dram_sun50i_h616.c +1
-1@@ -975,7 +975,7 @@ static bool mctl_phy_init(const struct dram_para *para, val = para->tpr6 &0xff ;break ;case SUNXI_DRAM_TYPE_LPDDR3 : - val = para->tpr6 >>8 &0xff ; + val = para->tpr6 >>16 &0xff ;This change is definitely necessary though.
Yes, absolutely.
Cheers,
AndreQuoted 9 lines
Quoted 4 lines
arch/arm/mach-sunxi/dram_sun50i_h616.c static bool mctl_phy_init(const struct dram_para *para, · line 981
Quoted 4 lines
arch/arm/mach-sunxi/dram_sun50i_h616.c +0
-0break ;case SUNXI_DRAM_TYPE_LPDDR4 : val = para->tpr6 >>24 &0xff ;All the best,
Paul
Signature · 6 lines
Paul Kocialkowski, Free software developer - https://www.paulk.fr/ Independent contractor - sys-base - https://www.sys-base.io/ Contributor to fully free software support for selected hardware.
Hi Paul,
Quoted 85 lines · Paul Kocialkowski
Hi Andre,
Quoted 65 lines · Andre Przywara
On Thu, 9 Apr 2026 17:10:19 +0200
Paul Kocialkowski <[email protected]> wrote:Hi Paul, Mikhail,
thanks for the reply!
Quoted 43 lines
Hi,
Quoted 24 lines · Mikhail Kalashnikov
Quoted 23 lines · Philippe Simons
From: Jernej Skrabec <[email protected]>
Allwinner's BSP DRAM code uses parameter TPR6, presumably containing some "Vref" parameter, to encode the values for *all* four supported DRAM types. The code selects one byte based on the DRAM type used at runtime. To allow copying DRAM parameters from vendor firmware, we used this value and its encoding, but wrongly: the proper order of bytes is DDR3, DDR4, LPDDR3, LPDDR4, from LSB to MSB, cf. the A523 and A133 DRAM code.
Correct the masking for LPDDR3 to fix DRAM operation on some boards using this DRAM type.
With LPDDR3 TRP6 parsing fixed, adapt default
DRAM_SUNXI_TPR6value. Also change LPDDR4 default value to0x38used by A523 boards.Signed-off-by Jernej Skrabec <[email protected]>[adjusted commit message, update default value]Signed-off-by Philippe Simons <[email protected]>--- arch/arm/mach-sunxi/Kconfig | 2 +- arch/arm/mach-sunxi/dram_sun50i_h616.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)Quoted 15 lines
arch/arm/mach-sunxi/Kconfig config DRAM_SUNXI_TPR3 · line 146
Quoted 9 lines
arch/arm/mach-sunxi/Kconfig +1
-1@@ -144,7 +144,7 @@ config DRAM_SUNXI_TPR3 config DRAM_SUNXI_TPR6 hex "DRAM TPR6 parameter" - default 0x3300c080 + default 0x38c00080I don't think this will be a good solution. The changes in this series were originally made to improve compatibility with the vendor driver, but now you are introducing an additional inconsistency by closing the previous one. The default values are not just arbitrary values — they are part of the vendor code that was obtained through binary analysis.
https://lore.kernel.org/all/[email protected]/Quoted 4 lines
I tend to agree with you, it feels like the default value was taken from the reference code while the field parsing was just an issue that was introduced with the h616 code. So it should not affect the defaut value, which was likely mistakenly parsed before.
Yes, that Tanix TX1 uses a wrong value because of this, but that's about the only effect, I'd say.
It seems like at this point the "default" value is just a convenience value we introduced to avoid naming the same repeated TPR6 value in every defconfig, as per my email. But it's a pure mainline U-Boot technicality at this point, and we could easily just provide an explicit value in each defconfig. I came up with this table, for the currently mainline supported boards:
Quoted 16 lines
board name SoC TPR6 value type Vref value
------------------------------------------------------------------
liontron-h-a133l A1330x48000000LPDDR4 48xxxxxxanbernic_rg35xx_h700H6160x40808080LPDDR4 40xxxxxxorangepi_zero2H6160x3300c080d DDR3 xxxxxx80orangepi_zero2wH6160x48808080LPDDR4 48xxxxxxorangepi_zero3H6160x44000000LPDDR4 44xxxxxxtanix_tx1H6160x2fb08080LPDDR3 xxb0xxxx
transpeed-8k618-t H6160x3300c080d DDR3 xxxxxx80x96_mateH6160x3300c080d DDR3 xxxxxx80
x96q H6160x3300c080d DDR3 xxxxxx80
yuzukihd-chameleon H6160x33808080DDR3 xxxxxx80
avaota-a1 A5230x38000000LPDDR4 38xxxxxxorangepi_4aA5230x38000000LPDDR4 38xxxxxx
radxa-cubie-a5e A5230x38000000LPDDR4 38xxxxxxx96q_pro_plusA5230x3380807eDDR3 xxxxxx7e
Quoted 8 lines
A few more entries for board I could get running (not submitted yet):
board name SoC TPR6 value type Vref value
------------------------------------------------------------------
baijie-helperboard-a133 A1330x48000000LPDDR4 48xxxxxx
logicom-la-tab-129 A1330x2fb88080LPDDR3 xxb8xxxx
kickpi-k5c A1330x33808080DDR3 xxxxxx80
dshanpi-rosx R8180x48000000LPDDR4 48xxxxxx
Ah, many thanks for that, good to have more examples. And looking forward to the support patches for those boards ;-)
Quoted 10 lines
Quoted 6 lines
So the default value is just used for the old H616 DDR3 boards, where only the LSB matters.
So what about dropping the default completely, since now it spans three SoCs already, and finding some reasonable default for all of them will become more complicated?
Yes honestly this is the only DRAM TPR value that has a non-zero default in
Kconfigand it feels a bit weird. I'm in favor of explicitly defining all the board-specific parameters in the configs and using zero asKconfigdefault.
Cool, I will do that!
Quoted 9 lines
Quoted 3 lines
And maybe you can confirm: this should not affect compatibility with vendor parameters at all, I think they always contain an explicit TPR6 value, and "no TPR6 value provided" is not a thing?
Yes I've always seen an explicit value defined, and since it's part of the
dram_paraarray, there has to be something. However the A133 code has fallback values when it gets a zero fromdram_para:
https://source.denx.de/u-boot/custodians/u-boot-sunxi/-/blob/master/arch/arm/mach-sunxi/dram_sun50i_a133.c?ref_type=heads#L598
Quoted 4 lines
This doesn't seem to be the case in the H616 and A523 code. The default is
0x80for DDR3/DDR4/LPDDR3 and0x33for LPDDR4. I'm not sure this is really a thing that boards might actually rely on though. I would rather be in favor of removing it too to avoid confusion.
From what I'have seen, it looks like the LPDDR4 value is always a multiple of 8, at least no board uses 0x33. But I'd say leave the A133 code in for now, it doesn't hurt either and mimics the BSP.
Quoted 14 lines
Quoted 14 lines
Quoted 3 lines
Quoted 3 lines
There are several options here:
1. If our goal is to improve compatibility, then we should not change the default values for LPDDR4, and only keep the changes for LPDDR3.Fair, I don't really care about the MSB, the new value I suggested seemed just like the most common value (see the table above). But it's pointless, since those boards provide an explicit value, and don't use the default.
Quoted 4 lines
Quoted 4 lines
2. Add the changes from option 2, and additionally introduce the default values for the A523 platform that I made during the initial binary analysis but for some reason did not get merged into mainline.
(https://github.com/iuncuim/u-boot/blob/b17c5c8911a4fce328b01e6332632a9ccd88ebc6/arch/arm/mach-sunxi/Kconfig#L102)
Quoted 8 lines
Quoted 5 lines
Sorry, but this value doesn't seem right: The LPDDR4 boards use
0x38, not0x33, and the DDR3 board uses0x7e, not0x80. I don't know about other boards, but this value don't seem to help - and it's unneeded anyway, as the A523 board already provide an explicit TPR6 - and new boards could do as well.I think we should just drop the default value instead of trying to make sense of what that default should be for different platforms.
Yes, will do that.
Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
It would be good to have different defaults for different platforms yes. Note that the a133 code has some fallback with defaults when the extracted field in tpr6 is zero. Maybe they should be used as default value for a133. We probably still need to keep these fallbacks in the code in case some board-specific tpr6 value does have zeroes and relies on this behavior.
Quoted 3 lines
3. If we accept the incompatibility between the vendor driver and the mainline driver, then this patch series is unnecessary because they introduce additional inconsistency with the vendor driver.
We definitely want to be able to take the dram parameter values straight from the BSP and put them directly into our
Kconfig. Changing the order of fields would make porting new boards very painful so it should be avoided.
Quoted 7 lines
Quoted 5 lines
Yes, I agree, we should take the DRAM parameters values verbatim. But as explained above, I think the
Kconfigdefault is a different matter. For simplicity, I'd say we drop it and add TPR6 values into the affected defconfigs. Providing separate defaults for different SoC just makes things more complicated - for no reason.Agreed.
Thanks, will send a v3 to that effect.
Cheers,
Andre
Quoted 46 lines
All the best,
Paul
Quoted 40 lines
Quoted 9 lines
Quoted 5 lines
I think option two is the most correct, but option one is also suitable, since the DRAM driver for the A523 only supports DDR3 and LPDDR4, and the default values in this case are the same as for the H616 (A523 is
0x33808080, H616 is0x33c00080).I suggest we keep the current default (without moving the lpddr3 bits) for h616 and add new defaults in
Kconfigfor a523 and a133.Quoted 14 lines
Quoted 4 lines
Quoted 4 lines
arch/arm/mach-sunxi/Kconfig +0
-0help TPR6 value from vendor DRAM settings.arch/arm/mach-sunxi/dram_sun50i_h616.c +0
-0Quoted 8 lines
arch/arm/mach-sunxi/dram_sun50i_h616.c static bool mctl_phy_init(const struct dram_para *para, · line 978
Quoted 8 lines
arch/arm/mach-sunxi/dram_sun50i_h616.c +1
-1@@ -975,7 +975,7 @@ static bool mctl_phy_init(const struct dram_para *para, val = para->tpr6 &0xff ;break ;case SUNXI_DRAM_TYPE_LPDDR3 : - val = para->tpr6 >>8 &0xff ; + val = para->tpr6 >>16 &0xff ;This change is definitely necessary though.
Yes, absolutely.
Cheers,
AndreQuoted 9 lines
Quoted 4 lines
arch/arm/mach-sunxi/dram_sun50i_h616.c static bool mctl_phy_init(const struct dram_para *para, · line 981
Quoted 4 lines
arch/arm/mach-sunxi/dram_sun50i_h616.c +0
-0break ;case SUNXI_DRAM_TYPE_LPDDR4 : val = para->tpr6 >>24 &0xff ;All the best,
Paul