bluetooth: move static device definition to platform configs

This moves the static device definition from the driver file,
drivers/bluetooth/uart.c, into the platform config files for
each platform.

This is another step towards converting UART drivers to
the new driver model. Also, platform config files are a more
logical place for the definition.

Change-Id: I668a52de5a38005b8b2bcb67d74437ead377cb16
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
Daniel Leung 2015-08-10 13:29:53 -07:00 committed by Anas Nashif
parent a4212108f7
commit 0f7a78ce1b
7 changed files with 50 additions and 12 deletions

View file

@ -196,12 +196,19 @@ extern struct device * const uart_console_dev;
#define UART_CONSOLE_DEV uart_console_dev
/* Bluetooth UART definitions */
#if defined(CONFIG_BLUETOOTH_UART)
#define CONFIG_BLUETOOTH_UART_INDEX 1
#define CONFIG_BLUETOOTH_UART_BAUDRATE 115200
#define CONFIG_BLUETOOTH_UART_IRQ IRQ_UART1_STATUS
#define CONFIG_BLUETOOTH_UART_INT_PRI 3
#define CONFIG_BLUETOOTH_UART_FREQ SYSCLK_DEFAULT_IOSC_HZ
extern struct device * const bt_uart_dev;
#define BT_UART_DEV bt_uart_dev
#endif /* CONFIG_BLUETOOTH_UART */
#define EXC_FROM_IRQ(irq) ((irq) + 16)
#define VECTOR_FROM_IRQ(irq) EXC_FROM_IRQ(irq)
#define VECTOR_ADDR(vector) ((uint32_t *)((int)vector << 2))

View file

