From de4d25964de310effe8ede09e5ba6fa2f40dc52b Mon Sep 17 00:00:00 2001 From: Shawn Nematbakhsh Date: Thu, 11 Aug 2016 17:02:41 -0700 Subject: mkbp_event: Allow host to report sleep state for non-wake event skipping Allow the host to self-report its sleep state through EC_CMD_HOST_SLEEP_EVENT, which will typically be sent with SUSPEND param when the host begins its sleep process. While the host has self-reported that it is in SUSPEND, don't assert the interrupt line, except for designated wake events. BUG=chrome-os-partner:56156 BRANCH=None TEST=On kevin, run 'ectool hostsleepstate suspend', verify that interrupt assertion is skipped for battery host event. Run 'ectool hostsleepstate resume' and verify interrupt is again asserted by the battery host event. Signed-off-by: Shawn Nematbakhsh Change-Id: I74288465587ccf7185cec717f7c1810602361b8c Reviewed-on: https://chromium-review.googlesource.com/368391 Commit-Ready: Shawn N Tested-by: Shawn N Reviewed-by: Aseda Aboagye --- util/ectool.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'util') diff --git a/util/ectool.c b/util/ectool.c index 6d9c09737d..a32b67e3aa 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -119,6 +119,8 @@ const char help_str[] = " Checks for basic communication with EC\n" " hibdelay [sec]\n" " Set the delay before going into hibernation\n" + " hostsleepstate\n" + " Report host sleep state to the EC\n" " kbpress\n" " Simulate key press\n" " kbfactorytest\n" @@ -380,6 +382,32 @@ int cmd_hibdelay(int argc, char *argv[]) return 0; } +int cmd_hostsleepstate(int argc, char *argv[]) +{ + struct ec_params_host_sleep_event p; + + if (argc < 2) { + fprintf(stderr, "Usage: %s [suspend|resume|freeze|thaw]\n", + argv[0]); + return -1; + } + + if (!strcmp(argv[1], "suspend")) + p.sleep_event = HOST_SLEEP_EVENT_S3_SUSPEND; + else if (!strcmp(argv[1], "resume")) + p.sleep_event = HOST_SLEEP_EVENT_S3_RESUME; + else if (!strcmp(argv[1], "freeze")) + p.sleep_event = HOST_SLEEP_EVENT_S0IX_SUSPEND; + else if (!strcmp(argv[1], "thaw")) + p.sleep_event = HOST_SLEEP_EVENT_S0IX_RESUME; + else { + fprintf(stderr, "Unknown command: %s\n", argv[1]); + return -1; + } + + return ec_command(EC_CMD_HOST_SLEEP_EVENT, 0, &p, sizeof(p), NULL, 0); +} + int cmd_test(int argc, char *argv[]) { struct ec_params_test_protocol p = { @@ -6881,6 +6909,7 @@ const struct command commands[] = { {"hangdetect", cmd_hang_detect}, {"hello", cmd_hello}, {"hibdelay", cmd_hibdelay}, + {"hostsleepstate", cmd_hostsleepstate}, {"kbpress", cmd_kbpress}, {"i2cprotect", cmd_i2c_protect}, {"i2cread", cmd_i2c_read}, -- cgit v1.2.1