2727
2828#define IN_VR_PGOOD POWER_SIGNAL_MASK(X86_VR_PG)
2929
30- static int power_ready ;
3130static int power_s5_up ; /* Chipset is sequencing up or down */
3231static int ap_boot_delay = 9 ; /* For global reset to wait SLP_S5 signal de-asserts */
3332static 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-
149123void 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)
213187DECLARE_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-
226190void 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
251216void 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