Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce siwg917 #85144

Draft
wants to merge 27 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
74584bb
uart: ns16550: Enable clock if defined
jerome-pouiller Jan 29, 2025
1381720
modules: hal_silabs: Introduce WiseConnect SDK
jerome-pouiller Jan 29, 2025
3c41254
drivers: clock: Add dumb clock driver for SiWx91x
jerome-pouiller Jan 29, 2025
8f8a652
soc: silabs: Introduce new SoC SiWG917
jerome-pouiller Jan 30, 2025
9369743
boards: silabs: Add support for Silabs SiWx917 BRD4338 board
jerome-pouiller Jan 30, 2025
59e24c9
drivers: pinctrl: Introduce support for SiWx91x
jerome-pouiller Jan 29, 2025
5a29daf
boards: silabs: siwx91x: Add support for pinctrl
jerome-pouiller Feb 4, 2025
7531896
drivers: gpio: Introduce support for SiWx91x
jerome-pouiller Jan 31, 2025
9e3c3b3
boards: silabs: siwx91x: Add support for GPIOs
jerome-pouiller Feb 3, 2025
8a028b7
tests: drivers: gpio: Enable board siwx917_rb4338a
jerome-pouiller Feb 3, 2025
0493d3e
drivers: entropy: Introduce SiWx91x entropy driver
jerome-pouiller Jan 31, 2025
aa3e83b
boards: silabs: siwx91x: Add support for hardware RNG
jerome-pouiller Feb 3, 2025
5f06fad
drivers: dma: Introduce support for SiWx91x
jerome-pouiller Feb 3, 2025
e066c1f
boards: silabs: siwx91x: Add support for DMAs
jerome-pouiller Feb 4, 2025
e8031cf
tests: drivers: dma: Enable board siwx917_rb4338a
jerome-pouiller Feb 3, 2025
c0698ae
soc: silabs: siwg917: Initialize the NWP
jerome-pouiller Feb 4, 2025
5ea0685
drivers: flash: Introduce SiWx91x Flash driver
jerome-pouiller Jan 31, 2025
df1c534
boards: silabs: siwx91x: Add support for Flash
jerome-pouiller Feb 4, 2025
7d8a570
tests: drivers: flash: Enable board siwx917_rb4338a
jerome-pouiller Feb 3, 2025
ea537ea
drivers: bluetooth: Introduce SiWx91x HCI driver
jerome-pouiller Feb 3, 2025
d2fc4a2
boards: silabs: siwx91x: Add support for Bluetooth
jerome-pouiller Feb 3, 2025
3e11fd0
drivers: wifi: Introduce SiWx91x WiFi driver
jerome-pouiller Feb 3, 2025
d1df2b4
boards: silabs: Add support for Wifi
jerome-pouiller Feb 3, 2025
c08bccf
tests: drivers: wifi: Enable board siwx917_rb4338a
jerome-pouiller Feb 3, 2025
072f11d
drivers: clock: siwx91x: Add support for i2c clock
jerome-pouiller Feb 4, 2025
38d90dd
boards: silabs: Add support for i2c
jerome-pouiller Feb 3, 2025
0a60cf9
boards: silabs: Add support for si7021 sensor
jerome-pouiller Feb 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions drivers/bluetooth/hci/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ zephyr_library_sources_ifdef(CONFIG_BT_STM32WBA hci_stm32wba.c)
zephyr_library_sources_ifdef(CONFIG_BT_STM32WB0 hci_stm32wb0.c)
zephyr_library_sources_ifdef(CONFIG_BT_USERCHAN userchan.c)
zephyr_library_sources_ifdef(CONFIG_BT_SILABS_EFR32 hci_silabs_efr32.c)
zephyr_library_sources_ifdef(CONFIG_BT_SILABS_SIWX91X hci_silabs_siwx91x.c)
zephyr_library_sources_ifdef(CONFIG_BT_PSOC6_BLESS hci_ifx_psoc6_bless.c)
zephyr_library_sources_ifdef(CONFIG_SOC_NRF5340_CPUAPP nrf53_support.c)
zephyr_library_sources_ifdef(CONFIG_BT_AMBIQ_HCI hci_ambiq.c apollox_blue.c)
Expand Down
10 changes: 10 additions & 0 deletions drivers/bluetooth/hci/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,18 @@ config BT_SILABS_EFR32
help
Use Silicon Labs binary Bluetooth library to connect to the
controller.

