Skip to content

Commit 0e45a6a

Browse files
soc: silabs: siwx91x: removed old nwp soc files and link nwp driver
The goal of this patch is to switch from the nwp.c and nwp.h soc files to the new nwp driver. During this transition, we also renamed CONFIG_WISECONNECT_NETWORK_STACK to CONFIG_SILABS_SIWX91X_NWP which are a better naming to let the user knows that the network coprocessor files will be added to the compilation. The switch from a soc file to a driver device introduce a notion of nwp device that allows us to check for good initialization and ressources allocation. Before this patch, it is not possible to know if the nwp have booted successfully or not. We can now check if the device driver is ready or not before trying to do operation related to the nwp. Signed-off-by: Martin Hoff <[email protected]>
1 parent 1fe6c77 commit 0e45a6a

File tree

18 files changed

+46
-577
lines changed

18 files changed

+46
-577
lines changed

drivers/bluetooth/hci/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ config BT_SILABS_SIWX91X
184184
bool "Silabs SiWx91x Bluetooth interface"
185185
default y
186186
depends on DT_HAS_SILABS_SIWX91X_BT_HCI_ENABLED
187-
select WISECONNECT_NETWORK_STACK
187+
select SILABS_SIWX91X_NWP
188188
select ENTROPY_GENERATOR
189189
help
190190
Use Silicon Labs Wiseconnect 3.x Bluetooth library to connect to the controller.

drivers/flash/Kconfig.siwx91x

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ config SOC_FLASH_SILABS_SIWX91X
99
select FLASH_HAS_EXPLICIT_ERASE
1010
select FLASH_HAS_PAGE_LAYOUT
1111
# Flash controller is handled by the network coprocessor
12-
select WISECONNECT_NETWORK_STACK
12+
select SILABS_SIWX91X_NWP
1313
help
1414
Enable flash controller for flash embedded on Silicon Labs SiWx91x
1515
chips.

drivers/wifi/siwx91x/Kconfig.siwx91x

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ config WIFI_SILABS_SIWX91X
66
default y
77
depends on DT_HAS_SILABS_SIWX91X_WIFI_ENABLED
88
depends on NETWORKING
9-
select WISECONNECT_NETWORK_STACK
9+
select SILABS_SIWX91X_NWP
1010
select EVENTS
1111
select NET_L2_WIFI_MGMT
1212
help

drivers/wifi/siwx91x/siwx91x_wifi.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#include <zephyr/version.h>
99

