Skip to content

Commit 1ec734f

Browse files
silabs-TiborLjerome-pouiller
authored andcommitted
drivers: bluetooth and wifi: siwx917: Introducing NWP init
WiFi and Bluetooth HCI driver was changed to use the nwp_init component. The NWP stands for Network Processor which refers to the ThreadArch® Network Processor. 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. Also hal_silabs revision update was done. Signed-off-by: Tibor Laczko <[email protected]>
1 parent 0fad170 commit 1ec734f

File tree

9 files changed

+138
-129
lines changed

9 files changed

+138
-129
lines changed

drivers/bluetooth/hci/Kconfig.siwx917

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,7 @@
44
config BT_SIWX917
55
bool "Silabs SiWx917 Bluetooth interface"
66
default y
7-
depends on DT_HAS_SILABS_SIWX917_BT_HCI_ENABLED
8-
select CMSIS_RTOS_V2
9-
select POLL
10-
select DYNAMIC_THREAD
11-
select THREAD_NAME
12-
select THREAD_STACK_INFO
13-
select THREAD_MONITOR
14-
select INIT_STACKS
7+
depends on DT_HAS_SILABS_BT_HCI_SIWX917_ENABLED
8+
select WISECONNECT_NETWORK_STACK
159
help
1610
Use Silicon Labs Wiseconnect 3.x Bluetooth library to connect to the controller.
17-
18-
if BT_SIWX917
19-
20-
# WiseConnect create threads with realtime priority. Default (10kHz) clock tick
21-
# prevent proper use of the system with these threads.
22-
config SYS_CLOCK_TICKS_PER_SEC
23-
default 1024
24-
25-
config NUM_PREEMPT_PRIORITIES
26-
default 56
27-
28-
config CMSIS_V2_THREAD_DYNAMIC_MAX_COUNT
29-
default 2
30-
31-
config CMSIS_V2_THREAD_DYNAMIC_STACK_SIZE
32-
default 1024
33-
34-
config CMSIS_V2_THREAD_MAX_STACK_SIZE
35-
default 2048
36-
37-
endif #BT_SIWX917

drivers/bluetooth/hci/siwx917_hci.c renamed to drivers/bluetooth/hci/hci_silabs_siwx917.c

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@
1111
#include <zephyr/logging/log.h>
1212
LOG_MODULE_REGISTER(bt_hci_driver_siwg917);
1313

14-
#include "sl_wifi.h"
15-
#include "sl_wifi_callback_framework.h"
16-
#include "rsi_ble_common_config.h"
1714
#include "rsi_ble.h"
1815

1916
static void bt_siwg917_resp_rcvd(uint16_t status, rsi_ble_event_rcp_rcvd_info_t *resp_buf);
@@ -23,54 +20,11 @@ struct hci_data {
2320
rsi_data_packet_t rsi_data_packet;
2421
};
2522

