summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-02-07 09:36:28 -0800
committerGerrit Code Review <gerrit@gerrit-int.golo.chromium.org>2012-02-07 09:36:28 -0800
commit36d39dbb0dc457aaac6b1904e6352b8a0a42dc60 (patch)
tree0bf09b0fdcf5f825e3583f5b5beeda6bb6665e55 /chip
parent730f099c83b67861a269560e2bb5da1bd6bee503 (diff)
parent7ce07a78350500d3b60f05bf5b1c132fc2910d8f (diff)
downloadchrome-ec-36d39dbb0dc457aaac6b1904e6352b8a0a42dc60.tar.gz
Merge "Fix power button being held down for 8 sec"
Diffstat (limited to 'chip')
-rw-r--r--chip/lm4/power_button.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/chip/lm4/power_button.c b/chip/lm4/power_button.c
index 4beed7e47b..4b3e3b4edc 100644
--- a/chip/lm4/power_button.c
+++ b/chip/lm4/power_button.c
@@ -28,11 +28,11 @@ struct debounce_isr_t debounce_isr[DEBOUNCE_ISR_ID_MAX];
enum power_button_state {
PWRBTN_STATE_STOPPED = 0,
- PWRBTN_STATE_START = 1,
- PWRBTN_STATE_T0 = 2,
- PWRBTN_STATE_T1 = 3,
- PWRBTN_STATE_T2 = 4,
- PWRBTN_STATE_STOPPING = 5,
+ PWRBTN_STATE_START,
+ PWRBTN_STATE_T0,
+ PWRBTN_STATE_T1,
+ PWRBTN_STATE_HELD_DOWN,
+ PWRBTN_STATE_STOPPING,
};
static enum power_button_state pwrbtn_state = PWRBTN_STATE_STOPPED;
/* The next timestamp to move onto next state if power button is still pressed.
@@ -41,7 +41,6 @@ static timestamp_t pwrbtn_next_ts = {0};
#define PWRBTN_DELAY_T0 32000 /* 32ms */
#define PWRBTN_DELAY_T1 (4000000 - PWRBTN_DELAY_T0) /* 4 secs - t0 */
-#define PWRBTN_DELAY_T2 4000000 /* 4 secs */
static void lid_switch_isr(void)
@@ -61,7 +60,7 @@ static void lid_switch_isr(void)
*
* PWRBTN# --- --------- ----
* to PCH |__| |___________|
- * t0 t1 t2
+ * t0 t1 held down
*/
static void set_pwrbtn_to_pch(int high)
{
@@ -88,8 +87,7 @@ static void pwrbtn_sm_stop(void)
static void pwrbtn_sm_handle(timestamp_t current)
{
/* Not the time to move onto next state */
- if (pwrbtn_state == PWRBTN_STATE_STOPPED ||
- current.val < pwrbtn_next_ts.val)
+ if (current.val < pwrbtn_next_ts.val)
return;
switch (pwrbtn_state) {
@@ -104,17 +102,16 @@ static void pwrbtn_sm_handle(timestamp_t current)
set_pwrbtn_to_pch(1);
break;
case PWRBTN_STATE_T1:
- pwrbtn_next_ts.val = current.val + PWRBTN_DELAY_T2;
- pwrbtn_state = PWRBTN_STATE_T2;
+ pwrbtn_state = PWRBTN_STATE_HELD_DOWN;
set_pwrbtn_to_pch(0);
break;
- case PWRBTN_STATE_T2:
- /* T2 has passed */
case PWRBTN_STATE_STOPPING:
set_pwrbtn_to_pch(1);
pwrbtn_state = PWRBTN_STATE_STOPPED;
break;
- default:
+ case PWRBTN_STATE_STOPPED:
+ case PWRBTN_STATE_HELD_DOWN:
+ /* Do nothing */
break;
}
}