diff options
author | Peng Fan <peng.fan@nxp.com> | 2018-01-02 15:51:20 +0800 |
---|---|---|
committer | Stefano Babic <sbabic@denx.de> | 2018-01-12 14:28:04 +0100 |
commit | 8df42bee0e728707ef4f7e7d2b12b015a4a95200 (patch) | |
tree | b6c95fd6243915042eae8d307186675b72f513fe /drivers/misc/mxc_ocotp.c | |
parent | fb8cac936615e6e75237ce95ccaa09d8b109cae3 (diff) | |
download | u-boot-8df42bee0e728707ef4f7e7d2b12b015a4a95200.tar.gz |
misc: mxc_ocotp: check fuse word before programming on i.MX7ULP
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 <ye.li@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Diffstat (limited to 'drivers/misc/mxc_ocotp.c')
-rw-r--r-- | drivers/misc/mxc_ocotp.c | 17 |
1 files changed, 17 insertions, 0 deletions
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); } |