diff options
author | Patryk Duda <pdk@semihalf.com> | 2021-05-12 16:29:07 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-05-17 18:31:29 +0000 |
commit | 49c22349759369c6736169386d3d5e66e1e7400d (patch) | |
tree | 8b10f1ca41f70351179fd19b0c840f69acd99c67 | |
parent | 24d6a3c2770ccd9c333e76ce4e932803ff092d31 (diff) | |
download | chrome-ec-49c22349759369c6736169386d3d5e66e1e7400d.tar.gz |
dartmonkey: 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: I51a30b1cec35d19d6cdf3241a310e7427c750f88
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2891863
Reviewed-by: Craig Hesling <hesling@chromium.org>
-rw-r--r-- | board/nocturne_fp/board_rw.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/board/nocturne_fp/board_rw.c b/board/nocturne_fp/board_rw.c index 30e38b4887..f9ca66cc5d 100644 --- a/board/nocturne_fp/board_rw.c +++ b/board/nocturne_fp/board_rw.c @@ -102,6 +102,10 @@ void board_init_rw(void) /* Enable interrupt on PCH power signals */ 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(); } |