Skip to content

Commit 2f961d0

Browse files
committed
Lotus: turn off the 0.75 and 1.8 power rail when the system in S5/G3
Signed-off-by: Josh-Tsai <josh_tsai@compal.com>
1 parent b97c7eb commit 2f961d0

File tree

2 files changed

+24
-62
lines changed

2 files changed

+24
-62
lines changed

zephyr/program/lotus/lotus/src/power_button_x86.c

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -260,19 +260,13 @@ static void state_machine(uint64_t tnow)
260260
case PWRBTN_STATE_PRESSED:
261261
/* chipset exit hard off function only executes at G3 state */
262262
if (chipset_in_state(CHIPSET_STATE_HARD_OFF)) {
263-
/* Check the VALW power rail is ready */
264-
if (get_power_rail_status()) {
265-
/*
266-
* Power button out signal implements in power_sequence.c,
267-
* just call the exit hard off start to run the state mechine.
268-
*/
269-
reset_diagnostics();
270-
chipset_exit_hard_off();
271-
pwrbtn_state = PWRBTN_STATE_IDLE;
272-
} else {
273-
tnext_state = tnow + PWRBTN_DELAY_INIT;
274-
pwrbtn_state = PWRBTN_STATE_PRESSED;
275-
}
263+
/*
264+
* Power button out signal implements in power_sequence.c,
265+
* just call the exit hard off start to run the state mechine.
266+
*/
267+
reset_diagnostics();
268+
chipset_exit_hard_off();
269+
pwrbtn_state = PWRBTN_STATE_IDLE;
276270
} else {
277271
/*
278272
* when in preOS still need send power button signal
@@ -344,19 +338,13 @@ static void state_machine(uint64_t tnow)
344338
}
345339
}
346340

347-
/* Check the VALW power rail is ready */
348-
if (get_power_rail_status()) {
349-
/*
350-
* Power button out signal implements in power_sequence.c,
351-
* just call the exit hard off start to run the state mechine.
352-
*/
353-
reset_diagnostics();
354-
chipset_exit_hard_off();
355-
pwrbtn_state = PWRBTN_STATE_IDLE;
356-
} else {
357-
tnext_state = tnow + PWRBTN_DELAY_INIT;
358-
pwrbtn_state = PWRBTN_STATE_INIT_ON;
359-
}
341+
/*
342+
* Power button out signal implements in power_sequence.c,
343+
* just call the exit hard off start to run the state mechine.
344+
*/
345+
reset_diagnostics();
346+
chipset_exit_hard_off();
347+
pwrbtn_state = PWRBTN_STATE_IDLE;
360348
break;
361349
case PWRBTN_STATE_HELD:
362350

zephyr/program/lotus/lotus/src/power_sequence.c

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
#define IN_VR_PGOOD POWER_SIGNAL_MASK(X86_VR_PG)
2929

30-
static int power_ready;
3130
static int power_s5_up; /* Chipset is sequencing up or down */
3231
static int ap_boot_delay = 9; /* For global reset to wait SLP_S5 signal de-asserts */
3332
static int s5_exit_tries; /* For global reset to wait SLP_S5 signal de-asserts */
@@ -121,31 +120,6 @@ static void clear_rtcwake(void)
121120
*host_get_memmap(EC_CUSTOMIZED_MEMMAP_WAKE_EVENT) &= ~BIT(0);
122121
}
123122

124-
static void board_power_on(void);
125-
DECLARE_DEFERRED(board_power_on);
126-
DECLARE_HOOK(HOOK_INIT, board_power_on, HOOK_PRIO_DEFAULT);
127-
128-
static void board_power_on(void)
129-
{
130-
static int logs_printed; /* Only prints the log one time */
131-
132-
/*
133-
* we need to wait the 3VALW power rail ready
134-
* then enable 0.75VALW and 1.8VALW power rail
135-
*/
136-
if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_spok)) == 1) {
137-
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_0p75_1p8valw_pwren), 1);
138-
power_ready = 1;
139-
CPRINTS("0.75 and 1.8 VALW power rail ready");
140-
} else {
141-
if (!logs_printed) {
142-
CPRINTS("wait 3VALW power rail ready");
143-
logs_printed = 1;
144-
}
145-
hook_call_deferred(&board_power_on_data, 5 * MSEC);
146-
}
147-
}
148-
149123
void power_state_clear(int state)
150124
{
151125
*host_get_memmap(EC_CUSTOMIZED_MEMMAP_POWER_STATE) &= ~state;
@@ -213,16 +187,6 @@ void s0ix_status_handle(void)
213187
DECLARE_HOOK(HOOK_TICK, s0ix_status_handle, HOOK_PRIO_DEFAULT);
214188
#endif
215189

216-
int get_power_rail_status(void)
217-
{
218-
/*
219-
* If the 3VALW, 0.75VALW and 1.8VALW power rail not ready,
220-
* the unit should not power on.
221-
* This function will be used by PB task.
222-
*/
223-
return power_ready;
224-
}
225-
226190
void power_s5_up_control(int control)
227191
{
228192
CPRINTS("%s power s5 up!", control ? "setup" : "clear");
@@ -246,6 +210,7 @@ static void chipset_force_g3(void)
246210
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_pbtn_out), 0);
247211
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_apu_aud_pwr_en), 0);
248212
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_pch_pwr_en), 0);
213+
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_0p75_1p8valw_pwren), 0);
249214
}
250215

251216
void chipset_force_shutdown(enum chipset_shutdown_reason reason)
@@ -299,6 +264,14 @@ enum power_state power_handle_state(enum power_state state)
299264
break;
300265

301266
case POWER_G3S5:
267+
if (power_wait_signals(X86_3VALW_PG)) {
268+
/* something wrong, turn off power and force to g3 */
269+
chipset_force_g3();
270+
return POWER_G3;
271+
}
272+
273+
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_0p75_1p8valw_pwren), 1);
274+
k_msleep(10);
302275
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_apu_aud_pwr_en), 1);
303276
k_msleep(10);
304277
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_pch_pwr_en), 1);
@@ -548,6 +521,7 @@ enum power_state power_handle_state(enum power_state state)
548521
k_msleep(5);
549522
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_apu_aud_pwr_en), 0);
550523
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_pch_pwr_en), 0);
524+
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_0p75_1p8valw_pwren), 0);
551525
input_modules_powerdown();
552526

553527
/* clear suspend flag when system shutdown */

0 commit comments

Comments
 (0)