Skip to contentSkip to conversation

Turris Omnia DDR training changes

PATCH In review Marek Behún 2 participants 18 messages Jun 18, 2024 – Jul 8, 2024

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

cover Turris Omnia DDR training changes

Hi Stefan,

this is v2 of the series adds some changes to DDR3 training for Armada 38x and Turris Omnia.

I also put one unrelated patch (Fix ethernet PHY reset gpio FDT fixup) here.

It depends on stuff in Tom's next branch.

Marek

Marek Behún (16):
arm: mvebu: turris_omnia: Disable ext4 write support in defconfig
ddr: marvell: a38x: debug: return from ddr3_tip_print_log() early if
we won't print anything
ddr: marvell: a38x: debug: Remove unused variables
ddr: marvell: a38x: debug: Define DDR_VIEWER_TOOL variables only if
needed, and make them static
ddr: marvell: a38x: debug: Allow compiling with immutable debug
settings to reduce binary size
arm: mvebu: turris_omnia: Enable immutable debug settings in DDR3
training by default
arm: mvebu: turris_omnia: Fix ethernet PHY reset gpio FDT fixup
arm: mvebu: turris_omnia: Implement EEPROM layout for the 'eeprom'
command
arm: mvebu: turris_omnia: Enable the 'eeprom' command
arm: mvebu: turris_omnia: Extend EEPROM info structure
arm: mvebu: turris_omnia: Read DDR speed from EEPROM
ddr: marvell: a38x: Import old DDR training code from 2017 version of
U-Boot
ddr: marvell: a38x: old: Fix some compiler warning of the old code
ddr: marvell: a38x: old: Backport immutable debug settings
arm: mvebu: a38x: Add optional support for using old DDR3 training
code
arm: mvebu: turris_omnia: Support old DDR3 training

 arch/arm/mach-mvebu/Kconfig                   |   15 +
 arch/arm/mach-mvebu/include/mach/cpu.h        |    1 +
 arch/arm/mach-mvebu/spl.c                     |   37 +-
 board/CZ.NIC/turris_omnia/Makefile            |    2 +
 board/CZ.NIC/turris_omnia/eeprom.c            |  190 ++
 board/CZ.NIC/turris_omnia/old_ddr3_training.c |   63 +
 board/CZ.NIC/turris_omnia/turris_omnia.c      |  199 +-
 configs/turris_omnia_defconfig                |    6 +-
 drivers/ddr/marvell/a38x/Makefile             |    2 +
 drivers/ddr/marvell/a38x/ddr3_debug.c         |   30 +-
 drivers/ddr/marvell/a38x/ddr3_init.c          |    3 +-
 drivers/ddr/marvell/a38x/ddr3_init.h          |   43 +-
 drivers/ddr/marvell/a38x/old/Makefile         |   29 +
 drivers/ddr/marvell/a38x/old/ddr3_a38x.c      |  737 +++++
 drivers/ddr/marvell/a38x/old/ddr3_a38x.h      |   93 +
 .../marvell/a38x/old/ddr3_a38x_mc_static.h    |  226 ++
 .../ddr/marvell/a38x/old/ddr3_a38x_topology.h |   22 +
 .../ddr/marvell/a38x/old/ddr3_a38x_training.c |   39 +
 drivers/ddr/marvell/a38x/old/ddr3_debug.c     | 1546 ++++++++++
 .../marvell/a38x/old/ddr3_hws_hw_training.c   |  147 +
 .../marvell/a38x/old/ddr3_hws_hw_training.h   |   49 +
 .../a38x/old/ddr3_hws_hw_training_def.h       |  464 +++
 .../marvell/a38x/old/ddr3_hws_sil_training.h  |   17 +
 drivers/ddr/marvell/a38x/old/ddr3_init.c      |  769 +++++
 drivers/ddr/marvell/a38x/old/ddr3_init.h      |  405 +++
 .../ddr/marvell/a38x/old/ddr3_logging_def.h   |  101 +
 .../marvell/a38x/old/ddr3_patterns_64bit.h    |  924 ++++++
 .../ddr/marvell/a38x/old/ddr3_topology_def.h  |   76 +
 drivers/ddr/marvell/a38x/old/ddr3_training.c  | 2650 +++++++++++++++++
 .../ddr/marvell/a38x/old/ddr3_training_bist.c |  288 ++
 .../a38x/old/ddr3_training_centralization.c   |  711 +++++
 .../ddr/marvell/a38x/old/ddr3_training_db.c   |  651 ++++
 .../marvell/a38x/old/ddr3_training_hw_algo.c  |  685 +++++
 .../marvell/a38x/old/ddr3_training_hw_algo.h  |   14 +
 .../ddr/marvell/a38x/old/ddr3_training_ip.h   |  178 ++
 .../marvell/a38x/old/ddr3_training_ip_bist.h  |   54 +
 .../old/ddr3_training_ip_centralization.h     |   15 +
 .../marvell/a38x/old/ddr3_training_ip_db.h    |   34 +
 .../marvell/a38x/old/ddr3_training_ip_def.h   |  173 ++
 .../a38x/old/ddr3_training_ip_engine.c        | 1354 +++++++++
 .../a38x/old/ddr3_training_ip_engine.h        |   85 +
 .../marvell/a38x/old/ddr3_training_ip_flow.h  |  349 +++
 .../marvell/a38x/old/ddr3_training_ip_pbs.h   |   41 +
 .../a38x/old/ddr3_training_ip_prv_if.h        |  107 +
 .../a38x/old/ddr3_training_ip_static.h        |   31 +
 .../marvell/a38x/old/ddr3_training_leveling.c | 1836 ++++++++++++
 .../marvell/a38x/old/ddr3_training_leveling.h |   17 +
 .../ddr/marvell/a38x/old/ddr3_training_pbs.c  |  994 +++++++
 .../marvell/a38x/old/ddr3_training_static.c   |  537 ++++
 .../ddr/marvell/a38x/old/ddr_topology_def.h   |  121 +
 .../ddr/marvell/a38x/old/ddr_training_ip_db.h |   16 +
 .../marvell/a38x/old/glue_symbol_renames.h    |  247 ++
 drivers/ddr/marvell/a38x/old/silicon_if.h     |   17 +
 drivers/ddr/marvell/a38x/old/xor.h            |   92 +
 54 files changed, 17475 insertions(+), 57 deletions(-)
 create mode 100644 board/CZ.NIC/turris_omnia/eeprom.c
 create mode 100644 board/CZ.NIC/turris_omnia/old_ddr3_training.c
 create mode 100644 drivers/ddr/marvell/a38x/old/Makefile
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_a38x.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_a38x.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_a38x_mc_static.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_a38x_topology.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_a38x_training.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_debug.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_hws_hw_training.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_hws_hw_training.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_hws_hw_training_def.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_hws_sil_training.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_init.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_init.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_logging_def.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_patterns_64bit.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_topology_def.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_bist.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_centralization.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_db.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_hw_algo.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_hw_algo.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_bist.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_centralization.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_db.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_def.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_engine.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_engine.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_flow.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_pbs.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_prv_if.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_static.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_leveling.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_leveling.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_pbs.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_static.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr_topology_def.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr_training_ip_db.h
 create mode 100644 drivers/ddr/marvell/a38x/old/glue_symbol_renames.h
 create mode 100644 drivers/ddr/marvell/a38x/old/silicon_if.h
 create mode 100644 drivers/ddr/marvell/a38x/old/xor.h
Signature · 1 line
2.44.2
#1 lore raw

PATCH 1/16 arm: mvebu: turris_omnia: Disable ext4 write support in defconfig

Turris Omnia defconfig is nearing image size limit. Disable ext4 write support to reserve space for more important stuff.

This reduces the size of the KWB image by ~19 KiB.

If in the future U-Boot supports compressing itself and decompressing on load, we may enable this again.

---
 configs/turris_omnia_defconfig | 1 -
 1 file changed, 1 deletion(-)
configs/turris_omnia_defconfig +0 -1
index 225a76f993..d5699782d7 100644
@@ -124,4 +124,3 @@ CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_WDT=y
 CONFIG_WDT_ORION=y
-CONFIG_EXT4_WRITE=y
Signature · 1 line
2.44.2
#2 lore raw

PATCH 2/16 ddr: marvell: a38x: debug: return from ddr3_tip_print_log() early if we won't print anything

In reply to Marek Behún

Return from ddr3_tip_print_log() early if we won't print anything anyway.

This way the compiler can optimize away the VALIDATE_IF_ACTIVE() calls in the for-loop, so if the SILENT_LIB macro is defined, no code is generated for the rest of the function, which saves some space.

---
 drivers/ddr/marvell/a38x/ddr3_debug.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/ddr/marvell/a38x/ddr3_debug.c +9 -0
index 9e499cfb99..0374a84387 100644
@@ -399,6 +399,15 @@ int ddr3_tip_print_log(u32 dev_num, u32 mem_addr)
 	}
 #endif /* DDR_VIEWER_TOOL */
 
+	/* return early if we won't print anything anyway */
+	if (
+#if defined(SILENT_LIB)
+	    1 ||
+#endif
+	    debug_training < DEBUG_LEVEL_INFO) {
+		return MV_OK;
+	}
+
 	for (if_id = 0; if_id <= MAX_INTERFACE_NUM - 1; if_id++) {
 		VALIDATE_IF_ACTIVE(tm->if_act_mask, if_id);
 
Signature · 1 line
2.44.2
#3 lore raw

PATCH 3/16 ddr: marvell: a38x: debug: Remove unused variables

In reply to Marek Behún

The variables is_default_centralization, is_tune_result and is_bist_reset_bit are never used.

---
 drivers/ddr/marvell/a38x/ddr3_debug.c | 3 ---
 drivers/ddr/marvell/a38x/ddr3_init.h  | 1 -
 2 files changed, 4 deletions(-)
drivers/ddr/marvell/a38x/ddr3_debug.c +0 -3
index 0374a84387..c659ae92d8 100644
@@ -117,12 +117,9 @@ u32 ctrl_level_phase[MAX_CS_NUM * MAX_INTERFACE_NUM * MAX_BUS_NUM];
 #endif /* DDR_VIEWER_TOOL */
 
 struct hws_tip_config_func_db config_func_info[MAX_DEVICE_NUM];
-u8 is_default_centralization = 0;
-u8 is_tune_result = 0;
 u8 is_validate_window_per_if = 0;
 u8 is_validate_window_per_pup = 0;
 u8 sweep_cnt = 1;
-u32 is_bist_reset_bit = 1;
 u8 is_run_leveling_sweep_tests;
 
 static struct hws_xsb_info xsb_info[MAX_DEVICE_NUM];
drivers/ddr/marvell/a38x/ddr3_init.h +0 -1
index 6854bb49de..9288073a78 100644
@@ -116,7 +116,6 @@ extern u32 clamp_tbl[];
 extern u32 freq_mask[MAX_DEVICE_NUM][MV_DDR_FREQ_LAST];
 
 extern u32 maxt_poll_tries;
-extern u32 is_bist_reset_bit;
 
 extern u8 vref_window_size[MAX_INTERFACE_NUM][MAX_BUS_NUM];
 extern u32 effective_cs;
Signature · 1 line
2.44.2
#4 lore raw

PATCH 4/16 ddr: marvell: a38x: debug: Define DDR_VIEWER_TOOL variables only if needed, and make them static

In reply to Marek Behún

The variables is_validate_window_per_if, is_validate_window_per_pup, sweep_cnt and is_run_leveling_sweep_tests are only used if DDR_VIEWER_TOOL macro is defined, so define them only in that case.

Make them static since they are only used in ddr3_debug.c.

---
 drivers/ddr/marvell/a38x/ddr3_debug.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/ddr/marvell/a38x/ddr3_debug.c +5 -4
index c659ae92d8..d32d42c408 100644
@@ -114,13 +114,14 @@ u32 ctrl_adll[MAX_CS_NUM * MAX_INTERFACE_NUM * MAX_BUS_NUM];
 u32 ctrl_adll1[MAX_CS_NUM * MAX_INTERFACE_NUM * MAX_BUS_NUM];
 u32 ctrl_level_phase[MAX_CS_NUM * MAX_INTERFACE_NUM * MAX_BUS_NUM];
 #endif /* EXCLUDE_SWITCH_DEBUG */
+
+static u8 is_validate_window_per_if = 0;
+static u8 is_validate_window_per_pup = 0;
+static u8 sweep_cnt = 1;
+static u8 is_run_leveling_sweep_tests;
 #endif /* DDR_VIEWER_TOOL */
 
 struct hws_tip_config_func_db config_func_info[MAX_DEVICE_NUM];
-u8 is_validate_window_per_if = 0;
-u8 is_validate_window_per_pup = 0;
-u8 sweep_cnt = 1;
-u8 is_run_leveling_sweep_tests;
 
 static struct hws_xsb_info xsb_info[MAX_DEVICE_NUM];
 
Signature · 1 line
2.44.2
#5 lore raw

PATCH 5/16 ddr: marvell: a38x: debug: Allow compiling with immutable debug settings to reduce binary size

In reply to Marek Behún

Allow compiling with immutable debug settings:
- DEBUG_LEVEL is always set to DEBUG_LEVEL_ERROR
- register dumps are disabled

This can save around 10 KiB of space in the resulting binary, which is a lot in U-Boot SPL.

---
 arch/arm/mach-mvebu/Kconfig           | 10 +++++++
 drivers/ddr/marvell/a38x/ddr3_debug.c |  9 ++++--
 drivers/ddr/marvell/a38x/ddr3_init.c  |  3 +-
 drivers/ddr/marvell/a38x/ddr3_init.h  | 42 ++++++++++++++++++++++-----
 4 files changed, 53 insertions(+), 11 deletions(-)
arch/arm/mach-mvebu/Kconfig +10 -0
index f15d3cc5ed..a320793a30 100644
@@ -250,6 +250,16 @@ config DDR_LOG_LEVEL
 	  At level 3, rovides the windows margin of each DQ as a results of
 	  DQS centeralization.
 
+config DDR_IMMUTABLE_DEBUG_SETTINGS
+	bool "Immutable DDR debug level (always DEBUG_LEVEL_ERROR)"
+	depends on ARMADA_38X
+	help
+	  Makes the DDR training code debug level settings immutable.
+	  The debug level setting from board topology definition is ignored.
+	  The debug level is always set to DEBUG_LEVEL_ERROR and register
+	  dumps are disabled.
+	  This can save around 10 KiB of space in SPL binary.
+
 config DDR_RESET_ON_TRAINING_FAILURE
 	bool "Reset the board on DDR training failure instead of hanging"
 	depends on ARMADA_38X || ARMADA_XP
drivers/ddr/marvell/a38x/ddr3_debug.c +6 -3
index d32d42c408..0b65168d82 100644
@@ -7,18 +7,21 @@
 #include "mv_ddr_training_db.h"
 #include "mv_ddr_regs.h"
 
+#if !defined(CONFIG_DDR_IMMUTABLE_DEBUG_SETTINGS)
 u8 is_reg_dump = 0;
 u8 debug_pbs = DEBUG_LEVEL_ERROR;
+#endif
 
 /*
  * API to change flags outside of the lib
  */
-#if defined(SILENT_LIB)
+#if defined(SILENT_LIB) || defined(CONFIG_DDR_IMMUTABLE_DEBUG_SETTINGS)
 void ddr3_hws_set_log_level(enum ddr_lib_debug_block block, u8 level)
 {
 	/* do nothing */
 }
-#else /* SILENT_LIB */
+#else /* !SILENT_LIB && !CONFIG_DDR_IMMUTABLE_DEBUG_SETTINGS */
+
 /* Debug flags for other Training modules */
 u8 debug_training_static = DEBUG_LEVEL_ERROR;
 u8 debug_training = DEBUG_LEVEL_ERROR;
@@ -104,7 +107,7 @@ void ddr3_hws_set_log_level(enum ddr_lib_debug_block block, u8 level)
 #endif /* CONFIG_DDR4 */
 	}
 }
-#endif /* SILENT_LIB */
+#endif /* !SILENT_LIB && !CONFIG_DDR_IMMUTABLE_DEBUG_SETTINGS */
 
 #if defined(DDR_VIEWER_TOOL)
 static char *convert_freq(enum mv_ddr_freq freq);
drivers/ddr/marvell/a38x/ddr3_init.c +2 -1
index 27eb3ac173..7c5147f474 100644
@@ -41,7 +41,8 @@ int ddr3_init(void)
 	mv_ddr_pre_training_soc_config(ddr_type);
 
 	/* Set log level for training library */
-	mv_ddr_user_log_level_set(DEBUG_BLOCK_ALL);
+	if (!IS_ENABLED(CONFIG_DDR_IMMUTABLE_DEBUG_SETTINGS))
+		mv_ddr_user_log_level_set(DEBUG_BLOCK_ALL);
 
 	mv_ddr_early_init();
 
drivers/ddr/marvell/a38x/ddr3_init.h +35 -7

65 lines not on this page · raw message

Signature · 1 line
2.44.2
#6 lore raw

PATCH 6/16 arm: mvebu: turris_omnia: Enable immutable debug settings in DDR3 training by default

In reply to Marek Behún

Save 10 KiB in Turris Omnia's SPL binary by enabling immutable debug settings for DDR3 training code.

---
 configs/turris_omnia_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/turris_omnia_defconfig +1 -0
index d5699782d7..938ad88ae5 100644
@@ -10,6 +10,7 @@ CONFIG_NR_DRAM_BANKS=2
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xff0000
 CONFIG_TARGET_TURRIS_OMNIA=y
+CONFIG_DDR_IMMUTABLE_DEBUG_SETTINGS=y
 CONFIG_DDR_RESET_ON_TRAINING_FAILURE=y
 CONFIG_MVEBU_EFUSE_VHV_GPIO="mcu_56"
 CONFIG_MVEBU_EFUSE_VHV_GPIO_ACTIVE_LOW=y
Signature · 1 line
2.44.2
#7 lore raw

PATCH 7/16 arm: mvebu: turris_omnia: Fix ethernet PHY reset gpio FDT fixup

In reply to Marek Behún

For board revisions where the WAN ethernet PHY reset GPIO is controllable via MCU we currently insert a phy-reset-gpios property into the ethernet controller node. The mvneta driver parses this property and uses the GPIO to reset the PHY.