source "drivers/bluetooth/hci/Kconfig.silabs"

config BT_SILABS_SIWX91X
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably go before the source "drivers/bluetooth/hci/Kconfig.silabs" line, so that options specific to the 917 HCI driver can be put into Kconfig.silabs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think it'd be even justified to move the top-level Silabs driver options into that file too, however if the current situation is the common practice for HCI drivers we can do the refactoring in a later PR too.

bool "Silabs SiWx91x Bluetooth interface"
default y
depends on DT_HAS_SILABS_SIWX91X_BT_HCI_ENABLED
select WISECONNECT_NETWORK_STACK
select ENTROPY_GENERATOR
help
Use Silicon Labs Wiseconnect 3.x Bluetooth library to connect to the controller.

config BT_USERCHAN
bool
depends on (BOARD_NATIVE_POSIX || BOARD_NATIVE_SIM)
Expand Down
118 changes: 118 additions & 0 deletions drivers/bluetooth/hci/hci_silabs_siwx91x.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
* Copyright (c) 2024 Silicon Laboratories Inc.
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/kernel.h>
#include <zephyr/drivers/bluetooth.h>

#define DT_DRV_COMPAT silabs_siwx91x_bt_hci
#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(bt_hci_driver_siwg917);

#include "rsi_ble.h"

static void siwx91x_bt_resp_rcvd(uint16_t status, rsi_ble_event_rcp_rcvd_info_t *resp_buf);

struct hci_data {
bt_hci_recv_t recv;
rsi_data_packet_t rsi_data_packet;
};

static int siwx91x_bt_open(const struct device *dev, bt_hci_recv_t recv)
{
struct hci_data *hci = dev->data;
int status = rsi_ble_enhanced_gap_extended_register_callbacks(RSI_BLE_ON_RCP_EVENT,
(void *)siwx91x_bt_resp_rcvd);

if (!status) {
hci->recv = recv;
}
return status ? -EIO : 0;
}

static int siwx91x_bt_send(const struct device *dev, struct net_buf *buf)
{
struct hci_data *hci = dev->data;
int sc = -EOVERFLOW;
uint8_t packet_type = BT_HCI_H4_NONE;

switch (bt_buf_get_type(buf)) {
case BT_BUF_ACL_OUT:
packet_type = BT_HCI_H4_ACL;
break;
case BT_BUF_CMD:
packet_type = BT_HCI_H4_CMD;
break;
default:
sc = -EINVAL;
break;
}

if ((packet_type != BT_HCI_H4_NONE) && (buf->len < sizeof(hci->rsi_data_packet.data))) {
net_buf_push_u8(buf, packet_type);
memcpy(&hci->rsi_data_packet, buf->data, buf->len);
sc = rsi_bt_driver_send_cmd(RSI_BLE_REQ_HCI_RAW, &hci->rsi_data_packet, NULL);
/* TODO SILABS ZEPHYR Convert to errno. A common function from rsi/sl_status should
* be introduced
*/
if (sc) {
LOG_ERR("BT command send failure: %d", sc);
sc = -EIO;
}
}
net_buf_unref(buf);
return sc;
}

