Merge branch '2019-10-28-azure-ci-support'
[oweals/u-boot.git] / common / board_r.c
index 2f982b1646082fc3efc237dabaaf5a0334b418e0..d6fb5047a26511cc0cf997664e9f9a387dee1ee3 100644 (file)
@@ -18,7 +18,8 @@
 #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 <initcall.h>
 #include <linux/compiler.h>
 #include <linux/err.h>
 #include <efi_loader.h>
+#include <wdt.h>
+#if defined(CONFIG_GPIO_HOG)
+#include <asm/gpio.h>
+#endif
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -154,6 +159,13 @@ static int initr_reloc_global_data(void)
        gd->fdt_blob += gd->reloc_off;
 #endif
 #ifdef CONFIG_EFI_LOADER
+       /*
+        * On the ARM architecture gd is mapped to a fixed register (r9 or x18).
+        * As this register may be overwritten by an EFI payload we save it here
+        * and restore it on every callback entered.
+        */
+       efi_save_gd();
+
        efi_runtime_relocate(gd->relocaddr, NULL);
 #endif
 
@@ -235,6 +247,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);
@@ -436,9 +452,10 @@ 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_addr("fdtcontroladdr", gd->fdt_blob);
+       env_set_hex("fdtcontroladdr",
+                   (unsigned long)map_to_sysmem(gd->fdt_blob));
 #endif
 
        /* Initialize from environment */
@@ -570,15 +587,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)
 {
@@ -632,10 +640,7 @@ static int run_main_loop(void)
 }
 
 /*
- * 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
+ * We 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?
@@ -691,6 +696,9 @@ static init_fnc_t init_sequence_r[] = {
        stdio_init_tables,
        initr_serial,
        initr_announce,
+#if CONFIG_IS_ENABLED(WDT)
+       initr_watchdog,
+#endif
        INIT_FUNC_WATCHDOG_RESET
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
        initr_manual_reloc_cmdtable,
@@ -787,6 +795,9 @@ static init_fnc_t init_sequence_r[] = {
 #ifdef CONFIG_CMD_NET
        initr_ethaddr,
 #endif
+#if defined(CONFIG_GPIO_HOG)
+       gpio_hog_probe_all,
+#endif
 #ifdef CONFIG_BOARD_LATE_INIT
        board_late_init,
 #endif
@@ -804,9 +815,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