Skip to content

Commit ac7fdbc

Browse files
mRrvzsuperna9999
authored andcommitted
cmd/arm: meson: sm: introduce efusedump command
Using this command user can print efuse memory: $ sm efusedump 0 10 00000000: ff 00 31 00 00 ff 66 00 00 00 ..1...f... Signed-off-by: Alexey Romanov <[email protected]> Reviewed-by: Mattijs Korpershoek <[email protected]> Reviewed-by: Neil Armstrong <[email protected]> Link: https://lore.kernel.org/r/[email protected] [narmstrong: added display_options.h include for print_buffer()] Signed-off-by: Neil Armstrong <[email protected]>
1 parent 23435cf commit ac7fdbc

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

cmd/meson/sm.c

+36-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
* Author: Beniamino Galvani <[email protected]>
66
* Author: Vyacheslav Bocharov <[email protected]>
77
* Author: Neil Armstrong <[email protected]>
8+
* Author: Alexey Romanov <[email protected]>
89
*/
910

1011
#include <command.h>
1112
#include <common.h>
1213
#include <env.h>
1314
#include <asm/arch/sm.h>
1415
#include <stdlib.h>
16+
#include <display_options.h>
1517

1618
static int do_sm_serial(struct cmd_tbl *cmdtp, int flag, int argc,
1719
char *const argv[])
@@ -119,11 +121,43 @@ static int do_efuse_write(struct cmd_tbl *cmdtp, int flag, int argc,
119121
return CMD_RET_SUCCESS;
120122
}
121123

124+
static int do_efuse_dump(struct cmd_tbl *cmdtp, int flag, int argc,
125+
char *const argv[])
126+
{
127+
ulong offset, size;
128+
u8 *buffer;
129+
int ret;
130+
131+
if (argc != 3)
132+
return CMD_RET_USAGE;
133+
134+
offset = simple_strtoul(argv[1], NULL, 0);
135+
size = simple_strtoul(argv[2], NULL, 0);
136+
buffer = malloc(size);
137+
if (!buffer) {
138+
pr_err("Failed to allocate %lu bytes\n", size);
139+
return CMD_RET_FAILURE;
140+
}
141+
142+
ret = meson_sm_read_efuse(offset, (void *)buffer, size);
143+
if (ret != size) {
144+
ret = CMD_RET_FAILURE;
145+
goto free_buffer;
146+
}
147+
148+
print_buffer(0, buffer, 1, size, 0);
149+
150+
free_buffer:
151+
free(buffer);
152+
return ret;
153+
}
154+
122155
static struct cmd_tbl cmd_sm_sub[] = {
123156
U_BOOT_CMD_MKENT(serial, 2, 1, do_sm_serial, "", ""),
124157
U_BOOT_CMD_MKENT(reboot_reason, 1, 1, do_sm_reboot_reason, "", ""),
125158
U_BOOT_CMD_MKENT(efuseread, 4, 1, do_efuse_read, "", ""),
126159
U_BOOT_CMD_MKENT(efusewrite, 4, 0, do_efuse_write, "", ""),
160+
U_BOOT_CMD_MKENT(efusedump, 3, 1, do_efuse_dump, "", ""),
127161
};
128162

129163
static int do_sm(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -152,5 +186,6 @@ U_BOOT_CMD(
152186
"serial <address> - read chip unique id to memory address\n"
153187
"sm reboot_reason [name] - get reboot reason and store to environment\n"
154188
"sm efuseread <offset> <size> <address> - read efuse to memory address\n"
155-
"sm efusewrite <offset> <size> <address> - write into efuse from memory address"
189+
"sm efusewrite <offset> <size> <address> - write into efuse from memory address\n"
190+
"sm efusedump <offset> <size> - dump efuse data range to console"
156191
);

0 commit comments

Comments
 (0)