mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-16 01:44:34 +00:00
cmd: fuse: Add fuse writebuff sub-system command
Add CMD_FUSE_WRITEBUFF config option to add and enable fuse writebuff sub-system command. Add fuse_writebuff function to be invoked on writebuff command. Signed-off-by: Harsha Vardhan V M <h-vm@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
833c05ea27
commit
578e7882bf
3 changed files with 42 additions and 5 deletions
|
@ -1236,6 +1236,14 @@ config CMD_FUSE
|
||||||
which control the behaviour of the device. The command uses the
|
which control the behaviour of the device. The command uses the
|
||||||
fuse_...() API.
|
fuse_...() API.
|
||||||
|
|
||||||
|
config CMD_FUSE_WRITEBUFF
|
||||||
|
bool "Support for the fuse writebuff"
|
||||||
|
depends on CMD_FUSE
|
||||||
|
help
|
||||||
|
This allows programming fuses, which control the behaviour of
|
||||||
|
the device, using a structured buffer in memory. The command
|
||||||
|
uses the fuse_writebuff() API.
|
||||||
|
|
||||||
config CMD_GPIO
|
config CMD_GPIO
|
||||||
bool "gpio"
|
bool "gpio"
|
||||||
help
|
help
|
||||||
|
|
30
cmd/fuse.c
30
cmd/fuse.c
|
@ -43,11 +43,18 @@ static int do_fuse(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
argc -= 2 + confirmed;
|
argc -= 2 + confirmed;
|
||||||
argv += 2 + confirmed;
|
argv += 2 + confirmed;
|
||||||
|
|
||||||
if (argc < 2)
|
if (IS_ENABLED(CONFIG_CMD_FUSE_WRITEBUFF) && !strcmp(op, "writebuff")) {
|
||||||
return CMD_RET_USAGE;
|
if (argc == 1)
|
||||||
|
addr = simple_strtoul(argv[0], NULL, 16);
|
||||||
|
else
|
||||||
|
return CMD_RET_USAGE;
|
||||||
|
} else {
|
||||||
|
if (argc < 2)
|
||||||
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
bank = simple_strtoul(argv[0], NULL, 0);
|
bank = simple_strtoul(argv[0], NULL, 0);
|
||||||
word = simple_strtoul(argv[1], NULL, 0);
|
word = simple_strtoul(argv[1], NULL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcmp(op, "read")) {
|
if (!strcmp(op, "read")) {
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
|
@ -161,6 +168,15 @@ static int do_fuse(struct cmd_tbl *cmdtp, int flag, int argc,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
} else if (IS_ENABLED(CONFIG_CMD_FUSE_WRITEBUFF) && !strcmp(op, "writebuff")) {
|
||||||
|
printf("Programming fuses using a structured buffer in memory "
|
||||||
|
"starting at addr 0x%lx\n", addr);
|
||||||
|
if (!confirmed && !confirm_prog())
|
||||||
|
return CMD_RET_FAILURE;
|
||||||
|
|
||||||
|
ret = fuse_writebuff(addr);
|
||||||
|
if (ret)
|
||||||
|
goto err;
|
||||||
} else {
|
} else {
|
||||||
return CMD_RET_USAGE;
|
return CMD_RET_USAGE;
|
||||||
}
|
}
|
||||||
|
@ -186,5 +202,9 @@ U_BOOT_CMD(
|
||||||
"fuse prog [-y] <bank> <word> <hexval> [<hexval>...] - program 1 or\n"
|
"fuse prog [-y] <bank> <word> <hexval> [<hexval>...] - program 1 or\n"
|
||||||
" several fuse words, starting at 'word' (PERMANENT)\n"
|
" several fuse words, starting at 'word' (PERMANENT)\n"
|
||||||
"fuse override <bank> <word> <hexval> [<hexval>...] - override 1 or\n"
|
"fuse override <bank> <word> <hexval> [<hexval>...] - override 1 or\n"
|
||||||
" several fuse words, starting at 'word'"
|
" several fuse words, starting at 'word'\n"
|
||||||
|
#ifdef CONFIG_CMD_FUSE_WRITEBUFF
|
||||||
|
"fuse writebuff [-y] <addr> - program fuse data\n"
|
||||||
|
" using a structured buffer in memory starting at 'addr'\n"
|
||||||
|
#endif /* CONFIG_CMD_FUSE_WRITEBUFF */
|
||||||
);
|
);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#define _FUSE_H_
|
#define _FUSE_H_
|
||||||
|
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
|
#include <linux/errno.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read/Sense/Program/Override interface:
|
* Read/Sense/Program/Override interface:
|
||||||
|
@ -25,5 +26,13 @@ int fuse_read(u32 bank, u32 word, u32 *val);
|
||||||
int fuse_sense(u32 bank, u32 word, u32 *val);
|
int fuse_sense(u32 bank, u32 word, u32 *val);
|
||||||
int fuse_prog(u32 bank, u32 word, u32 val);
|
int fuse_prog(u32 bank, u32 word, u32 val);
|
||||||
int fuse_override(u32 bank, u32 word, u32 val);
|
int fuse_override(u32 bank, u32 word, u32 val);
|
||||||
|
#ifdef CONFIG_CMD_FUSE_WRITEBUFF
|
||||||
|
int fuse_writebuff(ulong addr);
|
||||||
|
#else
|
||||||
|
static inline int fuse_writebuff(ulong addr)
|
||||||
|
{
|
||||||
|
return -EPERM;
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_CMD_FUSE_WRITEBUFF */
|
||||||
|
|
||||||
#endif /* _FUSE_H_ */
|
#endif /* _FUSE_H_ */
|
||||||
|
|
Loading…
Add table
Reference in a new issue