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>
This commit is contained in:
Furquan Shaikh
2017-06-13 12:19:14 -07:00
committed by chrome-bot
parent b9b431557e
commit 98dc270b23

View File

@@ -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);