[PATCH v2 8/9] soc: imx8m: register SoC UID
Sascha Hauer
s.hauer at pengutronix.de
Mon Nov 17 00:35:41 PST 2025
Just like the ocotp driver the i.MX8M SoC driver also reads the SoC UID.
Unlike the ocotp driver the i.MX8M SoC driver is always enabled, so if
we don't have the ocotp driver enabled then register the SoC UID from
the SoC driver.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/nvmem/ocotp.c | 12 ++++++++++--
drivers/soc/imx/soc-imx8m.c | 4 ++++
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/drivers/nvmem/ocotp.c b/drivers/nvmem/ocotp.c
index 4d12426275426acb69f8e8349cf56367a3f1f80d..fa80f1bfe2324d6667c789758bfd683451cb5f80 100644
--- a/drivers/nvmem/ocotp.c
+++ b/drivers/nvmem/ocotp.c
@@ -31,6 +31,7 @@
#ifdef CONFIG_ARCH_IMX
#include <mach/imx/ocotp.h>
#include <mach/imx/ocotp-fusemap.h>
+#include <mach/imx/generic.h>
#else
#include <mach/mxs/ocotp.h>
#include <mach/mxs/ocotp-fusemap.h>
@@ -853,6 +854,13 @@ static int imx_ocotp_init_dt(struct ocotp_priv *priv)
return imx8m_feat_ctrl_init(priv->dev.parent, tester3, tester4, priv->data->feat);
}
+#ifndef CONFIG_ARCH_IMX
+static inline bool imx8mp_keep_compatible_soc_uid(void)
+{
+ return false;
+}
+#endif
+
#define IMX8MP_OCOTP_UID(n) \
(OCOTP_WORD(0x420 + 0x10 * (n)) | OCOTP_BIT(0) | OCOTP_WIDTH(32))
#define IMX8MP_OCOTP_UID_2(n) \
@@ -865,7 +873,7 @@ static void imx_ocotp_set_unique_machine_id(void)
int len;
char *uidstr;
- if (is_imx8mp) {
+ if (is_imx8mp && !imx8mp_keep_compatible_soc_uid()) {
if (imx_ocotp_read_field(IMX8MP_OCOTP_UID(0), &uid[0]))
return;
if (imx_ocotp_read_field(IMX8MP_OCOTP_UID(1), &uid[1]))
@@ -887,7 +895,7 @@ static void imx_ocotp_set_unique_machine_id(void)
uidstr = xasprintf("%08X%08X", uid[1], uid[0]);
}
- barebox_set_soc_uid(uidstr, &uid, sizeof(uid));
+ barebox_set_soc_uid(uidstr, &uid, len);
free(uidstr);
}
diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-imx8m.c
index 06c524308e83b2d2b57615b9dc60652400f202e2..6f61bdb9e8d3f0bd05282d585a066d45a7ef5305 100644
--- a/drivers/soc/imx/soc-imx8m.c
+++ b/drivers/soc/imx/soc-imx8m.c
@@ -284,6 +284,10 @@ static int __init imx8_soc_init(void)
goto free_rev;
}
+ if (!IS_ENABLED(CONFIG_IMX_OCOTP))
+ barebox_set_soc_uid(soc_dev_attr->serial_number, soc_uid,
+ sizeof(soc_uid));
+
soc_dev = soc_device_register(soc_dev_attr);
if (IS_ERR(soc_dev)) {
ret = PTR_ERR(soc_dev);
--
2.47.3
More information about the barebox
mailing list