[PATCH v2 1/6] drivers: ddr: altera: Add DRAM size checking for arria10

Naresh Kumar Ravulapalli nareshkumar.ravulapalli at altera.com
Mon May 26 20:03:23 CEST 2025


Add DRAM size checking compare between size from device tree and actual
hardware.

Display warning message if DRAM size mismatch between device tree and
actual hardware. Use DRAM size from hardware if device tree value is
greater than actual hardware value.

Signed-off-by: Naresh Kumar Ravulapalli <nareshkumar.ravulapalli at altera.com>
---
 drivers/ddr/altera/sdram_arria10.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/ddr/altera/sdram_arria10.c b/drivers/ddr/altera/sdram_arria10.c
index d3305a6c82d..088dc1cb33f 100644
--- a/drivers/ddr/altera/sdram_arria10.c
+++ b/drivers/ddr/altera/sdram_arria10.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (C) 2017 Intel Corporation <www.intel.com>
+ * Copyright (C) 2025 Altera Corporation <www.altera.com>
  */
 
 #include <cpu_func.h>
@@ -702,6 +703,19 @@ int ddr_calibration_sequence(void)
 	/* setup the dram info within bd */
 	dram_init_banksize();
 
+	if (gd->ram_size != gd->bd->bi_dram[0].size) {
+		printf("DDR: Warning: DRAM size from device tree (%ld MiB)\n",
+		       gd->bd->bi_dram[0].size >> 20);
+		printf(" mismatch with hardware (%ld MiB).\n",
+		       gd->ram_size >> 20);
+	}
+
+	if (gd->bd->bi_dram[0].size > gd->ram_size) {
+		printf("DDR: Warning: DRAM size from device tree > hardware size.\n");
+		printf("Hence, initializing DRAM size to hardware DRAM size.\n");
+		gd->bd->bi_dram[0].size = gd->ram_size;
+	}
+
 	if (of_sdram_firewall_setup(gd->fdt_blob))
 		puts("FW: Error Configuring Firewall\n");
 
-- 
2.35.3



More information about the U-Boot mailing list