summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWealian Liao <whliao@nuvoton.corp-partner.google.com>2020-11-19 23:05:49 -0800
committerCommit Bot <commit-bot@chromium.org>2020-12-01 04:11:17 +0000
commit80964208e12d90d42dc9cecea7138776a73c6bb7 (patch)
tree60575cf4efe8ec96f930c43ff5d6f8556864e1ce
parent6e61e71e8770f3f92848d02f9075a974b4146ffd (diff)
downloadchrome-ec-80964208e12d90d42dc9cecea7138776a73c6bb7.tar.gz
zephyr: shim system_jumped_late & system_enter_hibernate
shim the system_jumped_late() and system_enter_hibernate() that needed by keyboard scan. BRANCH=none BUG=b:167405015 TEST=compile with keyboard scan Signed-off-by: Wealian Liao <whliao@nuvoton.corp-partner.google.com> Change-Id: I4f79dd3b0313f4ed19550b1896ed0e439407caf6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2552321 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Jack Rosenthal <jrosenth@chromium.org> Commit-Queue: Jack Rosenthal <jrosenth@chromium.org>
-rw-r--r--zephyr/shim/src/system.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/zephyr/shim/src/system.c b/zephyr/shim/src/system.c
index 0baa9a5574..2dcd0c8ef8 100644
--- a/zephyr/shim/src/system.c
+++ b/zephyr/shim/src/system.c
@@ -7,6 +7,7 @@
#include <string.h>
#include <sys/util.h>
+#include "chipset.h"
#include "config.h"
#include "ec_commands.h"
#include "sysjump.h"
@@ -33,6 +34,11 @@ struct jump_tag {
/** Jump data (at end of RAM, or preceding panic data). */
static struct jump_data *jdata;
+static enum ec_reboot_cmd reboot_at_shutdown;
+
+STATIC_IF(CONFIG_HIBERNATE) uint32_t hibernate_seconds;
+STATIC_IF(CONFIG_HIBERNATE) uint32_t hibernate_microseconds;
+
/**
* The flags set by the reset cause. These will be a combination of
* EC_RESET_FLAG_*s and will be used to control the logic of initializing the
@@ -234,3 +240,29 @@ __test_only void system_override_jdata(void *test_jdata)
{
jdata = (struct jump_data *)test_jdata;
}
+
+void system_enter_hibernate(uint32_t seconds, uint32_t microseconds)
+{
+ if (!IS_ENABLED(CONFIG_HIBERNATE))
+ return;
+
+ /*
+ * If chipset is already off, then call system_hibernate directly. Else,
+ * let chipset_task bring down the power rails and transition to proper
+ * state before system_hibernate is called.
+ */
+ if (chipset_in_state(CHIPSET_STATE_ANY_OFF)) {
+ system_hibernate(seconds, microseconds);
+ } else {
+ reboot_at_shutdown = EC_REBOOT_HIBERNATE;
+ hibernate_seconds = seconds;
+ hibernate_microseconds = microseconds;
+
+ chipset_force_shutdown(CHIPSET_SHUTDOWN_CONSOLE_CMD);
+ }
+}
+
+int system_jumped_late(void)
+{
+ return !(reset_flags & EC_RESET_FLAG_EFS) && jumped_to_image;
+}