Skip to content

Commit 6ea7984

Browse files
authored
Lotus.gpio sequence (#869)
* lotus: do not reset the usb30 hub when the system shutdown Signed-off-by: Josh-Tsai <[email protected]> * lotus: turn off the peripheral device power in chipset_force_g3 Signed-off-by: Josh-Tsai <[email protected]> * lotus: run the shutdown seuqence for force_shutdown process Signed-off-by: Josh-Tsai <[email protected]> --------- Signed-off-by: Josh-Tsai <[email protected]>
1 parent 38f68cf commit 6ea7984

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

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

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
static int power_s5_up; /* Chipset is sequencing up or down */
3636
static int ap_boot_delay = 9; /* For global reset to wait SLP_S5 signal de-asserts */
3737
static int s5_exit_tries; /* For global reset to wait SLP_S5 signal de-asserts */
38-
static int force_g3_flags; /* Chipset force to g3 immediately when chipset force shutdown */
38+
static int force_shoutdown_flags;
3939
static int stress_test_enable;
4040
static int d3cold_is_entry; /* check the d3cold status */
4141

@@ -304,11 +304,11 @@ static void chipset_force_g3(void)
304304

305305
void chipset_force_shutdown(enum chipset_shutdown_reason reason)
306306
{
307-
CPRINTS("%s(%d)", __func__, reason);
308307
if (!chipset_in_state(CHIPSET_STATE_ANY_OFF)) {
308+
CPRINTS("%s(%d)", __func__, reason);
309309
report_ap_reset(reason);
310-
force_g3_flags = 1;
311-
chipset_force_g3();
310+
force_shoutdown_flags = 1;
311+
task_wake(TASK_ID_CHIPSET);
312312
}
313313
}
314314

@@ -356,11 +356,9 @@ static int chipset_prepare_S3(uint8_t enable)
356356
k_msleep(20);
357357
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_vr_on), 1);
358358

359-
/* wait VR power good */
360-
if (power_wait_signals(IN_VR_PGOOD)) {
361-
/* something wrong, turn off power and force to g3 */
362-
chipset_force_g3();
363-
}
359+
/* wait VR power good. if something wrong, turn off power and force to g3 */
360+
if (power_wait_signals(IN_VR_PGOOD))
361+
force_shoutdown_flags = 1;
364362

365363
k_msleep(10);
366364
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_sys_pwrgd_ec), 1);
@@ -412,8 +410,8 @@ enum power_state power_handle_state(enum power_state state)
412410

413411
case POWER_S5:
414412

415-
if (force_g3_flags) {
416-
force_g3_flags = 0;
413+
if (force_shoutdown_flags) {
414+
force_shoutdown_flags = 0;
417415
return POWER_S5G3;
418416
}
419417

@@ -458,7 +456,8 @@ enum power_state power_handle_state(enum power_state state)
458456
return POWER_S3;
459457

460458
case POWER_S3:
461-
if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_slp_s3_l)) == 1) {
459+
if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_slp_s3_l)) == 1 &&
460+
!force_shoutdown_flags) {
462461

463462
/* still in s0ix state */
464463
if (system_in_s0ix)
@@ -472,7 +471,8 @@ enum power_state power_handle_state(enum power_state state)
472471
/* Power up to next state */
473472
k_msleep(10);
474473
return POWER_S3S0;
475-
} else if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_slp_s5_l)) == 0) {
474+
} else if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_slp_s5_l)) == 0
475+
|| force_shoutdown_flags) {
476476

477477
if (system_in_s0ix) {
478478
resume_ms_flag = 0;
@@ -488,6 +488,11 @@ enum power_state power_handle_state(enum power_state state)
488488
}
489489

490490
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb30_hub_en), 0);
491+
492+
/* disable the ssd2 power when the system shutdown to S5 */
493+
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_ssd2_pwr_en), 0);
494+
set_gpu_gpio(GPIO_FUNC_SSD1_POWER, 0);
495+
set_gpu_gpio(GPIO_FUNC_SSD2_POWER, 0);
491496
k_msleep(55);
492497
/* Power down to next state */
493498
return POWER_S3S5;
@@ -517,8 +522,11 @@ enum power_state power_handle_state(enum power_state state)
517522
if (power_wait_signals(IN_VR_PGOOD)) {
518523
/* something wrong, turn off power and force to g3 */
519524
set_diagnostic(DIAGNOSTICS_VCCIN_AUX_VR, 1);
520-
chipset_force_g3();
521-
return POWER_G3;
525+
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_vr_on), 0);
526+
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_susp_l), 0);
527+
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_0p75vs_pwr_en), 0);
528+
force_shoutdown_flags = 1;
529+
return POWER_S3;
522530
}
523531

524532
k_msleep(10);
@@ -538,7 +546,8 @@ enum power_state power_handle_state(enum power_state state)
538546

539547
case POWER_S0:
540548

541-
if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_slp_s3_l)) == 0) {
549+
if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_slp_s3_l)) == 0 ||
550+
force_shoutdown_flags) {
542551
/* Power down to next state */
543552
k_msleep(5);
544553
return POWER_S0S3;
@@ -552,7 +561,8 @@ enum power_state power_handle_state(enum power_state state)
552561

553562
#ifdef CONFIG_PLATFORM_EC_POWERSEQ_S0IX
554563
case POWER_S0ix:
555-
if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_slp_s3_l)) == 0) {
564+
if (gpio_pin_get_dt(GPIO_DT_FROM_NODELABEL(gpio_slp_s3_l)) == 0 ||
565+
force_shoutdown_flags) {
556566
/*
557567
* If power signal lose, we need to resume to S0 and
558568
* clear the all s0ix flags
@@ -706,6 +716,9 @@ static void usb30_hub_reset(void)
706716
set_gpu_gpio(GPIO_FUNC_SSD1_POWER, 1);
707717
set_gpu_gpio(GPIO_FUNC_SSD2_POWER, 1);
708718
usleep(200 * MSEC);
719+
/* do not reset the hub when the system shutdown */
720+
if (!chipset_in_state(CHIPSET_STATE_ON))
721+
return;
709722
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb30_hub_en), 0);
710723
usleep(10 * MSEC);
711724
gpio_pin_set_dt(GPIO_DT_FROM_NODELABEL(gpio_usb30_hub_en), 1);

0 commit comments

Comments
 (0)