But this phy-reset-gpios property is not a valid DT binding in upstream kernel. Instead, a reset-gpios property should be inserted into the ethernet PHY node. This correct DT binding is supported by the DM ETH PHY U-Boot driver.

Insert the reset-gpios property into the WAN PHY node instead the phy-reset-gpios property in WAN ETH node so that Linux will correctly use the reset GPIO.

Enable the CONFIG_DM_ETH_PHY config option so that U-Boot will also use the correct DT property.

Note: currently there are 4 ethernet controller drivers parsing the wrong DT property: dwc_eth_qos, fex_mxc, mvneta and mvpp2. We should convert all relevant device-trees to use reset-gpios so that we can get rid of these drivers parsing this property.

Fixes 1da53ae26afc ("arm: mvebu: turris_omnia: Add support for design with SW reset signals")
---
 board/CZ.NIC/turris_omnia/turris_omnia.c | 44 ++++++++++++++----------
 configs/turris_omnia_defconfig           |  1 +
 2 files changed, 26 insertions(+), 19 deletions(-)
board/CZ.NIC/turris_omnia/turris_omnia.c +25 -19
index 4ee1a394b0..100a991406 100644
@@ -978,11 +978,21 @@ static int fixup_mcu_gpio_in_pcie_nodes(void *blob)
 	return 0;
 }
 
-static int fixup_mcu_gpio_in_eth_wan_node(void *blob)
+static int get_phy_wan_node_offset(const void *blob)
+{
+	u32 phy_wan_phandle;
+
+	phy_wan_phandle = fdt_getprop_u32_default(blob, "ethernet2", "phy-handle", 0);
+	if (!phy_wan_phandle)
+		return -FDT_ERR_NOTFOUND;
+
+	return fdt_node_offset_by_phandle(blob, phy_wan_phandle);
+}
+
+static int fixup_mcu_gpio_in_phy_wan_node(void *blob)
 {
 	unsigned int mcu_phandle;
-	int eth_wan_node;
-	int ret;
+	int phy_wan_node, ret;
 
 	ret = fdt_increase_size(blob, 64);
 	if (ret < 0) {
@@ -990,21 +1000,17 @@ static int fixup_mcu_gpio_in_eth_wan_node(void *blob)
 		return ret;
 	}
 
-	eth_wan_node = fdt_path_offset(blob, "ethernet2");
-	if (eth_wan_node < 0)
-		return eth_wan_node;
+	phy_wan_node = get_phy_wan_node_offset(blob);
+	if (phy_wan_node < 0)
+		return phy_wan_node;
 
 	mcu_phandle = fdt_create_phandle_by_compatible(blob, "cznic,turris-omnia-mcu");
 	if (!mcu_phandle)
 		return -FDT_ERR_NOPHANDLES;
 
-	/* insert: phy-reset-gpios = <&mcu 2 gpio GPIO_ACTIVE_LOW>; */
-	ret = insert_mcu_gpio_prop(blob, eth_wan_node, "phy-reset-gpios",
-				   mcu_phandle, 2, ilog2(EXT_CTL_nRES_PHY), GPIO_ACTIVE_LOW);
-	if (ret < 0)
-		return ret;
-
-	return 0;
+	/* insert: reset-gpios = <&mcu 2 gpio GPIO_ACTIVE_LOW>; */
+	return insert_mcu_gpio_prop(blob, phy_wan_node, "reset-gpios",
+				    mcu_phandle, 2, ilog2(EXT_CTL_nRES_PHY), GPIO_ACTIVE_LOW);
 }
 
 static void fixup_atsha_node(void *blob)
@@ -1033,7 +1039,7 @@ int board_fix_fdt(void *blob)
 {
 	if (omnia_mcu_has_feature(FEAT_PERIPH_MCU)) {
 		fixup_mcu_gpio_in_pcie_nodes(blob);
-		fixup_mcu_gpio_in_eth_wan_node(blob);
+		fixup_mcu_gpio_in_phy_wan_node(blob);
 	}
 
 	fixup_msata_port_nodes(blob);
@@ -1218,14 +1224,14 @@ int ft_board_setup(void *blob, struct bd_info *bd)
 	int node;
 
 	/*
-	 * U-Boot's FDT blob contains phy-reset-gpios in ethernet2
-	 * node when MCU controls all peripherals resets.
+	 * U-Boot's FDT blob contains reset-gpios in ethernet2 PHY node when MCU
+	 * controls all peripherals resets.
 	 * Fixup MCU GPIO nodes in PCIe and eth wan nodes in this case.
 	 */
-	node = fdt_path_offset(gd->fdt_blob, "ethernet2");
-	if (node >= 0 && fdt_getprop(gd->fdt_blob, node, "phy-reset-gpios", NULL)) {
+	node = get_phy_wan_node_offset(gd->fdt_blob);
+	if (node >= 0 && fdt_getprop(gd->fdt_blob, node, "reset-gpios", NULL)) {
 		fixup_mcu_gpio_in_pcie_nodes(blob);
-		fixup_mcu_gpio_in_eth_wan_node(blob);
+		fixup_mcu_gpio_in_phy_wan_node(blob);
 	}
 
 	fixup_spi_nor_partitions(blob);
configs/turris_omnia_defconfig +1 -0
index 938ad88ae5..08e3e21215 100644
@@ -101,6 +101,7 @@ CONFIG_PHY_ANEG_TIMEOUT=8000
 CONFIG_PHY_MARVELL=y
 CONFIG_PHY_FIXED=y
 CONFIG_DM_DSA=y
+CONFIG_DM_ETH_PHY=y
 CONFIG_PHY_GIGE=y
 CONFIG_MV88E6XXX=y
 CONFIG_MVNETA=y
Signature · 1 line
2.44.2
#8 lore raw

PATCH 8/16 arm: mvebu: turris_omnia: Implement EEPROM layout for the 'eeprom' command

In reply to Marek Behún

Implement Turris Omnia EEPROM layout for the 'eeprom' command.

When the 'eeprom' command (with layout support) is enabled, we can now use the 'eeprom print' and 'eeprom update' commands, for example:

=> eeprom print
Magic constant 34a04103
RAM size in GB 2
Wi-Fi Region
CRC32 checksum cecbc2a1

---
 board/CZ.NIC/turris_omnia/Makefile |   1 +
 board/CZ.NIC/turris_omnia/eeprom.c | 109 +++++++++++++++++++++++++++++
 2 files changed, 110 insertions(+)
 create mode 100644 board/CZ.NIC/turris_omnia/eeprom.c
board/CZ.NIC/turris_omnia/Makefile +1 -0
index 341378b4e5..216e11958a 100644
@@ -3,3 +3,4 @@
 # Copyright (C) 2017 Marek Behún <[email protected]>
 
 obj-y	:= turris_omnia.o ../turris_atsha_otp.o ../turris_common.o
+obj-$(CONFIG_CMD_EEPROM_LAYOUT)	+= eeprom.o
board/CZ.NIC/turris_omnia/eeprom.c new file +109 -0

109 lines not on this page · raw message

Signature · 1 line
2.44.2
#9 lore raw

PATCH 9/16 arm: mvebu: turris_omnia: Enable the 'eeprom' command

In reply to Marek Behún

Enable the 'eeprom' command with support for EEPROM layout for Turris Omnia. Enable the i2c-eeprom driver so that the EEPROM is accessed via driver model.

---
 configs/turris_omnia_defconfig | 3 +++
 1 file changed, 3 insertions(+)
configs/turris_omnia_defconfig +3 -0
index 08e3e21215..c8756a3a78 100644
@@ -55,6 +55,8 @@ CONFIG_SPL_BOARD_INIT=y
 CONFIG_SPL_ENV_SUPPORT=y
 CONFIG_SPL_I2C=y
 CONFIG_SYS_MAXARGS=32
+CONFIG_CMD_EEPROM=y
+CONFIG_CMD_EEPROM_LAYOUT=y
 CONFIG_CMD_MEMTEST=y
 CONFIG_SYS_ALT_MEMTEST=y
 CONFIG_CMD_SHA1SUM=y
@@ -90,6 +92,7 @@ CONFIG_SPL_OF_TRANSLATE=y
 CONFIG_AHCI_PCI=y
 CONFIG_AHCI_MVEBU=y
 CONFIG_DM_PCA953X=y
+CONFIG_I2C_EEPROM=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_MV=y
 CONFIG_DM_MTD=y
Signature · 1 line
2.44.2
#10 lore raw

PATCH 10/16 arm: mvebu: turris_omnia: Extend EEPROM info structure

In reply to Marek Behún

Extend the Omnia EEPROM information structure in preparation for more variables to be stored there.

---
 board/CZ.NIC/turris_omnia/eeprom.c       | 11 ++++++-
 board/CZ.NIC/turris_omnia/turris_omnia.c | 42 ++++++++++++++++++++----
 2 files changed, 46 insertions(+), 7 deletions(-)
board/CZ.NIC/turris_omnia/eeprom.c +10 -1
index a4f1dab469..ea13e95b37 100644
@@ -60,9 +60,13 @@ static struct eeprom_field omnia_layout[] = {
 	_DEF_FIELD("RAM size in GB", 4, ramsz),
 	_DEF_FIELD("Wi-Fi Region", 4, region),
 	_DEF_FIELD("CRC32 checksum", 4, bin),
+	_DEF_FIELD("Extended reserved fields", 44, reserved),
+	_DEF_FIELD("Extended CRC32 checksum", 4, bin),
 };
 
 static struct eeprom_field *crc_field = &omnia_layout[3];
+static struct eeprom_field *ext_crc_field =
+	&omnia_layout[ARRAY_SIZE(omnia_layout) - 1];
 
 static int omnia_update_field(struct eeprom_layout *layout, char *field_name,
 			      char *new_data)
@@ -91,6 +95,11 @@ static int omnia_update_field(struct eeprom_layout *layout, char *field_name,
 		put_unaligned_le32(crc, crc_field->buf);
 	}
 
+	if (field < ext_crc_field) {
+		u32 crc = crc32(0, layout->data, 44);
+		put_unaligned_le32(crc, ext_crc_field->buf);
+	}
+
 	return 0;
 }
 
@@ -99,7 +108,7 @@ void eeprom_layout_assign(struct eeprom_layout *layout, int)
 	layout->fields = omnia_layout;
 	layout->num_of_fields = ARRAY_SIZE(omnia_layout);
 	layout->update = omnia_update_field;
-	layout->data_size = 16;
+	layout->data_size = 64;
 }
 
 int eeprom_layout_detect(unsigned char *)
