Skip to contentSkip to conversation

ddr: marvell: a38x: Add support for DDR4 from Marvell mv-ddr-marvell repository

PATCH Superseded Tony Dinh 3 participants 8 messages Jan 17, 2023 – Jan 18, 2023

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Tony Dinh

author
#0 lore raw

PATCH v2 1/1 ddr: marvell: a38x: Add support for DDR4 from Marvell mv-ddr-marvell repository

This syncs drivers/ddr/marvell/a38x/ with the master branch of repository
https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.git

up to the commit "mv_ddr: a3700: Use the right size for memset to not overflow" d5acc10c287e40cc2feeb28710b92e45c93c702c

This patch was created by following steps:

1. Replace all a38x files in U-Boot tree by files from upstream github Marvell mv-ddr-marvell repository.

2. Run following command to omit portions not relevant for a38x, ddr3, and ddr4:

files=drivers/ddr/marvell/a38x/*
sed 's/#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
-UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
-UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
-UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DTRUE $files

3. Manually change license to SPDX-License-Identifier (upstream license in upstream github repository contains long license texts and U-Boot is using just SPDX-License-Identifier.

After applying this patch, a38x ddr3 ddr4 code in upstream Marvell github repository and in U-Boot would be fully identical. So in future applying above steps could be used to sync code again.

The only change in this patch are:
- Removal of common board_topology_map code using ifdefs in mv_ddr_brd.c
- Some fixes with include files.
- Some basic type defines (original from ATF headers) in mv_ddr_plat.c

Reference:
"ddr: marvell: a38x: Sync code with Marvell mv-ddr-marvell repository"
https://source.denx.de/u-boot/u-boot/-/commit/107c3391b95bcc2ba09a876da4fa0c31b6c1e460

---

Changes in v2:
- Modified the filter scrip to explicitly include ARMADA_38X code
and exclude ARMADA_39X code; also remove 64BIT code. Reran it on drivers/ddr/marvell/a38x/
- Updated script
files=drivers/ddr/marvell/a38x/*
sed 's/#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files

unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
                -UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
                -UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
                -UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DCONFIG_ARMADA_38X -UCONFIG_ARMADA_39X \
                                -UCONFIG_64BIT $files

- Remove more dead code files
- Correct SPDX license header

 drivers/ddr/marvell/a38x/Makefile             |    8 +
 drivers/ddr/marvell/a38x/ddr3_debug.c         |  120 +
 drivers/ddr/marvell/a38x/ddr3_init.c          |   25 +
 drivers/ddr/marvell/a38x/ddr3_init.h          |   14 +
 drivers/ddr/marvell/a38x/ddr3_logging_def.h   |   27 +
 drivers/ddr/marvell/a38x/ddr3_training.c      |  131 +
 drivers/ddr/marvell/a38x/ddr3_training_bist.c |   12 +
 .../a38x/ddr3_training_centralization.c       |    4 +
 drivers/ddr/marvell/a38x/ddr3_training_db.c   |  212 ++
 drivers/ddr/marvell/a38x/ddr3_training_ip.h   |   17 +
 .../ddr/marvell/a38x/ddr3_training_ip_db.h    |   61 +
 .../marvell/a38x/ddr3_training_ip_engine.c    |  145 +
 .../ddr/marvell/a38x/ddr3_training_ip_flow.h  |    5 +
 .../ddr/marvell/a38x/ddr3_training_leveling.c |  135 +
 drivers/ddr/marvell/a38x/dram_if.h            |   13 -
 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c |  674 +++++
 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h |   59 +
 drivers/ddr/marvell/a38x/mv_ddr4_training.c   |  565 ++++
 drivers/ddr/marvell/a38x/mv_ddr4_training.h   |   32 +
 .../a38x/mv_ddr4_training_calibration.c       | 2336 +++++++++++++++++
 .../a38x/mv_ddr4_training_calibration.h       |   26 +
 .../ddr/marvell/a38x/mv_ddr4_training_db.c    |  545 ++++
 .../marvell/a38x/mv_ddr4_training_leveling.c  |  441 ++++
 .../marvell/a38x/mv_ddr4_training_leveling.h  |   11 +
 drivers/ddr/marvell/a38x/mv_ddr_plat.c        |  249 ++
 drivers/ddr/marvell/a38x/mv_ddr_plat.h        |   11 +
 drivers/ddr/marvell/a38x/mv_ddr_regs.h        |   59 +
 drivers/ddr/marvell/a38x/mv_ddr_topology.h    |   72 +
 28 files changed, 5996 insertions(+), 13 deletions(-)
 delete mode 100644 drivers/ddr/marvell/a38x/dram_if.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_db.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.h
drivers/ddr/marvell/a38x/Makefile +8 -0
index 8251d6db66..fcfb615686 100644
@@ -17,3 +17,11 @@ obj-$(CONFIG_SPL_BUILD) += mv_ddr_common.o
 obj-$(CONFIG_SPL_BUILD) += mv_ddr_spd.o
 obj-$(CONFIG_SPL_BUILD) += mv_ddr_topology.o
 obj-$(CONFIG_SPL_BUILD) += xor.o
+
+ifdef CONFIG_DDR4
+	obj-$(CONFIG_SPL_BUILD) += mv_ddr4_mpr_pda_if.o
+	obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training.o
+	obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_calibration.o
+	obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_db.o
+	obj-$(CONFIG_SPL_BUILD) += mv_ddr4_training_leveling.o
+endif
drivers/ddr/marvell/a38x/ddr3_debug.c +120 -0

210 lines not on this page · raw message

drivers/ddr/marvell/a38x/ddr3_init.c +25 -0
index f878b4512b..27eb3ac173 100644
@@ -6,7 +6,11 @@
 #include "ddr3_init.h"
 #include "mv_ddr_common.h"
 
+#if defined(CONFIG_DDR4)
+static char *ddr_type = "DDR4";
+#else /* CONFIG_DDR4 */
 static char *ddr_type = "DDR3";
+#endif /* CONFIG_DDR4 */
 
 /*
  * generic_init_controller controls D-unit configuration:
@@ -61,6 +65,13 @@ int ddr3_init(void)
 	mv_ddr_mc_init();
 
 	if (!is_manual_cal_done) {
+#if defined(CONFIG_DDR4)
+		status = mv_ddr4_calibration_adjust(0, 1, 0);
+		if (status != MV_OK) {
+			printf("%s: failed (0x%x)\n", __func__, status);
+			return status;
+		}
+#endif
 	}
 
 
@@ -120,6 +131,19 @@ static int mv_ddr_training_params_set(u8 dev_num)
 	params.g_zpodt_ctrl = TUNE_TRAINING_PARAMS_P_ODT_CTRL;
 	params.g_znodt_ctrl = TUNE_TRAINING_PARAMS_N_ODT_CTRL;
 
+#if defined(CONFIG_DDR4)
+	params.g_zpodt_data = TUNE_TRAINING_PARAMS_P_ODT_DATA_DDR4;
+	params.g_odt_config = TUNE_TRAINING_PARAMS_ODT_CONFIG_DDR4;
+	params.g_rtt_nom = TUNE_TRAINING_PARAMS_RTT_NOM_DDR4;
+	params.g_dic = TUNE_TRAINING_PARAMS_DIC_DDR4;
+	if (cs_num == 1) {
+		params.g_rtt_wr =  TUNE_TRAINING_PARAMS_RTT_WR_1CS;
+		params.g_rtt_park = TUNE_TRAINING_PARAMS_RTT_PARK_1CS;
+	} else {
+		params.g_rtt_wr =  TUNE_TRAINING_PARAMS_RTT_WR_2CS;
+		params.g_rtt_park = TUNE_TRAINING_PARAMS_RTT_PARK_2CS;
+	}
+#else /* CONFIG_DDR4 */
 	params.g_zpodt_data = TUNE_TRAINING_PARAMS_P_ODT_DATA;
 	params.g_dic = TUNE_TRAINING_PARAMS_DIC;
 	params.g_rtt_nom = TUNE_TRAINING_PARAMS_RTT_NOM;
@@ -130,6 +154,7 @@ static int mv_ddr_training_params_set(u8 dev_num)
 		params.g_rtt_wr = TUNE_TRAINING_PARAMS_RTT_WR_2CS;
 		params.g_odt_config = TUNE_TRAINING_PARAMS_ODT_CONFIG_2CS;
 	}
+#endif /* CONFIG_DDR4 */
 
 	if (ck_delay > 0)
 		params.ck_delay = ck_delay;
drivers/ddr/marvell/a38x/ddr3_init.h +14 -0
index 055516b67e..ba9f7881d5 100644
@@ -137,6 +137,10 @@ extern u32 dfs_low_freq;
 extern u32 nominal_avs;
 extern u32 extension_avs;
 
+#if defined(CONFIG_DDR4)
+/* if 1, SSTL & POD have same Vref and workaround is required */
+extern u8 vref_calibration_wa;
+#endif /* CONFIG_DDR4 */
 
 /* Prototypes */
 int ddr3_init(void);
@@ -152,6 +156,13 @@ void ddr3_new_tip_ecc_scrub(void);
 int ddr3_tip_reg_write(u32 dev_num, u32 reg_addr, u32 data);
 int ddr3_tip_reg_read(u32 dev_num, u32 reg_addr, u32 *data, u32 reg_mask);
 int ddr3_silicon_get_ddr_target_freq(u32 *ddr_freq);
+#if defined(CONFIG_DDR4)
+int mv_ddr4_mode_regs_init(u8 dev_num);
+int mv_ddr4_sdram_config(u32 dev_num);
+int mv_ddr4_phy_config(u32 dev_num);
+int mv_ddr4_calibration_adjust(u32 dev_num, u8 vref_en, u8 pod_only);
+int mv_ddr4_training_main_flow(u32 dev_num);
+#endif /* CONFIG_DDR4 */
 
 int print_adll(u32 dev_num, u32 adll[MAX_INTERFACE_NUM * MAX_BUS_NUM]);
 int print_ph(u32 dev_num, u32 adll[MAX_INTERFACE_NUM * MAX_BUS_NUM]);
@@ -188,5 +199,8 @@ unsigned int mv_ddr_misl_phy_drv_ctrl_p_get(void);
 unsigned int mv_ddr_misl_phy_drv_ctrl_n_get(void);
 unsigned int mv_ddr_misl_phy_odt_p_get(void);
 unsigned int mv_ddr_misl_phy_odt_n_get(void);
+#if defined(CONFIG_DDR4)
+void refresh(void);
+#endif
 
 #endif /* _DDR3_INIT_H */
