diff options
| author | Alif Zakuan Yuslaimi <[email protected]> | 2025-12-16 00:46:22 -0800 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-02-14 11:06:46 -0600 |
| commit | 847e67582b1f0eee85e8f1aa7f5a7a3a41286288 (patch) | |
| tree | f377cb2b6436aed63193fc8fac2fe74f7ffb3d49 /drivers | |
| parent | 83f2843f20f171122a9d70ec04049e74042ec7e1 (diff) | |
ddr: altera: arria10: Add DRAM size checking
Add DRAM size checking compare between size from device tree and actual
hardware.
Trigger hang if DRAM size from device tree is greater than actual hardware.
Display warning message if DRAM size mismatch between device tree and
actual hardware.
Signed-off-by: Alif Zakuan Yuslaimi <[email protected]>
Reviewed-by: Tien Fong Chee <[email protected]> Best regards,
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/ddr/altera/sdram_arria10.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/ddr/altera/sdram_arria10.c b/drivers/ddr/altera/sdram_arria10.c index d3305a6c82d..c281f711fdf 100644 --- a/drivers/ddr/altera/sdram_arria10.c +++ b/drivers/ddr/altera/sdram_arria10.c @@ -8,6 +8,7 @@ #include <fdtdec.h> #include <init.h> #include <log.h> +#include <hang.h> #include <malloc.h> #include <wait_bit.h> #include <watchdog.h> @@ -667,6 +668,22 @@ static int of_sdram_firewall_setup(const void *blob) return 0; } +static void sdram_size_check(void) +{ + phys_size_t ram_check = 0; + + debug("DDR: Running SDRAM size sanity check\n"); + + ram_check = get_ram_size((long *)gd->bd->bi_dram[0].start, + gd->bd->bi_dram[0].size); + if (ram_check != gd->bd->bi_dram[0].size) { + puts("DDR: SDRAM size check failed!\n"); + hang(); + } + + debug("DDR: SDRAM size check passed!\n"); +} + int ddr_calibration_sequence(void) { schedule(); @@ -702,11 +719,26 @@ 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: Error: DRAM size from device tree is greater\n"); + printf(" than hardware size.\n"); + hang(); + } + if (of_sdram_firewall_setup(gd->fdt_blob)) puts("FW: Error Configuring Firewall\n"); if (sdram_is_ecc_enabled()) sdram_init_ecc_bits(gd->ram_size); + sdram_size_check(); + return 0; } |
