diff options
author | Han Xu <han.xu@nxp.com> | 2020-05-05 22:04:04 +0800 |
---|---|---|
committer | Stefano Babic <sbabic@denx.de> | 2020-05-10 20:55:20 +0200 |
commit | f797fe84fc8e609443a1352bd816ee9cf328416d (patch) | |
tree | d4c5599d9df1beeb2c59b378df9e922b6b610f43 /arch | |
parent | 214b7d534d420e9377d7f9e4c364123e33b0233d (diff) | |
download | u-boot-f797fe84fc8e609443a1352bd816ee9cf328416d.zip u-boot-f797fe84fc8e609443a1352bd816ee9cf328416d.tar.gz u-boot-f797fe84fc8e609443a1352bd816ee9cf328416d.tar.bz2 |
nandbcb: read boot search count from fuse for imx8qxp
add support for imx8qxp to read boot search count from fuse in nandbcb
Signed-off-by: Han Xu <han.xu@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-imx/cmd_nandbcb.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/arch/arm/mach-imx/cmd_nandbcb.c b/arch/arm/mach-imx/cmd_nandbcb.c index ab12b1f..94cae14 100644 --- a/arch/arm/mach-imx/cmd_nandbcb.c +++ b/arch/arm/mach-imx/cmd_nandbcb.c @@ -27,6 +27,7 @@ #include <mxs_nand.h> #include <linux/mtd/mtd.h> #include <nand.h> +#include <fuse.h> #include "../../../cmd/legacy-mtd-utils.h" @@ -1260,6 +1261,35 @@ static bool check_fingerprint(void *data, int fingerprint) return (*(int *)(data + off) == fingerprint); } +static int fuse_to_search_count(u32 bank, u32 word, u32 mask, u32 off) +{ + int err; + u32 val; + int ret; + + /* by default, the boot search count from fuse should be 2 */ + err = fuse_read(bank, word, &val); + if (err) + return 2; + + val = (val & mask) >> off; + + switch (val) { + case 0: + ret = 2; + break; + case 1: + case 2: + case 3: + ret = 1 << val; + break; + default: + ret = 2; + } + + return ret; +} + static int nandbcb_dump(struct boot_config *boot_cfg) { int i; @@ -1459,7 +1489,14 @@ static int do_nandbcb(cmd_tbl_t *cmdtp, int flag, int argc, return CMD_RET_FAILURE; } - /* TODO: set the boot search count if need to read from fuse */ + if (plat_config.misc_flags & BT_SEARCH_CNT_FROM_FUSE) { + if (is_imx8qxp()) { + g_boot_search_count = fuse_to_search_count(0, 720, + 0xc0, 6); + printf("search count set to %d from fuse\n", + g_boot_search_count); + } + } cmd = argv[1]; --argc; |