arm: mvebu: a38x: Add optional support for using old DDR3 training code
Add optional support for using old DDR3 training code from 2017.
The code lives in drivers/ddr/marvell/a38x/old/. To prevent symbol
clashing with new DDR3 training code, a special header which renames all
clashing symbols via macros is included and the symbols are prefixed
with 'old_'.
If old DDR3 training support is selected for a board, then the SPL
initialization code calls a new function
board_use_old_ddr3_training()
to check whether it should use old DDR3 training code. The default
weak implementation returns false, defaulting to new DDR3 training code.
Boards that wish to support this need to select the
ARMADA_38X_SUPPORT_OLD_DDR3_TRAINING
config option and implement the old version of DDR topology provider,
ddr3_get_topology_map().
Signed-off-by: Marek BehĂșn <kabel@kernel.org>
diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index 4f4f7e0..cbef411 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -313,6 +313,33 @@
hang();
}
+#if !defined(CONFIG_ARMADA_375)
+__weak bool board_use_old_ddr3_training(void)
+{
+ return false;
+}
+
+static void ddr3_init_or_fail(void)
+{
+ int ret;
+
+ if (IS_ENABLED(CONFIG_ARMADA_38X_SUPPORT_OLD_DDR3_TRAINING) &&
+ board_use_old_ddr3_training())
+ ret = old_ddr3_init();
+ else
+ ret = ddr3_init();
+
+ if (ret) {
+ printf("ddr3 init failed: %d\n", ret);
+ if (IS_ENABLED(CONFIG_DDR_RESET_ON_TRAINING_FAILURE) &&
+ get_boot_device() != BOOT_DEVICE_UART)
+ reset_cpu();
+ else
+ hang();
+ }
+}
+#endif
+
void board_init_f(ulong dummy)
{
int ret;
@@ -347,15 +374,7 @@
serdes_phy_config();
/* Setup DDR */
- ret = ddr3_init();
- if (ret) {
- printf("ddr3_init() failed: %d\n", ret);
- if (IS_ENABLED(CONFIG_DDR_RESET_ON_TRAINING_FAILURE) &&
- get_boot_device() != BOOT_DEVICE_UART)
- reset_cpu();
- else
- hang();
- }
+ ddr3_init_or_fail();
#endif
/* Initialize Auto Voltage Scaling */