hooks: Introduce HOOK_CHIPSET_SHUTDOWN_COMPLETE

A new hook HOOK_CHIPSET_SHUTDOWN_COMPLETE is introduced, which are
called from the chipset task, while the system has already shut down
and all the suspend rails are already off.

It will be used for executing pending EC reboot at the chipset shutdown.
The EC reboot should be executed when the chipset is completely off.

BRANCH=None
BUG=b:156981868
TEST=Built all boards.

Change-Id: I12f26957e46a1bb34ef079f127b0bddd133cd4e7
Signed-off-by: Wai-Hong Tam <waihong@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2228395
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
This commit is contained in:
Wai-Hong Tam 2020-06-02 19:54:18 -07:00 committed by Commit Bot
parent e4bfe793ce
commit 8565d05751
22 changed files with 71 additions and 0 deletions

View File

@ -71,5 +71,6 @@ test_mockable void chipset_task(void)
power_off_req = 0;
chipset_state = CHIPSET_STATE_SOFT_OFF;
hook_notify(HOOK_CHIPSET_SHUTDOWN);
hook_notify(HOOK_CHIPSET_SHUTDOWN_COMPLETE);
}
}

View File

@ -462,6 +462,9 @@ enum power_state power_handle_state(enum power_state state)
gpio_set_level(GPIO_TOUCHSCREEN_RESET_L, 0);
gpio_set_level(GPIO_LIGHTBAR_RESET_L, 0);
/* Call hooks after we remove power rails */
hook_notify(HOOK_CHIPSET_SHUTDOWN_COMPLETE);
return power_get_pause_in_s5() ? POWER_S5 : POWER_S5G3;
case POWER_S5G3:

View File

@ -135,6 +135,7 @@ static void chipset_s3_to_s5(void)
{
ps = POWER_S5;
hook_notify(HOOK_CHIPSET_SHUTDOWN);
hook_notify(HOOK_CHIPSET_SHUTDOWN_COMPLETE);
}
static void chipset_s0_to_s3(void)
@ -234,6 +235,7 @@ static void board_init(void)
} else {
enable_sleep(SLEEP_MASK_AP_RUN);
hook_notify(HOOK_CHIPSET_SHUTDOWN);
hook_notify(HOOK_CHIPSET_SHUTDOWN_COMPLETE);
ps = POWER_S5;
}

View File

