summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYilun Lin <yllin@chromium.org>2019-08-20 13:54:00 +0800
committerCommit Bot <commit-bot@chromium.org>2019-08-23 05:48:34 +0000
commit1d0f58a303f8eb57d4c9fdec406f6f09918547cc (patch)
treebde71b2fa13b21fc73786208af2d839598d26788
parent7e26c7c66898d1e4609184ae2fa207cddbf0c4fb (diff)
downloadchrome-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>
-rw-r--r--include/config.h1
-rw-r--r--power/build.mk1
-rw-r--r--power/common.c71
-rw-r--r--power/host_sleep.c78
4 files changed, 79 insertions, 72 deletions
diff --git a/include/config.h b/include/config.h
index dd2570f630..66b23526b4 100644
--- a/include/config.h
+++ b/include/config.h
@@ -4628,7 +4628,6 @@
#undef CONFIG_CHIPSET_SKYLAKE
#undef CONFIG_CHIPSET_STONEY
#undef CONFIG_POWER_COMMON
-#undef CONFIG_POWER_TRACK_HOST_SLEEP_STATE
#endif
/*
diff --git a/power/build.mk b/power/build.mk
index 0134b01744..3b001e3596 100644
--- a/power/build.mk
+++ b/power/build.mk
@@ -20,3 +20,4 @@ power-$(CONFIG_CHIPSET_SDM845)+=sdm845.o
power-$(CONFIG_CHIPSET_SKYLAKE)+=skylake.o intel_x86.o
power-$(CONFIG_CHIPSET_STONEY)+=stoney.o
power-$(CONFIG_POWER_COMMON)+=common.o
+power-$(CONFIG_POWER_TRACK_HOST_SLEEP_STATE)+=host_sleep.o
diff --git a/power/common.c b/power/common.c
index f0fc3117d3..5128f46ac8 100644
--- a/power/common.c
+++ b/power/common.c
@@ -877,77 +877,6 @@ DECLARE_CONSOLE_COMMAND(pause_in_s5, command_pause_in_s5,
"Should the AP pause in S5 during shutdown?");
#endif /* CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5 */
-#ifdef CONFIG_POWER_TRACK_HOST_SLEEP_STATE
-/* 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_S3_SUSPEND:
- case HOST_SLEEP_EVENT_S0IX_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_S3_RESUME:
- case HOST_SLEEP_EVENT_S0IX_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;
-}
-
-#endif /* CONFIG_POWER_TRACK_HOST_SLEEP_STATE */
-
#ifdef CONFIG_POWER_PP5000_CONTROL
/* 5V enable request bitmask from various tasks. */
static uint32_t pwr_5v_en_req;
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;
+}
+