mirror of https://github.com/OpenIPC/firmware.git
187 lines
3.8 KiB
Diff
187 lines
3.8 KiB
Diff
diff -drupN a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
|
|
--- a/drivers/bluetooth/hci_ldisc.c 2017-10-21 18:09:07.000000000 +0300
|
|
+++ b/drivers/bluetooth/hci_ldisc.c 2022-06-09 05:02:28.000000000 +0300
|
|
@@ -48,6 +48,13 @@
|
|
#include "btintel.h"
|
|
#include "btbcm.h"
|
|
#include "hci_uart.h"
|
|
+#include <linux/platform_device.h>
|
|
+#define DEVNAME "rtl_bt_en"
|
|
+
|
|
+#ifdef BTCOEX
|
|
+#include <linux/version.h>
|
|
+#include "rtk_coex.h"
|
|
+#endif
|
|
|
|
#define VERSION "2.3"
|
|
|
|
@@ -208,6 +215,9 @@ static int hci_uart_open(struct hci_dev
|
|
BT_DBG("%s %p", hdev->name, hdev);
|
|
|
|
/* Nothing to do for UART driver */
|
|
+#ifdef BTCOEX
|
|
+ rtk_btcoex_open(hdev);
|
|
+#endif
|
|
return 0;
|
|
}
|
|
|
|
@@ -238,8 +248,16 @@ static int hci_uart_close(struct hci_dev
|
|
{
|
|
BT_DBG("hdev %p", hdev);
|
|
|
|
+ if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
|
|
+ return 0;
|
|
+
|
|
hci_uart_flush(hdev);
|
|
hdev->flush = NULL;
|
|
+
|
|
+#ifdef BTCOEX
|
|
+ rtk_btcoex_close();
|
|
+#endif
|
|
+
|
|
return 0;
|
|
}
|
|
|
|
@@ -250,6 +268,13 @@ static int hci_uart_send_frame(struct hc
|
|
|
|
BT_DBG("%s: type %d len %d", hdev->name, bt_cb(skb)->pkt_type, skb->len);
|
|
|
|
+#ifdef BTCOEX
|
|
+ if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT)
|
|
+ rtk_btcoex_parse_cmd(skb->data, skb->len);
|
|
+ if (bt_cb(skb)->pkt_type == HCI_ACLDATA_PKT)
|
|
+ rtk_btcoex_parse_l2cap_data_tx(skb->data, skb->len);
|
|
+#endif
|
|
+
|
|
hu->proto->enqueue(hu, skb);
|
|
|
|
hci_uart_tx_wakeup(hu);
|
|
@@ -505,7 +530,9 @@ static void hci_uart_tty_close(struct tt
|
|
}
|
|
hu->proto->close(hu);
|
|
}
|
|
-
|
|
+#ifdef CONFIG_BT_HCIUART_RTKH5
|
|
+ clear_bit(HCI_UART_PROTO_SET, &hu->flags);
|
|
+#endif
|
|
kfree(hu);
|
|
}
|
|
|
|
@@ -625,7 +652,9 @@ static int hci_uart_register_dev(struct
|
|
}
|
|
|
|
set_bit(HCI_UART_REGISTERED, &hu->flags);
|
|
-
|
|
+#ifdef BTCOEX
|
|
+ rtk_btcoex_probe(hdev);
|
|
+#endif
|
|
return 0;
|
|
}
|
|
|
|
@@ -643,9 +672,15 @@ static int hci_uart_set_proto(struct hci
|
|
return err;
|
|
|
|
hu->proto = p;
|
|
+#ifdef CONFIG_BT_HCIUART_RTKH5
|
|
+ set_bit(HCI_UART_PROTO_SET, &hu->flags);
|
|
+#endif
|
|
|
|
err = hci_uart_register_dev(hu);
|
|
if (err) {
|
|
+#ifdef CONFIG_BT_HCIUART_RTKH5
|
|
+ clear_bit(HCI_UART_PROTO_SET, &hu->flags);
|
|
+#endif
|
|
p->close(hu);
|
|
return err;
|
|
}
|
|
@@ -810,6 +845,14 @@ static int __init hci_uart_init(void)
|
|
qca_init();
|
|
#endif
|
|
|
|
+#ifdef CONFIG_BT_HCIUART_RTKH5
|
|
+ h5_init();
|
|
+#endif
|
|
+
|
|
+#ifdef BTCOEX
|
|
+ rtk_btcoex_init();
|
|
+#endif
|
|
+
|
|
return 0;
|
|
}
|
|
|
|
@@ -841,15 +884,74 @@ static void __exit hci_uart_exit(void)
|
|
#ifdef CONFIG_BT_HCIUART_QCA
|
|
qca_deinit();
|
|
#endif
|
|
+#ifdef CONFIG_BT_HCIUART_RTKH5
|
|
+ h5_deinit();
|
|
+#endif
|
|
|
|
+#ifdef BTCOEX
|
|
+ rtk_btcoex_exit();
|
|
+#endif
|
|
/* Release tty registration of line discipline */
|
|
err = tty_unregister_ldisc(N_HCI);
|
|
if (err)
|
|
BT_ERR("Can't unregister HCI line discipline (%d)", err);
|
|
}
|
|
+#if (defined CONFIG_BT_HCIUART_RTKH5) && (defined CONFIG_BT_HCIUART_H4)
|
|
+
|
|
+struct rtl_bt_data {
|
|
+ int (*rtl_bt_en)(void);
|
|
+};
|
|
+
|
|
+static int rtl_bt_probe (struct platform_device *pdev)
|
|
+{
|
|
+ struct rtl_bt_data * bt_data = NULL;
|
|
+ int ret = 0;
|
|
|
|
+ bt_data = (struct rtl_bt_data *)pdev->dev.platform_data;
|
|
+ if (bt_data->rtl_bt_en)
|
|
+ bt_data->rtl_bt_en();
|
|
+ else
|
|
+ BT_ERR("rtl_bt_en pin enable failed\n");
|
|
+
|
|
+ ret = hci_uart_init();
|
|
+ return ret;
|
|
+}
|
|
+
|
|
+static int rtl_bt_remove (struct platform_device *pdev)
|
|
+{
|
|
+ hci_uart_exit();
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+static struct platform_driver bt_drv = {
|
|
+ .probe = rtl_bt_probe,
|
|
+ .remove = rtl_bt_remove,
|
|
+ .driver = {
|
|
+ .name = DEVNAME,
|
|
+ },
|
|
+};
|
|
+
|
|
+static int __init rtk_bt_init(void)
|
|
+{
|
|
+ int ret = 0;
|
|
+ ret = platform_driver_register(&bt_drv);
|
|
+ if (ret < 0) {
|
|
+ BT_ERR("register bt driver failed\n");
|
|
+ }
|
|
+ return ret;
|
|
+}
|
|
+
|
|
+static void __exit rtk_bt_exit(void)
|
|
+{
|
|
+ platform_driver_unregister(&bt_drv);
|
|
+}
|
|
+
|
|
+module_init(rtk_bt_init);
|
|
+module_exit(rtk_bt_exit);
|
|
+#else
|
|
module_init(hci_uart_init);
|
|
module_exit(hci_uart_exit);
|
|
+#endif
|
|
|
|
MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
|
|
MODULE_DESCRIPTION("Bluetooth HCI UART driver ver " VERSION);
|