From 6a7cbff9b27398581f5056c84dd80cb6d3187541 Mon Sep 17 00:00:00 2001 From: Aksel Skauge Mellbye Date: Mon, 12 May 2025 13:13:16 +0200 Subject: [PATCH] soc: silabs: siwx91x: Initialize NWP sufficiently early The NWP provides Bluetooth, Wi-Fi and crypto services, and must be initialized before any users of these. Mbed TLS is initialized at priority level 40 (kernel default priority), ensure that the NWP is initialized before that. Make the priority configurable to allow users to tweak the init sequence. Signed-off-by: Aksel Skauge Mellbye --- soc/silabs/silabs_siwx91x/Kconfig | 8 ++++++++ soc/silabs/silabs_siwx91x/siwg917/nwp.c | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/soc/silabs/silabs_siwx91x/Kconfig b/soc/silabs/silabs_siwx91x/Kconfig index 34ea8e2dfa4..458d55dc2c8 100644 --- a/soc/silabs/silabs_siwx91x/Kconfig +++ b/soc/silabs/silabs_siwx91x/Kconfig @@ -19,4 +19,12 @@ config SOC_SILABS_SLEEPTIMER help The Sleeptimer HAL module is used for SIWX91X. +config SIWX91X_NWP_INIT_PRIORITY + int "SiWx91x Network Processor init priority" + default 39 + help + Initialization priority of the SiWx91x Network Processor. NWP init must + have a higher priority than services that depend on it, such as Bluetooth, + Wi-Fi and crypto. + endif # SOC_FAMILY_SILABS_SIWX91X diff --git a/soc/silabs/silabs_siwx91x/siwg917/nwp.c b/soc/silabs/silabs_siwx91x/siwg917/nwp.c index 3882fcf07fb..71a20ac33c3 100644 --- a/soc/silabs/silabs_siwx91x/siwg917/nwp.c +++ b/soc/silabs/silabs_siwx91x/siwg917/nwp.c @@ -193,7 +193,11 @@ static int siwg917_nwp_init(void) return 0; } -SYS_INIT(siwg917_nwp_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE); +#if defined(CONFIG_MBEDTLS_INIT) +BUILD_ASSERT(CONFIG_SIWX91X_NWP_INIT_PRIORITY < CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, + "mbed TLS must be initialized after the NWP."); +#endif +SYS_INIT(siwg917_nwp_init, POST_KERNEL, CONFIG_SIWX91X_NWP_INIT_PRIORITY); /* IRQn 74 is used for communication with co-processor */ Z_ISR_DECLARE(74, 0, IRQ074_Handler, 0);