diff options
author | Wai-Hong Tam <waihong@google.com> | 2020-07-23 16:34:35 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-07-30 04:32:32 +0000 |
commit | c7a2cb72c6de063c83cc2b5385f1e67571267569 (patch) | |
tree | 45760db3175a93b561cf8cb275649cad30f86c62 | |
parent | b40786b4b8f543e8e33537582ca0b5b71f57b1f1 (diff) | |
download | chrome-ec-c7a2cb72c6de063c83cc2b5385f1e67571267569.tar.gz |
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
-rw-r--r-- | common/hooks.c | 5 | ||||
-rw-r--r-- | core/cortex-m/ec.lds.S | 10 | ||||
-rw-r--r-- | core/cortex-m0/ec.lds.S | 10 | ||||
-rw-r--r-- | core/minute-ia/ec.lds.S | 10 | ||||
-rw-r--r-- | core/nds32/ec.lds.S | 10 | ||||
-rw-r--r-- | core/riscv-rv32i/ec.lds.S | 10 | ||||
-rw-r--r-- | include/config.h | 8 | ||||
-rw-r--r-- | include/hooks.h | 18 | ||||
-rw-r--r-- | include/link_defs.h | 6 |
9 files changed, 87 insertions, 0 deletions
diff --git a/common/hooks.c b/common/hooks.c index 8c8e8b09fe..4c2a4e48c6 100644 --- a/common/hooks.c +++ b/common/hooks.c @@ -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}, diff --git a/core/cortex-m/ec.lds.S b/core/cortex-m/ec.lds.S index 1e620dc54d..4b6bd04a48 100644 --- a/core/cortex-m/ec.lds.S +++ b/core/cortex-m/ec.lds.S @@ -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 = .; diff --git a/core/cortex-m0/ec.lds.S b/core/cortex-m0/ec.lds.S index 8a3a75b272..ca2984bd0f 100644 --- a/core/cortex-m0/ec.lds.S +++ b/core/cortex-m0/ec.lds.S @@ -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 = .; diff --git a/core/minute-ia/ec.lds.S b/core/minute-ia/ec.lds.S index 37d2d8da49..5b814abe42 100644 --- a/core/minute-ia/ec.lds.S +++ b/core/minute-ia/ec.lds.S @@ -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 = .; diff --git a/core/nds32/ec.lds.S b/core/nds32/ec.lds.S index 75c687655a..2ffb58d932 100644 --- a/core/nds32/ec.lds.S +++ b/core/nds32/ec.lds.S @@ -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 = .; diff --git a/core/riscv-rv32i/ec.lds.S b/core/riscv-rv32i/ec.lds.S index 2741521f39..20ac8e0ab8 100644 --- a/core/riscv-rv32i/ec.lds.S +++ b/core/riscv-rv32i/ec.lds.S @@ -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 = .; diff --git a/include/config.h b/include/config.h index 0c9596c08a..bafa80fc78 100644 --- a/include/config.h +++ b/include/config.h @@ -1130,6 +1130,14 @@ #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 * resources into PP3300_A resources. diff --git a/include/hooks.h b/include/hooks.h index bc157bacbd..52bca8b94d 100644 --- a/include/hooks.h +++ b/include/hooks.h @@ -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. * diff --git a/include/link_defs.h b/include/link_defs.h index 4465843b50..5b04b857bb 100644 --- a/include/link_defs.h +++ b/include/link_defs.h @@ -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[]; |