Skip to content

Commit 7dec65c

Browse files
jhedbergGustavo Padovan
authored andcommitted
Bluetooth: Initial skeleton for Three-wire UART (H5) support
This patch adds the initial skeleton for Three-wire UART (H5) support and hooks it up to the HCI UART framework. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
1 parent 83ce9a0 commit 7dec65c

5 files changed

Lines changed: 112 additions & 0 deletions

File tree

‎drivers/bluetooth/Kconfig‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,18 @@ config BT_HCIUART_LL
8181

8282
Say Y here to compile support for HCILL protocol.
8383

84+
config BT_HCIUART_3WIRE
85+
bool "Three-wire UART (H5) protocol support"
86+
depends on BT_HCIUART
87+
help
88+
The HCI Three-wire UART Transport Layer makes it possible to
89+
user the Bluetooth HCI over a serial port interface. The HCI
90+
Three-wire UART Transport Layer assumes that the UART
91+
communication may have bit errors, overrun errors or burst
92+
errors and thereby making CTS/RTS lines unnecessary.
93+
94+
Say Y here to compile support for Three-wire UART protocol.
95+
8496
config BT_HCIBCM203X
8597
tristate "HCI BCM203x USB driver"
8698
depends on USB

‎drivers/bluetooth/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ hci_uart-$(CONFIG_BT_HCIUART_H4) += hci_h4.o
2828
hci_uart-$(CONFIG_BT_HCIUART_BCSP) += hci_bcsp.o
2929
hci_uart-$(CONFIG_BT_HCIUART_LL) += hci_ll.o
3030
hci_uart-$(CONFIG_BT_HCIUART_ATH3K) += hci_ath.o
31+
hci_uart-$(CONFIG_BT_HCIUART_3WIRE) += hci_h5.o
3132
hci_uart-objs := $(hci_uart-y)

‎drivers/bluetooth/hci_h5.c‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/*
2+
*
3+
* Bluetooth HCI Three-wire UART driver
4+
*
5+
* Copyright (C) 2012 Intel Corporation
6+
*
7+
*
8+
* This program is free software; you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation; either version 2 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21+
*
22+
*/
23+
24+
#include <linux/kernel.h>
25+
#include <linux/errno.h>
26+
#include <linux/skbuff.h>
27+
28+
#include <net/bluetooth/bluetooth.h>
29+
#include <net/bluetooth/hci_core.h>
30+
31+
#include "hci_uart.h"
32+
33+
static int h5_open(struct hci_uart *hu)
34+
{
35+
return -ENOSYS;
36+
}
37+
38+
static int h5_close(struct hci_uart *hu)
39+
{
40+
return -ENOSYS;
41+
}
42+
43+
static int h5_recv(struct hci_uart *hu, void *data, int count)
44+
{
45+
return -ENOSYS;
46+
}
47+
48+
static int h5_enqueue(struct hci_uart *hu, struct sk_buff *skb)
49+
{
50+
return -ENOSYS;
51+
}
52+
53+
static struct sk_buff *h5_dequeue(struct hci_uart *hu)
54+
{
55+
return NULL;
56+
}
57+
58+
static int h5_flush(struct hci_uart *hu)
59+
{
60+
return -ENOSYS;
61+
}
62+
63+
static struct hci_uart_proto h5p = {
64+
.id = HCI_UART_3WIRE,
65+
.open = h5_open,
66+
.close = h5_close,
67+
.recv = h5_recv,
68+
.enqueue = h5_enqueue,
69+
.dequeue = h5_dequeue,
70+
.flush = h5_flush,
71+
};
72+
73+
int __init h5_init(void)
74+
{
75+
int err = hci_uart_register_proto(&h5p);
76+
77+
if (!err)
78+
BT_INFO("HCI Three-wire UART (H5) protocol initialized");
79+
else
80+
BT_ERR("HCI Three-wire UART (H5) protocol init failed");
81+
82+
return err;
83+
}
84+
85+
int __exit h5_deinit(void)
86+
{
87+
return hci_uart_unregister_proto(&h5p);
88+
}

‎drivers/bluetooth/hci_ldisc.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,9 @@ static int __init hci_uart_init(void)
558558
#ifdef CONFIG_BT_HCIUART_ATH3K
559559
ath_init();
560560
#endif
561+
#ifdef CONFIG_BT_HCIUART_3WIRE
562+
h5_init();
563+
#endif
561564

562565
return 0;
563566
}
@@ -578,6 +581,9 @@ static void __exit hci_uart_exit(void)
578581
#ifdef CONFIG_BT_HCIUART_ATH3K
579582
ath_deinit();
580583
#endif
584+
#ifdef CONFIG_BT_HCIUART_3WIRE
585+
h5_deinit();
586+
#endif
581587

582588
/* Release tty registration of line discipline */
583589
if ((err = tty_unregister_ldisc(N_HCI)))

‎drivers/bluetooth/hci_uart.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,8 @@ int ll_deinit(void);
104104
int ath_init(void);
105105
int ath_deinit(void);
106106
#endif
107+
108+
#ifdef CONFIG_BT_HCIUART_3WIRE
109+
int h5_init(void);
110+
int h5_deinit(void);
111+
#endif

0 commit comments

Comments
 (0)