diff options
-rw-r--r-- | drivers/bluetooth/hci_h5.c | 69 |
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 | ||
826 | static 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 | |||
866 | out_free: | ||
867 | btrtl_free(btrtl_dev); | ||
868 | |||
869 | return err; | ||
870 | } | ||
871 | |||
872 | static 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 | |||
880 | static struct h5_vnd rtl_vnd = { | ||
881 | .setup = h5_btrtl_setup, | ||
882 | .open = h5_btrtl_open, | ||
883 | }; | ||
884 | |||
885 | #ifdef CONFIG_ACPI | ||
886 | static const struct acpi_device_id h5_acpi_match[] = { | ||
887 | { "OBDA8723", (kernel_ulong_t)&rtl_vnd }, | ||
888 | { }, | ||
889 | }; | ||
890 | MODULE_DEVICE_TABLE(acpi, h5_acpi_match); | ||
891 | #endif | ||
892 | |||
825 | static struct serdev_device_driver h5_serdev_driver = { | 893 | static 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 | ||