colibri_imx6: fix video stdout in default environment
[oweals/u-boot.git] / common / board_r.c
index 8a0c1114e77ac2ed644f2324cbaaa0c7cf5cae72..fa57fa9b699399d91d20a16199d68c51993328b6 100644 (file)
 
 #include <common.h>
 #include <api.h>
+#include <bootstage.h>
 #include <cpu_func.h>
 #include <exports.h>
+#include <flash.h>
 #include <hang.h>
 #include <image.h>
 #include <irq_func.h>
+#include <log.h>
 #include <net.h>
+#include <asm/cache.h>
 #include <u-boot/crc.h>
 /* TODO: can we just include all these headers whether needed or not? */
 #if defined(CONFIG_CMD_BEDBUG)
@@ -232,9 +236,8 @@ static int initr_unlock_ram_in_cache(void)
 #ifdef CONFIG_PCI
 static int initr_pci(void)
 {
-#ifndef CONFIG_DM_PCI
-       pci_init();
-#endif
+       if (IS_ENABLED(CONFIG_PCI_INIT_R))
+               pci_init();
 
        return 0;
 }
@@ -311,9 +314,9 @@ static int initr_dm(void)
 #ifdef CONFIG_TIMER
        gd->timer = NULL;
 #endif
-       bootstage_start(BOOTSTATE_ID_ACCUM_DM_R, "dm_r");
+       bootstage_start(BOOTSTAGE_ID_ACCUM_DM_R, "dm_r");
        ret = dm_init_and_scan(false);
-       bootstage_accum(BOOTSTATE_ID_ACCUM_DM_R);
+       bootstage_accum(BOOTSTAGE_ID_ACCUM_DM_R);
        if (ret)
                return ret;
 
@@ -355,8 +358,8 @@ static int initr_announce(void)
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
 static int initr_manual_reloc_cmdtable(void)
 {
-       fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
-                      ll_entry_count(cmd_tbl_t, cmd));
+       fixup_cmdtable(ll_entry_start(struct cmd_tbl, cmd),
+                      ll_entry_count(struct cmd_tbl, cmd));
        return 0;
 }
 #endif
@@ -370,11 +373,19 @@ static int initr_binman(void)
 }
 
 #if defined(CONFIG_MTD_NOR_FLASH)
+__weak int is_flash_available(void)
+{
+       return 1;
+}
+
 static int initr_flash(void)
 {
        ulong flash_size = 0;
        bd_t *bd = gd->bd;
 
+       if (!is_flash_available())
+               return 0;
+
        puts("Flash: ");
 
        if (board_flash_wp_on())
@@ -464,13 +475,14 @@ static int initr_mmc(void)
  */
 static int should_load_env(void)
 {
-#ifdef CONFIG_OF_CONTROL
-       return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 1);
-#elif defined CONFIG_DELAY_ENVIRONMENT
-       return 0;
-#else
+       if (IS_ENABLED(CONFIG_OF_CONTROL))
+               return fdtdec_get_config_int(gd->fdt_blob,
+                                               "load-environment", 1);
+
+       if (IS_ENABLED(CONFIG_DELAY_ENVIRONMENT))
+               return 0;
+
        return 1;
-#endif
 }
 
 static int initr_env(void)
@@ -480,10 +492,10 @@ static int initr_env(void)
                env_relocate();
        else
                env_set_default(NULL, 0);
-#ifdef CONFIG_OF_CONTROL
-       env_set_hex("fdtcontroladdr",
-                   (unsigned long)map_to_sysmem(gd->fdt_blob));
-#endif
+
+       if (IS_ENABLED(CONFIG_OF_CONTROL))
+               env_set_hex("fdtcontroladdr",
+                           (unsigned long)map_to_sysmem(gd->fdt_blob));
 
        /* Initialize from environment */
        image_load_addr = env_get_ulong("loadaddr", 16, image_load_addr);
@@ -518,15 +530,6 @@ static int initr_api(void)
 }
 #endif
 
-/* enable exceptions */
-#ifdef CONFIG_ARM
-static int initr_enable_interrupts(void)
-{
-       enable_interrupts();
-       return 0;
-}
-#endif
-
 #ifdef CONFIG_CMD_NET
 static int initr_ethaddr(void)
 {
@@ -646,15 +649,6 @@ int initr_mem(void)
 }
 #endif
 
-#ifdef CONFIG_CMD_BEDBUG
-static int initr_bedbug(void)
-{
-       bedbug_init();
-
-       return 0;
-}
-#endif
-
 static int run_main_loop(void)
 {
 #ifdef CONFIG_SANDBOX
@@ -813,9 +807,6 @@ static init_fnc_t init_sequence_r[] = {
        initr_kgdb,
 #endif
        interrupt_init,
-#ifdef CONFIG_ARM
-       initr_enable_interrupts,
-#endif
 #if defined(CONFIG_MICROBLAZE) || defined(CONFIG_M68K)
        timer_init,             /* initialize timer */
 #endif
@@ -860,10 +851,13 @@ static init_fnc_t init_sequence_r[] = {
 #endif
 #ifdef CONFIG_CMD_BEDBUG
        INIT_FUNC_WATCHDOG_RESET
-       initr_bedbug,
+       bedbug_init,
 #endif
 #if defined(CONFIG_PRAM)
        initr_mem,
+#endif
+#if defined(CONFIG_M68K) && defined(CONFIG_BLOCK_CACHE)
+       blkcache_init,
 #endif
        run_main_loop,
 };