summaryrefslogtreecommitdiff
path: root/cmd/cedit.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-08-14 16:40:37 -0600
committerTom Rini <trini@konsulko.com>2023-08-25 13:54:33 -0400
commiteb6c71b56282d3054dbffb83793e7d2c6745578e (patch)
tree0ad2e2b829a5afca3442eb2f58b09a6fb635b582 /cmd/cedit.c
parentbcf2b7202e960e7fb3df8d5e8ed0d6fa00a5a9fa (diff)
expo: cedit: Support writing settings to CMOS RAM
Add a command to write cedit settings to CMOS RAM so that it can be preserved across a reboot. This uses a simple bit-encoding, where each field has a 'bit position' and a 'bit length' in the schema. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'cmd/cedit.c')
-rw-r--r--cmd/cedit.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/cmd/cedit.c b/cmd/cedit.c
index b2548f44b57..95d5c22c2f7 100644
--- a/cmd/cedit.c
+++ b/cmd/cedit.c
@@ -10,6 +10,7 @@
#include <abuf.h>
#include <cedit.h>
#include <command.h>
+#include <dm.h>
#include <expo.h>
#include <fs.h>
#include <malloc.h>
@@ -176,6 +177,39 @@ static int do_cedit_read_env(struct cmd_tbl *cmdtp, int flag, int argc,
return 0;
}
+static int do_cedit_write_cmos(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct udevice *dev;
+ bool verbose = false;
+ int ret;
+
+ if (check_cur_expo())
+ return CMD_RET_FAILURE;
+
+ if (argc > 1 && !strcmp(argv[1], "-v")) {
+ verbose = true;
+ argc--;
+ argv++;
+ }
+
+ if (argc > 1)
+ ret = uclass_get_device_by_name(UCLASS_RTC, argv[1], &dev);
+ else
+ ret = uclass_first_device_err(UCLASS_RTC, &dev);
+ if (ret) {
+ printf("Failed to get RTC device: %dE\n", ret);
+ return CMD_RET_FAILURE;
+ }
+
+ if (cedit_write_settings_cmos(cur_exp, dev, verbose)) {
+ printf("Failed to write settings to CMOS\n");
+ return CMD_RET_FAILURE;
+ }
+
+ return 0;
+}
+
static int do_cedit_run(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
@@ -209,6 +243,7 @@ static char cedit_help_text[] =
"cedit write_fdt <i/f> <dev[:part]> <filename> - write settings\n"
"cedit read_env [-v] - read settings from env vars\n"
"cedit write_env [-v] - write settings to env vars\n"
+ "cedit write_cmos [-v] [dev] - write settings to CMOS RAM\n"
"cedit run - run config editor";
#endif /* CONFIG_SYS_LONGHELP */
@@ -218,5 +253,6 @@ U_BOOT_CMD_WITH_SUBCMDS(cedit, "Configuration editor", cedit_help_text,
U_BOOT_SUBCMD_MKENT(write_fdt, 5, 1, do_cedit_write_fdt),
U_BOOT_SUBCMD_MKENT(read_env, 2, 1, do_cedit_read_env),
U_BOOT_SUBCMD_MKENT(write_env, 2, 1, do_cedit_write_env),
+ U_BOOT_SUBCMD_MKENT(write_cmos, 2, 1, do_cedit_write_cmos),
U_BOOT_SUBCMD_MKENT(run, 1, 1, do_cedit_run),
);