Message ID | 20211128160253.1468839-2-angus@akkea.ca |
---|---|
State | Accepted |
Commit | b4f0c7f613177e41894a9153e55adb8fec8d7bc0 |
Delegated to: | Stefano Babic |
Headers | show |
Series | [1/2] cmd: fuse: add a fuse comparison function | expand |
Are there any problems with this patch ? Thanks Angus On 2021-11-28 08:02, Angus Ainslie wrote: > With the fuse values in memory we can use some of the other u-boot > shell > conditonal operators to do tests. > > Signed-off-by: Angus Ainslie <angus@akkea.ca> > --- > cmd/fuse.c | 27 +++++++++++++++++++++++++++ > 1 file changed, 27 insertions(+) > > diff --git a/cmd/fuse.c b/cmd/fuse.c > index 78b1065d99e..0676bb7a812 100644 > --- a/cmd/fuse.c > +++ b/cmd/fuse.c > @@ -12,6 +12,7 @@ > #include <command.h> > #include <console.h> > #include <fuse.h> > +#include <mapmem.h> > #include <linux/errno.h> > > static int strtou32(const char *str, unsigned int base, u32 *result) > @@ -46,6 +47,8 @@ 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, cmp; > + ulong addr; > + void *buf, *start; > int ret, i; > > argc -= 2 + confirmed; > @@ -73,6 +76,28 @@ static int do_fuse(struct cmd_tbl *cmdtp, int flag, > int argc, > printf(" %.8x", val); > } > putc('\n'); > + } else if (!strcmp(op, "readm")) { > + if (argc == 3) > + cnt = 1; > + else if (argc != 4 || strtou32(argv[3], 0, &cnt)) > + return CMD_RET_USAGE; > + > + addr = simple_strtoul(argv[2], NULL, 16); > + > + start = map_sysmem(addr, 4); > + buf = start; > + > + printf("Reading bank %u len %u to 0x%lx\n", bank, cnt, addr); > + for (i = 0; i < cnt; i++, word++) { > + ret = fuse_read(bank, word, &val); > + if (ret) > + goto err; > + > + *((u32 *)buf) = val; > + buf += 4; > + } > + > + unmap_sysmem(start); > } else if (!strcmp(op, "cmp")) { > if (argc != 3 || strtou32(argv[2], 0, &cmp)) > return CMD_RET_USAGE; > @@ -157,6 +182,8 @@ U_BOOT_CMD( > " starting at 'word'\n" > "fuse cmp <bank> <word> <hexval> - compare 'hexval' to fuse\n" > " at 'word'\n" > + "fuse readm <bank> <word> <addr> [<cnt>] - read 1 or 'cnt' fuse > words,\n" > + " starting at 'word' into memory at 'addr'\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"
> With the fuse values in memory we can use some of the other u-boot shell > conditonal operators to do tests. > Signed-off-by: Angus Ainslie <angus@akkea.ca> Applied to u-boot-imx, master, thanks ! Best regards, Stefano Babic
diff --git a/cmd/fuse.c b/cmd/fuse.c index 78b1065d99e..0676bb7a812 100644 --- a/cmd/fuse.c +++ b/cmd/fuse.c @@ -12,6 +12,7 @@ #include <command.h> #include <console.h> #include <fuse.h> +#include <mapmem.h> #include <linux/errno.h> static int strtou32(const char *str, unsigned int base, u32 *result) @@ -46,6 +47,8 @@ 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, cmp; + ulong addr; + void *buf, *start; int ret, i; argc -= 2 + confirmed; @@ -73,6 +76,28 @@ static int do_fuse(struct cmd_tbl *cmdtp, int flag, int argc, printf(" %.8x", val); } putc('\n'); + } else if (!strcmp(op, "readm")) { + if (argc == 3) + cnt = 1; + else if (argc != 4 || strtou32(argv[3], 0, &cnt)) + return CMD_RET_USAGE; + + addr = simple_strtoul(argv[2], NULL, 16); + + start = map_sysmem(addr, 4); + buf = start; + + printf("Reading bank %u len %u to 0x%lx\n", bank, cnt, addr); + for (i = 0; i < cnt; i++, word++) { + ret = fuse_read(bank, word, &val); + if (ret) + goto err; + + *((u32 *)buf) = val; + buf += 4; + } + + unmap_sysmem(start); } else if (!strcmp(op, "cmp")) { if (argc != 3 || strtou32(argv[2], 0, &cmp)) return CMD_RET_USAGE; @@ -157,6 +182,8 @@ U_BOOT_CMD( " starting at 'word'\n" "fuse cmp <bank> <word> <hexval> - compare 'hexval' to fuse\n" " at 'word'\n" + "fuse readm <bank> <word> <addr> [<cnt>] - read 1 or 'cnt' fuse words,\n" + " starting at 'word' into memory at 'addr'\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"
With the fuse values in memory we can use some of the other u-boot shell conditonal operators to do tests. Signed-off-by: Angus Ainslie <angus@akkea.ca> --- cmd/fuse.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)