From: Frieder Schrempf Date: Tue, 4 Nov 2025 12:54:28 +0000 (+0100) Subject: imx: kontron-sl-mx8mm: Add support for reading HW UIDs X-Git-Tag: v2026.01-rc2~39^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=306c3caf81a34d94a13037a6f5772b64b54fe082;p=thirdparty%2Fu-boot.git imx: kontron-sl-mx8mm: Add support for reading HW UIDs 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 --- diff --git a/board/kontron/sl-mx8mm/Kconfig b/board/kontron/sl-mx8mm/Kconfig index 1597bcf894d..0a5123d2979 100644 --- a/board/kontron/sl-mx8mm/Kconfig +++ b/board/kontron/sl-mx8mm/Kconfig @@ -9,4 +9,6 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "kontron-sl-mx8mm" +source "board/kontron/common/Kconfig" + endif diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c b/board/kontron/sl-mx8mm/sl-mx8mm.c index df92765cb2d..d24d5286e45 100644 --- a/board/kontron/sl-mx8mm/sl-mx8mm.c +++ b/board/kontron/sl-mx8mm/sl-mx8mm.c @@ -18,8 +18,37 @@ #include #include +#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 + 0x7A0), + .len = 2, + .format = UID_OTP_FORMAT_DEC, + .desc = "BOARD" + }, + { + .addr = (u32 *)(OCOTP_BASE_ADDR + 0x780), + .len = 2, + .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 */ + #if IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_SUPPORT) struct efi_fw_image fw_images[] = { { @@ -167,6 +196,9 @@ int board_late_init(void) env_set("touch_rst_gpio", "87"); } + if (IS_ENABLED(CONFIG_KONTRON_HW_UID)) + get_serial_number(uid_otp_locations, ARRAY_SIZE(uid_otp_locations)); + if (is_usb_boot()) { env_set("bootcmd", "fastboot 0"); env_set("bootdelay", "0"); diff --git a/configs/kontron-sl-mx8mm_defconfig b/configs/kontron-sl-mx8mm_defconfig index 42346a305f9..ed60d3b9ce4 100644 --- a/configs/kontron-sl-mx8mm_defconfig +++ b/configs/kontron-sl-mx8mm_defconfig @@ -11,6 +11,7 @@ CONFIG_ENV_OFFSET=0x1E0000 CONFIG_ENV_SECT_SIZE=0x10000 CONFIG_IMX_CONFIG="board/kontron/sl-mx8mm/imximage.cfg" CONFIG_DM_GPIO=y +CONFIG_KONTRON_HW_UID=y CONFIG_SPL_DM_SPI=y CONFIG_DEFAULT_DEVICE_TREE="freescale/imx8mm-kontron-bl" CONFIG_TARGET_KONTRON_MX8MM=y