summaryrefslogtreecommitdiff
path: root/cmd/fuse.c
diff options
context:
space:
mode:
authorAngus Ainslie <angus@akkea.ca>2021-11-28 08:02:52 -0800
committerStefano Babic <sbabic@denx.de>2022-02-18 18:12:23 +0100
commitc2a4af5ca8032d69818bac6d4030233af50f09a9 (patch)
tree8652837e3633fcdfc7fe5c82a6ff6c828c165042 /cmd/fuse.c
parent8ad1c9c26f7740806a162818b790d4a72f515b7e (diff)
downloadu-boot-c2a4af5ca8032d69818bac6d4030233af50f09a9.tar.gz
u-boot-c2a4af5ca8032d69818bac6d4030233af50f09a9.tar.bz2
u-boot-c2a4af5ca8032d69818bac6d4030233af50f09a9.zip
cmd: fuse: add a fuse comparison function
Compare a hexval to the fuse value and return pass or fail. Signed-off-by: Angus Ainslie <angus@akkea.ca>
Diffstat (limited to 'cmd/fuse.c')
-rw-r--r--cmd/fuse.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/cmd/fuse.c b/cmd/fuse.c
index e001619d17..78b1065d99 100644
--- a/cmd/fuse.c
+++ b/cmd/fuse.c
@@ -45,7 +45,7 @@ static int do_fuse(struct cmd_tbl *cmdtp, int flag, int argc,
{
const char *op = argc >= 2 ? argv[1] : NULL;
int confirmed = argc >= 3 && !strcmp(argv[2], "-y");
- u32 bank, word, cnt, val;
+ u32 bank, word, cnt, val, cmp;
int ret, i;
argc -= 2 + confirmed;
@@ -73,6 +73,24 @@ static int do_fuse(struct cmd_tbl *cmdtp, int flag, int argc,
printf(" %.8x", val);
}
putc('\n');
+ } else if (!strcmp(op, "cmp")) {
+ if (argc != 3 || strtou32(argv[2], 0, &cmp))
+ return CMD_RET_USAGE;
+
+ printf("Comparing bank %u:\n", bank);
+ printf("\nWord 0x%.8x:", word);
+ printf("\nValue 0x%.8x:", cmp);
+
+ ret = fuse_read(bank, word, &val);
+ if (ret)
+ goto err;
+
+ printf("0x%.8x\n", val);
+ if (val != cmp) {
+ printf("failed\n");
+ return CMD_RET_FAILURE;
+ }
+ printf("passed\n");
} else if (!strcmp(op, "sense")) {
if (argc == 2)
cnt = 1;
@@ -137,6 +155,8 @@ U_BOOT_CMD(
"Fuse sub-system",
"read <bank> <word> [<cnt>] - read 1 or 'cnt' fuse words,\n"
" starting at 'word'\n"
+ "fuse cmp <bank> <word> <hexval> - compare 'hexval' to fuse\n"
+ " at 'word'\n"
"fuse sense <bank> <word> [<cnt>] - sense 1 or 'cnt' fuse words,\n"
" starting at 'word'\n"
"fuse prog [-y] <bank> <word> <hexval> [<hexval>...] - program 1 or\n"