summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2015-11-09 12:06:54 -0800
committerChromeOS bot <3su6n15k.default@developer.gserviceaccount.com>2015-11-09 23:46:50 +0000
commitd2b7ebcf5bfccd8fff9d7c3ed5848439c653f12e (patch)
treeebd9f6f2a02eef0fc53e2fba3e8abf21330be955
parent5ed13ceaabde4eca28bf1549d5d50504c6516a1b (diff)
downloadchrome-ec-d2b7ebcf5bfccd8fff9d7c3ed5848439c653f12e.tar.gz
tegra: use long press for power-on
Switch from using a short power button press to a long 2-second press to power-on the product. Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=smaug BUG=b:25523378 TEST=manual: press the power button for various period and observe the EC console. Change-Id: Ib61f0a538986cfde6bfcd2f730be847c544874a5 Reviewed-on: https://chromium-review.googlesource.com/311720 Tested-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Alec Berg <alecaberg@chromium.org> Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--power/tegra.c31
1 files changed, 29 insertions, 2 deletions
diff --git a/power/tegra.c b/power/tegra.c
index f178ad7e79..d694fa50b4 100644
--- a/power/tegra.c
+++ b/power/tegra.c
@@ -56,6 +56,9 @@
/* Long power key press to force shutdown */
#define DELAY_FORCE_SHUTDOWN (10200 * MSEC) /* 10.2 seconds */
+/* Long power key press to power on the product */
+#define DELAY_LONG_POWER_ON (2000 * MSEC) /* 2 seconds */
+
/*
* The minimum time to assert the PMIC PWRON pin is 20ms.
* Give it longer to ensure the PMIC doesn't lose it.
@@ -101,6 +104,9 @@ static char lid_opened;
/* time where we will power off, if power button still held down */
static timestamp_t power_off_deadline;
+/* time where we will power on, if power button still held down */
+static timestamp_t power_on_deadline;
+
/* force AP power on (used for recovery keypress) */
static int auto_power_on;
@@ -321,6 +327,13 @@ void chipset_force_shutdown(void)
/*****************************************************************************/
+static void check_long_power_on(void)
+{
+ /* we are ready to power-on, kick the chipset task to do it */
+ task_wake(TASK_ID_CHIPSET);
+}
+DECLARE_DEFERRED(check_long_power_on);
+
/**
* Check if there has been a power-on event
*
@@ -365,8 +378,16 @@ static int check_for_power_on_event(void)
}
/* check for power button press */
- if (power_button_is_pressed())
- return 4;
+ if (power_button_is_pressed()) {
+ timestamp_t now = get_time();
+ if (!power_on_deadline.val) {
+ power_on_deadline.val = now.val + DELAY_LONG_POWER_ON;
+ hook_call_deferred(check_long_power_on,
+ DELAY_LONG_POWER_ON);
+ } else if (get_time().val >= power_on_deadline.val) {
+ return 4;
+ }
+ }
if (power_request == POWER_REQ_ON) {
power_request = POWER_REQ_NONE;
@@ -595,6 +616,12 @@ enum power_state power_handle_state(enum power_state state)
static void powerbtn_tegra_changed(void)
{
+ /* power button released: cancel long power-on */
+ if (!power_button_is_pressed()) {
+ power_on_deadline.val = 0;
+ hook_call_deferred(check_long_power_on, -1);
+ }
+
task_wake(TASK_ID_CHIPSET);
}
DECLARE_HOOK(HOOK_POWER_BUTTON_CHANGE, powerbtn_tegra_changed,