26-
static const sl_wifi_device_configuration_t network_config = {
27-
.boot_option = LOAD_NWP_FW,
28-
.mac_address = NULL,
29-
.band = SL_SI91X_WIFI_BAND_2_4GHZ,
30-
.region_code = DEFAULT_REGION,
31-
.boot_config = {
32-
.oper_mode = SL_SI91X_CLIENT_MODE,
33-
.coex_mode = SL_SI91X_BLE_MODE,
34-
.feature_bit_map =
35-
SL_SI91X_FEAT_SECURITY_OPEN |
36-
SL_SI91X_FEAT_WPS_DISABLE,
37-
.tcp_ip_feature_bit_map =
38-
SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT |
39-
SL_SI91X_TCP_IP_FEAT_EXTENSION_VALID,
40-
.ext_tcp_ip_feature_bit_map = SL_SI91X_CONFIG_FEAT_EXTENSION_VALID,
41-
.custom_feature_bit_map = SL_SI91X_CUSTOM_FEAT_EXTENSION_VALID,
42-
.ext_custom_feature_bit_map =
43-
MEMORY_CONFIG |
44-
SL_SI91X_EXT_FEAT_XTAL_CLK |
45-
SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0 |
46-
SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE,
47-
.config_feature_bit_map = SL_SI91X_ENABLE_ENHANCED_MAX_PSP,
48-
.bt_feature_bit_map =
49-
SL_SI91X_BT_RF_TYPE |
50-
SL_SI91X_ENABLE_BLE_PROTOCOL,
51-
.ble_feature_bit_map =
52-
SL_SI91X_BLE_MAX_NBR_PERIPHERALS(RSI_BLE_MAX_NBR_PERIPHERALS) |
53-
SL_SI91X_BLE_MAX_NBR_CENTRALS(RSI_BLE_MAX_NBR_CENTRALS) |
54-
SL_SI91X_BLE_MAX_NBR_ATT_SERV(RSI_BLE_MAX_NBR_ATT_SERV) |
55-
SL_SI91X_BLE_MAX_NBR_ATT_REC(RSI_BLE_MAX_NBR_ATT_REC) |
56-
SL_SI91X_BLE_PWR_INX(RSI_BLE_PWR_INX) |
57-
SL_SI91X_BLE_PWR_SAVE_OPTIONS(RSI_BLE_PWR_SAVE_OPTIONS) |
58-
SL_SI91X_916_BLE_COMPATIBLE_FEAT_ENABLE |
59-
SL_SI91X_FEAT_BLE_CUSTOM_FEAT_EXTENSION_VALID,
60-
.ble_ext_feature_bit_map =
61-
SL_SI91X_BLE_NUM_CONN_EVENTS(RSI_BLE_NUM_CONN_EVENTS) |
62-
SL_SI91X_BLE_NUM_REC_BYTES(RSI_BLE_NUM_REC_BYTES) |
63-
SL_SI91X_BLE_ENABLE_ADV_EXTN |
64-
SL_SI91X_BLE_AE_MAX_ADV_SETS(RSI_BLE_AE_MAX_ADV_SETS),
65-
}};
66-
6723
static int bt_siwg917_open(const struct device *dev, bt_hci_recv_t recv)
6824
{
6925
struct hci_data *hci = dev->data;
70-
71-
int status = sl_wifi_init(&network_config, NULL, sl_wifi_default_event_handler);
72-
status |= rsi_ble_enhanced_gap_extended_register_callbacks(RSI_BLE_ON_RCP_EVENT,
73-
(void *)bt_siwg917_resp_rcvd);
26+
int status = rsi_ble_enhanced_gap_extended_register_callbacks(RSI_BLE_ON_RCP_EVENT,
27+
(void *)bt_siwg917_resp_rcvd);
7428

7529
if (!status) {
7630
hci->recv = recv;
@@ -162,6 +116,3 @@ static const struct bt_hci_driver_api drv = {
162116

163117
/* Only one instance supported right now */
164118
HCI_DEVICE_INIT(0)
165-
166-
/* IRQn 74 is used for communication with co-processor */
167-
Z_ISR_DECLARE(74, ISR_FLAG_DIRECT, IRQ074_Handler, 0);

drivers/wifi/siwx917/Kconfig.siwx917

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,15 @@ config WIFI_SIWX917
55
bool "Silabs SiWx917 SoC series WiFi driver"
66
default y
77
depends on DT_HAS_SILABS_SIWX917_WIFI_ENABLED
8+
select WISECONNECT_NETWORK_STACK
89
select EVENTS
910
select WIFI_OFFLOAD
1011
select NET_L2_WIFI_MGMT
11-
select CMSIS_RTOS_V2
12-
# Also select CMSIS-RTOS v2 dependencies
13-
select POLL
14-
select DYNAMIC_THREAD
15-
select THREAD_NAME
16-
select THREAD_STACK_INFO
17-
select THREAD_MONITOR
18-
select INIT_STACKS
1912
help
2013
Enable WiFi driver for the Silabs SiWx917 SoC series.
2114

2215
if WIFI_SIWX917
2316

24-
# WiseConnect create threads with realtime priority. Default (10kHz) clock tick
25-
# prevent proper use of the system with these threads.
26-
config SYS_CLOCK_TICKS_PER_SEC
27-
default 1024
28-
29-
config NUM_PREEMPT_PRIORITIES
30-
default 56
31-
32-
config CMSIS_V2_THREAD_DYNAMIC_MAX_COUNT
33-
default 2
34-
35-
config CMSIS_V2_THREAD_DYNAMIC_STACK_SIZE
36-
default 1024
37-
38-
config CMSIS_V2_THREAD_MAX_STACK_SIZE
39-
default 2048
40-
4117
config NET_TCP_WORKQ_STACK_SIZE
4218
default 2048
4319

drivers/wifi/siwx917/siwx917_wifi.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,6 @@ static void siwx917_iface_init(struct net_if *iface)
622622
{
623623
struct siwx917_dev *sidev = iface->if_dev->dev->data;
624624
sl_mac_address_t mac_addr;
625-
sl_status_t status;
626625

627626
iface->if_dev->offload = &siwx917_offload;
628627
sidev->state = WIFI_STATE_INTERFACE_DISABLED;
@@ -633,12 +632,6 @@ static void siwx917_iface_init(struct net_if *iface)
633632
sl_wifi_set_join_callback(siwx917_on_join, sidev);
634633
sl_wifi_get_mac_address(SL_WIFI_CLIENT_INTERFACE, &mac_addr);
635634
net_if_set_link_addr(iface, mac_addr.octet, sizeof(mac_addr.octet), NET_LINK_ETHERNET);
636-
637-
status = sl_net_init(SL_NET_WIFI_CLIENT_INTERFACE, NULL, NULL, NULL);
638-
if (status) {
639-
LOG_ERR("sl_net_init(): %#04x", status);
640-
return;
641-
}
642635
sidev->state = WIFI_STATE_INACTIVE;
643636
}
644637

@@ -668,6 +661,3 @@ static const struct net_wifi_mgmt_offload siwx917_api = {
668661
static struct siwx917_dev siwx917_dev;
669662
NET_DEVICE_DT_INST_OFFLOAD_DEFINE(0, siwx917_dev_init, NULL, &siwx917_dev, NULL,
670663
CONFIG_WIFI_INIT_PRIORITY, &siwx917_api, NET_ETH_MTU);
671-
672-
/* IRQn 74 is used for communication with co-processor */
673-
Z_ISR_DECLARE(74, ISR_FLAG_DIRECT, IRQ074_Handler, 0);

soc/silabs/silabs_siwx917/siwg917/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
zephyr_include_directories(.)
55

66
zephyr_sources_ifdef(CONFIG_SOC_SERIES_SIWG917 soc.c)
7+
zephyr_sources_ifdef(CONFIG_WISECONNECT_NETWORK_STACK nwp_init.c)
78

89
set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld CACHE INTERNAL "")

soc/silabs/silabs_siwx917/siwg917/Kconfig

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,34 @@ config SIWX917_FLASH_MODE_DUAL
1515
bool "Dual Flash"
1616

1717
endchoice
18+
19+
config WISECONNECT_NETWORK_STACK
20+
bool
21+
select CMSIS_RTOS_V2
22+
select POLL
23+
select DYNAMIC_THREAD
24+
select THREAD_NAME
25+
select THREAD_STACK_INFO
26+
select THREAD_MONITOR
27+
select INIT_STACKS
28+
29+
if WISECONNECT_NETWORK_STACK
30+
31+
# WiseConnect create threads with realtime priority. Default (10kHz) clock tick
32+
# prevent proper use of the system with these threads.
33+
config SYS_CLOCK_TICKS_PER_SEC
34+
default 1024
35+
36+
config NUM_PREEMPT_PRIORITIES
37+
default 56
38+
39+
config CMSIS_V2_THREAD_DYNAMIC_MAX_COUNT
40+
default 2
41+
42+
config CMSIS_V2_THREAD_DYNAMIC_STACK_SIZE
43+
default 1024
44+
45+
config CMSIS_V2_THREAD_MAX_STACK_SIZE
46+
default 2048
47+
48+
endif #WISECONNECT_NETWORK_STACK
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/**
2+
* @file
3+
* @brief Network Processor Initialization for SiWx917.
4+
*
5+
* This file contains the initialization routine for the (ThreadArch) network processor
6+
* on the SiWx917 platform. The component is responsible for setting up the necessary
7+
* hardware and software components to enable network communication.
8+
*
9+
* Copyright (c) 2024 Silicon Laboratories Inc.
10+
* SPDX-License-Identifier: Apache-2.0
11+
*/
12+
13+
#include <zephyr/kernel.h>
14+
15+
#include "sl_wifi.h"
16+
#include "sl_wifi_callback_framework.h"
17+
#ifdef CONFIG_BT_SIWX917
18+
#include "rsi_ble_common_config.h"
19+
#endif
20+
21+
#if defined(CONFIG_WIFI_SIWX917) && defined(CONFIG_BT_SIWX917)
22+
#define NWP_INIT_COEX_MODE SL_SI91X_WLAN_BLE_MODE
23+
#elif defined(CONFIG_WIFI_SIWX917)
24+
#define NWP_INIT_COEX_MODE SL_SI91X_WLAN_ONLY_MODE
25+
#elif defined(CONFIG_BT_SIWX917)
26+
#define NWP_INIT_COEX_MODE SL_SI91X_BLE_MODE
27+
#else
28+
#error "Not supported configuration!"
29+
#endif
30+
31+
static int silabs_siwx917_nwp_init(void)
32+
{
33+
sl_wifi_device_configuration_t network_config = {
34+
.boot_option = LOAD_NWP_FW,
35+
.band = SL_SI91X_WIFI_BAND_2_4GHZ,
36+
.region_code = DEFAULT_REGION,
37+
.boot_config = {
38+
.oper_mode = SL_SI91X_CLIENT_MODE,
39+
.coex_mode = NWP_INIT_COEX_MODE,
40+
.feature_bit_map = SL_SI91X_FEAT_SECURITY_OPEN | SL_SI91X_FEAT_WPS_DISABLE,
41+
.tcp_ip_feature_bit_map = SL_SI91X_TCP_IP_FEAT_EXTENSION_VALID,
42+
.ext_tcp_ip_feature_bit_map = SL_SI91X_CONFIG_FEAT_EXTENSION_VALID,
43+
.config_feature_bit_map = SL_SI91X_ENABLE_ENHANCED_MAX_PSP,
44+
.custom_feature_bit_map = SL_SI91X_CUSTOM_FEAT_EXTENSION_VALID,
45+
.ext_custom_feature_bit_map =
46+
MEMORY_CONFIG | SL_SI91X_EXT_FEAT_XTAL_CLK |
47+
SL_SI91X_EXT_FEAT_FRONT_END_SWITCH_PINS_ULP_GPIO_4_5_0,
48+
}};
49+
sl_si91x_boot_configuration_t *cfg = &network_config.boot_config;
50+
51+
#ifdef CONFIG_WIFI_SIWX917
52+
cfg->tcp_ip_feature_bit_map |=
53+
#ifdef CONFIG_NET_IPV6
54+
SL_SI91X_TCP_IP_FEAT_DHCPV6_CLIENT | SL_SI91X_TCP_IP_FEAT_IPV6 |
55+
#endif
56+
SL_SI91X_TCP_IP_FEAT_DHCPV4_CLIENT | SL_SI91X_TCP_IP_FEAT_DNS_CLIENT |
57+
SL_SI91X_TCP_IP_FEAT_SSL | SL_SI91X_TCP_IP_FEAT_MDNSD | SL_SI91X_TCP_IP_FEAT_ICMP;
58+
cfg->ext_tcp_ip_feature_bit_map |=
59+
SL_SI91X_EXT_TCP_IP_WINDOW_SCALING | SL_SI91X_EXT_TCP_IP_TOTAL_SELECTS(10);
60+
#endif
61+
62+
#ifdef CONFIG_BT_SIWX917
63+
cfg->ext_custom_feature_bit_map |= SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE;
64+
cfg->bt_feature_bit_map |= SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL;
65+
cfg->ble_feature_bit_map |= SL_SI91X_BLE_MAX_NBR_PERIPHERALS(RSI_BLE_MAX_NBR_PERIPHERALS) |
66+
SL_SI91X_BLE_MAX_NBR_CENTRALS(RSI_BLE_MAX_NBR_CENTRALS) |
67+
SL_SI91X_BLE_MAX_NBR_ATT_SERV(RSI_BLE_MAX_NBR_ATT_SERV) |
68+
SL_SI91X_BLE_MAX_NBR_ATT_REC(RSI_BLE_MAX_NBR_ATT_REC) |
69+
SL_SI91X_BLE_PWR_INX(RSI_BLE_PWR_INX) |
70+
SL_SI91X_BLE_PWR_SAVE_OPTIONS(RSI_BLE_PWR_SAVE_OPTIONS) |
71+
SL_SI91X_916_BLE_COMPATIBLE_FEAT_ENABLE |
72+
SL_SI91X_FEAT_BLE_CUSTOM_FEAT_EXTENSION_VALID;
73+
cfg->ble_ext_feature_bit_map |= SL_SI91X_BLE_NUM_CONN_EVENTS(RSI_BLE_NUM_CONN_EVENTS) |
74+
SL_SI91X_BLE_NUM_REC_BYTES(RSI_BLE_NUM_REC_BYTES) |
75+
SL_SI91X_BLE_ENABLE_ADV_EXTN |
76+
SL_SI91X_BLE_AE_MAX_ADV_SETS(RSI_BLE_AE_MAX_ADV_SETS);
77+
#endif
78+
79+
/* TODO: If sl_net_*_profile() functions will be needed for WiFi then call
80+
* sl_net_set_profile() here. Currently these are unused.
81+
*/
82+
return sl_wifi_init(&network_config, NULL, sl_wifi_default_event_handler);
83+
}
84+
SYS_INIT(silabs_siwx917_nwp_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
85+
86+
/* IRQn 74 is used for communication with co-processor */
87+
Z_ISR_DECLARE(74, ISR_FLAG_DIRECT, IRQ074_Handler, 0);
88+
89+
/* Co-processor will use value stored in IVT to store its stack.
90+
*
91+
* FIXME: We can't use Z_ISR_DECLARE() to declare this entry
92+
* FIXME: Allow to configure size of buffer
93+
*/
94+
static uint8_t __aligned(8) nwp_stack[10 * 1024];
95+
static Z_DECL_ALIGN(struct _isr_list) Z_GENERIC_SECTION(.intList)
96+
__used __isr_siwx917_coprocessor_stack_irq = {
97+
.irq = 30,
98+
.flags = ISR_FLAG_DIRECT,
99+
.func = &nwp_stack[sizeof(nwp_stack) - 1],
100+
};

soc/silabs/silabs_siwx917/siwg917/soc.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,6 @@ int silabs_siwx917_init(void)
5353
}
5454
SYS_INIT(silabs_siwx917_init, PRE_KERNEL_1, 0);
5555

56-
/* Co-processor will use value stored in IVT to store its stack.
57-
*
58-
* FIXME: We can't use Z_ISR_DECLARE() to declare this entry
59-
* FIXME: Allow to configure size of buffer
60-
*/
61-
uint8_t __aligned(4) siwx917_coprocessor_stack[10 * 1024];
62-
static Z_DECL_ALIGN(struct _isr_list) Z_GENERIC_SECTION(.intList)
63-
__used __isr_siwx917_coprocessor_stack_irq = {
64-
.irq = 30,
65-
.flags = ISR_FLAG_DIRECT,
66-
.func = siwx917_coprocessor_stack + sizeof(siwx917_coprocessor_stack),
67-
};
68-
6956
/* SiWx917's bootloader requires IRQn 32 to hold payload's entry point address. */
7057
extern void z_arm_reset(void);
7158
Z_ISR_DECLARE(32, ISR_FLAG_DIRECT, z_arm_reset, 0);

west.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ manifest:
1111
projects:
1212
- name: hal_silabs
1313
remote: silabs
14-
revision: pull/6/head
14+
revision: 1e8a139aaf84c7687761f5aeef6efed73db91e1b
1515
path: modules/hal/silabs
1616
- name: zephyr
1717
remote: zephyrproject-rtos

0 commit comments

Comments
 (0)