Bluetooth: Rename bt_driver to bt_hci_driver

The bt_driver API was created when Zephyr only had a Bluetooth host
stack, but no controller-side functionality. The only "driver" that
was needed for the host was the HCI driver, and hence "HCI" was
omitted from the name.

With support both for host and controller Zephyr will be getting more
Bluetooth driver types, in particular radio drivers. To prepare for
this, move all HCI drivers to drivers/bluetooth/hci/ and rename the
bt_driver API bt_hci_driver.

Change-Id: I82829da80aa61f26c2bb2005380f1e88d069ac7d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2016-10-27 16:55:01 +03:00
parent d1fe8e0189
commit 6989bf88e1
28 changed files with 170 additions and 168 deletions

View file

@ -74,7 +74,7 @@ Persistent Storage
HCI Drivers
***********
.. doxygengroup:: bt_driver
.. doxygengroup:: bt_hci_driver
:project: Zephyr
:content-only:

View file

@ -24,104 +24,7 @@ if BLUETOOTH
menu "Bluetooth Drivers"
if BLUETOOTH_STACK_HCI || BLUETOOTH_STACK_HCI_RAW
comment "Bluetooth HCI Driver Options"
config BLUETOOTH_UART
bool
default n
choice
prompt "Bluetooth HCI driver"
default BLUETOOTH_H4
config BLUETOOTH_H4
bool "H:4 UART"
select SERIAL
select UART_INTERRUPT_DRIVEN
select BLUETOOTH_UART
select BLUETOOTH_HOST_BUFFERS
help
Bluetooth H:4 UART driver. Requires hardware flow control
lines to be available.
config BLUETOOTH_H5
bool "H:5 UART [EXPERIMENTAL]"
select SERIAL
select UART_INTERRUPT_DRIVEN
select BLUETOOTH_UART
select BLUETOOTH_HOST_BUFFERS
select NANO_WORKQUEUE
select SYSTEM_WORKQUEUE
help
Bluetooth three-wire (H:5) UART driver. Implementation of HCI
Three-Wire UART Transport Layer.
config BLUETOOTH_CONTROLLER
bool "Controller"
select BLUETOOTH_HOST_BUFFERS
help
Enables support for SoC native controller implementation.
config BLUETOOTH_NO_DRIVER
bool "No default HCI driver"
help
This is intended for unit tests where no internal driver
should be selected.
endchoice
config BLUETOOTH_HOST_BUFFERS
bool "Host managed incoming data buffers"
default n
help
Enable this to have the host stack manage incoming ACL data
and HCI event buffers. This makes sense for all HCI drivers
that talk to a controller running on a different CPU.
If the controller resides in the same address space it may
make sense to have the lower layers manage these buffers, in
which case this option can be left disabled.
config BLUETOOTH_DEBUG_DRIVER
bool "Bluetooth driver debug"
depends on BLUETOOTH_DEBUG && (BLUETOOTH_UART || BLUETOOTH_CONTROLLER)
default n
help
This option enables debug support for the chosen
Bluetooth HCI driver
config BLUETOOTH_UART_ON_DEV_NAME
string "Device Name of UART Device for Bluetooth"
default "UART_0"
depends on BLUETOOTH_UART
help
This option specifies the name of UART device to be used
for Bluetooth.
# Headroom that the driver needs for sending and receiving buffers.
# Add a new 'default' entry for each new driver.
# Needed headroom for outgoing buffers (to controller)
config BLUETOOTH_HCI_SEND_RESERVE
int
# Even if no driver is selected the following default is still
# needed e.g. for unit tests.
default 0
default 0 if BLUETOOTH_H4
default 1 if BLUETOOTH_H5
# Needed headroom for incoming buffers (from controller)
config BLUETOOTH_HCI_RECV_RESERVE
int
# Even if no driver is selected the following default is still
# needed e.g. for unit tests.
default 0
default 0 if BLUETOOTH_H4
default 0 if BLUETOOTH_H5
endif # BLUETOOTH_STACK_HCI
source "drivers/bluetooth/hci/Kconfig"
source "drivers/bluetooth/nble/Kconfig"

