]> Git Repo - J-u-boot.git/blobdiff - common/board_r.c
common: Remove <common.h> and add needed includes
[J-u-boot.git] / common / board_r.c
index 98653de0553b61214105628677d7b039b21e74f6..c823cd262f16e0d7b038bea3b1f120beb2a1d56e 100644 (file)
@@ -9,7 +9,7 @@
  * Marius Groeger <[email protected]>
  */
 
-#include <common.h>
+#include <config.h>
 #include <api.h>
 #include <bootstage.h>
 #include <cpu_func.h>
@@ -126,9 +126,9 @@ static int initr_reloc_global_data(void)
 #ifdef __ARM__
        monitor_flash_len = _end - __image_copy_start;
 #elif defined(CONFIG_RISCV)
-       monitor_flash_len = (ulong)&_end - (ulong)&_start;
+       monitor_flash_len = (ulong)_end - (ulong)_start;
 #elif !defined(CONFIG_SANDBOX) && !defined(CONFIG_NIOS2)
-       monitor_flash_len = (ulong)&__init_end - gd->relocaddr;
+       monitor_flash_len = (ulong)__init_end - gd->relocaddr;
 #endif
 #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx)
        /*
@@ -151,13 +151,6 @@ static int initr_reloc_global_data(void)
         */
        gd->env_addr += gd->reloc_off;
 #endif
-       /*
-        * The fdt_blob needs to be moved to new relocation address
-        * incase of FDT blob is embedded with in image
-        */
-       if (CONFIG_IS_ENABLED(OF_EMBED) && CONFIG_IS_ENABLED(NEEDS_MANUAL_RELOC))
-               gd->fdt_blob += gd->reloc_off;
-
 #ifdef CONFIG_EFI_LOADER
        /*
         * On the ARM architecture gd is mapped to a fixed register (r9 or x18).
@@ -196,9 +189,9 @@ static int initr_barrier(void)
 
 static int initr_malloc(void)
 {
-       ulong malloc_start;
+       ulong start;
 
-#if CONFIG_VAL(SYS_MALLOC_F_LEN)
+#if CONFIG_IS_ENABLED(SYS_MALLOC_F)
        debug("Pre-reloc malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
              gd->malloc_ptr / 1024);
 #endif
@@ -207,8 +200,9 @@ static int initr_malloc(void)
         * This value MUST match the value of gd->start_addr_sp in board_f.c:
         * reserve_noncached().
         */
-       malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN;
-       mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN),
+       start = gd->relocaddr - TOTAL_MALLOC_LEN;
+       gd_set_malloc_start(start);
+       mem_malloc_init((ulong)map_sysmem(start, TOTAL_MALLOC_LEN),
                        TOTAL_MALLOC_LEN);
        return 0;
 }
