summaryrefslogtreecommitdiff
path: root/util/ectool.c
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2022-04-28 15:45:57 -0600
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-05-17 20:12:07 +0000
commit095b82e619a60122a3394beb62237cfb4a5607cb (patch)
tree24b7be08b40846337e4eaa6b3a9419fc596d9202 /util/ectool.c
parent201c108a37350ee83f214cd4c8cd046ab71b6eaa (diff)
downloadchrome-ec-095b82e619a60122a3394beb62237cfb4a5607cb.tar.gz
chargesplash: Add ectool command
Add a new "chargesplash" subcommand to ectool corresponding to the new host command, which enables printing and modifying the chargesplash state for debugging or testing purposes. BUG=b:228370390 BRANCH=none TEST=run all 4 "ectool chargesplash" commands on brya Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Change-Id: I5135c81f34d1f53b12670287e27e34161c9cff6b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3615485 Reviewed-by: Aaron Massey <aaronmassey@google.com> Reviewed-by: Raul Rangel <rrangel@chromium.org> Commit-Queue: Raul Rangel <rrangel@chromium.org>
Diffstat (limited to 'util/ectool.c')
-rw-r--r--util/ectool.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/util/ectool.c b/util/ectool.c
index c6ebb11f1c..640ff8e539 100644
--- a/util/ectool.c
+++ b/util/ectool.c
@@ -99,6 +99,8 @@ const char help_str[] =
" Force the battery to stop charging or discharge\n"
" chargeoverride\n"
" Overrides charge port selection logic\n"
+ " chargesplash\n"
+ " Show and manipulate chargesplash variables\n"
" chargestate\n"
" Handle commands related to charge state v2 (and later)\n"
" chipinfo\n"
@@ -7590,6 +7592,53 @@ int cmd_charge_control(int argc, char *argv[])
}
+static void print_bool(const char *name, bool value)
+{
+ printf("%s = %s\n", name, value ? "true" : "false");
+}
+
+static int cmd_chargesplash(int argc, char **argv)
+{
+ static struct {
+ const char *name;
+ enum ec_chargesplash_cmd cmd;
+ } actions[] = {
+ { "state", EC_CHARGESPLASH_GET_STATE },
+ { "request", EC_CHARGESPLASH_REQUEST },
+ { "lockout", EC_CHARGESPLASH_LOCKOUT },
+ { "reset", EC_CHARGESPLASH_RESET },
+ };
+ struct ec_params_chargesplash params;
+ struct ec_response_chargesplash resp;
+
+ if (argc != 2) {
+ goto usage;
+ }
+
+ for (int i = 0; i < ARRAY_SIZE(actions); i++) {
+ if (!strcasecmp(actions[i].name, argv[1])) {
+ params.cmd = actions[i].cmd;
+ if (ec_command(EC_CMD_CHARGESPLASH, 0, &params,
+ sizeof(params), &resp,
+ sizeof(resp)) < 0) {
+ fprintf(stderr, "Host command failed\n");
+ return -1;
+ }
+
+ print_bool("requested", resp.requested);
+ print_bool("display_initialized",
+ resp.display_initialized);
+ print_bool("locked_out", resp.locked_out);
+ return 0;
+ }
+ }
+
+usage:
+ fprintf(stderr, "Usage: %s <state|request|lockout|reset>", argv[0]);
+ return -1;
+}
+
+
#define ST_CMD_SIZE ST_FLD_SIZE(ec_params_charge_state, cmd)
#define ST_PRM_SIZE(SUBCMD) \
(ST_CMD_SIZE + ST_FLD_SIZE(ec_params_charge_state, SUBCMD))
@@ -10665,6 +10714,7 @@ const struct command commands[] = {
{"chargecurrentlimit", cmd_charge_current_limit},
{"chargecontrol", cmd_charge_control},
{"chargeoverride", cmd_charge_port_override},
+ {"chargesplash", cmd_chargesplash},
{"chargestate", cmd_charge_state},
{"chipinfo", cmd_chipinfo},
{"cmdversions", cmd_cmdversions},