-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
drivers: bluetooth and wifi: siwx917: Introducing NWP init
WiFi and Bluetooth HCI driver was changed to use the nwp_init component. This component initializes the NWP based on the project configuration (BLE and/or WiFi). Later on the component can be modified to support common flash mode read/write/erase without BLE and WiFi. Coprocessor stack moved to a more suitable place (nwp_init). WiFi and Bluetooth advertising sample apps were tried to verify the change. Signed-off-by: Tibor Laczko <[email protected]>
- Loading branch information
1 parent
d9b2565
commit 2ebcb5e
Showing
8 changed files
with
162 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
* Copyright (c) 2024 Silicon Laboratories Inc. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
|
||
#include "sl_wifi.h" | ||
#include "sl_wifi_callback_framework.h" | ||
#if CONFIG_BT_SIWX917 | ||
#include "rsi_ble_common_config.h" | ||
#endif | ||
|
||
/* TODO SILABS ZEPHYR: Check how to add constants to the vector table */ | ||
#define NWP_ADD_TO_VECTOR_TABLE(irq, flags, expression, arg, name) \ | ||
static Z_DECL_ALIGN(struct _isr_list) Z_GENERIC_SECTION(.intList) \ | ||
__used __isr_##name = {irq, flags, expression, arg} | ||
|
||
/* TODO SILABS ZEPHYR: Make these configs accessible via Kconfig */ | ||
#define NWP_INIT_EXT_TCP_IP_FEATURE_BIT_MAP_WIFI \ | ||
(SL_SI91X_EXT_TCP_IP_WINDOW_SCALING | SL_SI91X_EXT_TCP_IP_TOTAL_SELECTS(10) | \ | ||
SL_SI91X_CONFIG_FEAT_EXTENSION_VALID) | ||
|
||
#ifdef SLI_SI91X_ENABLE_IPV6 | ||
#define NWP_INIT_TCP_IP_FEATURE_BIT_MAP_WIFI_IPV6 \ | ||
(SL_SI91X_TCP_IP_FEAT_DHCPV6_CLIENT | SL_SI91X_TCP_IP_FEAT_IPV6) | ||
#else | ||
#define NWP_INIT_TCP_IP_FEATURE_BIT_MAP_WIFI_IPV6 0 | ||
#endif | ||
#define NWP_INIT_TCP_IP_FEATURE_BIT_MAP_WIFI \ | ||
(SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT | NWP_INIT_TCP_IP_FEATURE_BIT_MAP_WIFI_IPV6 | \ | ||
SL_SI91X_TCP_IP_FEAT_DNS_CLIENT | SL_SI91X_TCP_IP_FEAT_SSL | SL_SI91X_TCP_IP_FEAT_MDNSD | \ | ||
SL_SI91X_TCP_IP_FEAT_ICMP | SL_SI91X_TCP_IP_FEAT_EXTENSION_VALID) | ||
#define NWP_INIT_TCP_IP_FEATURE_BIT_MAP_BLE \ | ||
(SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT | SL_SI91X_TCP_IP_FEAT_EXTENSION_VALID) | ||
|
||
#define NWP_INIT_BT_FEATURE_BIT_MAP_BLE (SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL) | ||
|
||
#define NWP_INIT_BLE_FEATURE_BIT_MAP_BLE \ | ||
(SL_SI91X_BLE_MAX_NBR_PERIPHERALS(RSI_BLE_MAX_NBR_PERIPHERALS) | \ | ||
SL_SI91X_BLE_MAX_NBR_CENTRALS(RSI_BLE_MAX_NBR_CENTRALS) | \ | ||
SL_SI91X_BLE_MAX_NBR_ATT_SERV(RSI_BLE_MAX_NBR_ATT_SERV) | \ | ||
SL_SI91X_BLE_MAX_NBR_ATT_REC(RSI_BLE_MAX_NBR_ATT_REC) | \ | ||
SL_SI91X_BLE_PWR_INX(RSI_BLE_PWR_INX) | \ | ||
SL_SI91X_BLE_PWR_SAVE_OPTIONS(RSI_BLE_PWR_SAVE_OPTIONS) | \ | ||
SL_SI91X_916_BLE_COMPATIBLE_FEAT_ENABLE | SL_SI91X_FEAT_BLE_CUSTOM_FEAT_EXTENSION_VALID) | ||
|
||
#define NWP_INIT_BLE_EXT_FEATURE_BIT_MAP_BLE \ | ||
(SL_SI91X_BLE_NUM_CONN_EVENTS(RSI_BLE_NUM_CONN_EVENTS) | \ | ||
SL_SI91X_BLE_NUM_REC_BYTES(RSI_BLE_NUM_REC_BYTES) | SL_SI91X_BLE_ENABLE_ADV_EXTN | \ | ||
SL_SI91X_BLE_AE_MAX_ADV_SETS(RSI_BLE_AE_MAX_ADV_SETS)) | ||
|
||
#define NWP_INIT_EXT_CUSTOM_FEATURE_BIT_MAP_COMMON \ | ||
(MEMORY_CONFIG | SL_SI91X_EXT_FEAT_XTAL_CLK | \ | ||
SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0) | ||
|
||
#if CONFIG_WIFI_SIWX917 && CONFIG_BT_SIWX917 | ||
#define NWP_INIT_COEX_MODE SL_SI91X_WLAN_BLE_MODE | ||
#define NWP_INIT_TCP_IP_FEATURE_BIT_MAP \ | ||
(NWP_INIT_TCP_IP_FEATURE_BIT_MAP_WIFI | NWP_INIT_TCP_IP_FEATURE_BIT_MAP_BLE) | ||
#define NWP_INIT_EXT_CUSTOM_FEATURE_BIT_MAP \ | ||
(NWP_INIT_EXT_CUSTOM_FEATURE_BIT_MAP_COMMON | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE) | ||
#define NWP_INIT_BT_FEATURE_BIT_MAP NWP_INIT_BT_FEATURE_BIT_MAP_BLE | ||
#define NWP_INIT_EXT_TCP_IP_FEATURE_BIT_MAP NWP_INIT_EXT_TCP_IP_FEATURE_BIT_MAP_WIFI | ||
#define NWP_INIT_BLE_FEATURE_BIT_MAP NWP_INIT_BLE_FEATURE_BIT_MAP_BLE | ||
#define NWP_INIT_BLE_EXT_FEATURE_BIT_MAP NWP_INIT_BLE_EXT_FEATURE_BIT_MAP_BLE | ||
|
||
#elif CONFIG_WIFI_SIWX917 | ||
#define NWP_INIT_COEX_MODE SL_SI91X_WLAN_ONLY_MODE | ||
#define NWP_INIT_TCP_IP_FEATURE_BIT_MAP NWP_INIT_TCP_IP_FEATURE_BIT_MAP_WIFI | ||
#define NWP_INIT_EXT_CUSTOM_FEATURE_BIT_MAP NWP_INIT_EXT_CUSTOM_FEATURE_BIT_MAP_COMMON | ||
#define NWP_INIT_BT_FEATURE_BIT_MAP 0 | ||
#define NWP_INIT_EXT_TCP_IP_FEATURE_BIT_MAP NWP_INIT_EXT_TCP_IP_FEATURE_BIT_MAP_WIFI | ||
#define NWP_INIT_BLE_FEATURE_BIT_MAP 0 | ||
#define NWP_INIT_BLE_EXT_FEATURE_BIT_MAP 0 | ||
|
||
#elif CONFIG_BT_SIWX917 | ||
#define NWP_INIT_COEX_MODE SL_SI91X_BLE_MODE | ||
#define NWP_INIT_TCP_IP_FEATURE_BIT_MAP NWP_INIT_TCP_IP_FEATURE_BIT_MAP_BLE | ||
#define NWP_INIT_EXT_CUSTOM_FEATURE_BIT_MAP \ | ||
(NWP_INIT_EXT_CUSTOM_FEATURE_BIT_MAP_COMMON | SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE) | ||
#define NWP_INIT_BT_FEATURE_BIT_MAP NWP_INIT_BT_FEATURE_BIT_MAP_BLE | ||
#define NWP_INIT_EXT_TCP_IP_FEATURE_BIT_MAP SL_SI91X_CONFIG_FEAT_EXTENSION_VALID | ||
#define NWP_INIT_BLE_FEATURE_BIT_MAP NWP_INIT_BLE_FEATURE_BIT_MAP_BLE | ||
#define NWP_INIT_BLE_EXT_FEATURE_BIT_MAP NWP_INIT_BLE_EXT_FEATURE_BIT_MAP_BLE | ||
|
||
#else | ||
#error "No configuration selected" | ||
#endif | ||
|
||
static const sl_wifi_device_configuration_t network_config = { | ||
.boot_option = LOAD_NWP_FW, | ||
.mac_address = NULL, | ||
.band = SL_SI91X_WIFI_BAND_2_4GHZ, | ||
.region_code = DEFAULT_REGION, | ||
.boot_config = { | ||
.oper_mode = SL_SI91X_CLIENT_MODE, | ||
.coex_mode = NWP_INIT_COEX_MODE, | ||
.feature_bit_map = SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_WPS_DISABLE, | ||
.tcp_ip_feature_bit_map = NWP_INIT_TCP_IP_FEATURE_BIT_MAP, | ||
.ext_tcp_ip_feature_bit_map = NWP_INIT_EXT_TCP_IP_FEATURE_BIT_MAP, | ||
.custom_feature_bit_map = SL_SI91X_CUSTOM_FEAT_EXTENSION_VALID, | ||
.ext_custom_feature_bit_map = NWP_INIT_EXT_CUSTOM_FEATURE_BIT_MAP, | ||
.bt_feature_bit_map = NWP_INIT_BT_FEATURE_BIT_MAP, | ||
.ble_feature_bit_map = NWP_INIT_BLE_FEATURE_BIT_MAP, | ||
.ble_ext_feature_bit_map = NWP_INIT_BLE_EXT_FEATURE_BIT_MAP, | ||
.config_feature_bit_map = SL_SI91X_ENABLE_ENHANCED_MAX_PSP, | ||
}}; | ||
|
||
static int silabs_siwx917_nwp_init(void) | ||
{ | ||
return sl_wifi_init(&network_config, NULL, sl_wifi_default_event_handler); | ||
} | ||
SYS_INIT(silabs_siwx917_nwp_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE); | ||
|
||
/* IRQn 74 is used for communication with co-processor */ | ||
Z_ISR_DECLARE(74, ISR_FLAG_DIRECT, IRQ074_Handler, 0); | ||
|
||
/* TODO SILABS ZEPHYR: CONFIG macro for the NWP stack size */ | ||
static uint8_t __aligned(8) nwp_stack[10 * 1024]; | ||
NWP_ADD_TO_VECTOR_TABLE(30, ISR_FLAG_DIRECT, &nwp_stack[sizeof(nwp_stack) - 1], 0, nwp_stack); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters