summaryrefslogtreecommitdiff
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-18 08:08:03 +0000
commit4f3384749a9707d36115ab5b7ced11f793ce73c4 (patch)
tree8c140c3513cf1fee790229cf5ad33bbb55b2ce11
parentfc70295830a2fb0938858ddd06fe455eb3172484 (diff)
downloadchrome-ec-4f3384749a9707d36115ab5b7ced11f793ce73c4.tar.gz
bloonchipper: Check if AP is on when processing HOOK_INIT hooks
Call ap_deferred() function directly (not as deferred function) from board_init_rw(). 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. FPMCU log without this change: [Reset cause: reset-pin soft sysjump] [1.322620 Inits done] [1.322665 hook_task: running HOOK_INIT] [1.322713 hook notify 0] [1.322754 spi_init: init] [1.322794 spi_init: SPI initialized] [1.322846 board_init: init] [1.322901 FP_SPI_SEL: DEVELOPMENT] [1.322954 TRANSPORT_SEL: SPI] [1.323009 hook_task: enabling all other tasks] Console is enabled; type HELP for help. > [1.323106 event set 0x0000000000002000] [1.323176 hostcmd init 0x0000000000002000] [1.323238 FP_SENSOR_SEL: FPC] FPC libfpsensor.a v0.2.0.064 [1.365068 hook call deferred 0x8100365] [1.365132 ap_deferred: SLP_L is 1] [1.365180 ap_deferred: SLP_ALT_L is 1] [1.365232 hook notify 6] [1.365271 spi_chipset_startup: enabling interrupt] 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_rw() 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). FPMCU log with this change, interrupt is enabled 300us after SPI is initialized: [Reset cause: reset-pin soft sysjump] [1.322458 Inits done] [1.322503 hook_task: running HOOK_INIT] [1.322551 hook notify 0] [1.322592 spi_init: init] [1.322632 spi_init: SPI initialized] [1.322684 board_init: init] [1.322740 FP_SPI_SEL: DEVELOPMENT] [1.322793 TRANSPORT_SEL: SPI] [1.322837 ap_deferred: SLP_L is 1] [1.322885 ap_deferred: SLP_ALT_L is 1] [1.322936 hook notify 6] [1.322975 spi_chipset_startup: enabling interrupt] [1.323113 hook_task: enabling all other tasks] BUG=b:185467818 BRANCH=none TEST=make -j buildall Signed-off-by: Patryk Duda <pdk@semihalf.com> Change-Id: I91f868c01458ac5b7d02c4e5d2a7ae51060ffc50 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2900222 Reviewed-by: Craig Hesling <hesling@chromium.org>
-rw-r--r--board/hatch_fp/board_rw.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/board/hatch_fp/board_rw.c b/board/hatch_fp/board_rw.c
index 74794647cf..bfea56508c 100644
--- a/board/hatch_fp/board_rw.c
+++ b/board/hatch_fp/board_rw.c
@@ -101,6 +101,10 @@ void board_init_rw(void)
gpio_enable_interrupt(GPIO_SLP_ALT_L);
gpio_enable_interrupt(GPIO_SLP_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();
}