diff options
author | Ye Li <ye.li@nxp.com> | 2017-01-18 15:19:55 +0800 |
---|---|---|
committer | Ye Li <ye.li@nxp.com> | 2017-01-18 16:03:06 +0800 |
commit | e8447d649a631ec98120d84fab124ca29fbe39f0 (patch) | |
tree | 011046dbd9a1adf9c7f32e48d499ee741a2082d7 | |
parent | 52c5c2851bdeddbb0c6ced802bdca938bc5d9cf8 (diff) | |
download | u-boot-imx-e8447d649a631ec98120d84fab124ca29fbe39f0.zip u-boot-imx-e8447d649a631ec98120d84fab124ca29fbe39f0.tar.gz u-boot-imx-e8447d649a631ec98120d84fab124ca29fbe39f0.tar.bz2 |
MLK-13776 ocotp: Add fuse word checking before programming it 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>
-rw-r--r-- | drivers/misc/mxc_ocotp.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/misc/mxc_ocotp.c b/drivers/misc/mxc_ocotp.c index ab3565e..29c597e 100644 --- a/drivers/misc/mxc_ocotp.c +++ b/drivers/misc/mxc_ocotp.c @@ -8,6 +8,7 @@ * http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/drivers/misc/imx_otp.c?h=imx_v2009.08_1.1.0&id=9aa74e6, * which is: * Copyright (C) 2011-2016 Freescale Semiconductor, Inc. + * Copyright 2017 NXP * * SPDX-License-Identifier: GPL-2.0+ */ @@ -343,6 +344,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); } |