# Bluetooth drivers configuration options

# Copyright (c) 2016 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

comment "Bluetooth HCI Driver Options"

config BT_UART
	bool
	select SERIAL
	select UART_INTERRUPT_DRIVEN

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.

config BT_H5
	bool "H:5 UART [EXPERIMENTAL]"
	select BT_UART
	select EXPERIMENTAL
	default y
	depends on DT_HAS_ZEPHYR_BT_HCI_3WIRE_UART_ENABLED
	help
	  Bluetooth three-wire (H:5) UART driver. Implementation of HCI
	  Three-Wire UART Transport Layer.

config BT_HCI_IPC
	bool
	default y
	depends on DT_HAS_ZEPHYR_BT_HCI_IPC_ENABLED
	select BT_HAS_HCI_VS
	select IPC_SERVICE
	select MBOX
	help
	  Bluetooth HCI driver for communication with another CPU
	  using the IPC subsystem.

config BT_HCI_IPC_SEND_RETRY_COUNT
	int "HCI IPC send retry count"
	depends on BT_HCI_IPC
	default 3
	help
	  Number of times to retry sending a message via IPC.
	  The retries occur in case of a failure to send a message
	  through IPC (-ENOMEM returned by ipc_service_send).

config BT_HCI_IPC_SEND_RETRY_DELAY_US
	int "HCI IPC send retry delay (us)"
	depends on BT_HCI_IPC
	default 75
	help
	  Delay in microseconds between retries when sending a message via IPC.
	  When a single tick (CONFIG_SYS_CLOCK_TICKS_PER_SEC) is bigger then
	  the retry delay the k_busy_wait function is used. Set with care.

config BT_HCI_IPC_ENDPOINT_BOUND_TIMEOUT_MS
	int "HCI IPC binding timeout value in milliseconds"
	depends on BT_HCI_IPC
	default 2000
	help
	  Timeout value that HCI will wait for an IPC endpoint to be bound,
	  in milliseconds.

config BT_SPI
	bool
	select SPI
	help
	  Supports Bluetooth ICs using SPI as the communication protocol.
	  HCI packets are sent and received as single Byte transfers,
	  prepended after a known header. Headers may vary per device, so
	  additional platform specific knowledge may need to be added as
	  devices are.

config BT_SPI_INIT_PRIORITY
	int "BT SPI init priority"
	depends on BT_SPI
	default 75

config BT_SPI_BOOT_TIMEOUT_SEC
	int "Seconds to wait for SPI device to report ready"
	depends on BT_SPI_ZEPHYR || BT_SPI_BLUENRG
	default 30
	help
	  Maximum duration for a HCI SPI Controller to report ready through the
	  Zephyr Project defined `EVT_BLUE_INITIALIZED` HCI vendor event.
	  Default is 30 seconds to support a bootloader image swap on the
	  Controller.

config BT_SPI_ZEPHYR
	bool
	default y
	depends on DT_HAS_ZEPHYR_BT_HCI_SPI_ENABLED
	select BT_SPI
	help
	  Bluetooth HCI over SPI driver for communication with Bluetooth
	  controllers running Zephyr.

config BT_SPI_BLUENRG
	bool
	default y
	depends on DT_HAS_ST_HCI_SPI_V1_ENABLED || DT_HAS_ST_HCI_SPI_V2_ENABLED
	select BT_SPI
	help
	  Bluetooth HCI over SPI driver for communication with
	  STMicroelectronics BlueNRG devices.

config BT_BLUENRG_ACI
	bool "ACI message with BlueNRG-based devices"
	depends on BT_SPI_BLUENRG
	select BT_HCI_SET_PUBLIC_ADDR
	help
	  Enable support for devices compatible with the BlueNRG Bluetooth
	  Stack. Current driver supports: ST BLUENRG-MS.

config BT_STM32_IPM
	bool
	default y
	depends on DT_HAS_ST_STM32WB_RF_ENABLED
	select USE_STM32_HAL_CORTEX
	select HAS_STM32LIB
	select BT_HCI_SETUP
	help
	  TODO

