Skip to content

Commit 02c300c

Browse files
authored
Merge pull request #623 from FrameworkComputer/hx30.PB_behavior
Iris: Modify Power button behavior
2 parents 7c760ce + c657c42 commit 02c300c

1 file changed

Lines changed: 23 additions & 10 deletions

File tree

board/hx30/power_button_x86.c

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
*/
5959
#define PWRBTN_DELAY_T0 (32 * MSEC) /* 32ms (PCH requires >16ms) */
6060
#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) */
6262
#define PWRBTN_DELAY_T3 (1 * SECOND) /* 11s - (T1 + 6s hold) */
6363
/*
6464
* Length of time to stretch initial power button press to give chipset a
@@ -72,8 +72,10 @@
7272
#define PWRBTN_RETRY_COUNT 200 /* base on PWRBTN_WAIT_RSMRST 1 count = 20ms */
7373
#define PWRBTN_WAIT_RELEASE (100 * MSEC)
7474
#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+
7779

7880
enum power_button_state {
7981
/* Button up; state machine idle */
@@ -442,15 +444,25 @@ static void state_machine(uint64_t tnow)
442444
case PWRBTN_STATE_HELD:
443445

444446
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;
448451

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+
}
452464
} else {
453-
CPRINTS("PB held press 4~10s execute force shutdown");
465+
CPRINTS("PB held press over 4s execute force shutdown");
454466
chipset_force_shutdown(CHIPSET_SHUTDOWN_G3);
455467
hold_check = 0;
456468
power_button_released(tnow);
@@ -585,6 +597,7 @@ static void powerbtn_x86_changed(void)
585597
if (pwrbtn_state == PWRBTN_STATE_BOOT_KB_RESET ||
586598
pwrbtn_state == PWRBTN_STATE_INIT_ON ||
587599
pwrbtn_state == PWRBTN_STATE_LID_OPEN ||
600+
pwrbtn_state == PWRBTN_STATE_HELD ||
588601
pwrbtn_state == PWRBTN_STATE_WAS_OFF ||
589602
pwrbtn_state == PWRBTN_STATE_NEED_BATT_CUTOFF) {
590603
/* Ignore all power button changes during an initial pulse */

0 commit comments

Comments
 (0)