Skip to content

Commit 8e51ebf

Browse files
iandmorriskartben
authored andcommitted
drivers: bluetooth: hci: add hardware reset for da1453x
Add ability to perform a hardware reset of the DA1453x during setup of the HCI transport. Signed-off-by: Ian Morris <[email protected]>
1 parent d87bafe commit 8e51ebf

File tree

4 files changed

+97
-0
lines changed

4 files changed

+97
-0
lines changed

drivers/bluetooth/hci/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ if(CONFIG_DT_HAS_INFINEON_CAT1_BLESS_HCI_ENABLED)
2929
endif()
3030
zephyr_library_sources_ifdef(CONFIG_SOC_NRF5340_CPUAPP nrf53_support.c)
3131
zephyr_library_sources_ifdef(CONFIG_BT_AMBIQ_HCI hci_ambiq.c apollox_blue.c)
32+
zephyr_library_sources_ifdef(CONFIG_BT_DA1453X hci_da1453x.c)
3233
zephyr_library_sources_ifdef(CONFIG_BT_DA1469X hci_da1469x.c)
3334
zephyr_library_sources_ifdef(CONFIG_BT_NXP hci_nxp.c)
3435
zephyr_library_sources_ifdef(CONFIG_BT_H4_NXP_CTLR hci_nxp_setup.c)

drivers/bluetooth/hci/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,15 @@ config BT_PSOC6_BLESS
160160
PSOC 6 BLESS driver with BLE Controller which operates in
161161
Single CPU mode.
162162

163+
config BT_DA1453X
164+
bool "DA1453x HCI driver"
165+
default y
166+
depends on DT_HAS_RENESAS_BT_HCI_DA1453X_ENABLED
167+
select GPIO
168+
help
169+
Bluetooth HCI driver for communication with controller
170+
running on DA1453x MCU.
171+
163172
config BT_DA1469X
164173
bool
165174
default y

drivers/bluetooth/hci/hci_da1453x.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2024 Ian Morris
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/device.h>
9+
#include <zephyr/devicetree.h>
10+
#include <zephyr/drivers/gpio.h>
11+
#include <zephyr/drivers/uart.h>
12+
13+
#define LOG_LEVEL CONFIG_BT_HCI_DRIVER_LOG_LEVEL
14+
#include <zephyr/logging/log.h>
15+
LOG_MODULE_REGISTER(bt_hci_da1453x);
16+
17+
#define DT_DRV_COMPAT renesas_bt_hci_da1453x
18+
19+
int bt_hci_transport_setup(const struct device *h4)
20+
{
21+
int err = 0;
22+
23+
#if DT_INST_NODE_HAS_PROP(0, reset_gpios)
24+
char c;
25+
struct gpio_dt_spec bt_reset = GPIO_DT_SPEC_GET(DT_DRV_INST(0), reset_gpios);
26+
27+
if (!gpio_is_ready_dt(&bt_reset)) {
28+
LOG_ERR("Error: failed to configure bt_reset %s pin %d", bt_reset.port->name,
29+
bt_reset.pin);
30+
return -EIO;
31+
}
32+
33+
/* Set bt_reset as output and activate DA1453x reset */
34+
err = gpio_pin_configure_dt(&bt_reset, GPIO_OUTPUT_ACTIVE);
35+
if (err) {
36+
LOG_ERR("Error %d: failed to configure bt_reset %s pin %d", err,
37+
bt_reset.port->name, bt_reset.pin);
38+
return err;
39+
}
40+
41+
k_sleep(K_MSEC(DT_INST_PROP_OR(0, reset_assert_duration_ms, 0)));
42+
43+
/* Release the DA1453x from reset */
44+
err = gpio_pin_set_dt(&bt_reset, 0);
45+
if (err) {
46+
return err;
47+
}
48+
49+
/* Wait for the DA1453x to boot */
50+
k_sleep(K_MSEC(DT_INST_PROP(0, boot_duration_ms)));
51+
52+
/* Drain bytes */
53+
while (h4 && uart_fifo_read(h4, &c, 1)) {
54+
continue;
55+
}
56+
#endif /* DT_INST_NODE_HAS_PROP(0, reset_gpios) */
57+
58+
return err;
59+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2024 Ian Morris
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: |
5+
Extension of the Bluetooth H:4 HCI driver for a Renesas DA1453x based
6+
controller, allowing control of the GPIO used to reset the DA1453x.
7+
8+
compatible: "renesas,bt-hci-da1453x"
9+
10+
include: base.yaml
11+
12+
properties:
13+
reset-gpios:
14+
type: phandle-array
15+
description: |
16+
This gpio is used to reset the DA1453x.
17+
18+
reset-assert-duration-ms:
19+
type: int
20+
description: |
21+
Minimum duration to activate the reset-gpios pin.
22+
If not specified no delay beyond the code path execution time is guaranteed.
23+
24+
boot-duration-ms:
25+
type: int
26+
default: 200
27+
description: |
28+
Minimum time to wait for the DA1453x to boot following a hardware reset.

0 commit comments

Comments
 (0)