board/CZ.NIC/turris_omnia/turris_omnia.c +36 -6

60 lines not on this page · raw message

Signature · 1 line
2.44.2
#11 lore raw

PATCH 11/16 arm: mvebu: turris_omnia: Read DDR speed from EEPROM

In reply to Marek Behún

Some Turris Omnia boards experience memory issues, and by experimentation we found that some of these issues can be solved by slowing DDR speed.

Add a new field in the extended EEPROM information structure, ddr_speed. Support several values in this field (for now 1066F, 1333H, and the default, 1600K) and use it to overwrite the DDR topology parameters used by the DDR training algorithm.

---
 board/CZ.NIC/turris_omnia/eeprom.c       | 41 +++++++++-
 board/CZ.NIC/turris_omnia/turris_omnia.c | 99 +++++++++++++++++++++++-
 2 files changed, 135 insertions(+), 5 deletions(-)
board/CZ.NIC/turris_omnia/eeprom.c +39 -2
index ea13e95b37..32572481ce 100644
@@ -55,12 +55,49 @@ static int eeprom_field_update_region(struct eeprom_field *field, char *value)
 	return 0;
 }
 
+static void eeprom_field_print_ddr_speed(const struct eeprom_field *field)
+{
+	printf(PRINT_FIELD_SEGMENT, field->name);
+
+	if (field->buf[0] == '\0' || field->buf[0] == 0xff)
+		puts("(empty, defaults to 1600K)\n");
+	else
+		printf("%.5s\n", field->buf);
+}
+
+bool omnia_valid_ddr_speed(const char *name);
+void omnia_print_ddr_speeds(void);
+
+static int eeprom_field_update_ddr_speed(struct eeprom_field *field,
+					 char *value)
+{
+	if (value[0] == '\0') {
+		/* setting default value */
+		memset(field->buf, 0xff, field->size);
+
+		return 0;
+	}
+
+	if (!omnia_valid_ddr_speed(value)) {
+		printf("%s: invalid setting, supported values are:\n  ",
+		       field->name);
+		omnia_print_ddr_speeds();
+
+		return -1;
+	}
+
+	strncpy(field->buf, value, field->size);
+
+	return 0;
+}
+
 static struct eeprom_field omnia_layout[] = {
 	_DEF_FIELD("Magic constant", 4, bin),
 	_DEF_FIELD("RAM size in GB", 4, ramsz),
 	_DEF_FIELD("Wi-Fi Region", 4, region),
 	_DEF_FIELD("CRC32 checksum", 4, bin),
-	_DEF_FIELD("Extended reserved fields", 44, reserved),
+	_DEF_FIELD("DDR speed", 5, ddr_speed),
+	_DEF_FIELD("Extended reserved fields", 39, reserved),
 	_DEF_FIELD("Extended CRC32 checksum", 4, bin),
 };
 
@@ -96,7 +133,7 @@ static int omnia_update_field(struct eeprom_layout *layout, char *field_name,
 	}
 
 	if (field < ext_crc_field) {
-		u32 crc = crc32(0, layout->data, 44);
+		u32 crc = crc32(0, layout->data, 60);
 		put_unaligned_le32(crc, ext_crc_field->buf);
 	}
 
board/CZ.NIC/turris_omnia/turris_omnia.c +96 -3

121 lines not on this page · raw message

Signature · 1 line
2.44.2
#12 lore raw

PATCH 12/16 ddr: marvell: a38x: Import old DDR training code from 2017 version of U-Boot

In reply to Marek Behún

