From: Fabian Pflug <f.pflug@pengutronix.de>
To: Marco Felsch <m.felsch@pengutronix.de>,
BAREBOX <barebox@lists.infradead.org>,
Lucas Stach <l.stach@pengutronix.de>,
Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: Fabian Pflug <f.pflug@pengutronix.de>
Subject: [PATCH v3 3/5] i.MX: HAB: extend field_return support to imx6
Date: Fri, 19 Dec 2025 11:49:01 +0100 [thread overview]
Message-ID: <20251219-v2025-11-0-topic-imx6-field-return-v3-3-690fdeb78978@pengutronix.de> (raw)
In-Reply-To: <20251219-v2025-11-0-topic-imx6-field-return-v3-0-690fdeb78978@pengutronix.de>
Extend the helper for imx_fuse_burn with support for i.MX6 devices.
Create a helper function for i.MX8 and i.MX6 rom the old i.MX8M
function, as they all share the same pattern.
Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>
Signed-off-by: Fabian Pflug <f.pflug@pengutronix.de>
---
drivers/hab/hab.c | 34 +++++++++++++++++++++-------------
include/mach/imx/ocotp-fusemap.h | 1 +
2 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/drivers/hab/hab.c b/drivers/hab/hab.c
index 1c747e8a3e..de0a6c73d6 100644
--- a/drivers/hab/hab.c
+++ b/drivers/hab/hab.c
@@ -256,13 +256,7 @@ static int imx8m_hab_revoke_key_ocotp(unsigned key_idx)
return ret;
}
-/*
- * The fuse pattern for i.MX8M Plus is 0x28001401, but bit 2 is already set from factory.
- * This means when field return is set, the fuse word value reads 0x28001405
- */
-#define MX8MP_FIELD_RETURN_PATTERN 0x28001401
-
-static int imx8m_hab_field_return_ocotp(void)
+static int imx_hab_field_return_ocotp(uint32_t field, unsigned int value)
{
int ret;
@@ -274,13 +268,26 @@ static int imx8m_hab_field_return_ocotp(void)
if (ret == 1)
return -EINVAL;
- if (cpu_is_mx8mp())
- ret = imx_ocotp_write_field(MX8MP_OCOTP_FIELD_RETURN,
- MX8MP_FIELD_RETURN_PATTERN);
- else
- ret = imx_ocotp_write_field(MX8M_OCOTP_FIELD_RETURN, 1);
+ return imx_ocotp_write_field(field, value);
+}
- return ret;
+static int imx6_hab_field_return_ocotp(void)
+{
+ return imx_hab_field_return_ocotp(MX6_OCOTP_FIELD_RETURN, 1);
+}
+
+/*
+ * The fuse pattern for i.MX8M Plus is 0x28001401, but bit 2 is already set from factory.
+ * This means when field return is set, the fuse word value reads 0x28001405
+ */
+#define MX8MP_FIELD_RETURN_PATTERN 0x28001401
+
+static int imx8m_hab_field_return_ocotp(void)
+{
+ if (cpu_is_mx8mp())
+ return imx_hab_field_return_ocotp(MX8MP_OCOTP_FIELD_RETURN,
+ MX8MP_FIELD_RETURN_PATTERN);
+ return imx_hab_field_return_ocotp(MX8M_OCOTP_FIELD_RETURN, 1);
}
struct imx_hab_ops {
@@ -310,6 +317,7 @@ static struct imx_hab_ops imx6_hab_ops_ocotp = {
.device_locked_down = imx6_hab_device_locked_down_ocotp,
.permanent_write_enable = imx_hab_permanent_write_enable_ocotp,
.print_status = imx6_hab_print_status,
+ .field_return = imx6_hab_field_return_ocotp,
};
static struct imx_hab_ops imx8m_hab_ops_ocotp = {
diff --git a/include/mach/imx/ocotp-fusemap.h b/include/mach/imx/ocotp-fusemap.h
index ae10dcef2a..3fd9d6df24 100644
--- a/include/mach/imx/ocotp-fusemap.h
+++ b/include/mach/imx/ocotp-fusemap.h
@@ -103,6 +103,7 @@
#define MX8M_OCOTP_TZASC_EN (OCOTP_WORD(0x480) | OCOTP_BIT(11) | OCOTP_WIDTH(1))
#define MX8MP_OCOTP_ROM_NO_LOG (OCOTP_WORD(0x480) | OCOTP_BIT(22) | OCOTP_WIDTH(1))
#define MX8M_OCOTP_RECOVERY_SDMMC_BOOT_DIS (OCOTP_WORD(0x490) | OCOTP_BIT(23) | OCOTP_WIDTH(1))
+#define MX6_OCOTP_FIELD_RETURN (OCOTP_WORD(0x6E0) | OCOTP_BIT(0) | OCOTP_WIDTH(1))
#define MX8M_OCOTP_FIELD_RETURN (OCOTP_WORD(0x630) | OCOTP_BIT(0) | OCOTP_WIDTH(1))
#define MX8MP_OCOTP_FIELD_RETURN (OCOTP_WORD(0x630) | OCOTP_BIT(0) | OCOTP_WIDTH(32))
#define MX8M_OCOTP_SRK_REVOKE (OCOTP_WORD(0x670) | OCOTP_BIT(0) | OCOTP_WIDTH(4))
--
2.47.3
next prev parent reply other threads:[~2025-12-19 10:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-19 10:48 [PATCH v3 0/5] i.mx: hab/ocotop: extend field return to i.MX6 Fabian Pflug
2025-12-19 10:48 ` [PATCH v3 1/5] arm: mach-imx6: use kconfig for field return Fabian Pflug
2025-12-19 10:49 ` [PATCH v3 2/5] nvmem: ocotp: extend support to query the sticky bit Fabian Pflug
2025-12-19 10:49 ` Fabian Pflug [this message]
2025-12-19 10:49 ` [PATCH v3 4/5] commands: hab: extend by field_return fuse burn Fabian Pflug
2025-12-19 10:49 ` [PATCH v3 5/5] i.MX: HAB: fix field return unlock fuse uid Fabian Pflug
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=20251219-v2025-11-0-topic-imx6-field-return-v3-3-690fdeb78978@pengutronix.de \
--to=f.pflug@pengutronix.de \
--cc=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=l.stach@pengutronix.de \
--cc=m.felsch@pengutronix.de \
/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