-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
jerome-pouiller
wants to merge
27
commits into
zephyrproject-rtos:main
Choose a base branch
from
jerome-pouiller:introduce-siwg917
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,946
−4
Draft
Introduce siwg917 #85144
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 1381720
modules: hal_silabs: Introduce WiseConnect SDK
jerome-pouiller 3c41254
drivers: clock: Add dumb clock driver for SiWx91x
jerome-pouiller 8f8a652
soc: silabs: Introduce new SoC SiWG917
jerome-pouiller 9369743
boards: silabs: Add support for Silabs SiWx917 BRD4338 board
jerome-pouiller 59e24c9
drivers: pinctrl: Introduce support for SiWx91x
jerome-pouiller 5a29daf
boards: silabs: siwx91x: Add support for pinctrl
jerome-pouiller 7531896
drivers: gpio: Introduce support for SiWx91x
jerome-pouiller 9e3c3b3
boards: silabs: siwx91x: Add support for GPIOs
jerome-pouiller 8a028b7
tests: drivers: gpio: Enable board siwx917_rb4338a
jerome-pouiller 0493d3e
drivers: entropy: Introduce SiWx91x entropy driver
jerome-pouiller aa3e83b
boards: silabs: siwx91x: Add support for hardware RNG
jerome-pouiller 5f06fad
drivers: dma: Introduce support for SiWx91x
jerome-pouiller e066c1f
boards: silabs: siwx91x: Add support for DMAs
jerome-pouiller e8031cf
tests: drivers: dma: Enable board siwx917_rb4338a
jerome-pouiller c0698ae
soc: silabs: siwg917: Initialize the NWP
jerome-pouiller 5ea0685
drivers: flash: Introduce SiWx91x Flash driver
jerome-pouiller df1c534
boards: silabs: siwx91x: Add support for Flash
jerome-pouiller 7d8a570
tests: drivers: flash: Enable board siwx917_rb4338a
jerome-pouiller ea537ea
drivers: bluetooth: Introduce SiWx91x HCI driver
jerome-pouiller d2fc4a2
boards: silabs: siwx91x: Add support for Bluetooth
jerome-pouiller 3e11fd0
drivers: wifi: Introduce SiWx91x WiFi driver
jerome-pouiller d1df2b4
boards: silabs: Add support for Wifi
jerome-pouiller c08bccf
tests: drivers: wifi: Enable board siwx917_rb4338a
jerome-pouiller 072f11d
drivers: clock: siwx91x: Add support for i2c clock
jerome-pouiller 38d90dd
boards: silabs: Add support for i2c
jerome-pouiller 0a60cf9
boards: silabs: Add support for si7021 sensor
jerome-pouiller File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 intoKconfig.silabs
There was a problem hiding this comment.
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.