[U-Boot] [PATCH v2 20/22] ARM: uniphier: set loadaddr at boot-time

Masahiro Yamada yamada.masahiro at socionext.com
Wed Jul 10 11:07:48 UTC 2019


The base of DRAM will be changed for the next generation SoC.
To support it along with existing SoCs in the single defconfig,
set 'loadaddr' at boot-time by adding the offset to the DRAM base.

CONFIG_SYS_LOAD_ADDR is still hard-coded for compilation, but the
value from environment variable 'loadaddr' should be used.

Signed-off-by: Masahiro Yamada <yamada.masahiro at socionext.com>
---

 arch/arm/mach-uniphier/board_late_init.c | 32 ++++++++++++++++++++++++
 include/configs/uniphier.h               |  4 +--
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-uniphier/board_late_init.c b/arch/arm/mach-uniphier/board_late_init.c
index 37b375c01984..dbd1f17e832e 100644
--- a/arch/arm/mach-uniphier/board_late_init.c
+++ b/arch/arm/mach-uniphier/board_late_init.c
@@ -66,6 +66,36 @@ fail:
 	pr_warn("\"fdt_file\" environment variable was not set correctly\n");
 }
 
+static void uniphier_set_env_addr(const char *env, const char *offset_env)
+{
+	unsigned long offset = 0;
+	const char *str;
+	char *end;
+	int ret;
+
+	if (env_get(env))
+		return;		/* do nothing if it is already set */
+
+	if (offset_env) {
+		str = env_get(offset_env);
+		if (!str)
+			goto fail;
+
+		offset = simple_strtoul(str, &end, 16);
+		if (*end)
+			goto fail;
+	}
+
+	ret = env_set_hex(env, gd->ram_base + offset);
+	if (ret)
+		goto fail;
+
+	return;
+
+fail:
+	pr_warn("\"%s\" environment variable was not set correctly\n", env);
+}
+
 int board_late_init(void)
 {
 	puts("MODE:  ");
@@ -105,5 +135,7 @@ int board_late_init(void)
 
 	uniphier_set_env_fdt_file();
 
+	uniphier_set_env_addr("loadaddr", "loadaddr_offset");
+
 	return 0;
 }
diff --git a/include/configs/uniphier.h b/include/configs/uniphier.h
index 46d576d54aa1..6d3d9b318881 100644
--- a/include/configs/uniphier.h
+++ b/include/configs/uniphier.h
@@ -98,8 +98,7 @@
 #define CONFIG_GATEWAYIP		192.168.11.1
 #define CONFIG_NETMASK			255.255.255.0
 
-#define CONFIG_LOADADDR			0x85000000
-#define CONFIG_SYS_LOAD_ADDR		CONFIG_LOADADDR
+#define CONFIG_SYS_LOAD_ADDR		0x85000000
 #define CONFIG_SYS_BOOTM_LEN		(32 << 20)
 
 #if defined(CONFIG_ARM64)
@@ -158,6 +157,7 @@
 #define	CONFIG_EXTRA_ENV_SETTINGS				\
 	"netdev=eth0\0"						\
 	"initrd_high=0xffffffffffffffff\0"			\
+	"loadaddr_offset=0x05000000\0" \
 	"script=boot.scr\0" \
 	"scriptaddr=0x85000000\0"				\
 	"nor_base=0x42000000\0"					\
-- 
2.17.1



More information about the U-Boot mailing list