Skip to content

Commit

Permalink
Bluetooth: drivers: Convert H4 (UART) HCI driver to new API
Browse files Browse the repository at this point in the history
Convert the H4 driver to the new HCI driver API. This includes updating
also any boards that use the driver, i.e. adding the appropriate
devicetree node and chosen property to them.

Signed-off-by: Johan Hedberg <[email protected]>
  • Loading branch information
jhedberg authored and nashif committed Jun 11, 2024
1 parent dcff0be commit 3482a3b
Show file tree
Hide file tree
Showing 15 changed files with 347 additions and 238 deletions.
19 changes: 12 additions & 7 deletions boards/arduino/giga_r1/arduino_giga_r1_stm32h747xx_m7.dts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
zephyr,console = &usart1;
zephyr,shell-uart = &usart1;
zephyr,uart-mcumgr = &usart1;
zephyr,bt-uart = &uart7;
zephyr,bt-hci = &bt_hci_uart;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,canbus = &fdcan2;
Expand Down Expand Up @@ -97,12 +97,17 @@
status = "okay";
hw-flow-control;

murata-1dx {
compatible = "infineon,cyw43xxx-bt-hci";
bt-reg-on-gpios = <&gpioa 10 GPIO_ACTIVE_HIGH>;
bt-host-wake-gpios = <&gpiog 3 GPIO_ACTIVE_HIGH>;
bt-dev-wake-gpios = <&gpioh 7 GPIO_ACTIVE_HIGH>;
fw-download-speed = <115200>;
bt_hci_uart: bt_hci_uart {
compatible = "zephyr,bt-hci-uart";
status = "okay";

murata-1dx {
compatible = "infineon,cyw43xxx-bt-hci";
bt-reg-on-gpios = <&gpioa 10 GPIO_ACTIVE_HIGH>;
bt-host-wake-gpios = <&gpiog 3 GPIO_ACTIVE_HIGH>;
bt-dev-wake-gpios = <&gpioh 7 GPIO_ACTIVE_HIGH>;
fw-download-speed = <115200>;
};
};
};

Expand Down
29 changes: 17 additions & 12 deletions boards/infineon/cy8cproto_062_4343w/cy8cproto_062_4343w.dts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
zephyr,flash = &flash0;
zephyr,console = &uart5;
zephyr,shell-uart = &uart5;
zephyr,bt_uart = &uart2;
zephyr,bt-hci = &bt_hci_uart;
};
};

