From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH v2 2/9] soc: imx8mp: Soc ID is 128bit
Date: Mon, 17 Nov 2025 09:35:35 +0100 [thread overview]
Message-ID: <20251117-soc-uid-v2-2-a2415bf9133d@pengutronix.de> (raw)
In-Reply-To: <20251117-soc-uid-v2-0-a2415bf9133d@pengutronix.de>
On i.MX8MP the SoC ID has 128 bits instead of 64 bits as on other i.MX8M
SoCs. Read the remaining 64 bits which so far haven't been included in
the SoC ID.
On already rolled out devices a change of the SoC ID is undesired, so
this commit introduces CONFIG_ARCH_IMX8MP_KEEP_COMPATIBLE_SOC_UID. With
this option enabled the old SoC ID will be used.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-imx/Kconfig | 10 ++++++++++
drivers/soc/imx/soc-imx8m.c | 33 +++++++++++++++++++++++----------
include/mach/imx/generic.h | 5 +++++
3 files changed, 38 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
index 5f50d1a8233ca0e034e5f9b83343a02e7b6a35b8..3edf95af2b1896ad9d5cb0981e54d2af372dd49c 100644
--- a/arch/arm/mach-imx/Kconfig
+++ b/arch/arm/mach-imx/Kconfig
@@ -823,6 +823,16 @@ config IMX_SAVE_BOOTROM_LOG
bool
default CMD_BOOTROM
+config ARCH_IMX8MP_KEEP_COMPATIBLE_SOC_UID
+ bool "Keep compatible i.MX8MP SOC UID"
+ depends on ARCH_IMX8MP
+ help
+ barebox used to wrongly read out the i.MX8MP SOC UID. The SOC UID on
+ i.MX8MP is 128bits wide, but we used to only use 64bit. As the
+ machine_id might be generated from the SOC UID already deployed
+ systems might depend on the SOC UID staying constant. Enable this
+ option to keep the old behaviour.
+
config HAB
bool
diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c
index 3b83284fcbfd56d543cc300b8d42771202aa0bbb..06c524308e83b2d2b57615b9dc60652400f202e2 100644
--- a/drivers/soc/imx/soc-imx8m.c
+++ b/drivers/soc/imx/soc-imx8m.c
@@ -48,7 +48,7 @@ struct imx8_soc_data {
void (*save_boot_loc)(void);
};
-static u64 soc_uid;
+static u64 soc_uid[2];
#ifdef CONFIG_HAVE_ARM_SMCCC
static u32 imx8mq_soc_revision_from_atf(void)
@@ -99,9 +99,9 @@ static u32 __init imx8mq_soc_revision(void)
rev = REV_B1;
}
- soc_uid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH);
- soc_uid <<= 32;
- soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW);
+ soc_uid[0] = readl_relaxed(ocotp_base + OCOTP_UID_HIGH);
+ soc_uid[0] <<= 32;
+ soc_uid[0] |= readl_relaxed(ocotp_base + OCOTP_UID_LOW);
/* Keep the OCOTP clk on for the TF-A else the CPU stuck */
of_node_put(np);
@@ -109,13 +109,16 @@ static u32 __init imx8mq_soc_revision(void)
return rev;
}
+#define IMX8MP_OCOTP_UID_2_LOW 0xe00
+#define IMX8MP_OCOTP_UID_2_HIGH 0xe10
+
static void __init imx8mm_soc_uid(void)
{
void __iomem *ocotp_base;
struct device_node *np;
struct clk *clk;
- u32 offset = of_machine_is_compatible("fsl,imx8mp") ?
- IMX8MP_OCOTP_UID_OFFSET : 0;
+ bool is_imx8mp = of_machine_is_compatible("fsl,imx8mp");
+ u32 offset = is_imx8mp ? IMX8MP_OCOTP_UID_OFFSET : 0;
np = of_find_compatible_node(NULL, NULL, "fsl,imx8mm-ocotp");
if (!np)
@@ -131,9 +134,15 @@ static void __init imx8mm_soc_uid(void)
clk_prepare_enable(clk);
- soc_uid = readl_relaxed(ocotp_base + OCOTP_UID_HIGH + offset);
- soc_uid <<= 32;
- soc_uid |= readl_relaxed(ocotp_base + OCOTP_UID_LOW + offset);
+ soc_uid[0] = readl_relaxed(ocotp_base + OCOTP_UID_HIGH + offset);
+ soc_uid[0] <<= 32;
+ soc_uid[0] |= readl_relaxed(ocotp_base + OCOTP_UID_LOW + offset);
+
+ if (is_imx8mp) {
+ soc_uid[1] = readl_relaxed(ocotp_base + IMX8MP_OCOTP_UID_2_HIGH);
+ soc_uid[1] <<= 32;
+ soc_uid[1] |= readl_relaxed(ocotp_base + IMX8MP_OCOTP_UID_2_LOW);
+ }
/* Keep the OCOTP clk on for the TF-A else the CPU stuck */
of_node_put(np);
@@ -265,7 +274,11 @@ static int __init imx8_soc_init(void)
goto free_soc;
}
- soc_dev_attr->serial_number = xasprintf("%016llX", soc_uid);
+ if (soc_uid[1] && !imx8mp_keep_compatible_soc_uid())
+ soc_dev_attr->serial_number = xasprintf("%016llX%016llX",
+ soc_uid[1], soc_uid[0]);
+ else
+ soc_dev_attr->serial_number = xasprintf("%016llX", soc_uid[0]);
if (!soc_dev_attr->serial_number) {
ret = -ENOMEM;
goto free_rev;
diff --git a/include/mach/imx/generic.h b/include/mach/imx/generic.h
index a0f65391686b479136f08b699fca34c45d915761..5f81aa65a7452f30084acd61a04d47d429e99d12 100644
--- a/include/mach/imx/generic.h
+++ b/include/mach/imx/generic.h
@@ -77,6 +77,11 @@ void imx8mn_cpu_lowlevel_init(void);
void imx8mp_cpu_lowlevel_init(void);
void imx93_cpu_lowlevel_init(void);
+static inline bool imx8mp_keep_compatible_soc_uid(void)
+{
+ return IS_ENABLED(CONFIG_ARCH_IMX8MP_KEEP_COMPATIBLE_SOC_UID);
+}
+
/* There's a off-by-one betweem the gpio bank number and the gpiochip */
/* range e.g. GPIO_1_5 is gpio 5 under linux */
#define IMX_GPIO_NR(bank, nr) (((bank) - 1) * 32 + (nr))
--
2.47.3
next prev parent reply other threads:[~2025-11-17 8:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-17 8:35 [PATCH v2 0/9] Unify SoC UID and machine hashable data Sascha Hauer
2025-11-17 8:35 ` [PATCH v2 1/9] introduce SoC UID Sascha Hauer
2025-11-17 10:16 ` Jonas Rebmann
2025-11-17 11:28 ` Sascha Hauer
2025-11-17 8:35 ` Sascha Hauer [this message]
2025-11-17 9:59 ` [PATCH v2 2/9] soc: imx8mp: Soc ID is 128bit Jonas Rebmann
2025-11-17 11:02 ` Sascha Hauer
2025-11-17 8:35 ` [PATCH v2 3/9] ARM: i.MX6: print leading zero for SoC ID Sascha Hauer
2025-11-17 8:35 ` [PATCH v2 4/9] nvmem: bsec: call barebox_set_soc_uid() Sascha Hauer
2025-11-17 8:35 ` [PATCH v2 5/9] nvmem: imx-ocotp-ele: " Sascha Hauer
2025-11-17 8:35 ` [PATCH v2 6/9] nvmem: ocotp: Fix SoC ID reading for i.MX8MP Sascha Hauer
2025-11-17 8:35 ` [PATCH v2 7/9] nvmem: imx-ocotp: call barebox_set_soc_uid() Sascha Hauer
2025-11-17 8:35 ` [PATCH v2 8/9] soc: imx8m: register SoC UID Sascha Hauer
2025-11-17 8:35 ` [PATCH v2 9/9] Documentation: migration: add i.MX8MP SoC UID change note Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251117-soc-uid-v2-2-a2415bf9133d@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox