Skip to content

Commit 5251758

Browse files
authored
Iris: change the FP power button behavior (#867)
* Iris: change the FP power button behavior change the PB force shutdown behavior now if hold the PB over than 4s will direct execution force shutdown over than 20s still execution EC reset Signed-off-by: LeoCX_Tsai <[email protected]> * Iris: remove json code Signed-off-by: LeoCX_Tsai <[email protected]> * Iris: remove unused function Signed-off-by: LeoCX_Tsai <[email protected]> --------- Signed-off-by: LeoCX_Tsai <[email protected]>
1 parent f6d6b92 commit 5251758

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

board/hx30/power_button_x86.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
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 (1 * SECOND) /* 20s - (T1 + 16s hold) */
62-
#define PWRBTN_DELAY_T3 (1 * SECOND) /* 11s - (T1 + 6s hold) */
61+
#define PWRBTN_DELAY_T2 (1 * MSEC) /* (T1 + 16s hold) */
62+
#define PWRBTN_DELAY_T3 (1 * SECOND) /* 1s + (T1 + 6s hold) */
6363
/*
6464
* Length of time to stretch initial power button press to give chipset a
6565
* chance to wake up (~100ms) and react to the press (~16ms). Also used as
@@ -446,10 +446,12 @@ static void state_machine(uint64_t tnow)
446446
if (power_button_is_pressed()) {
447447
tnext_state = tnow + PWRBTN_WAIT_HOLD;
448448
if (!gpio_get_level(GPIO_ON_OFF_FP_L)) {
449-
if (++hold_check < PWRBTN_FP_HOLD_COUNT)
450-
break;
451449

452-
hold_check = 0;
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+
453455
tnext_state = tnow + PWRBTN_STATE_DELAY;
454456
pwrbtn_state = PWRBTN_STATE_NEED_SHUTDOWN;
455457
} else if (!gpio_get_level(GPIO_ON_OFF_BTN_L)) {
@@ -499,13 +501,19 @@ static void state_machine(uint64_t tnow)
499501

500502
if (power_button_is_pressed()) {
501503
if (!gpio_get_level(GPIO_ON_OFF_FP_L)) {
504+
tnext_state = tnow + PWRBTN_WAIT_HOLD;
505+
if (++hold_check < PWRBTN_FP_HOLD_COUNT)
506+
break;
507+
508+
hold_check = 0;
502509
tnext_state = tnow + PWRBTN_DELAY_T2;
503510
pwrbtn_state = PWRBTN_STATE_NEED_RESET;
504511
} else if (!gpio_get_level(GPIO_ON_OFF_BTN_L)) {
505512
tnext_state = tnow + PWRBTN_DELAY_T3;
506513
pwrbtn_state = PWRBTN_STATE_NEED_BATT_CUTOFF;
507514
}
508515
} else {
516+
hold_check = 0;
509517
power_button_released(tnow);
510518
}
511519

board/hx30/power_sequence.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#define CPUTS(outstr) cputs(CC_CHIPSET, outstr)
3737
#define CPRINTS(format, args...) cprints(CC_CHIPSET, format, ## args)
3838

39-
static int forcing_shutdown; /* Forced shutdown in progress? */
4039
static int custom_forcing_shutdown;
4140

4241
/*
@@ -80,7 +79,6 @@ void chipset_force_shutdown(enum chipset_shutdown_reason reason)
8079
*/
8180
if (!chipset_in_state(CHIPSET_STATE_ANY_OFF)) {
8281
report_ap_reset(reason);
83-
forcing_shutdown = 1;
8482
custom_forcing_shutdown = 1;
8583
chipset_force_g3();
8684
/* we need to clear the wake source to avoid the wrong power state */
@@ -92,17 +90,10 @@ void chipset_force_shutdown(enum chipset_shutdown_reason reason)
9290
void chipset_handle_espi_reset_assert(void)
9391
{
9492
/*
95-
* If eSPI_Reset# pin is asserted without SLP_SUS# being asserted, then
96-
* it means that there is an unexpected power loss (global reset
97-
* event). In this case, check if shutdown was being forced by pressing
98-
* power button. If yes, release power button.
93+
* remove unused function, because we still need
94+
* keep PB state when PCH_RESET or chip set shutdown
95+
* for next PB action(EC chip Reset)
9996
*/
100-
if ((power_get_signals() & IN_PCH_SLP_SUS_DEASSERTED) &&
101-
forcing_shutdown) {
102-
power_button_pch_release();
103-
forcing_shutdown = 0;
104-
105-
}
10697
}
10798

10899
/*

0 commit comments

Comments
 (0)