@ -41,6 +41,8 @@ static const struct hook_ptrs hook_list[] = {
{__hooks_chipset_resume, __hooks_chipset_resume_end},
{__hooks_chipset_suspend, __hooks_chipset_suspend_end},
{__hooks_chipset_shutdown, __hooks_chipset_shutdown_end},
{__hooks_chipset_shutdown_complete,
__hooks_chipset_shutdown_complete_end},
{__hooks_chipset_reset, __hooks_chipset_reset_end},
{__hooks_ac_change, __hooks_ac_change_end},
{__hooks_lid_change, __hooks_lid_change_end},

View File

@ -192,6 +192,10 @@ SECTIONS
KEEP(*(.rodata.HOOK_CHIPSET_SHUTDOWN))
__hooks_chipset_shutdown_end = .;
__hooks_chipset_shutdown_complete = .;
KEEP(*(.rodata.HOOK_CHIPSET_SHUTDOWN_COMPLETE))
__hooks_chipset_shutdown_complete_end = .;
__hooks_chipset_reset = .;
KEEP(*(.rodata.HOOK_CHIPSET_RESET))
__hooks_chipset_reset_end = .;

View File

@ -121,6 +121,10 @@ SECTIONS
KEEP(*(.rodata.HOOK_CHIPSET_SHUTDOWN))
__hooks_chipset_shutdown_end = .;
__hooks_chipset_shutdown_complete = .;
KEEP(*(.rodata.HOOK_CHIPSET_SHUTDOWN_COMPLETE))
__hooks_chipset_shutdown_complete_end = .;
__hooks_chipset_reset = .;
KEEP(*(.rodata.HOOK_CHIPSET_RESET))
__hooks_chipset_reset_end = .;

View File

@ -61,6 +61,10 @@ SECTIONS {
*(.rodata.HOOK_CHIPSET_SHUTDOWN)
__hooks_chipset_shutdown_end = .;
__hooks_chipset_shutdown_complete = .;
*(.rodata.HOOK_CHIPSET_SHUTDOWN_COMPLETE)
__hooks_chipset_shutdown_complete_end = .;
__hooks_chipset_reset = .;
*(.rodata.HOOK_CHIPSET_RESET)
__hooks_chipset_reset_end = .;

View File

@ -88,6 +88,10 @@ SECTIONS
KEEP(*(.rodata.HOOK_CHIPSET_SHUTDOWN))
__hooks_chipset_shutdown_end = .;
__hooks_chipset_shutdown_complete = .;
KEEP(*(.rodata.HOOK_CHIPSET_SHUTDOWN_COMPLETE))
__hooks_chipset_shutdown_complete_end = .;
__hooks_chipset_reset = .;
KEEP(*(.rodata.HOOK_CHIPSET_RESET))
__hooks_chipset_reset_end = .;

View File

@ -117,6 +117,10 @@ SECTIONS
KEEP(*(.rodata.HOOK_CHIPSET_SHUTDOWN))
__hooks_chipset_shutdown_end = .;
__hooks_chipset_shutdown_complete = .;
KEEP(*(.rodata.HOOK_CHIPSET_SHUTDOWN_COMPLETE))
__hooks_chipset_shutdown_complete_end = .;
__hooks_chipset_reset = .;
KEEP(*(.rodata.HOOK_CHIPSET_RESET))
__hooks_chipset_reset_end = .;

View File

@ -156,6 +156,10 @@ SECTIONS
KEEP(*(.rodata.HOOK_CHIPSET_SHUTDOWN))
__hooks_chipset_shutdown_end = .;
__hooks_chipset_shutdown_complete = .;
KEEP(*(.rodata.HOOK_CHIPSET_SHUTDOWN_COMPLETE))
__hooks_chipset_shutdown_complete_end = .;
__hooks_chipset_reset = .;
KEEP(*(.rodata.HOOK_CHIPSET_RESET))
__hooks_chipset_reset_end = .;

View File

@ -126,6 +126,13 @@ enum hook_type {
*/
HOOK_CHIPSET_SHUTDOWN,
/*
* System has already shut down. All the suspend rails are already off.
*
* Hook routines are called from the chipset task.
*/
HOOK_CHIPSET_SHUTDOWN_COMPLETE,
/*
* System reset in S0. All rails are still up.
*

View File

@ -42,6 +42,8 @@ extern const struct hook_data __hooks_chipset_suspend[];
extern const struct hook_data __hooks_chipset_suspend_end[];
extern const struct hook_data __hooks_chipset_shutdown[];
extern const struct hook_data __hooks_chipset_shutdown_end[];
extern const struct hook_data __hooks_chipset_shutdown_complete[];
extern const struct hook_data __hooks_chipset_shutdown_complete_end[];
extern const struct hook_data __hooks_chipset_reset[];
extern const struct hook_data __hooks_chipset_reset_end[];
extern const struct hook_data __hooks_ac_change[];

View File

@ -269,6 +269,9 @@ enum power_state power_handle_state(enum power_state state)
/*wireless_set_state(WIRELESS_OFF);*/
/* Call hooks after we remove power rails */
hook_notify(HOOK_CHIPSET_SHUTDOWN_COMPLETE);
/* Start shutting down */
return power_get_pause_in_s5() ? POWER_S5 : POWER_S5G3;

View File

@ -559,6 +559,9 @@ enum power_state common_intel_x86_power_handle_state(enum power_state state)
/* Disable wireless */
wireless_set_state(WIRELESS_OFF);
/* Call hooks after we remove power rails */
hook_notify(HOOK_CHIPSET_SHUTDOWN_COMPLETE);
/* Always enter into S5 state. The S5 state is required to
* correctly handle global resets which have a bit of delay
* while the SLP_Sx_L signals are asserted then deasserted.

View File

@ -514,6 +514,9 @@ static void power_off(void)
powerled_set_state(POWERLED_STATE_OFF);
#endif
CPRINTS("power shutdown complete");
/* Call hooks after we drop power rails */
hook_notify(HOOK_CHIPSET_SHUTDOWN_COMPLETE);
}
/**

View File

@ -486,6 +486,9 @@ enum power_state power_handle_state(enum power_state state)
gpio_disable_interrupt(GPIO_AP_EC_WATCHDOG_L);
power_seq_run(s3s5_power_seq, ARRAY_SIZE(s3s5_power_seq));
/* Call hooks after we remove power rails */
hook_notify(HOOK_CHIPSET_SHUTDOWN_COMPLETE);
/* Start shutting down */
return POWER_S5;

View File

@ -409,6 +409,9 @@ enum power_state power_handle_state(enum power_state state)
GPIO_SET_LEVEL(GPIO_EN_PP1800_U, 0);
GPIO_SET_LEVEL(GPIO_EN_PP3300_U, 0);
/* Call hooks after we remove power rails */
hook_notify(HOOK_CHIPSET_SHUTDOWN_COMPLETE);
/* Start shutting down */
return POWER_S5;

View File

@ -380,6 +380,9 @@ static void power_off(void)
powerled_set_state(POWERLED_STATE_OFF);
CPRINTS("power shutdown complete");
/* Call hooks after we drop power rails */
hook_notify(HOOK_CHIPSET_SHUTDOWN_COMPLETE);
}
void chipset_reset(enum chipset_reset_reason reason)

View File

@ -521,6 +521,9 @@ enum power_state power_handle_state(enum power_state state)
power_seq_run(s3s5_power_seq, ARRAY_SIZE(s3s5_power_seq));
/* Call hooks after we remove power rails */
hook_notify(HOOK_CHIPSET_SHUTDOWN_COMPLETE);
/* Start shutting down */
return POWER_S5;

View File

@ -496,6 +496,9 @@ static void power_off(void)
lid_opened = 0;
enable_sleep(SLEEP_MASK_AP_RUN);
CPRINTS("power shutdown complete");
/* Call hooks after we drop power rails */
hook_notify(HOOK_CHIPSET_SHUTDOWN_COMPLETE);
}
/**

View File

@ -479,6 +479,9 @@ static void power_off(void)
lid_opened = 0;
enable_sleep(SLEEP_MASK_AP_RUN);
CPRINTS("power shutdown complete");
/* Call hooks after we drop power rails */
hook_notify(HOOK_CHIPSET_SHUTDOWN_COMPLETE);
}
/**

View File

@ -272,6 +272,9 @@ enum power_state power_handle_state(enum power_state state)
/* Disable wireless */
wireless_set_state(WIRELESS_OFF);
/* Call hooks after we remove power rails */
hook_notify(HOOK_CHIPSET_SHUTDOWN_COMPLETE);
return POWER_S5;
case POWER_S5G3: