[U-Boot] [PATCH v2 1/3] mach-stm32: Add set_env_soc_name support

patrice.chotard at st.com patrice.chotard at st.com
Mon Feb 5 10:33:25 UTC 2018


From: Patrice Chotard <patrice.chotard at st.com>

This allows to create and set the environment variable
"soc_name" which contains the current STM32 SoC's name.

Signed-off-by: Christophe Priouzeau <christophe.priouzeau at st.com>
Signed-off-by: Patrice Chotard <patrice.chotard at st.com>
---

v2: _ Remove get_cpu_id() function and use directly CONFIG_STM32xx flag
      to identify the STM32 SoC family.


 arch/arm/include/asm/arch-stm32f4/stm32.h |  1 +
 arch/arm/include/asm/arch-stm32f7/stm32.h |  1 +
 arch/arm/include/asm/arch-stm32h7/stm32.h |  3 +++
 arch/arm/mach-stm32/soc.c                 | 15 +++++++++++++++
 4 files changed, 20 insertions(+)

diff --git a/arch/arm/include/asm/arch-stm32f4/stm32.h b/arch/arm/include/asm/arch-stm32f4/stm32.h
index 0449fcecede0..d4b0c40804c0 100644
--- a/arch/arm/include/asm/arch-stm32f4/stm32.h
+++ b/arch/arm/include/asm/arch-stm32f4/stm32.h
@@ -50,5 +50,6 @@ static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT] = {
 };
 
 void stm32_flash_latency_cfg(int latency);
+void set_env_soc_name(void);
 
 #endif /* _MACH_STM32_H_ */
diff --git a/arch/arm/include/asm/arch-stm32f7/stm32.h b/arch/arm/include/asm/arch-stm32f7/stm32.h
index f54e6f195575..315d2a14790c 100644
--- a/arch/arm/include/asm/arch-stm32f7/stm32.h
+++ b/arch/arm/include/asm/arch-stm32f7/stm32.h
@@ -63,5 +63,6 @@ static const u32 sect_sz_kb[CONFIG_SYS_MAX_FLASH_SECT] = {
 
 
 void stm32_flash_latency_cfg(int latency);
+void set_env_soc_name(void);
 
 #endif /* _ASM_ARCH_HARDWARE_H */
diff --git a/arch/arm/include/asm/arch-stm32h7/stm32.h b/arch/arm/include/asm/arch-stm32h7/stm32.h
index f2922aa3237e..9377c5d65bfb 100644
--- a/arch/arm/include/asm/arch-stm32h7/stm32.h
+++ b/arch/arm/include/asm/arch-stm32h7/stm32.h
@@ -18,4 +18,7 @@
  * arch/arm/include/asm/arch-stm32f4/stm32.h
  * arch/arm/include/asm/arch-stm32f7/stm32.h
  */
+
+void set_env_soc_name(void);
+
 #endif /* _ASM_ARCH_HARDWARE_H */
diff --git a/arch/arm/mach-stm32/soc.c b/arch/arm/mach-stm32/soc.c
index df20d547c500..06ca61b270cf 100644
--- a/arch/arm/mach-stm32/soc.c
+++ b/arch/arm/mach-stm32/soc.c
@@ -8,6 +8,7 @@
 #include <common.h>
 #include <asm/io.h>
 #include <asm/armv7m_mpu.h>
+#include <asm/arch/stm32.h>
 
 int arch_cpu_init(void)
 {
@@ -54,3 +55,17 @@ int arch_cpu_init(void)
 
 	return 0;
 }
+
+void set_env_soc_name(void)
+{
+	char soc[16];
+
+#ifdef CONFIG_STM32F4
+	snprintf(soc, sizeof(soc), "stm32f4");
+#elif CONFIG_STM32F7
+	snprintf(soc, sizeof(soc), "stm32f7");
+#elif CONFIG_STM32H7
+	snprintf(soc, sizeof(soc), "stm32h7");
+#endif
+	env_set("soc_name", soc);
+}
-- 
1.9.1



More information about the U-Boot mailing list