[coreboot-gerrit] New patch to review for coreboot: ce2b317 storm: handle dual purpose recovery button

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Thu Apr 16 14:59:18 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/9761

-gerrit

commit ce2b3178def26ab48ab17780a6dde8d2fb7fa475
Author: Vadim Bendebury <vbendeb at chromium.org>
Date:   Fri Feb 20 12:49:47 2015 -0800

    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 at chromium.org>
    Original-Commit-Id: 45e7265bc760944f93dd98903d39d2b30aa96365
    Original-Change-Id: Iab3609ebce3a74e3d0270775b83f3cf03a8837ca
    Original-Signed-off-by: Vadim Bendebury <vbendeb at chromium.org>
    Original-Reviewed-on: https://chromium-review.googlesource.com/251711
    Original-Reviewed-by: Stefan Reinauer <reinauer at chromium.org>
---
 src/mainboard/google/storm/chromeos.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/src/mainboard/google/storm/chromeos.c b/src/mainboard/google/storm/chromeos.c
index 5913c3f..be949a5 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)



More information about the coreboot-gerrit mailing list