Merge tag 'u-boot-atmel-fixes-2021.01-b' of https://gitlab.denx.de/u-boot/custodians...
[platform/kernel/u-boot.git] / arch / arm / mach-stm32mp / spl.c
index c6ae73d..66a6346 100644 (file)
@@ -4,9 +4,16 @@
  */
 
 #include <common.h>
+#include <cpu_func.h>
 #include <dm.h>
+#include <hang.h>
+#include <init.h>
+#include <log.h>
 #include <spl.h>
+#include <asm/cache.h>
 #include <asm/io.h>
+#include <asm/arch/sys_proto.h>
+#include <linux/libfdt.h>
 
 u32 spl_boot_device(void)
 {
@@ -36,17 +43,20 @@ u32 spl_boot_device(void)
                return BOOT_DEVICE_NAND;
        case BOOT_FLASH_NOR_QSPI:
                return BOOT_DEVICE_SPI;
+       case BOOT_FLASH_SPINAND_1:
+               return BOOT_DEVICE_NONE; /* SPINAND not supported in SPL */
        }
 
        return BOOT_DEVICE_MMC1;
 }
 
-u32 spl_boot_mode(const u32 boot_device)
+u32 spl_mmc_boot_mode(const u32 boot_device)
 {
        return MMCSD_MODE_RAW;
 }
 
-int spl_boot_partition(const u32 boot_device)
+#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
+int spl_mmc_boot_partition(const u32 boot_device)
 {
        switch (boot_device) {
        case BOOT_DEVICE_MMC1:
@@ -57,6 +67,27 @@ int spl_boot_partition(const u32 boot_device)
                return -EINVAL;
        }
 }
+#endif
+
+#ifdef CONFIG_SPL_DISPLAY_PRINT
+void spl_display_print(void)
+{
+       DECLARE_GLOBAL_DATA_PTR;
+       const char *model;
+
+       /* same code than show_board_info() but not compiled for SPL
+        * see CONFIG_DISPLAY_BOARDINFO & common/board_info.c
+        */
+       model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
+       if (model)
+               printf("Model: %s\n", model);
+}
+#endif
+
+__weak int board_early_init_f(void)
+{
+       return 0;
+}
 
 void board_init_f(ulong dummy)
 {
@@ -74,27 +105,52 @@ void board_init_f(ulong dummy)
        ret = uclass_get_device(UCLASS_CLK, 0, &dev);
        if (ret) {
                debug("Clock init failed: %d\n", ret);
-               return;
+               hang();
        }
 
        ret = uclass_get_device(UCLASS_RESET, 0, &dev);
        if (ret) {
                debug("Reset init failed: %d\n", ret);
-               return;
+               hang();
        }
 
        ret = uclass_get_device(UCLASS_PINCTRL, 0, &dev);
        if (ret) {
                debug("%s: Cannot find pinctrl device\n", __func__);
-               return;
+               hang();
        }
 
        /* enable console uart printing */
        preloader_console_init();
 
+       ret = board_early_init_f();
+       if (ret) {
+               debug("board_early_init_f() failed: %d\n", ret);
+               hang();
+       }
+
        ret = uclass_get_device(UCLASS_RAM, 0, &dev);
        if (ret) {
-               debug("DRAM init failed: %d\n", ret);
-               return;
+               printf("DRAM init failed: %d\n", ret);
+               hang();
        }
+
+       /*
+        * activate cache on DDR only when DDR is fully initialized
+        * to avoid speculative access and issue in get_ram_size()
+        */
+       if (!CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
+               mmu_set_region_dcache_behaviour(STM32_DDR_BASE,
+                                               CONFIG_DDR_CACHEABLE_SIZE,
+                                               DCACHE_DEFAULT_OPTION);
+}
+
+void spl_board_prepare_for_boot(void)
+{
+       dcache_disable();
+}
+
+void spl_board_prepare_for_linux(void)
+{
+       dcache_disable();
 }