@ -144,4 +144,8 @@ struct device uart_devs[] = {
struct device * const uart_console_dev = &uart_devs[CONFIG_UART_CONSOLE_INDEX];
#endif
#ifdef CONFIG_BLUETOOTH_UART
struct device * const bt_uart_dev = &uart_devs[CONFIG_BLUETOOTH_UART_INDEX];
#endif
#endif /* CONFIG_K20_UART */

View file

@ -125,12 +125,19 @@ extern struct device * const uart_console_dev;
#define UART_CONSOLE_DEV uart_console_dev
/* Bluetooth UART definitions */
#if defined(CONFIG_BLUETOOTH_UART)
#define CONFIG_BLUETOOTH_UART_INDEX 1
#define CONFIG_BLUETOOTH_UART_BAUDRATE 115200
#define CONFIG_BLUETOOTH_UART_IRQ IRQ_UART1
#define CONFIG_BLUETOOTH_UART_INT_PRI 3
#define CONFIG_BLUETOOTH_UART_FREQ SYSCLK_DEFAULT_IOSC_HZ
extern struct device * const bt_uart_dev;
#define BT_UART_DEV bt_uart_dev
#endif /* CONFIG_BLUETOOTH_UART */
/* Simple UART definitions */
#define CONFIG_UART_SIMPLE_INDEX 2
#define CONFIG_UART_SIMPLE_BAUDRATE 115200

View file

@ -98,4 +98,8 @@ struct device uart_devs[] = {
struct device * const uart_console_dev = &uart_devs[CONFIG_UART_CONSOLE_INDEX];
#endif
#ifdef CONFIG_BLUETOOTH_UART
struct device * const bt_uart_dev = &uart_devs[CONFIG_BLUETOOTH_UART_INDEX];
#endif
#endif /* CONFIG_STELLARIS_UART */

View file

@ -110,12 +110,23 @@ extern struct device * const uart_console_dev;
#endif
/* Bluetooth UART definitions */
#if defined(CONFIG_BLUETOOTH_UART)
#define CONFIG_BLUETOOTH_UART_INDEX 1
#define CONFIG_BLUETOOTH_UART_IRQ COM2_INT_LVL
#define CONFIG_BLUETOOTH_UART_INT_PRI COM2_INT_PRI
#define CONFIG_BLUETOOTH_UART_FREQ UART_XTAL_FREQ
#define CONFIG_BLUETOOTH_UART_BAUDRATE CONFIG_UART_BAUDRATE
#ifndef _ASMLANGUAGE
extern struct device * const bt_uart_dev;
#define BT_UART_DEV bt_uart_dev
#endif
#endif /* CONFIG_BLUETOOTH_UART */
#endif /* CONFIG_NS16550 */
#ifndef _ASMLANGUAGE

View file

@ -88,4 +88,8 @@ struct device uart_devs[] = {
struct device * const uart_console_dev = &uart_devs[CONFIG_UART_CONSOLE_INDEX];
#endif
#ifdef CONFIG_BLUETOOTH_UART
struct device * const bt_uart_dev = &uart_devs[CONFIG_BLUETOOTH_UART_INDEX];
#endif
#endif

View file

@ -58,8 +58,6 @@
#define H4_SCO 0x03
#define H4_EVT 0x04
#define UART (&uart_devs[CONFIG_BLUETOOTH_UART_INDEX])
static int bt_uart_read(struct device *uart, uint8_t *buf,
size_t len, size_t min)
{
@ -103,7 +101,7 @@ static struct bt_buf *bt_uart_evt_recv(int *remaining)
struct bt_buf *buf;
/* We can ignore the return value since we pass len == min */
bt_uart_read(UART, (void *)&hdr, sizeof(hdr), sizeof(hdr));
bt_uart_read(BT_UART_DEV, (void *)&hdr, sizeof(hdr), sizeof(hdr));
*remaining = hdr.len;
@ -125,7 +123,7 @@ static struct bt_buf *bt_uart_acl_recv(int *remaining)
struct bt_buf *buf;
/* We can ignore the return value since we pass len == min */
bt_uart_read(UART, (void *)&hdr, sizeof(hdr), sizeof(hdr));
bt_uart_read(BT_UART_DEV, (void *)&hdr, sizeof(hdr), sizeof(hdr));
buf = bt_buf_get(BT_ACL_IN, 0);
if (buf) {
@ -148,11 +146,12 @@ void bt_uart_isr(void *unused)
ARG_UNUSED(unused);
while (uart_irq_update(UART) && uart_irq_is_pending(UART)) {
while (uart_irq_update(BT_UART_DEV)
&& uart_irq_is_pending(BT_UART_DEV)) {
int read;
if (!uart_irq_rx_ready(UART)) {
if (uart_irq_tx_ready(UART)) {
if (!uart_irq_rx_ready(BT_UART_DEV)) {
if (uart_irq_tx_ready(BT_UART_DEV)) {
BT_DBG("transmit ready\n");
} else {
BT_DBG("spurious interrupt\n");
@ -165,7 +164,8 @@ void bt_uart_isr(void *unused)
uint8_t type;
/* Get packet type */
read = bt_uart_read(UART, &type, sizeof(type), 0);
read = bt_uart_read(BT_UART_DEV, &type,
sizeof(type), 0);
if (read != sizeof(type)) {
BT_WARN("Unable to read H4 packet type\n");
continue;
@ -192,13 +192,14 @@ void bt_uart_isr(void *unused)
}
if (!buf) {
read = bt_uart_discard(UART, remaining);
read = bt_uart_discard(BT_UART_DEV, remaining);
BT_WARN("Discarded %d bytes\n", read);
remaining -= read;
continue;
}
read = bt_uart_read(UART, bt_buf_tail(buf), remaining, 0);
read = bt_uart_read(BT_UART_DEV, bt_buf_tail(buf),
remaining, 0);
buf->len += read;
remaining -= read;
@ -248,7 +249,7 @@ static int bt_uart_send(struct bt_buf *buf)
return -EINVAL;
}
return uart_fifo_fill(UART, buf->data, buf->len);
return uart_fifo_fill(BT_UART_DEV, buf->data, buf->len);
}
IRQ_CONNECT_STATIC(bluetooth, CONFIG_BLUETOOTH_UART_IRQ,
@ -283,7 +284,7 @@ static int bt_uart_open()
.int_pri = CONFIG_BLUETOOTH_UART_INT_PRI,
};
bt_uart_setup(UART, &info);
bt_uart_setup(BT_UART_DEV, &info);
return 0;
}