aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Cline <jeremy@jcline.org>2018-08-02 10:57:20 -0400
committerMarcel Holtmann <marcel@holtmann.org>2018-08-03 07:27:47 -0400
commitb825d7c4052643a9b8a10d1c83213394f795c806 (patch)
treef5beaece3d432ba0e0a8e2c845fb59fc8bc9bf4d
parent4eb3cbc4c4dbd3185c9e7595e38ed01a87bba80f (diff)
Bluetooth: hci_h5: Add support for the RTL8723BS
Implement support for the RTL8723BS chip. Signed-off-by: Jeremy Cline <jeremy@jcline.org> [hdegoede@redhat.com: Port from bt3wire.c to hci_h5.c, drop broken GPIO code] Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--drivers/bluetooth/hci_h5.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
index b3f762291e7f..3513dad43f3c 100644
--- a/drivers/bluetooth/hci_h5.c
+++ b/drivers/bluetooth/hci_h5.c
@@ -31,6 +31,7 @@
31#include <net/bluetooth/bluetooth.h> 31#include <net/bluetooth/bluetooth.h>
32#include <net/bluetooth/hci_core.h> 32#include <net/bluetooth/hci_core.h>
33 33
34#include "btrtl.h"
34#include "hci_uart.h" 35#include "hci_uart.h"
35 36
36#define HCI_3WIRE_ACK_PKT 0 37#define HCI_3WIRE_ACK_PKT 0
@@ -822,11 +823,79 @@ static void h5_serdev_remove(struct serdev_device *serdev)
822 hci_uart_unregister_device(&h5->serdev_hu); 823 hci_uart_unregister_device(&h5->serdev_hu);
823} 824}
824 825
826static int h5_btrtl_setup(struct h5 *h5)
827{
828 struct btrtl_device_info *btrtl_dev;
829 struct sk_buff *skb;
830 __le32 baudrate_data;
831 u32 device_baudrate;
832 unsigned int controller_baudrate;
833 bool flow_control;
834 int err;
835
836 btrtl_dev = btrtl_initialize(h5->hu->hdev, h5->id);
837 if (IS_ERR(btrtl_dev))
838 return PTR_ERR(btrtl_dev);
839
840 err = btrtl_get_uart_settings(h5->hu->hdev, btrtl_dev,
841 &controller_baudrate, &device_baudrate,
842 &flow_control);
843 if (err)
844 goto out_free;
845
846 baudrate_data = cpu_to_le32(device_baudrate);
847 skb = __hci_cmd_sync(h5->hu->hdev, 0xfc17, sizeof(baudrate_data),
848 &baudrate_data, HCI_INIT_TIMEOUT);
849 if (IS_ERR(skb)) {
850 rtl_dev_err(h5->hu->hdev, "set baud rate command failed\n");
851 err = PTR_ERR(skb);
852 goto out_free;
853 } else {
854 kfree_skb(skb);
855 }
856 /* Give the device some time to set up the new baudrate. */
857 usleep_range(10000, 20000);
858
859 serdev_device_set_baudrate(h5->hu->serdev, controller_baudrate);
860 serdev_device_set_flow_control(h5->hu->serdev, flow_control);
861
862 err = btrtl_download_firmware(h5->hu->hdev, btrtl_dev);
863 /* Give the device some time before the hci-core sends it a reset */
864 usleep_range(10000, 20000);
865
866out_free:
867 btrtl_free(btrtl_dev);
868
869 return err;
870}
871
872static void h5_btrtl_open(struct h5 *h5)
873{
874 /* Devices always start with these fixed parameters */
875 serdev_device_set_flow_control(h5->hu->serdev, false);
876 serdev_device_set_parity(h5->hu->serdev, SERDEV_PARITY_EVEN);
877 serdev_device_set_baudrate(h5->hu->serdev, 115200);
878}
879
880static struct h5_vnd rtl_vnd = {
881 .setup = h5_btrtl_setup,
882 .open = h5_btrtl_open,
883};
884
885#ifdef CONFIG_ACPI
886static const struct acpi_device_id h5_acpi_match[] = {
887 { "OBDA8723", (kernel_ulong_t)&rtl_vnd },
888 { },
889};
890MODULE_DEVICE_TABLE(acpi, h5_acpi_match);
891#endif
892
825static struct serdev_device_driver h5_serdev_driver = { 893static struct serdev_device_driver h5_serdev_driver = {
826 .probe = h5_serdev_probe, 894 .probe = h5_serdev_probe,
827 .remove = h5_serdev_remove, 895 .remove = h5_serdev_remove,
828 .driver = { 896 .driver = {
829 .name = "hci_uart_h5", 897 .name = "hci_uart_h5",
898 .acpi_match_table = ACPI_PTR(h5_acpi_match),
830 }, 899 },
831}; 900};
832 901