diff mbox series

[U-Boot,01/19] stm32mp1: add runtime information in environment

Message ID 1551283289-23564-2-git-send-email-patrick.delaunay@st.com
State Accepted
Commit b4ae34b66b2d5447e0422e03bf88dd0fde31dea0
Delegated to: Tom Rini
Headers show
Series stm32mp1: update of stm32mp arch and stm32mp1 board | expand

Commit Message

Patrick DELAUNAY Feb. 27, 2019, 4:01 p.m. UTC
Set board name with the first dts compatible found in DT
code under CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG

The result with DEVICE_TREE=stm32mp157c-ev1 is:
    STM32MP> env print
    	board=stm32mp1
    	board_name=stm32mp157c-ev1

Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
---

 arch/arm/Kconfig             |  1 +
 board/st/stm32mp1/stm32mp1.c | 24 +++++++++++++++++++-----
 2 files changed, 20 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 9e861c2..ec524f4 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1364,6 +1364,7 @@  config ARCH_STM32MP
 	select SYSRESET
 	select SYS_THUMB_BUILD
 	imply CMD_DM
+	imply ENV_VARS_UBOOT_RUNTIME_CONFIG
 	help
 	  Support for STM32MP SoC family developed by STMicroelectronics,
 	  MPUs based on ARM cortex A core
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 07d1add..48da459 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -220,11 +220,6 @@  int board_usb_cleanup(int index, enum usb_init_type init)
 	return 0;
 }
 
-int board_late_init(void)
-{
-	return 0;
-}
-
 /* board dependent setup after realloc */
 int board_init(void)
 {
@@ -236,3 +231,22 @@  int board_init(void)
 
 	return 0;
 }
+
+int board_late_init(void)
+{
+#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+	const void *fdt_compat;
+	int fdt_compat_len;
+
+	fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible",
+				 &fdt_compat_len);
+	if (fdt_compat && fdt_compat_len) {
+		if (strncmp(fdt_compat, "st,", 3) != 0)
+			env_set("board_name", fdt_compat);
+		else
+			env_set("board_name", fdt_compat + 3);
+	}
+#endif
+
+	return 0;
+}