]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
imx: kontron-sl-mx6ul: Add support for reading HW UIDs
authorFrieder Schrempf <frieder.schrempf@kontron.de>
Tue, 4 Nov 2025 12:54:27 +0000 (13:54 +0100)
committerFabio Estevam <festevam@nabladev.com>
Tue, 4 Nov 2025 15:46:11 +0000 (12:46 -0300)
The factory provides a CPU UID in the OTPs and the SoM module
and the carrier board might provide additional UIDs in the GP
registers of the OTPs. Load these values in the following order
and create a serial number string:

* Board UID (GP2)
* SoM UID (GP1)
* CPU UID (UNIQUE_ID)

The string is stored in the "serial#" env variable and
exported to Linux. Further this prints the used UID to the
console which looks like this

  ID:    0042152331 (Board)

or:

  ID:    0030124840 (SoM)

or:

  ID:    4696668CD9516886 (CPU)

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
board/kontron/sl-mx6ul/Kconfig
board/kontron/sl-mx6ul/sl-mx6ul.c
configs/kontron-sl-mx6ul_defconfig

index 7a4ffbed28931ea70ec7b8092271662092d58a1d..a6d3fa49778d1b78dd933edcf6c7c2fa054669b7 100644 (file)
@@ -9,4 +9,6 @@ config SYS_VENDOR
 config SYS_CONFIG_NAME
        default "kontron-sl-mx6ul"
 
+source "board/kontron/common/Kconfig"
+
 endif
index 65f9b75c1a0f53a36cfb7da4c09cfbbebcc63475..9dda8822ef93139db739d980f31cbf24710e39c2 100644 (file)
 
 #include "sl-mx6ul-common.h"
 
+#include "../common/hw-uid.h"
+
 DECLARE_GLOBAL_DATA_PTR;
 
+#if IS_ENABLED(CONFIG_KONTRON_HW_UID)
+
+struct uid_otp_loc uid_otp_locations[] = {
+       {
+               .addr = (u32 *)(OCOTP_BASE_ADDR + 0x670),
+               .len = 1,
+               .format = UID_OTP_FORMAT_DEC,
+               .desc = "BOARD"
+       },
+       {
+               .addr = (u32 *)(OCOTP_BASE_ADDR + 0x660),
+               .len = 1,
+               .format = UID_OTP_FORMAT_DEC,
+               .desc = "SOM"
+       },
+#if IS_ENABLED(CONFIG_KONTRON_HW_UID_USE_SOC_FALLBACK)
+       {
+               .addr = (u32 *)(OCOTP_BASE_ADDR + 0x410),
+               .len = 2,
+               .format = UID_OTP_FORMAT_HEX,
+               .desc = "SOC"
+       }
+#endif
+};
+
+#endif /* CONFIG_KONTRON_HW_UID */
+
 int dram_init(void)
 {
        gd->ram_size = imx_ddr_size();
@@ -91,6 +120,9 @@ int board_init(void)
 
 int board_late_init(void)
 {
+       if (IS_ENABLED(CONFIG_KONTRON_HW_UID))
+               get_serial_number(uid_otp_locations, ARRAY_SIZE(uid_otp_locations));
+
        if (is_boot_from_usb()) {
                env_set("bootdelay", "0");
                env_set("bootcmd", "fastboot 0");
index 9f7003bf54c5290283d1810cf6dd98017567a02c..c6d450419cc39280370fa17162c1a7d94bd4a00c 100644 (file)
@@ -13,6 +13,7 @@ CONFIG_ENV_SECT_SIZE=0x4000
 CONFIG_MX6UL=y
 CONFIG_TARGET_KONTRON_MX6UL=y
 CONFIG_DM_GPIO=y
+CONFIG_KONTRON_HW_UID=y
 CONFIG_DEFAULT_DEVICE_TREE="nxp/imx/imx6ul-kontron-bl"
 CONFIG_SPL_MMC=y
 CONFIG_SPL_SERIAL=y