diff --git a/boards/arm/96b_carbon/96b_carbon.dts b/boards/arm/96b_carbon/96b_carbon.dts index 7426cab5ee8..cc612086ec4 100644 --- a/boards/arm/96b_carbon/96b_carbon.dts +++ b/boards/arm/96b_carbon/96b_carbon.dts @@ -48,7 +48,6 @@ led1 = &green_led_2; led2 = &bt_blue_led; sw0 = &user_button; - bt = &bt0; }; }; @@ -87,7 +86,7 @@ status = "ok"; /* Nordic nRF51822-QFAC */ - bt0: bt-hci@0 { + bt-hci@0 { compatible = "zephyr,bt-hci-spi"; reg = <0>; reset-gpios = <&gpiob 4 0>; diff --git a/boards/arm/96b_carbon/dts_fixup.h b/boards/arm/96b_carbon/dts_fixup.h deleted file mode 100644 index c1d0ded8af6..00000000000 --- a/boards/arm/96b_carbon/dts_fixup.h +++ /dev/null @@ -1,12 +0,0 @@ -/* This file is a temporary workaround for mapping of the generated information - * to the current driver definitions. This will be removed when the drivers - * are modified to handle the generated information, or the mapping of - * generated data matches the driver definitions. - */ - -#define CONFIG_BT_SPI_IRQ_DEV_NAME BT_IRQ_GPIOS_CONTROLLER -#define CONFIG_BT_SPI_IRQ_PIN BT_IRQ_GPIOS_PIN -#define CONFIG_BT_SPI_RESET_DEV_NAME BT_RESET_GPIOS_CONTROLLER -#define CONFIG_BT_SPI_RESET_PIN BT_RESET_GPIOS_PIN -#define CONFIG_BT_SPI_DEV_NAME DT_ST_STM32_SPI_40013000_ZEPHYR_BT_HCI_SPI_0_BUS_NAME -#define CONFIG_BT_SPI_MAX_CLK_FREQ DT_ST_STM32_SPI_40013000_ZEPHYR_BT_HCI_SPI_0_SPI_MAX_FREQUENCY diff --git a/boards/arm/disco_l475_iot1/disco_l475_iot1.dts b/boards/arm/disco_l475_iot1/disco_l475_iot1.dts index 30fa601786c..c492d769bf4 100644 --- a/boards/arm/disco_l475_iot1/disco_l475_iot1.dts +++ b/boards/arm/disco_l475_iot1/disco_l475_iot1.dts @@ -43,7 +43,6 @@ led0 = &green_led_2; led1 = &green_led_1; sw0 = &user_button; - bt = &bt0; eswifi0 = &wifi0; }; }; @@ -123,8 +122,8 @@ arduino_serial: &uart4 {}; cs-gpios = <&gpiod 13 0>, <&gpioe 0 0>; - bt0: spbtle-rf@0 { - compatible = "st,spbtle-rf"; + spbtle-rf@0 { + compatible = "zephyr,bt-hci-spi"; reg = <0>; reset-gpios = <&gpioa 8 0>; irq-gpios = <&gpioe 6 0>; diff --git a/boards/arm/disco_l475_iot1/dts_fixup.h b/boards/arm/disco_l475_iot1/dts_fixup.h deleted file mode 100644 index c9bb2aeccf7..00000000000 --- a/boards/arm/disco_l475_iot1/dts_fixup.h +++ /dev/null @@ -1,15 +0,0 @@ -/* This file is a temporary workaround for mapping of the generated information - * to the current driver definitions. This will be removed when the drivers - * are modified to handle the generated information, or the mapping of - * generated data matches the driver definitions. - */ - -#define CONFIG_BT_SPI_DEV_NAME DT_ST_STM32_SPI_FIFO_40003C00_ST_SPBTLE_RF_0_BUS_NAME -#define CONFIG_BT_SPI_MAX_CLK_FREQ DT_ST_STM32_SPI_FIFO_40003C00_ST_SPBTLE_RF_0_SPI_MAX_FREQUENCY - -#define CONFIG_BT_SPI_IRQ_DEV_NAME BT_IRQ_GPIOS_CONTROLLER -#define CONFIG_BT_SPI_IRQ_PIN BT_IRQ_GPIOS_PIN -#define CONFIG_BT_SPI_CHIP_SELECT_DEV_NAME DT_ST_STM32_SPI_FIFO_40003C00_CS_GPIOS_CONTROLLER_0 -#define CONFIG_BT_SPI_CHIP_SELECT_PIN DT_ST_STM32_SPI_FIFO_40003C00_CS_GPIOS_PIN_0 -#define CONFIG_BT_SPI_RESET_DEV_NAME BT_RESET_GPIOS_CONTROLLER -#define CONFIG_BT_SPI_RESET_PIN BT_RESET_GPIOS_PIN diff --git a/drivers/bluetooth/hci/Kconfig b/drivers/bluetooth/hci/Kconfig index 4bfa24f8a5d..7a218e7b956 100644 --- a/drivers/bluetooth/hci/Kconfig +++ b/drivers/bluetooth/hci/Kconfig @@ -72,17 +72,6 @@ config BT_UART_ON_DEV_NAME for Bluetooth. endif -config BT_SPI_DEV_NAME - string "Device Name of SPI Device for Bluetooth" - default "SPI_0" - depends on BT_SPI && !HAS_DTS_SPI - help - This option specifies the name of SPI device to be used for Bluetooth. - On the controller side, this SPI device is used to encapsulate the - RAW HCI frames to send further up the stack. On the BLE stack side, - this device is used to reply back with HCI frames that are sent over - the air. - if BT_SPI config BT_BLUENRG_ACI @@ -97,52 +86,4 @@ config BT_SPI_BLUENRG Enable support for devices compatible with the BlueNRG Bluetooth Stack. Current driver supports: ST BLUENRG-MS. -if !HAS_DTS_SPI - -config BT_SPI_CHIP_SELECT_DEV_NAME - string "Chip Select (CS) line driver name" - depends on BT_SPI_BLUENRG - help - This option specifies the name of GPIO driver controlling - the Chip Select (CS) line. - -config BT_SPI_IRQ_DEV_NAME - string "IRQ line driver name" - help - This option specifies the name of GPIO driver controlling - the chip's IRQ line. - -config BT_SPI_RESET_DEV_NAME - string "Reset line driver name" - help - This option specifies the name of GPIO driver controlling - the chip's Reset line. - -config BT_SPI_CHIP_SELECT_PIN - int "SPI Chip Select (CS) line number" - depends on BT_SPI_BLUENRG - help - This option specifies the Chip Select (CS) line number on the SPI - device - -config BT_SPI_IRQ_PIN - int "SPI IRQ line number" - help - This option specifies the IRQ line number on the SPI device - -config BT_SPI_RESET_PIN - int "SPI Reset line number" - help - This option specifies the Reset line number on the SPI device - -endif # !HAS_DTS_SPI - -config BT_SPI_MAX_CLK_FREQ - int "Maximum clock frequency for the HCI SPI interface" - default 5000000 - depends on !HAS_DTS_SPI - help - This option specifies the maximum clock rate the HCI SPI - interface is capable of running at. - endif # BT_SPI diff --git a/drivers/bluetooth/hci/spi.c b/drivers/bluetooth/hci/spi.c index 9dba93bf906..70a92bd6d9c 100644 --- a/drivers/bluetooth/hci/spi.c +++ b/drivers/bluetooth/hci/spi.c @@ -45,11 +45,11 @@ #define CMD_OGF 1 #define CMD_OCF 2 -#define GPIO_IRQ_PIN CONFIG_BT_SPI_IRQ_PIN -#define GPIO_RESET_PIN CONFIG_BT_SPI_RESET_PIN -#if defined(CONFIG_BT_SPI_BLUENRG) -#define GPIO_CS_PIN CONFIG_BT_SPI_CHIP_SELECT_PIN -#endif /* CONFIG_BT_SPI_BLUENRG */ +#define GPIO_IRQ_PIN DT_ZEPHYR_BT_HCI_SPI_0_IRQ_GPIO_PIN +#define GPIO_RESET_PIN DT_ZEPHYR_BT_HCI_SPI_0_RESET_GPIO_PIN +#ifdef DT_ZEPHYR_BT_HCI_SPI_0_CS_GPIO_PIN +#define GPIO_CS_PIN DT_ZEPHYR_BT_HCI_SPI_0_CS_GPIO_PIN +#endif /* DT_ZEPHYR_BT_HCI_SPI_0_CS_GPIO_PIN */ /* Max SPI buffer length for transceive operations. * @@ -124,7 +124,7 @@ static int bt_spi_send_aci_config_data_controller_mode(void); static struct device *spi_dev; static struct spi_config spi_conf = { - .frequency = CONFIG_BT_SPI_MAX_CLK_FREQ, + .frequency = DT_ZEPHYR_BT_HCI_SPI_0_SPI_MAX_FREQUENCY, .operation = (SPI_OP_MODE_MASTER | SPI_TRANSFER_MSB | SPI_WORD_SET(8) | SPI_LINES_SINGLE), .slave = 0, @@ -194,10 +194,10 @@ static void bt_spi_handle_vendor_evt(u8_t *rxmsg) */ static int configure_cs(void) { - cs_dev = device_get_binding(CONFIG_BT_SPI_CHIP_SELECT_DEV_NAME); + cs_dev = device_get_binding(DT_ZEPHYR_BT_HCI_SPI_0_CS_GPIO_CONTROLLER); if (!cs_dev) { BT_ERR("Failed to initialize GPIO driver: %s", - CONFIG_BT_SPI_CHIP_SELECT_DEV_NAME); + DT_ZEPHYR_BT_HCI_SPI_0_CS_GPIO_CONTROLLER); return -EIO; } @@ -246,13 +246,33 @@ static bool exit_irq_high_loop(void) } #else -#define configure_cs(...) 0 + +static int configure_cs(void) +{ +#ifdef GPIO_CS_PIN + static struct spi_cs_control spi_conf_cs; + + spi_conf_cs.gpio_pin = GPIO_CS_PIN, + spi_conf_cs.gpio_dev = device_get_binding( + DT_ZEPHYR_BT_HCI_SPI_0_CS_GPIO_CONTROLLER); + if (!spi_conf_cs.gpio_dev) { + BT_ERR("Failed to initialize GPIO driver: %s", + DT_ZEPHYR_BT_HCI_SPI_0_CS_GPIO_CONTROLLER); + return -EIO; + } + + spi_conf.cs = &spi_conf_cs; +#endif /* GPIO_CS_PIN */ + + return 0; +} #define kick_cs(...) #define release_cs(...) #define irq_pin_high(...) 0 #define init_irq_high_loop(...) #define exit_irq_high_loop(...) 1 -#endif + +#endif /* CONFIG_BT_SPI_BLUENRG */ #if defined(CONFIG_BT_BLUENRG_ACI) static int bt_spi_send_aci_config_data_controller_mode(void) @@ -500,7 +520,7 @@ static int bt_spi_open(void) } static const struct bt_hci_driver drv = { - .name = "BT SPI", + .name = DT_ZEPHYR_BT_HCI_SPI_0_LABEL, .bus = BT_HCI_DRIVER_BUS_SPI, #if defined(CONFIG_BT_BLUENRG_ACI) .quirks = BT_QUIRK_NO_RESET, @@ -513,10 +533,10 @@ static int _bt_spi_init(struct device *unused) { ARG_UNUSED(unused); - spi_dev = device_get_binding(CONFIG_BT_SPI_DEV_NAME); + spi_dev = device_get_binding(DT_ZEPHYR_BT_HCI_SPI_0_BUS_NAME); if (!spi_dev) { BT_ERR("Failed to initialize SPI driver: %s", - CONFIG_BT_SPI_DEV_NAME); + DT_ZEPHYR_BT_HCI_SPI_0_BUS_NAME); return -EIO; } @@ -524,17 +544,19 @@ static int _bt_spi_init(struct device *unused) return -EIO; } - irq_dev = device_get_binding(CONFIG_BT_SPI_IRQ_DEV_NAME); + irq_dev = device_get_binding( + DT_ZEPHYR_BT_HCI_SPI_0_IRQ_GPIO_CONTROLLER); if (!irq_dev) { BT_ERR("Failed to initialize GPIO driver: %s", - CONFIG_BT_SPI_IRQ_DEV_NAME); + DT_ZEPHYR_BT_HCI_SPI_0_IRQ_GPIO_CONTROLLER); return -EIO; } - rst_dev = device_get_binding(CONFIG_BT_SPI_RESET_DEV_NAME); + rst_dev = device_get_binding( + DT_ZEPHYR_BT_HCI_SPI_0_RESET_GPIO_CONTROLLER); if (!rst_dev) { BT_ERR("Failed to initialize GPIO driver: %s", - CONFIG_BT_SPI_RESET_DEV_NAME); + DT_ZEPHYR_BT_HCI_SPI_0_RESET_GPIO_CONTROLLER); return -EIO; } diff --git a/dts/bindings/bluetooth/st,spbtle-rf.yaml b/dts/bindings/bluetooth/st,spbtle-rf.yaml deleted file mode 100644 index 1530529d56b..00000000000 --- a/dts/bindings/bluetooth/st,spbtle-rf.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright (c) 2018, I-SENSE group of ICCS -# -# SPDX-License-Identifier: Apache-2.0 -# ---- -title: STMicroelectronics SPBTLE-RF bluetooth module -version: 0.1 - -description: > - This binding gives the base representation of SPBTLE-RF bluetooth module - -inherits: - !include spi-device.yaml - -properties: - compatible: - constraint: "st,spbtle-rf" - - irq-gpios: - type: compound - category: required - generation: define, use-prop-name - - reset-gpios: - type: compound - category: required - generation: define, use-prop-name -... diff --git a/dts/bindings/bluetooth/zephyr,bt-hci-spi.yaml b/dts/bindings/bluetooth/zephyr,bt-hci-spi.yaml index 265069ebac7..2e04de28333 100644 --- a/dts/bindings/bluetooth/zephyr,bt-hci-spi.yaml +++ b/dts/bindings/bluetooth/zephyr,bt-hci-spi.yaml @@ -21,11 +21,10 @@ properties: irq-gpios: type: compound category: required - generation: define, use-prop-name + generation: define reset-gpios: type: compound category: required - generation: define, use-prop-name - + generation: define ...