View file

@ -1,5 +1,4 @@
obj-$(CONFIG_BLUETOOTH_H4) += h4.o
obj-$(CONFIG_BLUETOOTH_H5) += h5.o
obj-y += hci/
obj-$(CONFIG_NBLE) += nble/
obj-$(CONFIG_BLUETOOTH_NRF51_PM) += nrf51_pm.o
obj-$(CONFIG_BLUETOOTH_CONTROLLER) += controller/

View file

@ -32,7 +32,7 @@
#include <bluetooth/bluetooth.h>
#include <bluetooth/log.h>
#include <bluetooth/hci.h>
#include <bluetooth/driver.h>
#include <bluetooth/hci_driver.h>
#include "util/defines.h"
#include "util/work.h"
@ -45,7 +45,7 @@
#include "hal/debug.h"
#if !defined(CONFIG_BLUETOOTH_DEBUG_DRIVER)
#if !defined(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER)
#undef BT_DBG
#define BT_DBG(fmt, ...)
#endif
@ -324,9 +324,9 @@ static int hci_driver_open(void)
return 0;
}
static struct bt_driver drv = {
static struct bt_hci_driver drv = {
.name = "Controller",
.bus = BT_DRIVER_BUS_VIRTUAL,
.bus = BT_HCI_DRIVER_BUS_VIRTUAL,
.open = hci_driver_open,
.send = hci_driver_send,
};
@ -335,7 +335,7 @@ static int _hci_driver_init(struct device *unused)
{
ARG_UNUSED(unused);
bt_driver_register(&drv);
bt_hci_driver_register(&drv);
return 0;
}

View file

@ -0,0 +1,98 @@
if BLUETOOTH_STACK_HCI || BLUETOOTH_STACK_HCI_RAW
comment "Bluetooth HCI Driver Options"
config BLUETOOTH_UART
bool
default n
choice
prompt "Bluetooth HCI driver"
default BLUETOOTH_H4
config BLUETOOTH_H4
bool "H:4 UART"
select SERIAL
select UART_INTERRUPT_DRIVEN
select BLUETOOTH_UART
select BLUETOOTH_HOST_BUFFERS
help
Bluetooth H:4 UART driver. Requires hardware flow control
lines to be available.
config BLUETOOTH_H5
bool "H:5 UART [EXPERIMENTAL]"
select SERIAL
select UART_INTERRUPT_DRIVEN
select BLUETOOTH_UART
select BLUETOOTH_HOST_BUFFERS
select NANO_WORKQUEUE
select SYSTEM_WORKQUEUE
help
Bluetooth three-wire (H:5) UART driver. Implementation of HCI
Three-Wire UART Transport Layer.
config BLUETOOTH_CONTROLLER
bool "Controller"
select BLUETOOTH_HOST_BUFFERS
help
Enables support for SoC native controller implementation.
config BLUETOOTH_NO_DRIVER
bool "No default HCI driver"
help
This is intended for unit tests where no internal driver
should be selected.
endchoice
config BLUETOOTH_HOST_BUFFERS
bool "Host managed incoming data buffers"
default n
help
Enable this to have the host stack manage incoming ACL data
and HCI event buffers. This makes sense for all HCI drivers
that talk to a controller running on a different CPU.
If the controller resides in the same address space it may
make sense to have the lower layers manage these buffers, in
which case this option can be left disabled.
config BLUETOOTH_DEBUG_HCI_DRIVER
bool "Bluetooth HCI driver debug"
depends on BLUETOOTH_DEBUG && (BLUETOOTH_UART || BLUETOOTH_CONTROLLER)
default n
help
This option enables debug support for the chosen
Bluetooth HCI driver
config BLUETOOTH_UART_ON_DEV_NAME
string "Device Name of UART Device for Bluetooth"
default "UART_0"
depends on BLUETOOTH_UART
help
This option specifies the name of UART device to be used
for Bluetooth.
# Headroom that the driver needs for sending and receiving buffers.
# Add a new 'default' entry for each new driver.
# Needed headroom for outgoing buffers (to controller)
config BLUETOOTH_HCI_SEND_RESERVE
int
# Even if no driver is selected the following default is still
# needed e.g. for unit tests.
default 0
default 0 if BLUETOOTH_H4
default 1 if BLUETOOTH_H5
# Needed headroom for incoming buffers (from controller)
config BLUETOOTH_HCI_RECV_RESERVE
int
# Even if no driver is selected the following default is still
# needed e.g. for unit tests.
default 0
default 0 if BLUETOOTH_H4
default 0 if BLUETOOTH_H5
endif # BLUETOOTH_STACK_HCI || BLUETOOTH_STACK_HCI_RAW

View file

@ -0,0 +1,2 @@
obj-$(CONFIG_BLUETOOTH_H4) += h4.o
obj-$(CONFIG_BLUETOOTH_H5) += h5.o

View file

@ -31,17 +31,17 @@
#include <bluetooth/bluetooth.h>
#include <bluetooth/log.h>
#include <bluetooth/hci.h>
#include <bluetooth/driver.h>
#include <bluetooth/hci_driver.h>
#include "util.h"
#include "../util.h"
#if !defined(CONFIG_BLUETOOTH_DEBUG_DRIVER)
#if !defined(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER)
#undef BT_DBG
#define BT_DBG(fmt, ...)
#endif
#if defined(CONFIG_BLUETOOTH_NRF51_PM)
#include "nrf51_pm.h"
#include "../nrf51_pm.h"
#endif
#define H4_CMD 0x01
@ -249,9 +249,9 @@ static int h4_open(void)
return 0;
}
static struct bt_driver drv = {
static struct bt_hci_driver drv = {
.name = "H:4",
.bus = BT_DRIVER_BUS_UART,
.bus = BT_HCI_DRIVER_BUS_UART,
.open = h4_open,
.send = h4_send,
};
@ -265,7 +265,7 @@ static int _bt_uart_init(struct device *unused)
return -EINVAL;
}
bt_driver_register(&drv);
bt_hci_driver_register(&drv);
return 0;
}

