Skip to content

Commit b4f0c7f

Browse files
nytowlsbabic
authored andcommittedFeb 18, 2022
cmd: fuse: Add a command to read fuses to memory
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 <[email protected]>
1 parent c2a4af5 commit b4f0c7f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
 

‎cmd/fuse.c

+27
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <command.h>
1313
#include <console.h>
1414
#include <fuse.h>
15+
#include <mapmem.h>
1516
#include <linux/errno.h>
1617

1718
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,
4647
const char *op = argc >= 2 ? argv[1] : NULL;
4748
int confirmed = argc >= 3 && !strcmp(argv[2], "-y");
4849
u32 bank, word, cnt, val, cmp;
50+
ulong addr;
51+
void *buf, *start;
4952
int ret, i;
5053

5154
argc -= 2 + confirmed;
@@ -73,6 +76,28 @@ static int do_fuse(struct cmd_tbl *cmdtp, int flag, int argc,
7376
printf(" %.8x", val);
7477
}
7578
putc('\n');
79+
} else if (!strcmp(op, "readm")) {
80+
if (argc == 3)
81+
cnt = 1;
82+
else if (argc != 4 || strtou32(argv[3], 0, &cnt))
83+
return CMD_RET_USAGE;
84+
85+
addr = simple_strtoul(argv[2], NULL, 16);
86+
87+
start = map_sysmem(addr, 4);
88+
buf = start;
89+
90+
printf("Reading bank %u len %u to 0x%lx\n", bank, cnt, addr);
91+
for (i = 0; i < cnt; i++, word++) {
92+
ret = fuse_read(bank, word, &val);
93+
if (ret)
94+
goto err;
95+
96+
*((u32 *)buf) = val;
97+
buf += 4;
98+
}
99+
100+
unmap_sysmem(start);
76101
} else if (!strcmp(op, "cmp")) {
77102
if (argc != 3 || strtou32(argv[2], 0, &cmp))
78103
return CMD_RET_USAGE;
@@ -157,6 +182,8 @@ U_BOOT_CMD(
157182
" starting at 'word'\n"
158183
"fuse cmp <bank> <word> <hexval> - compare 'hexval' to fuse\n"
159184
" at 'word'\n"
185+
"fuse readm <bank> <word> <addr> [<cnt>] - read 1 or 'cnt' fuse words,\n"
186+
" starting at 'word' into memory at 'addr'\n"
160187
"fuse sense <bank> <word> [<cnt>] - sense 1 or 'cnt' fuse words,\n"
161188
" starting at 'word'\n"
162189
"fuse prog [-y] <bank> <word> <hexval> [<hexval>...] - program 1 or\n"

0 commit comments

Comments
 (0)
Please sign in to comment.