|
5 | 5 | * Author: Beniamino Galvani <[email protected]>
|
6 | 6 | * Author: Vyacheslav Bocharov <[email protected]>
|
7 | 7 | * Author: Neil Armstrong <[email protected]>
|
| 8 | + * Author: Alexey Romanov <[email protected]> |
8 | 9 | */
|
9 | 10 |
|
10 | 11 | #include <command.h>
|
11 | 12 | #include <common.h>
|
12 | 13 | #include <env.h>
|
13 | 14 | #include <asm/arch/sm.h>
|
14 | 15 | #include <stdlib.h>
|
| 16 | +#include <display_options.h> |
15 | 17 |
|
16 | 18 | static int do_sm_serial(struct cmd_tbl *cmdtp, int flag, int argc,
|
17 | 19 | char *const argv[])
|
@@ -119,11 +121,43 @@ static int do_efuse_write(struct cmd_tbl *cmdtp, int flag, int argc,
|
119 | 121 | return CMD_RET_SUCCESS;
|
120 | 122 | }
|
121 | 123 |
|
| 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 | + |
122 | 155 | static struct cmd_tbl cmd_sm_sub[] = {
|
123 | 156 | U_BOOT_CMD_MKENT(serial, 2, 1, do_sm_serial, "", ""),
|
124 | 157 | U_BOOT_CMD_MKENT(reboot_reason, 1, 1, do_sm_reboot_reason, "", ""),
|
125 | 158 | U_BOOT_CMD_MKENT(efuseread, 4, 1, do_efuse_read, "", ""),
|
126 | 159 | U_BOOT_CMD_MKENT(efusewrite, 4, 0, do_efuse_write, "", ""),
|
| 160 | + U_BOOT_CMD_MKENT(efusedump, 3, 1, do_efuse_dump, "", ""), |
127 | 161 | };
|
128 | 162 |
|
129 | 163 | static int do_sm(struct cmd_tbl *cmdtp, int flag, int argc,
|
@@ -152,5 +186,6 @@ U_BOOT_CMD(
|
152 | 186 | "serial <address> - read chip unique id to memory address\n"
|
153 | 187 | "sm reboot_reason [name] - get reboot reason and store to environment\n"
|
154 | 188 | "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" |
156 | 191 | );
|
0 commit comments