Merge tag 'u-boot-nand-20230417' of https://source.denx.de/u-boot/custodians/u-boot...
[platform/kernel/u-boot.git] / common / board_f.c
index faa0964..1688e27 100644 (file)
@@ -290,7 +290,10 @@ static int setup_mon_len(void)
 {
 #if defined(__ARM__) || defined(__MICROBLAZE__)
        gd->mon_len = (ulong)&__bss_end - (ulong)_start;
+#elif defined(CONFIG_SANDBOX) && !defined(__riscv)
+       gd->mon_len = (ulong)&_end - (ulong)_init;
 #elif defined(CONFIG_SANDBOX)
+       /* gcc does not provide _init in crti.o on RISC-V */
        gd->mon_len = 0;
 #elif defined(CONFIG_EFI_APP)
        gd->mon_len = (ulong)&_end - (ulong)_init;
@@ -329,12 +332,12 @@ __weak int mach_cpu_init(void)
 /* Get the top of usable RAM */
 __weak phys_size_t board_get_usable_ram_top(phys_size_t total_size)
 {
-#if defined(CONFIG_SYS_SDRAM_BASE) && CONFIG_SYS_SDRAM_BASE > 0
+#if defined(CFG_SYS_SDRAM_BASE) && CFG_SYS_SDRAM_BASE > 0
        /*
         * Detect whether we have so much RAM that it goes past the end of our
         * 32-bit address space. If so, clip the usable RAM so it doesn't.
         */
-       if (gd->ram_top < CONFIG_SYS_SDRAM_BASE)
+       if (gd->ram_top < CFG_SYS_SDRAM_BASE)
                /*
                 * Will wrap back to top of 32-bit space when reservations
                 * are made.
@@ -369,8 +372,8 @@ static int setup_dest_addr(void)
         */
        gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE;
 #endif
-#ifdef CONFIG_SYS_SDRAM_BASE
-       gd->ram_base = CONFIG_SYS_SDRAM_BASE;
+#ifdef CFG_SYS_SDRAM_BASE
+       gd->ram_base = CFG_SYS_SDRAM_BASE;
 #endif
        gd->ram_top = gd->ram_base + get_effective_memsize();
        gd->ram_top = board_get_usable_ram_top(gd->mon_len);
@@ -380,19 +383,19 @@ static int setup_dest_addr(void)
        return arch_setup_dest_addr();
 }
 
-#ifdef CONFIG_PRAM
+#ifdef CFG_PRAM
 /* reserve protected RAM */
 static int reserve_pram(void)
 {
        ulong reg;
 
-       reg = env_get_ulong("pram", 10, CONFIG_PRAM);
+       reg = env_get_ulong("pram", 10, CFG_PRAM);
        gd->relocaddr -= (reg << 10);           /* size is in kB */
        debug("Reserving %ldk for protected RAM at %08lx\n", reg,
              gd->relocaddr);
        return 0;
 }
-#endif /* CONFIG_PRAM */
+#endif /* CFG_PRAM */
 
 /* Round memory pointer down to next 4 kB limit */
 static int reserve_round_4k(void)
@@ -475,8 +478,8 @@ static int reserve_noncached(void)
 {
        /*
         * The value of gd->start_addr_sp must match the value of malloc_start
-        * calculated in boatrd_f.c:initr_malloc(), which is passed to
-        * board_r.c:mem_malloc_init() and then used by
+        * calculated in board_r.c:initr_malloc(), which is passed to
+        * dlmalloc.c:mem_malloc_init() and then used by
         * cache.c:noncached_init()
         *
         * These calculations must match the code in cache.c:noncached_init()
@@ -839,7 +842,6 @@ static const init_fnc_t init_sequence_f[] = {
        initf_malloc,
        log_init,
        initf_bootstage,        /* uses its own timer, so does not need DM */
-       cyclic_init,
        event_init,
 #ifdef CONFIG_BLOBLIST
        bloblist_init,
@@ -861,7 +863,7 @@ static const init_fnc_t init_sequence_f[] = {
        /* get CPU and bus clocks according to the environment variable */
        get_clocks,             /* get CPU and bus clocks (etc.) */
 #endif
-#if !defined(CONFIG_M68K)
+#if !defined(CONFIG_M68K) || (defined(CONFIG_M68K) && !defined(CONFIG_MCFTMR))
        timer_init,             /* initialize timer */
 #endif
 #if defined(CONFIG_BOARD_POSTCLK_INIT)
@@ -901,9 +903,9 @@ static const init_fnc_t init_sequence_f[] = {
        post_init_f,
 #endif
        INIT_FUNC_WATCHDOG_RESET
-#if defined(CONFIG_SYS_DRAM_TEST)
+#if defined(CFG_SYS_DRAM_TEST)
        testdram,
-#endif /* CONFIG_SYS_DRAM_TEST */
+#endif /* CFG_SYS_DRAM_TEST */
        INIT_FUNC_WATCHDOG_RESET
 
 #ifdef CONFIG_POST
@@ -926,7 +928,7 @@ static const init_fnc_t init_sequence_f[] = {
 #ifdef CONFIG_OF_BOARD_FIXUP
        fix_fdt,
 #endif
-#ifdef CONFIG_PRAM
+#ifdef CFG_PRAM
        reserve_pram,
 #endif
        reserve_round_4k,
@@ -957,6 +959,16 @@ static const init_fnc_t init_sequence_f[] = {
        do_elf_reloc_fixups,
 #endif
        clear_bss,
+       /*
+        * Deregister all cyclic functions before relocation, so that
+        * gd->cyclic_list does not contain any references to pre-relocation
+        * devices. Drivers will register their cyclic functions anew when the
+        * devices are probed again.
+        *
+        * This should happen as late as possible so that the window where a
+        * watchdog device is not serviced is as small as possible.
+        */
+       cyclic_unregister_all,
 #if !defined(CONFIG_ARM) && !defined(CONFIG_SANDBOX) && \
                !CONFIG_IS_ENABLED(X86_64)
        jump_to_copy,