diff options
-rw-r--r-- | drivers/bluetooth/btusb.c | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 292b1ea066ca..84de6244ae66 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c | |||
@@ -2502,11 +2502,9 @@ static const struct qca_device_info qca_devices_table[] = { | |||
2502 | { 0x00000302, 28, 4, 18 }, /* Rome 3.2 */ | 2502 | { 0x00000302, 28, 4, 18 }, /* Rome 3.2 */ |
2503 | }; | 2503 | }; |
2504 | 2504 | ||
2505 | static int btusb_qca_send_vendor_req(struct hci_dev *hdev, u8 request, | 2505 | static int btusb_qca_send_vendor_req(struct usb_device *udev, u8 request, |
2506 | void *data, u16 size) | 2506 | void *data, u16 size) |
2507 | { | 2507 | { |
2508 | struct btusb_data *btdata = hci_get_drvdata(hdev); | ||
2509 | struct usb_device *udev = btdata->udev; | ||
2510 | int pipe, err; | 2508 | int pipe, err; |
2511 | u8 *buf; | 2509 | u8 *buf; |
2512 | 2510 | ||
@@ -2521,7 +2519,7 @@ static int btusb_qca_send_vendor_req(struct hci_dev *hdev, u8 request, | |||
2521 | err = usb_control_msg(udev, pipe, request, USB_TYPE_VENDOR | USB_DIR_IN, | 2519 | err = usb_control_msg(udev, pipe, request, USB_TYPE_VENDOR | USB_DIR_IN, |
2522 | 0, 0, buf, size, USB_CTRL_SET_TIMEOUT); | 2520 | 0, 0, buf, size, USB_CTRL_SET_TIMEOUT); |
2523 | if (err < 0) { | 2521 | if (err < 0) { |
2524 | bt_dev_err(hdev, "Failed to access otp area (%d)", err); | 2522 | dev_err(&udev->dev, "Failed to access otp area (%d)", err); |
2525 | goto done; | 2523 | goto done; |
2526 | } | 2524 | } |
2527 | 2525 | ||
@@ -2671,20 +2669,38 @@ static int btusb_setup_qca_load_nvm(struct hci_dev *hdev, | |||
2671 | return err; | 2669 | return err; |
2672 | } | 2670 | } |
2673 | 2671 | ||
2672 | /* identify the ROM version and check whether patches are needed */ | ||
2673 | static bool btusb_qca_need_patch(struct usb_device *udev) | ||
2674 | { | ||
2675 | struct qca_version ver; | ||
2676 | |||
2677 | if (btusb_qca_send_vendor_req(udev, QCA_GET_TARGET_VERSION, &ver, | ||
2678 | sizeof(ver)) < 0) | ||
2679 | return false; | ||
2680 | /* only low ROM versions need patches */ | ||
2681 | return !(le32_to_cpu(ver.rom_version) & ~0xffffU); | ||
2682 | } | ||
2683 | |||
2674 | static int btusb_setup_qca(struct hci_dev *hdev) | 2684 | static int btusb_setup_qca(struct hci_dev *hdev) |
2675 | { | 2685 | { |
2686 | struct btusb_data *btdata = hci_get_drvdata(hdev); | ||
2687 | struct usb_device *udev = btdata->udev; | ||
2676 | const struct qca_device_info *info = NULL; | 2688 | const struct qca_device_info *info = NULL; |
2677 | struct qca_version ver; | 2689 | struct qca_version ver; |
2678 | u32 ver_rom; | 2690 | u32 ver_rom; |
2679 | u8 status; | 2691 | u8 status; |
2680 | int i, err; | 2692 | int i, err; |
2681 | 2693 | ||
2682 | err = btusb_qca_send_vendor_req(hdev, QCA_GET_TARGET_VERSION, &ver, | 2694 | err = btusb_qca_send_vendor_req(udev, QCA_GET_TARGET_VERSION, &ver, |
2683 | sizeof(ver)); | 2695 | sizeof(ver)); |
2684 | if (err < 0) | 2696 | if (err < 0) |
2685 | return err; | 2697 | return err; |
2686 | 2698 | ||
2687 | ver_rom = le32_to_cpu(ver.rom_version); | 2699 | ver_rom = le32_to_cpu(ver.rom_version); |
2700 | /* Don't care about high ROM versions */ | ||
2701 | if (ver_rom & ~0xffffU) | ||
2702 | return 0; | ||
2703 | |||
2688 | for (i = 0; i < ARRAY_SIZE(qca_devices_table); i++) { | 2704 | for (i = 0; i < ARRAY_SIZE(qca_devices_table); i++) { |
2689 | if (ver_rom == qca_devices_table[i].rom_version) | 2705 | if (ver_rom == qca_devices_table[i].rom_version) |
2690 | info = &qca_devices_table[i]; | 2706 | info = &qca_devices_table[i]; |
@@ -2694,7 +2710,7 @@ static int btusb_setup_qca(struct hci_dev *hdev) | |||
2694 | return -ENODEV; | 2710 | return -ENODEV; |
2695 | } | 2711 | } |
2696 | 2712 | ||
2697 | err = btusb_qca_send_vendor_req(hdev, QCA_CHECK_STATUS, &status, | 2713 | err = btusb_qca_send_vendor_req(udev, QCA_CHECK_STATUS, &status, |
2698 | sizeof(status)); | 2714 | sizeof(status)); |
2699 | if (err < 0) | 2715 | if (err < 0) |
2700 | return err; | 2716 | return err; |
@@ -2908,7 +2924,8 @@ static int btusb_probe(struct usb_interface *intf, | |||
2908 | /* Old firmware would otherwise let ath3k driver load | 2924 | /* Old firmware would otherwise let ath3k driver load |
2909 | * patch and sysconfig files | 2925 | * patch and sysconfig files |
2910 | */ | 2926 | */ |
2911 | if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001) | 2927 | if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001 && |
2928 | !btusb_qca_need_patch(udev)) | ||
2912 | return -ENODEV; | 2929 | return -ENODEV; |
2913 | } | 2930 | } |
2914 | 2931 | ||
@@ -3070,6 +3087,7 @@ static int btusb_probe(struct usb_interface *intf, | |||
3070 | } | 3087 | } |
3071 | 3088 | ||
3072 | if (id->driver_info & BTUSB_ATH3012) { | 3089 | if (id->driver_info & BTUSB_ATH3012) { |
3090 | data->setup_on_usb = btusb_setup_qca; | ||
3073 | hdev->set_bdaddr = btusb_set_bdaddr_ath3012; | 3091 | hdev->set_bdaddr = btusb_set_bdaddr_ath3012; |
3074 | set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); | 3092 | set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); |
3075 | set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); | 3093 | set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); |