@@ -294,15 +288,6 @@ static int initr_announce(void)
        return 0;
 }
 
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-static int initr_manual_reloc_cmdtable(void)
-{
-       fixup_cmdtable(ll_entry_start(struct cmd_tbl, cmd),
-                      ll_entry_count(struct cmd_tbl, cmd));
-       return 0;
-}
-#endif
-
 static int initr_binman(void)
 {
        int ret;
@@ -346,7 +331,7 @@ static int initr_flash(void)
         * NOTE: Maybe we should add some schedule()? XXX
         */
        if (env_get_yesno("flashchecksum") == 1) {
-               const uchar *flash_base = (const uchar *)CONFIG_SYS_FLASH_BASE;
+               const uchar *flash_base = (const uchar *)CFG_SYS_FLASH_BASE;
 
                printf("  CRC: %08X", crc32(0,
                                            flash_base,
@@ -356,8 +341,8 @@ static int initr_flash(void)
        putc('\n');
 
        /* update start of FLASH memory    */
-#ifdef CONFIG_SYS_FLASH_BASE
-       bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
+#ifdef CFG_SYS_FLASH_BASE
+       bd->bi_flashstart = CFG_SYS_FLASH_BASE;
 #endif
        /* size of FLASH memory (final value) */
        bd->bi_flashsize = flash_size;
@@ -370,7 +355,7 @@ static int initr_flash(void)
 #if defined(CONFIG_OXC) || defined(CONFIG_RMU)
        /* flash mapped at end of memory map */
        bd->bi_flashoffset = CONFIG_TEXT_BASE + flash_size;
-#elif CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE
+#elif CONFIG_SYS_MONITOR_BASE == CFG_SYS_FLASH_BASE
        bd->bi_flashoffset = monitor_flash_len; /* reserved area for monitor */
 #endif
        return 0;
@@ -452,8 +437,8 @@ static int initr_env(void)
                env_set_hex("fdtcontroladdr",
                            (unsigned long)map_to_sysmem(gd->fdt_blob));
 
-       #if (CONFIG_IS_ENABLED(SAVE_PREV_BL_INITRAMFS_START_ADDR) || \
-                                               CONFIG_IS_ENABLED(SAVE_PREV_BL_FDT_ADDR))
+       #if (IS_ENABLED(CONFIG_SAVE_PREV_BL_INITRAMFS_START_ADDR) || \
+                                               IS_ENABLED(CONFIG_SAVE_PREV_BL_FDT_ADDR))
                save_prev_bl_data();
        #endif
 
@@ -487,17 +472,6 @@ static int initr_status_led(void)
 }
 #endif
 
-#if defined(CONFIG_SCSI) && !defined(CONFIG_DM_SCSI)
-static int initr_scsi(void)
-{
-       puts("SCSI:  ");
-       scsi_init();
-       puts("\n");
-
-       return 0;
-}
-#endif
-
 #ifdef CONFIG_CMD_NET
 static int initr_net(void)
 {
@@ -519,21 +493,7 @@ static int initr_post(void)
 }
 #endif
 
-#if defined(CONFIG_IDE) && !defined(CONFIG_BLK)
-static int initr_ide(void)
-{
-       puts("IDE:   ");
-#if defined(CONFIG_START_IDE)
-       if (board_start_ide())
-               ide_init();
-#else
-       ide_init();
-#endif
-       return 0;
-}
-#endif
-
-#if defined(CONFIG_PRAM)
+#if defined(CFG_PRAM)
 /*
  * Export available size of memory for Linux, taking into account the
  * protected RAM at top of memory
@@ -543,7 +503,7 @@ int initr_mem(void)
        ulong pram = 0;
        char memsz[32];
 
-       pram = env_get_ulong("pram", 10, CONFIG_PRAM);
+       pram = env_get_ulong("pram", 10, CFG_PRAM);
        sprintf(memsz, "%ldk", (long int)((gd->ram_size / 1024) - pram));
        env_set("mem", memsz);
 
@@ -569,6 +529,13 @@ static int dm_announce(void)
                        printf("Warning: Unexpected devicetree source (not from a prior stage)");
                        printf("Warning: U-Boot may not function properly\n");
                }
+               if (IS_ENABLED(CONFIG_OF_TAG_MIGRATE) &&
+                   (gd->flags & GD_FLG_OF_TAG_MIGRATE))
+                       /*
+                        * U-Boot will silently fail to work after 2023.07 if
+                        * there are old tags present
+                        */
+                       printf("Warning: Device tree includes old 'u-boot,dm-' tags: please fix by 2023.07!\n");
        }
 
        return 0;
@@ -579,6 +546,9 @@ static int run_main_loop(void)
 #ifdef CONFIG_SANDBOX
        sandbox_main_loop_init();
 #endif
+
+       event_notify_null(EVT_MAIN_LOOP);
+
        /* main_loop() can return to retry autoboot, if so just run it again */
        for (;;)
                main_loop();
@@ -586,7 +556,10 @@ static int run_main_loop(void)
 }
 
 /*
- * We hope to remove most of the driver-related init and do it if/when
+ * Over time we hope to remove these functions with code fragments and
+ * stub functions, and instead call the relevant function directly.
+ *
+ * We also hope to remove most of the driver-related init and do it if/when
  * the driver is later used.
  *
  * TODO: perhaps reset the watchdog in the initcall function after each call?
@@ -606,15 +579,11 @@ static init_fnc_t init_sequence_r[] = {
         */
 #endif
        initr_reloc_global_data,
-#if CONFIG_IS_ENABLED(NEEDS_MANUAL_RELOC) && CONFIG_IS_ENABLED(EVENT)
-       event_manual_reloc,
-#endif
 #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500)
        initr_unlock_ram_in_cache,
 #endif
        initr_barrier,
        initr_malloc,
