summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorNeil Armstrong <narmstrong@baylibre.com>2019-08-06 17:21:02 +0200
committerNeil Armstrong <narmstrong@baylibre.com>2019-08-12 10:02:30 +0200
commit559e6256f855e61f987598a18ed4f2e20bc530e7 (patch)
tree43ab67c5c90c9a82a6816ad028e7c10ea4e68bb2 /arch
parent191a374e65ef9c333263677538753188703dd94e (diff)
arm: meson: add sm cmd to retrieve SoC serial
The Secure Monitor offers multiple services, like returning the SoC unique serial number, already used to generate an unique MAC address. This adds a new, Amlogic specific, "sm" cmd with a "serial" subcommand to write the SoC unique serial to memory. This "cm" command will be extended in further patches. Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-meson/sm.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/arch/arm/mach-meson/sm.c b/arch/arm/mach-meson/sm.c
index 05b7f0bdf2..99fa17d9a8 100644
--- a/arch/arm/mach-meson/sm.c
+++ b/arch/arm/mach-meson/sm.c
@@ -77,3 +77,51 @@ int meson_sm_get_serial(void *buffer, size_t size)
return 0;
}
+
+static int do_sm_serial(cmd_tbl_t *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ ulong address;
+ int ret;
+
+ if (argc < 2)
+ return CMD_RET_USAGE;
+
+ address = simple_strtoul(argv[1], NULL, 0);
+
+ ret = meson_sm_get_serial((void *)address, SM_CHIP_ID_SIZE);
+ if (ret)
+ return CMD_RET_FAILURE;
+
+ return CMD_RET_SUCCESS;
+}
+
+static cmd_tbl_t cmd_sm_sub[] = {
+ U_BOOT_CMD_MKENT(serial, 2, 1, do_sm_serial, "", ""),
+};
+
+static int do_sm(cmd_tbl_t *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ cmd_tbl_t *c;
+
+ if (argc < 2)
+ return CMD_RET_USAGE;
+
+ /* Strip off leading 'sm' command argument */
+ argc--;
+ argv++;
+
+ c = find_cmd_tbl(argv[0], &cmd_sm_sub[0], ARRAY_SIZE(cmd_sm_sub));
+
+ if (c)
+ return c->cmd(cmdtp, flag, argc, argv);
+ else
+ return CMD_RET_USAGE;
+}
+
+U_BOOT_CMD(
+ sm, 5, 0, do_sm,
+ "Secure Monitor Control",
+ "serial <address> - read chip unique id to memory address"
+);