diff options
author | Patryk Duda <pdk@semihalf.com> | 2021-05-12 16:29:07 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-05-21 21:42:55 +0000 |
commit | 671b6719f39da00d642258e6bbd75c3ba44b9261 (patch) | |
tree | 1ddf770c3435462f14d95ad9f2b3601738229cee | |
parent | d819e2ded5b0006eb03218cbc99e6b658ddbcd0d (diff) | |
download | chrome-ec-671b6719f39da00d642258e6bbd75c3ba44b9261.tar.gz |
nucleo-f412zg: Check if AP is on when processing HOOK_INIT hooks
Call ap_deferred() function directly (not as deferred function) from
board_init(). This change causes CS pin interrupt to be enabled
while running board_init() init hook, just after SPI initialization.
It removes 43ms window when SPI is initialized but we are not able
to communicate because interrupt on CS line is not enabled. This
change only affects RW firmware.
After main(), only hook task is marked as ready, so we are switching to
it and start executing HOOK_INIT hooks (spi_init() and board_init() are
called). SPI initialization is performed, but CS interrupt is still not
enabled (spi_init() checks if chipset is on). The interrupt is enabled
on HOOK_CHIPSET_RESUME. For RW side HOOK_CHIPSET_RESUME is emitted when
SLP_L and SLP_ALT_L are set to 1 (see ap_deferred()). ap_deferred() is
a deferred function so it is called from hook task context. It is
scheduled always in board_init() or in slp_event() when SLP_L and
SLP_ALT_L changes.
When hook task finishes executing all HOOK_INIT hooks it enables other
tasks with task_enable_all_tasks(). Now task with higher priority is
scheduled (CONSOLE, HOSTCMD, FPSENSOR tasks have higher priority than
HOOK task). When all higher priority tasks are waiting for events hook
task is scheduled and we can finally run ap_deferred() function which
should enable interrupt on CS pin (if AP is running).
BUG=b:185467818
BRANCH=none
TEST=make -j buildall
TEST=Flash nucleo-f412zg board and check if it is fully functional
Signed-off-by: Patryk Duda <pdk@semihalf.com>
Change-Id: Ia71c30a1e738411f566a7f29354c04a337cdce6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2905655
Reviewed-by: Craig Hesling <hesling@chromium.org>
-rw-r--r-- | board/nucleo-f412zg/board.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/board/nucleo-f412zg/board.c b/board/nucleo-f412zg/board.c index e06408c404..4324101da9 100644 --- a/board/nucleo-f412zg/board.c +++ b/board/nucleo-f412zg/board.c @@ -58,7 +58,12 @@ static void board_init(void) /* Enable interrupt on PCH power signals */ gpio_enable_interrupt(GPIO_PCH_SLP_S3_L); gpio_enable_interrupt(GPIO_PCH_SLP_S0_L); - /* enable the SPI slave interface if the PCH is up */ - hook_call_deferred(&ap_deferred_data, 0); + + /* + * Enable the SPI slave interface if the PCH is up. + * Do not use hook_call_deferred(), because ap_deferred() will be + * called after tasks with priority higher than HOOK task (very late). + */ + ap_deferred(); } DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); |