summaryrefslogtreecommitdiff
path: root/power
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2018-04-18 23:48:18 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-04-19 19:28:44 -0700
commit91148de7c836a382e3433e6a7a1d8adc48148799 (patch)
treefbf7138b447f3cb2990da0a8d4c644d40faad5fc /power
parent277d59a36c0ecc80db9a5e4097c05c33c0bc30b7 (diff)
downloadchrome-ec-91148de7c836a382e3433e6a7a1d8adc48148799.tar.gz
APL/GLK: Move chipset shutdown to chipset task
In order to ensure that all chipset init/shutdown operations happen within the context of chipset task for APL/GLK: 1. Update chipset_force_shutdown to only set a flag force_shutdown to indicate that chipset shutdown is requested and wake the chipset task. 2. Make chipset task (within the power state machine) call internal_chipset_shutdown. 3. Make internal_chipset_shutdown reset force_shutdown flag and make a callback to weak function chipset_do_shutdown to trigger chipset shutdown. BUG=b:78259506 BRANCH=None TEST=Verified that "apshutdown" on EC console results in chipset shutdown action being taken within chipset task. Change-Id: If13b65ae47e3dce2e466320cc14c68239563f6ed Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/1018737 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'power')
-rw-r--r--power/apollolake.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/power/apollolake.c b/power/apollolake.c
index 69d253c8fd..c1fcbe8e17 100644
--- a/power/apollolake.c
+++ b/power/apollolake.c
@@ -9,23 +9,42 @@
#include "console.h"
#include "gpio.h"
#include "intel_x86.h"
+#include "task.h"
#include "timer.h"
/* Console output macros */
#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
+/*
+ * force_shutdown is used to maintain chipset shutdown request. This request
+ * needs to be handled from within the chipset task.
+ */
+static int force_shutdown;
+
__attribute__((weak)) void chipset_do_shutdown(void)
{
/* Need to implement board specific shutdown */
}
-void chipset_force_shutdown(void)
+static void internal_chipset_shutdown(void)
{
CPRINTS("%s()", __func__);
+ force_shutdown = 0;
chipset_do_shutdown();
}
+void chipset_force_shutdown(void)
+{
+ /*
+ * This function is called from multiple tasks and hence it is racy! But
+ * since things are going down hard, it does not matter if some task
+ * misses out.
+ */
+ force_shutdown = 1;
+ task_wake(TASK_ID_CHIPSET);
+}
+
enum power_state chipset_force_g3(void)
{
chipset_force_shutdown();
@@ -64,13 +83,17 @@ enum power_state power_handle_state(enum power_state state)
if (state == POWER_S5 && !power_has_signals(IN_PGOOD_ALL_CORE)) {
/* Required rail went away */
- chipset_force_shutdown();
+ internal_chipset_shutdown();
new_state = POWER_S5G3;
goto rsmrst_handle;
}
+ /* If force shutdown is requested, perform that. */
+ if (force_shutdown)
+ internal_chipset_shutdown();
+
new_state = common_intel_x86_power_handle_state(state);
rsmrst_handle: