* [PATCH 1/2] cmd: fuse: add a fuse comparison function
@ 2021-11-28 16:02 Angus Ainslie
2021-11-28 16:02 ` [PATCH 2/2] cmd: fuse: Add a command to read fuses to memory Angus Ainslie
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Angus Ainslie @ 2021-11-28 16:02 UTC (permalink / raw)
To: u-boot; +Cc: kernel, Angus Ainslie
Compare a hexval to the fuse value and return pass or fail.
Signed-off-by: Angus Ainslie <angus@akkea.ca>
---
cmd/fuse.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/cmd/fuse.c b/cmd/fuse.c
index e001619d172..78b1065d99e 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"
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] cmd: fuse: Add a command to read fuses to memory
2021-11-28 16:02 [PATCH 1/2] cmd: fuse: add a fuse comparison function Angus Ainslie
@ 2021-11-28 16:02 ` Angus Ainslie
2022-01-14 14:57 ` Angus Ainslie
2022-02-19 13:08 ` sbabic
2022-01-14 14:56 ` [PATCH 1/2] cmd: fuse: add a fuse comparison function Angus Ainslie
2022-02-19 13:08 ` sbabic
2 siblings, 2 replies; 6+ messages in thread
From: Angus Ainslie @ 2021-11-28 16:02 UTC (permalink / raw)
To: u-boot; +Cc: kernel, Angus Ainslie
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"
--
2.25.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] cmd: fuse: add a fuse comparison function
2021-11-28 16:02 [PATCH 1/2] cmd: fuse: add a fuse comparison function Angus Ainslie
2021-11-28 16:02 ` [PATCH 2/2] cmd: fuse: Add a command to read fuses to memory Angus Ainslie
@ 2022-01-14 14:56 ` Angus Ainslie
2022-02-19 13:08 ` sbabic
2 siblings, 0 replies; 6+ messages in thread
From: Angus Ainslie @ 2022-01-14 14:56 UTC (permalink / raw)
To: u-boot; +Cc: kernel, uboot-imx
Are there any problems with this patch ?
Thanks
Angus
On 2021-11-28 08:02, Angus Ainslie wrote:
> Compare a hexval to the fuse value and return pass or fail.
>
> Signed-off-by: Angus Ainslie <angus@akkea.ca>
> ---
> cmd/fuse.c | 22 +++++++++++++++++++++-
> 1 file changed, 21 insertions(+), 1 deletion(-)
>
> diff --git a/cmd/fuse.c b/cmd/fuse.c
> index e001619d172..78b1065d99e 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"
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] cmd: fuse: Add a command to read fuses to memory
2021-11-28 16:02 ` [PATCH 2/2] cmd: fuse: Add a command to read fuses to memory Angus Ainslie
@ 2022-01-14 14:57 ` Angus Ainslie
2022-02-19 13:08 ` sbabic
1 sibling, 0 replies; 6+ messages in thread
From: Angus Ainslie @ 2022-01-14 14:57 UTC (permalink / raw)
To: u-boot; +Cc: kernel, uboot-imx
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"
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] cmd: fuse: add a fuse comparison function
2021-11-28 16:02 [PATCH 1/2] cmd: fuse: add a fuse comparison function Angus Ainslie
2021-11-28 16:02 ` [PATCH 2/2] cmd: fuse: Add a command to read fuses to memory Angus Ainslie
2022-01-14 14:56 ` [PATCH 1/2] cmd: fuse: add a fuse comparison function Angus Ainslie
@ 2022-02-19 13:08 ` sbabic
2 siblings, 0 replies; 6+ messages in thread
From: sbabic @ 2022-02-19 13:08 UTC (permalink / raw)
To: Angus Ainslie, u-boot
> Compare a hexval to the fuse value and return pass or fail.
> Signed-off-by: Angus Ainslie <angus@akkea.ca>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] cmd: fuse: Add a command to read fuses to memory
2021-11-28 16:02 ` [PATCH 2/2] cmd: fuse: Add a command to read fuses to memory Angus Ainslie
2022-01-14 14:57 ` Angus Ainslie
@ 2022-02-19 13:08 ` sbabic
1 sibling, 0 replies; 6+ messages in thread
From: sbabic @ 2022-02-19 13:08 UTC (permalink / raw)
To: Angus Ainslie, u-boot
> 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
--
=====================================================================
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-02-19 13:10 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-28 16:02 [PATCH 1/2] cmd: fuse: add a fuse comparison function Angus Ainslie
2021-11-28 16:02 ` [PATCH 2/2] cmd: fuse: Add a command to read fuses to memory Angus Ainslie
2022-01-14 14:57 ` Angus Ainslie
2022-02-19 13:08 ` sbabic
2022-01-14 14:56 ` [PATCH 1/2] cmd: fuse: add a fuse comparison function Angus Ainslie
2022-02-19 13:08 ` sbabic
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox