[PATCH] misc: mxc_ocotp: check fuse word before programming on i.MX7ULP

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] misc: mxc_ocotp: check fuse word before programming on i.MX7ULP

Peng Fan-4
On i.MX7ULP, the fuse words (except bank 0 and 1) only supports to
write once, because they use ECC mode. Multiple writes may damage
the ECC value and cause a wrong fuse value decoded when reading.
This patch adds a checking before the fuse word programming, only
can write when the word value is 0.

Signed-off-by: Ye Li <[hidden email]>
Signed-off-by: Peng Fan <[hidden email]>
---
 drivers/misc/mxc_ocotp.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/misc/mxc_ocotp.c b/drivers/misc/mxc_ocotp.c
index 8986bb4ad0..18a2730909 100644
--- a/drivers/misc/mxc_ocotp.c
+++ b/drivers/misc/mxc_ocotp.c
@@ -342,6 +342,23 @@ int fuse_sense(u32 bank, u32 word, u32 *val)
 static int prepare_write(struct ocotp_regs **regs, u32 bank, u32 word,
  const char *caller)
 {
+#ifdef CONFIG_MX7ULP
+ u32 val;
+ int ret;
+
+ /* Only bank 0 and 1 are redundancy mode, others are ECC mode */
+ if (bank != 0 && bank != 1) {
+ ret = fuse_sense(bank, word, &val);
+ if (ret)
+ return ret;
+
+ if (val != 0) {
+ printf("mxc_ocotp: The word has been programmed, no more write\n");
+ return -EPERM;
+ }
+ }
+#endif
+
  return prepare_access(regs, bank, word, true, caller);
 }
 
--
2.14.1

_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] misc: mxc_ocotp: check fuse word before programming on i.MX7ULP

Stefano Babic
On 02/01/2018 08:51, Peng Fan wrote:
> On i.MX7ULP, the fuse words (except bank 0 and 1) only supports to
> write once, because they use ECC mode. Multiple writes may damage
> the ECC value and cause a wrong fuse value decoded when reading.
> This patch adds a checking before the fuse word programming, only
> can write when the word value is 0.
>
> Signed-off-by: Ye Li <[hidden email]>
> Signed-off-by: Peng Fan <[hidden email]>
> ---

Applied to u-boot-imx, thanks !

Best regards,
Stefano Babic


--
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: [hidden email]
=====================================================================
_______________________________________________
U-Boot mailing list
[hidden email]
https://lists.denx.de/listinfo/u-boot