summaryrefslogtreecommitdiff
path: root/board/nucleo-h743zi/board.c
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:43:03 +0000
commit6cd536203a98ea7efd526ed98d56052db577429e (patch)
treedac331b4283c7150a02a52127a3c1a83ae7ee8b3 /board/nucleo-h743zi/board.c
parent671b6719f39da00d642258e6bbd75c3ba44b9261 (diff)
downloadchrome-ec-6cd536203a98ea7efd526ed98d56052db577429e.tar.gz
nucleo-h743zi: 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-h743zi board and check if it is fully functional Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I9a3b80688b67e8babaf51e38859f6f43b19201f8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2905656 Reviewed-by: Craig Hesling <hesling@chromium.org>
Diffstat (limited to 'board/nucleo-h743zi/board.c')
-rw-r--r--board/nucleo-h743zi/board.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/board/nucleo-h743zi/board.c b/board/nucleo-h743zi/board.c
index c4c7e764c8..f1493658aa 100644
--- a/board/nucleo-h743zi/board.c
+++ b/board/nucleo-h743zi/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);