Skip to content

Commit 7c760ce

Browse files
authored
Merge pull request #618 from FrameworkComputer/hx30.PB_behavior
Iris: modify main board power button behavior
2 parents 31ed448 + ab919f5 commit 7c760ce

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

board/hx30/power_button_x86.c

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,10 @@
5656
* to host v v
5757
* @S0 make code break code
5858
*/
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) */
6763
/*
6864
* Length of time to stretch initial power button press to give chipset a
6965
* chance to wake up (~100ms) and react to the press (~16ms). Also used as
@@ -76,6 +72,8 @@
7672
#define PWRBTN_RETRY_COUNT 200 /* base on PWRBTN_WAIT_RSMRST 1 count = 20ms */
7773
#define PWRBTN_WAIT_RELEASE (100 * MSEC)
7874
#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 */
7977

8078
enum power_button_state {
8179
/* Button up; state machine idle */
@@ -138,6 +136,9 @@ static uint64_t tnext_state;
138136
/* retry for the PWRBTN_WAIT_RSMRST */
139137
static int rsmrst_retry = 0;
140138

139+
/* check for the hold state */
140+
static int hold_check;
141+
141142
/*
142143
* Record the time when power button task starts. It can be used by any code
143144
* 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)
441442
case PWRBTN_STATE_HELD:
442443

443444
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;
445451
pwrbtn_state = PWRBTN_STATE_NEED_SHUTDOWN;
446452
} else {
453+
CPRINTS("PB held press 4~10s execute force shutdown");
454+
chipset_force_shutdown(CHIPSET_SHUTDOWN_G3);
455+
hold_check = 0;
447456
power_button_released(tnow);
448457
}
449458

@@ -476,10 +485,6 @@ static void state_machine(uint64_t tnow)
476485
break;
477486
case PWRBTN_STATE_NEED_SHUTDOWN:
478487

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-
}
483488

484489
if (power_button_is_pressed()) {
485490
if (!gpio_get_level(GPIO_ON_OFF_FP_L)) {

0 commit comments

Comments
 (0)