|
58 | 58 | */ |
59 | 59 | #define PWRBTN_DELAY_T0 (32 * MSEC) /* 32ms (PCH requires >16ms) */ |
60 | 60 | #define PWRBTN_DELAY_T1 (4 * SECOND - PWRBTN_DELAY_T0) /* 4 secs - t0 */ |
61 | | -#define PWRBTN_DELAY_T2 (10 * SECOND) /* 20s - (T1 + 6s hold) */ |
| 61 | +#define PWRBTN_DELAY_T2 (1 * SECOND) /* 20s - (T1 + 16s hold) */ |
62 | 62 | #define PWRBTN_DELAY_T3 (1 * SECOND) /* 11s - (T1 + 6s hold) */ |
63 | 63 | /* |
64 | 64 | * Length of time to stretch initial power button press to give chipset a |
|
72 | 72 | #define PWRBTN_RETRY_COUNT 200 /* base on PWRBTN_WAIT_RSMRST 1 count = 20ms */ |
73 | 73 | #define PWRBTN_WAIT_RELEASE (100 * MSEC) |
74 | 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 */ |
| 75 | +#define PWRBTN_WAIT_HOLD (200 * MSEC) |
| 76 | +#define PWRBTN_HOLD_COUNT 30 /* base on PWRBTN_WAIT_HOLD 1 count = 200ms */ |
| 77 | +#define PWRBTN_FP_HOLD_COUNT 80 /* base on PWRBTN_WAIT_HOLD 1 count = 200ms */ |
| 78 | + |
77 | 79 |
|
78 | 80 | enum power_button_state { |
79 | 81 | /* Button up; state machine idle */ |
@@ -442,15 +444,25 @@ static void state_machine(uint64_t tnow) |
442 | 444 | case PWRBTN_STATE_HELD: |
443 | 445 |
|
444 | 446 | if (power_button_is_pressed()) { |
445 | | - tnext_state = tnow + PWRBTN_WAIT_HOLD; |
446 | | - if (++hold_check < PWRBTN_HOLD_COUNT) |
447 | | - break; |
| 447 | + if (!gpio_get_level(GPIO_ON_OFF_FP_L)) { |
| 448 | + tnext_state = tnow + PWRBTN_WAIT_HOLD; |
| 449 | + if (++hold_check < PWRBTN_FP_HOLD_COUNT) |
| 450 | + break; |
448 | 451 |
|
449 | | - hold_check = 0; |
450 | | - tnext_state = tnow + PWRBTN_STATE_DELAY; |
451 | | - pwrbtn_state = PWRBTN_STATE_NEED_SHUTDOWN; |
| 452 | + hold_check = 0; |
| 453 | + tnext_state = tnow + PWRBTN_STATE_DELAY; |
| 454 | + pwrbtn_state = PWRBTN_STATE_NEED_SHUTDOWN; |
| 455 | + } else if (!gpio_get_level(GPIO_ON_OFF_BTN_L)) { |
| 456 | + tnext_state = tnow + PWRBTN_WAIT_HOLD; |
| 457 | + if (++hold_check < PWRBTN_HOLD_COUNT) |
| 458 | + break; |
| 459 | + |
| 460 | + hold_check = 0; |
| 461 | + tnext_state = tnow + PWRBTN_STATE_DELAY; |
| 462 | + pwrbtn_state = PWRBTN_STATE_NEED_SHUTDOWN; |
| 463 | + } |
452 | 464 | } else { |
453 | | - CPRINTS("PB held press 4~10s execute force shutdown"); |
| 465 | + CPRINTS("PB held press over 4s execute force shutdown"); |
454 | 466 | chipset_force_shutdown(CHIPSET_SHUTDOWN_G3); |
455 | 467 | hold_check = 0; |
456 | 468 | power_button_released(tnow); |
@@ -585,6 +597,7 @@ static void powerbtn_x86_changed(void) |
585 | 597 | if (pwrbtn_state == PWRBTN_STATE_BOOT_KB_RESET || |
586 | 598 | pwrbtn_state == PWRBTN_STATE_INIT_ON || |
587 | 599 | pwrbtn_state == PWRBTN_STATE_LID_OPEN || |
| 600 | + pwrbtn_state == PWRBTN_STATE_HELD || |
588 | 601 | pwrbtn_state == PWRBTN_STATE_WAS_OFF || |
589 | 602 | pwrbtn_state == PWRBTN_STATE_NEED_BATT_CUTOFF) { |
590 | 603 | /* Ignore all power button changes during an initial pulse */ |
|
0 commit comments