Expand Down Expand Up @@ -58,17 +58,22 @@ uart2: &scb2 {
/* HW Flow control must be enabled for HCI H4 */
hw-flow-control;

bt-hci {
status = "okay";
compatible = "infineon,cyw43xxx-bt-hci";
bt-reg-on-gpios = <&gpio_prt3 4 (GPIO_ACTIVE_HIGH)>;

/* Configuration UART speeds for firmware download (fw-download-speed) and
* HCI operation (hci-operation-speed).
* If hci-operation-speed or fw-download-speed are not defined in bt-hci{...}
* node, cyw43xx driver will use bus/current-speed as default speed.
*/
fw-download-speed = <3000000>;
bt_hci_uart: bt_hci_uart {
compatible = "zephyr,bt-hci-uart";

murata-1dx {
status = "okay";
compatible = "infineon,cyw43xxx-bt-hci";
bt-reg-on-gpios = <&gpio_prt3 4 (GPIO_ACTIVE_HIGH)>;

/* Configuration UART speeds for firmware download (fw-download-speed)
* and HCI operation (hci-operation-speed).
* If hci-operation-speed or fw-download-speed are not defined in
* bt-hci{...} node, cyw43xx driver will use bus/current-speed as
* default speed.
*/
fw-download-speed = <3000000>;
};
};
};

Expand Down
7 changes: 6 additions & 1 deletion boards/ite/it82xx2_evb/it82xx2_evb.dts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
chosen {
zephyr,console = &uart1;
zephyr,shell-uart = &uart1;
zephyr,bt-uart = &uart2;
zephyr,bt-hci = &bt_hci_uart;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,flash-controller = &flashctrl;
Expand Down Expand Up @@ -115,6 +115,11 @@
status = "okay";
current-speed = <460800>;
clock-frequency = <1843200>;

bt_hci_uart: bt_hci_uart {
compatible = "zephyr,bt-hci-uart";
status = "okay";
};
};

&ite_uart1_wrapper {
Expand Down
7 changes: 6 additions & 1 deletion boards/ite/it8xxx2_evb/it8xxx2_evb.dts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
chosen {
zephyr,console = &uart1;
zephyr,shell-uart = &uart1;
zephyr,bt-uart = &uart2;
zephyr,bt-hci = &bt_hci_uart;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,flash-controller = &flashctrl;
Expand Down Expand Up @@ -105,6 +105,11 @@
status = "okay";
current-speed = <460800>;
clock-frequency = <1843200>;

bt_hci_uart: bt_hci_uart {
compatible = "zephyr,bt-hci-uart";
status = "okay";
};
};
&ite_uart1_wrapper {
status = "okay";
Expand Down
7 changes: 6 additions & 1 deletion boards/nxp/hexiwear/hexiwear_mk64f12.dts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
zephyr,code-partition = &slot0_partition;
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,bt-uart = &uart4;
zephyr,bt-hci = &bt_hci_uart;
};

leds {
Expand Down Expand Up @@ -153,6 +153,11 @@
current-speed = <115200>;
pinctrl-0 = <&uart4_default>;
pinctrl-names = "default";

bt_hci_uart: bt_hci_uart {
compatible = "zephyr,bt-hci-uart";
status = "okay";
};
};

&gpioa {
Expand Down
7 changes: 6 additions & 1 deletion boards/qemu/cortex_m3/qemu_cortex_m3.dts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
zephyr,flash = &flash0;
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,bt-uart = &uart2;
zephyr,bt-hci = &bt_hci_uart;
zephyr,uart-pipe = &uart1;
zephyr,bt-mon-uart = &uart2;
};
Expand All @@ -39,6 +39,11 @@
&uart2 {
status = "okay";
current-speed = <115200>;

bt_hci_uart: bt_hci_uart {
compatible = "zephyr,bt-hci-uart";
status = "okay";
};
};

&eth {
Expand Down
7 changes: 6 additions & 1 deletion boards/qemu/x86/qemu_x86.dts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
zephyr,sram = &dram0;
zephyr,flash = &flash0;
zephyr,console = &uart0;
zephyr,bt-hci = &bt_hci_uart;
zephyr,shell-uart = &uart0;
zephyr,bt-uart = &uart1;
zephyr,uart-pipe = &uart1;
zephyr,bt-mon-uart = &uart1;
zephyr,code-partition = &slot0_partition;
Expand Down Expand Up @@ -125,6 +125,11 @@
&uart1 {
status = "okay";
current-speed = <115200>;

bt_hci_uart: bt_hci_uart {
compatible = "zephyr,bt-hci-uart";
status = "okay";
};
};

&hpet {
Expand Down
7 changes: 6 additions & 1 deletion boards/shields/frdm_kw41z/frdm_kw41z.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@

/ {
chosen {
zephyr,bt-uart = &arduino_serial;
zephyr,bt-hci = &bt_hci_uart;
};
};

&arduino_serial {
status = "okay";
current-speed = <115200>;

bt_hci_uart: bt_hci_uart {
compatible = "zephyr,bt-hci-uart";
status = "okay";
};
};
7 changes: 6 additions & 1 deletion boards/st/b_u585i_iot02a/b_u585i_iot02a.dts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,code-partition = &slot0_partition;
zephyr,bt-uart=&uart4;
zephyr,bt-hci = &bt_hci_uart;
};

aliases {
Expand Down Expand Up @@ -81,4 +81,9 @@
pinctrl-names = "default";
current-speed = <100000>;
status = "okay";

bt_hci_uart: bt_hci_uart {
compatible = "zephyr,bt-hci-uart";
status = "okay";
};
};
9 changes: 8 additions & 1 deletion boards/up-bridge-the-gap/up_squared/up_squared.dts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
zephyr,sram = &dram0;
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,bt-uart = &uart1;
zephyr,bt-hci = &bt_hci_uart;
zephyr,uart-pipe = &uart1;
zephyr,bt-mon-uart = &uart1;
};
Expand All @@ -49,3 +49,10 @@
};
};
};

&uart1 {
bt_hci_uart: bt_hci_uart {
compatible = "zephyr,bt-hci-uart";
status = "okay";
};
};
2 changes: 2 additions & 0 deletions drivers/bluetooth/hci/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ choice BT_HCI_BUS_TYPE
config BT_H4
bool "H:4 UART"
select BT_UART
default y
depends on DT_HAS_ZEPHYR_BT_HCI_UART_ENABLED
help
Bluetooth H:4 UART driver. Requires hardware flow control
lines to be available.
Expand Down
6 changes: 3 additions & 3 deletions drivers/bluetooth/hci/cyw43xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ LOG_MODULE_REGISTER(cyw43xxx_driver);

#include <stdint.h>

BUILD_ASSERT(DT_PROP(DT_CHOSEN(zephyr_bt_uart), hw_flow_control) == 1,
"hw_flow_control must be enabled for HCI H4 UART");

#define DT_DRV_COMPAT infineon_cyw43xxx_bt_hci

BUILD_ASSERT(DT_PROP(DT_INST_GPARENT(0), hw_flow_control) == 1,
"hw_flow_control must be enabled for HCI H4 UART");

/* BT settling time after power on */
#define BT_POWER_ON_SETTLING_TIME_MS (500u)

Expand Down
Loading

0 comments on commit 3482a3b

Please sign in to comment.