Skip to content

Commit d5b2507

Browse files
ArunmaniAlagarsamy2710kartben
authored andcommitted
drivers: wifi: siwx91x: Add Wi-Fi version command support
Add support for the Wi-Fi version command to retrieve the Wi-Fi firmware and driver version information. Signed-off-by: Arunmani Alagarsamy <arunmani.a@silabs.com>
1 parent 216ff00 commit d5b2507

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

drivers/wifi/siwx91x/siwx91x_wifi.c

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77

88
#include <zephyr/logging/log.h>
99
#include <zephyr/sys/__assert.h>
10-
#include <nwp.h>
10+
#include <zephyr/version.h>
1111

12+
#include <nwp.h>
1213
#include "siwx91x_wifi.h"
1314
#include "siwx91x_wifi_socket.h"
1415

@@ -20,7 +21,7 @@
2021
#include "sl_wifi.h"
2122
#include "sl_net.h"
2223

23-
#define SIWX91X_INTERFACE_MASK (0x03)
24+
#define SIWX91X_DRIVER_VERSION KERNEL_VERSION_STRING
2425

2526
LOG_MODULE_REGISTER(siwx91x_wifi);
2627

@@ -722,6 +723,36 @@ static int siwx91x_stats(const struct device *dev, struct net_stats_wifi *stats)
722723
}
723724
#endif
724725

726+
static int siwx91x_get_version(const struct device *dev, struct wifi_version *params)
727+
{
728+
sl_wifi_firmware_version_t fw_version = { };
729+
struct siwx91x_dev *sidev = dev->data;
730+
static char fw_version_str[32];
731+
sl_status_t status;
732+
733+
__ASSERT(params, "params cannot be NULL");
734+
735+
if (sidev->state == WIFI_STATE_INTERFACE_DISABLED) {
736+
return -EIO;
737+
}
738+
739+
status = sl_wifi_get_firmware_version(&fw_version);
740+
if (status != SL_STATUS_OK) {
741+
return -EINVAL;
742+
}
743+
744+
snprintf(fw_version_str, sizeof(fw_version_str), "%02x%02x.%d.%d.%d.%d.%d.%d",
745+
fw_version.chip_id, fw_version.rom_id,
746+
fw_version.major, fw_version.minor,
747+
fw_version.security_version, fw_version.patch_num,
748+
fw_version.customer_id, fw_version.build_num);
749+
750+
params->fw_version = fw_version_str;
751+
params->drv_version = SIWX91X_DRIVER_VERSION;
752+
753+
return 0;
754+
}
755+
725756
static void siwx91x_iface_init(struct net_if *iface)
726757
{
727758
struct siwx91x_dev *sidev = iface->if_dev->dev->data;
@@ -768,6 +799,7 @@ static const struct wifi_mgmt_ops siwx91x_mgmt = {
768799
#if defined(CONFIG_NET_STATISTICS_WIFI)
769800
.get_stats = siwx91x_stats,
770801
#endif
802+
.get_version = siwx91x_get_version,
771803
};
772804

773805
static const struct net_wifi_mgmt_offload siwx91x_api = {

0 commit comments

Comments
 (0)