Import DDR training code from commit 1b69ce2fc0ec ("arm: mvebu:
ddr3_debug: remove self assignments") into drivers/ddr/marvell/a38x/old/. The code is not used yet.

Explanation:

Since 2019, on some Turris Omnia boards we have been having problems with newer versions of Marvell's DDR3 training code for Armada 38x, which is ported from mv-ddr-marvell [1] to U-Boot into the drivers/ddr/marvell/a38x/ directory:
- sometimes the DDR3 training fails on some older boards, sometime it fails on some newer boards
- other times it succeeds, but some boards experience crashes of the operating system after running for some time.

Using the stock version of Turris Omnia's U-Boot from solved these issues, but this solution was not satisfactory, since we wanted features from new U-Boot.

Back in 2020-2022 we have spent several months trying to debug the issues, working with Marvell, on our own, and also with U-Boot community, but these issues persist still.

One solution we used back in 2019 was a "hybrid U-Boot": the SPL part (containing the DDR3 training code) was taken from the stock version, while the proper part was current U-Boot at the time. This solution also has its drawbacks, of which the main one is the need to glue binaries from two separate builds.

Since then there have been some more changes to the DDR3 training code in upstream mv-ddr-marvell that have been ported to U-Boot. We have provided our users experimental builds of U-Boot in the TurrisOS so that they could try upgrading the firmware and let us know if those problems still exist. And they do.

We do not have the time nor manpower to debug this problem and fix it properly. Marvell was also no able to provide a solution to this, probably because they do not have the manpower as well.

I have therefore come up with this "not that pretty" solution: take the DDR3 training code from an older version of U-Boot that is known to work, put it into current U-Boot under old/ subdirectory within drivers/ddr/marvell/a38x/, build into the SPL binary both the old and new versions and make it possible to select the old version via an env variable.

[1] https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell

---
 drivers/ddr/marvell/a38x/old/Makefile         |   18 +
 drivers/ddr/marvell/a38x/old/ddr3_a38x.c      |  736 +++++
 drivers/ddr/marvell/a38x/old/ddr3_a38x.h      |   93 +
 .../marvell/a38x/old/ddr3_a38x_mc_static.h    |  226 ++
 .../ddr/marvell/a38x/old/ddr3_a38x_topology.h |   22 +
 .../ddr/marvell/a38x/old/ddr3_a38x_training.c |   39 +
 drivers/ddr/marvell/a38x/old/ddr3_debug.c     | 1526 ++++++++++
 .../marvell/a38x/old/ddr3_hws_hw_training.c   |  147 +
 .../marvell/a38x/old/ddr3_hws_hw_training.h   |   49 +
 .../a38x/old/ddr3_hws_hw_training_def.h       |  464 +++
 .../marvell/a38x/old/ddr3_hws_sil_training.h  |   17 +
 drivers/ddr/marvell/a38x/old/ddr3_init.c      |  768 +++++
 drivers/ddr/marvell/a38x/old/ddr3_init.h      |  393 +++
 .../ddr/marvell/a38x/old/ddr3_logging_def.h   |  101 +
 .../marvell/a38x/old/ddr3_patterns_64bit.h    |  924 ++++++
 .../ddr/marvell/a38x/old/ddr3_topology_def.h  |   76 +
 drivers/ddr/marvell/a38x/old/ddr3_training.c  | 2649 +++++++++++++++++
 .../ddr/marvell/a38x/old/ddr3_training_bist.c |  288 ++
 .../a38x/old/ddr3_training_centralization.c   |  711 +++++
 .../ddr/marvell/a38x/old/ddr3_training_db.c   |  651 ++++
 .../marvell/a38x/old/ddr3_training_hw_algo.c  |  685 +++++
 .../marvell/a38x/old/ddr3_training_hw_algo.h  |   14 +
 .../ddr/marvell/a38x/old/ddr3_training_ip.h   |  178 ++
 .../marvell/a38x/old/ddr3_training_ip_bist.h  |   54 +
 .../old/ddr3_training_ip_centralization.h     |   15 +
 .../marvell/a38x/old/ddr3_training_ip_db.h    |   34 +
 .../marvell/a38x/old/ddr3_training_ip_def.h   |  173 ++
 .../a38x/old/ddr3_training_ip_engine.c        | 1353 +++++++++
 .../a38x/old/ddr3_training_ip_engine.h        |   85 +
 .../marvell/a38x/old/ddr3_training_ip_flow.h  |  349 +++
 .../marvell/a38x/old/ddr3_training_ip_pbs.h   |   41 +
 .../a38x/old/ddr3_training_ip_prv_if.h        |  107 +
 .../a38x/old/ddr3_training_ip_static.h        |   31 +
 .../marvell/a38x/old/ddr3_training_leveling.c | 1835 ++++++++++++
 .../marvell/a38x/old/ddr3_training_leveling.h |   17 +
 .../ddr/marvell/a38x/old/ddr3_training_pbs.c  |  994 +++++++
 .../marvell/a38x/old/ddr3_training_static.c   |  537 ++++
 .../ddr/marvell/a38x/old/ddr_topology_def.h   |  121 +
 .../ddr/marvell/a38x/old/ddr_training_ip_db.h |   16 +
 drivers/ddr/marvell/a38x/old/silicon_if.h     |   17 +
 drivers/ddr/marvell/a38x/old/xor.h            |   92 +
 41 files changed, 16646 insertions(+)
 create mode 100644 drivers/ddr/marvell/a38x/old/Makefile
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_a38x.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_a38x.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_a38x_mc_static.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_a38x_topology.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_a38x_training.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_debug.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_hws_hw_training.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_hws_hw_training.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_hws_hw_training_def.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_hws_sil_training.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_init.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_init.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_logging_def.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_patterns_64bit.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_topology_def.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_bist.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_centralization.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_db.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_hw_algo.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_hw_algo.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_bist.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_centralization.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_db.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_def.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_engine.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_engine.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_flow.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_pbs.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_prv_if.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_static.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_leveling.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_leveling.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_pbs.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_static.c
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr_topology_def.h
 create mode 100644 drivers/ddr/marvell/a38x/old/ddr_training_ip_db.h
 create mode 100644 drivers/ddr/marvell/a38x/old/silicon_if.h
 create mode 100644 drivers/ddr/marvell/a38x/old/xor.h
drivers/ddr/marvell/a38x/old/Makefile new file +18 -0
new file mode 100644
index 0000000000..e7b723bb24
@@ -0,0 +1,18 @@
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-$(CONFIG_SPL_BUILD) += ddr3_a38x.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_a38x_training.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_debug.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_hws_hw_training.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_init.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_training.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_training_bist.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_training_centralization.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_training_db.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_training_hw_algo.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_training_ip_engine.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_training_leveling.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_training_pbs.o
+obj-$(CONFIG_SPL_BUILD) += ddr3_training_static.o
drivers/ddr/marvell/a38x/old/ddr3_a38x.c new file +736 -0

736 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_a38x.h new file +93 -0

93 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_a38x_mc_static.h new file +226 -0

226 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_a38x_topology.h new file +22 -0
new file mode 100644
index 0000000000..f27bbff733
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#ifndef _DDR3_A38X_TOPOLOGY_H
+#define _DDR3_A38X_TOPOLOGY_H
+
+#include "ddr_topology_def.h"
+
+/* Bus mask variants */
+#define BUS_MASK_32BIT			0xf
+#define BUS_MASK_32BIT_ECC		0x1f
+#define BUS_MASK_16BIT			0x3
+#define BUS_MASK_16BIT_ECC		0x13
+#define BUS_MASK_16BIT_ECC_PUP3		0xb
+
+#define DYNAMIC_CS_SIZE_CONFIG
+#define DISABLE_L2_FILTERING_DURING_DDR_TRAINING
+
+#endif /* _DDR3_A38X_TOPOLOGY_H */
drivers/ddr/marvell/a38x/old/ddr3_a38x_training.c new file +39 -0
new file mode 100644
index 0000000000..edb2e706bb
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#include <i2c.h>
+#include <spl.h>
+#include <asm/io.h>
+#include <asm/arch/cpu.h>
+#include <asm/arch/soc.h>
+
+#include "ddr3_init.h"
+
+/*
+ * Name:     ddr3_tip_init_silicon
+ * Desc:     initiate silicon parameters
+ * Args:
+ * Notes:
+ * Returns:  required value
+ */
+int ddr3_silicon_init(void)
+{
+	int status;
+	static int init_done;
+
+	if (init_done == 1)
+		return MV_OK;
+
+	status = ddr3_tip_init_a38x(0, 0);
+	if (MV_OK != status) {
+		printf("DDR3 A38x silicon init - FAILED 0x%x\n", status);
+		return status;
+	}
+
+	init_done = 1;
+
+	return MV_OK;
+}
drivers/ddr/marvell/a38x/old/ddr3_debug.c new file +1526 -0

1,526 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_hws_hw_training.c new file +147 -0

147 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_hws_hw_training.h new file +49 -0

49 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_hws_hw_training_def.h new file +464 -0

144 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_hws_sil_training.h new file +17 -0
new file mode 100644
index 0000000000..544237a276

Lines of this file are not shown. View the raw message.

drivers/ddr/marvell/a38x/old/ddr3_init.c new file +768 -0

768 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_init.h new file +393 -0

393 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_logging_def.h new file +101 -0

101 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_patterns_64bit.h new file +924 -0

924 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_topology_def.h new file +76 -0

76 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_training.c new file +2649 -0

2,649 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_training_bist.c new file +288 -0

288 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_training_centralization.c new file +711 -0

711 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_training_db.c new file +651 -0

651 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_training_hw_algo.c new file +685 -0

685 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_training_hw_algo.h new file +14 -0
new file mode 100644
index 0000000000..6e1bab260d

Lines of this file are not shown. View the raw message.

drivers/ddr/marvell/a38x/old/ddr3_training_ip.h new file +178 -0

178 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_training_ip_bist.h new file +54 -0

54 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_training_ip_centralization.h new file +15 -0
new file mode 100644
index 0000000000..7c57603947

Lines of this file are not shown. View the raw message.

drivers/ddr/marvell/a38x/old/ddr3_training_ip_db.h new file +34 -0
new file mode 100644
index 0000000000..c0afa7742e

Lines of this file are not shown. View the raw message.

drivers/ddr/marvell/a38x/old/ddr3_training_ip_def.h new file +173 -0

173 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_training_ip_engine.c new file +1353 -0

1,353 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_training_ip_engine.h new file +85 -0

85 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_training_ip_flow.h new file +349 -0

349 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_training_ip_pbs.h new file +41 -0

41 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_training_ip_prv_if.h new file +107 -0

107 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_training_ip_static.h new file +31 -0
new file mode 100644
index 0000000000..878068b24d

Lines of this file are not shown. View the raw message.

drivers/ddr/marvell/a38x/old/ddr3_training_leveling.c new file +1835 -0

1,835 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_training_leveling.h new file +17 -0
new file mode 100644
index 0000000000..f2b4177082

Lines of this file are not shown. View the raw message.

drivers/ddr/marvell/a38x/old/ddr3_training_pbs.c new file +994 -0

994 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr3_training_static.c new file +537 -0

537 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr_topology_def.h new file +121 -0

121 lines not on this page · raw message

drivers/ddr/marvell/a38x/old/ddr_training_ip_db.h new file +16 -0
new file mode 100644
index 0000000000..ff5f817383

Lines of this file are not shown. View the raw message.

drivers/ddr/marvell/a38x/old/silicon_if.h new file +17 -0
new file mode 100644
index 0000000000..7fce27da12

Lines of this file are not shown. View the raw message.

drivers/ddr/marvell/a38x/old/xor.h new file +92 -0

92 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.44.2

Part of the diff is not shown here. View the raw message.

#13 lore raw

PATCH 13/16 ddr: marvell: a38x: old: Fix some compiler warning of the old code

In reply to Marek Behún

Fix some compilation warning in the old DDR training code.

---
 drivers/ddr/marvell/a38x/old/ddr3_a38x.c               | 1 +
 drivers/ddr/marvell/a38x/old/ddr3_init.h               | 2 ++
 drivers/ddr/marvell/a38x/old/ddr3_training.c           | 1 +
 drivers/ddr/marvell/a38x/old/ddr3_training_ip_engine.c | 1 +
 drivers/ddr/marvell/a38x/old/ddr3_training_leveling.c  | 1 +
 5 files changed, 6 insertions(+)
drivers/ddr/marvell/a38x/old/ddr3_a38x.c +1 -0
index cc2e498d50..8504b9b40c 100644
@@ -9,6 +9,7 @@
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/soc.h>
+#include <linux/delay.h>
 
 #include "ddr3_init.h"
 
drivers/ddr/marvell/a38x/old/ddr3_init.h +2 -0
index 8cb08864c2..ad95cc9ef8 100644
@@ -291,7 +291,9 @@ extern struct cl_val_per_freq cas_latency_table[];
 extern u32 target_freq;
 extern struct hws_tip_config_func_db config_func_info[HWS_MAX_DEVICE_NUM];
 extern u32 clamp_tbl[];
+#if 0
 extern u32 init_freq;
+#endif
 /* list of allowed frequency listed in order of enum hws_ddr_freq */
 extern u32 freq_val[];
 extern u8 debug_training_static;
drivers/ddr/marvell/a38x/old/ddr3_training.c +1 -0
index c5ebd7c16d..29b31a059a 100644
@@ -8,6 +8,7 @@
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/soc.h>
+#include <linux/delay.h>
 
 #include "ddr3_init.h"
 
drivers/ddr/marvell/a38x/old/ddr3_training_ip_engine.c +1 -0
index 7ac23aedc6..869f397b7f 100644
@@ -8,6 +8,7 @@
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/soc.h>
+#include <linux/delay.h>
 
 #include "ddr3_init.h"
 
drivers/ddr/marvell/a38x/old/ddr3_training_leveling.c +1 -0
index 8073c2baaf..d41845a4f4 100644
@@ -8,6 +8,7 @@
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
 #include <asm/arch/soc.h>
+#include <linux/delay.h>
 
 #include "ddr3_init.h"
 
Signature · 1 line
2.44.2
#14 lore raw

PATCH 14/16 ddr: marvell: a38x: old: Backport immutable debug settings

In reply to Marek Behún

Backport the option to compile with immutable debug settings also to the old implementation of the DDR3 training code.

The original PR for mv-ddr-marvell can be seen at
https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell/pull/45/

---
 drivers/ddr/marvell/a38x/old/ddr3_debug.c | 34 +++++++++++++++----
 drivers/ddr/marvell/a38x/old/ddr3_init.c  |  3 +-
 drivers/ddr/marvell/a38x/old/ddr3_init.h  | 40 ++++++++++++++---------
 3 files changed, 54 insertions(+), 23 deletions(-)
drivers/ddr/marvell/a38x/old/ddr3_debug.c +27 -7
index d8bd328dfd..d559a84a68 100644
@@ -12,13 +12,15 @@
 
 #include "ddr3_init.h"
 
+#if !defined(CONFIG_DDR_IMMUTABLE_DEBUG_SETTINGS)
 u8 is_reg_dump = 0;
 u8 debug_pbs = DEBUG_LEVEL_ERROR;
+#endif
 
 /*
  * API to change flags outside of the lib
  */
-#ifndef SILENT_LIB
+#if !defined(SILENT_LIB) && !defined(CONFIG_DDR_IMMUTABLE_DEBUG_SETTINGS)
 /* Debug flags for other Training modules */
 u8 debug_training_static = DEBUG_LEVEL_ERROR;
 u8 debug_training = DEBUG_LEVEL_ERROR;
@@ -83,12 +85,13 @@ void ddr3_hws_set_log_level(enum ddr_lib_debug_block block, u8 level)
 #endif
 
 struct hws_tip_config_func_db config_func_info[HWS_MAX_DEVICE_NUM];
-u8 is_default_centralization = 0;
-u8 is_tune_result = 0;
-u8 is_validate_window_per_if = 0;
-u8 is_validate_window_per_pup = 0;
-u8 sweep_cnt = 1;
-u32 is_bist_reset_bit = 1;
+
+#if 0
+static u8 is_validate_window_per_if = 0;
+static u8 is_validate_window_per_pup = 0;
+static u8 sweep_cnt = 1;
+#endif
+
 static struct hws_xsb_info xsb_info[HWS_MAX_DEVICE_NUM];
 
 /*
@@ -291,6 +294,7 @@ int print_device_info(u8 dev_num)
 	return MV_OK;
 }
 
+#if 0
 void hws_ddr3_tip_sweep_test(int enable)
 {
 	if (enable) {
@@ -303,6 +307,7 @@ void hws_ddr3_tip_sweep_test(int enable)
 	}
 }
 #endif
+#endif
 
 char *ddr3_tip_convert_tune_result(enum hws_result tune_result)
 {
@@ -326,6 +331,7 @@ int ddr3_tip_print_log(u32 dev_num, u32 mem_addr)
 	u32 if_id = 0;
 	struct hws_topology_map *tm = ddr3_get_topology_map();
 
+#if 0
 #ifndef EXCLUDE_SWITCH_DEBUG
 	if ((is_validate_window_per_if != 0) ||
 	    (is_validate_window_per_pup != 0)) {
@@ -346,8 +352,18 @@ int ddr3_tip_print_log(u32 dev_num, u32 mem_addr)
 		CHECK_STATUS(ddr3_tip_restore_dunit_regs(dev_num));
 		ddr3_tip_reg_dump(dev_num);
 	}
+#endif
 #endif
 
+	/* return early if we won't print anything anyway */
+	if (
+#if defined(SILENT_LIB)
+	    1 ||
+#endif
+	    debug_training < DEBUG_LEVEL_INFO) {
+		return MV_OK;
+	}
+
 	for (if_id = 0; if_id <= MAX_INTERFACE_NUM - 1; if_id++) {
 		VALIDATE_ACTIVE(tm->if_act_mask, if_id);
 
@@ -756,7 +772,9 @@ u32 xsb_test_table[][8] = {
 	 0xffffffff, 0xffffffff}
 };
 
+#if 0
 static int ddr3_tip_access_atr(u32 dev_num, u32 flag_id, u32 value, u32 **ptr);
+#endif
 
 int ddr3_tip_print_adll(void)
 {
@@ -788,6 +806,7 @@ int ddr3_tip_print_adll(void)
 	return MV_OK;
 }
 
+#if 0
 /*
  * Set attribute value
  */
@@ -1155,6 +1174,7 @@ static int ddr3_tip_access_atr(u32 dev_num, u32 flag_id, u32 value, u32 **ptr)
 
 	return MV_OK;
 }
