spl: mmc: Fix spl_mmc_get_uboot_raw_sector() implementation
[oweals/u-boot.git] / common / board_r.c
index 84aec7fc71cf5203dc3ae28c65f068a46a8bab8e..0bbeaa7594c6bbbcbc9274a238581bf8d02526ca 100644 (file)
 
 #include <common.h>
 #include <api.h>
+#include <cpu_func.h>
+#include <exports.h>
+#include <hang.h>
+#include <image.h>
+#include <irq_func.h>
+#include <net.h>
+#include <u-boot/crc.h>
 /* TODO: can we just include all these headers whether needed or not? */
 #if defined(CONFIG_CMD_BEDBUG)
 #include <bedbug/type.h>
 #endif
+#include <binman.h>
 #include <command.h>
 #include <console.h>
 #include <dm.h>
-#include <environment.h>
+#include <env.h>
+#include <env_internal.h>
 #include <fdtdec.h>
 #include <ide.h>
+#include <init.h>
 #include <initcall.h>
 #if defined(CONFIG_CMD_KGDB)
 #include <kgdb.h>
 #endif
+#include <irq_func.h>
 #include <malloc.h>
 #include <mapmem.h>
 #ifdef CONFIG_BITBANGMII
@@ -36,6 +47,7 @@
 #include <onenand_uboot.h>
 #include <scsi.h>
 #include <serial.h>
+#include <status_led.h>
 #include <stdio_dev.h>
 #include <timer.h>
 #include <trace.h>
@@ -143,7 +155,7 @@ static int initr_reloc_global_data(void)
         */
        fixup_cpu();
 #endif
-#if !defined(CONFIG_ENV_ADDR) || defined(ENV_IS_EMBEDDED)
+#ifdef CONFIG_SYS_RELOC_GD_ENV_ADDR
        /*
         * Relocate the early env_addr pointer unless we know it is not inside
         * the binary. Some systems need this and for the rest, it doesn't hurt.
@@ -246,6 +258,10 @@ static int initr_malloc(void)
              gd->malloc_ptr / 1024);
 #endif
        /* The malloc area is immediately below the monitor copy in DRAM */
+       /*
+        * 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),
                        TOTAL_MALLOC_LEN);
@@ -300,16 +316,24 @@ static int initr_dm(void)
        bootstage_accum(BOOTSTATE_ID_ACCUM_DM_R);
        if (ret)
                return ret;
-#ifdef CONFIG_TIMER_EARLY
-       ret = dm_timer_init();
-       if (ret)
-               return ret;
-#endif
 
        return 0;
 }
 #endif
 
+static int initr_dm_devices(void)
+{
+       int ret;
+
+       if (IS_ENABLED(CONFIG_TIMER_EARLY)) {
+               ret = dm_timer_init();
+               if (ret)
+                       return ret;
+       }
+
+       return 0;
+}
+
 static int initr_bootstage(void)
 {
        bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r");
@@ -337,6 +361,14 @@ static int initr_manual_reloc_cmdtable(void)
 }
 #endif
 
+static int initr_binman(void)
+{
+       if (!CONFIG_IS_ENABLED(BINMAN_FDT))
+               return 0;
+
+       return binman_init();
+}
+
 #if defined(CONFIG_MTD_NOR_FLASH)
 static int initr_flash(void)
 {
@@ -447,14 +479,14 @@ static int initr_env(void)
        if (should_load_env())
                env_relocate();
        else
-               set_default_env(NULL, 0);
+               env_set_default(NULL, 0);
 #ifdef CONFIG_OF_CONTROL
        env_set_hex("fdtcontroladdr",
                    (unsigned long)map_to_sysmem(gd->fdt_blob));
 #endif
 
        /* Initialize from environment */
-       load_addr = env_get_ulong("loadaddr", 16, load_addr);
+       image_load_addr = env_get_ulong("loadaddr", 16, image_load_addr);
 
        return 0;
 }
@@ -582,15 +614,6 @@ static int initr_post(void)
 }
 #endif
 
-#if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_IDE)
-static int initr_pcmcia(void)
-{
-       puts("PCMCIA:");
-       pcmcia_init();
-       return 0;
-}
-#endif
-
 #if defined(CONFIG_IDE) && !defined(CONFIG_BLK)
 static int initr_ide(void)
 {
@@ -674,7 +697,6 @@ static init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_SYS_NONCACHED_MEMORY
        initr_noncached,
 #endif
-       bootstage_relocate,
 #ifdef CONFIG_OF_LIVE
        initr_of_live,
 #endif
@@ -697,6 +719,11 @@ static init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_EFI_LOADER
        efi_memory_init,
 #endif
+       initr_binman,
+#ifdef CONFIG_FSP_VERSION2
+       arch_fsp_init_r,
+#endif
+       initr_dm_devices,
        stdio_init_tables,
        initr_serial,
        initr_announce,
@@ -819,9 +846,6 @@ static init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_POST
        initr_post,
 #endif
-#if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_IDE)
-       initr_pcmcia,
-#endif
 #if defined(CONFIG_IDE) && !defined(CONFIG_BLK)
        initr_ide,
 #endif
@@ -840,6 +864,9 @@ static init_fnc_t init_sequence_r[] = {
 #endif
 #if defined(CONFIG_PRAM)
        initr_mem,
+#endif
+#if defined(CONFIG_M68K) && defined(CONFIG_BLOCK_CACHE)
+       blkcache_init,
 #endif
        run_main_loop,
 };