Skip to content

Commit 8026aab

Browse files
RockShen-ASUSasus-leslieyu
authored andcommitted
bluetooth: add rtl8723b driver
Change-Id: I5c6ef165210b758a07fcb7b8ce4393d9699cca57 Signed-off-by: Rock Shen <rock_shen@asus.com>
1 parent e21d76d commit 8026aab

7 files changed

Lines changed: 3019 additions & 19 deletions

File tree

arch/arm/configs/rockchip_linux_defconfig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,10 @@ CONFIG_BT_RFCOMM=y
171171
CONFIG_BT_HIDP=y
172172
CONFIG_BT_HCIBTUSB=y
173173
CONFIG_BT_HCIUART=y
174-
CONFIG_BT_HCIUART_ATH3K=y
175-
CONFIG_BT_HCIUART_LL=y
174+
CONFIG_BT_HCIUART_H4=y
175+
CONFIG_BT_HCIUART_3WIRE=y
176+
CONFIG_BT_HCIUART_ATH3K=n
177+
CONFIG_BT_HCIUART_LL=n
176178
CONFIG_BT_HCIBFUSB=y
177179
CONFIG_BT_HCIVHCI=y
178180
CONFIG_BT_MRVL=y

drivers/bluetooth/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ obj-$(CONFIG_BT_QCA) += btqca.o
2828
btmrvl-y := btmrvl_main.o
2929
btmrvl-$(CONFIG_DEBUG_FS) += btmrvl_debugfs.o
3030

31-
hci_uart-y := hci_ldisc.o
31+
hci_uart-y := hci_ldisc.o rtk_coex.o
3232
hci_uart-$(CONFIG_BT_HCIUART_H4) += hci_h4.o
3333
hci_uart-$(CONFIG_BT_HCIUART_BCSP) += hci_bcsp.o
3434
hci_uart-$(CONFIG_BT_HCIUART_LL) += hci_ll.o

drivers/bluetooth/hci_h5.c

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030

3131
#include "hci_uart.h"
3232

33+
#ifdef BTCOEX
34+
#include "rtk_coex.h"
35+
#endif
36+
3337
#define HCI_3WIRE_ACK_PKT 0
3438
#define HCI_3WIRE_LINK_PKT 15
3539

@@ -192,7 +196,7 @@ static void h5_peer_reset(struct hci_uart *hu)
192196
static int h5_open(struct hci_uart *hu)
193197
{
194198
struct h5 *h5;
195-
const unsigned char sync[] = { 0x01, 0x7e };
199+
/* const unsigned char sync[] = { 0x01, 0x7e }; */
196200

197201
BT_DBG("hu %p", hu);
198202

@@ -214,11 +218,16 @@ static int h5_open(struct hci_uart *hu)
214218

215219
h5->tx_win = H5_TX_WIN_MAX;
216220

217-
set_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags);
221+
/* set_bit(HCI_UART_INIT_PENDING, &hu->hdev_flags); */
222+
223+
/* Firmware was already download by userspace app rtk_hciattach */
224+
h5->state = H5_ACTIVE;
225+
hci_uart_init_ready(hu);
218226

219227
/* Send initial sync request */
220-
h5_link_control(hu, sync, sizeof(sync));
221-
mod_timer(&h5->timer, jiffies + H5_SYNC_TIMEOUT);
228+
/* h5_link_control(hu, sync, sizeof(sync));
229+
* mod_timer(&h5->timer, jiffies + H5_SYNC_TIMEOUT);
230+
*/
222231

223232
return 0;
224233
}
@@ -365,6 +374,16 @@ static void h5_complete_rx_pkt(struct hci_uart *hu)
365374
/* Remove Three-wire header */
366375
skb_pull(h5->rx_skb, 4);
367376

377+
#ifdef BTCOEX
378+
if (bt_cb(h5->rx_skb)->pkt_type == HCI_EVENT_PKT)
379+
rtk_btcoex_parse_event(h5->rx_skb->data,
380+
h5->rx_skb->len);
381+
382+
if (bt_cb(h5->rx_skb)->pkt_type == HCI_ACLDATA_PKT)
383+
rtk_btcoex_parse_l2cap_data_rx(h5->rx_skb->data,
384+
h5->rx_skb->len);
385+
#endif
386+
368387
hci_recv_frame(hu->hdev, h5->rx_skb);
369388
h5->rx_skb = NULL;
370389

@@ -380,6 +399,11 @@ static void h5_complete_rx_pkt(struct hci_uart *hu)
380399

