Skip to content

Commit a9dd0c9

Browse files
ArunmaniAlagarsamy2710cfriedt
authored andcommitted
drivers: wifi: siwx91x: Support max TX power configuration via Device Tree
Add support for configuring the maximum TX power for STA and AP modes using a Device Tree property (`max-tx-power`). If unspecified, the default value is set to 31 dBm. Signed-off-by: Arunmani Alagarsamy <[email protected]>
1 parent 814a9e6 commit a9dd0c9

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

drivers/wifi/siwx91x/siwx91x_wifi.c

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,21 @@ bool siwx91x_param_changed(struct wifi_iface_status *prev_params,
185185
return false;
186186
}
187187

188+
static int siwx91x_set_max_tx_power(const struct siwx91x_config *siwx91x_cfg)
189+
{
190+
sl_wifi_interface_t interface = sl_wifi_get_default_interface();
191+
sl_wifi_max_tx_power_t max_tx_power = {
192+
.scan_tx_power = siwx91x_cfg->scan_tx_power,
193+
.join_tx_power = siwx91x_cfg->join_tx_power,
194+
};
195+
196+
return sl_wifi_set_max_tx_power(interface, max_tx_power);
197+
}
198+
188199
static int siwx91x_mode(const struct device *dev, struct wifi_mode_info *mode)
189200
{
190201
sl_wifi_interface_t interface = sl_wifi_get_default_interface();
202+
const struct siwx91x_config *siwx91x_cfg = dev->config;
191203
struct siwx91x_dev *sidev = dev->data;
192204
int cur_mode;
193205
int ret = 0;
@@ -207,6 +219,12 @@ static int siwx91x_mode(const struct device *dev, struct wifi_mode_info *mode)
207219
if (ret < 0) {
208220
return ret;
209221
}
222+
223+
ret = siwx91x_set_max_tx_power(siwx91x_cfg);
224+
if (ret != SL_STATUS_OK) {
225+
LOG_ERR("Failed to set max tx power:%x", ret);
226+
return -EINVAL;
227+
}
210228
}
211229
sidev->state = WIFI_STATE_INACTIVE;
212230
}
@@ -353,6 +371,7 @@ static int siwx91x_get_version(const struct device *dev, struct wifi_version *pa
353371

354372
static void siwx91x_iface_init(struct net_if *iface)
355373
{
374+
const struct siwx91x_config *siwx91x_cfg = iface->if_dev->dev->config;
356375
struct siwx91x_dev *sidev = iface->if_dev->dev->data;
357376
int ret;
358377

@@ -369,6 +388,12 @@ static void siwx91x_iface_init(struct net_if *iface)
369388
sl_wifi_set_callback(SL_WIFI_STATS_RESPONSE_EVENTS, siwx91x_wifi_module_stats_event_handler,
370389
sidev);
371390

391+
ret = siwx91x_set_max_tx_power(siwx91x_cfg);
392+
if (ret != SL_STATUS_OK) {
393+
LOG_ERR("Failed to set max tx power:%x", ret);
394+
return;
395+
}
396+
372397
ret = sl_wifi_get_mac_address(SL_WIFI_CLIENT_INTERFACE, &sidev->macaddr);
373398
if (ret) {
374399
LOG_ERR("sl_wifi_get_mac_address(): %#04x", ret);
@@ -419,6 +444,11 @@ static const struct net_wifi_mgmt_offload siwx91x_api = {
419444
.wifi_mgmt_api = &siwx91x_mgmt,
420445
};
421446

447+
static const struct siwx91x_config siwx91x_cfg = {
448+
.scan_tx_power = DT_INST_PROP(0, wifi_max_tx_pwr_scan),
449+
.join_tx_power = DT_INST_PROP(0, wifi_max_tx_pwr_join),
450+
};
451+
422452
static struct siwx91x_dev sidev = {
423453
.ps_params.enabled = WIFI_PS_DISABLED,
424454
.ps_params.exit_strategy = WIFI_PS_EXIT_EVERY_TIM,
@@ -427,9 +457,9 @@ static struct siwx91x_dev sidev = {
427457
};
428458

429459
#ifdef CONFIG_WIFI_SILABS_SIWX91X_NET_STACK_NATIVE
430-
ETH_NET_DEVICE_DT_INST_DEFINE(0, siwx91x_dev_init, NULL, &sidev, NULL,
460+
ETH_NET_DEVICE_DT_INST_DEFINE(0, siwx91x_dev_init, NULL, &sidev, &siwx91x_cfg,
431461
CONFIG_WIFI_INIT_PRIORITY, &siwx91x_api, NET_ETH_MTU);
432462
#else
433-
NET_DEVICE_DT_INST_OFFLOAD_DEFINE(0, siwx91x_dev_init, NULL, &sidev, NULL,
463+
NET_DEVICE_DT_INST_OFFLOAD_DEFINE(0, siwx91x_dev_init, NULL, &sidev, &siwx91x_cfg,
434464
CONFIG_WIFI_INIT_PRIORITY, &siwx91x_api, NET_ETH_MTU);
435465
#endif

drivers/wifi/siwx91x/siwx91x_wifi.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
#include "sl_si91x_types.h"
1111

12+
struct siwx91x_config {
13+
uint8_t scan_tx_power;
14+
uint8_t join_tx_power;
15+
};
16+
1217
struct siwx91x_dev {
1318
struct net_if *iface;
1419
sl_mac_address_t macaddr;

dts/bindings/wifi/silabs,siwx91x-wifi.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,19 @@
55
description: Silabs SiWx91x SoC WiFi
66

77
compatible: "silabs,siwx91x-wifi"
8+
9+
properties:
10+
wifi-max-tx-pwr-scan:
11+
type: int
12+
default: 31
13+
description: |
14+
Maximum TX power (in dBm) used during Wi‑Fi scanning. Actual
15+
output may be capped by regulatory or hardware constraints.
16+
Note: SiWx91x firmware does **not** support per‑rate power.
17+
wifi-max-tx-pwr-join:
18+
type: int
19+
default: 31
20+
description: |
21+
Maximum TX power (in dBm) used when joining a Wi‑Fi network.
22+
Actual output may be capped by regulatory or hardware constraints.
23+
Note: SiWx91x firmware does **not** support per‑rate power.

0 commit comments

Comments
 (0)