From 3d694ba06142794533b43620ecdf25635dd8e950 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 15 Oct 2024 18:42:43 +0300 Subject: [PATCH 1/2] Bluetooth: HCI: Use lower-case values for bus and quirks in devicetree It's more common (and more readable) convention to use lower-case names for string-based device tree property values. Convert the HCI bus and quirks to follow this convention. Also take advantage of the recently added support for string-array enums to enforce that the correct values are used. Signed-off-by: Johan Hedberg --- dts/bindings/bluetooth/ambiq,bt-hci-spi.yaml | 2 +- dts/bindings/bluetooth/bt-hci.yaml | 23 +++++++++++-------- .../bluetooth/espressif,esp32-bt-hci.yaml | 4 ++-- .../bluetooth/infineon,cat1-bless-hci.yaml | 4 ++-- .../bluetooth/infineon,cyw208xx-hci.yaml | 2 +- dts/bindings/bluetooth/nxp,hci-ble.yaml | 2 +- .../bluetooth/renesas,bt-hci-da1469x.yaml | 2 +- dts/bindings/bluetooth/silabs,bt-hci.yaml | 4 ++-- dts/bindings/bluetooth/st,hci-spi-v1.yaml | 2 +- dts/bindings/bluetooth/st,hci-spi-v2.yaml | 2 +- dts/bindings/bluetooth/st,hci-stm32wba.yaml | 2 +- dts/bindings/bluetooth/st,stm32wb-ble-rf.yaml | 2 +- .../bluetooth/zephyr,bt-hci-3wire-uart.yaml | 2 +- dts/bindings/bluetooth/zephyr,bt-hci-ipc.yaml | 4 ++-- .../bluetooth/zephyr,bt-hci-ll-sw-split.yaml | 4 ++-- dts/bindings/bluetooth/zephyr,bt-hci-spi.yaml | 2 +- .../bluetooth/zephyr,bt-hci-uart.yaml | 2 +- .../bluetooth/zephyr,bt-hci-userchan.yaml | 2 +- include/zephyr/drivers/bluetooth.h | 6 +++-- .../dts/bindings/zephyr,bt-hci-test.yaml | 2 +- .../dts/bindings/zephyr,bt-hci-test.yaml | 4 ++-- .../dts/bindings/zephyr,bt-hci-test.yaml | 2 +- .../dts/bindings/zephyr,bt-hci-test.yaml | 4 ++-- 23 files changed, 45 insertions(+), 40 deletions(-) diff --git a/dts/bindings/bluetooth/ambiq,bt-hci-spi.yaml b/dts/bindings/bluetooth/ambiq,bt-hci-spi.yaml index 8816d57bf664ae..d73fcfa4633bf8 100644 --- a/dts/bindings/bluetooth/ambiq,bt-hci-spi.yaml +++ b/dts/bindings/bluetooth/ambiq,bt-hci-spi.yaml @@ -37,4 +37,4 @@ properties: default: "ambiq hci" bt-hci-bus: - default: "BT_HCI_BUS_SPI" + default: "spi" diff --git a/dts/bindings/bluetooth/bt-hci.yaml b/dts/bindings/bluetooth/bt-hci.yaml index e53b9022e9069f..a010310f755328 100644 --- a/dts/bindings/bluetooth/bt-hci.yaml +++ b/dts/bindings/bluetooth/bt-hci.yaml @@ -10,19 +10,22 @@ properties: type: string description: Bus of the transport enum: - - "BT_HCI_BUS_VIRTUAL" - - "BT_HCI_BUS_USB" - - "BT_HCI_BUS_PCCARD" - - "BT_HCI_BUS_UART" - - "BT_HCI_BUS_RS232" - - "BT_HCI_BUS_PCI" - - "BT_HCI_BUS_SDIO" - - "BT_HCI_BUS_SPI" - - "BT_HCI_BUS_I2C" - - "BT_HCI_BUS_IPM" + - "virtual" + - "usb" + - "pccard" + - "uart" + - "rs232" + - "pci" + - "sdio" + - "spi" + - "i2c" + - "ipm" bt-hci-quirks: type: string-array description: HCI device quirks + enum: + - "no-reset" + - "no-auto-dle" bt-hci-vs-ext: type: boolean description: Zephyr HCI vendor extensions are supported diff --git a/dts/bindings/bluetooth/espressif,esp32-bt-hci.yaml b/dts/bindings/bluetooth/espressif,esp32-bt-hci.yaml index e095fcd9510a4c..47c62eeaab40c1 100644 --- a/dts/bindings/bluetooth/espressif,esp32-bt-hci.yaml +++ b/dts/bindings/bluetooth/espressif,esp32-bt-hci.yaml @@ -8,6 +8,6 @@ properties: bt-hci-name: default: "BT ESP32" bt-hci-bus: - default: "BT_HCI_BUS_IPM" + default: "ipm" bt-hci-quirks: - default: ["BT_HCI_QUIRK_NO_AUTO_DLE"] + default: ["no-auto-dle"] diff --git a/dts/bindings/bluetooth/infineon,cat1-bless-hci.yaml b/dts/bindings/bluetooth/infineon,cat1-bless-hci.yaml index 80671e581350eb..1d221144eb6b92 100644 --- a/dts/bindings/bluetooth/infineon,cat1-bless-hci.yaml +++ b/dts/bindings/bluetooth/infineon,cat1-bless-hci.yaml @@ -14,8 +14,8 @@ properties: bt-hci-name: default: "PSoC 6 BLESS" bt-hci-bus: - default: "BT_HCI_BUS_VIRTUAL" + default: "virtual" bt-hci-quirks: - default: ["BT_HCI_QUIRK_NO_RESET"] + default: ["no-reset"] interrupts: required: true diff --git a/dts/bindings/bluetooth/infineon,cyw208xx-hci.yaml b/dts/bindings/bluetooth/infineon,cyw208xx-hci.yaml index be3cb559be4b3b..96b6ceea99bcd1 100644 --- a/dts/bindings/bluetooth/infineon,cyw208xx-hci.yaml +++ b/dts/bindings/bluetooth/infineon,cyw208xx-hci.yaml @@ -18,4 +18,4 @@ properties: bt-hci-name: default: "CYW208XX" bt-hci-bus: - default: "BT_HCI_BUS_VIRTUAL" + default: "virtual" diff --git a/dts/bindings/bluetooth/nxp,hci-ble.yaml b/dts/bindings/bluetooth/nxp,hci-ble.yaml index f2c05c2fda1d9c..f6994ebbb212bb 100644 --- a/dts/bindings/bluetooth/nxp,hci-ble.yaml +++ b/dts/bindings/bluetooth/nxp,hci-ble.yaml @@ -13,4 +13,4 @@ properties: bt-hci-name: default: "BT NXP" bt-hci-bus: - default: "BT_HCI_BUS_IPM" + default: "ipm" diff --git a/dts/bindings/bluetooth/renesas,bt-hci-da1469x.yaml b/dts/bindings/bluetooth/renesas,bt-hci-da1469x.yaml index cd66b0119538b7..088a1f58f7b799 100644 --- a/dts/bindings/bluetooth/renesas,bt-hci-da1469x.yaml +++ b/dts/bindings/bluetooth/renesas,bt-hci-da1469x.yaml @@ -8,4 +8,4 @@ properties: bt-hci-name: default: "BT DA1469x" bt-hci-bus: - default: "BT_HCI_BUS_IPM" + default: "ipm" diff --git a/dts/bindings/bluetooth/silabs,bt-hci.yaml b/dts/bindings/bluetooth/silabs,bt-hci.yaml index 9dc5b67947c581..d14f2d549685f8 100644 --- a/dts/bindings/bluetooth/silabs,bt-hci.yaml +++ b/dts/bindings/bluetooth/silabs,bt-hci.yaml @@ -8,6 +8,6 @@ properties: bt-hci-name: default: "sl:bt" bt-hci-bus: - default: "BT_HCI_BUS_VIRTUAL" + default: "virtual" bt-hci-quirks: - default: ["BT_HCI_QUIRK_NO_RESET"] + default: ["no-reset"] diff --git a/dts/bindings/bluetooth/st,hci-spi-v1.yaml b/dts/bindings/bluetooth/st,hci-spi-v1.yaml index 020a796af85f0c..4a316dd47cc040 100644 --- a/dts/bindings/bluetooth/st,hci-spi-v1.yaml +++ b/dts/bindings/bluetooth/st,hci-spi-v1.yaml @@ -9,4 +9,4 @@ include: zephyr,bt-hci-spi.yaml properties: bt-hci-quirks: - default: ["BT_HCI_QUIRK_NO_RESET"] + default: ["no-reset"] diff --git a/dts/bindings/bluetooth/st,hci-spi-v2.yaml b/dts/bindings/bluetooth/st,hci-spi-v2.yaml index 97b62dc90bd82d..1d480a8333940c 100644 --- a/dts/bindings/bluetooth/st,hci-spi-v2.yaml +++ b/dts/bindings/bluetooth/st,hci-spi-v2.yaml @@ -9,4 +9,4 @@ include: zephyr,bt-hci-spi.yaml properties: bt-hci-quirks: - default: ["BT_HCI_QUIRK_NO_RESET"] + default: ["no-reset"] diff --git a/dts/bindings/bluetooth/st,hci-stm32wba.yaml b/dts/bindings/bluetooth/st,hci-stm32wba.yaml index ea7c8dbbcc7358..6b4fcc036d032b 100644 --- a/dts/bindings/bluetooth/st,hci-stm32wba.yaml +++ b/dts/bindings/bluetooth/st,hci-stm32wba.yaml @@ -8,4 +8,4 @@ properties: bt-hci-name: default: "BT IPM" bt-hci-bus: - default: "BT_HCI_BUS_IPM" + default: "ipm" diff --git a/dts/bindings/bluetooth/st,stm32wb-ble-rf.yaml b/dts/bindings/bluetooth/st,stm32wb-ble-rf.yaml index f1903de684000b..88964fb1416d2c 100644 --- a/dts/bindings/bluetooth/st,stm32wb-ble-rf.yaml +++ b/dts/bindings/bluetooth/st,stm32wb-ble-rf.yaml @@ -14,4 +14,4 @@ properties: bt-hci-name: default: "BT IPM" bt-hci-bus: - default: "BT_HCI_BUS_IPM" + default: "ipm" diff --git a/dts/bindings/bluetooth/zephyr,bt-hci-3wire-uart.yaml b/dts/bindings/bluetooth/zephyr,bt-hci-3wire-uart.yaml index d2a5f62c2137d2..7c734d794ae827 100644 --- a/dts/bindings/bluetooth/zephyr,bt-hci-3wire-uart.yaml +++ b/dts/bindings/bluetooth/zephyr,bt-hci-3wire-uart.yaml @@ -10,4 +10,4 @@ properties: bt-hci-name: default: "H:5" bt-hci-bus: - default: "BT_HCI_BUS_UART" + default: "uart" diff --git a/dts/bindings/bluetooth/zephyr,bt-hci-ipc.yaml b/dts/bindings/bluetooth/zephyr,bt-hci-ipc.yaml index 88780827ce47e2..ee1f8e76c3b17b 100644 --- a/dts/bindings/bluetooth/zephyr,bt-hci-ipc.yaml +++ b/dts/bindings/bluetooth/zephyr,bt-hci-ipc.yaml @@ -8,9 +8,9 @@ properties: bt-hci-name: default: "IPC" bt-hci-bus: - default: "BT_HCI_BUS_IPM" + default: "ipm" bt-hci-quirks: - default: ["BT_HCI_QUIRK_NO_AUTO_DLE"] + default: ["no-auto-dle"] bt-hci-ipc-name: type: string default: "nrf_bt_hci" diff --git a/dts/bindings/bluetooth/zephyr,bt-hci-ll-sw-split.yaml b/dts/bindings/bluetooth/zephyr,bt-hci-ll-sw-split.yaml index f53cf49e90e053..6995f88b20f5c0 100644 --- a/dts/bindings/bluetooth/zephyr,bt-hci-ll-sw-split.yaml +++ b/dts/bindings/bluetooth/zephyr,bt-hci-ll-sw-split.yaml @@ -8,6 +8,6 @@ properties: bt-hci-name: default: "Controller" bt-hci-bus: - default: "BT_HCI_BUS_VIRTUAL" + default: "virtual" bt-hci-quirks: - default: ["BT_HCI_QUIRK_NO_AUTO_DLE"] + default: ["no-auto-dle"] diff --git a/dts/bindings/bluetooth/zephyr,bt-hci-spi.yaml b/dts/bindings/bluetooth/zephyr,bt-hci-spi.yaml index 0447e69d5f19f0..8d835f8d419087 100644 --- a/dts/bindings/bluetooth/zephyr,bt-hci-spi.yaml +++ b/dts/bindings/bluetooth/zephyr,bt-hci-spi.yaml @@ -40,4 +40,4 @@ properties: default: "SPI" bt-hci-bus: - default: "BT_HCI_BUS_SPI" + default: "spi" diff --git a/dts/bindings/bluetooth/zephyr,bt-hci-uart.yaml b/dts/bindings/bluetooth/zephyr,bt-hci-uart.yaml index d14f8e3035648e..794fbc9c8af995 100644 --- a/dts/bindings/bluetooth/zephyr,bt-hci-uart.yaml +++ b/dts/bindings/bluetooth/zephyr,bt-hci-uart.yaml @@ -10,4 +10,4 @@ properties: bt-hci-name: default: "H:4" bt-hci-bus: - default: "BT_HCI_BUS_UART" + default: "uart" diff --git a/dts/bindings/bluetooth/zephyr,bt-hci-userchan.yaml b/dts/bindings/bluetooth/zephyr,bt-hci-userchan.yaml index 124a2983532750..ad43d73ecaec0e 100644 --- a/dts/bindings/bluetooth/zephyr,bt-hci-userchan.yaml +++ b/dts/bindings/bluetooth/zephyr,bt-hci-userchan.yaml @@ -8,4 +8,4 @@ properties: bt-hci-name: default: "HCI User Channel" bt-hci-bus: - default: "BT_HCI_BUS_UART" + default: "uart" diff --git a/include/zephyr/drivers/bluetooth.h b/include/zephyr/drivers/bluetooth.h index 22b3392baf5e76..f06481948efe95 100644 --- a/include/zephyr/drivers/bluetooth.h +++ b/include/zephyr/drivers/bluetooth.h @@ -72,7 +72,8 @@ enum bt_hci_bus { BT_HCI_BUS_IPM = 9, }; -#define BT_DT_HCI_QUIRK_OR(node_id, prop, idx) DT_STRING_TOKEN_BY_IDX(node_id, prop, idx) +#define BT_DT_HCI_QUIRK_OR(node_id, prop, idx) \ + UTIL_CAT(BT_HCI_QUIRK_, DT_STRING_UPPER_TOKEN_BY_IDX(node_id, prop, idx)) #define BT_DT_HCI_QUIRKS_GET(node_id) COND_CODE_1(DT_NODE_HAS_PROP(node_id, bt_hci_quirks), \ (DT_FOREACH_PROP_ELEM_SEP(node_id, \ bt_hci_quirks, \ @@ -84,7 +85,8 @@ enum bt_hci_bus { #define BT_DT_HCI_NAME_GET(node_id) DT_PROP_OR(node_id, bt_hci_name, "HCI") #define BT_DT_HCI_NAME_INST_GET(inst) BT_DT_HCI_NAME_GET(DT_DRV_INST(inst)) -#define BT_DT_HCI_BUS_GET(node_id) DT_STRING_TOKEN_OR(node_id, bt_hci_bus, BT_HCI_BUS_VIRTUAL) +#define BT_DT_HCI_BUS_GET(node_id) \ + UTIL_CAT(BT_HCI_BUS_, DT_STRING_UPPER_TOKEN_OR(node_id, bt_hci_bus, VIRTUAL)) #define BT_DT_HCI_BUS_INST_GET(inst) BT_DT_HCI_BUS_GET(DT_DRV_INST(inst)) typedef int (*bt_hci_recv_t)(const struct device *dev, struct net_buf *buf); diff --git a/tests/bluetooth/bluetooth/dts/bindings/zephyr,bt-hci-test.yaml b/tests/bluetooth/bluetooth/dts/bindings/zephyr,bt-hci-test.yaml index cd5c0ecd760741..e2f22bfbd5ba70 100644 --- a/tests/bluetooth/bluetooth/dts/bindings/zephyr,bt-hci-test.yaml +++ b/tests/bluetooth/bluetooth/dts/bindings/zephyr,bt-hci-test.yaml @@ -8,4 +8,4 @@ properties: bt-hci-name: default: "test" bt-hci-bus: - default: "BT_HCI_BUS_VIRTUAL" + default: "virtual" diff --git a/tests/bluetooth/hci_prop_evt/dts/bindings/zephyr,bt-hci-test.yaml b/tests/bluetooth/hci_prop_evt/dts/bindings/zephyr,bt-hci-test.yaml index 7d8adacc908066..2854c38ae64c87 100644 --- a/tests/bluetooth/hci_prop_evt/dts/bindings/zephyr,bt-hci-test.yaml +++ b/tests/bluetooth/hci_prop_evt/dts/bindings/zephyr,bt-hci-test.yaml @@ -8,6 +8,6 @@ properties: bt-hci-name: default: "test" bt-hci-bus: - default: "BT_HCI_BUS_VIRTUAL" + default: "virtual" bt-hci-quirks: - default: ["BT_HCI_QUIRK_NO_RESET"] + default: ["no-reset"] diff --git a/tests/bluetooth/hci_uart_async/dts/bindings/zephyr,bt-hci-test.yaml b/tests/bluetooth/hci_uart_async/dts/bindings/zephyr,bt-hci-test.yaml index 893e6a78cdc23d..4c689a6472a143 100644 --- a/tests/bluetooth/hci_uart_async/dts/bindings/zephyr,bt-hci-test.yaml +++ b/tests/bluetooth/hci_uart_async/dts/bindings/zephyr,bt-hci-test.yaml @@ -8,4 +8,4 @@ properties: bt-hci-name: default: "Mock Controller" bt-hci-bus: - default: "BT_HCI_BUS_VIRTUAL" + default: "virtual" diff --git a/tests/bluetooth/host_long_adv_recv/dts/bindings/zephyr,bt-hci-test.yaml b/tests/bluetooth/host_long_adv_recv/dts/bindings/zephyr,bt-hci-test.yaml index 7d8adacc908066..2854c38ae64c87 100644 --- a/tests/bluetooth/host_long_adv_recv/dts/bindings/zephyr,bt-hci-test.yaml +++ b/tests/bluetooth/host_long_adv_recv/dts/bindings/zephyr,bt-hci-test.yaml @@ -8,6 +8,6 @@ properties: bt-hci-name: default: "test" bt-hci-bus: - default: "BT_HCI_BUS_VIRTUAL" + default: "virtual" bt-hci-quirks: - default: ["BT_HCI_QUIRK_NO_RESET"] + default: ["no-reset"] From 255e518bbab598d042271e4a6ea59d493e870330 Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Tue, 15 Oct 2024 18:48:04 +0300 Subject: [PATCH 2/2] doc: migration-guide-4.0: Add a note about updated HCI DT properties Add a note for the updated bt-hci-quirks and bt-hci-bus DT properties. Signed-off-by: Johan Hedberg --- doc/releases/migration-guide-4.0.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/releases/migration-guide-4.0.rst b/doc/releases/migration-guide-4.0.rst index 6c0f35ac5d4374..4b813ae336afbc 100644 --- a/doc/releases/migration-guide-4.0.rst +++ b/doc/releases/migration-guide-4.0.rst @@ -309,6 +309,9 @@ Bluetooth Bluetooth HCI ============= +* The ``bt-hci-bus`` and ``bt-hci-quirks`` devicetree properties for HCI bindings have been changed + to use lower-case strings without the ``BT_HCI_QUIRK_`` and ``BT_HCI_BUS_`` prefixes. + Bluetooth Mesh ==============