Skip to content

Commit a29b80c

Browse files
authored
hx30: modified the mainboard power button behavior (#951)
Signed-off-by: Josh-Tsai <[email protected]>
1 parent 4ea1c89 commit a29b80c

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

board/hx30/power_button_x86.c

+12-16
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
#define PWRBTN_WAIT_HOLD (200 * MSEC)
7676
#define PWRBTN_HOLD_COUNT 30 /* base on PWRBTN_WAIT_HOLD 1 count = 200ms */
7777
#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 */
7879

7980

8081
enum power_button_state {
@@ -444,24 +445,14 @@ static void state_machine(uint64_t tnow)
444445
case PWRBTN_STATE_HELD:
445446

446447
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;
460448

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);
464452
}
453+
454+
tnext_state = tnow + PWRBTN_STATE_DELAY;
455+
pwrbtn_state = PWRBTN_STATE_NEED_SHUTDOWN;
465456
} else {
466457
CPRINTS("PB held press over 4s execute force shutdown");
467458
chipset_force_shutdown(CHIPSET_SHUTDOWN_G3);
@@ -509,6 +500,11 @@ static void state_machine(uint64_t tnow)
509500
tnext_state = tnow + PWRBTN_DELAY_T2;
510501
pwrbtn_state = PWRBTN_STATE_NEED_RESET;
511502
} 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;
512508
tnext_state = tnow + PWRBTN_DELAY_T3;
513509
pwrbtn_state = PWRBTN_STATE_NEED_BATT_CUTOFF;
514510
}

0 commit comments

Comments
 (0)