config BT_STM32WBA
	bool
	default y
	depends on DT_HAS_ST_HCI_STM32WBA_ENABLED
	depends on ZEPHYR_HAL_STM32_MODULE_BLOBS
	select HAS_STM32LIB
	select BT_HCI_SET_PUBLIC_ADDR if !BT_HCI_RAW
	help
	  ST STM32WBA HCI Bluetooth interface

config BT_STM32WB0
	bool "STM32WB0 HCI driver"
	default y
	depends on DT_HAS_ST_HCI_STM32WB0_ENABLED
	depends on ZEPHYR_HAL_STM32_MODULE_BLOBS
	select HAS_STM32LIB
	select USE_STM32_HAL_PKA
	select USE_STM32_HAL_CORTEX
	select USE_STM32_HAL_GPIO
	select USE_STM32_HAL_RADIO
	select USE_STM32_HAL_RADIO_TIMER
	help
	  ST STM32WB0 HCI Bluetooth interface

config BT_SILABS_EFR32
	bool "Silabs EFR32 HCI driver"
	default y
	depends on DT_HAS_SILABS_BT_HCI_EFR32_ENABLED
	depends on ZEPHYR_HAL_SILABS_MODULE_BLOBS || BUILD_ONLY_NO_BLOBS
	depends on SOC_GECKO_HAS_RADIO
	select SOC_GECKO_USE_RAIL
	select PSA_CRYPTO
	select SILABS_SISDK_PROTOCOL_CRYPTO
	select HAS_BT_CTLR
	select BT_CTLR_PHY_UPDATE_SUPPORT
	select BT_CTLR_PER_INIT_FEAT_XCHG_SUPPORT
	select BT_CTLR_DATA_LEN_UPDATE_SUPPORT
	select BT_CTLR_EXT_REJ_IND_SUPPORT
	select BT_CTLR_CHAN_SEL_2_SUPPORT
	select BT_CTLR_CONN_RSSI_SUPPORT
	select BT_CTLR_ADV_EXT_SUPPORT
	select BT_CTLR_PRIVACY_SUPPORT
	select BT_CTLR_PHY_2M_SUPPORT
	select BT_CTLR_SYNC_PERIODIC_SUPPORT
	select BT_CTLR_SYNC_TRANSFER_RECEIVER_SUPPORT
	select BT_CTLR_SYNC_TRANSFER_SENDER_SUPPORT
	help
	  Use Silicon Labs binary Bluetooth library to connect to the
	  controller.

source "drivers/bluetooth/hci/Kconfig.silabs"

config BT_SILABS_SIWX91X
	bool "Silabs SiWx91x Bluetooth interface"
	default y
	depends on DT_HAS_SILABS_SIWX91X_BT_HCI_ENABLED
	select SILABS_SIWX91X_NWP
	select ENTROPY_GENERATOR
	select BT_HCI_SETUP
	help
	  Use Silicon Labs Wiseconnect 3.x Bluetooth library to connect to the controller.

	# SiWx917 BLE controller currently does not support HCI Command: Host Number of Completed Packets
	configdefault BT_HCI_ACL_FLOW_CONTROL
		default n if BT_SILABS_SIWX91X

