diff options
author | Yilun Lin <yllin@chromium.org> | 2019-08-20 13:54:00 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-08-23 05:48:34 +0000 |
commit | 1d0f58a303f8eb57d4c9fdec406f6f09918547cc (patch) | |
tree | bde71b2fa13b21fc73786208af2d839598d26788 /power/host_sleep.c | |
parent | 7e26c7c66898d1e4609184ae2fa207cddbf0c4fb (diff) | |
download | chrome-ec-1d0f58a303f8eb57d4c9fdec406f6f09918547cc.tar.gz |
power: Make HC host_sleep_event independent from power common.
host_sleep_event provides the AP power state information to EC,
and this is not necessary bound to CONFIG_POWER_COMMON. This CL
moves the HC out of CONFIG_POWER_COMMON.
TEST=1. make buildall -j
2. #define CONFIG_POWER_TRACK_HOST_SLEEP_STATE kukui_scp, and see
it build successfully.
BUG=b:136240895
BRANCH=none
Cq-Depend: chromium:1760656
Change-Id: I5555c7ba8b97547ce9fc0ff8e2bff14ef3da8fe7
Signed-off-by: Yilun Lin <yllin@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1753563
Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'power/host_sleep.c')
-rw-r--r-- | power/host_sleep.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/power/host_sleep.c b/power/host_sleep.c new file mode 100644 index 0000000000..7d342441eb --- /dev/null +++ b/power/host_sleep.c @@ -0,0 +1,78 @@ +/* Copyright 2019 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "ec_commands.h" +#include "host_command.h" +#include "power.h" + +/* Track last reported sleep event */ +static enum host_sleep_event host_sleep_state; + +__overridable void power_chipset_handle_host_sleep_event( + enum host_sleep_event state, + struct host_sleep_event_context *ctx) +{ + /* Default weak implementation -- no action required. */ +} + +static int host_command_host_sleep_event(struct host_cmd_handler_args *args) +{ + const struct ec_params_host_sleep_event_v1 *p = args->params; + struct ec_response_host_sleep_event_v1 *r = args->response; + struct host_sleep_event_context ctx; + enum host_sleep_event state = p->sleep_event; + + host_sleep_state = state; + ctx.sleep_transitions = 0; + switch (state) { + case HOST_SLEEP_EVENT_S0IX_SUSPEND: + case HOST_SLEEP_EVENT_S3_SUSPEND: + case HOST_SLEEP_EVENT_S3_WAKEABLE_SUSPEND: + ctx.sleep_timeout_ms = EC_HOST_SLEEP_TIMEOUT_DEFAULT; + + /* The original version contained only state. */ + if (args->version >= 1) + ctx.sleep_timeout_ms = + p->suspend_params.sleep_timeout_ms; + + break; + + default: + break; + } + + power_chipset_handle_host_sleep_event(host_sleep_state, &ctx); + switch (state) { + case HOST_SLEEP_EVENT_S0IX_RESUME: + case HOST_SLEEP_EVENT_S3_RESUME: + if (args->version >= 1) { + r->resume_response.sleep_transitions = + ctx.sleep_transitions; + + args->response_size = sizeof(*r); + } + + break; + + default: + break; + } + + return EC_RES_SUCCESS; +} +DECLARE_HOST_COMMAND(EC_CMD_HOST_SLEEP_EVENT, + host_command_host_sleep_event, + EC_VER_MASK(0) | EC_VER_MASK(1)); + +enum host_sleep_event power_get_host_sleep_state(void) +{ + return host_sleep_state; +} + +void power_set_host_sleep_state(enum host_sleep_event state) +{ + host_sleep_state = state; +} + |