+#endif
 
 #ifndef EXCLUDE_SWITCH_DEBUG
 /*
drivers/ddr/marvell/a38x/old/ddr3_init.c +2 -1
index 9818c3d494..b3c04eb3ab 100644
@@ -385,7 +385,8 @@ int ddr3_init(void)
 		return status;
 
 	/* Set log level for training lib */
-	ddr3_hws_set_log_level(DEBUG_BLOCK_ALL, DEBUG_LEVEL_ERROR);
+	if (!IS_ENABLED(CONFIG_DDR_IMMUTABLE_DEBUG_SETTINGS))
+		ddr3_hws_set_log_level(DEBUG_BLOCK_ALL, DEBUG_LEVEL_ERROR);
 
 	/* Start New Training IP */
 	status = ddr3_hws_hw_training();
drivers/ddr/marvell/a38x/old/ddr3_init.h +25 -15
index ad95cc9ef8..5090cf97a7 100644
@@ -152,17 +152,38 @@ enum log_level  {
 };
 
 /* Globals */
-extern u8 debug_training;
+#if defined(CONFIG_DDR_IMMUTABLE_DEBUG_SETTINGS)
+static const u8 is_reg_dump = 0;
+static const u8 debug_training_static = DEBUG_LEVEL_ERROR;
+static const u8 debug_training = DEBUG_LEVEL_ERROR;
+static const u8 debug_leveling = DEBUG_LEVEL_ERROR;
+static const u8 debug_centralization = DEBUG_LEVEL_ERROR;
+static const u8 debug_training_ip = DEBUG_LEVEL_ERROR;
+static const u8 debug_training_bist = DEBUG_LEVEL_ERROR;
+static const u8 debug_training_hw_alg = DEBUG_LEVEL_ERROR;
+static const u8 debug_training_access = DEBUG_LEVEL_ERROR;
+static const u8 debug_training_a38x = DEBUG_LEVEL_ERROR;
+static const u8 debug_pbs = DEBUG_LEVEL_ERROR;
+#else /* !CONFIG_DDR_IMMUTABLE_DEBUG_SETTINGS */
 extern u8 is_reg_dump;
+extern u8 debug_training_static;
+extern u8 debug_training;
+extern u8 debug_leveling;
+extern u8 debug_centralization;
+extern u8 debug_training_ip;
+extern u8 debug_training_bist;
+extern u8 debug_training_hw_alg;
+extern u8 debug_training_access;
+extern u8 debug_training_a38x;
+extern u8 debug_pbs;
+#endif /* !CONFIG_DDR_IMMUTABLE_DEBUG_SETTINGS */
+
 extern u8 generic_init_controller;
 extern u32 freq_val[];
 extern u32 is_pll_old;
 extern struct cl_val_per_freq cas_latency_table[];
 extern struct pattern_info pattern_table[];
 extern struct cl_val_per_freq cas_write_latency_table[];
-extern u8 debug_training;
-extern u8 debug_centralization, debug_training_ip, debug_training_bist,
-	debug_pbs, debug_training_static, debug_leveling;
 extern u32 pipe_multicast_mask;
 extern struct hws_tip_config_func_db config_func_info[];
 extern u8 cs_mask_reg[];
@@ -186,8 +207,6 @@ extern u32 g_dic;
 extern u32 g_odt_config;
 extern u32 g_rtt_nom;
 
-extern u8 debug_training_access;
-extern u8 debug_training_a38x;
 extern u32 first_active_if;
 extern enum hws_ddr_freq init_freq;
 extern u32 delay_enable, ck_delay, ck_delay_16, ca_delay;
@@ -227,7 +246,6 @@ extern u32 znri_data_phy_val;
 extern u32 zpri_data_phy_val;
 extern u32 znri_ctrl_phy_val;
 extern u32 zpri_ctrl_phy_val;
-extern u8 debug_training_access;
 extern u32 finger_test, p_finger_start, p_finger_end, n_finger_start,
 	n_finger_end, p_finger_step, n_finger_step;
 extern u32 mode2_t;
@@ -243,8 +261,6 @@ extern u32 freq_mask[HWS_MAX_DEVICE_NUM][DDR_FREQ_LIMIT];
 extern u32 start_pattern, end_pattern;
 
 extern u32 maxt_poll_tries;
