|
75 | 75 | #define PWRBTN_WAIT_HOLD (200 * MSEC) |
76 | 76 | #define PWRBTN_HOLD_COUNT 30 /* base on PWRBTN_WAIT_HOLD 1 count = 200ms */ |
77 | 77 | #define PWRBTN_FP_HOLD_COUNT 80 /* base on PWRBTN_WAIT_HOLD 1 count = 200ms */ |
| 78 | +#define PWRBTN_MB_HOLD_COUNT 30 /* base on PWRBTN_WAIT_HOLD 1 count = 200ms */ |
78 | 79 |
|
79 | 80 |
|
80 | 81 | enum power_button_state { |
@@ -444,24 +445,14 @@ static void state_machine(uint64_t tnow) |
444 | 445 | case PWRBTN_STATE_HELD: |
445 | 446 |
|
446 | 447 | if (power_button_is_pressed()) { |
447 | | - tnext_state = tnow + PWRBTN_WAIT_HOLD; |
448 | | - if (!gpio_get_level(GPIO_ON_OFF_FP_L)) { |
449 | | - |
450 | | - if (!chipset_in_state(CHIPSET_STATE_ANY_OFF)) { |
451 | | - CPRINTS("PB held press 4s execute force shutdown"); |
452 | | - chipset_force_shutdown(CHIPSET_SHUTDOWN_G3); |
453 | | - } |
454 | | - |
455 | | - tnext_state = tnow + PWRBTN_STATE_DELAY; |
456 | | - pwrbtn_state = PWRBTN_STATE_NEED_SHUTDOWN; |
457 | | - } else if (!gpio_get_level(GPIO_ON_OFF_BTN_L)) { |
458 | | - if (++hold_check < PWRBTN_HOLD_COUNT) |
459 | | - break; |
460 | 448 |
|
461 | | - hold_check = 0; |
462 | | - tnext_state = tnow + PWRBTN_STATE_DELAY; |
463 | | - pwrbtn_state = PWRBTN_STATE_NEED_SHUTDOWN; |
| 449 | + if (!chipset_in_state(CHIPSET_STATE_ANY_OFF)) { |
| 450 | + CPRINTS("PB held press 4s execute force shutdown"); |
| 451 | + chipset_force_shutdown(CHIPSET_SHUTDOWN_G3); |
464 | 452 | } |
| 453 | + |
| 454 | + tnext_state = tnow + PWRBTN_STATE_DELAY; |
| 455 | + pwrbtn_state = PWRBTN_STATE_NEED_SHUTDOWN; |
465 | 456 | } else { |
466 | 457 | CPRINTS("PB held press over 4s execute force shutdown"); |
467 | 458 | chipset_force_shutdown(CHIPSET_SHUTDOWN_G3); |
@@ -509,6 +500,11 @@ static void state_machine(uint64_t tnow) |
509 | 500 | tnext_state = tnow + PWRBTN_DELAY_T2; |
510 | 501 | pwrbtn_state = PWRBTN_STATE_NEED_RESET; |
511 | 502 | } else if (!gpio_get_level(GPIO_ON_OFF_BTN_L)) { |
| 503 | + tnext_state = tnow + PWRBTN_WAIT_HOLD; |
| 504 | + if (++hold_check < PWRBTN_MB_HOLD_COUNT) |
| 505 | + break; |
| 506 | + |
| 507 | + hold_check = 0; |
512 | 508 | tnext_state = tnow + PWRBTN_DELAY_T3; |
513 | 509 | pwrbtn_state = PWRBTN_STATE_NEED_BATT_CUTOFF; |
514 | 510 | } |
|
0 commit comments