summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2017-04-25 16:47:34 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-05-02 17:45:16 -0700
commitc388d3e27877c1e3b1b2f078cd320d604509087d (patch)
tree15887d1e570fba25d62b245663f2bed816ce6881
parent2bb9aec01aded925b726f7b18a66cdad181ac8db (diff)
downloadchrome-ec-stabilize-9517.B.tar.gz
common/button: Blink LED for 3 seconds when setting recovery HW_REINITstabilize-9517.B
If user holds down volume up, volume down and power button for 30 seconds, set HW_REINIT event and blink LED for 3 seconds to indicate to user that the request was accepted. BUG=b:37682514 BRANCH=None TEST=make -j buildall Change-Id: I6b70d56f50d0a1cfae3fa7f337a34ac487943775 Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/487281 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
-rw-r--r--common/button.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/common/button.c b/common/button.c
index 71d1af95fb..531467240b 100644
--- a/common/button.c
+++ b/common/button.c
@@ -12,6 +12,7 @@
#include "host_command.h"
#include "hooks.h"
#include "keyboard_protocol.h"
+#include "led_common.h"
#include "power_button.h"
#include "system.h"
#include "timer.h"
@@ -59,6 +60,30 @@ static int raw_button_pressed(const struct button_config *button)
}
#ifdef CONFIG_BUTTON_RECOVERY
+
+#ifdef CONFIG_LED_COMMON
+static void button_blink_hw_reinit_led(void)
+{
+ int led_state = LED_STATE_ON;
+ timestamp_t deadline;
+ timestamp_t now = get_time();
+
+ /* Blink LED for 3 seconds. */
+ deadline.val = now.val + (3 * SECOND);
+
+ while (!timestamp_expired(deadline, &now)) {
+ led_control(EC_LED_ID_RECOVERY_HW_REINIT_LED, led_state);
+ led_state = !led_state;
+ watchdog_reload();
+ msleep(100);
+ now = get_time();
+ }
+
+ /* Reset LED to default state. */
+ led_control(EC_LED_ID_RECOVERY_HW_REINIT_LED, LED_STATE_RESET);
+}
+#endif
+
/*
* If the EC is reset and recovery is requested, then check if HW_REINIT is
* requested as well. Since the EC reset occurs after volup+voldn+power buttons
@@ -89,6 +114,10 @@ static void button_check_hw_reinit_required(void)
CPRINTS("HW_REINIT requested");
host_set_single_event(EC_HOST_EVENT_KEYBOARD_RECOVERY_HW_REINIT);
+
+#ifdef CONFIG_LED_COMMON
+ button_blink_hw_reinit_led();
+#endif
}
#endif