drivers/ddr/marvell/a38x/ddr3_logging_def.h +27 -0
index ad9da1cfff..a809213926 100644
@@ -73,6 +73,27 @@
 #endif
 #endif
 
+#ifdef CONFIG_DDR4
+#ifdef SILENT_LIB
+#define DEBUG_TAP_TUNING_ENGINE(level, s)
+#define DEBUG_CALIBRATION(level, s)
+#define DEBUG_DDR4_CENTRALIZATION(level, s)
+#define DEBUG_DM_TUNING(level, s)
+#else /* SILENT_LIB */
+#define DEBUG_TAP_TUNING_ENGINE(level, s)	\
+	if (level >= debug_tap_tuning)		\
+		printf s
+#define DEBUG_CALIBRATION(level, s)		\
+	if (level >= debug_calibration)		\
+		printf s
+#define DEBUG_DDR4_CENTRALIZATION(level, s)	\
+	if (level >= debug_ddr4_centralization)	\
+		printf s
+#define DEBUG_DM_TUNING(level, s)		\
+	if (level >= debug_dm_tuning)		\
+		printf s
+#endif /* SILENT_LIB */
+#endif /* CONFIG_DDR4 */
 
 /* Logging defines */
 enum mv_ddr_debug_level {
@@ -94,6 +115,12 @@ enum ddr_lib_debug_block {
 	DEBUG_BLOCK_DEVICE,
 	DEBUG_BLOCK_ACCESS,
 	DEBUG_STAGES_REG_DUMP,
+#if defined(CONFIG_DDR4)
+	DEBUG_TAP_TUNING_ENGINE,
+	DEBUG_BLOCK_CALIBRATION,
+	DEBUG_BLOCK_DDR4_CENTRALIZATION,
+	DEBUG_DM_TUNING,
+#endif /* CONFIG_DDR4 */
 	/* All excluding IP and REG_DUMP, should be enabled separatelly */
 	DEBUG_BLOCK_ALL
 };
drivers/ddr/marvell/a38x/ddr3_training.c +131 -0

251 lines not on this page · raw message

drivers/ddr/marvell/a38x/ddr3_training_bist.c +12 -0
index d388a17291..3f072eb037 100644
@@ -459,7 +459,11 @@ static int mv_ddr_odpg_bist_prepare(enum hws_pattern pattern, enum hws_access_ty
 					       (ODPG_WRBUF_RD_CTRL_DIS << ODPG_WRBUF_RD_CTRL_OFFS),
 			  (ODPG_WRBUF_RD_CTRL_MASK << ODPG_WRBUF_RD_CTRL_OFFS));
 
+#if defined(CONFIG_DDR4)
+	if (pattern == PATTERN_ZERO || pattern == PATTERN_ONE)
+#else
 	if (pattern == PATTERN_00 || pattern == PATTERN_FF)
+#endif
 		ddr3_tip_load_pattern_to_odpg(0, access_type, 0, pattern, offset);
 	else
 		mv_ddr_load_dm_pattern_to_odpg(access_type, pattern, dm_dir);
@@ -507,7 +511,11 @@ int mv_ddr_dm_vw_get(enum hws_pattern pattern, u32 cs, u8 *vw_vector)
 	ddr3_tip_if_write(0, ACCESS_TYPE_UNICAST, 0, ODPG_DATA_CTRL_REG, 0, MASK_ALL_BITS);
 	mv_ddr_odpg_bist_prepare(pattern, ACCESS_TYPE_UNICAST, OPER_WRITE, STRESS_NONE, DURATION_SINGLE,
 				 bist_offset, cs, pattern_table[pattern].num_of_phases_tx,
+#if defined(CONFIG_DDR4)
+				 (pattern == PATTERN_ZERO) ? DM_DIR_DIRECT : DM_DIR_INVERSE);
+#else
 				 (pattern == PATTERN_00) ? DM_DIR_DIRECT : DM_DIR_INVERSE);
+#endif
 
 	for (adll_tap = 0; adll_tap < ADLL_TAPS_PER_PERIOD; adll_tap++) {
 		/* change target odpg address */
@@ -539,7 +547,11 @@ int mv_ddr_dm_vw_get(enum hws_pattern pattern, u32 cs, u8 *vw_vector)
 	/* fill memory with vref pattern to increment addr using odpg bist */
 	mv_ddr_odpg_bist_prepare(PATTERN_VREF, ACCESS_TYPE_UNICAST, OPER_WRITE, STRESS_NONE, DURATION_SINGLE,
 				 bist_offset, cs, pattern_table[pattern].num_of_phases_tx,
+#if defined(CONFIG_DDR4)
+				 (pattern == PATTERN_ZERO) ? DM_DIR_DIRECT : DM_DIR_INVERSE);
+#else
 				 (pattern == PATTERN_00) ? DM_DIR_DIRECT : DM_DIR_INVERSE);
