From 98dc270b23ae2fc931ffb4960dd1c2127fed4c8f Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Tue, 13 Jun 2017 12:19:14 -0700 Subject: [PATCH] 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 Reviewed-on: https://chromium-review.googlesource.com/533921 Reviewed-by: Aseda Aboagye --- common/power_button_x86.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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);