10-
#include <nwp.h>
10+
#include <siwx91x_nwp.h>
1111
#include "siwx91x_wifi.h"
1212
#include "siwx91x_wifi_ap.h"
1313
#include "siwx91x_wifi_ps.h"
@@ -207,7 +207,7 @@ static int siwx91x_mode(const struct device *dev, struct wifi_mode_info *mode)
207207
mode->mode = cur_mode;
208208
} else if (mode->oper == WIFI_MGMT_SET) {
209209
if (cur_mode != mode->mode) {
210-
ret = siwx91x_nwp_mode_switch(mode->mode, false, 0);
210+
ret = siwx91x_nwp_mode_switch(siwx91x_cfg->nwp_dev, mode->mode, false, 0);
211211
if (ret < 0) {
212212
return ret;
213213
}
@@ -394,6 +394,7 @@ static int map_sdk_region_to_zephyr_channel_info(const sli_si91x_set_region_ap_r
394394

395395
static int siwx91x_wifi_reg_domain(const struct device *dev, struct wifi_reg_domain *reg_domain)
396396
{
397+
const struct siwx91x_config *siwx91x_cfg = dev->config;
397398
const sli_si91x_set_region_ap_request_t *sdk_reg = NULL;
398399
sl_wifi_operation_mode_t oper_mode = sli_get_opermode();
399400
sl_wifi_region_code_t region_code;
@@ -411,13 +412,13 @@ static int siwx91x_wifi_reg_domain(const struct device *dev, struct wifi_reg_dom
411412
}
412413

413414
if (region_code == SL_WIFI_DEFAULT_REGION) {
414-
siwx91x_store_country_code(DEFAULT_COUNTRY_CODE);
415+
siwx91x_store_country_code(siwx91x_cfg->nwp_dev, DEFAULT_COUNTRY_CODE);
415416
LOG_INF("Country code not supported, using default region");
416417
} else {
417-
siwx91x_store_country_code(reg_domain->country_code);
418+
siwx91x_store_country_code(siwx91x_cfg->nwp_dev, reg_domain->country_code);
418419
}
419420
} else if (reg_domain->oper == WIFI_MGMT_GET) {
420-
country_code = siwx91x_get_country_code();
421+
country_code = siwx91x_get_country_code(siwx91x_cfg->nwp_dev);
421422
memcpy(reg_domain->country_code, country_code, WIFI_COUNTRY_CODE_LEN);
422423
region_code = siwx91x_map_country_code_to_region(country_code);
423424

@@ -532,6 +533,13 @@ int siwx91x_set_rts_threshold(const struct device *dev, unsigned int rts_thresho
532533

533534
static int siwx91x_dev_init(const struct device *dev)
534535
{
536+
const struct siwx91x_config *siwx91x_cfg = dev->config;
537+
538+
if(!device_is_ready(siwx91x_cfg->nwp_dev)) {
539+
LOG_ERR("NWP device not ready");
540+
return -ENODEV;
541+
}
542+
535543
return 0;
536544
}
537545

@@ -568,6 +576,7 @@ static const struct net_wifi_mgmt_offload siwx91x_api = {
568576
};
569577

570578
static const struct siwx91x_config siwx91x_cfg = {
579+
.nwp_dev = DEVICE_DT_GET(DT_INST_PARENT(0)),
571580
.scan_tx_power = DT_INST_PROP(0, wifi_max_tx_pwr_scan),
572581
.join_tx_power = DT_INST_PROP(0, wifi_max_tx_pwr_join),
573582
};

drivers/wifi/siwx91x/siwx91x_wifi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "sl_si91x_types.h"
1111

1212
struct siwx91x_config {
13+
const struct device *nwp_dev;
1314
uint8_t scan_tx_power;
1415
uint8_t join_tx_power;
1516
};

drivers/wifi/siwx91x/siwx91x_wifi_ap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2024-2025 Silicon Laboratories Inc.
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
#include <nwp.h>
6+
#include <siwx91x_nwp.h>
77
#include "siwx91x_wifi.h"
88

99
#include "sl_rsi_utility.h"
@@ -13,11 +13,13 @@ LOG_MODULE_DECLARE(siwx91x_wifi);
1313

1414
static int siwx91x_nwp_reboot_if_required(const struct device *dev, uint8_t oper_mode)
1515
{
16+
const struct siwx91x_config *siwx91x_cfg = dev->config;
1617
struct siwx91x_dev *sidev = dev->data;
1718
int ret;
1819

1920
if (sidev->reboot_needed) {
20-
ret = siwx91x_nwp_mode_switch(oper_mode, sidev->hidden_ssid, sidev->max_num_sta);
21+
ret = siwx91x_nwp_mode_switch(siwx91x_cfg->nwp_dev, oper_mode, sidev->hidden_ssid,
22+
sidev->max_num_sta);
2123
if (ret < 0) {
2224
LOG_ERR("Failed to reboot the device: %d", ret);
2325
return ret;

drivers/wifi/siwx91x/siwx91x_wifi_ps.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66
#include <zephyr/sys/util.h>
7-
#include <nwp.h>
7+
#include <siwx91x_nwp.h>
88
#include "siwx91x_wifi.h"
99
#include "siwx91x_wifi_ps.h"
1010

drivers/wifi/siwx91x/siwx91x_wifi_scan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
#include <zephyr/logging/log.h>
77

8-
#include <nwp.h>
8+
#include <siwx91x_nwp.h>
99
#include "siwx91x_wifi.h"
1010
#include "siwx91x_wifi_scan.h"
1111

drivers/wifi/siwx91x/siwx91x_wifi_sta.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
#include <zephyr/logging/log.h>
77

8-
#include <nwp.h>
8+
#include <siwx91x_nwp.h>
99
#include "siwx91x_wifi.h"
1010
#include "siwx91x_wifi_socket.h"
1111
#include "siwx91x_wifi_ps.h"

dts/arm/silabs/siwg917.dtsi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@
7676
nwp: nwp {
7777
compatible = "silabs,siwx91x-nwp";
7878
power-profile = "high-performance";
79+
stack-size = <10240>;
80+
interrupt-parent = <&nvic>;
81+
interrupts = <30 0>, <74 0>;
82+
interrupt-names = "nwp_stack", "nwp_irq";
83+
status = "okay";
7984

8085
bt_hci0: bt_hci {
8186
compatible = "silabs,siwx91x-bt-hci";

0 commit comments

Comments
 (0)