]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
stm32mp: add setup_serial_number for stm32mp25
authorPatrice Chotard <patrice.chotard@foss.st.com>
Mon, 15 Jan 2024 14:05:50 +0000 (15:05 +0100)
committerPatrice Chotard <patrice.chotard@foss.st.com>
Fri, 19 Jan 2024 13:37:50 +0000 (14:37 +0100)
Add support of serial number for stm32mp25, gets from OTP with BSEC driver.

Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Igor Opaniuk <igor.opaniuk@foundries.io>
arch/arm/mach-stm32mp/include/mach/sys_proto.h
arch/arm/mach-stm32mp/soc.c
arch/arm/mach-stm32mp/stm32mp1/cpu.c
arch/arm/mach-stm32mp/stm32mp2/cpu.c

index 83388fdb73716e43e8dc5ce2d0b9b412a286ebd4..2a65efc0a50a42bf95106c08b9efa98fd3e5aa5b 100644 (file)
@@ -97,6 +97,7 @@ u32 get_bootauth(void);
 
 int get_eth_nb(void);
 int setup_mac_address(void);
+int setup_serial_number(void);
 
 /* board power management : configure vddcore according OPP */
 void board_vddcore_init(u32 voltage_mv);
index d7b03590b8c4a85f4fc1ae612b01da3e486ba5e9..ff70ebe974644712cffc7c7f831290af8ec45f12 100644 (file)
@@ -4,8 +4,10 @@
  */
 
 #include <env.h>
+#include <misc.h>
 #include <asm/arch/sys_proto.h>
 #include <dm/device.h>
+#include <dm/uclass.h>
 
 /* used when CONFIG_DISPLAY_CPUINFO is activated */
 int print_cpuinfo(void)
@@ -17,3 +19,30 @@ int print_cpuinfo(void)
 
        return 0;
 }
+
+int setup_serial_number(void)
+{
+       char serial_string[25];
+       u32 otp[3] = {0, 0, 0 };
+       struct udevice *dev;
+       int ret;
+
+       if (env_get("serial#"))
+               return 0;
+
+       ret = uclass_get_device_by_driver(UCLASS_MISC,
+                                         DM_DRIVER_GET(stm32mp_bsec),
+                                         &dev);
+       if (ret)
+               return ret;
+
+       ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_SERIAL),
+                       otp, sizeof(otp));
+       if (ret < 0)
+               return ret;
+
+       sprintf(serial_string, "%08X%08X%08X", otp[0], otp[1], otp[2]);
+       env_set("serial#", serial_string);
+
+       return 0;
+}
index 00fea7929b2ffb61e90e4963358778863e0be508..f84cb26fa5654ed2b2addc67b62deae5bda2c151 100644 (file)
@@ -336,33 +336,6 @@ __weak int setup_mac_address(void)
        return 0;
 }
 
-static int setup_serial_number(void)
-{
-       char serial_string[25];
-       u32 otp[3] = {0, 0, 0 };
-       struct udevice *dev;
-       int ret;
-
-       if (env_get("serial#"))
-               return 0;
-
-       ret = uclass_get_device_by_driver(UCLASS_MISC,
-                                         DM_DRIVER_GET(stm32mp_bsec),
-                                         &dev);
-       if (ret)
-               return ret;
-
-       ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_SERIAL),
-                       otp, sizeof(otp));
-       if (ret < 0)
-               return ret;
-
-       sprintf(serial_string, "%08X%08X%08X", otp[0], otp[1], otp[2]);
-       env_set("serial#", serial_string);
-
-       return 0;
-}
-
 __weak void stm32mp_misc_init(void)
 {
 }
index c0f6519e8d7c82696db2f4b21bf64d50b2dbf7b7..301e365cf4f44caadf9de6b97f8c9f8fa23586d9 100644 (file)
@@ -69,6 +69,8 @@ void enable_caches(void)
 
 int arch_misc_init(void)
 {
+       setup_serial_number();
+
        return 0;
 }