diff options
Diffstat (limited to 'util/ectool.cc')
-rw-r--r-- | util/ectool.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/util/ectool.cc b/util/ectool.cc index 45c87bec2e..b0b6e56ab4 100644 --- a/util/ectool.cc +++ b/util/ectool.cc @@ -11385,6 +11385,46 @@ int cmd_cec(int argc, char *argv[]) return -1; } +static void cmd_s0ix_counter_help(char *cmd) +{ + fprintf(stderr, + " Usage: %s get - to get the value of s0ix counter\n" + " %s reset - to reset s0ix counter \n", + cmd, cmd); +} + +static int cmd_s0ix_counter(int argc, char *argv[]) +{ + struct ec_params_s0ix_cnt p; + struct ec_response_s0ix_cnt r; + int rv; + + if (argc != 2) { + fprintf(stderr, "Invalid number of params\n"); + cmd_s0ix_counter_help(argv[0]); + return -1; + } + + if (!strcasecmp(argv[1], "get")) { + p.flags = 0; + } else if (!strcasecmp(argv[1], "reset")) { + p.flags = EC_S0IX_COUNTER_RESET; + } else { + fprintf(stderr, "Bad subcommand: %s\n", argv[1]); + return -1; + } + + rv = ec_command(EC_CMD_GET_S0IX_COUNTER, 0, &p, sizeof(p), &r, + sizeof(r)); + if (rv < 0) { + return rv; + } + + printf("s0ix_counter: %u\n", r.s0ix_counter); + + return 0; +} + /* NULL-terminated list of commands */ const struct command commands[] = { { "adcread", cmd_adc_read }, @@ -11502,6 +11542,7 @@ const struct command commands[] = { { "rwsigaction", cmd_rwsig_action_legacy }, { "rwsigstatus", cmd_rwsig_status }, { "sertest", cmd_serial_test }, + { "s0ix_counter", cmd_s0ix_counter }, { "smartdischarge", cmd_smart_discharge }, { "stress", cmd_stress_test }, { "sysinfo", cmd_sysinfo }, |