diff mbox series

[40/42] imx9: Calculate DDR size from DDRC setting

Message ID 20230428040847.10841-41-peng.fan@oss.nxp.com
State Accepted
Commit dace5e9fdc17786a3c4a857e63032d7d012e316d
Delegated to: Stefano Babic
Headers show
Series imx: i.MX9 update | expand

Commit Message

Peng Fan (OSS) April 28, 2023, 4:08 a.m. UTC
From: Ye Li <ye.li@nxp.com>

To avoid using static setting for ECC enabled DDR size, switch
to calculate DDR size from DDRC setting

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Jacky Bai <ping.bai@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 arch/arm/mach-imx/imx9/soc.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

Comments

Stefano Babic May 21, 2023, 5:09 p.m. UTC | #1
> From: Ye Li <ye.li@nxp.com>
> To avoid using static setting for ECC enabled DDR size, switch
> to calculate DDR size from DDRC setting
> Signed-off-by: Ye Li <ye.li@nxp.com>
> Reviewed-by: Peng Fan <peng.fan@nxp.com>
> Reviewed-by: Jacky Bai <ping.bai@nxp.com>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/arch/arm/mach-imx/imx9/soc.c b/arch/arm/mach-imx/imx9/soc.c
index 22152172169..f1c74550f3f 100644
--- a/arch/arm/mach-imx/imx9/soc.c
+++ b/arch/arm/mach-imx/imx9/soc.c
@@ -36,6 +36,7 @@ 
 #include <asm/arch-imx/cpu.h>
 #include <asm/mach-imx/s400_api.h>
 #include <fuse.h>
+#include <asm/arch/ddr.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -327,14 +328,26 @@  void enable_caches(void)
 
 __weak int board_phys_sdram_size(phys_size_t *size)
 {
+	phys_size_t start, end;
+	phys_size_t val;
+
 	if (!size)
 		return -EINVAL;
 
-	*size = PHYS_SDRAM_SIZE;
+	val = readl(REG_DDR_CS0_BNDS);
+	start = (val >> 16) << 24;
+	end   = (val & 0xFFFF);
+	end   = end ? end + 1 : 0;
+	end   = end << 24;
+	*size = end - start;
+
+	val = readl(REG_DDR_CS1_BNDS);
+	start = (val >> 16) << 24;
+	end   = (val & 0xFFFF);
+	end   = end ? end + 1 : 0;
+	end   = end << 24;
+	*size += end - start;
 
-#ifdef PHYS_SDRAM_2_SIZE
-	*size += PHYS_SDRAM_2_SIZE;
-#endif
 	return 0;
 }