From 823d3a2d5121ab8798e03e097b374f78f3051144 Mon Sep 17 00:00:00 2001 From: Aseda Aboagye Date: Thu, 24 Sep 2015 14:55:48 -0700 Subject: ec_commands: Add "hibdelay" as an EC host command. Currently, the only way to prevent a system from hibernating is via the EC console command "hibdelay". This commit adds the host command equivalent so that it can be set elsewhere. The host command takes the amount of time in seconds to delay hibernation by and responds with the current time in the G3 power state, the time remaining before hibernation should be invoked, and the current setting of the hibernation delay. BUG=chrome-os-partner:45608 BUG=chrome-os-partner:44831 BRANCH=None TEST=Build and flash on samus. Issue the host command from EC console. Verify that the hibernation delay was updated by checking with the hibdelay command. Change-Id: I34725516507995c3c0337d5d64736d21a472866c Signed-off-by: Aseda Aboagye Reviewed-on: https://chromium-review.googlesource.com/302197 Commit-Ready: Aseda Aboagye Tested-by: Aseda Aboagye Reviewed-by: Randall Spangler --- power/common.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'power') diff --git a/power/common.c b/power/common.c index fa0ccc2816..204ef2221e 100644 --- a/power/common.c +++ b/power/common.c @@ -562,6 +562,36 @@ DECLARE_CONSOLE_COMMAND(hibdelay, command_hibernation_delay, "[sec]", "Set the delay before going into hibernation", NULL); + +static int host_command_hibernation_delay(struct host_cmd_handler_args *args) +{ + const struct ec_params_hibernation_delay *p = args->params; + struct ec_response_hibernation_delay *r = args->response; + + uint32_t time_g3 = (uint32_t)((get_time().val - last_shutdown_time) + / SECOND); + + /* Only change the hibernation delay if seconds is non-zero. */ + if (p->seconds) + hibernate_delay = p->seconds; + + if (state == POWER_G3 && !extpower_is_present()) + r->time_g3 = time_g3; + else + r->time_g3 = 0; + + if ((time_g3 != 0) && (time_g3 > hibernate_delay)) + r->time_remaining = 0; + else + r->time_remaining = hibernate_delay - time_g3; + r->hibernate_delay = hibernate_delay; + + args->response_size = sizeof(struct ec_response_hibernation_delay); + return EC_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_HIBERNATION_DELAY, + host_command_hibernation_delay, + EC_VER_MASK(0)); #endif /* CONFIG_HIBERNATE */ #ifdef CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5 -- cgit v1.2.1