summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2024-03-11 11:21:50 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2024-03-13 12:01:21 +0100
commit3b0dbcfa4c84dfce9022537a062e2c0e100038c3 (patch)
treedbd7bcdc7ba6b5ef6fa08e4f2c5ea34877a16551
parentcb6ee04c5b9eb9b7bfbd2d807f85b1c3ad9ec212 (diff)
downloadbarebox-3b0dbcfa4c84dfce9022537a062e2c0e100038c3.tar.gz
barebox-3b0dbcfa4c84dfce9022537a062e2c0e100038c3.tar.xz
ARM: i.MX: ele: add ele_write_shadow_fuse
The ocotp fuses have shadow values. For some fuses the shadow values can be read from and written to. While it's not really clear where the ROM really uses these shadow values, it still helps reading and writing them to get an idea if we are about to write the correct fuses before we finally enable permanent write. Link: https://lore.barebox.org/20240311102152.360762-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/arm/mach-imx/ele.c33
-rw-r--r--include/mach/imx/ele.h2
2 files changed, 35 insertions, 0 deletions
diff --git a/arch/arm/mach-imx/ele.c b/arch/arm/mach-imx/ele.c
index 0086366a33..48e8749b31 100644
--- a/arch/arm/mach-imx/ele.c
+++ b/arch/arm/mach-imx/ele.c
@@ -326,6 +326,39 @@ int ele_write_fuse(u16 fuse_id, u32 fuse_val, bool lock, u32 *response)
}
/*
+ * ele_write_shadow_fuse - write a fuse
+ * @fuse_id: The fuse to write to
+ * @fuse_val: The value to write to the fuse
+ * @lock: lock fuse after writing
+ * @response: on return contains the response from ELE
+ *
+ * This writes the 32bit given in @fuse_val to the fuses at @fuse_id. This is
+ * a permanent change, be careful.
+ *
+ * Return: 0 when the ELE call succeeds, negative error code otherwise
+ */
+int ele_write_shadow_fuse(u16 fuse_id, u32 fuse_val, u32 *response)
+{
+ struct ele_msg msg;
+ int ret;
+
+ msg.version = ELE_VERSION;
+ msg.tag = ELE_CMD_TAG;
+ msg.size = 3;
+ msg.command = ELE_WRITE_SHADOW_REQ;
+ msg.data[0] = fuse_id;
+
+ msg.data[1] = fuse_val;
+
+ ret = imx9_s3mua_call(&msg);
+
+ if (response)
+ *response = msg.data[0];
+
+ return ret;
+}
+
+/*
* ele_forward_lifecycle - forward lifecycle
* @lc: The lifecycle value to forward to
* @response: on return contains the response from ELE
diff --git a/include/mach/imx/ele.h b/include/mach/imx/ele.h
index da4b0aa50d..7ba8afde20 100644
--- a/include/mach/imx/ele.h
+++ b/include/mach/imx/ele.h
@@ -45,6 +45,7 @@
#define ELE_ATTEST_REQ (0xDB)
#define ELE_RELEASE_PATCH_REQ (0xDC)
#define ELE_OTP_SEQ_SWITH_REQ (0xDD)
+#define ELE_WRITE_SHADOW_REQ (0xF2)
#define ELE_READ_SHADOW_REQ (0xF3)
/* ELE failure indications */
@@ -152,6 +153,7 @@ int ele_call(struct ele_msg *msg);
int ele_read_common_fuse(u16 fuse_id, u32 *fuse_word, u32 *response);
int ele_release_rdc(u8 core_id, u8 xrdc, u32 *response);
int ele_read_shadow_fuse(u16 fuse_id, u32 *fuse_word, u32 *response);
+int ele_write_shadow_fuse(u16 fuse_id, u32 fuse_val, u32 *response);
int ele_get_info(struct ele_get_info_data *info);
int ele_write_fuse(u16 fuse_id, u32 fuse_val, bool lock, u32 *response);
int ele_authenticate_container(unsigned long addr, u32 *response);