35
35
static int power_s5_up ; /* Chipset is sequencing up or down */
36
36
static int ap_boot_delay = 9 ; /* For global reset to wait SLP_S5 signal de-asserts */
37
37
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 ;
39
39
static int stress_test_enable ;
40
40
static int d3cold_is_entry ; /* check the d3cold status */
41
41
@@ -304,11 +304,11 @@ static void chipset_force_g3(void)
304
304
305
305
void chipset_force_shutdown (enum chipset_shutdown_reason reason )
306
306
{
307
- CPRINTS ("%s(%d)" , __func__ , reason );
308
307
if (!chipset_in_state (CHIPSET_STATE_ANY_OFF )) {
308
+ CPRINTS ("%s(%d)" , __func__ , reason );
309
309
report_ap_reset (reason );
310
- force_g3_flags = 1 ;
311
- chipset_force_g3 ( );
310
+ force_shoutdown_flags = 1 ;
311
+ task_wake ( TASK_ID_CHIPSET );
312
312
}
313
313
}
314
314
@@ -356,11 +356,9 @@ static int chipset_prepare_S3(uint8_t enable)
356
356
k_msleep (20 );
357
357
gpio_pin_set_dt (GPIO_DT_FROM_NODELABEL (gpio_vr_on ), 1 );
358
358
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 ;
364
362
365
363
k_msleep (10 );
366
364
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)
412
410
413
411
case POWER_S5 :
414
412
415
- if (force_g3_flags ) {
416
- force_g3_flags = 0 ;
413
+ if (force_shoutdown_flags ) {
414
+ force_shoutdown_flags = 0 ;
417
415
return POWER_S5G3 ;
418
416
}
419
417
@@ -458,7 +456,8 @@ enum power_state power_handle_state(enum power_state state)
458
456
return POWER_S3 ;
459
457
460
458
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 ) {
462
461
463
462
/* still in s0ix state */
464
463
if (system_in_s0ix )
@@ -472,7 +471,8 @@ enum power_state power_handle_state(enum power_state state)
472
471
/* Power up to next state */
473
472
k_msleep (10 );
474
473
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 ) {
476
476
477
477
if (system_in_s0ix ) {
478
478
resume_ms_flag = 0 ;
@@ -488,6 +488,11 @@ enum power_state power_handle_state(enum power_state state)
488
488
}
489
489
490
490
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 );
491
496
k_msleep (55 );
492
497
/* Power down to next state */
493
498
return POWER_S3S5 ;
@@ -517,8 +522,11 @@ enum power_state power_handle_state(enum power_state state)
517
522
if (power_wait_signals (IN_VR_PGOOD )) {
518
523
/* something wrong, turn off power and force to g3 */
519
524
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 ;
522
530
}
523
531
524
532
k_msleep (10 );
@@ -538,7 +546,8 @@ enum power_state power_handle_state(enum power_state state)
538
546
539
547
case POWER_S0 :
540
548
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 ) {
542
551
/* Power down to next state */
543
552
k_msleep (5 );
544
553
return POWER_S0S3 ;
@@ -552,7 +561,8 @@ enum power_state power_handle_state(enum power_state state)
552
561
553
562
#ifdef CONFIG_PLATFORM_EC_POWERSEQ_S0IX
554
563
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 ) {
556
566
/*
557
567
* If power signal lose, we need to resume to S0 and
558
568
* clear the all s0ix flags
@@ -706,6 +716,9 @@ static void usb30_hub_reset(void)
706
716
set_gpu_gpio (GPIO_FUNC_SSD1_POWER , 1 );
707
717
set_gpu_gpio (GPIO_FUNC_SSD2_POWER , 1 );
708
718
usleep (200 * MSEC );
719
+ /* do not reset the hub when the system shutdown */
720
+ if (!chipset_in_state (CHIPSET_STATE_ON ))
721
+ return ;
709
722
gpio_pin_set_dt (GPIO_DT_FROM_NODELABEL (gpio_usb30_hub_en ), 0 );
710
723
usleep (10 * MSEC );
711
724
gpio_pin_set_dt (GPIO_DT_FROM_NODELABEL (gpio_usb30_hub_en ), 1 );
0 commit comments