-extern u32 is_bist_reset_bit;
-extern u8 debug_training_bist;
 
 extern u8 vref_window_size[MAX_INTERFACE_NUM][MAX_BUS_NUM];
 extern u32 debug_mode;
@@ -252,20 +268,16 @@ extern u32 effective_cs;
 extern int ddr3_tip_centr_skip_min_win_check;
 extern u32 *dq_map_table;
 extern enum auto_tune_stage training_stage;
-extern u8 debug_centralization;
 
 extern u32 delay_enable;
 extern u32 start_pattern, end_pattern;
 extern u32 freq_val[DDR_FREQ_LIMIT];
-extern u8 debug_training_hw_alg;
 extern enum auto_tune_stage training_stage;
 
-extern u8 debug_training_ip;
 extern enum hws_result training_result[MAX_STAGE_LIMIT][MAX_INTERFACE_NUM];
 extern enum auto_tune_stage training_stage;
 extern u32 effective_cs;
 
-extern u8 debug_leveling;
 extern enum hws_result training_result[MAX_STAGE_LIMIT][MAX_INTERFACE_NUM];
 extern enum auto_tune_stage training_stage;
 extern u32 rl_version;
@@ -276,7 +288,6 @@ extern u32 odt_config;
 extern u32 effective_cs;
 extern u32 phy_reg1_val;
 
-extern u8 debug_pbs;
 extern u32 effective_cs;
 extern u16 mask_results_dq_reg_map[];
 extern enum hws_ddr_freq medium_freq;
@@ -296,7 +307,6 @@ extern u32 init_freq;
 #endif
 /* list of allowed frequency listed in order of enum hws_ddr_freq */
 extern u32 freq_val[];
-extern u8 debug_training_static;
 extern u32 first_active_if;
 
 /* Prototypes */
Signature · 1 line
2.44.2
#15 lore raw

PATCH 15/16 arm: mvebu: a38x: Add optional support for using old DDR3 training code

In reply to Marek Behún

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().

---
 arch/arm/mach-mvebu/Kconfig                   |   4 +
 arch/arm/mach-mvebu/include/mach/cpu.h        |   1 +
 arch/arm/mach-mvebu/spl.c                     |  37 ++-
 drivers/ddr/marvell/a38x/Makefile             |   2 +
 drivers/ddr/marvell/a38x/old/Makefile         |  11 +
 .../marvell/a38x/old/glue_symbol_renames.h    | 247 ++++++++++++++++++
 6 files changed, 293 insertions(+), 9 deletions(-)
 create mode 100644 drivers/ddr/marvell/a38x/old/glue_symbol_renames.h
arch/arm/mach-mvebu/Kconfig +4 -0
index a320793a30..e377e8a48a 100644
@@ -37,6 +37,10 @@ config ARMADA_38X_HS_IMPEDANCE_THRESH
 	default 0x6
 	range 0x0 0x7
 
+config ARMADA_38X_SUPPORT_OLD_DDR3_TRAINING
+	bool
+	depends on ARMADA_38X
+
 config ARMADA_XP
 	bool
 	select ARMADA_32BIT
arch/arm/mach-mvebu/include/mach/cpu.h +1 -0
index 904e7157ba..af6ce2920e 100644
@@ -174,6 +174,7 @@ int serdes_phy_config(void);
  * drivers/ddr/marvell
  */
 int ddr3_init(void);
+int old_ddr3_init(void);
 
 /* Auto Voltage Scaling */
 #if defined(CONFIG_ARMADA_38X)
arch/arm/mach-mvebu/spl.c +28 -9
index 4f4f7e00e3..cbef411376 100644
@@ -313,6 +313,33 @@ int board_return_to_bootrom(struct spl_image_info *spl_image,
 	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 @@ void board_init_f(ulong dummy)
 	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 */
drivers/ddr/marvell/a38x/Makefile +2 -0
index fcfb615686..4e8a9d190d 100644
@@ -18,6 +18,8 @@ obj-$(CONFIG_SPL_BUILD) += mv_ddr_spd.o
 obj-$(CONFIG_SPL_BUILD) += mv_ddr_topology.o
 obj-$(CONFIG_SPL_BUILD) += xor.o
 
+obj-$(CONFIG_ARMADA_38X_SUPPORT_OLD_DDR3_TRAINING) += old/
+
 ifdef CONFIG_DDR4
 	obj-$(CONFIG_SPL_BUILD) += mv_ddr4_mpr_pda_if.o
 	obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training.o
drivers/ddr/marvell/a38x/old/Makefile +11 -0
index e7b723bb24..1645a79b40 100644
@@ -16,3 +16,14 @@ obj-$(CONFIG_SPL_BUILD) += ddr3_training_ip_engine.o
 obj-$(CONFIG_SPL_BUILD) += ddr3_training_leveling.o
 obj-$(CONFIG_SPL_BUILD) += ddr3_training_pbs.o
 obj-$(CONFIG_SPL_BUILD) += ddr3_training_static.o
+
+define IncludeSymbolRename
+  CFLAGS_$(1) = -include $(srctree)/drivers/ddr/marvell/a38x/old/glue_symbol_renames.h
+endef
+
+$(foreach obj,$(obj-y),$(eval $(call IncludeSymbolRename,$(obj))))
+
+# The old version of DDR training fails weirdly on some boards if the whole
+# driver is compiled with LTO. It seems to work if at least ddr3_init.c is
+# compiled without LTO.
+CFLAGS_REMOVE_ddr3_init.o := $(LTO_CFLAGS)
drivers/ddr/marvell/a38x/old/glue_symbol_renames.h new file +247 -0

247 lines not on this page · raw message

Signature · 1 line
2.44.2
#16 lore raw

PATCH 16/16 arm: mvebu: turris_omnia: Support old DDR3 training

In reply to Marek Behún

Support old DDR3 training code on Turris Omnia, selectable via EEPROM field.

Users experiencing DDR3 initialization failures or random crashes of the operating system due to incorrect DDR3 configuration can select the old DDR3 training implementation to fix those issues by setting the EEPROM field "Use old DDR training":
eeprom update "Use old DDR training" 1

---
 arch/arm/mach-mvebu/Kconfig                   |  1 +
 board/CZ.NIC/turris_omnia/Makefile            |  1 +
 board/CZ.NIC/turris_omnia/eeprom.c            | 37 ++++++++++-
 board/CZ.NIC/turris_omnia/old_ddr3_training.c | 63 +++++++++++++++++++
 board/CZ.NIC/turris_omnia/turris_omnia.c      | 18 +++++-
 5 files changed, 117 insertions(+), 3 deletions(-)
 create mode 100644 board/CZ.NIC/turris_omnia/old_ddr3_training.c
arch/arm/mach-mvebu/Kconfig +1 -0
index e377e8a48a..4a8328760e 100644
@@ -149,6 +149,7 @@ config TARGET_TURRIS_OMNIA
 	select SPL_SYS_MALLOC_SIMPLE
 	select SYS_I2C_MVTWSI
 	select ATSHA204A
+	select ARMADA_38X_SUPPORT_OLD_DDR3_TRAINING
 
 config TARGET_TURRIS_MOX
 	bool "Support CZ.NIC's Turris Mox / RIPE Atlas Probe"
board/CZ.NIC/turris_omnia/Makefile +1 -0
index 216e11958a..d1ef5cb860 100644
@@ -4,3 +4,4 @@
 
 obj-y	:= turris_omnia.o ../turris_atsha_otp.o ../turris_common.o
 obj-$(CONFIG_CMD_EEPROM_LAYOUT)	+= eeprom.o
+obj-$(CONFIG_SPL_BUILD)		+= old_ddr3_training.o
board/CZ.NIC/turris_omnia/eeprom.c +36 -1
index 32572481ce..6e2640ad2a 100644
@@ -91,13 +91,48 @@ static int eeprom_field_update_ddr_speed(struct eeprom_field *field,
 	return 0;
 }
 
+static void eeprom_field_print_bool(const struct eeprom_field *field)
+{
+	unsigned char val = field->buf[0];
+
+	printf(PRINT_FIELD_SEGMENT, field->name);
+
+	if (val == 0xff)
+		puts("(empty, defaults to 0)\n");
+	else
+		printf("%u\n", val);
+}
+
+static int eeprom_field_update_bool(struct eeprom_field *field, char *value)
+{
+	unsigned char *val = &field->buf[0];
+
+	if (value[0] == '\0') {
+		/* setting default value */
+		*val = 0xff;
+
+		return 0;
+	}
+
+	if (value[1] != '\0')
+		return -1;
+
+	if (value[0] == '1' || value[0] == '0')
+		*val = value[0] - '0';
+	else
+		return -1;
+
+	return 0;
+}
+
 static struct eeprom_field omnia_layout[] = {
 	_DEF_FIELD("Magic constant", 4, bin),
 	_DEF_FIELD("RAM size in GB", 4, ramsz),
 	_DEF_FIELD("Wi-Fi Region", 4, region),
 	_DEF_FIELD("CRC32 checksum", 4, bin),
 	_DEF_FIELD("DDR speed", 5, ddr_speed),
-	_DEF_FIELD("Extended reserved fields", 39, reserved),
+	_DEF_FIELD("Use old DDR training", 1, bool),
+	_DEF_FIELD("Extended reserved fields", 38, reserved),
 	_DEF_FIELD("Extended CRC32 checksum", 4, bin),
 };
 
board/CZ.NIC/turris_omnia/old_ddr3_training.c new file +63 -0

63 lines not on this page · raw message

board/CZ.NIC/turris_omnia/turris_omnia.c +16 -2
index 544784e860..2f29d26edf 100644
@@ -432,7 +432,8 @@ struct omnia_eeprom {
 
 	/* second part (only considered if crc2 is not all-ones) */
 	char ddr_speed[5];
-	u8 reserved[39];
+	u8 old_ddr_training;
+	u8 reserved[38];
 	u32 crc2;
 };
 
@@ -496,7 +497,7 @@ static bool omnia_read_eeprom(struct omnia_eeprom *oep)
 	return true;
 }
 
