|
56 | 56 | * to host v v |
57 | 57 | * @S0 make code break code |
58 | 58 | */ |
59 | | -#define PWRBTN_DELAY_T0 (32 * MSEC) /* 32ms (PCH requires >16ms) */ |
60 | | -#define PWRBTN_DELAY_T1 (4 * SECOND - PWRBTN_DELAY_T0) /* 4 secs - t0 */ |
61 | | -#define PWRBTN_DELAY_T4 \ |
62 | | - (8 * SECOND - PWRBTN_DELAY_T1 - PWRBTN_DELAY_T0) /* 8 secs - t1 */ |
63 | | -#define PWRBTN_DELAY_T2 \ |
64 | | - (20 * SECOND - PWRBTN_DELAY_T4 - PWRBTN_DELAY_T1) /* 20 secs - t4 */ |
65 | | -#define PWRBTN_DELAY_T3 \ |
66 | | - (10 * SECOND - PWRBTN_DELAY_T4 - PWRBTN_DELAY_T1) /* 10 secs - t4 */ |
| 59 | +#define PWRBTN_DELAY_T0 (32 * MSEC) /* 32ms (PCH requires >16ms) */ |
| 60 | +#define PWRBTN_DELAY_T1 (4 * SECOND - PWRBTN_DELAY_T0) /* 4 secs - t0 */ |
| 61 | +#define PWRBTN_DELAY_T2 (10 * SECOND) /* 20s - (T1 + 6s hold) */ |
| 62 | +#define PWRBTN_DELAY_T3 (1 * SECOND) /* 11s - (T1 + 6s hold) */ |
67 | 63 | /* |
68 | 64 | * Length of time to stretch initial power button press to give chipset a |
69 | 65 | * chance to wake up (~100ms) and react to the press (~16ms). Also used as |
|
76 | 72 | #define PWRBTN_RETRY_COUNT 200 /* base on PWRBTN_WAIT_RSMRST 1 count = 20ms */ |
77 | 73 | #define PWRBTN_WAIT_RELEASE (100 * MSEC) |
78 | 74 | #define PWRBTN_STATE_DELAY (1 * MSEC) /* debounce for the state change */ |
| 75 | +#define PWRBTN_WAIT_HOLD (1000 * MSEC) |
| 76 | +#define PWRBTN_HOLD_COUNT 6 /* base on PWRBTN_WAIT_HOLD 1 count = 1000ms */ |
79 | 77 |
|
80 | 78 | enum power_button_state { |
81 | 79 | /* Button up; state machine idle */ |
@@ -138,6 +136,9 @@ static uint64_t tnext_state; |
138 | 136 | /* retry for the PWRBTN_WAIT_RSMRST */ |
139 | 137 | static int rsmrst_retry = 0; |
140 | 138 |
|
| 139 | +/* check for the hold state */ |
| 140 | +static int hold_check; |
| 141 | + |
141 | 142 | /* |
142 | 143 | * Record the time when power button task starts. It can be used by any code |
143 | 144 | * path that needs to compare the current time with power button task start time |
@@ -441,9 +442,17 @@ static void state_machine(uint64_t tnow) |
441 | 442 | case PWRBTN_STATE_HELD: |
442 | 443 |
|
443 | 444 | if (power_button_is_pressed()) { |
444 | | - tnext_state = tnow + PWRBTN_DELAY_T4; |
| 445 | + tnext_state = tnow + PWRBTN_WAIT_HOLD; |
| 446 | + if (++hold_check < PWRBTN_HOLD_COUNT) |
| 447 | + break; |
| 448 | + |
| 449 | + hold_check = 0; |
| 450 | + tnext_state = tnow + PWRBTN_STATE_DELAY; |
445 | 451 | pwrbtn_state = PWRBTN_STATE_NEED_SHUTDOWN; |
446 | 452 | } else { |
| 453 | + CPRINTS("PB held press 4~10s execute force shutdown"); |
| 454 | + chipset_force_shutdown(CHIPSET_SHUTDOWN_G3); |
| 455 | + hold_check = 0; |
447 | 456 | power_button_released(tnow); |
448 | 457 | } |
449 | 458 |
|
@@ -476,10 +485,6 @@ static void state_machine(uint64_t tnow) |
476 | 485 | break; |
477 | 486 | case PWRBTN_STATE_NEED_SHUTDOWN: |
478 | 487 |
|
479 | | - if (!chipset_in_state(CHIPSET_STATE_ANY_OFF)) { |
480 | | - CPRINTS("PB held press 8s execute force shutdown"); |
481 | | - chipset_force_shutdown(CHIPSET_SHUTDOWN_G3); |
482 | | - } |
483 | 488 |
|
484 | 489 | if (power_button_is_pressed()) { |
485 | 490 | if (!gpio_get_level(GPIO_ON_OFF_FP_L)) { |
|
0 commit comments