summaryrefslogtreecommitdiff
path: root/board/nucleo-dartmonkey
diff options
context:
space:
mode:
authorPatryk Duda <pdk@semihalf.com>2021-05-12 16:29:07 +0000
committerCommit Bot <commit-bot@chromium.org>2021-05-21 21:42:54 +0000
commitd819e2ded5b0006eb03218cbc99e6b658ddbcd0d (patch)
treefa5ad6f7f676f0f32896e201b1fad2634f101a54 /board/nucleo-dartmonkey
parent6ef3bf4f7f24a16c77acda900277b403ed97db04 (diff)
downloadchrome-ec-d819e2ded5b0006eb03218cbc99e6b658ddbcd0d.tar.gz
nucleo-dartmonkey: 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-dartmonkey board and check if it behaves correctly Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I93413c002aa98e8ebdb96aca2764b8ee1551d5f7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2905654 Reviewed-by: Craig Hesling <hesling@chromium.org>
Diffstat (limited to 'board/nucleo-dartmonkey')
-rw-r--r--board/nucleo-dartmonkey/board.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/board/nucleo-dartmonkey/board.c b/board/nucleo-dartmonkey/board.c
index a201f69ec5..ee84c262a7 100644
--- a/board/nucleo-dartmonkey/board.c
+++ b/board/nucleo-dartmonkey/board.c
@@ -89,7 +89,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);