-static int omnia_get_ram_size_gb(void)
+int omnia_get_ram_size_gb(void)
 {
 	static int ram_size;
 	struct omnia_eeprom oep;
@@ -521,6 +522,19 @@ static int omnia_get_ram_size_gb(void)
 	return ram_size;
 }
 
+bool board_use_old_ddr3_training(void)
+{
+	struct omnia_eeprom oep;
+
+	if (!omnia_read_eeprom(&oep))
+		return false;
+
+	if (!is_omnia_eeprom_second_part_valid(&oep))
+		return false;
+
+	return oep.old_ddr_training == 1;
+}
+
 static const char *omnia_get_ddr_speed(void)
 {
 	struct omnia_eeprom oep;
Signature · 1 line
2.44.2
#17 lore raw
In reply to Marek Behún
Quoted 9 lines · Marek Behún

Hi Stefan,

this is v2 of the series adds some changes to DDR3 training for Armada 38x and Turris Omnia.

I also put one unrelated patch (Fix ethernet PHY reset gpio FDT fixup) here.

It depends on stuff in Tom's next branch.

Applied to u-boot-marvell/master

Thanks,
Stefan

Quoted 118 lines

Marek

Marek Behún (16):
arm: mvebu: turris_omnia: Disable ext4 write support in defconfig
ddr: marvell: a38x: debug: return from ddr3_tip_print_log() early if
we won't print anything
ddr: marvell: a38x: debug: Remove unused variables
ddr: marvell: a38x: debug: Define DDR_VIEWER_TOOL variables only if
needed, and make them static
ddr: marvell: a38x: debug: Allow compiling with immutable debug
settings to reduce binary size
arm: mvebu: turris_omnia: Enable immutable debug settings in DDR3
training by default
arm: mvebu: turris_omnia: Fix ethernet PHY reset gpio FDT fixup
arm: mvebu: turris_omnia: Implement EEPROM layout for the 'eeprom'
command
arm: mvebu: turris_omnia: Enable the 'eeprom' command
arm: mvebu: turris_omnia: Extend EEPROM info structure
arm: mvebu: turris_omnia: Read DDR speed from EEPROM
ddr: marvell: a38x: Import old DDR training code from 2017 version of
U-Boot
ddr: marvell: a38x: old: Fix some compiler warning of the old code
ddr: marvell: a38x: old: Backport immutable debug settings
arm: mvebu: a38x: Add optional support for using old DDR3 training
code
arm: mvebu: turris_omnia: Support old DDR3 training

  arch/arm/mach-mvebu/Kconfig                   |   15 +
  arch/arm/mach-mvebu/include/mach/cpu.h        |    1 +
  arch/arm/mach-mvebu/spl.c                     |   37 +-
  board/CZ.NIC/turris_omnia/Makefile            |    2 +
  board/CZ.NIC/turris_omnia/eeprom.c            |  190 ++
  board/CZ.NIC/turris_omnia/old_ddr3_training.c |   63 +
  board/CZ.NIC/turris_omnia/turris_omnia.c      |  199 +-
  configs/turris_omnia_defconfig                |    6 +-
  drivers/ddr/marvell/a38x/Makefile             |    2 +
  drivers/ddr/marvell/a38x/ddr3_debug.c         |   30 +-
  drivers/ddr/marvell/a38x/ddr3_init.c          |    3 +-
  drivers/ddr/marvell/a38x/ddr3_init.h          |   43 +-
  drivers/ddr/marvell/a38x/old/Makefile         |   29 +
  drivers/ddr/marvell/a38x/old/ddr3_a38x.c      |  737 +++++
  drivers/ddr/marvell/a38x/old/ddr3_a38x.h      |   93 +
  .../marvell/a38x/old/ddr3_a38x_mc_static.h    |  226 ++
  .../ddr/marvell/a38x/old/ddr3_a38x_topology.h |   22 +
  .../ddr/marvell/a38x/old/ddr3_a38x_training.c |   39 +
  drivers/ddr/marvell/a38x/old/ddr3_debug.c     | 1546 ++++++++++
  .../marvell/a38x/old/ddr3_hws_hw_training.c   |  147 +
  .../marvell/a38x/old/ddr3_hws_hw_training.h   |   49 +
  .../a38x/old/ddr3_hws_hw_training_def.h       |  464 +++
  .../marvell/a38x/old/ddr3_hws_sil_training.h  |   17 +
  drivers/ddr/marvell/a38x/old/ddr3_init.c      |  769 +++++
  drivers/ddr/marvell/a38x/old/ddr3_init.h      |  405 +++
  .../ddr/marvell/a38x/old/ddr3_logging_def.h   |  101 +
  .../marvell/a38x/old/ddr3_patterns_64bit.h    |  924 ++++++
  .../ddr/marvell/a38x/old/ddr3_topology_def.h  |   76 +
  drivers/ddr/marvell/a38x/old/ddr3_training.c  | 2650 +++++++++++++++++
  .../ddr/marvell/a38x/old/ddr3_training_bist.c |  288 ++
  .../a38x/old/ddr3_training_centralization.c   |  711 +++++
  .../ddr/marvell/a38x/old/ddr3_training_db.c   |  651 ++++
  .../marvell/a38x/old/ddr3_training_hw_algo.c  |  685 +++++
  .../marvell/a38x/old/ddr3_training_hw_algo.h  |   14 +
  .../ddr/marvell/a38x/old/ddr3_training_ip.h   |  178 ++
  .../marvell/a38x/old/ddr3_training_ip_bist.h  |   54 +
  .../old/ddr3_training_ip_centralization.h     |   15 +
  .../marvell/a38x/old/ddr3_training_ip_db.h    |   34 +
  .../marvell/a38x/old/ddr3_training_ip_def.h   |  173 ++
  .../a38x/old/ddr3_training_ip_engine.c        | 1354 +++++++++
  .../a38x/old/ddr3_training_ip_engine.h        |   85 +
  .../marvell/a38x/old/ddr3_training_ip_flow.h  |  349 +++
  .../marvell/a38x/old/ddr3_training_ip_pbs.h   |   41 +
  .../a38x/old/ddr3_training_ip_prv_if.h        |  107 +
  .../a38x/old/ddr3_training_ip_static.h        |   31 +
  .../marvell/a38x/old/ddr3_training_leveling.c | 1836 ++++++++++++
  .../marvell/a38x/old/ddr3_training_leveling.h |   17 +
  .../ddr/marvell/a38x/old/ddr3_training_pbs.c  |  994 +++++++
  .../marvell/a38x/old/ddr3_training_static.c   |  537 ++++
  .../ddr/marvell/a38x/old/ddr_topology_def.h   |  121 +
  .../ddr/marvell/a38x/old/ddr_training_ip_db.h |   16 +
  .../marvell/a38x/old/glue_symbol_renames.h    |  247 ++
  drivers/ddr/marvell/a38x/old/silicon_if.h     |   17 +
  drivers/ddr/marvell/a38x/old/xor.h            |   92 +
  54 files changed, 17475 insertions(+), 57 deletions(-)

create mode 100644 board/CZ.NIC/turris_omnia/eeprom.c
create mode 100644 board/CZ.NIC/turris_omnia/old_ddr3_training.c create mode 100644 drivers/ddr/marvell/a38x/old/Makefile
create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_a38x.c
create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_a38x.h
create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_a38x_mc_static.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_a38x_topology.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_a38x_training.c create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_debug.c
create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_hws_hw_training.c create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_hws_hw_training.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_hws_hw_training_def.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_hws_sil_training.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_init.c
create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_init.h
create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_logging_def.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_patterns_64bit.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_topology_def.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training.c create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_bist.c create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_centralization.c create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_db.c create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_hw_algo.c create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_hw_algo.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_bist.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_centralization.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_db.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_def.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_engine.c create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_engine.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_flow.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_pbs.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_prv_if.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_ip_static.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_leveling.c

Quoted 9 lines

create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_leveling.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_pbs.c create mode 100644 drivers/ddr/marvell/a38x/old/ddr3_training_static.c create mode 100644 drivers/ddr/marvell/a38x/old/ddr_topology_def.h create mode 100644 drivers/ddr/marvell/a38x/old/ddr_training_ip_db.h create mode 100644 drivers/ddr/marvell/a38x/old/glue_symbol_renames.h create mode 100644 drivers/ddr/marvell/a38x/old/silicon_if.h create mode 100644 drivers/ddr/marvell/a38x/old/xor.h

Viele Grüße,
Stefan Roese

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]