config BT_USERCHAN
	bool
	depends on BOARD_NATIVE_SIM
	default y
	depends on DT_HAS_ZEPHYR_BT_HCI_USERCHAN_ENABLED
	select NATIVE_USE_NSI_ERRNO
	help
	  This driver provides access to the local Linux host's Bluetooth
	  adapter using a User Channel HCI socket to the Linux kernel. It
	  is only intended to be used with the native_sim[//64] build of Zephyr.
	  The Bluetooth adapter must be powered off in order for Zephyr to
	  be able to use it.

config BT_ESP32
	bool
	default y
	depends on DT_HAS_ESPRESSIF_ESP32_BT_HCI_ENABLED
	depends on ZEPHYR_HAL_ESPRESSIF_MODULE_BLOBS || BUILD_ONLY_NO_BLOBS
	select HAS_BT_CTLR
	select BT_CTLR_PRIVACY_SUPPORT
	select BT_CTLR_EXT_SCAN_FP_SUPPORT
	select BT_CTLR_DATA_LEN_UPDATE_SUPPORT
	select BT_CTLR_ADV_EXT_SUPPORT if !SOC_SERIES_ESP32
	select BT_CTLR_PHY_UPDATE_SUPPORT if !SOC_SERIES_ESP32
	select BT_CTLR_EXT_REJ_IND_SUPPORT if !SOC_SERIES_ESP32
	select BT_CTLR_PHY_2M_SUPPORT if !SOC_SERIES_ESP32
	select BT_CTLR_CHAN_SEL_2_SUPPORT if !SOC_SERIES_ESP32
	help
	  Espressif HCI bluetooth interface

config BT_PSOC6_BLESS
	bool
	default y
	depends on DT_HAS_INFINEON_CAT1_BLESS_HCI_ENABLED
	depends on ZEPHYR_HAL_INFINEON_MODULE_BLOBS
	select BT_HCI_SETUP
	help
	  PSOC 6 BLESS driver with BLE Controller which operates in
	  Single CPU mode.

config BT_DA1453X
	bool "DA1453x HCI driver"
	default y
	depends on DT_HAS_RENESAS_BT_HCI_DA1453X_ENABLED
	select GPIO
	help
	  Bluetooth HCI driver for communication with controller
	  running on DA1453x MCU.

config BT_DA1469X
	bool
	default y
	depends on DT_HAS_RENESAS_BT_HCI_DA1469X_ENABLED
	help
	  Bluetooth HCI driver for communication with CMAC core
	  on DA1469x MCU.

config BT_NXP
	bool
	default y
	depends on DT_HAS_NXP_HCI_BLE_ENABLED
	select BT_HCI_SETUP
	select CRC if BT_HCI_SET_PUBLIC_ADDR
	help
	  NXP HCI bluetooth interface

config BT_CYW208XX
	bool
	default y
	depends on DT_HAS_INFINEON_CYW208XX_HCI_ENABLED
	select BT_HCI_SET_PUBLIC_ADDR
	help
	  Infineon CYW208XX HCI bluetooth interface

config BT_AMBIQ_HCI
	bool
	default y
	depends on DT_HAS_AMBIQ_BT_HCI_SPI_ENABLED
	select SPI
	select GPIO if SOC_SERIES_APOLLO4X
	select CLOCK_CONTROL if SOC_SERIES_APOLLO4X
	select BT_HCI_SETUP
	select AMBIQ_COMPONENT_USE_BT
	help
	  Supports Ambiq Bluetooth SoC using SPI as the communication protocol.
	  HCI packets are sent and received as single Byte transfers.

config BT_HCI_INIT_PRIORITY
	int "BT HCI init priority"
	default 75 if BT_AMBIQ_HCI
	default KERNEL_INIT_PRIORITY_DEVICE
	help
	  The priority of BT HCI driver initialization.

config BT_STM32_IPM_RX_STACK_SIZE
	int "STM32 IPM stack size for RX thread"
	depends on BT_STM32_IPM
	default 512

config BT_AIROC
	bool "AIROC BT connectivity"
	default y
	select GPIO                          if BT_H4
	select UART                          if BT_H4
	select UART_USE_RUNTIME_CONFIGURE    if BT_H4
	select BT_HCI_SETUP
	select USE_INFINEON_ABSTRACTION_RTOS if BT_CYW208XX
	select EVENTS                        if BT_CYW208XX
	depends on DT_HAS_INFINEON_CYW43XXX_BT_HCI_ENABLED || DT_HAS_INFINEON_CYW208XX_HCI_ENABLED
	help
	  Infineon's AIROC™ Wi-Fi & combos portfolio integrates
	  IEEE 802.11a/b/g/n/ac/ax Wi-Fi and Bluetooth® 5.2 in a single-chip
	  solution to enable small-form-factor IoT designs.
source "drivers/bluetooth/hci/Kconfig.esp32"
source "drivers/bluetooth/hci/Kconfig.infineon"
source "drivers/bluetooth/hci/Kconfig.nxp"
source "drivers/bluetooth/hci/Kconfig.stm32"

config BT_DRIVER_QUIRK_NO_AUTO_DLE
	bool "Host auto-initiated Data Length Update quirk"
	depends on BT_AUTO_DATA_LEN_UPDATE
	default y if BT_HCI_IPC || BT_ESP32
	help
	  Enable the quirk wherein BT Host stack will auto-initiate Data Length
	  Update procedure for new connections for controllers that do not
	  auto-initiate the procedure if the default data length parameters are
	  not equal to the initial parameters.

	  This has to be enabled when the BLE controller connected is Zephyr
	  open source controller.

config BT_HCI_SET_PUBLIC_ADDR
	bool
	select BT_HCI_SETUP
	help
	  Pass the controller's public address to the HCI driver in setup()

	  This option should be enabled by drivers for controllers that support setting the
	  public identity through vendor-specific commands. They can then implement the
	  setup() HCI driver API function and get the address to set from the public_addr field.

	  From the application side, the public address is set using the first call to
	  bt_id_create(), before calling bt_enable().

config BT_HCI_SETUP
	bool
	help
	  Enable the HCI vendor-specific Setup function.

	  This option has to be enabled when the BT Controller requires execution
	  of the vendor-specific commands sequence to initialize the BT Controller
	  before the BT Host executes a Reset sequence.

	  The user should generally avoid changing it via menuconfig or in
	  configuration files. This option are enabled by the vendor-specific
	  HCI extension, where the Setup function is implemented.

config BT_DRV_TX_STACK_SIZE
	int
	default 256
	help
	  Stack size for the HCI driver's TX thread.

config BT_DRV_RX_STACK_SIZE
	int
	default 640 if (BT_SPI || BT_AMBIQ_HCI)
	default BT_RX_STACK_SIZE if (BT_H4 || BT_HCI_RAW_H4)
	default BT_STM32_IPM_RX_STACK_SIZE if BT_STM32_IPM
	default HCI_NXP_RX_STACK_SIZE if HCI_NXP_RX_THREAD
	default 512
	help
	  Stack size for the HCI driver's RX thread.

config BT_H4_NXP_CTLR
	bool "NXP Bluetooth Controller"
	select GPIO
	depends on BT_H4
	select CRC
	select BT_HCI_SETUP
	default y
	depends on DT_HAS_NXP_BT_HCI_UART_ENABLED
	help
	  Enables support for NXP Bluetooth Controller.
	  More information about NXP Bluetooth products could be found on
	  https://www.nxp.com/products/wireless-connectivity/wi-fi-plus-bluetooth-plus-802-15-4:WIFI-BLUETOOTH

if BT_H4_NXP_CTLR

config BT_H4_NXP_CTLR_WAIT_HDR_SIG_TIMEOUT
	int "Timeout for waiting HDR Signure"
	range 1000 60000
	default 2500
	help
	  Timeout for waiting HDR Signure. Unit is millisecond.

config BT_H4_NXP_CTLR_WAIT_TIME_AFTER_UPLOAD
	int "Waiting time after firmware is uploaded"
	range 1000 5000
	default 1000
	help
	  Waiting time after firmware is uploaded. Unit is millisecond.

config BT_H4_NXP_CTLR_WAIT_TIME_AFTER_BAUDRATE_UPDATE
	int "Waiting time after controller baudrate is updated"
	range 500 5000
	default 500
	help
	  Waiting time after controller baudrate is updated. Unit is millisecond.

endif #BT_H4_NXP_CTLR
