summaryrefslogtreecommitdiff
path: root/common/power_button_x86.c
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2017-06-13 12:19:14 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-06-14 01:19:33 -0700
commit98dc270b23ae2fc931ffb4960dd1c2127fed4c8f (patch)
treeafa09b0fc096efdae22b00be2f19e029bb784474 /common/power_button_x86.c
parentb9b431557e0b5d4c97af56f640f627533296373c (diff)
downloadchrome-ec-98dc270b23ae2fc931ffb4960dd1c2127fed4c8f.tar.gz
power_button_x86: Save and restore power button pulse setting
This change ensures that the power button pulse setting is saved and restored across a sysjump. It uses the SYSJUMP_TAG "PB" (0x5042). BUG=b:62445190 BRANCH=None TEST=The condition mentioned in the bug could be reproduced using following steps: 1. reboot on EC console 2. Use Vup/Vdn to select any option other than Power off. 3. Press power button After step #3 above, device would shut down instead of selecting the option. Verified that with this change, the device does not power off anymore at step #3. Change-Id: Icebe9c17d39a82fc3854dd75cc3a1dea032a234a Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/533921 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'common/power_button_x86.c')
-rw-r--r--common/power_button_x86.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/common/power_button_x86.c b/common/power_button_x86.c
index 096fd478ce..bccf9c9c11 100644
--- a/common/power_button_x86.c
+++ b/common/power_button_x86.c
@@ -495,3 +495,31 @@ DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, power_button_pulse_setting_reset,
HOOK_PRIO_DEFAULT);
DECLARE_HOOK(HOOK_CHIPSET_RESUME, power_button_pulse_setting_reset,
HOOK_PRIO_DEFAULT);
+
+#define POWER_BUTTON_SYSJUMP_TAG 0x5042 /* PB */
+#define POWER_BUTTON_HOOK_VERSION 1
+
+static void power_button_pulse_setting_restore_state(void)
+{
+ const int *state;
+ int version, size;
+
+ state = (const int *)system_get_jump_tag(POWER_BUTTON_SYSJUMP_TAG,
+ &version, &size);
+
+ if (state && (version == POWER_BUTTON_HOOK_VERSION) &&
+ (size == sizeof(power_button_pulse_enabled)))
+ power_button_pulse_enabled = *state;
+}
+DECLARE_HOOK(HOOK_INIT, power_button_pulse_setting_restore_state,
+ HOOK_PRIO_INIT_POWER_BUTTON + 1);
+
+static void power_button_pulse_setting_preserve_state(void)
+{
+ system_add_jump_tag(POWER_BUTTON_SYSJUMP_TAG,
+ POWER_BUTTON_HOOK_VERSION,
+ sizeof(power_button_pulse_enabled),
+ &power_button_pulse_enabled);
+}
+DECLARE_HOOK(HOOK_SYSJUMP, power_button_pulse_setting_preserve_state,
+ HOOK_PRIO_DEFAULT);