diff --git a/modules/hal_silabs/wiseconnect/CMakeLists.txt b/modules/hal_silabs/wiseconnect/CMakeLists.txt index 3243f980af4..14f03bb2283 100644 --- a/modules/hal_silabs/wiseconnect/CMakeLists.txt +++ b/modules/hal_silabs/wiseconnect/CMakeLists.txt @@ -62,5 +62,44 @@ zephyr_library_sources_ifdef(CONFIG_DMA_SILABS_SIWX91X ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/rom_driver/src/rsi_rom_table_si91x.c ) +if(CONFIG_WISECONNECT_NETWORK_STACK) + zephyr_compile_definitions( + SLI_SI91X_ENABLE_OS + SL_SI91X_SI917_RAM_MEM_CONFIG=1 + SL_WIFI_COMPONENT_INCLUDED # Depite de the name, required for everything + ) + zephyr_include_directories( + # FIXME: find why this directory is not included when CMSIS_RTOS_V2=y + ${ZEPHYR_BASE}/include/zephyr/portability + ${SISDK_DIR}/platform/emlib/inc + ${WISECONNECT_DIR}/resources/defaults + ${WISECONNECT_DIR}/components/common/inc + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/inc + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/sl_net/inc + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/socket/inc + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/asynchronous_socket/inc + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ahb_interface/inc + ${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/core/chip/config + ${WISECONNECT_DIR}/components/protocol/wifi/inc + ${WISECONNECT_DIR}/components/service/network_manager/inc + ) + zephyr_library_sources( + ${WISECONNECT_DIR}/components/common/src/sl_utility.c + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ahb_interface/src/rsi_hal_mcu_m4_ram.c + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ahb_interface/src/rsi_hal_mcu_m4_rom.c + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ahb_interface/src/sli_siwx917_soc.c + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ahb_interface/src/sl_platform.c + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ahb_interface/src/sl_platform_wireless.c + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ahb_interface/src/sl_si91x_bus.c + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/host_mcu/si91x/siwx917_soc_ncp_host.c + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/memory/malloc_buffers.c + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/src/sl_rsi_utility.c + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/src/sl_si91x_driver.c + ${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/threading/sli_si91x_multithreaded.c + ${WISECONNECT_DIR}/components/protocol/wifi/si91x/sl_wifi.c + ${WISECONNECT_DIR}/components/protocol/wifi/src/sl_wifi_callback_framework.c + ) +endif() # CONFIG_WISECONNECT_NETWORK_STACK + zephyr_linker_sources(ROM_SECTIONS linker/code_classification_text.ld) zephyr_linker_sources(RAMFUNC_SECTION linker/code_classification_ramfunc.ld) diff --git a/soc/silabs/silabs_siwx91x/siwg917/CMakeLists.txt b/soc/silabs/silabs_siwx91x/siwg917/CMakeLists.txt index 1fbd96d1ada..33985be7796 100644 --- a/soc/silabs/silabs_siwx91x/siwg917/CMakeLists.txt +++ b/soc/silabs/silabs_siwx91x/siwg917/CMakeLists.txt @@ -2,5 +2,6 @@ # SPDX-License-Identifier: Apache-2.0 zephyr_sources_ifdef(CONFIG_SOC_SERIES_SIWG917 soc.c) +zephyr_sources_ifdef(CONFIG_WISECONNECT_NETWORK_STACK nwp_init.c) set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld CACHE INTERNAL "") diff --git a/soc/silabs/silabs_siwx91x/siwg917/nwp_init.c b/soc/silabs/silabs_siwx91x/siwg917/nwp_init.c new file mode 100644 index 00000000000..055c9e1a181 --- /dev/null +++ b/soc/silabs/silabs_siwx91x/siwg917/nwp_init.c @@ -0,0 +1,60 @@ +/** + * @file + * @brief Network Processor Initialization for SiWx91x. + * + * This file contains the initialization routine for the (ThreadArch) network processor + * on the SiWx91x platform. The component is responsible for setting up the necessary + * hardware and software components to enable network communication. + * + * Copyright (c) 2024 Silicon Laboratories Inc. + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#include "sl_wifi.h" +#include "sl_wifi_callback_framework.h" + +static int siwg917_nwp_init(void) +{ + sl_wifi_device_configuration_t network_config = { + .boot_option = LOAD_NWP_FW, + .band = SL_SI91X_WIFI_BAND_2_4GHZ, + .region_code = DEFAULT_REGION, + .boot_config = { + .oper_mode = SL_SI91X_CLIENT_MODE, + .tcp_ip_feature_bit_map = SL_SI91X_TCP_IP_FEAT_EXTENSION_VALID, + .ext_tcp_ip_feature_bit_map = SL_SI91X_CONFIG_FEAT_EXTENSION_VALID, + .config_feature_bit_map = SL_SI91X_ENABLE_ENHANCED_MAX_PSP, + .custom_feature_bit_map = SL_SI91X_CUSTOM_FEAT_EXTENSION_VALID, + /* Even if neither WiFi or BLE is used we have to specify a Coex mode */ + .coex_mode = SL_SI91X_BLE_MODE, + .ext_custom_feature_bit_map = + MEMORY_CONFIG | + SL_SI91X_EXT_FEAT_XTAL_CLK | + SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0, + } + }; + + /* TODO: If sl_net_*_profile() functions will be needed for WiFi then call + * sl_net_set_profile() here. Currently these are unused. + */ + return sl_wifi_init(&network_config, NULL, sl_wifi_default_event_handler); +} +SYS_INIT(siwg917_nwp_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE); + +/* IRQn 74 is used for communication with co-processor */ +Z_ISR_DECLARE(74, 0, IRQ074_Handler, 0); + +/* Co-processor will use value stored in IVT to store its stack. + * + * FIXME: We can't use Z_ISR_DECLARE() to declare this entry + * FIXME: Allow to configure size of buffer + */ +static uint8_t __aligned(8) siwg917_nwp_stack[10 * 1024]; +static Z_DECL_ALIGN(struct _isr_list) Z_GENERIC_SECTION(.intList) + __used __isr_siwg917_coprocessor_stack_irq = { + .irq = 30, + .flags = ISR_FLAG_DIRECT, + .func = &siwg917_nwp_stack[sizeof(siwg917_nwp_stack) - 1], + };