hooks: Introduce chipset resume init and suspend complete hooks

These hooks are only enabled through a new CONFIG.

The resume init hook will be used to initialize 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 hook.

The suspend complete hook is paired with the resume init hook,
which reverts the initialization of the SPI driver.

BRANCH=None
BUG=b:148149387
TEST=make buildall -j
TEST=Build successfully on both default off and defining this CONFIG.

Change-Id: I615e2bf92c75f83a7b0ab3eded61a1ef241dbdcf
Signed-off-by: Wai-Hong Tam <waihong@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2321875
This commit is contained in:
Wai-Hong Tam 2020-07-23 16:34:35 -07:00 committed by Commit Bot
parent b40786b4b8
commit c7a2cb72c6
9 changed files with 87 additions and 0 deletions

View File

@ -40,6 +40,11 @@ static const struct hook_ptrs hook_list[] = {
{__hooks_chipset_startup, __hooks_chipset_startup_end},
{__hooks_chipset_resume, __hooks_chipset_resume_end},
{__hooks_chipset_suspend, __hooks_chipset_suspend_end},
#ifdef CONFIG_CHIPSET_RESUME_INIT_HOOK
{__hooks_chipset_resume_init, __hooks_chipset_resume_init_end},
{__hooks_chipset_suspend_complete,
__hooks_chipset_suspend_complete_end},
#endif
{__hooks_chipset_shutdown, __hooks_chipset_shutdown_end},
{__hooks_chipset_shutdown_complete,
__hooks_chipset_shutdown_complete_end},

View File

@ -188,6 +188,16 @@ SECTIONS
KEEP(*(.rodata.HOOK_CHIPSET_SUSPEND))
__hooks_chipset_suspend_end = .;
#ifdef CONFIG_CHIPSET_RESUME_INIT_HOOK
__hooks_chipset_resume_init = .;
KEEP(*(.rodata.HOOK_CHIPSET_RESUME_INIT))
__hooks_chipset_resume_init_end = .;
__hooks_chipset_suspend_complete = .;
KEEP(*(.rodata.HOOK_CHIPSET_SUSPEND_COMPLETE))
__hooks_chipset_suspend_complete_end = .;
#endif
__hooks_chipset_shutdown = .;
KEEP(*(.rodata.HOOK_CHIPSET_SHUTDOWN))
__hooks_chipset_shutdown_end = .;

View File

@ -117,6 +117,16 @@ SECTIONS
KEEP(*(.rodata.HOOK_CHIPSET_SUSPEND))
__hooks_chipset_suspend_end = .;
#ifdef CONFIG_CHIPSET_RESUME_INIT_HOOK
__hooks_chipset_resume_init = .;
KEEP(*(.rodata.HOOK_CHIPSET_RESUME_INIT))
__hooks_chipset_resume_init_end = .;
__hooks_chipset_suspend_complete = .;
KEEP(*(.rodata.HOOK_CHIPSET_SUSPEND_COMPLETE))
__hooks_chipset_suspend_complete_end = .;
#endif
__hooks_chipset_shutdown = .;
KEEP(*(.rodata.HOOK_CHIPSET_SHUTDOWN))
__hooks_chipset_shutdown_end = .;

View File

@ -84,6 +84,16 @@ SECTIONS
KEEP(*(.rodata.HOOK_CHIPSET_SUSPEND))
__hooks_chipset_suspend_end = .;
#ifdef CONFIG_CHIPSET_RESUME_INIT_HOOK
__hooks_chipset_resume_init = .;
KEEP(*(.rodata.HOOK_CHIPSET_RESUME_INIT))
__hooks_chipset_resume_init_end = .;
__hooks_chipset_suspend_complete = .;
KEEP(*(.rodata.HOOK_CHIPSET_SUSPEND_COMPLETE))
__hooks_chipset_suspend_complete_end = .;
#endif
__hooks_chipset_shutdown = .;
KEEP(*(.rodata.HOOK_CHIPSET_SHUTDOWN))
__hooks_chipset_shutdown_end = .;

View File

@ -113,6 +113,16 @@ SECTIONS
KEEP(*(.rodata.HOOK_CHIPSET_SUSPEND))
__hooks_chipset_suspend_end = .;
#ifdef CONFIG_CHIPSET_RESUME_INIT_HOOK
__hooks_chipset_resume_init = .;
KEEP(*(.rodata.HOOK_CHIPSET_RESUME_INIT))
__hooks_chipset_resume_init_end = .;
__hooks_chipset_suspend_complete = .;
KEEP(*(.rodata.HOOK_CHIPSET_SUSPEND_COMPLETE))
__hooks_chipset_suspend_complete_end = .;
#endif
__hooks_chipset_shutdown = .;
KEEP(*(.rodata.HOOK_CHIPSET_SHUTDOWN))
__hooks_chipset_shutdown_end = .;

View File

@ -152,6 +152,16 @@ SECTIONS
KEEP(*(.rodata.HOOK_CHIPSET_SUSPEND))
__hooks_chipset_suspend_end = .;
#ifdef CONFIG_CHIPSET_RESUME_INIT_HOOK
__hooks_chipset_resume_init = .;
KEEP(*(.rodata.HOOK_CHIPSET_RESUME_INIT))
__hooks_chipset_resume_init_end = .;
__hooks_chipset_suspend_complete = .;
KEEP(*(.rodata.HOOK_CHIPSET_SUSPEND_COMPLETE))
__hooks_chipset_suspend_complete_end = .;
#endif
__hooks_chipset_shutdown = .;
KEEP(*(.rodata.HOOK_CHIPSET_SHUTDOWN))
__hooks_chipset_shutdown_end = .;

View File

@ -1129,6 +1129,14 @@
/* Enable chipset reset hook, requires a deferrable function */
#undef CONFIG_CHIPSET_RESET_HOOK
/*
* Enable chipset resume init and suspend complete hooks. These hooks 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 hook.
*/
#undef CONFIG_CHIPSET_RESUME_INIT_HOOK
/*
* Enable turning on PP3300_A rail before PP5000_A rail on the Ice Lake
* and Tiger Lake chipsets. Enable this option if there is leakage from PP5000_A

View File

@ -119,6 +119,24 @@ enum hook_type {
*/
HOOK_CHIPSET_SUSPEND,
#ifdef CONFIG_CHIPSET_RESUME_INIT_HOOK
/*
* Initialization before the system resumes, like enabling the SPI
* driver such that it can receive a host resume event.
*
* Hook routines are called from the chipset task.
*/
HOOK_CHIPSET_RESUME_INIT,
/*
* System has suspended. It is paired with CHIPSET_RESUME_INIT hook,
* like reverting the initialization of the SPI driver.
*
* Hook routines are called from the chipset task.
*/
HOOK_CHIPSET_SUSPEND_COMPLETE,
#endif
/*
* System is shutting down. All suspend rails are still on.
*

View File

@ -40,6 +40,12 @@ extern const struct hook_data __hooks_chipset_resume[];
extern const struct hook_data __hooks_chipset_resume_end[];
extern const struct hook_data __hooks_chipset_suspend[];
extern const struct hook_data __hooks_chipset_suspend_end[];
#ifdef CONFIG_CHIPSET_RESUME_INIT_HOOK
extern const struct hook_data __hooks_chipset_resume_init[];
extern const struct hook_data __hooks_chipset_resume_init_end[];
extern const struct hook_data __hooks_chipset_suspend_complete[];
extern const struct hook_data __hooks_chipset_suspend_complete_end[];
#endif
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[];