diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2015-02-20 12:49:47 -0800 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2015-04-17 10:03:58 +0200 |
commit | f61809ab38ddde631586da7c1345c8dc787174f4 (patch) | |
tree | ff75b6af4bd11f9531b75ea00c6f72b6381d93b8 /src/mainboard/google | |
parent | 20557c28ceb0117e4a5ae57b043e5e3edd385162 (diff) |
storm: handle dual purpose recovery button
Storm devices' recovery button is overloaded. Pressing it when the
system is running is supposed to reset the device. To trigger recovery
mode the button must be held pressed for at least 5 seconds after
reset.
Currently interpreting the recovery button state is the responsibility
of the board (vboot gets a consolidated state, which is a combination
of several conditions), so the simplest way to implement this feature
is to make the board follow the recovery button state.
In case the button is not pressed when it is first sampled, its state
is saved immediately and no recovery request is reported. In case the
button is pressed when it is first sampled, the board code keeps
polling it up to 5 seconds and acts accordingly.
BRANCH=storm
BUG=chrome-os-partner:36059
TEST=tried starting a whirlwind with recovery button pressed for
various durations, it entered recovery mode when the button was
pressed longer than 5 seconds.
Change-Id: Icb3250be7c2a76089c070acd68cb521d1399e245
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 45e7265bc760944f93dd98903d39d2b30aa96365
Original-Change-Id: Iab3609ebce3a74e3d0270775b83f3cf03a8837ca
Original-Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Original-Reviewed-on: https://chromium-review.googlesource.com/251711
Original-Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
Reviewed-on: http://review.coreboot.org/9761
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/mainboard/google')
-rw-r--r-- | src/mainboard/google/storm/chromeos.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/mainboard/google/storm/chromeos.c b/src/mainboard/google/storm/chromeos.c index 5913c3fe13..be949a515e 100644 --- a/src/mainboard/google/storm/chromeos.c +++ b/src/mainboard/google/storm/chromeos.c @@ -22,6 +22,7 @@ #include <delay.h> #include <gpio.h> #include <string.h> +#include <timer.h> #include <vendorcode/google/chromeos/chromeos.h> #define DEV_SW 15 @@ -60,9 +61,35 @@ int get_developer_mode_switch(void) return read_gpio(DEV_SW) ^ !DEV_POL; } +/* + * Holding recovery button pressed continuously for 5 seconds at reset time + * is required to trigger recovery mode. + */ +#define RECOVERY_MODE_DELAY_MS (5 * 1000) int get_recovery_mode_switch(void) { - return read_gpio(REC_SW) ^ !REC_POL; + struct stopwatch sw; + static int sampled_value = -1; + + if (sampled_value == -1) + sampled_value = read_gpio(REC_SW) ^ !REC_POL; + + if (!sampled_value) + return 0; + + printk(BIOS_INFO, "recovery button pressed\n"); + stopwatch_init_msecs_expire(&sw, RECOVERY_MODE_DELAY_MS); + + do { + sampled_value = read_gpio(REC_SW) ^ !REC_POL; + if (!sampled_value) + break; + } while (!stopwatch_expired(&sw)); + + if (sampled_value) + printk(BIOS_INFO, "recovery mode requested\n"); + + return sampled_value; } int get_write_protect_state(void) |