-       cyclic_init,
        log_init,
        initr_bootstage,        /* Needs malloc() but has its own timer */
 #if defined(CONFIG_CONSOLE_RECORD)
@@ -658,12 +627,6 @@ static init_fnc_t init_sequence_r[] = {
        initr_watchdog,
 #endif
        INIT_FUNC_WATCHDOG_RESET
-#if defined(CONFIG_NEEDS_MANUAL_RELOC) && defined(CONFIG_BLOCK_CACHE)
-       blkcache_init,
-#endif
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-       initr_manual_reloc_cmdtable,
-#endif
        arch_initr_trap,
 #if defined(CONFIG_BOARD_EARLY_INIT_R)
        board_early_init_r,
@@ -692,7 +655,7 @@ static init_fnc_t init_sequence_r[] = {
        /* initialize higher level parts of CPU like time base and timers */
        cpu_init_r,
 #endif
-#ifdef CONFIG_EFI_SETUP_EARLY
+#ifdef CONFIG_EFI_LOADER
        efi_init_early,
 #endif
 #ifdef CONFIG_CMD_NAND
@@ -719,6 +682,7 @@ static init_fnc_t init_sequence_r[] = {
 #if defined(CONFIG_ID_EEPROM)
        mac_read_from_eeprom,
 #endif
+       INITCALL_EVENT(EVT_SETTINGS_R),
        INIT_FUNC_WATCHDOG_RESET
 #if defined(CONFIG_PCI_INIT_R) && !defined(CONFIG_SYS_EARLY_PCI_INIT)
        /*
@@ -754,16 +718,9 @@ static init_fnc_t init_sequence_r[] = {
        initr_status_led,
 #endif
        /* PPC has a udelay(20) here dating from 2002. Why? */
-#if defined(CONFIG_GPIO_HOG)
-       gpio_hog_probe_all,
-#endif
 #ifdef CONFIG_BOARD_LATE_INIT
        board_late_init,
 #endif
-#if defined(CONFIG_SCSI) && !defined(CONFIG_DM_SCSI)
-       INIT_FUNC_WATCHDOG_RESET
-       initr_scsi,
-#endif
 #ifdef CONFIG_BITBANGMII
        bb_miiphy_init,
 #endif
@@ -777,19 +734,9 @@ static init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_POST
        initr_post,
 #endif
-#if defined(CONFIG_IDE) && !defined(CONFIG_BLK)
-       initr_ide,
-#endif
-#ifdef CONFIG_LAST_STAGE_INIT
        INIT_FUNC_WATCHDOG_RESET
-       /*
-        * Some parts can be only initialized if all others (like
-        * Interrupts) are up and running (i.e. the PC-style ISA
-        * keyboard).
-        */
-       last_stage_init,
-#endif
-#if defined(CONFIG_PRAM)
+       INITCALL_EVENT(EVT_LAST_STAGE_INIT),
+#if defined(CFG_PRAM)
        initr_mem,
 #endif
        run_main_loop,
@@ -797,6 +744,15 @@ static init_fnc_t init_sequence_r[] = {
 
 void board_init_r(gd_t *new_gd, ulong dest_addr)
 {
+       /*
+        * The pre-relocation drivers may be using memory that has now gone
+        * away. Mark serial as unavailable - this will fall back to the debug
+        * UART if available.
+        *
+        * Do the same with log drivers since the memory may not be available.
+        */
+       gd->flags &= ~(GD_FLG_SERIAL_READY | GD_FLG_LOG_READY);
+
        /*
         * Set up the new global data pointer. So far only x86 does this
         * here.
@@ -811,11 +767,6 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
 #endif
        gd->flags &= ~GD_FLG_LOG_READY;
 
-       if (IS_ENABLED(CONFIG_NEEDS_MANUAL_RELOC)) {
-               for (int i = 0; i < ARRAY_SIZE(init_sequence_r); i++)
-                       MANUAL_RELOC(init_sequence_r[i]);
-       }
-
        if (initcall_run_list(init_sequence_r))
                hang();
 
This page took 0.0357 seconds and 4 git commands to generate.