+#endif
 
 	for (adll_tap = 0; adll_tap < ADLL_TAPS_PER_PERIOD; adll_tap++) {
 		ddr3_tip_bus_write(0, ACCESS_TYPE_UNICAST, 0, ACCESS_TYPE_MULTICAST, 0,
drivers/ddr/marvell/a38x/ddr3_training_centralization.c +4 -0
index be9f985f22..e75e45c169 100644
@@ -16,7 +16,11 @@
 #define CENTRAL_RX		1
 #define NUM_OF_CENTRAL_TYPES	2
 
+#if   defined(CONFIG_DDR4) /* DDR4 16/32-bit */
+u32 start_pattern = PATTERN_KILLER_DQ0, end_pattern = PATTERN_KILLER_DQ7_INV;
+#else /* DDR3 16/32-bit */
 u32 start_pattern = PATTERN_KILLER_DQ0, end_pattern = PATTERN_KILLER_DQ7;
+#endif /* CONFIG_64BIT */
 
 u32 start_if = 0, end_if = (MAX_INTERFACE_NUM - 1);
 u8 bus_end_window[NUM_OF_CENTRAL_TYPES][MAX_INTERFACE_NUM][MAX_BUS_NUM];
drivers/ddr/marvell/a38x/ddr3_training_db.c +212 -0

341 lines not on this page · raw message

drivers/ddr/marvell/a38x/ddr3_training_ip.h +17 -0
index 056c21497c..37d21f2b2b 100644
@@ -42,6 +42,13 @@
 #define WRITE_LEVELING_LF_MASK_BIT	0x02000000
 
 /* DDR4 Specific Training Mask bits */
+#if defined (CONFIG_DDR4)
+#define RECEIVER_CALIBRATION_MASK_BIT	0x04000000
+#define WL_PHASE_CORRECTION_MASK_BIT	0x08000000
+#define DQ_VREF_CALIBRATION_MASK_BIT	0x10000000
+#define DQ_MAPPING_MASK_BIT		0x20000000
+#define DM_TUNING_MASK_BIT		0x40000000
+#endif /* CONFIG_DDR4 */
 
 enum hws_result {
 	TEST_FAILED = 0,
@@ -63,6 +70,9 @@ enum auto_tune_stage {
 	WRITE_LEVELING,
 	LOAD_PATTERN_2,
 	READ_LEVELING,
+#if defined(CONFIG_DDR4)
+	SW_READ_LEVELING,
+#endif /* CONFIG_DDR4 */
 	WRITE_LEVELING_SUPP,
 	PBS_RX,
 	PBS_TX,
@@ -78,6 +88,13 @@ enum auto_tune_stage {
 	TX_EMPHASIS,
 	LOAD_PATTERN_HIGH,
 	PER_BIT_READ_LEVELING_TF,
+#if defined(CONFIG_DDR4)
+	RECEIVER_CALIBRATION,
+	WL_PHASE_CORRECTION,
+	DQ_VREF_CALIBRATION,
+	DM_TUNING,
+	DQ_MAPPING,
+#endif /* CONFIG_DDR4 */
 	WRITE_LEVELING_LF,
 	MAX_STAGE_LIMIT
 };
drivers/ddr/marvell/a38x/ddr3_training_ip_db.h +61 -0

73 lines not on this page · raw message

drivers/ddr/marvell/a38x/ddr3_training_ip_engine.c +145 -0

176 lines not on this page · raw message

drivers/ddr/marvell/a38x/ddr3_training_ip_flow.h +5 -0
index 55832a5540..16a59512ee 100644
@@ -46,6 +46,11 @@ enum mr_number {
 	MR_CMD1,
 	MR_CMD2,
 	MR_CMD3,
+#if defined(CONFIG_DDR4)
+	MR_CMD4,
+	MR_CMD5,
+	MR_CMD6,
+#endif
 	MR_LAST
 };
 
drivers/ddr/marvell/a38x/ddr3_training_leveling.c +135 -0

159 lines not on this page · raw message

drivers/ddr/marvell/a38x/dram_if.h deleted +0 -13
deleted file mode 100644
index 4d0846489b..0000000000
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2016 Marvell International Ltd.
- */
-
-#ifndef _DRAM_IF_H_
-#define _DRAM_IF_H_
-
-/* TODO: update atf to this new prototype */
-int dram_init(void);
-void dram_mmap_config(void);
-unsigned long long dram_iface_mem_sz_get(void);
-#endif /* _DRAM_IF_H_ */
drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c new file +674 -0

674 lines not on this page · raw message

drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h new file +59 -0

59 lines not on this page · raw message

drivers/ddr/marvell/a38x/mv_ddr4_training.c new file +565 -0

565 lines not on this page · raw message

drivers/ddr/marvell/a38x/mv_ddr4_training.h new file +32 -0
new file mode 100644
index 0000000000..fa2e9a0877
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) Marvell International Ltd. and its affiliates
+ */
+
+#ifndef _MV_DDR4_TRAINING_H
+#define _MV_DDR4_TRAINING_H
+
+#include "ddr3_training_ip.h"
+
+/* configure DDR4 SDRAM */
+int mv_ddr4_sdram_config(u32 dev_num);
+
+/* configure phy */
+int mv_ddr4_phy_config(u32 dev_num);
+
+/*
+ * configure sstl for manual calibration and pod for automatic one
+ * assumes subphy configured to pod ealier
+ */
+int mv_ddr4_calibration_adjust(u32 dev_num, u8 vref_en, u8 pod_only);
+
+/*
+ * validates calibration values
+ * soc dependent; TODO: check it
+ */
+int mv_ddr4_calibration_validate(u32 dev_num);
+
+u16 mv_ddr4_rtt_nom_to_odt(u16 rtt_nom);
+u16 mv_ddr4_rtt_wr_to_odt(u16 rtt_wr);
+
+#endif /* _MV_DDR4_TRAINING_H */
drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c new file +2336 -0

226 lines not on this page · raw message

drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.h new file +26 -0
new file mode 100644
index 0000000000..da4a866fe9

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

drivers/ddr/marvell/a38x/mv_ddr4_training_db.c new file +545 -0

545 lines not on this page · raw message

drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.c new file +441 -0

441 lines not on this page · raw message

drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.h new file +11 -0
new file mode 100644
index 0000000000..4067cac968

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

drivers/ddr/marvell/a38x/mv_ddr_plat.c +249 -0

249 lines not on this page · raw message

drivers/ddr/marvell/a38x/mv_ddr_plat.h +11 -0
index 44998847c2..01894f652c 100644

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

drivers/ddr/marvell/a38x/mv_ddr_regs.h +59 -0

59 lines not on this page · raw message

drivers/ddr/marvell/a38x/mv_ddr_topology.h +72 -0

72 lines not on this page · raw message

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

Signature · 1 line
2.30.2

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

#1 lore raw

Hello! Thank you for update. It is much better.

Quoted 11 lines · On Monday 16 January 2023 21:34:39 Tony Dinh wrote:

This syncs drivers/ddr/marvell/a38x/ with the master branch of repository
https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.git

up to the commit "mv_ddr: a3700: Use the right size for memset to not overflow" d5acc10c287e40cc2feeb28710b92e45c93c702c

This patch was created by following steps:

1. Replace all a38x files in U-Boot tree by files from upstream github Marvell mv-ddr-marvell repository.

Quoted 8 lines

2. Run following command to omit portions not relevant for a38x, ddr3, and ddr4:

files=drivers/ddr/marvell/a38x/*
sed 's/#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
-UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
-UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
-UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DTRUE $files

Do not forget to also update commit message.

And btw, commit messages has on each line some leading spaces which is not probably intended.

Quoted 20 lines

3. Manually change license to SPDX-License-Identifier (upstream license in upstream github repository contains long license texts and U-Boot is using just SPDX-License-Identifier.

After applying this patch, a38x ddr3 ddr4 code in upstream Marvell github repository and in U-Boot would be fully identical. So in future applying above steps could be used to sync code again.

The only change in this patch are:
- Removal of common board_topology_map code using ifdefs in mv_ddr_brd.c
- Some fixes with include files.
- Some basic type defines (original from ATF headers) in mv_ddr_plat.c

Reference:
"ddr: marvell: a38x: Sync code with Marvell mv-ddr-marvell repository"
https://source.denx.de/u-boot/u-boot/-/commit/107c3391b95bcc2ba09a876da4fa0c31b6c1e460

---

Quoted 7 lines

Changes in v2:
- Modified the filter scrip to explicitly include ARMADA_38X code
and exclude ARMADA_39X code; also remove 64BIT code. Reran it on drivers/ddr/marvell/a38x/
- Updated script
files=drivers/ddr/marvell/a38x/*
sed 's/#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files

You do not need this sed anymore. CONFIG_ARMADA_39X is explicitly removed and CONFIG_ARMADA_38X already handled by unifdef.

Quoted 30 lines
unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
                -UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
                -UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
                -UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DCONFIG_ARMADA_38X -UCONFIG_ARMADA_39X \
                                -UCONFIG_64BIT $files

- Remove more dead code files
- Correct SPDX license header

 drivers/ddr/marvell/a38x/Makefile             |    8 +
 drivers/ddr/marvell/a38x/ddr3_debug.c         |  120 +
 drivers/ddr/marvell/a38x/ddr3_init.c          |   25 +
 drivers/ddr/marvell/a38x/ddr3_init.h          |   14 +
 drivers/ddr/marvell/a38x/ddr3_logging_def.h   |   27 +
 drivers/ddr/marvell/a38x/ddr3_training.c      |  131 +
 drivers/ddr/marvell/a38x/ddr3_training_bist.c |   12 +
 .../a38x/ddr3_training_centralization.c       |    4 +
 drivers/ddr/marvell/a38x/ddr3_training_db.c   |  212 ++
 drivers/ddr/marvell/a38x/ddr3_training_ip.h   |   17 +
 .../ddr/marvell/a38x/ddr3_training_ip_db.h    |   61 +
 .../marvell/a38x/ddr3_training_ip_engine.c    |  145 +
 .../ddr/marvell/a38x/ddr3_training_ip_flow.h  |    5 +
 .../ddr/marvell/a38x/ddr3_training_leveling.c |  135 +
 drivers/ddr/marvell/a38x/dram_if.h            |   13 -
 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c |  674 +++++
 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h |   59 +
 drivers/ddr/marvell/a38x/mv_ddr4_training.c   |  565 ++++
 drivers/ddr/marvell/a38x/mv_ddr4_training.h   |   32 +
 .../a38x/mv_ddr4_training_calibration.c       | 2336 +++++++++++++++++
 .../a38x/mv_ddr4_training_calibration.h       |   26 +
 .../ddr/marvell/a38x/mv_ddr4_training_db.c    |  545 ++++
Quoted 8 lines
 .../marvell/a38x/mv_ddr4_training_leveling.c  |  441 ++++
 .../marvell/a38x/mv_ddr4_training_leveling.h  |   11 +
 drivers/ddr/marvell/a38x/mv_ddr_plat.c        |  249 ++
 drivers/ddr/marvell/a38x/mv_ddr_plat.h        |   11 +
 drivers/ddr/marvell/a38x/mv_ddr_regs.h        |   59 +
 drivers/ddr/marvell/a38x/mv_ddr_topology.h    |   72 +
 28 files changed, 5996 insertions(+), 13 deletions(-)
 delete mode 100644 drivers/ddr/marvell/a38x/dram_if.h

I see that you are removing some existing file. If it is not needed neither for DDR3 nor for DDR4 then please remove it in separate commit or patch. So we do not mix different things into one commit.

Quoted 9 lines
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_db.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.h

...

drivers/ddr/marvell/a38x/mv_ddr_plat.c line 19

Quoted 13 lines
drivers/ddr/marvell/a38x/mv_ddr_plat.c +5 -0
index 7c7bce73a3..16d177b42f 100644
@@ -12,6 +12,11 @@
 #define DDR_INTERFACES_NUM		1
 #define DDR_INTERFACE_OCTETS_NUM	5
 
+/* These were defined in ATF area that was stripped out */
+#define MV_STATUS	int
+#define MV_U32		u32
+#define MV_U8		u8
+

This is something new which you added? Because I do not see it in Marvell code.

author
#2 lore raw

Hi Pali,

Quoted 17 lines · Pali Rohár

Hello! Thank you for update. It is much better.

Quoted 13 lines · On Monday 16 January 2023 21:34:39 Tony Dinh wrote:

This syncs drivers/ddr/marvell/a38x/ with the master branch of repository
https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.git

up to the commit "mv_ddr: a3700: Use the right size for memset to not overflow" d5acc10c287e40cc2feeb28710b92e45c93c702c

This patch was created by following steps:

1. Replace all a38x files in U-Boot tree by files from upstream github Marvell mv-ddr-marvell repository.

2. Run following command to omit portions not relevant for a38x, ddr3, and ddr4:

Quoted 8 lines
Quoted 6 lines
        files=drivers/ddr/marvell/a38x/*
        sed 's/#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files
        unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
            -UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
            -UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
            -UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DTRUE $files

Do not forget to also update commit message.

Yes, patman extracts and creates the patch description from the commit.

Quoted 3 lines

And btw, commit messages has on each line some leading spaces which is not probably intended.

That was intentional to make the commit description (and patch description) more readable. Is it not recommended?

Quoted 29 lines
Quoted 21 lines

3. Manually change license to SPDX-License-Identifier (upstream license in upstream github repository contains long license texts and U-Boot is using just SPDX-License-Identifier.

After applying this patch, a38x ddr3 ddr4 code in upstream Marvell github repository and in U-Boot would be fully identical. So in future applying above steps could be used to sync code again.

The only change in this patch are:
- Removal of common board_topology_map code using ifdefs in mv_ddr_brd.c
- Some fixes with include files.
- Some basic type defines (original from ATF headers) in mv_ddr_plat.c

Reference:
"ddr: marvell: a38x: Sync code with Marvell mv-ddr-marvell repository"
https://source.denx.de/u-boot/u-boot/-/commit/107c3391b95bcc2ba09a876da4fa0c31b6c1e460

---

Quoted 7 lines

Changes in v2:
- Modified the filter scrip to explicitly include ARMADA_38X code
and exclude ARMADA_39X code; also remove 64BIT code. Reran it on drivers/ddr/marvell/a38x/
- Updated script
files=drivers/ddr/marvell/a38x/*
sed 's/#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files

Quoted 2 lines

You do not need this sed anymore. CONFIG_ARMADA_39X is explicitly removed and CONFIG_ARMADA_38X already handled by unifdef.

Thanks, I was not sure if unifdef works in that "OR" condition. I will update the commit message.

Quoted 40 lines
Quoted 31 lines
unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
                -UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
                -UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
                -UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DCONFIG_ARMADA_38X -UCONFIG_ARMADA_39X \
                                -UCONFIG_64BIT $files

- Remove more dead code files
- Correct SPDX license header

 drivers/ddr/marvell/a38x/Makefile             |    8 +
 drivers/ddr/marvell/a38x/ddr3_debug.c         |  120 +
 drivers/ddr/marvell/a38x/ddr3_init.c          |   25 +
 drivers/ddr/marvell/a38x/ddr3_init.h          |   14 +
 drivers/ddr/marvell/a38x/ddr3_logging_def.h   |   27 +
 drivers/ddr/marvell/a38x/ddr3_training.c      |  131 +
 drivers/ddr/marvell/a38x/ddr3_training_bist.c |   12 +
 .../a38x/ddr3_training_centralization.c       |    4 +
 drivers/ddr/marvell/a38x/ddr3_training_db.c   |  212 ++
 drivers/ddr/marvell/a38x/ddr3_training_ip.h   |   17 +
 .../ddr/marvell/a38x/ddr3_training_ip_db.h    |   61 +
 .../marvell/a38x/ddr3_training_ip_engine.c    |  145 +
 .../ddr/marvell/a38x/ddr3_training_ip_flow.h  |    5 +
 .../ddr/marvell/a38x/ddr3_training_leveling.c |  135 +
 drivers/ddr/marvell/a38x/dram_if.h            |   13 -
 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c |  674 +++++
 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h |   59 +
 drivers/ddr/marvell/a38x/mv_ddr4_training.c   |  565 ++++
 drivers/ddr/marvell/a38x/mv_ddr4_training.h   |   32 +
 .../a38x/mv_ddr4_training_calibration.c       | 2336 +++++++++++++++++
 .../a38x/mv_ddr4_training_calibration.h       |   26 +
 .../ddr/marvell/a38x/mv_ddr4_training_db.c    |  545 ++++
Quoted 8 lines
 .../marvell/a38x/mv_ddr4_training_leveling.c  |  441 ++++
 .../marvell/a38x/mv_ddr4_training_leveling.h  |   11 +
 drivers/ddr/marvell/a38x/mv_ddr_plat.c        |  249 ++
 drivers/ddr/marvell/a38x/mv_ddr_plat.h        |   11 +
 drivers/ddr/marvell/a38x/mv_ddr_regs.h        |   59 +
 drivers/ddr/marvell/a38x/mv_ddr_topology.h    |   72 +
 28 files changed, 5996 insertions(+), 13 deletions(-)
 delete mode 100644 drivers/ddr/marvell/a38x/dram_if.h
Quoted 3 lines

I see that you are removing some existing file. If it is not needed neither for DDR3 nor for DDR4 then please remove it in separate commit or patch. So we do not mix different things into one commit.

Instead of making a different commit, will it work if we list the files being removed in this commit message? It is part of removing dead code.

Quoted 19 lines
Quoted 10 lines
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_db.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.h

...

Quoted 8 lines
drivers/ddr/marvell/a38x/mv_ddr_plat.c +0 -0
index 7c7bce73a3..16d177b42f 100644
@@ -12,6 +12,11 @@
 #define DDR_INTERFACES_NUM           1
 #define DDR_INTERFACE_OCTETS_NUM     5
 
Quoted 8 lines

drivers/ddr/marvell/a38x/mv_ddr_plat.c line 19

Quoted 5 lines
drivers/ddr/marvell/a38x/mv_ddr_plat.c +5 -0
+/* These were defined in ATF area that was stripped out */
+#define MV_STATUS    int
+#define MV_U32               u32
+#define MV_U8                u8
+

This is something new which you added? Because I do not see it in Marvell code.

Yes, those were in the original code after the initial copying from the Marvell repo.

# grep -E '(MV_U32|MV_STATUS|MV_U8)' *.[ch] a38x/*.[ch]

ddr_init.c:MV_U32 ddr_init(void)
mv_ddr_atf_wrapper.h:#define MV_STATUS int mv_ddr_atf_wrapper.h:#define MV_U8 u8 mv_ddr_atf_wrapper.h:#define MV_U32 u32 a38x/mv_ddr_plat.c:MV_STATUS mv_ddr4_calibration_validate(MV_U32 dev_num) a38x/mv_ddr_plat.c: MV_STATUS status = MV_OK; a38x/mv_ddr_plat.c: MV_U8 if_id = 0;
a38x/mv_ddr_plat.c: MV_U32 read_data[MAX_INTERFACE_NUM]; a38x/mv_ddr_plat.c: MV_U32 cal_n = 0, cal_p = 0;

Those 3 are defined in mv_ddr_atf_wrapper.h and used in mv_ddr_plat.c (after we ran the filter script, this file is the only place that needs those 3 defines). Since we removed the ATF code, we need to define them here in mv_ddr_plat.c. Is this OK or do you have any suggestions for a better approach?

Thanks,
Tony

#3 lore raw

Hello!

Quoted 27 lines · On Tuesday 17 January 2023 13:02:46 Tony Dinh wrote:

Hi Pali,

Quoted 24 lines · Pali Rohár

Hello! Thank you for update. It is much better.

Quoted 19 lines · On Monday 16 January 2023 21:34:39 Tony Dinh wrote:

This syncs drivers/ddr/marvell/a38x/ with the master branch of repository
https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.git

up to the commit "mv_ddr: a3700: Use the right size for memset to not overflow" d5acc10c287e40cc2feeb28710b92e45c93c702c

This patch was created by following steps:

1. Replace all a38x files in U-Boot tree by files from upstream github Marvell mv-ddr-marvell repository.

2. Run following command to omit portions not relevant for a38x, ddr3, and ddr4:

files=drivers/ddr/marvell/a38x/*
sed 's/#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
-UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
-UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
-UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DTRUE $files

Quoted 3 lines
Quoted 1 line

Do not forget to also update commit message.

Yes, patman extracts and creates the patch description from the commit.

My reaction was just because you forgot to update undef for a39x.

Quoted 6 lines
Quoted 3 lines

And btw, commit messages has on each line some leading spaces which is not probably intended.

That was intentional to make the commit description (and patch description) more readable. Is it not recommended?

I'm not sure if we are talking about the same thing. When I read this your patch I saw that every time, even the first one "This sync drivers/..." has 4 spaces before word "This". And I'm not sure if this is just my email client or not and there is some reason for it. Look at indentation of line "Signed-off-by:" and line "Reference:". Should not be those two lines at same indentation level? Or I did not understand it? :D

I agree that adding indentation inside of 1. 2. 3. parts is fully recommended as it makes text more readable.

Quoted 29 lines
Quoted 29 lines
Quoted 28 lines

3. Manually change license to SPDX-License-Identifier (upstream license in upstream github repository contains long license texts and U-Boot is using just SPDX-License-Identifier.

After applying this patch, a38x ddr3 ddr4 code in upstream Marvell github repository and in U-Boot would be fully identical. So in future applying above steps could be used to sync code again.

The only change in this patch are:
- Removal of common board_topology_map code using ifdefs in mv_ddr_brd.c
- Some fixes with include files.
- Some basic type defines (original from ATF headers) in mv_ddr_plat.c

Reference:
"ddr: marvell: a38x: Sync code with Marvell mv-ddr-marvell repository"
https://source.denx.de/u-boot/u-boot/-/commit/107c3391b95bcc2ba09a876da4fa0c31b6c1e460

---

Changes in v2:
- Modified the filter scrip to explicitly include ARMADA_38X code
and exclude ARMADA_39X code; also remove 64BIT code. Reran it on drivers/ddr/marvell/a38x/
- Updated script
files=drivers/ddr/marvell/a38x/*
sed 's/#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files

Quoted 5 lines
Quoted 2 lines

You do not need this sed anymore. CONFIG_ARMADA_39X is explicitly removed and CONFIG_ARMADA_38X already handled by unifdef.

Thanks, I was not sure if unifdef works in that "OR" condition. I will update the commit message.

It should work if at least one of the option in OR condition is specified with -D on command line. But if you are unsure then it is better to test it (should be quite easy and fast).

Quoted 40 lines
Quoted 40 lines
Quoted 39 lines
unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
                -UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
                -UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
                -UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DCONFIG_ARMADA_38X -UCONFIG_ARMADA_39X \
                                -UCONFIG_64BIT $files

- Remove more dead code files
- Correct SPDX license header

 drivers/ddr/marvell/a38x/Makefile             |    8 +
 drivers/ddr/marvell/a38x/ddr3_debug.c         |  120 +
 drivers/ddr/marvell/a38x/ddr3_init.c          |   25 +
 drivers/ddr/marvell/a38x/ddr3_init.h          |   14 +
 drivers/ddr/marvell/a38x/ddr3_logging_def.h   |   27 +
 drivers/ddr/marvell/a38x/ddr3_training.c      |  131 +
 drivers/ddr/marvell/a38x/ddr3_training_bist.c |   12 +
 .../a38x/ddr3_training_centralization.c       |    4 +
 drivers/ddr/marvell/a38x/ddr3_training_db.c   |  212 ++
 drivers/ddr/marvell/a38x/ddr3_training_ip.h   |   17 +
 .../ddr/marvell/a38x/ddr3_training_ip_db.h    |   61 +
 .../marvell/a38x/ddr3_training_ip_engine.c    |  145 +
 .../ddr/marvell/a38x/ddr3_training_ip_flow.h  |    5 +
 .../ddr/marvell/a38x/ddr3_training_leveling.c |  135 +
 drivers/ddr/marvell/a38x/dram_if.h            |   13 -
 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c |  674 +++++
 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h |   59 +
 drivers/ddr/marvell/a38x/mv_ddr4_training.c   |  565 ++++
 drivers/ddr/marvell/a38x/mv_ddr4_training.h   |   32 +
 .../a38x/mv_ddr4_training_calibration.c       | 2336 +++++++++++++++++
 .../a38x/mv_ddr4_training_calibration.h       |   26 +
 .../ddr/marvell/a38x/mv_ddr4_training_db.c    |  545 ++++
 .../marvell/a38x/mv_ddr4_training_leveling.c  |  441 ++++
 .../marvell/a38x/mv_ddr4_training_leveling.h  |   11 +
 drivers/ddr/marvell/a38x/mv_ddr_plat.c        |  249 ++
 drivers/ddr/marvell/a38x/mv_ddr_plat.h        |   11 +
 drivers/ddr/marvell/a38x/mv_ddr_regs.h        |   59 +
 drivers/ddr/marvell/a38x/mv_ddr_topology.h    |   72 +
 28 files changed, 5996 insertions(+), 13 deletions(-)
 delete mode 100644 drivers/ddr/marvell/a38x/dram_if.h
Quoted 7 lines
Quoted 3 lines

I see that you are removing some existing file. If it is not needed neither for DDR3 nor for DDR4 then please remove it in separate commit or patch. So we do not mix different things into one commit.

Instead of making a different commit, will it work if we list the files being removed in this commit message? It is part of removing dead code.

I do not know. I'm always trying to put different thing into different commits. Reason is that if in some case it would be needed to revert commit then unrelated cleanup does not need to be reverted :-)

Quoted 43 lines
Quoted 19 lines
Quoted 10 lines
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_db.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.h

...

Quoted 8 lines
drivers/ddr/marvell/a38x/mv_ddr_plat.c +0 -0
index 7c7bce73a3..16d177b42f 100644
@@ -12,6 +12,11 @@
 #define DDR_INTERFACES_NUM           1
 #define DDR_INTERFACE_OCTETS_NUM     5
 
Quoted 8 lines

drivers/ddr/marvell/a38x/mv_ddr_plat.c line 19

Quoted 5 lines
drivers/ddr/marvell/a38x/mv_ddr_plat.c +5 -0
+/* These were defined in ATF area that was stripped out */
+#define MV_STATUS    int
+#define MV_U32               u32
+#define MV_U8                u8
+

This is something new which you added? Because I do not see it in Marvell code.

Yes, those were in the original code after the initial copying from the Marvell repo.

# grep -E '(MV_U32|MV_STATUS|MV_U8)' *.[ch] a38x/*.[ch]

ddr_init.c:MV_U32 ddr_init(void)
mv_ddr_atf_wrapper.h:#define MV_STATUS int mv_ddr_atf_wrapper.h:#define MV_U8 u8 mv_ddr_atf_wrapper.h:#define MV_U32 u32 a38x/mv_ddr_plat.c:MV_STATUS mv_ddr4_calibration_validate(MV_U32 dev_num) a38x/mv_ddr_plat.c: MV_STATUS status = MV_OK; a38x/mv_ddr_plat.c: MV_U8 if_id = 0;
a38x/mv_ddr_plat.c: MV_U32 read_data[MAX_INTERFACE_NUM]; a38x/mv_ddr_plat.c: MV_U32 cal_n = 0, cal_p = 0;

Quoted 5 lines

Those 3 are defined in mv_ddr_atf_wrapper.h and used in mv_ddr_plat.c (after we ran the filter script, this file is the only place that needs those 3 defines). Since we removed the ATF code, we need to define them here in mv_ddr_plat.c. Is this OK or do you have any suggestions for a better approach?

Hmm... You found another bug in Marvell code:

$ git grep mv_ddr4_calibration_validate
a38x/mv_ddr_plat.c:MV_STATUS mv_ddr4_calibration_validate(MV_U32 dev_num)
apn806/mv_ddr_plat.c:int mv_ddr4_calibration_validate(u32 dev_num)
mv_ddr4_training.c:             return mv_ddr4_calibration_validate(dev_num);
mv_ddr4_training.h:int mv_ddr4_calibration_validate(u32 dev_num);

That function mv_ddr4_calibration_validate() should return int type (as defined in header file) and not MV_STATUS type. So rather fix return type of the function to match what is in header file. Also there is mismatch with its argument u32 vs MV_u32!

Next, MV_U8 is used only at one place (a37xx defines it moreover locally):

$ git grep MV_U8
a3700/mv_ddr_a3700_wrapper.h:#define MV_U8              u8
a38x/mv_ddr_plat.c:     MV_U8 if_id = 0;
mv_ddr_atf_wrapper.h:#define MV_U8              u8

So replace MV_U8 directly by u8. And same for MV_U32 for a38x code.

And ideally, send a pull request to Marvell repo with these fixes (and also with floating point), so code can be synced easily also again in future.

author
#4 lore raw

Hi Pali,

Quoted 31 lines · Pali Rohár

Hello!

Quoted 27 lines · On Tuesday 17 January 2023 13:02:46 Tony Dinh wrote:

Hi Pali,

Quoted 24 lines · Pali Rohár

Hello! Thank you for update. It is much better.

Quoted 19 lines · On Monday 16 January 2023 21:34:39 Tony Dinh wrote:

This syncs drivers/ddr/marvell/a38x/ with the master branch of repository
https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.git

up to the commit "mv_ddr: a3700: Use the right size for memset to not overflow" d5acc10c287e40cc2feeb28710b92e45c93c702c

This patch was created by following steps:

1. Replace all a38x files in U-Boot tree by files from upstream github Marvell mv-ddr-marvell repository.

2. Run following command to omit portions not relevant for a38x, ddr3, and ddr4:

files=drivers/ddr/marvell/a38x/*
sed 's/#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
-UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
-UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
-UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DTRUE $files

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Do not forget to also update commit message.

Yes, patman extracts and creates the patch description from the commit.

My reaction was just because you forgot to update undef for a39x.

I see. Yes, I did miss that! I only described the changes in v2 description.

Quoted 14 lines
Quoted 6 lines
Quoted 3 lines

And btw, commit messages has on each line some leading spaces which is not probably intended.

That was intentional to make the commit description (and patch description) more readable. Is it not recommended?

I'm not sure if we are talking about the same thing. When I read this your patch I saw that every time, even the first one "This sync drivers/..." has 4 spaces before word "This". And I'm not sure if this is just my email client or not and there is some reason for it. Look at indentation of line "Signed-off-by:" and line "Reference:". Should not be those two lines at same indentation level? Or I did not understand it? :D

Quoted 2 lines

I agree that adding indentation inside of 1. 2. 3. parts is fully recommended as it makes text more readable.

When I do git log I also see an extra 4 or 8 spaces on each line:) so not sure what we are seeing here. But yes it seems some of the indentation is inconsistent. Will fix that.

Quoted 84 lines
Quoted 30 lines
Quoted 30 lines
Quoted 29 lines

3. Manually change license to SPDX-License-Identifier (upstream license in upstream github repository contains long license texts and U-Boot is using just SPDX-License-Identifier.

After applying this patch, a38x ddr3 ddr4 code in upstream Marvell github repository and in U-Boot would be fully identical. So in future applying above steps could be used to sync code again.

The only change in this patch are:
- Removal of common board_topology_map code using ifdefs in mv_ddr_brd.c
- Some fixes with include files.
- Some basic type defines (original from ATF headers) in mv_ddr_plat.c

Reference:
"ddr: marvell: a38x: Sync code with Marvell mv-ddr-marvell repository"
https://source.denx.de/u-boot/u-boot/-/commit/107c3391b95bcc2ba09a876da4fa0c31b6c1e460

---

Changes in v2:
- Modified the filter scrip to explicitly include ARMADA_38X code
and exclude ARMADA_39X code; also remove 64BIT code. Reran it on drivers/ddr/marvell/a38x/
- Updated script
files=drivers/ddr/marvell/a38x/*
sed 's/#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files

Quoted 5 lines
Quoted 2 lines

You do not need this sed anymore. CONFIG_ARMADA_39X is explicitly removed and CONFIG_ARMADA_38X already handled by unifdef.

Thanks, I was not sure if unifdef works in that "OR" condition. I will update the commit message.

It should work if at least one of the option in OR condition is specified with -D on command line. But if you are unsure then it is better to test it (should be quite easy and fast).

Quoted 44 lines
Quoted 43 lines
Quoted 31 lines
unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
                -UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
                -UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
                -UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DCONFIG_ARMADA_38X -UCONFIG_ARMADA_39X \
                                -UCONFIG_64BIT $files

- Remove more dead code files
- Correct SPDX license header

 drivers/ddr/marvell/a38x/Makefile             |    8 +
 drivers/ddr/marvell/a38x/ddr3_debug.c         |  120 +
 drivers/ddr/marvell/a38x/ddr3_init.c          |   25 +
 drivers/ddr/marvell/a38x/ddr3_init.h          |   14 +
 drivers/ddr/marvell/a38x/ddr3_logging_def.h   |   27 +
 drivers/ddr/marvell/a38x/ddr3_training.c      |  131 +
 drivers/ddr/marvell/a38x/ddr3_training_bist.c |   12 +
 .../a38x/ddr3_training_centralization.c       |    4 +
 drivers/ddr/marvell/a38x/ddr3_training_db.c   |  212 ++
 drivers/ddr/marvell/a38x/ddr3_training_ip.h   |   17 +
 .../ddr/marvell/a38x/ddr3_training_ip_db.h    |   61 +
 .../marvell/a38x/ddr3_training_ip_engine.c    |  145 +
 .../ddr/marvell/a38x/ddr3_training_ip_flow.h  |    5 +
 .../ddr/marvell/a38x/ddr3_training_leveling.c |  135 +
 drivers/ddr/marvell/a38x/dram_if.h            |   13 -
 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c |  674 +++++
 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h |   59 +
 drivers/ddr/marvell/a38x/mv_ddr4_training.c   |  565 ++++
 drivers/ddr/marvell/a38x/mv_ddr4_training.h   |   32 +
 .../a38x/mv_ddr4_training_calibration.c       | 2336 +++++++++++++++++
 .../a38x/mv_ddr4_training_calibration.h       |   26 +
 .../ddr/marvell/a38x/mv_ddr4_training_db.c    |  545 ++++
Quoted 8 lines
 .../marvell/a38x/mv_ddr4_training_leveling.c  |  441 ++++
 .../marvell/a38x/mv_ddr4_training_leveling.h  |   11 +
 drivers/ddr/marvell/a38x/mv_ddr_plat.c        |  249 ++
 drivers/ddr/marvell/a38x/mv_ddr_plat.h        |   11 +
 drivers/ddr/marvell/a38x/mv_ddr_regs.h        |   59 +
 drivers/ddr/marvell/a38x/mv_ddr_topology.h    |   72 +
 28 files changed, 5996 insertions(+), 13 deletions(-)
 delete mode 100644 drivers/ddr/marvell/a38x/dram_if.h

I see that you are removing some existing file. If it is not needed neither for DDR3 nor for DDR4 then please remove it in separate commit or patch. So we do not mix different things into one commit.

Quoted 7 lines
Quoted 3 lines

Instead of making a different commit, will it work if we list the files being removed in this commit message? It is part of removing dead code.

I do not know. I'm always trying to put different thing into different commits. Reason is that if in some case it would be needed to revert commit then unrelated cleanup does not need to be reverted :-)

There is only one existing file removed (dram_if.h). The other are new files that become dead code after we run the filter script. Do you think those should also be kept in this patch, and then we'll have a cleanup patch later? The alternative is I can just list the new-but-deleted files in the commit description so they can be kept tracked of (easier for the future code sync if we know what should be candidates for removal).

Quoted 63 lines
Quoted 44 lines
Quoted 20 lines
Quoted 11 lines

 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_db.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.h

...

Quoted 8 lines
drivers/ddr/marvell/a38x/mv_ddr_plat.c +0 -0
index 7c7bce73a3..16d177b42f 100644
@@ -12,6 +12,11 @@
 #define DDR_INTERFACES_NUM           1
 #define DDR_INTERFACE_OCTETS_NUM     5
 
Quoted 8 lines

drivers/ddr/marvell/a38x/mv_ddr_plat.c line 19

Quoted 5 lines
drivers/ddr/marvell/a38x/mv_ddr_plat.c +5 -0
+/* These were defined in ATF area that was stripped out */
+#define MV_STATUS    int
+#define MV_U32               u32
+#define MV_U8                u8
+

This is something new which you added? Because I do not see it in Marvell code.

Yes, those were in the original code after the initial copying from the Marvell repo.

# grep -E '(MV_U32|MV_STATUS|MV_U8)' *.[ch] a38x/*.[ch]

ddr_init.c:MV_U32 ddr_init(void)
mv_ddr_atf_wrapper.h:#define MV_STATUS int mv_ddr_atf_wrapper.h:#define MV_U8 u8 mv_ddr_atf_wrapper.h:#define MV_U32 u32 a38x/mv_ddr_plat.c:MV_STATUS mv_ddr4_calibration_validate(MV_U32 dev_num) a38x/mv_ddr_plat.c: MV_STATUS status = MV_OK; a38x/mv_ddr_plat.c: MV_U8 if_id = 0;
a38x/mv_ddr_plat.c: MV_U32 read_data[MAX_INTERFACE_NUM]; a38x/mv_ddr_plat.c: MV_U32 cal_n = 0, cal_p = 0;

Quoted 5 lines

Those 3 are defined in mv_ddr_atf_wrapper.h and used in mv_ddr_plat.c (after we ran the filter script, this file is the only place that needs those 3 defines). Since we removed the ATF code, we need to define them here in mv_ddr_plat.c. Is this OK or do you have any suggestions for a better approach?

Hmm... You found another bug in Marvell code:

$ git grep mv_ddr4_calibration_validate
a38x/mv_ddr_plat.c:MV_STATUS mv_ddr4_calibration_validate(MV_U32 dev_num)
apn806/mv_ddr_plat.c:int mv_ddr4_calibration_validate(u32 dev_num)
mv_ddr4_training.c:             return mv_ddr4_calibration_validate(dev_num);
mv_ddr4_training.h:int mv_ddr4_calibration_validate(u32 dev_num);

That function mv_ddr4_calibration_validate() should return int type (as defined in header file) and not MV_STATUS type. So rather fix return type of the function to match what is in header file. Also there is mismatch with its argument u32 vs MV_u32!

Quoted 8 lines

Next, MV_U8 is used only at one place (a37xx defines it moreover locally):

$ git grep MV_U8
a3700/mv_ddr_a3700_wrapper.h:#define MV_U8              u8
a38x/mv_ddr_plat.c:     MV_U8 if_id = 0;
mv_ddr_atf_wrapper.h:#define MV_U8              u8

So replace MV_U8 directly by u8. And same for MV_U32 for a38x code.

Cool.

Quoted 3 lines

And ideally, send a pull request to Marvell repo with these fixes (and also with floating point), so code can be synced easily also again in future.

Would you do that when you have time after DDR4 gets merged?

Thanks,
Tony

#5 lore raw
Quoted 151 lines · On Tuesday 17 January 2023 17:18:43 Tony Dinh wrote:

Hi Pali,

Quoted 31 lines · Pali Rohár

Hello!

Quoted 27 lines · On Tuesday 17 January 2023 13:02:46 Tony Dinh wrote:

Hi Pali,

Quoted 24 lines · Pali Rohár

Hello! Thank you for update. It is much better.

Quoted 19 lines · On Monday 16 January 2023 21:34:39 Tony Dinh wrote:

This syncs drivers/ddr/marvell/a38x/ with the master branch of repository
https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.git

up to the commit "mv_ddr: a3700: Use the right size for memset to not overflow" d5acc10c287e40cc2feeb28710b92e45c93c702c

This patch was created by following steps:

1. Replace all a38x files in U-Boot tree by files from upstream github Marvell mv-ddr-marvell repository.

2. Run following command to omit portions not relevant for a38x, ddr3, and ddr4:

files=drivers/ddr/marvell/a38x/*
sed 's/#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
-UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
-UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
-UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DTRUE $files

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Do not forget to also update commit message.

Yes, patman extracts and creates the patch description from the commit.

My reaction was just because you forgot to update undef for a39x.

I see. Yes, I did miss that! I only described the changes in v2 description.

Quoted 14 lines
Quoted 6 lines
Quoted 3 lines

And btw, commit messages has on each line some leading spaces which is not probably intended.

That was intentional to make the commit description (and patch description) more readable. Is it not recommended?

I'm not sure if we are talking about the same thing. When I read this your patch I saw that every time, even the first one "This sync drivers/..." has 4 spaces before word "This". And I'm not sure if this is just my email client or not and there is some reason for it. Look at indentation of line "Signed-off-by:" and line "Reference:". Should not be those two lines at same indentation level? Or I did not understand it? :D

Quoted 2 lines

I agree that adding indentation inside of 1. 2. 3. parts is fully recommended as it makes text more readable.

When I do git log I also see an extra 4 or 8 spaces on each line:) so not sure what we are seeing here. But yes it seems some of the indentation is inconsistent. Will fix that.

Quoted 88 lines
Quoted 30 lines
Quoted 30 lines
Quoted 29 lines

3. Manually change license to SPDX-License-Identifier (upstream license in upstream github repository contains long license texts and U-Boot is using just SPDX-License-Identifier.

After applying this patch, a38x ddr3 ddr4 code in upstream Marvell github repository and in U-Boot would be fully identical. So in future applying above steps could be used to sync code again.

The only change in this patch are:
- Removal of common board_topology_map code using ifdefs in mv_ddr_brd.c
- Some fixes with include files.
- Some basic type defines (original from ATF headers) in mv_ddr_plat.c

Reference:
"ddr: marvell: a38x: Sync code with Marvell mv-ddr-marvell repository"
https://source.denx.de/u-boot/u-boot/-/commit/107c3391b95bcc2ba09a876da4fa0c31b6c1e460

---

Changes in v2:
- Modified the filter scrip to explicitly include ARMADA_38X code
and exclude ARMADA_39X code; also remove 64BIT code. Reran it on drivers/ddr/marvell/a38x/
- Updated script
files=drivers/ddr/marvell/a38x/*
sed 's/#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files

Quoted 5 lines
Quoted 2 lines

You do not need this sed anymore. CONFIG_ARMADA_39X is explicitly removed and CONFIG_ARMADA_38X already handled by unifdef.

Thanks, I was not sure if unifdef works in that "OR" condition. I will update the commit message.

It should work if at least one of the option in OR condition is specified with -D on command line. But if you are unsure then it is better to test it (should be quite easy and fast).

Quoted 47 lines
Quoted 40 lines
Quoted 31 lines
unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
                -UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
                -UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
                -UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DCONFIG_ARMADA_38X -UCONFIG_ARMADA_39X \
                                -UCONFIG_64BIT $files

- Remove more dead code files
- Correct SPDX license header

 drivers/ddr/marvell/a38x/Makefile             |    8 +
 drivers/ddr/marvell/a38x/ddr3_debug.c         |  120 +
 drivers/ddr/marvell/a38x/ddr3_init.c          |   25 +
 drivers/ddr/marvell/a38x/ddr3_init.h          |   14 +
 drivers/ddr/marvell/a38x/ddr3_logging_def.h   |   27 +
 drivers/ddr/marvell/a38x/ddr3_training.c      |  131 +
 drivers/ddr/marvell/a38x/ddr3_training_bist.c |   12 +
 .../a38x/ddr3_training_centralization.c       |    4 +
 drivers/ddr/marvell/a38x/ddr3_training_db.c   |  212 ++
 drivers/ddr/marvell/a38x/ddr3_training_ip.h   |   17 +
 .../ddr/marvell/a38x/ddr3_training_ip_db.h    |   61 +
 .../marvell/a38x/ddr3_training_ip_engine.c    |  145 +
 .../ddr/marvell/a38x/ddr3_training_ip_flow.h  |    5 +
 .../ddr/marvell/a38x/ddr3_training_leveling.c |  135 +
 drivers/ddr/marvell/a38x/dram_if.h            |   13 -
 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c |  674 +++++
 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h |   59 +
 drivers/ddr/marvell/a38x/mv_ddr4_training.c   |  565 ++++
 drivers/ddr/marvell/a38x/mv_ddr4_training.h   |   32 +
 .../a38x/mv_ddr4_training_calibration.c       | 2336 +++++++++++++++++
 .../a38x/mv_ddr4_training_calibration.h       |   26 +
 .../ddr/marvell/a38x/mv_ddr4_training_db.c    |  545 ++++
Quoted 8 lines
 .../marvell/a38x/mv_ddr4_training_leveling.c  |  441 ++++
 .../marvell/a38x/mv_ddr4_training_leveling.h  |   11 +
 drivers/ddr/marvell/a38x/mv_ddr_plat.c        |  249 ++
 drivers/ddr/marvell/a38x/mv_ddr_plat.h        |   11 +
 drivers/ddr/marvell/a38x/mv_ddr_regs.h        |   59 +
 drivers/ddr/marvell/a38x/mv_ddr_topology.h    |   72 +
 28 files changed, 5996 insertions(+), 13 deletions(-)
 delete mode 100644 drivers/ddr/marvell/a38x/dram_if.h
Quoted 3 lines

I see that you are removing some existing file. If it is not needed neither for DDR3 nor for DDR4 then please remove it in separate commit or patch. So we do not mix different things into one commit.

Instead of making a different commit, will it work if we list the files being removed in this commit message? It is part of removing dead code.

Quoted 5 lines
Quoted 3 lines

I do not know. I'm always trying to put different thing into different commits. Reason is that if in some case it would be needed to revert commit then unrelated cleanup does not need to be reverted :-)

There is only one existing file removed (dram_if.h).

It looks like that this file is already not needed. So in separate patch this file can be removed from u-boot repository.

Quoted 82 lines

The other are new
files that become dead code after we run the filter script. Do you think those should also be kept in this patch, and then we'll have a cleanup patch later? The alternative is I can just list the new-but-deleted files in the commit description so they can be kept tracked of (easier for the future code sync if we know what should be candidates for removal).

Quoted 63 lines
Quoted 44 lines
Quoted 20 lines
Quoted 11 lines

 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_db.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.h

...

Quoted 8 lines
drivers/ddr/marvell/a38x/mv_ddr_plat.c +0 -0
index 7c7bce73a3..16d177b42f 100644
@@ -12,6 +12,11 @@
 #define DDR_INTERFACES_NUM           1
 #define DDR_INTERFACE_OCTETS_NUM     5
 
Quoted 8 lines

drivers/ddr/marvell/a38x/mv_ddr_plat.c line 19

Quoted 5 lines
drivers/ddr/marvell/a38x/mv_ddr_plat.c +5 -0
+/* These were defined in ATF area that was stripped out */
+#define MV_STATUS    int
+#define MV_U32               u32
+#define MV_U8                u8
+

This is something new which you added? Because I do not see it in Marvell code.

Yes, those were in the original code after the initial copying from the Marvell repo.

# grep -E '(MV_U32|MV_STATUS|MV_U8)' *.[ch] a38x/*.[ch]

ddr_init.c:MV_U32 ddr_init(void)
mv_ddr_atf_wrapper.h:#define MV_STATUS int mv_ddr_atf_wrapper.h:#define MV_U8 u8 mv_ddr_atf_wrapper.h:#define MV_U32 u32 a38x/mv_ddr_plat.c:MV_STATUS mv_ddr4_calibration_validate(MV_U32 dev_num) a38x/mv_ddr_plat.c: MV_STATUS status = MV_OK; a38x/mv_ddr_plat.c: MV_U8 if_id = 0;
a38x/mv_ddr_plat.c: MV_U32 read_data[MAX_INTERFACE_NUM]; a38x/mv_ddr_plat.c: MV_U32 cal_n = 0, cal_p = 0;

Quoted 5 lines

Those 3 are defined in mv_ddr_atf_wrapper.h and used in mv_ddr_plat.c (after we ran the filter script, this file is the only place that needs those 3 defines). Since we removed the ATF code, we need to define them here in mv_ddr_plat.c. Is this OK or do you have any suggestions for a better approach?

Hmm... You found another bug in Marvell code:

$ git grep mv_ddr4_calibration_validate
a38x/mv_ddr_plat.c:MV_STATUS mv_ddr4_calibration_validate(MV_U32 dev_num)
apn806/mv_ddr_plat.c:int mv_ddr4_calibration_validate(u32 dev_num)
mv_ddr4_training.c:             return mv_ddr4_calibration_validate(dev_num);
mv_ddr4_training.h:int mv_ddr4_calibration_validate(u32 dev_num);

That function mv_ddr4_calibration_validate() should return int type (as defined in header file) and not MV_STATUS type. So rather fix return type of the function to match what is in header file. Also there is mismatch with its argument u32 vs MV_u32!

Quoted 8 lines

Next, MV_U8 is used only at one place (a37xx defines it moreover locally):

$ git grep MV_U8
a3700/mv_ddr_a3700_wrapper.h:#define MV_U8              u8
a38x/mv_ddr_plat.c:     MV_U8 if_id = 0;
mv_ddr_atf_wrapper.h:#define MV_U8              u8

So replace MV_U8 directly by u8. And same for MV_U32 for a38x code.

Cool.

Quoted 8 lines
Quoted 3 lines

And ideally, send a pull request to Marvell repo with these fixes (and also with floating point), so code can be synced easily also again in future.

Would you do that when you have time after DDR4 gets merged?

Thanks,
Tony

I could, but I do not have exact changes / patches for that.

author
#6 lore raw
Quoted 153 lines · Pali Rohár
Quoted 151 lines · On Tuesday 17 January 2023 17:18:43 Tony Dinh wrote:

Hi Pali,

Quoted 31 lines · Pali Rohár

Hello!

Quoted 27 lines · On Tuesday 17 January 2023 13:02:46 Tony Dinh wrote:

Hi Pali,

Quoted 24 lines · Pali Rohár

Hello! Thank you for update. It is much better.

Quoted 19 lines · On Monday 16 January 2023 21:34:39 Tony Dinh wrote:

This syncs drivers/ddr/marvell/a38x/ with the master branch of repository
https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.git

up to the commit "mv_ddr: a3700: Use the right size for memset to not overflow" d5acc10c287e40cc2feeb28710b92e45c93c702c

This patch was created by following steps:

1. Replace all a38x files in U-Boot tree by files from upstream github Marvell mv-ddr-marvell repository.

2. Run following command to omit portions not relevant for a38x, ddr3, and ddr4:

files=drivers/ddr/marvell/a38x/*
sed 's/#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
-UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
-UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
-UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DTRUE $files

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Do not forget to also update commit message.

Yes, patman extracts and creates the patch description from the commit.

My reaction was just because you forgot to update undef for a39x.

I see. Yes, I did miss that! I only described the changes in v2 description.

Quoted 14 lines
Quoted 6 lines
Quoted 3 lines

And btw, commit messages has on each line some leading spaces which is not probably intended.

That was intentional to make the commit description (and patch description) more readable. Is it not recommended?

I'm not sure if we are talking about the same thing. When I read this your patch I saw that every time, even the first one "This sync drivers/..." has 4 spaces before word "This". And I'm not sure if this is just my email client or not and there is some reason for it. Look at indentation of line "Signed-off-by:" and line "Reference:". Should not be those two lines at same indentation level? Or I did not understand it? :D

Quoted 2 lines

I agree that adding indentation inside of 1. 2. 3. parts is fully recommended as it makes text more readable.

When I do git log I also see an extra 4 or 8 spaces on each line:) so not sure what we are seeing here. But yes it seems some of the indentation is inconsistent. Will fix that.

Quoted 88 lines
Quoted 30 lines
Quoted 30 lines
Quoted 29 lines

3. Manually change license to SPDX-License-Identifier (upstream license in upstream github repository contains long license texts and U-Boot is using just SPDX-License-Identifier.

After applying this patch, a38x ddr3 ddr4 code in upstream Marvell github repository and in U-Boot would be fully identical. So in future applying above steps could be used to sync code again.

The only change in this patch are:
- Removal of common board_topology_map code using ifdefs in mv_ddr_brd.c
- Some fixes with include files.
- Some basic type defines (original from ATF headers) in mv_ddr_plat.c

Reference:
"ddr: marvell: a38x: Sync code with Marvell mv-ddr-marvell repository"
https://source.denx.de/u-boot/u-boot/-/commit/107c3391b95bcc2ba09a876da4fa0c31b6c1e460

---

Changes in v2:
- Modified the filter scrip to explicitly include ARMADA_38X code
and exclude ARMADA_39X code; also remove 64BIT code. Reran it on drivers/ddr/marvell/a38x/
- Updated script
files=drivers/ddr/marvell/a38x/*
sed 's/#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files

Quoted 5 lines
Quoted 2 lines

You do not need this sed anymore. CONFIG_ARMADA_39X is explicitly removed and CONFIG_ARMADA_38X already handled by unifdef.

Thanks, I was not sure if unifdef works in that "OR" condition. I will update the commit message.

It should work if at least one of the option in OR condition is specified with -D on command line. But if you are unsure then it is better to test it (should be quite easy and fast).

Quoted 47 lines
Quoted 40 lines
Quoted 31 lines
unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
                -UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
                -UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
                -UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DCONFIG_ARMADA_38X -UCONFIG_ARMADA_39X \
                                -UCONFIG_64BIT $files

- Remove more dead code files
- Correct SPDX license header

 drivers/ddr/marvell/a38x/Makefile             |    8 +
 drivers/ddr/marvell/a38x/ddr3_debug.c         |  120 +
 drivers/ddr/marvell/a38x/ddr3_init.c          |   25 +
 drivers/ddr/marvell/a38x/ddr3_init.h          |   14 +
 drivers/ddr/marvell/a38x/ddr3_logging_def.h   |   27 +
 drivers/ddr/marvell/a38x/ddr3_training.c      |  131 +
 drivers/ddr/marvell/a38x/ddr3_training_bist.c |   12 +
 .../a38x/ddr3_training_centralization.c       |    4 +
 drivers/ddr/marvell/a38x/ddr3_training_db.c   |  212 ++
 drivers/ddr/marvell/a38x/ddr3_training_ip.h   |   17 +
 .../ddr/marvell/a38x/ddr3_training_ip_db.h    |   61 +
 .../marvell/a38x/ddr3_training_ip_engine.c    |  145 +
 .../ddr/marvell/a38x/ddr3_training_ip_flow.h  |    5 +
 .../ddr/marvell/a38x/ddr3_training_leveling.c |  135 +
 drivers/ddr/marvell/a38x/dram_if.h            |   13 -
 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c |  674 +++++
 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h |   59 +
 drivers/ddr/marvell/a38x/mv_ddr4_training.c   |  565 ++++
 drivers/ddr/marvell/a38x/mv_ddr4_training.h   |   32 +
 .../a38x/mv_ddr4_training_calibration.c       | 2336 +++++++++++++++++
 .../a38x/mv_ddr4_training_calibration.h       |   26 +
 .../ddr/marvell/a38x/mv_ddr4_training_db.c    |  545 ++++
Quoted 8 lines
 .../marvell/a38x/mv_ddr4_training_leveling.c  |  441 ++++
 .../marvell/a38x/mv_ddr4_training_leveling.h  |   11 +
 drivers/ddr/marvell/a38x/mv_ddr_plat.c        |  249 ++
 drivers/ddr/marvell/a38x/mv_ddr_plat.h        |   11 +
 drivers/ddr/marvell/a38x/mv_ddr_regs.h        |   59 +
 drivers/ddr/marvell/a38x/mv_ddr_topology.h    |   72 +
 28 files changed, 5996 insertions(+), 13 deletions(-)
 delete mode 100644 drivers/ddr/marvell/a38x/dram_if.h
Quoted 3 lines

I see that you are removing some existing file. If it is not needed neither for DDR3 nor for DDR4 then please remove it in separate commit or patch. So we do not mix different things into one commit.

Instead of making a different commit, will it work if we list the files being removed in this commit message? It is part of removing dead code.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

I do not know. I'm always trying to put different thing into different commits. Reason is that if in some case it would be needed to revert commit then unrelated cleanup does not need to be reverted :-)

There is only one existing file removed (dram_if.h).

It looks like that this file is already not needed. So in separate patch this file can be removed from u-boot repository.

Thanks Stefan and Pali for the review. I will send in the v3 patch and later a separate patch to remove the file.

All the best,
Tony

Quoted 93 lines
Quoted 83 lines

The other are new
files that become dead code after we run the filter script. Do you think those should also be kept in this patch, and then we'll have a cleanup patch later? The alternative is I can just list the new-but-deleted files in the commit description so they can be kept tracked of (easier for the future code sync if we know what should be candidates for removal).

Quoted 63 lines
Quoted 44 lines
Quoted 20 lines
Quoted 11 lines

 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.h
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_db.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.c
 create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.h

...

Quoted 8 lines
drivers/ddr/marvell/a38x/mv_ddr_plat.c +0 -0
index 7c7bce73a3..16d177b42f 100644
@@ -12,6 +12,11 @@
 #define DDR_INTERFACES_NUM           1
 #define DDR_INTERFACE_OCTETS_NUM     5
 
Quoted 8 lines

drivers/ddr/marvell/a38x/mv_ddr_plat.c line 19

Quoted 5 lines
drivers/ddr/marvell/a38x/mv_ddr_plat.c +5 -0
+/* These were defined in ATF area that was stripped out */
+#define MV_STATUS    int
+#define MV_U32               u32
+#define MV_U8                u8
+

This is something new which you added? Because I do not see it in Marvell code.

Yes, those were in the original code after the initial copying from the Marvell repo.

# grep -E '(MV_U32|MV_STATUS|MV_U8)' *.[ch] a38x/*.[ch]

ddr_init.c:MV_U32 ddr_init(void)
mv_ddr_atf_wrapper.h:#define MV_STATUS int mv_ddr_atf_wrapper.h:#define MV_U8 u8 mv_ddr_atf_wrapper.h:#define MV_U32 u32 a38x/mv_ddr_plat.c:MV_STATUS mv_ddr4_calibration_validate(MV_U32 dev_num) a38x/mv_ddr_plat.c: MV_STATUS status = MV_OK; a38x/mv_ddr_plat.c: MV_U8 if_id = 0;
a38x/mv_ddr_plat.c: MV_U32 read_data[MAX_INTERFACE_NUM]; a38x/mv_ddr_plat.c: MV_U32 cal_n = 0, cal_p = 0;

Quoted 5 lines

Those 3 are defined in mv_ddr_atf_wrapper.h and used in mv_ddr_plat.c (after we ran the filter script, this file is the only place that needs those 3 defines). Since we removed the ATF code, we need to define them here in mv_ddr_plat.c. Is this OK or do you have any suggestions for a better approach?

Hmm... You found another bug in Marvell code:

$ git grep mv_ddr4_calibration_validate
a38x/mv_ddr_plat.c:MV_STATUS mv_ddr4_calibration_validate(MV_U32 dev_num)
apn806/mv_ddr_plat.c:int mv_ddr4_calibration_validate(u32 dev_num)
mv_ddr4_training.c:             return mv_ddr4_calibration_validate(dev_num);
mv_ddr4_training.h:int mv_ddr4_calibration_validate(u32 dev_num);

That function mv_ddr4_calibration_validate() should return int type (as defined in header file) and not MV_STATUS type. So rather fix return type of the function to match what is in header file. Also there is mismatch with its argument u32 vs MV_u32!

Quoted 8 lines

Next, MV_U8 is used only at one place (a37xx defines it moreover locally):

$ git grep MV_U8
a3700/mv_ddr_a3700_wrapper.h:#define MV_U8              u8
a38x/mv_ddr_plat.c:     MV_U8 if_id = 0;
mv_ddr_atf_wrapper.h:#define MV_U8              u8

So replace MV_U8 directly by u8. And same for MV_U32 for a38x code.

Cool.

Quoted 8 lines
Quoted 3 lines

And ideally, send a pull request to Marvell repo with these fixes (and also with floating point), so code can be synced easily also again in future.

Would you do that when you have time after DDR4 gets merged?

Thanks,
Tony

I could, but I do not have exact changes / patches for that.

#7 lore raw
In reply to Tony Dinh

Hi Tony,

Quoted 29 lines · Tony Dinh

Hi Pali,

Quoted 17 lines · Pali Rohár

Hello! Thank you for update. It is much better.

Quoted 13 lines · On Monday 16 January 2023 21:34:39 Tony Dinh wrote:

This syncs drivers/ddr/marvell/a38x/ with the master branch of repository
https://github.com/MarvellEmbeddedProcessors/mv-ddr-marvell.git

up to the commit "mv_ddr: a3700: Use the right size for memset to not overflow" d5acc10c287e40cc2feeb28710b92e45c93c702c

This patch was created by following steps:

1. Replace all a38x files in U-Boot tree by files from upstream github Marvell mv-ddr-marvell repository.

2. Run following command to omit portions not relevant for a38x, ddr3, and ddr4:

Quoted 8 lines
Quoted 6 lines
         files=drivers/ddr/marvell/a38x/*
         sed 's/#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files
         unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
             -UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
             -UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
             -UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DTRUE $files

Do not forget to also update commit message.

Quoted 8 lines

Yes, patman extracts and creates the patch description from the commit.

Quoted 3 lines

And btw, commit messages has on each line some leading spaces which is not probably intended.

That was intentional to make the commit description (and patch description) more readable. Is it not recommended?

Readability is just fine IMHO.

Quoted 75 lines
Quoted 29 lines
Quoted 21 lines

3. Manually change license to SPDX-License-Identifier (upstream license in upstream github repository contains long license texts and U-Boot is using just SPDX-License-Identifier.

After applying this patch, a38x ddr3 ddr4 code in upstream Marvell github repository and in U-Boot would be fully identical. So in future applying above steps could be used to sync code again.

The only change in this patch are:
- Removal of common board_topology_map code using ifdefs in mv_ddr_brd.c
- Some fixes with include files.
- Some basic type defines (original from ATF headers) in mv_ddr_plat.c

Reference:
"ddr: marvell: a38x: Sync code with Marvell mv-ddr-marvell repository"
https://source.denx.de/u-boot/u-boot/-/commit/107c3391b95bcc2ba09a876da4fa0c31b6c1e460

---

Quoted 7 lines

Changes in v2:
- Modified the filter scrip to explicitly include ARMADA_38X code
and exclude ARMADA_39X code; also remove 64BIT code. Reran it on drivers/ddr/marvell/a38x/
- Updated script
files=drivers/ddr/marvell/a38x/*
sed 's/#if defined(CONFIG_ARMADA_38X) || defined(CONFIG_ARMADA_39X)/#ifdef TRUE/' -i $files

Quoted 2 lines

You do not need this sed anymore. CONFIG_ARMADA_39X is explicitly removed and CONFIG_ARMADA_38X already handled by unifdef.

Thanks, I was not sure if unifdef works in that "OR" condition. I will update the commit message.

Quoted 40 lines
Quoted 39 lines
unifdef -m -UMV_DDR -UMV_DDR_ATF -UCONFIG_APN806 \
                 -UCONFIG_MC_STATIC -UCONFIG_MC_STATIC_PRINT -UCONFIG_PHY_STATIC \
                 -UCONFIG_PHY_STATIC_PRINT -UCONFIG_CUSTOMER_BOARD_SUPPORT \
                 -UCONFIG_A3700 -UA3900 -UA80X0 -UA70X0 -DCONFIG_ARMADA_38X -UCONFIG_ARMADA_39X \
                                 -UCONFIG_64BIT $files

- Remove more dead code files
- Correct SPDX license header

  drivers/ddr/marvell/a38x/Makefile             |    8 +
  drivers/ddr/marvell/a38x/ddr3_debug.c         |  120 +
  drivers/ddr/marvell/a38x/ddr3_init.c          |   25 +
  drivers/ddr/marvell/a38x/ddr3_init.h          |   14 +
  drivers/ddr/marvell/a38x/ddr3_logging_def.h   |   27 +
  drivers/ddr/marvell/a38x/ddr3_training.c      |  131 +
  drivers/ddr/marvell/a38x/ddr3_training_bist.c |   12 +
  .../a38x/ddr3_training_centralization.c       |    4 +
  drivers/ddr/marvell/a38x/ddr3_training_db.c   |  212 ++
  drivers/ddr/marvell/a38x/ddr3_training_ip.h   |   17 +
  .../ddr/marvell/a38x/ddr3_training_ip_db.h    |   61 +
  .../marvell/a38x/ddr3_training_ip_engine.c    |  145 +
  .../ddr/marvell/a38x/ddr3_training_ip_flow.h  |    5 +
  .../ddr/marvell/a38x/ddr3_training_leveling.c |  135 +
  drivers/ddr/marvell/a38x/dram_if.h            |   13 -
  drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c |  674 +++++
  drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h |   59 +
  drivers/ddr/marvell/a38x/mv_ddr4_training.c   |  565 ++++
  drivers/ddr/marvell/a38x/mv_ddr4_training.h   |   32 +
  .../a38x/mv_ddr4_training_calibration.c       | 2336 +++++++++++++++++
  .../a38x/mv_ddr4_training_calibration.h       |   26 +
  .../ddr/marvell/a38x/mv_ddr4_training_db.c    |  545 ++++
  .../marvell/a38x/mv_ddr4_training_leveling.c  |  441 ++++
  .../marvell/a38x/mv_ddr4_training_leveling.h  |   11 +
  drivers/ddr/marvell/a38x/mv_ddr_plat.c        |  249 ++
  drivers/ddr/marvell/a38x/mv_ddr_plat.h        |   11 +
  drivers/ddr/marvell/a38x/mv_ddr_regs.h        |   59 +
  drivers/ddr/marvell/a38x/mv_ddr_topology.h    |   72 +
  28 files changed, 5996 insertions(+), 13 deletions(-)

delete mode 100644 drivers/ddr/marvell/a38x/dram_if.h

Quoted 7 lines
Quoted 3 lines

I see that you are removing some existing file. If it is not needed neither for DDR3 nor for DDR4 then please remove it in separate commit or patch. So we do not mix different things into one commit.

Instead of making a different commit, will it work if we list the files being removed in this commit message? It is part of removing dead code.

I agree with Pali on this. Please keep logically unrelated changes in separate commits if possible.

Thanks,
Stefan

Quoted 43 lines
Quoted 19 lines
Quoted 10 lines

create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_mpr_pda_if.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_calibration.h create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_db.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.c create mode 100644 drivers/ddr/marvell/a38x/mv_ddr4_training_leveling.h

...

Quoted 8 lines
drivers/ddr/marvell/a38x/mv_ddr_plat.c +0 -0
index 7c7bce73a3..16d177b42f 100644
@@ -12,6 +12,11 @@
  #define DDR_INTERFACES_NUM           1
  #define DDR_INTERFACE_OCTETS_NUM     5
 
Quoted 8 lines

drivers/ddr/marvell/a38x/mv_ddr_plat.c line 19

Quoted 5 lines
drivers/ddr/marvell/a38x/mv_ddr_plat.c +5 -0
+/* These were defined in ATF area that was stripped out */
+#define MV_STATUS    int
+#define MV_U32               u32
+#define MV_U8                u8
+

This is something new which you added? Because I do not see it in Marvell code.

Yes, those were in the original code after the initial copying from the Marvell repo.

# grep -E '(MV_U32|MV_STATUS|MV_U8)' *.[ch] a38x/*.[ch]

ddr_init.c:MV_U32 ddr_init(void)
mv_ddr_atf_wrapper.h:#define MV_STATUS int mv_ddr_atf_wrapper.h:#define MV_U8 u8 mv_ddr_atf_wrapper.h:#define MV_U32 u32 a38x/mv_ddr_plat.c:MV_STATUS mv_ddr4_calibration_validate(MV_U32 dev_num) a38x/mv_ddr_plat.c: MV_STATUS status = MV_OK; a38x/mv_ddr_plat.c: MV_U8 if_id = 0;
a38x/mv_ddr_plat.c: MV_U32 read_data[MAX_INTERFACE_NUM]; a38x/mv_ddr_plat.c: MV_U32 cal_n = 0, cal_p = 0;

Quoted 8 lines

Those 3 are defined in mv_ddr_atf_wrapper.h and used in mv_ddr_plat.c (after we ran the filter script, this file is the only place that needs those 3 defines). Since we removed the ATF code, we need to define them here in mv_ddr_plat.c. Is this OK or do you have any suggestions for a better approach?

Thanks,
Tony

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]