]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
stm32f429: pass the device unique ID in DTB
authorAntonio Borneo <borneo.antonio@gmail.com>
Sun, 19 Jul 2015 14:19:46 +0000 (22:19 +0800)
committerTom Rini <trini@konsulko.com>
Mon, 27 Jul 2015 19:02:14 +0000 (15:02 -0400)
Read device unique ID and set environment variable "serial#".
Value would then be passed to kernel through DTB.

To read ID from DTB, kernel is required to have commit:
3f599875e5202986b350618a617527ab441bf206 (ARM: 8355/1: arch: Show
the serial number from devicetree in cpuinfo)
This commit is already mainline since v4.1-rc1.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
To: Albert Aribaud <albert.u.boot@aribaud.net>
To: Tom Rini <trini@konsulko.com>
To: Kamil Lulko <rev13@wp.pl>
Cc: u-boot@lists.denx.de
arch/arm/include/asm/arch-stm32f4/stm32.h
board/st/stm32f429-discovery/stm32f429-discovery.c
include/configs/stm32f429-discovery.h

index a9f88db560fe4f2b3aa9931b26096647580bf5b2..3ed3801dfe7d9d045d19110c70d4000029461002 100644 (file)
@@ -14,6 +14,7 @@
 /*
  * Peripheral memory map
  */
+#define STM32_SYSMEM_BASE      0x1FFF0000
 #define STM32_PERIPH_BASE      0x40000000
 #define STM32_APB1PERIPH_BASE  (STM32_PERIPH_BASE + 0x00000000)
 #define STM32_APB2PERIPH_BASE  (STM32_PERIPH_BASE + 0x00010000)
 /*
  * Register maps
  */
+struct stm32_u_id_regs {
+       u32 u_id_low;
+       u32 u_id_mid;
+       u32 u_id_high;
+};
+
 struct stm32_rcc_regs {
        u32 cr;         /* RCC clock control */
        u32 pllcfgr;    /* RCC PLL configuration */
@@ -78,6 +85,9 @@ struct stm32_flash_regs {
 /*
  * Registers access macros
  */
+#define STM32_U_ID_BASE                (STM32_SYSMEM_BASE + 0x7A10)
+#define STM32_U_ID             ((struct stm32_u_id_regs *)STM32_U_ID_BASE)
+
 #define STM32_RCC_BASE         (STM32_AHB1PERIPH_BASE + 0x3800)
 #define STM32_RCC              ((struct stm32_rcc_regs *)STM32_RCC_BASE)
 
index 2dd5d935d9ec9af0c661794d1daea9a9944fd6ae..f418186c1eab88d5942e412e5f84eb32be17a671 100644 (file)
@@ -285,3 +285,22 @@ int board_init(void)
 
        return 0;
 }
+
+#ifdef CONFIG_MISC_INIT_R
+int misc_init_r(void)
+{
+       char serialno[25];
+       uint32_t u_id_low, u_id_mid, u_id_high;
+
+       if (!getenv("serial#")) {
+               u_id_low  = readl(&STM32_U_ID->u_id_low);
+               u_id_mid  = readl(&STM32_U_ID->u_id_mid);
+               u_id_high = readl(&STM32_U_ID->u_id_high);
+               sprintf(serialno, "%08x%08x%08x",
+                       u_id_high, u_id_mid, u_id_low);
+               setenv("serial#", serialno);
+       }
+
+       return 0;
+}
+#endif
index 8169cac379753abb32bc8fdd880a7c98b19714c2..f9807db5c677f8c702db87f1cbc4e0c5f5255bc8 100644 (file)
@@ -15,6 +15,7 @@
 #define CONFIG_OF_LIBFDT
 
 #define CONFIG_BOARD_EARLY_INIT_F
+#define CONFIG_MISC_INIT_R
 
 #define CONFIG_SYS_FLASH_BASE          0x08000000