Bluetooth: drivers: Convert Silabs HCI driver to new API
Convert the slz_hci.c HCI driver to use the new HCI driver API. This also fixes the HCI bus type to correctly indicate VIRTUAL instead of UART. Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
This commit is contained in:
parent
fcddefd7f0
commit
3ecd7dbd4c
15 changed files with 95 additions and 30 deletions
|
@ -42,9 +42,6 @@ config MAIN_STACK_SIZE
|
|||
default 3072 if PM
|
||||
default 2304
|
||||
|
||||
config BT_SILABS_HCI
|
||||
default y
|
||||
|
||||
endif # BT
|
||||
|
||||
endif # BOARD_EFR32_RADIO
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
/ {
|
||||
model = "Silicon Labs BRD4104A (Blue Gecko Radio Board)";
|
||||
compatible = "silabs,efr32_radio_brd4104a", "silabs,efr32bg13p";
|
||||
|
||||
chosen {
|
||||
zephyr,bt-hci = &bt_hci_silabs;
|
||||
};
|
||||
};
|
||||
|
||||
&cpu0 {
|
||||
|
@ -56,3 +60,7 @@
|
|||
|
||||
};
|
||||
};
|
||||
|
||||
&bt_hci_silabs {
|
||||
status = "okay";
|
||||
};
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
/ {
|
||||
model = "Silicon Labs BRD4161A (Mighty Gecko Radio Board)";
|
||||
compatible = "silabs,efr32_radio_brd4161a", "silabs,efr32mg12p";
|
||||
|
||||
chosen {
|
||||
zephyr,bt-hci = &bt_hci_silabs;
|
||||
};
|
||||
};
|
||||
|
||||
&cpu0 {
|
||||
|
@ -89,3 +93,7 @@
|
|||
status = "okay";
|
||||
};
|
||||
};
|
||||
|
||||
&bt_hci_silabs {
|
||||
status = "okay";
|
||||
};
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
/ {
|
||||
model = "Silicon Labs BRD4170A (Mighty Gecko Radio Board)";
|
||||
compatible = "silabs,efr32_radio_brd4170a", "silabs,efr32mg12p";
|
||||
|
||||
chosen {
|
||||
zephyr,bt-hci = &bt_hci_silabs;
|
||||
};
|
||||
};
|
||||
|
||||
&cpu0 {
|
||||
|
@ -56,3 +60,7 @@
|
|||
|
||||
};
|
||||
};
|
||||
|
||||
&bt_hci_silabs {
|
||||
status = "okay";
|
||||
};
|
||||
|
|
|
@ -28,9 +28,6 @@ config MAIN_STACK_SIZE
|
|||
default 3072 if PM
|
||||
default 2304
|
||||
|
||||
config BT_SILABS_HCI
|
||||
default y
|
||||
|
||||
endif # BT
|
||||
|
||||
config REGULATOR
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
chosen {
|
||||
zephyr,code-partition = &slot0_partition;
|
||||
zephyr,bt-hci = &bt_hci_silabs;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -55,3 +56,7 @@
|
|||
&sw_imu_enable {
|
||||
enable-gpios = <&gpiob GECKO_PIN(4) GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
|
||||
&bt_hci_silabs {
|
||||
status = "okay";
|
||||
};
|
||||
|
|
|
@ -33,9 +33,6 @@ config MINIMAL_LIBC_MALLOC_ARENA_SIZE
|
|||
config MAIN_STACK_SIZE
|
||||
default 2304
|
||||
|
||||
config BT_SILABS_HCI
|
||||
default y
|
||||
|
||||
if SHELL
|
||||
|
||||
config SHELL_STACK_SIZE
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
zephyr,sram = &sram0;
|
||||
zephyr,flash = &flash0;
|
||||
zephyr,code-partition = &slot0_partition;
|
||||
zephyr,bt-hci = &bt_hci_silabs;
|
||||
};
|
||||
|
||||
aliases {
|
||||
|
@ -177,3 +178,7 @@
|
|||
&stimer0 {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&bt_hci_silabs {
|
||||
status = "okay";
|
||||
};
|
||||
|
|
|
@ -76,7 +76,8 @@ config BT_STM32WBA
|
|||
|
||||
config BT_SILABS_HCI
|
||||
bool "Silicon Labs Bluetooth interface"
|
||||
depends on SOC_SERIES_EFR32BG22 || SOC_SERIES_EFR32MG24 || SOC_SERIES_EFR32BG27
|
||||
default y
|
||||
depends on DT_HAS_SILABS_BT_HCI_ENABLED
|
||||
depends on !PM || SOC_GECKO_PM_BACKEND_PMGR
|
||||
select SOC_GECKO_USE_RAIL
|
||||
select ENTROPY_GENERATOR
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/drivers/bluetooth/hci_driver.h>
|
||||
#include <zephyr/drivers/bluetooth.h>
|
||||
|
||||
#include <sl_btctrl_linklayer.h>
|
||||
#include <sl_hci_common_transport.h>
|
||||
|
@ -16,6 +16,12 @@
|
|||
#include <zephyr/logging/log.h>
|
||||
LOG_MODULE_REGISTER(bt_hci_driver_slz);
|
||||
|
||||
#define DT_DRV_COMPAT silabs_bt_hci
|
||||
|
||||
struct hci_data {
|
||||
bt_hci_recv_t recv;
|
||||
};
|
||||
|
||||
#define SL_BT_CONFIG_ACCEPT_LIST_SIZE 1
|
||||
#define SL_BT_CONFIG_MAX_CONNECTIONS 1
|
||||
#define SL_BT_CONFIG_USER_ADVERTISERS 1
|
||||
|
@ -53,6 +59,8 @@ void rail_isr_installer(void)
|
|||
*/
|
||||
uint32_t hci_common_transport_transmit(uint8_t *data, int16_t len)
|
||||
{
|
||||
const struct device *dev = DEVICE_DT_GET(DT_DRV_INST(0));
|
||||
struct hci_data *hci = dev->data;
|
||||
struct net_buf *buf;
|
||||
uint8_t packet_type = data[0];
|
||||
uint8_t event_code;
|
||||
|
@ -77,17 +85,19 @@ uint32_t hci_common_transport_transmit(uint8_t *data, int16_t len)
|
|||
}
|
||||
|
||||
net_buf_add_mem(buf, data, len);
|
||||
bt_recv(buf);
|
||||
hci->recv(dev, buf);
|
||||
|
||||
sl_btctrl_hci_transmit_complete(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int slz_bt_send(struct net_buf *buf)
|
||||
static int slz_bt_send(const struct device *dev, struct net_buf *buf)
|
||||
{
|
||||
int rv = 0;
|
||||
|
||||
ARG_UNUSED(dev);
|
||||
|
||||
switch (bt_buf_get_type(buf)) {
|
||||
case BT_BUF_ACL_OUT:
|
||||
net_buf_push_u8(buf, h4_acl);
|
||||
|
@ -119,8 +129,9 @@ static void slz_thread_func(void *p1, void *p2, void *p3)
|
|||
slz_ll_thread_func();
|
||||
}
|
||||
|
||||
static int slz_bt_open(void)
|
||||
static int slz_bt_open(const struct device *dev, bt_hci_recv_t recv)
|
||||
{
|
||||
struct hci_data *hci = dev->data;
|
||||
int ret;
|
||||
|
||||
/* Start RX thread */
|
||||
|
@ -185,6 +196,8 @@ static int slz_bt_open(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
hci->recv = recv;
|
||||
|
||||
LOG_DBG("SiLabs BT HCI started");
|
||||
|
||||
return 0;
|
||||
|
@ -193,24 +206,16 @@ deinit:
|
|||
return ret;
|
||||
}
|
||||
|
||||
static const struct bt_hci_driver drv = {
|
||||
.name = "sl:bt",
|
||||
.bus = BT_HCI_DRIVER_BUS_UART,
|
||||
static const struct bt_hci_driver_api drv = {
|
||||
.open = slz_bt_open,
|
||||
.send = slz_bt_send,
|
||||
.quirks = BT_QUIRK_NO_RESET
|
||||
};
|
||||
|
||||
static int slz_bt_init(void)
|
||||
{
|
||||
int ret;
|
||||
#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)
|
||||
|
||||
ret = bt_hci_driver_register(&drv);
|
||||
if (ret) {
|
||||
LOG_ERR("Failed to register SiLabs BT HCI %d", ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
SYS_INIT(slz_bt_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE);
|
||||
/* Only one instance supported right now */
|
||||
HCI_DEVICE_INIT(0)
|
||||
|
|
|
@ -224,6 +224,11 @@
|
|||
#io-channel-cells = <1>;
|
||||
};
|
||||
};
|
||||
|
||||
bt_hci_silabs: bt_hci_silabs {
|
||||
compatible = "silabs,bt-hci";
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
|
||||
/ {
|
||||
|
|
|
@ -234,6 +234,11 @@
|
|||
};
|
||||
};
|
||||
|
||||
bt_hci_silabs: bt_hci_silabs {
|
||||
compatible = "silabs,bt-hci";
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
pinctrl: pin-controller {
|
||||
/* Pin controller is a "virtual" device since SiLabs SoCs do pin
|
||||
* control in a distributed way (GPIO registers and PSEL
|
||||
|
|
|
@ -213,6 +213,12 @@
|
|||
#io-channel-cells = <1>;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
bt_hci_silabs: bt_hci_silabs {
|
||||
compatible = "silabs,bt-hci";
|
||||
status = "disabled";
|
||||
};
|
||||
};
|
||||
|
||||
/ {
|
||||
|
|
|
@ -181,6 +181,11 @@
|
|||
};
|
||||
};
|
||||
|
||||
bt_hci_silabs: bt_hci_silabs {
|
||||
compatible = "silabs,bt-hci";
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
pinctrl: pin-controller {
|
||||
/* Pin controller is a "virtual" device since SiLabs SoCs do pin
|
||||
* control in a distributed way (GPIO registers and PSEL
|
||||
|
|
13
dts/bindings/bluetooth/silabs,bt-hci.yaml
Normal file
13
dts/bindings/bluetooth/silabs,bt-hci.yaml
Normal file
|
@ -0,0 +1,13 @@
|
|||
description: Bluetooth HCI on Silabs boards
|
||||
|
||||
compatible: "silabs,bt-hci"
|
||||
|
||||
include: bt-hci.yaml
|
||||
|
||||
properties:
|
||||
bt-hci-name:
|
||||
default: "sl:bt"
|
||||
bt-hci-bus:
|
||||
default: "BT_HCI_BUS_VIRTUAL"
|
||||
bt-hci-quirks:
|
||||
default: ["BT_HCI_QUIRK_NO_RESET"]
|
Loading…
Add table
Add a link
Reference in a new issue