static void siwx91x_bt_resp_rcvd(uint16_t status, rsi_ble_event_rcp_rcvd_info_t *resp_buf)
{
const struct device *dev = DEVICE_DT_GET(DT_DRV_INST(0));
struct hci_data *hci = dev->data;
uint8_t packet_type = BT_HCI_H4_NONE;
size_t len = 0;
struct net_buf *buf = NULL;

/* TODO SILABS ZEPHYR This horror expression is from the WiseConnect from the HCI example...
* No workaround have been found until now.
*/
memcpy(&packet_type, (resp_buf->data - 12), 1);
switch (packet_type) {
case BT_HCI_H4_EVT: {
struct bt_hci_evt_hdr *hdr = (void *)resp_buf->data;

len = hdr->len + sizeof(*hdr);
buf = bt_buf_get_evt(hdr->evt, false, K_FOREVER);
break;
}
case BT_HCI_H4_ACL: {
struct bt_hci_acl_hdr *hdr = (void *)resp_buf->data;

len = hdr->len + sizeof(*hdr);
buf = bt_buf_get_rx(BT_BUF_ACL_IN, K_FOREVER);
break;
}
default:
LOG_ERR("Unknown/Unhandled HCI type: %d", packet_type);
break;
}

if (buf && (len <= net_buf_tailroom(buf))) {
net_buf_add_mem(buf, resp_buf->data, len);
hci->recv(dev, buf);
}
}

static const struct bt_hci_driver_api drv = {
.open = siwx91x_bt_open,
.send = siwx91x_bt_send,
};

#define HCI_DEVICE_INIT(inst) \
static struct hci_data hci_data_##inst; \
DEVICE_DT_INST_DEFINE(inst, NULL, NULL, &hci_data_##inst, NULL, POST_KERNEL, \
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &drv)

/* Only one instance supported right now */
HCI_DEVICE_INIT(0)
13 changes: 13 additions & 0 deletions dts/bindings/bluetooth/silabs,siwx91x-bt-hci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
description: Bluetooth HCI on Silabs boards

compatible: "silabs,siwx91x-bt-hci"

include: bt-hci.yaml

properties:
bt-hci-name:
default: "sl:bt:siwx91x"
bt-hci-bus:
default: "virtual"
bt-hci-quirks:
default: ["no-reset"]
18 changes: 18 additions & 0 deletions modules/hal_silabs/wiseconnect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ zephyr_library_sources_ifdef(CONFIG_DMA_SILABS_SIWX91X
${WISECONNECT_DIR}/components/device/silabs/si91x/mcu/drivers/rom_driver/src/rsi_rom_table_si91x.c
)

if(CONFIG_BT_SILABS_SIWX91X)

zephyr_compile_definitions(
SLI_SI91X_ENABLE_BLE=1
)

zephyr_include_directories(
${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ble/inc
)

zephyr_library_sources(
${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ble/src/rsi_bt_ble.c
${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ble/src/rsi_common_apis.c
${WISECONNECT_DIR}/components/device/silabs/si91x/wireless/ble/src/rsi_utils.c
)

endif() # CONFIG_BT_SILABS_SIWX91X

if(CONFIG_WISECONNECT_NETWORK_STACK)

zephyr_compile_definitions(
Expand Down
20 changes: 20 additions & 0 deletions soc/silabs/silabs_siwx91x/siwg917/nwp_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

#include "sl_wifi.h"
#include "sl_wifi_callback_framework.h"
#ifdef CONFIG_BT_SILABS_SIWX91X
#include "rsi_ble_common_config.h"
#endif

static int siwg917_nwp_init(void)
{
Expand All @@ -36,6 +39,23 @@ static int siwg917_nwp_init(void)
}
};

#ifdef CONFIG_BT_SILABS_SIWX91X
cfg->ext_custom_feature_bit_map |= SL_SI91X_EXT_FEAT_BT_CUSTOM_FEAT_ENABLE;
cfg->bt_feature_bit_map |= SL_SI91X_BT_RF_TYPE | SL_SI91X_ENABLE_BLE_PROTOCOL;
cfg->ble_feature_bit_map |= 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;
cfg->ble_ext_feature_bit_map |= 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);
#endif

/* TODO: If sl_net_*_profile() functions will be needed for WiFi then call
* sl_net_set_profile() here. Currently these are unused.
*/
Expand Down