381400
static int h5_rx_crc(struct hci_uart *hu, unsigned char c)
382401
{
402+
struct h5 *h5 = hu->priv;
403+
404+
/* TODO: crc check */
405+
skb_trim(h5->rx_skb, h5->rx_skb->len - 2);
406+
383407
h5_complete_rx_pkt(hu);
384408

385409
return 0;

drivers/bluetooth/hci_ldisc.c

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
#include "btbcm.h"
5050
#include "hci_uart.h"
5151

52+
#ifdef BTCOEX
53+
#include "rtk_coex.h"
54+
#endif
55+
5256
#define VERSION "2.3"
5357

5458
static const struct hci_uart_proto *hup[HCI_UART_MAX_PROTO];
@@ -130,7 +134,7 @@ int hci_uart_tx_wakeup(struct hci_uart *hu)
130134

131135
BT_DBG("");
132136

133-
schedule_work(&hu->write_work);
137+
schedule_work_on(0, &hu->write_work);
134138

135139
return 0;
136140
}
@@ -142,11 +146,6 @@ static void hci_uart_write_work(struct work_struct *work)
142146
struct hci_dev *hdev = hu->hdev;
143147
struct sk_buff *skb;
144148

145-
if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) {
146-
clear_bit(HCI_UART_SENDING, &hu->tx_state);
147-
return;
148-
}
149-
150149
/* REVISIT: should we cope with bad skbs or ->write() returning
151150
* and error value ?
152151
*/
@@ -212,6 +211,10 @@ static int hci_uart_open(struct hci_dev *hdev)
212211
{
213212
BT_DBG("%s %p", hdev->name, hdev);
214213

214+
#ifdef BTCOEX
215+
rtk_btcoex_open(hdev);
216+
#endif
217+
215218
/* Nothing to do for UART driver */
216219
return 0;
217220
}
@@ -245,6 +248,11 @@ static int hci_uart_close(struct hci_dev *hdev)
245248

246249
hci_uart_flush(hdev);
247250
hdev->flush = NULL;
251+
252+
#ifdef BTCOEX
253+
rtk_btcoex_close();
254+
#endif
255+
248256
return 0;
249257
}
250258

@@ -255,8 +263,12 @@ static int hci_uart_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
255263

256264
BT_DBG("%s: type %d len %d", hdev->name, bt_cb(skb)->pkt_type, skb->len);
257265

258-
if (!test_bit(HCI_UART_PROTO_READY, &hu->flags))
259-
return -EUNATCH;
266+
#ifdef BTCOEX
267+
if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT)
268+
rtk_btcoex_parse_cmd(skb->data, skb->len);
269+
if (bt_cb(skb)->pkt_type == HCI_ACLDATA_PKT)
270+
rtk_btcoex_parse_l2cap_data_tx(skb->data, skb->len);
271+
#endif
260272

261273
hu->proto->enqueue(hu, skb);
262274

@@ -512,9 +524,9 @@ static void hci_uart_tty_close(struct tty_struct *tty)
512524
if (hdev)
513525
hci_uart_close(hdev);
514526

515-
if (test_and_clear_bit(HCI_UART_PROTO_READY, &hu->flags)) {
516-
cancel_work_sync(&hu->write_work);
527+
cancel_work_sync(&hu->write_work);
517528

529+
if (test_and_clear_bit(HCI_UART_PROTO_READY, &hu->flags)) {
518530
if (hdev) {
519531
if (test_bit(HCI_UART_REGISTERED, &hu->flags))
520532
hci_unregister_dev(hdev);
@@ -644,6 +656,10 @@ static int hci_uart_register_dev(struct hci_uart *hu)
644656

645657
set_bit(HCI_UART_REGISTERED, &hu->flags);
646658

659+
#ifdef BTCOEX
660+
rtk_btcoex_probe(hdev);
661+
#endif
662+
647663
return 0;
648664
}
649665

@@ -661,15 +677,15 @@ static int hci_uart_set_proto(struct hci_uart *hu, int id)
661677
return err;
662678

663679
hu->proto = p;
680+
set_bit(HCI_UART_PROTO_READY, &hu->flags);
664681

665682
err = hci_uart_register_dev(hu);
666683
if (err) {
684+
clear_bit(HCI_UART_PROTO_READY, &hu->flags);
667685
p->close(hu);
668686
return err;
669687
}
670688

671-
set_bit(HCI_UART_PROTO_READY, &hu->flags);
672-
673689
return 0;
674690
}
675691

@@ -830,6 +846,10 @@ static int __init hci_uart_init(void)
830846
qca_init();
831847
#endif
832848

849+
#ifdef BTCOEX
850+
rtk_btcoex_init();
851+
#endif
852+
833853
return 0;
834854
}
835855

@@ -866,6 +886,11 @@ static void __exit hci_uart_exit(void)
866886
err = tty_unregister_ldisc(N_HCI);
867887
if (err)
868888
BT_ERR("Can't unregister HCI line discipline (%d)", err);
889+
890+
#ifdef BTCOEX
891+
rtk_btcoex_exit();
892+
#endif
893+
869894
}
870895

871896
module_init(hci_uart_init);

drivers/bluetooth/hci_uart.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#define N_HCI 15
2828
#endif
2929

30+
#define BTCOEX
31+
3032
/* Ioctls */
3133
#define HCIUARTSETPROTO _IOW('U', 200, int)
3234
#define HCIUARTGETPROTO _IOR('U', 201, int)

0 commit comments

Comments
 (0)