Skip to content

Commit 0d5c246

Browse files
lifenggitaccChromeos LUCI
authored andcommitted
zephyr: ap_pwrseq: add more power event notifications
Flag CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK is used to enable AP power sequencing resume init and suspend complete callbacks. These are usually used to initialize/disable the SPI driver, which goes to sleep on suspend. Require to initialize it first such that it can receive a host resume event, that notifies the normal resume callback. Add following power event notifications: AP_POWER_RESUME_INIT AP_POWER_SUSPEND_COMPLETE AP_POWER_HARD_OFF BUG=b:201000950 BRANCH=none TEST=zmake configure -b nivviks --clobber On AP, "shutdown -h now", enter G3 On EC, "apshutdown", enter G3 Signed-off-by: Li Feng <li1.feng@intel.com> Change-Id: I9413735de1c50fcea6ee1e7fc97de91e125bbafc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3537389 Reviewed-by: Andrew McRae <amcrae@google.com>
1 parent 1bb6bb5 commit 0d5c246

1 file changed

Lines changed: 24 additions & 8 deletions

File tree

zephyr/subsys/ap_pwrseq/x86_non_dsx_common_pwrseq_sm_handler.c

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void rsmrst_pass_thru_handler(void)
163163

164164
/* TODO:
165165
* Add power down sequence
166-
* Add logic to suspend and resume the thread
166+
* Add S0ix
167167
*/
168168
static int common_pwr_sm_run(int state)
169169
{
@@ -223,7 +223,8 @@ static int common_pwr_sm_run(int state)
223223

224224
case SYS_POWER_STATE_S5G3:
225225
ap_power_force_shutdown(AP_POWER_SHUTDOWN_G3);
226-
ap_power_ev_send_callbacks(AP_POWER_SHUTDOWN_COMPLETE);
226+
/* Notify power event before we enter G3 */
227+
ap_power_ev_send_callbacks(AP_POWER_HARD_OFF);
227228
return SYS_POWER_STATE_G3;
228229

229230
case SYS_POWER_STATE_S5S4:
@@ -250,7 +251,7 @@ static int common_pwr_sm_run(int state)
250251
return SYS_POWER_STATE_G3;
251252
}
252253

253-
/* Call hooks now that rails are up */
254+
/* Notify power event that rails are up */
254255
ap_power_ev_send_callbacks(AP_POWER_STARTUP);
255256

256257
/* TODO: S0ix
@@ -281,6 +282,11 @@ static int common_pwr_sm_run(int state)
281282

282283
/* All the power rails must be stable */
283284
if (power_signal_get(PWR_ALL_SYS_PWRGD)) {
285+
#if defined(CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK)
286+
/* Notify power event before resume */
287+
ap_power_ev_send_callbacks(AP_POWER_RESUME_INIT);
288+
#endif
289+
/* Notify power event rails are up */
284290
ap_power_ev_send_callbacks(AP_POWER_RESUME);
285291
return SYS_POWER_STATE_S0;
286292
}
@@ -297,11 +303,17 @@ static int common_pwr_sm_run(int state)
297303
break;
298304

299305
case SYS_POWER_STATE_S4S5:
300-
/* Call hooks before we remove power rails */
306+
/* Notify power event before we remove power rails */
301307
ap_power_ev_send_callbacks(AP_POWER_SHUTDOWN);
302-
/* Disable wireless */
303-
/* wireless_set_state(WIRELESS_OFF); */
304-
/* Call hooks after we remove power rails */
308+
309+
/*
310+
* If support controlling power of wifi/WWAN/BT devices
311+
* add handling here.
312+
*/
313+
314+
/* Nofity power event after we remove power rails */
315+
ap_power_ev_send_callbacks(AP_POWER_SHUTDOWN_COMPLETE);
316+
305317
/* Always enter into S5 state. The S5 state is required to
306318
* correctly handle global resets which have a bit of delay
307319
* while the SLP_Sx_L signals are asserted then deasserted.
@@ -312,8 +324,12 @@ static int common_pwr_sm_run(int state)
312324
return SYS_POWER_STATE_S4;
313325

314326
case SYS_POWER_STATE_S0S3:
315-
/* Call hooks before we remove power rails */
327+
/* Notify power event before we remove power rails */
316328
ap_power_ev_send_callbacks(AP_POWER_SUSPEND);
329+
#if defined(CONFIG_PLATFORM_EC_CHIPSET_RESUME_INIT_HOOK)
330+
/* Notify power event after suspend */
331+
ap_power_ev_send_callbacks(AP_POWER_SUSPEND_COMPLETE);
332+
#endif
317333
return SYS_POWER_STATE_S3;
318334

319335
default:

0 commit comments

Comments
 (0)