aboutsummaryrefslogtreecommitdiffstats
path: root/src/mainboard
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2015-03-12 19:47:22 -0700
committerPatrick Georgi <pgeorgi@google.com>2015-04-22 19:53:13 +0200
commit381785df450cbbfa27ab12d8a9d929d5e834c673 (patch)
tree66595e57e4a367da410cdd590d059375fd6aa0b7 /src/mainboard
parent8a6e635419f647ea3816788444c6718ff0e4d846 (diff)
downloadcoreboot-381785df450cbbfa27ab12d8a9d929d5e834c673.tar.gz
coreboot-381785df450cbbfa27ab12d8a9d929d5e834c673.tar.xz
coreboot-381785df450cbbfa27ab12d8a9d929d5e834c673.zip
google/storm: support factory reset (wipeout) request
The recovery switch on storm is overloaded: it needs to be pressed for a certain duration at startup to signal different requests: - keeping it pressed for 8 to 16 seconds after startup signals the need for factory reset (wipeout); - keeping it pressed for longer than 16 seconds signals the need for Chrome OS recovery. This patch adds a function to report the wipeout request status and enables the new feature on Storm. BRANCH=storm BUG=chrome-os-partner:37219 TEST=verified that keeping the recovery button pressed between 8 and 16 seconds at startup results in the wipeout request generated (crossystem 'wipeout_request' returns 1). Keeping the button pressed for more than 16 seconds triggers recovery mode. Change-Id: I17131593e12833866a22837271feb0e6989e6750 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: 3c503ec13c2b096d4a21fb299c0dd0396f1d01e9 Original-Change-Id: Ic3678217906e56307d47378fa8a6defeb314084e Original-Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/259844 Reviewed-on: http://review.coreboot.org/9863 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Diffstat (limited to 'src/mainboard')
-rw-r--r--src/mainboard/google/storm/Kconfig1
-rw-r--r--src/mainboard/google/storm/chromeos.c73
2 files changed, 62 insertions, 12 deletions
diff --git a/src/mainboard/google/storm/Kconfig b/src/mainboard/google/storm/Kconfig
index 1cc83785f..65b3ed423 100644
--- a/src/mainboard/google/storm/Kconfig
+++ b/src/mainboard/google/storm/Kconfig
@@ -33,6 +33,7 @@ config BOARD_SPECIFIC_OPTIONS
select SPI_FLASH
select SPI_FLASH_SPANSION
select SPI_FLASH_STMICRO
+ select WIPEOUT_SUPPORTED
config BOARD_VARIANT_AP148
bool "pick this to build an image for ap148"
diff --git a/src/mainboard/google/storm/chromeos.c b/src/mainboard/google/storm/chromeos.c
index 4a01fa882..d424f3084 100644
--- a/src/mainboard/google/storm/chromeos.c
+++ b/src/mainboard/google/storm/chromeos.c
@@ -66,23 +66,45 @@ int get_developer_mode_switch(void)
}
/*
- * Holding recovery button pressed continuously for 5 seconds at reset time
- * is required to trigger recovery mode.
+ * The recovery switch on storm is overloaded: it needs to be pressed for a
+ * certain duration at startup to signal different requests:
+ *
+ * - keeping it pressed for 8 to 16 seconds after startup signals the need for
+ * factory reset (wipeout);
+ * - keeping it pressed for longer than 16 seconds signals the need for Chrome
+ * OS recovery.
+ *
+ * The state is read once and cached for following inquiries. The below enum
+ * lists possible states.
*/
-#define RECOVERY_MODE_DELAY_MS (5 * 1000)
-int get_recovery_mode_switch(void)
+enum switch_state {
+ not_probed = -1,
+ no_req,
+ recovery_req,
+ wipeout_req
+};
+
+#define WIPEOUT_MODE_DELAY_MS (8 * 1000)
+#define RECOVERY_MODE_EXTRA_DELAY_MS (8 * 1000)
+
+static enum switch_state get_switch_state(void)
{
struct stopwatch sw;
- static int sampled_value = -1;
+ int sampled_value;
+ static enum switch_state saved_state = not_probed;
- if (sampled_value == -1)
- sampled_value = read_gpio(REC_SW) ^ !REC_POL;
+ if (saved_state != not_probed)
+ return saved_state;
+
+ sampled_value = read_gpio(REC_SW) ^ !REC_POL;
- if (!sampled_value)
- return 0;
+ if (!sampled_value) {
+ saved_state = no_req;
+ return saved_state;
+ }
printk(BIOS_INFO, "recovery button pressed\n");
- stopwatch_init_msecs_expire(&sw, RECOVERY_MODE_DELAY_MS);
+ stopwatch_init_msecs_expire(&sw, WIPEOUT_MODE_DELAY_MS);
do {
sampled_value = read_gpio(REC_SW) ^ !REC_POL;
@@ -91,11 +113,38 @@ int get_recovery_mode_switch(void)
} while (!stopwatch_expired(&sw));
if (sampled_value) {
- printk(BIOS_INFO, "recovery mode requested\n");
if (board_id() == BOARD_ID_WHIRLWIND_SP5)
ww_ring_display_pattern(GSBI_ID_7, 0);
+
+ printk(BIOS_INFO, "wipeout requested, checking recovery\n");
+ stopwatch_init_msecs_expire(&sw, RECOVERY_MODE_EXTRA_DELAY_MS);
+ do {
+ sampled_value = read_gpio(REC_SW) ^ !REC_POL;
+ if (!sampled_value)
+ break;
+ } while (!stopwatch_expired(&sw));
+
+ if (sampled_value) {
+ saved_state = recovery_req;
+ printk(BIOS_INFO, "recovery requested\n");
+ } else {
+ saved_state = wipeout_req;
+ }
+ } else {
+ saved_state = no_req;
}
- return sampled_value;
+
+ return saved_state;
+}
+
+int get_recovery_mode_switch(void)
+{
+ return get_switch_state() == recovery_req;
+}
+
+int get_wipeout_mode_switch(void)
+{
+ return get_switch_state() == wipeout_req;
}
int get_write_protect_state(void)