diff mbox

[U-Boot] vexpress: qemu can load the fdt to ram base

Message ID 1413885940-3411-1-git-send-email-kraxel@redhat.com
State Deferred
Delegated to: Tom Rini
Headers show

Commit Message

Gerd Hoffmann Oct. 21, 2014, 10:05 a.m. UTC
Check if the fdt is there (happens only when passed via -dtb cmd line
switch to qemu), then setup env accordingly.  If present use it.
Otherwise try to load from disk.

Also tweak CONFIG_SYS_LOAD_ADDR and LINUX_BOOT_PARAM_ADDR a bit to
avoid them overriding the fdt.
---
 board/armltd/vexpress/vexpress_common.c | 18 ++++++++++++++++++
 include/configs/vexpress_common.h       |  9 ++++-----
 2 files changed, 22 insertions(+), 5 deletions(-)

Comments

Gerd Hoffmann Oct. 21, 2014, 10:36 a.m. UTC | #1
On Di, 2014-10-21 at 12:05 +0200, Gerd Hoffmann wrote:
> Check if the fdt is there (happens only when passed via -dtb cmd line
> switch to qemu), then setup env accordingly.  If present use it.
> Otherwise try to load from disk.

Oops, wrong patch, correct one just send.
It shows what I'm doing though to automatically use the qemu fdt:

> +int board_late_init(void)
> +{
> +	struct fdt_header *fdt = (void*)V2M_BASE;
> +
> +	if (fdt_magic(fdt) == FDT_MAGIC) {
> +		setenv_addr("fdt_addr", (void*)(ulong)V2M_BASE);
> +		printf("QEMU: fdt found at %s, using it.\n", getenv("fdt_addr"));
> +	} else {
> +		setenv_addr("fdt_addr_r", (void*)((ulong)V2M_BASE + 0x27f00000));
> +		setenv("fdtfile", CONFIG_DEFAULT_FDT_FILE);
> +		printf("QEMU: will try to load %s from disk.\n",
> +		       getenv("fdtfile"));
> +	}
> +
> +	return 0;
> +}

[ This one depends on other non-upstream patches so no plans to submit
  this upstream atm ]

cheers,
  Gerd
diff mbox

Patch

diff --git a/board/armltd/vexpress/vexpress_common.c b/board/armltd/vexpress/vexpress_common.c
index cb2de2f..dafa4b2 100644
--- a/board/armltd/vexpress/vexpress_common.c
+++ b/board/armltd/vexpress/vexpress_common.c
@@ -20,6 +20,7 @@ 
 #include <malloc.h>
 #include <errno.h>
 #include <netdev.h>
+#include <libfdt.h>
 #include <asm/io.h>
 #include <asm/arch/systimer.h>
 #include <asm/arch/sysctrl.h>
@@ -60,6 +61,23 @@  int board_init(void)
 	return 0;
 }
 
+int board_late_init(void)
+{
+	struct fdt_header *fdt = (void*)V2M_BASE;
+
+	if (fdt_magic(fdt) == FDT_MAGIC) {
+		setenv_addr("fdt_addr", (void*)(ulong)V2M_BASE);
+		printf("QEMU: fdt found at %s, using it.\n", getenv("fdt_addr"));
+	} else {
+		setenv_addr("fdt_addr_r", (void*)((ulong)V2M_BASE + 0x27f00000));
+		setenv("fdtfile", CONFIG_DEFAULT_FDT_FILE);
+		printf("QEMU: will try to load %s from disk.\n",
+		       getenv("fdtfile"));
+	}
+
+	return 0;
+}
+
 int board_eth_init(bd_t *bis)
 {
 	int rc = 0;
diff --git a/include/configs/vexpress_common.h b/include/configs/vexpress_common.h
index e378c10..e490804 100644
--- a/include/configs/vexpress_common.h
+++ b/include/configs/vexpress_common.h
@@ -184,8 +184,8 @@ 
 
 /* Miscellaneous configurable options */
 #undef	CONFIG_SYS_CLKS_IN_HZ
-#define CONFIG_SYS_LOAD_ADDR		(V2M_BASE + 0x8000)
-#define LINUX_BOOT_PARAM_ADDR		(V2M_BASE + 0x2000)
+#define CONFIG_SYS_LOAD_ADDR		(V2M_BASE + 0x100000)
+#define LINUX_BOOT_PARAM_ADDR		(V2M_BASE + 0x200000)
 
 /* Physical Memory Map */
 #define CONFIG_NR_DRAM_BANKS		2
@@ -207,6 +207,8 @@ 
 #include <config_distro_defaults.h>
 #include <config_distro_bootcmd.h>
 
+#define CONFIG_BOARD_LATE_INIT
+
 /* Basic environment settings */
 #define CONFIG_BOOTCOMMAND		"run bootflash;"
 #ifdef CONFIG_VEXPRESS_ORIGINAL_MEMORY_MAP
@@ -215,7 +217,6 @@ 
 		"kernel_addr_r="  "0x80008000\0" \
 		"scriptaddr="     "0x87d00000\0" \
 		"pxefile_addr_r=" "0x87e00000\0" \
-		"fdt_addr_r="     "0x87f00000\0" \
 		"ramdisk_addr_r=" "0x88000000\0"
 #elif defined(CONFIG_VEXPRESS_EXTENDED_MEMORY_MAP)
 #define CONFIG_PLATFORM_ENV_SETTINGS \
@@ -223,7 +224,6 @@ 
 		"kernel_addr_r="  "0xa0008000\0" \
 		"scriptaddr="     "0xa7d00000\0" \
 		"pxefile_addr_r=" "0xa7e00000\0" \
-		"fdt_addr_r="     "0xa7f00000\0" \
 		"ramdisk_addr_r=" "0xa8000000\0"
 #endif
 
@@ -235,7 +235,6 @@ 
 #define CONFIG_EXTRA_ENV_SETTINGS \
 		CONFIG_PLATFORM_ENV_SETTINGS \
 		"console=ttyAMA0,115200n8\0" \
-		"fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
                 BOOTENV
 
 /* FLASH and environment organization */