MLK-14938-6 imx8: Add fuse driver to wrap SCFW API
authorYe Li <ye.li@nxp.com>
Wed, 17 May 2017 07:06:15 +0000 (02:06 -0500)
committerJason Liu <jason.hui.liu@nxp.com>
Thu, 2 Nov 2017 18:36:49 +0000 (02:36 +0800)
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>
arch/arm/cpu/armv8/imx8/Makefile
arch/arm/cpu/armv8/imx8/fuse.c [new file with mode: 0644]

index 6210dcd..f60ee6e 100644 (file)
@@ -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/cpu/armv8/imx8/fuse.c b/arch/arm/cpu/armv8/imx8/fuse.c
new file mode 100644 (file)
index 0000000..bea76bc
--- /dev/null
@@ -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/imx-common/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;
+}