@@ -8,6 +8,7 @@
#include <dm.h>
#include <errno.h>
#include <fdtdec.h>
+#include <hang.h>
#include <malloc.h>
#include <ram.h>
#include <reset.h>
@@ -17,7 +18,7 @@
#include <asm/arch/fpga_manager.h>
#include <asm/arch/misc.h>
#include <dm/device_compat.h>
-#include <linux/kernel.h>
+#include <linux/sizes.h>
#include "sdram_arria10.h"
@@ -671,6 +672,21 @@ static int ddr_calibration_sequence(struct altera_sdram_platdata *plat)
return 0;
}
+static void sdram_size_check(struct ram_info *ram)
+{
+ phys_size_t ram_check = 0;
+
+ debug("DDR: Running SDRAM size sanity check\n");
+
+ ram_check = get_ram_size((void *)(ram->base), ram->size);
+ if (ram_check != ram->size) {
+ puts("DDR: SDRAM size check failed!\n");
+ hang();
+ }
+
+ debug("DDR: SDRAM size check passed!\n");
+}
+
static int altera_sdram_ofdata_to_platdata(struct udevice *dev)
{
struct altera_sdram_platdata *plat = dev->platdata;
@@ -715,6 +731,7 @@ static int altera_sdram_probe(struct udevice *dev)
priv->info.base = gd->bd->bi_dram[0].start;
priv->info.size = gd->ram_size;
+ sdram_size_check(&priv->info);
return 0;
failed:
Add call to get_ram_size() function to check memory range for valid RAM. Signed-off-by: Ley Foon Tan <ley.foon.tan at intel.com> --- v2: - Change SZ_1G to full SDRAM size in get_ram_size() argument. --- drivers/ddr/altera/sdram_arria10.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)