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 <aaboagye@google.com>
Reviewed-on: https://chromium-review.googlesource.com/302198
Commit-Ready: Aseda Aboagye <aaboagye@chromium.org>
Tested-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
This commit is contained in:
Aseda Aboagye
2015-09-24 15:32:47 -07:00
committed by chrome-bot
parent 747056ec93
commit 9d9f020aaf

View File

@@ -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},