Merge git://git.denx.de/u-boot-socfpga
[platform/kernel/u-boot.git] / common / spl / spl.c
index 0a49766..c56cc6f 100644 (file)
@@ -121,9 +121,6 @@ void spl_set_header_raw_uboot(struct spl_image_info *spl_image)
 {
        spl_image->size = CONFIG_SYS_MONITOR_LEN;
        spl_image->entry_point = CONFIG_SYS_UBOOT_START;
-#ifdef CONFIG_CPU_V7M
-       spl_image->entry_point |= 0x1;
-#endif
        spl_image->load_addr = CONFIG_SYS_TEXT_BASE;
        spl_image->os = IH_OS_U_BOOT;
        spl_image->name = "U-Boot";
@@ -223,15 +220,22 @@ static int spl_common_init(bool setup_malloc)
 
        debug("spl_early_init()\n");
 
-#if defined(CONFIG_SYS_MALLOC_F_LEN)
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
        if (setup_malloc) {
 #ifdef CONFIG_MALLOC_F_ADDR
                gd->malloc_base = CONFIG_MALLOC_F_ADDR;
 #endif
-               gd->malloc_limit = CONFIG_SYS_MALLOC_F_LEN;
+               gd->malloc_limit = CONFIG_VAL(SYS_MALLOC_F_LEN);
                gd->malloc_ptr = 0;
        }
 #endif
+       ret = bootstage_init(true);
+       if (ret) {
+               debug("%s: Failed to set up bootstage: ret=%d\n", __func__,
+                     ret);
+               return ret;
+       }
+       bootstage_mark_name(BOOTSTAGE_ID_START_SPL, "spl");
        if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
                ret = fdtdec_setup();
                if (ret) {
@@ -240,8 +244,10 @@ static int spl_common_init(bool setup_malloc)
                }
        }
        if (IS_ENABLED(CONFIG_SPL_DM)) {
+               bootstage_start(BOOTSTATE_ID_ACCUM_DM_SPL, "dm_spl");
                /* With CONFIG_SPL_OF_PLATDATA, bring in all devices */
                ret = dm_init_and_scan(!CONFIG_IS_ENABLED(OF_PLATDATA));
+               bootstage_accum(BOOTSTATE_ID_ACCUM_DM_SPL);
                if (ret) {
                        debug("dm_init_and_scan() returned error %d\n", ret);
                        return ret;
@@ -396,6 +402,9 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
                hang();
        }
 
+#ifdef CONFIG_CPU_V7M
+       spl_image.entry_point |= 0x1;
+#endif
        switch (spl_image.os) {
        case IH_OS_U_BOOT:
                debug("Jumping to U-Boot\n");
@@ -410,7 +419,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
        default:
                debug("Unsupported OS image.. Jumping nevertheless..\n");
        }
-#if defined(CONFIG_SYS_MALLOC_F_LEN) && !defined(CONFIG_SYS_SPL_MALLOC_SIZE)
+#if CONFIG_VAL(SYS_MALLOC_F_LEN) && !defined(CONFIG_SYS_SPL_MALLOC_SIZE)
        debug("SPL malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
              gd->malloc_ptr / 1024);
 #endif
@@ -421,6 +430,15 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
        }
 
        debug("loaded - jumping to U-Boot...\n");
+#ifdef CONFIG_BOOTSTAGE_STASH
+       int ret;
+
+       bootstage_mark_name(BOOTSTAGE_ID_END_SPL, "end_spl");
+       ret = bootstage_stash((void *)CONFIG_BOOTSTAGE_STASH_ADDR,
+                             CONFIG_BOOTSTAGE_STASH_SIZE);
+       if (ret)
+               debug("Failed to stash bootstage: err=%d\n", ret);
+#endif
        spl_board_prepare_for_boot();
        jump_to_image_no_args(&spl_image);
 }
@@ -468,7 +486,7 @@ ulong spl_relocate_stack_gd(void)
        gd_t *new_gd;
        ulong ptr = CONFIG_SPL_STACK_R_ADDR;
 
-#ifdef CONFIG_SPL_SYS_MALLOC_SIMPLE
+#if defined(CONFIG_SPL_SYS_MALLOC_SIMPLE) && CONFIG_SPL_SYS_MALLOC_F_LEN
        if (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN) {
                ptr -= CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN;
                gd->malloc_base = ptr;