Merge tag 'video-for-2021.01-rc1' of https://gitlab.denx.de/u-boot/custodians/u-boot...
[platform/kernel/u-boot.git] / common / board_r.c
index 6572084..9b2fec7 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)
 #include <bedbug/type.h>
 #endif
+#include <binman.h>
 #include <command.h>
 #include <console.h>
 #include <dm.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
 #include <nand.h>
 #include <of_live.h>
 #include <onenand_uboot.h>
+#include <pvblock.h>
 #include <scsi.h>
 #include <serial.h>
+#include <status_led.h>
 #include <stdio_dev.h>
 #include <timer.h>
 #include <trace.h>
 #include <watchdog.h>
+#ifdef CONFIG_XEN
+#include <xen.h>
+#endif
 #ifdef CONFIG_ADDR_MAP
 #include <asm/mmu.h>
 #endif
@@ -172,12 +191,6 @@ static int initr_reloc_global_data(void)
        return 0;
 }
 
-static int initr_serial(void)
-{
-       serial_initialize();
-       return 0;
-}
-
 #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_MIPS)
 static int initr_trap(void)
 {
@@ -218,12 +231,20 @@ static int initr_unlock_ram_in_cache(void)
 }
 #endif
 
+#ifdef CONFIG_PCI_ENDPOINT
+static int initr_pci_ep(void)
+{
+       pci_ep_init();
+
+       return 0;
+}
+#endif
+
 #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;
 }
@@ -300,21 +321,29 @@ 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;
-#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");
@@ -336,17 +365,33 @@ 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
 
+static int initr_binman(void)
+{
+       if (!CONFIG_IS_ENABLED(BINMAN_FDT))
+               return 0;
+
+       return binman_init();
+}
+
 #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;
+       struct bd_info *bd = gd->bd;
+
+       if (!is_flash_available())
+               return 0;
 
        puts("Flash: ");
 
@@ -424,6 +469,23 @@ static int initr_mmc(void)
 }
 #endif
 
+#ifdef CONFIG_XEN
+static int initr_xen(void)
+{
+       xen_init();
+       return 0;
+}
+#endif
+
+#ifdef CONFIG_PVBLOCK
+static int initr_pvblock(void)
+{
+       puts("PVBLOCK: ");
+       pvblock_init();
+       return 0;
+}
+#endif
+
 /*
  * Tell if it's OK to load the environment early in boot.
  *
@@ -437,13 +499,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)
@@ -453,13 +516,13 @@ 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 */
-       load_addr = env_get_ulong("loadaddr", 16, load_addr);
+       image_load_addr = env_get_ulong("loadaddr", 16, image_load_addr);
 
        return 0;
 }
@@ -491,37 +554,14 @@ 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)
 {
-       bd_t *bd = gd->bd;
+       struct bd_info *bd = gd->bd;
 
        /* kept around for legacy kernels only ... ignore the next section */
        eth_env_get_enetaddr("ethaddr", bd->bi_enetaddr);
-#ifdef CONFIG_HAS_ETH1
-       eth_env_get_enetaddr("eth1addr", bd->bi_enet1addr);
-#endif
-#ifdef CONFIG_HAS_ETH2
-       eth_env_get_enetaddr("eth2addr", bd->bi_enet2addr);
-#endif
-#ifdef CONFIG_HAS_ETH3
-       eth_env_get_enetaddr("eth3addr", bd->bi_enet3addr);
-#endif
-#ifdef CONFIG_HAS_ETH4
-       eth_env_get_enetaddr("eth4addr", bd->bi_enet4addr);
-#endif
-#ifdef CONFIG_HAS_ETH5
-       eth_env_get_enetaddr("eth5addr", bd->bi_enet5addr);
-#endif
+
        return 0;
 }
 #endif /* CONFIG_CMD_NET */
@@ -619,15 +659,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
@@ -692,13 +723,21 @@ 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,
+       serial_initialize,
        initr_announce,
 #if CONFIG_IS_ENABLED(WDT)
        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
@@ -744,6 +783,12 @@ static init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_MMC
        initr_mmc,
 #endif
+#ifdef CONFIG_XEN
+       initr_xen,
+#endif
+#ifdef CONFIG_PVBLOCK
+       initr_pvblock,
+#endif
        initr_env,
 #ifdef CONFIG_SYS_BOOTPARAMS_LEN
        initr_malloc_bootparams,
@@ -781,9 +826,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
@@ -807,6 +849,9 @@ static init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_BITBANGMII
        initr_bbmii,
 #endif
+#ifdef CONFIG_PCI_ENDPOINT
+       initr_pci_ep,
+#endif
 #ifdef CONFIG_CMD_NET
        INIT_FUNC_WATCHDOG_RESET
        initr_net,
@@ -828,7 +873,7 @@ 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,