View file

@ -33,11 +33,11 @@
#include <bluetooth/bluetooth.h>
#include <bluetooth/log.h>
#include <bluetooth/hci.h>
#include <bluetooth/driver.h>
#include <bluetooth/hci_driver.h>
#include "util.h"
#include "../util.h"
#if !defined(CONFIG_BLUETOOTH_DEBUG_DRIVER)
#if !defined(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER)
#undef BT_DBG
#define BT_DBG(fmt, ...)
#endif
@ -241,7 +241,7 @@ static void h5_print_header(const uint8_t *hdr, const char *str)
}
}
#if defined(CONFIG_BLUETOOTH_DEBUG_DRIVER)
#if defined(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER)
static void hexdump(const char *str, const uint8_t *packet, size_t length)
{
int n = 0;
@ -739,9 +739,9 @@ static int h5_open(void)
return 0;
}
static struct bt_driver drv = {
static struct bt_hci_driver drv = {
.name = "H:5",
.bus = BT_DRIVER_BUS_UART,
.bus = BT_HCI_DRIVER_BUS_UART,
.open = h5_open,
.send = h5_queue,
};
@ -756,7 +756,7 @@ static int _bt_uart_init(struct device *unused)
return -EINVAL;
}
bt_driver_register(&drv);
bt_hci_driver_register(&drv);
return 0;
}

View file

@ -89,7 +89,7 @@ config BLUETOOTH_RX_STACK_SIZE
if BLUETOOTH_DEBUG
config BLUETOOTH_DEBUG_DRIVER
config BLUETOOTH_DEBUG_HCI_DRIVER
bool "Bluetooth driver debug"
default n
help

