summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2017-05-24 08:49:24 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-06-28 21:50:51 -0700
commit3a4298ef4835b1f75046ede8cace149e05089d1a (patch)
tree24d4174c733236a43e0a7a3ee72b4bd09207ae74
parent9eca99983175784a0cc5e17a65e67498b9cfc8b1 (diff)
downloadchrome-ec-3a4298ef4835b1f75046ede8cace149e05089d1a.tar.gz
npcx: Make system stay off after clean shutdown
This patch sets/clears RESET_FLAG_AP_OFF on S5<->S3 transitions. It's set when the system gracefully shuts down and cleared when the system boots up. The result is EC tries to go back to the previous state upon AC plug-in on battery-less systems. This is required for digital signage and kiosk. This also reverts: CL 514209, 486946, and 486945. BUG=b:37536389 BRANCH=none TEST=Tested as follows: A. Boot to S0 A.1. Unplug AC while system is in S0 then plug in - PASS A.2. Unplug AC while system is in S3 then plug in - PASS A.3. Press recovery+power in S0 - PASS A.4. Press recovery+power in G3 - FAIL (To be fixed) A.5. Execute reboot console command - PASS A.6. Execute reboot OS command - PASS A.7. Execute reboot console command in G3 - PASS B. Boot to G3 B.1 Unplug AC while system is in G3 then plug in - PASS B.2 Unplug AC after B.1 then plug in - PASS B.3 Shutdown by power button on recovery screen then unplug plug in AC - PASS B.4 Execute reboot ap-off console command - PASS B.5 Execute shutdown command from OS then plug in AC - PASS Change-Id: Iaa6f930585050fdd3511c711b449dff47525066d Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/517287 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r--chip/npcx/system.c34
-rw-r--r--common/power_button_x86.c8
-rw-r--r--include/config.h2
3 files changed, 38 insertions, 6 deletions
diff --git a/chip/npcx/system.c b/chip/npcx/system.c
index f0f698684a..15d575658d 100644
--- a/chip/npcx/system.c
+++ b/chip/npcx/system.c
@@ -310,6 +310,35 @@ void chip_save_reset_flags(int flags)
bbram_data_write(BBRM_DATA_INDEX_SAVED_RESET_FLAGS, flags);
}
+#ifdef CONFIG_POWER_BUTTON_INIT_IDLE
+/*
+ * Set/clear AP_OFF flag. It's set when the system gracefully shuts down and
+ * it's cleared when the system boots up. The result is the system tries to
+ * go back to the previous state upon AC plug-in. If the system uncleanly
+ * shuts down, it boots immediately. If the system shuts down gracefully,
+ * it'll stay at S5 and wait for power button press.
+ */
+static void board_chipset_startup(void)
+{
+ uint32_t flags = bbram_data_read(BBRM_DATA_INDEX_SAVED_RESET_FLAGS);
+ flags &= ~RESET_FLAG_AP_OFF;
+ chip_save_reset_flags(flags);
+ system_clear_reset_flags(RESET_FLAG_AP_OFF);
+ CPRINTS("Cleared AP_OFF flag");
+}
+DECLARE_HOOK(HOOK_CHIPSET_STARTUP, board_chipset_startup, HOOK_PRIO_DEFAULT);
+
+static void board_chipset_shutdown(void)
+{
+ uint32_t flags = bbram_data_read(BBRM_DATA_INDEX_SAVED_RESET_FLAGS);
+ flags |= RESET_FLAG_AP_OFF;
+ chip_save_reset_flags(flags);
+ system_set_reset_flags(RESET_FLAG_AP_OFF);
+ CPRINTS("Set AP_OFF flag");
+}
+DECLARE_HOOK(HOOK_CHIPSET_SHUTDOWN, board_chipset_shutdown, HOOK_PRIO_DEFAULT);
+#endif
+
/* Check reset cause */
void system_check_reset_cause(void)
{
@@ -317,7 +346,12 @@ void system_check_reset_cause(void)
uint32_t flags = bbram_data_read(BBRM_DATA_INDEX_SAVED_RESET_FLAGS);
/* Clear saved reset flags in bbram */
+#ifdef CONFIG_POWER_BUTTON_INIT_IDLE
+ /* We'll clear AP_OFF on S5->S3 transition */
+ chip_save_reset_flags(flags & RESET_FLAG_AP_OFF);
+#else
chip_save_reset_flags(0);
+#endif
/* Clear saved hibernate wake flag in bbram , too */
bbram_data_write(BBRM_DATA_INDEX_WAKE, 0);
diff --git a/common/power_button_x86.c b/common/power_button_x86.c
index e6bdde38bc..8cfb8e685b 100644
--- a/common/power_button_x86.c
+++ b/common/power_button_x86.c
@@ -231,12 +231,10 @@ static void set_initial_pwrbtn_state(void)
return;
}
+#ifdef CONFIG_BRINGUP
+ pwrbtn_state = PWRBTN_STATE_IDLE;
+#else
pwrbtn_state = PWRBTN_STATE_INIT_ON;
-
-#if defined(CONFIG_BRINGUP) || defined(CONFIG_POWER_BUTTON_INIT_IDLE)
- if (!power_button_is_pressed() &&
- !host_is_event_set(EC_HOST_EVENT_KEYBOARD_RECOVERY))
- pwrbtn_state = PWRBTN_STATE_IDLE;
#endif
CPRINTS("PB %s",
pwrbtn_state == PWRBTN_STATE_INIT_ON ? "init-on" : "idle");
diff --git a/include/config.h b/include/config.h
index 8c6ca34276..67fe9e5764 100644
--- a/include/config.h
+++ b/include/config.h
@@ -1835,7 +1835,7 @@
/* Support sending the power button signal to x86 chipsets */
#undef CONFIG_POWER_BUTTON_X86
-/* Set power button state idle at init */
+/* Set power button state idle at init. Implemented only for npcx. */
#undef CONFIG_POWER_BUTTON_INIT_IDLE
/*