summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYe Li <ye.li@nxp.com>2017-05-17 02:06:15 -0500
committerYe Li <ye.li@nxp.com>2018-04-27 02:32:21 -0700
commit2f0e86f274a419d14c961137c883e1d9e599c084 (patch)
tree2b651b334a1f2bfd7658617d7977cc5c4dd8eeac
parent3cfed63d0aa557f0d4e16ba452b303b7cab2f4c6 (diff)
MLK-14938-6 imx8: Add fuse driver to wrap SCFW API
Implement a fuse driver to wrap the SCFW OCOTP API and provide interfaces to u-boot fuse command. So that we can use "fuse read" or "fuse sense" command. Since there is no concept of fuse bank on i.MX8. Need set "bank" parameter to 0 when using the fuse command. Signed-off-by: Ye Li <ye.li@nxp.com> (cherry picked from commit 2c8b160f9c5b96434bce87108f82b1bb434abaa5)
-rw-r--r--arch/arm/mach-imx/imx8/Makefile1
-rw-r--r--arch/arm/mach-imx/imx8/fuse.c52
2 files changed, 53 insertions, 0 deletions
diff --git a/arch/arm/mach-imx/imx8/Makefile b/arch/arm/mach-imx/imx8/Makefile
index 6210dcd602..f60ee6ea9c 100644
--- a/arch/arm/mach-imx/imx8/Makefile
+++ b/arch/arm/mach-imx/imx8/Makefile
@@ -7,3 +7,4 @@
obj-y += cpu.o
obj-y += clock.o
obj-y += fsl_mu_hal.o
+obj-y += fuse.o
diff --git a/arch/arm/mach-imx/imx8/fuse.c b/arch/arm/mach-imx/imx8/fuse.c
new file mode 100644
index 0000000000..537350a79c
--- /dev/null
+++ b/arch/arm/mach-imx/imx8/fuse.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2017 NXP
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ *
+ */
+
+#include <common.h>
+#include <errno.h>
+#include <asm/io.h>
+#include <fuse.h>
+#include <asm/mach-imx/sci/sci.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int fuse_read(u32 bank, u32 word, u32 *val)
+{
+ return fuse_sense(bank, word, val);
+}
+
+int fuse_sense(u32 bank, u32 word, u32 *val)
+{
+ sc_err_t err;
+ sc_ipc_t ipc;
+
+ if (bank != 0) {
+ printf("Invalid bank argument, ONLY bank 0 is supported\n");
+ return -EINVAL;
+ }
+
+ ipc = gd->arch.ipc_channel_handle;
+
+ err = sc_misc_otp_fuse_read(ipc, word, val);
+ if (err != SC_ERR_NONE) {
+ printf("fuse read error: %d\n", err);
+ return -EIO;
+ }
+
+ return 0;
+}
+
+int fuse_prog(u32 bank, u32 word, u32 val)
+{
+ printf("Program fuse to i.MX8 in u-boot is forbidden\n");
+ return -EPERM;
+}
+
+int fuse_override(u32 bank, u32 word, u32 val)
+{
+ printf("Override fuse to i.MX8 in u-boot is forbidden\n");
+ return -EPERM;
+}