aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim, Ben Young Tae <ytkim@qca.qualcomm.com>2015-02-15 18:07:33 -0500
committerMarcel Holtmann <marcel@holtmann.org>2015-03-02 20:07:01 -0500
commit3267c884cefa86c6d48c4d7c5571c20435271ecf (patch)
treef36db25ea42a03cd6dd9cacceafd681d9a36867d
parentace31982585a323afb194f56b9e0486f7bc6570c (diff)
Bluetooth: btusb: Add support for QCA ROME chipset family
This patch supports ROME Bluetooth family from Qualcomm Atheros, e.g. QCA61x4 or QCA6574. New chipset have similar firmware downloading sequences to previous chipset from Atheros, however, it doesn't support vid/pid switching after downloading the patch so that firmware needs to be handled by btusb module directly. ROME chipset can be differentiated from previous version by reading ROM version. T: Bus=03 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 16 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0cf3 ProdID=e300 Rev= 0.01 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms T: Bus=03 Lev=01 Prnt=01 Port=01 Cnt=01 Dev#= 8 Spd=12 MxCh= 0 D: Ver= 2.01 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs= 1 P: Vendor=0cf3 ProdID=e360 Rev= 0.01 C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=81(I) Atr=03(Int.) MxPS= 16 Ivl=1ms E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 0 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 0 Ivl=1ms I: If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 9 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 9 Ivl=1ms I: If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 17 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 17 Ivl=1ms I: If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 25 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 25 Ivl=1ms I: If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 33 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 33 Ivl=1ms I: If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb E: Ad=83(I) Atr=01(Isoc) MxPS= 49 Ivl=1ms E: Ad=03(O) Atr=01(Isoc) MxPS= 49 Ivl=1ms Signed-off-by: Ben Young Tae Kim <ytkim@qca.qualcomm.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r--drivers/bluetooth/btusb.c254
1 files changed, 254 insertions, 0 deletions
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 73e1066cd38b..08330548f7fe 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -52,6 +52,7 @@ static struct usb_driver btusb_driver;
52#define BTUSB_SWAVE 0x1000 52#define BTUSB_SWAVE 0x1000
53#define BTUSB_INTEL_NEW 0x2000 53#define BTUSB_INTEL_NEW 0x2000
54#define BTUSB_AMP 0x4000 54#define BTUSB_AMP 0x4000
55#define BTUSB_QCA_ROME 0x8000
55 56
56static const struct usb_device_id btusb_table[] = { 57static const struct usb_device_id btusb_table[] = {
57 /* Generic Bluetooth USB device */ 58 /* Generic Bluetooth USB device */
@@ -213,6 +214,10 @@ static const struct usb_device_id blacklist_table[] = {
213 { USB_DEVICE(0x0489, 0xe036), .driver_info = BTUSB_ATH3012 }, 214 { USB_DEVICE(0x0489, 0xe036), .driver_info = BTUSB_ATH3012 },
214 { USB_DEVICE(0x0489, 0xe03c), .driver_info = BTUSB_ATH3012 }, 215 { USB_DEVICE(0x0489, 0xe03c), .driver_info = BTUSB_ATH3012 },
215 216
217 /* QCA ROME chipset */
218 { USB_DEVICE(0x0cf3, 0xe300), .driver_info = BTUSB_QCA_ROME},
219 { USB_DEVICE(0x0cf3, 0xe360), .driver_info = BTUSB_QCA_ROME},
220
216 /* Broadcom BCM2035 */ 221 /* Broadcom BCM2035 */
217 { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 }, 222 { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 },
218 { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU }, 223 { USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU },
@@ -2638,6 +2643,250 @@ static int btusb_set_bdaddr_ath3012(struct hci_dev *hdev,
2638 return 0; 2643 return 0;
2639} 2644}
2640 2645
2646#define QCA_DFU_PACKET_LEN 4096
2647
2648#define QCA_GET_TARGET_VERSION 0x09
2649#define QCA_CHECK_STATUS 0x05
2650#define QCA_DFU_DOWNLOAD 0x01
2651
2652#define QCA_SYSCFG_UPDATED 0x40
2653#define QCA_PATCH_UPDATED 0x80
2654#define QCA_DFU_TIMEOUT 3000
2655
2656struct qca_version {
2657 __le32 rom_version;
2658 __le32 patch_version;
2659 __le32 ram_version;
2660 __le32 ref_clock;
2661 __u8 reserved[4];
2662} __packed;
2663
2664struct qca_rampatch_version {
2665 __le16 rom_version;
2666 __le16 patch_version;
2667} __packed;
2668
2669struct qca_device_info {
2670 __le32 rom_version;
2671 __u8 rampatch_hdr; /* length of header in rampatch */
2672 __u8 nvm_hdr; /* length of header in NVM */
2673 __u8 ver_offset; /* offset of version structure in rampatch */
2674};
2675
2676static const struct qca_device_info qca_devices_table[] = {
2677 { 0x00000100, 20, 4, 10 }, /* Rome 1.0 */
2678 { 0x00000101, 20, 4, 10 }, /* Rome 1.1 */
2679 { 0x00000201, 28, 4, 18 }, /* Rome 2.1 */
2680 { 0x00000300, 28, 4, 18 }, /* Rome 3.0 */
2681 { 0x00000302, 28, 4, 18 }, /* Rome 3.2 */
2682};
2683
2684static int btusb_qca_send_vendor_req(struct hci_dev *hdev, u8 request,
2685 void *data, u16 size)
2686{
2687 struct btusb_data *btdata = hci_get_drvdata(hdev);
2688 struct usb_device *udev = btdata->udev;
2689 int pipe, err;
2690 u8 *buf;
2691
2692 buf = kmalloc(size, GFP_KERNEL);
2693 if (!buf)
2694 return -ENOMEM;
2695
2696 /* Found some of USB hosts have IOT issues with ours so that we should
2697 * not wait until HCI layer is ready.
2698 */
2699 pipe = usb_rcvctrlpipe(udev, 0);
2700 err = usb_control_msg(udev, pipe, request, USB_TYPE_VENDOR | USB_DIR_IN,
2701 0, 0, buf, size, USB_CTRL_SET_TIMEOUT);
2702 if (err < 0) {
2703 BT_ERR("%s: Failed to access otp area (%d)", hdev->name, err);
2704 goto done;
2705 }
2706
2707 memcpy(data, buf, size);
2708
2709done:
2710 kfree(buf);
2711
2712 return err;
2713}
2714
2715static int btusb_setup_qca_download_fw(struct hci_dev *hdev,
2716 const struct firmware *firmware,
2717 size_t hdr_size)
2718{
2719 struct btusb_data *btdata = hci_get_drvdata(hdev);
2720 struct usb_device *udev = btdata->udev;
2721 size_t count, size, sent = 0;
2722 int pipe, len, err;
2723 u8 *buf;
2724
2725 buf = kmalloc(QCA_DFU_PACKET_LEN, GFP_KERNEL);
2726 if (!buf)
2727 return -ENOMEM;
2728
2729 count = firmware->size;
2730
2731 size = min_t(size_t, count, hdr_size);
2732 memcpy(buf, firmware->data, size);
2733
2734 /* USB patches should go down to controller through USB path
2735 * because binary format fits to go down through USB channel.
2736 * USB control path is for patching headers and USB bulk is for
2737 * patch body.
2738 */
2739 pipe = usb_sndctrlpipe(udev, 0);
2740 err = usb_control_msg(udev, pipe, QCA_DFU_DOWNLOAD, USB_TYPE_VENDOR,
2741 0, 0, buf, size, USB_CTRL_SET_TIMEOUT);
2742 if (err < 0) {
2743 BT_ERR("%s: Failed to send headers (%d)", hdev->name, err);
2744 goto done;
2745 }
2746
2747 sent += size;
2748 count -= size;
2749
2750 while (count) {
2751 size = min_t(size_t, count, QCA_DFU_PACKET_LEN);
2752
2753 memcpy(buf, firmware->data + sent, size);
2754
2755 pipe = usb_sndbulkpipe(udev, 0x02);
2756 err = usb_bulk_msg(udev, pipe, buf, size, &len,
2757 QCA_DFU_TIMEOUT);
2758 if (err < 0) {
2759 BT_ERR("%s: Failed to send body at %zd of %zd (%d)",
2760 hdev->name, sent, firmware->size, err);
2761 break;
2762 }
2763
2764 if (size != len) {
2765 BT_ERR("%s: Failed to get bulk buffer", hdev->name);
2766 err = -EILSEQ;
2767 break;
2768 }
2769
2770 sent += size;
2771 count -= size;
2772 }
2773
2774done:
2775 kfree(buf);
2776 return err;
2777}
2778
2779static int btusb_setup_qca_load_rampatch(struct hci_dev *hdev,
2780 struct qca_version *ver,
2781 const struct qca_device_info *info)
2782{
2783 struct qca_rampatch_version *rver;
2784 const struct firmware *fw;
2785 char fwname[64];
2786 int err;
2787
2788 snprintf(fwname, sizeof(fwname), "qca/rampatch_usb_%08x.bin",
2789 le32_to_cpu(ver->rom_version));
2790
2791 err = request_firmware(&fw, fwname, &hdev->dev);
2792 if (err) {
2793 BT_ERR("%s: failed to request rampatch file: %s (%d)",
2794 hdev->name, fwname, err);
2795 return err;
2796 }
2797
2798 BT_INFO("%s: using rampatch file: %s", hdev->name, fwname);
2799 rver = (struct qca_rampatch_version *)(fw->data + info->ver_offset);
2800 BT_INFO("%s: QCA: patch rome 0x%x build 0x%x, firmware rome 0x%x "
2801 "build 0x%x", hdev->name, le16_to_cpu(rver->