diff options
author | Ting Shen <phoenixshen@google.com> | 2021-05-20 18:16:41 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-05-27 09:17:00 +0000 |
commit | 00d63619edf7b6c1f62d7cfce7a2bd520635dbd3 (patch) | |
tree | dd379764d34d67abb3cac4c40499321c33651842 /util | |
parent | e9aae45d73c326331b07a0db171e64d73402907f (diff) | |
download | chrome-ec-00d63619edf7b6c1f62d7cfce7a2bd520635dbd3.tar.gz |
base_state: implement basestate host command
This CL introduces an unified method to force base attach/detach, to
deprecate the hard-coded gpio pin name table in
hammerd/hammertests/common.py.
Also modifies base_force_state to use the same parameter type as host
command.
BUG=b:188625010
TEST=manually,
run `ectool basestate attach|detach|reset` on coachz
BRANCH=trogdor,kukui
Signed-off-by: Ting Shen <phoenixshen@google.com>
Change-Id: I5235661727cbbd15015c49d588ec70605e4a33e8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2910472
Reviewed-by: Wai-Hong Tam <waihong@google.com>
Tested-by: Ting Shen <phoenixshen@chromium.org>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/ectool.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/util/ectool.c b/util/ectool.c index 25161265c3..65bb7c0a94 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -73,6 +73,8 @@ const char help_str[] = " Turn on automatic fan speed control.\n" " backlight <enabled>\n" " Enable/disable LCD backlight\n" + " basestate [attach | detach | reset]\n" + " Manually force base state to attached, detached or reset.\n" " battery\n" " Prints battery info\n" " batterycutoff [at-shutdown]\n" @@ -7437,6 +7439,35 @@ int cmd_lcd_backlight(int argc, char *argv[]) return 0; } +static void cmd_basestate_help(void) +{ + fprintf(stderr, + "Usage: ectool basestate [attach | detach | reset]\n"); +} + +int cmd_basestate(int argc, char *argv[]) +{ + struct ec_params_set_base_state p; + + if (argc != 2) { + cmd_basestate_help(); + return -1; + } + + if (!strncmp(argv[1], "attach", 6)) { + p.cmd = EC_SET_BASE_STATE_ATTACH; + } else if (!strncmp(argv[1], "detach", 6)) { + p.cmd = EC_SET_BASE_STATE_DETACH; + } else if (!strncmp(argv[1], "reset", 5)) { + p.cmd = EC_SET_BASE_STATE_RESET; + } else { + cmd_basestate_help(); + return -1; + } + + return ec_command(EC_CMD_SET_BASE_STATE, 0, + &p, sizeof(p), NULL, 0); +} int cmd_ext_power_limit(int argc, char *argv[]) { @@ -10497,6 +10528,7 @@ const struct command commands[] = { {"apreset", cmd_apreset}, {"autofanctrl", cmd_thermal_auto_fan_ctrl}, {"backlight", cmd_lcd_backlight}, + {"basestate", cmd_basestate}, {"battery", cmd_battery}, {"batterycutoff", cmd_battery_cut_off}, {"batteryparam", cmd_battery_vendor_param}, |