[coreboot-gerrit] Patch set updated for coreboot: 895c06f google/storm: support factory reset (wipeout) request

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Wed Apr 22 19:52:12 CEST 2015


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/9863

-gerrit

commit 895c06f645177c60e4b9b78b249b758ffc43c358
Author: Vadim Bendebury <vbendeb at chromium.org>
Date:   Thu Mar 12 19:47:22 2015 -0700

    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 at chromium.org>
    Original-Commit-Id: 3c503ec13c2b096d4a21fb299c0dd0396f1d01e9
    Original-Change-Id: Ic3678217906e56307d47378fa8a6defeb314084e
    Original-Signed-off-by: Vadim Bendebury <vbendeb at chromium.org>
    Original-Reviewed-on: https://chromium-review.googlesource.com/259844
---
 src/mainboard/google/storm/Kconfig    |  1 +
 src/mainboard/google/storm/chromeos.c | 73 +++++++++++++++++++++++++++++------
 2 files changed, 62 insertions(+), 12 deletions(-)

diff --git a/src/mainboard/google/storm/Kconfig b/src/mainboard/google/storm/Kconfig
index ecfb8be..3ca3b27 100644
--- a/src/mainboard/google/storm/Kconfig
+++ b/src/mainboard/google/storm/Kconfig
@@ -32,6 +32,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 4a01fa8..d424f30 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)



More information about the coreboot-gerrit mailing list