View file

@ -38,7 +38,7 @@
#include "nrf51_pm.h"
#endif
#if !defined(CONFIG_BLUETOOTH_DEBUG_DRIVER)
#if !defined(CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER)
#undef BT_DBG
#define BT_DBG(fmt, ...)
#endif

View file

@ -17,12 +17,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __BT_DRIVER_H
#define __BT_DRIVER_H
#ifndef __BT_HCI_DRIVER_H
#define __BT_HCI_DRIVER_H
/**
* @brief HCI drivers
* @defgroup bt_driver HCI drivers
* @defgroup bt_hci_driver HCI drivers
* @ingroup bluetooth
* @{
*/
@ -58,24 +58,24 @@ struct net_buf *bt_buf_get_acl(void);
/* Receive data from the controller/HCI driver */
int bt_recv(struct net_buf *buf);
enum bt_driver_bus {
BT_DRIVER_BUS_VIRTUAL = 0,
BT_DRIVER_BUS_USB = 1,
BT_DRIVER_BUS_PCCARD = 2,
BT_DRIVER_BUS_UART = 3,
BT_DRIVER_BUS_RS232 = 4,
BT_DRIVER_BUS_PCI = 5,
BT_DRIVER_BUS_SDIO = 6,
BT_DRIVER_BUS_SPI = 7,
BT_DRIVER_BUS_I2C = 8,
enum bt_hci_driver_bus {
BT_HCI_DRIVER_BUS_VIRTUAL = 0,
BT_HCI_DRIVER_BUS_USB = 1,
BT_HCI_DRIVER_BUS_PCCARD = 2,
BT_HCI_DRIVER_BUS_UART = 3,
BT_HCI_DRIVER_BUS_RS232 = 4,
BT_HCI_DRIVER_BUS_PCI = 5,
BT_HCI_DRIVER_BUS_SDIO = 6,
BT_HCI_DRIVER_BUS_SPI = 7,
BT_HCI_DRIVER_BUS_I2C = 8,
};
struct bt_driver {
struct bt_hci_driver {
/* Name of the driver */
const char *name;
/* Bus of the transport (BT_DRIVER_BUS_*) */
enum bt_driver_bus bus;
/* Bus of the transport (BT_HCI_DRIVER_BUS_*) */
enum bt_hci_driver_bus bus;
/* Open the HCI transport */
int (*open)(void);
@ -85,10 +85,10 @@ struct bt_driver {
};
/* Register a new HCI driver to the Bluetooth stack */
int bt_driver_register(struct bt_driver *drv);
int bt_hci_driver_register(struct bt_hci_driver *drv);
/* Unregister a previously registered HCI driver */
void bt_driver_unregister(struct bt_driver *drv);
void bt_hci_driver_unregister(struct bt_hci_driver *drv);
#ifdef __cplusplus
}
@ -98,4 +98,4 @@ void bt_driver_unregister(struct bt_driver *drv);
* @}
*/
#endif /* __BT_DRIVER_H */
#endif /* __BT_HCI_DRIVER_H */

View file

@ -30,7 +30,7 @@
#include <bluetooth/bluetooth.h>
#include <bluetooth/uuid.h>
#include <bluetooth/gatt.h>
#include <bluetooth/driver.h>
#include <bluetooth/hci_driver.h>
#include "hci_core.h"
#include "conn_internal.h"

View file

@ -29,7 +29,7 @@
#include <bluetooth/hci.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/conn.h>
#include <bluetooth/driver.h>
#include <bluetooth/hci_driver.h>
#include <bluetooth/att.h>
#include "hci_core.h"

View file

@ -30,7 +30,7 @@
#include <bluetooth/bluetooth.h>
#include <bluetooth/uuid.h>
#include <bluetooth/gatt.h>
#include <bluetooth/driver.h>
#include <bluetooth/hci_driver.h>
#include "hci_core.h"
#include "conn_internal.h"

View file

@ -30,7 +30,7 @@
#include <bluetooth/bluetooth.h>
#include <bluetooth/conn.h>
#include <bluetooth/hci.h>
#include <bluetooth/driver.h>
#include <bluetooth/hci_driver.h>
#include <bluetooth/storage.h>
#include <tinycrypt/constants.h>
@ -3481,7 +3481,7 @@ int bt_recv(struct net_buf *buf)
return 0;
}
int bt_driver_register(struct bt_driver *drv)
int bt_hci_driver_register(struct bt_hci_driver *drv)
{
if (bt_dev.drv) {
return -EALREADY;
@ -3501,7 +3501,7 @@ int bt_driver_register(struct bt_driver *drv)
return 0;
}
void bt_driver_unregister(struct bt_driver *drv)
void bt_hci_driver_unregister(struct bt_hci_driver *drv)
{
bt_dev.drv = NULL;
}
@ -3542,7 +3542,7 @@ static int irk_init(void)
static int bt_init(void)
{
struct bt_driver *drv = bt_dev.drv;
struct bt_hci_driver *drv = bt_dev.drv;
int err;
bt_hci_ecc_init();

View file

@ -120,7 +120,7 @@ struct bt_dev {
struct nano_fifo cmd_tx_queue;
/* Registered HCI driver */
struct bt_driver *drv;
struct bt_hci_driver *drv;
#if defined(CONFIG_BLUETOOTH_PRIVACY)
/* Local Identity Resolving Key */

View file

@ -30,7 +30,7 @@
#include <bluetooth/bluetooth.h>
#include <bluetooth/log.h>
#include <bluetooth/hci.h>
#include <bluetooth/driver.h>
#include <bluetooth/hci_driver.h>
#include "hci_core.h"
#if !defined(CONFIG_BLUETOOTH_DEBUG_HCI_CORE)

View file

@ -19,7 +19,7 @@
#include <errno.h>
#include <atomic.h>
#include <bluetooth/driver.h>
#include <bluetooth/hci_driver.h>
#include <bluetooth/log.h>
#include "monitor.h"
@ -40,10 +40,10 @@ static NET_BUF_POOL(hci_evt_pool, CONFIG_BLUETOOTH_HCI_EVT_COUNT,
static struct bt_dev {
/* Registered HCI driver */
struct bt_driver *drv;
struct bt_hci_driver *drv;
} bt_dev;
int bt_driver_register(struct bt_driver *drv)
int bt_hci_driver_register(struct bt_hci_driver *drv)
{
if (bt_dev.drv) {
return -EALREADY;
@ -63,7 +63,7 @@ int bt_driver_register(struct bt_driver *drv)
return 0;
}
void bt_driver_unregister(struct bt_driver *drv)
void bt_hci_driver_unregister(struct bt_hci_driver *drv)
{
bt_dev.drv = NULL;
}
@ -115,7 +115,7 @@ int bt_send(struct net_buf *buf)
int bt_enable_raw(struct nano_fifo *rx_queue)
{
struct bt_driver *drv = bt_dev.drv;
struct bt_hci_driver *drv = bt_dev.drv;
int err;
BT_DBG("");

View file

@ -28,7 +28,7 @@
#include <bluetooth/hci.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/conn.h>
#include <bluetooth/driver.h>
#include <bluetooth/hci_driver.h>
#include "hci_core.h"
#include "conn_internal.h"

View file

@ -28,7 +28,7 @@
#include <bluetooth/hci.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/conn.h>
#include <bluetooth/driver.h>
#include <bluetooth/hci_driver.h>
#include "hci_core.h"
#include "conn_internal.h"

View file

@ -27,7 +27,7 @@
#include <bluetooth/hci.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/conn.h>
#include <bluetooth/driver.h>
#include <bluetooth/hci_driver.h>
#include <bluetooth/l2cap.h>
#include <bluetooth/rfcomm.h>

View file

@ -33,7 +33,7 @@
#include <net/buf.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/driver.h>
#include <bluetooth/hci_driver.h>
#include <bluetooth/buf.h>
#include <bluetooth/hci_raw.h>

View file

@ -16,7 +16,7 @@ CONFIG_BLUETOOTH_DEBUG_CONN=y
CONFIG_BLUETOOTH_DEBUG_KEYS=y
CONFIG_BLUETOOTH_DEBUG_L2CAP=y
CONFIG_BLUETOOTH_DEBUG_SMP=y
CONFIG_BLUETOOTH_DEBUG_DRIVER=y
CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER=y
CONFIG_BLUETOOTH_SMP_SELFTEST=y
CONFIG_BLUETOOTH_DEBUG_ATT=y
CONFIG_BLUETOOTH_DEBUG_GATT=y

View file

@ -17,7 +17,7 @@ CONFIG_BLUETOOTH_DEBUG_CONN=y
CONFIG_BLUETOOTH_DEBUG_KEYS=y
CONFIG_BLUETOOTH_DEBUG_L2CAP=y
CONFIG_BLUETOOTH_DEBUG_SMP=y
CONFIG_BLUETOOTH_DEBUG_DRIVER=y
CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER=y
CONFIG_BLUETOOTH_SMP_SELFTEST=y
CONFIG_BLUETOOTH_DEBUG_ATT=y
CONFIG_BLUETOOTH_DEBUG_GATT=y

View file

@ -16,7 +16,7 @@ CONFIG_BLUETOOTH_DEBUG_CONN=y
CONFIG_BLUETOOTH_DEBUG_KEYS=y
CONFIG_BLUETOOTH_DEBUG_L2CAP=y
CONFIG_BLUETOOTH_DEBUG_SMP=y
CONFIG_BLUETOOTH_DEBUG_DRIVER=y
CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER=y
CONFIG_BLUETOOTH_SMP_SELFTEST=y
CONFIG_BLUETOOTH_DEBUG_ATT=y
CONFIG_BLUETOOTH_DEBUG_GATT=y

View file

@ -17,7 +17,7 @@ CONFIG_BLUETOOTH_DEBUG_CONN=y
CONFIG_BLUETOOTH_DEBUG_KEYS=y
CONFIG_BLUETOOTH_DEBUG_L2CAP=y
CONFIG_BLUETOOTH_DEBUG_SMP=y
CONFIG_BLUETOOTH_DEBUG_DRIVER=y
CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER=y
CONFIG_BLUETOOTH_SMP_SELFTEST=y
CONFIG_BLUETOOTH_DEBUG_ATT=y
CONFIG_BLUETOOTH_DEBUG_GATT=y

View file

@ -2,4 +2,4 @@ CONFIG_BLUETOOTH=y
CONFIG_BLUETOOTH_H5=y
CONFIG_BLUETOOTH_LE=y
CONFIG_BLUETOOTH_DEBUG_LOG=y
CONFIG_BLUETOOTH_DEBUG_DRIVER=y
CONFIG_BLUETOOTH_DEBUG_HCI_DRIVER=y

View file

@ -22,7 +22,7 @@
#include <tc_util.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/driver.h>
#include <bluetooth/hci_driver.h>
#define EXPECTED_ERROR -ENOSYS
@ -39,16 +39,16 @@ static int driver_send(struct net_buf *buf)
return 0;
}
static struct bt_driver drv = {
static struct bt_hci_driver drv = {
.name = "test",
.bus = BT_DRIVER_BUS_VIRTUAL,
.bus = BT_HCI_DRIVER_BUS_VIRTUAL,
.open = driver_open,
.send = driver_send,
};
static void driver_init(void)
{
bt_driver_register(&drv);
bt_hci_driver_register(&drv);
}
void main(void)