summaryrefslogtreecommitdiff
path: root/drivers/misc/k3_fuse.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2025-04-07 16:40:02 -0600
committerTom Rini <trini@konsulko.com>2025-04-08 11:43:23 -0600
commitff61d6bfd1c9534d3fc2397846a5899639f2e55d (patch)
treedcfe4bc52848a5637c975a3352b57885e5b8a06d /drivers/misc/k3_fuse.c
parent34820924edbc4ec7803eb89d9852f4b870fa760a (diff)
parentf892a7f397a66d8d09f418d1e0e06dfb48bac27d (diff)
Merge branch 'next'
Note that this undoes the changes of commit cf6d4535cc4c ("x86: emulation: Disable bloblist for now") as that was intended only for the release due to time.
Diffstat (limited to 'drivers/misc/k3_fuse.c')
-rw-r--r--drivers/misc/k3_fuse.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/drivers/misc/k3_fuse.c b/drivers/misc/k3_fuse.c
new file mode 100644
index 00000000000..4a8ff1f2523
--- /dev/null
+++ b/drivers/misc/k3_fuse.c
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2025 Texas Instruments Incorporated, <www.ti.com>
+ */
+
+#include <errno.h>
+#include <stdio.h>
+#include <fuse.h>
+#include <linux/arm-smccc.h>
+#include <string.h>
+
+#define K3_SIP_OTP_WRITEBUFF 0xC2000000
+#define K3_SIP_OTP_WRITE 0xC2000001
+#define K3_SIP_OTP_READ 0xC2000002
+
+int fuse_read(u32 bank, u32 word, u32 *val)
+{
+ struct arm_smccc_res res;
+
+ if (bank != 0U) {
+ printf("Invalid bank argument, ONLY bank 0 is supported\n");
+ return -EINVAL;
+ }
+
+ /* Make SiP SMC call and send the word in the parameter register */
+ arm_smccc_smc(K3_SIP_OTP_READ, word,
+ 0, 0, 0, 0, 0, 0, &res);
+
+ *val = res.a1;
+ if (res.a0 != 0)
+ printf("SMC call failed: Error code %lu\n", res.a0);
+
+ return res.a0;
+}
+
+int fuse_sense(u32 bank, u32 word, u32 *val)
+{
+ return -EPERM;
+}
+
+int fuse_prog(u32 bank, u32 word, u32 val)
+{
+ struct arm_smccc_res res;
+ u32 mask = val;
+
+ if (bank != 0U) {
+ printf("Invalid bank argument, ONLY bank 0 is supported\n");
+ return -EINVAL;
+ }
+
+ /* Make SiP SMC call and send the word, val and mask in the parameter register */
+ arm_smccc_smc(K3_SIP_OTP_WRITE, word,
+ val, mask, 0, 0, 0, 0, &res);
+
+ if (res.a0 != 0)
+ printf("SMC call failed: Error code %lu\n", res.a0);
+
+ return res.a0;
+}
+
+int fuse_override(u32 bank, u32 word, u32 val)
+{
+ return -EPERM;
+}
+
+int fuse_writebuff(ulong addr)
+{
+ struct arm_smccc_res res;
+
+ /* Make SiP SMC call and send the addr in the parameter register */
+ arm_smccc_smc(K3_SIP_OTP_WRITEBUFF, (unsigned long)addr,
+ 0, 0, 0, 0, 0, 0, &res);
+
+ if (res.a0 != 0)
+ printf("SMC call failed: Error code %lu\n", res.a0);
+
+ return res.a0;
+}