From 9d9f020aaf19267e767c48dcf96db1319e3669ce Mon Sep 17 00:00:00 2001 From: Aseda Aboagye Date: Thu, 24 Sep 2015 15:32:47 -0700 Subject: ectool: Add "hibdelay" command. This commit adds the "hibdelay" command which will set the time before the EC hibernates. BUG=chrome-os-partner:45608 BUG=chrome-os-partner:44831 BRANCH=None TEST=Build and flash samus EC with hibernation delay host command added. Use ectool to set the hibernation delay and verify that the hibernation delay was changed. CQ-DEPEND=302197 Change-Id: I91141ee48a648c1052f0a3930a810ea4f551e0a4 Signed-off-by: Aseda Aboagye Reviewed-on: https://chromium-review.googlesource.com/302198 Commit-Ready: Aseda Aboagye Tested-by: Aseda Aboagye Reviewed-by: Randall Spangler --- util/ectool.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/util/ectool.c b/util/ectool.c index 0617559220..722ba32cb5 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -117,6 +117,8 @@ const char help_str[] = " Configure or start/stop the hang detect timer\n" " hello\n" " Checks for basic communication with EC\n" + " hibdelay [sec]\n" + " Set the delay before going into hibernation\n" " kbpress\n" " Simulate key press\n" " i2cread\n" @@ -330,6 +332,36 @@ int cmd_hello(int argc, char *argv[]) return 0; } +int cmd_hibdelay(int argc, char *argv[]) +{ + struct ec_params_hibernation_delay p; + struct ec_response_hibernation_delay r; + char *e; + int rv; + + if (argc < 2) { + p.seconds = 0; /* Just read the current settings. */ + } else { + p.seconds = strtoul(argv[1], &e, 0); + if (e && *e) { + fprintf(stderr, "invalid number\n"); + return -1; + } + } + + rv = ec_command(EC_CMD_HIBERNATION_DELAY, 0, &p, sizeof(p), + &r, sizeof(r)); + if (rv < 0) { + fprintf(stderr, "err: rv=%d\n", rv); + return -1; + } + + printf("Hibernation delay: %u s\n", r.hibernate_delay); + printf("Time G3: %u s\n", r.time_g3); + printf("Time left: %u s\n", r.time_remaining); + return 0; +} + int cmd_test(int argc, char *argv[]) { struct ec_params_test_protocol p = { @@ -6463,6 +6495,7 @@ const struct command commands[] = { {"gpioset", cmd_gpio_set}, {"hangdetect", cmd_hang_detect}, {"hello", cmd_hello}, + {"hibdelay", cmd_hibdelay}, {"kbpress", cmd_kbpress}, {"i2cread", cmd_i2c_read}, {"i2cwrite", cmd_i2c_write}, -- cgit v1.2.1