Skip to contentSkip to conversation

imx: Use per board ddrphy_trained_csr

PATCH In review Peng Fan (OSS) 2 participants 2 messages Dec 23, 2024

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

PATCH 1/1 imx: Use per board ddrphy_trained_csr

From: Peng Fan <[email protected]>

Drop global ddrphy_trained_csr which maybe different with per board ddrphy_trained_csr. DDR TOOL generates ddrphy_trained_csr for each board, using the global ddrphy_trained_csr has risk that values may be not up to date.

---
 arch/arm/include/asm/arch-imx8m/ddr.h |   3 -
 arch/arm/include/asm/arch-imx9/ddr.h  |   3 -
 drivers/ddr/imx/phy/Makefile          |   2 +-
 drivers/ddr/imx/phy/ddrphy_csr.c      | 732 --------------------------
 drivers/ddr/imx/phy/ddrphy_train.c    |   3 +-
 drivers/ddr/imx/phy/helper.c          |   8 +-
 6 files changed, 7 insertions(+), 744 deletions(-)
 delete mode 100644 drivers/ddr/imx/phy/ddrphy_csr.c
arch/arm/include/asm/arch-imx8m/ddr.h +0 -3
index 1f81d91977c..5092ccae188 100644
@@ -747,7 +747,4 @@ static inline void reg32setbit(unsigned long addr, u32 bit)
 #define dwc_ddrphy_apb_rd(addr) \
 	reg32_read(IP2APB_DDRPHY_IPS_BASE_ADDR(0) + ddrphy_addr_remap(addr))
 
-extern struct dram_cfg_param ddrphy_trained_csr[];
-extern uint32_t ddrphy_trained_csr_num;
-
 #endif
arch/arm/include/asm/arch-imx9/ddr.h +0 -3
index 2b22f3a5bea..0dd2d62b9ef 100644
@@ -141,7 +141,4 @@ static inline void reg32setbit(unsigned long addr, u32 bit)
 #define dwc_ddrphy_apb_rd(addr) \
 	reg32_read(IP2APB_DDRPHY_IPS_BASE_ADDR(0) + ddrphy_addr_remap(addr))
 
-extern struct dram_cfg_param ddrphy_trained_csr[];
-extern u32 ddrphy_trained_csr_num;
-
 #endif
drivers/ddr/imx/phy/Makefile +1 -1
index 592d0c6ebad..95c93ba16d5 100644
@@ -5,5 +5,5 @@
 #
 
 ifdef CONFIG_XPL_BUILD
-obj-$(CONFIG_IMX_SNPS_DDR_PHY) += helper.o ddrphy_utils.o ddrphy_train.o ddrphy_csr.o
+obj-$(CONFIG_IMX_SNPS_DDR_PHY) += helper.o ddrphy_utils.o ddrphy_train.o
 endif
drivers/ddr/imx/phy/ddrphy_csr.c deleted +0 -732

732 lines not on this page · raw message

drivers/ddr/imx/phy/ddrphy_train.c +2 -1
index 2a2161dec33..1a2d071d6f1 100644
@@ -90,7 +90,8 @@ int ddr_cfg_phy(struct dram_timing_info *dram_timing)
 	}
 
 	/* save the ddr PHY trained CSR in memory for low power use */
-	ddrphy_trained_csr_save(ddrphy_trained_csr, ddrphy_trained_csr_num);
+	ddrphy_trained_csr_save(dram_timing->ddrphy_trained_csr,
+				dram_timing->ddrphy_trained_csr_num);
 
 	return 0;
 }
drivers/ddr/imx/phy/helper.c +4 -4
index c1fc800f191..b0dfc3a0b4f 100644
@@ -181,7 +181,7 @@ void *dram_config_save(struct dram_timing_info *timing_info, unsigned long saved
 
 	saved_timing->ddrc_cfg_num = timing_info->ddrc_cfg_num;
 	saved_timing->ddrphy_cfg_num = timing_info->ddrphy_cfg_num;
-	saved_timing->ddrphy_trained_csr_num = ddrphy_trained_csr_num;
+	saved_timing->ddrphy_trained_csr_num = timing_info->ddrphy_trained_csr_num;
 	saved_timing->ddrphy_pie_num = timing_info->ddrphy_pie_num;
 
 	/* save the fsp table */
@@ -209,9 +209,9 @@ void *dram_config_save(struct dram_timing_info *timing_info, unsigned long saved
 
 	/* save the ddrphy csr */
 	saved_timing->ddrphy_trained_csr = cfg;
-	for (i = 0; i < ddrphy_trained_csr_num; i++) {
-		cfg->reg = ddrphy_trained_csr[i].reg;
-		cfg->val = ddrphy_trained_csr[i].val;
+	for (i = 0; i < timing_info->ddrphy_trained_csr_num; i++) {
+		cfg->reg = timing_info->ddrphy_trained_csr[i].reg;
+		cfg->val = timing_info->ddrphy_trained_csr[i].val;
 		cfg++;
 	}
 
Signature · 1 line
2.35.3
reviewer
#1 lore raw
Quoted 9 lines · Peng Fan (OSS)

From: Peng Fan <[email protected]>

Drop global ddrphy_trained_csr which maybe different with per board ddrphy_trained_csr. DDR TOOL generates ddrphy_trained_csr for each board, using the global ddrphy_trained_csr has risk that values may be not up to date.

Applied to u-boot-imx/next, thanks.