Lines Matching +full:diag +full:- +full:version

1 // SPDX-License-Identifier: GPL-2.0-or-later
6 * Copyright (C) 2005-2008 Marcel Holtmann <marcel@holtmann.org>
30 #define VERSION "0.8" macro
79 /* Apple-specific (Broadcom) devices */
116 /* ALPS Modules with non-standard id */
120 /* Ericsson with non-standard id */
123 /* Canyon CN-BTU1 with HID interfaces */
137 /* Foxconn - Hon Hai */
141 /* Lite-On Technology - Broadcom based */
149 /* ASUSTek Computer - Broadcom based */
153 /* Belkin F8065bf - Broadcom based */
157 /* IMC Networks - Broadcom based */
161 /* Dell Computer - Broadcom based */
165 /* Toshiba Corp - Broadcom based */
402 /* Asus WL-BTD202 device */
530 /* Realtek 8852BT/8852BE-VT Bluetooth devices */
793 struct usb_interface *diag; member
850 int oob_wake_irq; /* irq for out-of-band wake-on-bt */
861 if (hdev->reset) { in btusb_reset()
862 hdev->reset(hdev); in btusb_reset()
868 err = usb_autopm_get_interface(data->intf); in btusb_reset()
875 usb_queue_reset_device(data->intf); in btusb_reset()
881 struct gpio_desc *reset_gpio = data->reset_gpio; in btusb_intel_cmd_timeout()
884 if (++data->cmd_timeout_cnt < 5) in btusb_intel_cmd_timeout()
887 if (intel_data->acpi_reset_method) { in btusb_intel_cmd_timeout()
888 if (test_and_set_bit(INTEL_ACPI_RESET_ACTIVE, intel_data->flags)) { in btusb_intel_cmd_timeout()
897 if (!intel_data->acpi_reset_method(hdev)) { in btusb_intel_cmd_timeout()
914 if (test_and_set_bit(BTUSB_HW_RESET_ACTIVE, &data->flags)) { in btusb_intel_cmd_timeout()
950 if (!hci_devcd_init(hdev, skb->len)) { in btusb_rtl_alloc_devcoredump()
962 struct gpio_desc *reset_gpio = data->reset_gpio; in btusb_rtl_cmd_timeout()
969 if (++data->cmd_timeout_cnt < 5) in btusb_rtl_cmd_timeout()
983 if (test_and_set_bit(BTUSB_HW_RESET_ACTIVE, &data->flags)) { in btusb_rtl_cmd_timeout()
1009 struct gpio_desc *reset_gpio = data->reset_gpio; in btusb_qca_cmd_timeout()
1011 if (test_bit(BTUSB_HW_SSR_ACTIVE, &data->flags)) { in btusb_qca_cmd_timeout()
1016 if (++data->cmd_timeout_cnt < 5) in btusb_qca_cmd_timeout()
1028 if (test_and_set_bit(BTUSB_HW_RESET_ACTIVE, &data->flags)) { in btusb_qca_cmd_timeout()
1047 spin_lock_irqsave(&data->rxlock, flags); in btusb_free_frags()
1049 dev_kfree_skb_irq(data->evt_skb); in btusb_free_frags()
1050 data->evt_skb = NULL; in btusb_free_frags()
1052 dev_kfree_skb_irq(data->acl_skb); in btusb_free_frags()
1053 data->acl_skb = NULL; in btusb_free_frags()
1055 dev_kfree_skb_irq(data->sco_skb); in btusb_free_frags()
1056 data->sco_skb = NULL; in btusb_free_frags()
1058 spin_unlock_irqrestore(&data->rxlock, flags); in btusb_free_frags()
1063 if (data->intr_interval) { in btusb_recv_event()
1065 schedule_delayed_work(&data->rx_work, 0); in btusb_recv_event()
1068 return data->recv_event(data->hdev, skb); in btusb_recv_event()
1077 spin_lock_irqsave(&data->rxlock, flags); in btusb_recv_intr()
1078 skb = data->evt_skb; in btusb_recv_intr()
1086 err = -ENOMEM; in btusb_recv_intr()
1097 count -= len; in btusb_recv_intr()
1099 hci_skb_expect(skb) -= len; in btusb_recv_intr()
1101 if (skb->len == HCI_EVENT_HDR_SIZE) { in btusb_recv_intr()
1103 hci_skb_expect(skb) = hci_event_hdr(skb)->plen; in btusb_recv_intr()
1109 err = -EILSEQ; in btusb_recv_intr()
1121 data->evt_skb = skb; in btusb_recv_intr()
1122 spin_unlock_irqrestore(&data->rxlock, flags); in btusb_recv_intr()
1132 if (!data->intr_interval) in btusb_recv_acl()
1133 return data->recv_acl(data->hdev, skb); in btusb_recv_acl()
1135 skb_queue_tail(&data->acl_q, skb); in btusb_recv_acl()
1136 schedule_delayed_work(&data->rx_work, data->intr_interval); in btusb_recv_acl()
1147 spin_lock_irqsave(&data->rxlock, flags); in btusb_recv_bulk()
1148 skb = data->acl_skb; in btusb_recv_bulk()
1156 err = -ENOMEM; in btusb_recv_bulk()
1167 count -= len; in btusb_recv_bulk()
1169 hci_skb_expect(skb) -= len; in btusb_recv_bulk()
1171 if (skb->len == HCI_ACL_HDR_SIZE) { in btusb_recv_bulk()
1172 __le16 dlen = hci_acl_hdr(skb)->dlen; in btusb_recv_bulk()
1181 err = -EILSEQ; in btusb_recv_bulk()
1193 data->acl_skb = skb; in btusb_recv_bulk()
1194 spin_unlock_irqrestore(&data->rxlock, flags); in btusb_recv_bulk()
1216 handle = hci_handle(__le16_to_cpu(hdr->handle)); in btusb_validate_sco_handle()
1233 spin_lock_irqsave(&data->rxlock, flags); in btusb_recv_isoc()
1234 skb = data->sco_skb; in btusb_recv_isoc()
1242 err = -ENOMEM; in btusb_recv_isoc()
1253 count -= len; in btusb_recv_isoc()
1255 hci_skb_expect(skb) -= len; in btusb_recv_isoc()
1257 if (skb->len == HCI_SCO_HDR_SIZE) { in btusb_recv_isoc()
1261 hci_skb_expect(skb) = hdr->dlen; in btusb_recv_isoc()
1264 !btusb_validate_sco_handle(data->hdev, hdr)) { in btusb_recv_isoc()
1268 err = -EILSEQ; in btusb_recv_isoc()
1275 hci_recv_frame(data->hdev, skb); in btusb_recv_isoc()
1280 data->sco_skb = skb; in btusb_recv_isoc()
1281 spin_unlock_irqrestore(&data->rxlock, flags); in btusb_recv_isoc()
1288 struct hci_dev *hdev = urb->context; in btusb_intr_complete()
1292 BT_DBG("%s urb %p status %d count %d", hdev->name, urb, urb->status, in btusb_intr_complete()
1293 urb->actual_length); in btusb_intr_complete()
1295 if (!test_bit(HCI_RUNNING, &hdev->flags)) in btusb_intr_complete()
1298 if (urb->status == 0) { in btusb_intr_complete()
1299 hdev->stat.byte_rx += urb->actual_length; in btusb_intr_complete()
1301 if (btusb_recv_intr(data, urb->transfer_buffer, in btusb_intr_complete()
1302 urb->actual_length) < 0) { in btusb_intr_complete()
1304 hdev->stat.err_rx++; in btusb_intr_complete()
1306 } else if (urb->status == -ENOENT) { in btusb_intr_complete()
1311 if (!test_bit(BTUSB_INTR_RUNNING, &data->flags)) in btusb_intr_complete()
1314 usb_mark_last_busy(data->udev); in btusb_intr_complete()
1315 usb_anchor_urb(urb, &data->intr_anchor); in btusb_intr_complete()
1319 /* -EPERM: urb is being killed; in btusb_intr_complete()
1320 * -ENODEV: device got disconnected in btusb_intr_complete()
1322 if (err != -EPERM && err != -ENODEV) in btusb_intr_complete()
1324 urb, -err); in btusb_intr_complete()
1325 if (err != -EPERM) in btusb_intr_complete()
1326 hci_cmd_sync_cancel(hdev, -err); in btusb_intr_complete()
1339 BT_DBG("%s", hdev->name); in btusb_submit_intr_urb()
1341 if (!data->intr_ep) in btusb_submit_intr_urb()
1342 return -ENODEV; in btusb_submit_intr_urb()
1346 return -ENOMEM; in btusb_submit_intr_urb()
1348 if (le16_to_cpu(data->udev->descriptor.idVendor) == 0x0a12 && in btusb_submit_intr_urb()
1349 le16_to_cpu(data->udev->descriptor.idProduct) == 0x0001) in btusb_submit_intr_urb()
1350 /* Fake CSR devices don't seem to support sort-transter */ in btusb_submit_intr_urb()
1351 size = le16_to_cpu(data->intr_ep->wMaxPacketSize); in btusb_submit_intr_urb()
1354 * ZPL/short-transfer automatically. in btusb_submit_intr_urb()
1361 return -ENOMEM; in btusb_submit_intr_urb()
1364 pipe = usb_rcvintpipe(data->udev, data->intr_ep->bEndpointAddress); in btusb_submit_intr_urb()
1366 usb_fill_int_urb(urb, data->udev, pipe, buf, size, in btusb_submit_intr_urb()
1367 btusb_intr_complete, hdev, data->intr_ep->bInterval); in btusb_submit_intr_urb()
1369 urb->transfer_flags |= URB_FREE_BUFFER; in btusb_submit_intr_urb()
1371 usb_anchor_urb(urb, &data->intr_anchor); in btusb_submit_intr_urb()
1375 if (err != -EPERM && err != -ENODEV) in btusb_submit_intr_urb()
1377 urb, -err); in btusb_submit_intr_urb()
1378 if (err != -EPERM) in btusb_submit_intr_urb()
1379 hci_cmd_sync_cancel(hdev, -err); in btusb_submit_intr_urb()
1384 if (!data->poll_sync) in btusb_submit_intr_urb()
1394 switch (urb->dev->speed) { in btusb_submit_intr_urb()
1397 data->intr_interval = usecs_to_jiffies(urb->interval * 125); in btusb_submit_intr_urb()
1400 data->intr_interval = msecs_to_jiffies(urb->interval); in btusb_submit_intr_urb()
1412 struct hci_dev *hdev = urb->context; in btusb_bulk_complete()
1416 BT_DBG("%s urb %p status %d count %d", hdev->name, urb, urb->status, in btusb_bulk_complete()
1417 urb->actual_length); in btusb_bulk_complete()
1419 if (!test_bit(HCI_RUNNING, &hdev->flags)) in btusb_bulk_complete()
1422 if (urb->status == 0) { in btusb_bulk_complete()
1423 hdev->stat.byte_rx += urb->actual_length; in btusb_bulk_complete()
1425 if (data->recv_bulk(data, urb->transfer_buffer, in btusb_bulk_complete()
1426 urb->actual_length) < 0) { in btusb_bulk_complete()
1428 hdev->stat.err_rx++; in btusb_bulk_complete()
1430 } else if (urb->status == -ENOENT) { in btusb_bulk_complete()
1435 if (!test_bit(BTUSB_BULK_RUNNING, &data->flags)) in btusb_bulk_complete()
1438 usb_anchor_urb(urb, &data->bulk_anchor); in btusb_bulk_complete()
1439 usb_mark_last_busy(data->udev); in btusb_bulk_complete()
1443 /* -EPERM: urb is being killed; in btusb_bulk_complete()
1444 * -ENODEV: device got disconnected in btusb_bulk_complete()
1446 if (err != -EPERM && err != -ENODEV) in btusb_bulk_complete()
1448 urb, -err); in btusb_bulk_complete()
1461 BT_DBG("%s", hdev->name); in btusb_submit_bulk_urb()
1463 if (!data->bulk_rx_ep) in btusb_submit_bulk_urb()
1464 return -ENODEV; in btusb_submit_bulk_urb()
1468 return -ENOMEM; in btusb_submit_bulk_urb()
1473 return -ENOMEM; in btusb_submit_bulk_urb()
1476 pipe = usb_rcvbulkpipe(data->udev, data->bulk_rx_ep->bEndpointAddress); in btusb_submit_bulk_urb()
1478 usb_fill_bulk_urb(urb, data->udev, pipe, buf, size, in btusb_submit_bulk_urb()
1481 urb->transfer_flags |= URB_FREE_BUFFER; in btusb_submit_bulk_urb()
1483 usb_mark_last_busy(data->udev); in btusb_submit_bulk_urb()
1484 usb_anchor_urb(urb, &data->bulk_anchor); in btusb_submit_bulk_urb()
1488 if (err != -EPERM && err != -ENODEV) in btusb_submit_bulk_urb()
1490 urb, -err); in btusb_submit_bulk_urb()
1501 struct hci_dev *hdev = urb->context; in btusb_isoc_complete()
1505 BT_DBG("%s urb %p status %d count %d", hdev->name, urb, urb->status, in btusb_isoc_complete()
1506 urb->actual_length); in btusb_isoc_complete()
1508 if (!test_bit(HCI_RUNNING, &hdev->flags)) in btusb_isoc_complete()
1511 if (urb->status == 0) { in btusb_isoc_complete()
1512 for (i = 0; i < urb->number_of_packets; i++) { in btusb_isoc_complete()
1513 unsigned int offset = urb->iso_frame_desc[i].offset; in btusb_isoc_complete()
1514 unsigned int length = urb->iso_frame_desc[i].actual_length; in btusb_isoc_complete()
1516 if (urb->iso_frame_desc[i].status) in btusb_isoc_complete()
1519 hdev->stat.byte_rx += length; in btusb_isoc_complete()
1521 if (btusb_recv_isoc(data, urb->transfer_buffer + offset, in btusb_isoc_complete()
1524 hdev->stat.err_rx++; in btusb_isoc_complete()
1527 } else if (urb->status == -ENOENT) { in btusb_isoc_complete()
1532 if (!test_bit(BTUSB_ISOC_RUNNING, &data->flags)) in btusb_isoc_complete()
1535 usb_anchor_urb(urb, &data->isoc_anchor); in btusb_isoc_complete()
1539 /* -EPERM: urb is being killed; in btusb_isoc_complete()
1540 * -ENODEV: device got disconnected in btusb_isoc_complete()
1542 if (err != -EPERM && err != -ENODEV) in btusb_isoc_complete()
1544 urb, -err); in btusb_isoc_complete()
1560 if (test_bit(BTUSB_ALT6_CONTINUOUS_TX, &data->flags)) in __fill_isoc_descriptor_msbc()
1569 if (data->usb_alt6_packet_flow) { in __fill_isoc_descriptor_msbc()
1571 data->usb_alt6_packet_flow = false; in __fill_isoc_descriptor_msbc()
1574 data->usb_alt6_packet_flow = true; in __fill_isoc_descriptor_msbc()
1578 urb->iso_frame_desc[i].offset = offset; in __fill_isoc_descriptor_msbc()
1579 urb->iso_frame_desc[i].length = offset; in __fill_isoc_descriptor_msbc()
1584 urb->iso_frame_desc[i].offset = offset; in __fill_isoc_descriptor_msbc()
1585 urb->iso_frame_desc[i].length = len; in __fill_isoc_descriptor_msbc()
1589 urb->number_of_packets = i; in __fill_isoc_descriptor_msbc()
1599 i++, offset += mtu, len -= mtu) { in __fill_isoc_descriptor()
1600 urb->iso_frame_desc[i].offset = offset; in __fill_isoc_descriptor()
1601 urb->iso_frame_desc[i].length = mtu; in __fill_isoc_descriptor()
1605 urb->iso_frame_desc[i].offset = offset; in __fill_isoc_descriptor()
1606 urb->iso_frame_desc[i].length = len; in __fill_isoc_descriptor()
1610 urb->number_of_packets = i; in __fill_isoc_descriptor()
1621 BT_DBG("%s", hdev->name); in btusb_submit_isoc_urb()
1623 if (!data->isoc_rx_ep) in btusb_submit_isoc_urb()
1624 return -ENODEV; in btusb_submit_isoc_urb()
1628 return -ENOMEM; in btusb_submit_isoc_urb()
1630 size = le16_to_cpu(data->isoc_rx_ep->wMaxPacketSize) * in btusb_submit_isoc_urb()
1636 return -ENOMEM; in btusb_submit_isoc_urb()
1639 pipe = usb_rcvisocpipe(data->udev, data->isoc_rx_ep->bEndpointAddress); in btusb_submit_isoc_urb()
1641 usb_fill_int_urb(urb, data->udev, pipe, buf, size, btusb_isoc_complete, in btusb_submit_isoc_urb()
1642 hdev, data->isoc_rx_ep->bInterval); in btusb_submit_isoc_urb()
1644 urb->transfer_flags = URB_FREE_BUFFER | URB_ISO_ASAP; in btusb_submit_isoc_urb()
1647 le16_to_cpu(data->isoc_rx_ep->wMaxPacketSize)); in btusb_submit_isoc_urb()
1649 usb_anchor_urb(urb, &data->isoc_anchor); in btusb_submit_isoc_urb()
1653 if (err != -EPERM && err != -ENODEV) in btusb_submit_isoc_urb()
1655 urb, -err); in btusb_submit_isoc_urb()
1666 struct hci_dev *hdev = urb->context; in btusb_diag_complete()
1670 BT_DBG("%s urb %p status %d count %d", hdev->name, urb, urb->status, in btusb_diag_complete()
1671 urb->actual_length); in btusb_diag_complete()
1673 if (urb->status == 0) { in btusb_diag_complete()
1676 skb = bt_skb_alloc(urb->actual_length, GFP_ATOMIC); in btusb_diag_complete()
1678 skb_put_data(skb, urb->transfer_buffer, in btusb_diag_complete()
1679 urb->actual_length); in btusb_diag_complete()
1682 } else if (urb->status == -ENOENT) { in btusb_diag_complete()
1687 if (!test_bit(BTUSB_DIAG_RUNNING, &data->flags)) in btusb_diag_complete()
1690 usb_anchor_urb(urb, &data->diag_anchor); in btusb_diag_complete()
1691 usb_mark_last_busy(data->udev); in btusb_diag_complete()
1695 /* -EPERM: urb is being killed; in btusb_diag_complete()
1696 * -ENODEV: device got disconnected in btusb_diag_complete()
1698 if (err != -EPERM && err != -ENODEV) in btusb_diag_complete()
1700 urb, -err); in btusb_diag_complete()
1713 BT_DBG("%s", hdev->name); in btusb_submit_diag_urb()
1715 if (!data->diag_rx_ep) in btusb_submit_diag_urb()
1716 return -ENODEV; in btusb_submit_diag_urb()
1720 return -ENOMEM; in btusb_submit_diag_urb()
1725 return -ENOMEM; in btusb_submit_diag_urb()
1728 pipe = usb_rcvbulkpipe(data->udev, data->diag_rx_ep->bEndpointAddress); in btusb_submit_diag_urb()
1730 usb_fill_bulk_urb(urb, data->udev, pipe, buf, size, in btusb_submit_diag_urb()
1733 urb->transfer_flags |= URB_FREE_BUFFER; in btusb_submit_diag_urb()
1735 usb_mark_last_busy(data->udev); in btusb_submit_diag_urb()
1736 usb_anchor_urb(urb, &data->diag_anchor); in btusb_submit_diag_urb()
1740 if (err != -EPERM && err != -ENODEV) in btusb_submit_diag_urb()
1742 urb, -err); in btusb_submit_diag_urb()
1753 struct sk_buff *skb = urb->context; in btusb_tx_complete()
1754 struct hci_dev *hdev = (struct hci_dev *)skb->dev; in btusb_tx_complete()
1758 BT_DBG("%s urb %p status %d count %d", hdev->name, urb, urb->status, in btusb_tx_complete()
1759 urb->actual_length); in btusb_tx_complete()
1761 if (!test_bit(HCI_RUNNING, &hdev->flags)) in btusb_tx_complete()
1764 if (!urb->status) { in btusb_tx_complete()
1765 hdev->stat.byte_tx += urb->transfer_buffer_length; in btusb_tx_complete()
1768 hci_cmd_sync_cancel(hdev, -urb->status); in btusb_tx_complete()
1769 hdev->stat.err_tx++; in btusb_tx_complete()
1773 spin_lock_irqsave(&data->txlock, flags); in btusb_tx_complete()
1774 data->tx_in_flight--; in btusb_tx_complete()
1775 spin_unlock_irqrestore(&data->txlock, flags); in btusb_tx_complete()
1777 kfree(urb->setup_packet); in btusb_tx_complete()
1784 struct sk_buff *skb = urb->context; in btusb_isoc_tx_complete()
1785 struct hci_dev *hdev = (struct hci_dev *)skb->dev; in btusb_isoc_tx_complete()
1787 BT_DBG("%s urb %p status %d count %d", hdev->name, urb, urb->status, in btusb_isoc_tx_complete()
1788 urb->actual_length); in btusb_isoc_tx_complete()
1790 if (!test_bit(HCI_RUNNING, &hdev->flags)) in btusb_isoc_tx_complete()
1793 if (!urb->status) in btusb_isoc_tx_complete()
1794 hdev->stat.byte_tx += urb->transfer_buffer_length; in btusb_isoc_tx_complete()
1796 hdev->stat.err_tx++; in btusb_isoc_tx_complete()
1799 kfree(urb->setup_packet); in btusb_isoc_tx_complete()
1809 BT_DBG("%s", hdev->name); in btusb_open()
1811 err = usb_autopm_get_interface(data->intf); in btusb_open()
1818 if (data->setup_on_usb) { in btusb_open()
1819 err = data->setup_on_usb(hdev); in btusb_open()
1824 data->intf->needs_remote_wakeup = 1; in btusb_open()
1826 if (test_and_set_bit(BTUSB_INTR_RUNNING, &data->flags)) in btusb_open()
1835 usb_kill_anchored_urbs(&data->intr_anchor); in btusb_open()
1839 set_bit(BTUSB_BULK_RUNNING, &data->flags); in btusb_open()
1842 if (data->diag) { in btusb_open()
1844 set_bit(BTUSB_DIAG_RUNNING, &data->flags); in btusb_open()
1848 usb_autopm_put_interface(data->intf); in btusb_open()
1852 clear_bit(BTUSB_INTR_RUNNING, &data->flags); in btusb_open()
1854 usb_autopm_put_interface(data->intf); in btusb_open()
1860 usb_kill_anchored_urbs(&data->intr_anchor); in btusb_stop_traffic()
1861 usb_kill_anchored_urbs(&data->bulk_anchor); in btusb_stop_traffic()
1862 usb_kill_anchored_urbs(&data->isoc_anchor); in btusb_stop_traffic()
1863 usb_kill_anchored_urbs(&data->diag_anchor); in btusb_stop_traffic()
1864 usb_kill_anchored_urbs(&data->ctrl_anchor); in btusb_stop_traffic()
1872 BT_DBG("%s", hdev->name); in btusb_close()
1874 cancel_delayed_work(&data->rx_work); in btusb_close()
1875 cancel_work_sync(&data->work); in btusb_close()
1876 cancel_work_sync(&data->waker); in btusb_close()
1878 skb_queue_purge(&data->acl_q); in btusb_close()
1880 clear_bit(BTUSB_ISOC_RUNNING, &data->flags); in btusb_close()
1881 clear_bit(BTUSB_BULK_RUNNING, &data->flags); in btusb_close()
1882 clear_bit(BTUSB_INTR_RUNNING, &data->flags); in btusb_close()
1883 clear_bit(BTUSB_DIAG_RUNNING, &data->flags); in btusb_close()
1888 err = usb_autopm_get_interface(data->intf); in btusb_close()
1892 data->intf->needs_remote_wakeup = 0; in btusb_close()
1894 /* Enable remote wake up for auto-suspend */ in btusb_close()
1895 if (test_bit(BTUSB_WAKEUP_AUTOSUSPEND, &data->flags)) in btusb_close()
1896 data->intf->needs_remote_wakeup = 1; in btusb_close()
1898 usb_autopm_put_interface(data->intf); in btusb_close()
1901 usb_scuttle_anchored_urbs(&data->deferred); in btusb_close()
1909 BT_DBG("%s", hdev->name); in btusb_flush()
1911 cancel_delayed_work(&data->rx_work); in btusb_flush()
1913 skb_queue_purge(&data->acl_q); in btusb_flush()
1915 usb_kill_anchored_urbs(&data->tx_anchor); in btusb_flush()
1930 return ERR_PTR(-ENOMEM); in alloc_ctrl_urb()
1935 return ERR_PTR(-ENOMEM); in alloc_ctrl_urb()
1938 dr->bRequestType = data->cmdreq_type; in alloc_ctrl_urb()
1939 dr->bRequest = data->cmdreq; in alloc_ctrl_urb()
1940 dr->wIndex = 0; in alloc_ctrl_urb()
1941 dr->wValue = 0; in alloc_ctrl_urb()
1942 dr->wLength = __cpu_to_le16(skb->len); in alloc_ctrl_urb()
1944 pipe = usb_sndctrlpipe(data->udev, 0x00); in alloc_ctrl_urb()
1946 usb_fill_control_urb(urb, data->udev, pipe, (void *)dr, in alloc_ctrl_urb()
1947 skb->data, skb->len, btusb_tx_complete, skb); in alloc_ctrl_urb()
1949 skb->dev = (void *)hdev; in alloc_ctrl_urb()
1960 if (!data->bulk_tx_ep) in alloc_bulk_urb()
1961 return ERR_PTR(-ENODEV); in alloc_bulk_urb()
1965 return ERR_PTR(-ENOMEM); in alloc_bulk_urb()
1967 pipe = usb_sndbulkpipe(data->udev, data->bulk_tx_ep->bEndpointAddress); in alloc_bulk_urb()
1969 usb_fill_bulk_urb(urb, data->udev, pipe, in alloc_bulk_urb()
1970 skb->data, skb->len, btusb_tx_complete, skb); in alloc_bulk_urb()
1972 skb->dev = (void *)hdev; in alloc_bulk_urb()
1983 if (!data->isoc_tx_ep) in alloc_isoc_urb()
1984 return ERR_PTR(-ENODEV); in alloc_isoc_urb()
1988 return ERR_PTR(-ENOMEM); in alloc_isoc_urb()
1990 pipe = usb_sndisocpipe(data->udev, data->isoc_tx_ep->bEndpointAddress); in alloc_isoc_urb()
1992 usb_fill_int_urb(urb, data->udev, pipe, in alloc_isoc_urb()
1993 skb->data, skb->len, btusb_isoc_tx_complete, in alloc_isoc_urb()
1994 skb, data->isoc_tx_ep->bInterval); in alloc_isoc_urb()
1996 urb->transfer_flags = URB_ISO_ASAP; in alloc_isoc_urb()
1998 if (data->isoc_altsetting == 6) in alloc_isoc_urb()
1999 __fill_isoc_descriptor_msbc(urb, skb->len, in alloc_isoc_urb()
2000 le16_to_cpu(data->isoc_tx_ep->wMaxPacketSize), in alloc_isoc_urb()
2003 __fill_isoc_descriptor(urb, skb->len, in alloc_isoc_urb()
2004 le16_to_cpu(data->isoc_tx_ep->wMaxPacketSize)); in alloc_isoc_urb()
2005 skb->dev = (void *)hdev; in alloc_isoc_urb()
2015 usb_anchor_urb(urb, &data->tx_anchor); in submit_tx_urb()
2019 if (err != -EPERM && err != -ENODEV) in submit_tx_urb()
2021 urb, -err); in submit_tx_urb()
2022 kfree(urb->setup_packet); in submit_tx_urb()
2025 usb_mark_last_busy(data->udev); in submit_tx_urb()
2038 spin_lock_irqsave(&data->txlock, flags); in submit_or_queue_tx_urb()
2039 suspending = test_bit(BTUSB_SUSPENDING, &data->flags); in submit_or_queue_tx_urb()
2041 data->tx_in_flight++; in submit_or_queue_tx_urb()
2042 spin_unlock_irqrestore(&data->txlock, flags); in submit_or_queue_tx_urb()
2047 usb_anchor_urb(urb, &data->deferred); in submit_or_queue_tx_urb()
2048 schedule_work(&data->waker); in submit_or_queue_tx_urb()
2058 BT_DBG("%s", hdev->name); in btusb_send_frame()
2066 hdev->stat.cmd_tx++; in btusb_send_frame()
2074 hdev->stat.acl_tx++; in btusb_send_frame()
2079 return -ENODEV; in btusb_send_frame()
2085 hdev->stat.sco_tx++; in btusb_send_frame()
2096 return -EILSEQ; in btusb_send_frame()
2103 BT_DBG("%s evt %d", hdev->name, evt); in btusb_notify()
2105 if (hci_conn_num(hdev, SCO_LINK) != data->sco_num) { in btusb_notify()
2106 data->sco_num = hci_conn_num(hdev, SCO_LINK); in btusb_notify()
2107 data->air_mode = evt; in btusb_notify()
2108 schedule_work(&data->work); in btusb_notify()
2115 struct usb_interface *intf = data->isoc; in __set_isoc_interface()
2119 if (!data->isoc) in __set_isoc_interface()
2120 return -ENODEV; in __set_isoc_interface()
2122 err = usb_set_interface(data->udev, data->isoc_ifnum, altsetting); in __set_isoc_interface()
2124 bt_dev_err(hdev, "setting interface failed (%d)", -err); in __set_isoc_interface()
2128 data->isoc_altsetting = altsetting; in __set_isoc_interface()
2130 data->isoc_tx_ep = NULL; in __set_isoc_interface()
2131 data->isoc_rx_ep = NULL; in __set_isoc_interface()
2133 for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) { in __set_isoc_interface()
2134 ep_desc = &intf->cur_altsetting->endpoint[i].desc; in __set_isoc_interface()
2136 if (!data->isoc_tx_ep && usb_endpoint_is_isoc_out(ep_desc)) { in __set_isoc_interface()
2137 data->isoc_tx_ep = ep_desc; in __set_isoc_interface()
2141 if (!data->isoc_rx_ep && usb_endpoint_is_isoc_in(ep_desc)) { in __set_isoc_interface()
2142 data->isoc_rx_ep = ep_desc; in __set_isoc_interface()
2147 if (!data->isoc_tx_ep || !data->isoc_rx_ep) { in __set_isoc_interface()
2149 return -ENODEV; in __set_isoc_interface()
2160 if (data->isoc_altsetting != new_alts) { in btusb_switch_alt_setting()
2163 clear_bit(BTUSB_ISOC_RUNNING, &data->flags); in btusb_switch_alt_setting()
2164 usb_kill_anchored_urbs(&data->isoc_anchor); in btusb_switch_alt_setting()
2175 spin_lock_irqsave(&data->rxlock, flags); in btusb_switch_alt_setting()
2176 dev_kfree_skb_irq(data->sco_skb); in btusb_switch_alt_setting()
2177 data->sco_skb = NULL; in btusb_switch_alt_setting()
2178 spin_unlock_irqrestore(&data->rxlock, flags); in btusb_switch_alt_setting()
2185 if (!test_and_set_bit(BTUSB_ISOC_RUNNING, &data->flags)) { in btusb_switch_alt_setting()
2187 clear_bit(BTUSB_ISOC_RUNNING, &data->flags); in btusb_switch_alt_setting()
2198 struct usb_interface *intf = data->isoc; in btusb_find_altsetting()
2206 for (i = 0; i < intf->num_altsetting; i++) { in btusb_find_altsetting()
2207 if (intf->altsetting[i].desc.bAlternateSetting == alt) in btusb_find_altsetting()
2208 return &intf->altsetting[i]; in btusb_find_altsetting()
2217 struct hci_dev *hdev = data->hdev; in btusb_work()
2221 if (data->sco_num > 0) { in btusb_work()
2222 if (!test_bit(BTUSB_DID_ISO_RESUME, &data->flags)) { in btusb_work()
2223 err = usb_autopm_get_interface(data->isoc ? data->isoc : data->intf); in btusb_work()
2225 clear_bit(BTUSB_ISOC_RUNNING, &data->flags); in btusb_work()
2226 usb_kill_anchored_urbs(&data->isoc_anchor); in btusb_work()
2230 set_bit(BTUSB_DID_ISO_RESUME, &data->flags); in btusb_work()
2233 if (data->air_mode == HCI_NOTIFY_ENABLE_SCO_CVSD) { in btusb_work()
2234 if (hdev->voice_setting & 0x0020) { in btusb_work()
2237 new_alts = alts[data->sco_num - 1]; in btusb_work()
2239 new_alts = data->sco_num; in btusb_work()
2241 } else if (data->air_mode == HCI_NOTIFY_ENABLE_SCO_TRANSP) { in btusb_work()
2248 * MTU >= 3 (packets) * 25 (size) - 3 (headers) = 72 in btusb_work()
2254 hdev->sco_mtu >= 72 && in btusb_work()
2255 test_bit(BTUSB_USE_ALT3_FOR_WBS, &data->flags)) in btusb_work()
2264 usb_kill_anchored_urbs(&data->isoc_anchor); in btusb_work()
2266 if (test_and_clear_bit(BTUSB_ISOC_RUNNING, &data->flags)) in btusb_work()
2269 if (test_and_clear_bit(BTUSB_DID_ISO_RESUME, &data->flags)) in btusb_work()
2270 usb_autopm_put_interface(data->isoc ? data->isoc : data->intf); in btusb_work()
2279 err = usb_autopm_get_interface(data->intf); in btusb_waker()
2283 usb_autopm_put_interface(data->intf); in btusb_waker()
2293 while ((skb = skb_dequeue(&data->acl_q))) in btusb_rx_work()
2294 data->recv_acl(data->hdev, skb); in btusb_rx_work()
2302 BT_DBG("%s", hdev->name); in btusb_setup_bcm92035()
2316 u16 bcdDevice = le16_to_cpu(data->udev->descriptor.bcdDevice); in btusb_setup_csr()
2322 BT_DBG("%s", hdev->name); in btusb_setup_csr()
2328 bt_dev_err(hdev, "CSR: Local version failed (%d)", err); in btusb_setup_csr()
2334 bt_dev_err(hdev, "CSR: Local version length mismatch"); in btusb_setup_csr()
2336 return -EIO; in btusb_setup_csr()
2340 rp->hci_ver, le16_to_cpu(rp->hci_rev)); in btusb_setup_csr()
2343 rp->lmp_ver, le16_to_cpu(rp->lmp_subver), in btusb_setup_csr()
2344 le16_to_cpu(rp->manufacturer)); in btusb_setup_csr()
2350 * The main thing they have in common is that these are really popular low-cost in btusb_setup_csr()
2355 * is Cambridge Silicon Radio (10) and ensuring that LMP sub-version and in btusb_setup_csr()
2358 if (le16_to_cpu(rp->manufacturer) != 10 || in btusb_setup_csr()
2359 le16_to_cpu(rp->hci_rev) != le16_to_cpu(rp->lmp_subver)) in btusb_setup_csr()
2363 * - 1.1 (0x1) -> 0x0073, 0x020d, 0x033c, 0x034e in btusb_setup_csr()
2364 * - 1.2 (0x2) -> 0x04d9, 0x0529 in btusb_setup_csr()
2365 * - 2.0 (0x3) -> 0x07a6, 0x07ad, 0x0c5c in btusb_setup_csr()
2366 * - 2.1 (0x4) -> 0x149c, 0x1735, 0x1899 (0x1899 is a BlueCore4-External) in btusb_setup_csr()
2367 * - 4.0 (0x6) -> 0x1d86, 0x2031, 0x22bb in btusb_setup_csr()
2371 * third-party BT 4.0 dongle reuses it. in btusb_setup_csr()
2373 else if (le16_to_cpu(rp->lmp_subver) <= 0x034e && in btusb_setup_csr()
2374 rp->hci_ver > BLUETOOTH_VER_1_1) in btusb_setup_csr()
2377 else if (le16_to_cpu(rp->lmp_subver) <= 0x0529 && in btusb_setup_csr()
2378 rp->hci_ver > BLUETOOTH_VER_1_2) in btusb_setup_csr()
2381 else if (le16_to_cpu(rp->lmp_subver) <= 0x0c5c && in btusb_setup_csr()
2382 rp->hci_ver > BLUETOOTH_VER_2_0) in btusb_setup_csr()
2385 else if (le16_to_cpu(rp->lmp_subver) <= 0x1899 && in btusb_setup_csr()
2386 rp->hci_ver > BLUETOOTH_VER_2_1) in btusb_setup_csr()
2389 else if (le16_to_cpu(rp->lmp_subver) <= 0x22bb && in btusb_setup_csr()
2390 rp->hci_ver > BLUETOOTH_VER_4_0) in btusb_setup_csr()
2395 le16_to_cpu(rp->lmp_subver) == 0x0c5c && in btusb_setup_csr()
2396 rp->hci_ver == BLUETOOTH_VER_2_0) in btusb_setup_csr()
2400 …bt_dev_warn(hdev, "CSR: Unbranded CSR clone detected; adding workarounds and force-suspending once… in btusb_setup_csr()
2407 set_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks); in btusb_setup_csr()
2408 set_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks); in btusb_setup_csr()
2409 set_bit(HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL, &hdev->quirks); in btusb_setup_csr()
2410 set_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks); in btusb_setup_csr()
2415 clear_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); in btusb_setup_csr()
2416 clear_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); in btusb_setup_csr()
2421 * - 0x0134: a Barrot 8041a02 (HCI rev: 0x0810 sub: 0x1012) in btusb_setup_csr()
2422 * - 0x7558: IC markings FR3191AHAL 749H15143 (HCI rev/sub-version: 0x0709) in btusb_setup_csr()
2424 * These controllers are really messed-up. in btusb_setup_csr()
2430 * (IOW remote-wakeup support is broken for the bulk endpoint). in btusb_setup_csr()
2432 * To fix 1. enable runtime-suspend, force-suspend the in btusb_setup_csr()
2433 * HCI and then wake-it up by disabling runtime-suspend. in btusb_setup_csr()
2438 * -- in btusb_setup_csr()
2444 pm_runtime_allow(&data->udev->dev); in btusb_setup_csr()
2446 ret = pm_runtime_suspend(&data->udev->dev); in btusb_setup_csr()
2450 …bt_dev_warn(hdev, "CSR: Couldn't suspend the device for our Barrot 8041a02 receive-issue workaroun… in btusb_setup_csr()
2452 pm_runtime_forbid(&data->udev->dev); in btusb_setup_csr()
2454 device_set_wakeup_capable(&data->udev->dev, false); in btusb_setup_csr()
2456 /* Re-enable autosuspend if this was requested */ in btusb_setup_csr()
2458 usb_enable_autosuspend(data->udev); in btusb_setup_csr()
2474 return -ENOMEM; in inject_cmd_complete()
2477 hdr->evt = HCI_EV_CMD_COMPLETE; in inject_cmd_complete()
2478 hdr->plen = sizeof(*evt) + 1; in inject_cmd_complete()
2481 evt->ncmd = 0x01; in inject_cmd_complete()
2482 evt->opcode = cpu_to_le16(opcode); in inject_cmd_complete()
2494 struct hci_dev *hdev = data->hdev; in btusb_recv_bulk_intel()
2510 BT_DBG("%s", hdev->name); in btusb_send_frame_intel()
2515 struct hci_command_hdr *cmd = (void *)skb->data; in btusb_send_frame_intel()
2516 __u16 opcode = le16_to_cpu(cmd->opcode); in btusb_send_frame_intel()
2540 hdev->stat.cmd_tx++; in btusb_send_frame_intel()
2548 hdev->stat.acl_tx++; in btusb_send_frame_intel()
2553 return -ENODEV; in btusb_send_frame_intel()
2559 hdev->stat.sco_tx++; in btusb_send_frame_intel()
2570 return -EILSEQ; in btusb_send_frame_intel()
2580 if (btrealtek_test_flag(data->hdev, REALTEK_ALT6_CONTINUOUS_TX_CHIP)) in btusb_setup_realtek()
2581 set_bit(BTUSB_ALT6_CONTINUOUS_TX, &data->flags); in btusb_setup_realtek()
2588 if (skb->data[0] == HCI_VENDOR_PKT && skb->data[2] == RTK_SUB_EVENT_CODE_COREDUMP) { in btusb_recv_event_realtek()
2594 skb->len); in btusb_recv_event_realtek()
2596 btusb_rtl_alloc_devcoredump(hdev, &hdr, skb->data, skb->len); in btusb_recv_event_realtek()
2607 struct btmtk_data *btmtk_data = hci_get_priv(data->hdev); in btusb_mtk_claim_iso_intf()
2611 btmtk_data->isopkt_intf, data); in btusb_mtk_claim_iso_intf()
2613 btmtk_data->isopkt_intf = NULL; in btusb_mtk_claim_iso_intf()
2614 bt_dev_err(data->hdev, "Failed to claim iso interface"); in btusb_mtk_claim_iso_intf()
2618 set_bit(BTMTK_ISOPKT_OVER_INTR, &btmtk_data->flags); in btusb_mtk_claim_iso_intf()
2623 struct btmtk_data *btmtk_data = hci_get_priv(data->hdev); in btusb_mtk_release_iso_intf()
2625 if (btmtk_data->isopkt_intf) { in btusb_mtk_release_iso_intf()
2626 usb_kill_anchored_urbs(&btmtk_data->isopkt_anchor); in btusb_mtk_release_iso_intf()
2627 clear_bit(BTMTK_ISOPKT_RUNNING, &btmtk_data->flags); in btusb_mtk_release_iso_intf()
2629 dev_kfree_skb_irq(btmtk_data->isopkt_skb); in btusb_mtk_release_iso_intf()
2630 btmtk_data->isopkt_skb = NULL; in btusb_mtk_release_iso_intf()
2631 usb_set_intfdata(btmtk_data->isopkt_intf, NULL); in btusb_mtk_release_iso_intf()
2633 btmtk_data->isopkt_intf); in btusb_mtk_release_iso_intf()
2636 clear_bit(BTMTK_ISOPKT_OVER_INTR, &btmtk_data->flags); in btusb_mtk_release_iso_intf()
2646 if (test_and_set_bit(BTMTK_HW_RESET_ACTIVE, &btmtk_data->flags)) { in btusb_mtk_reset()
2648 return -EBUSY; in btusb_mtk_reset()
2651 err = usb_autopm_get_interface(data->intf); in btusb_mtk_reset()
2655 if (test_bit(BTMTK_ISOPKT_RUNNING, &btmtk_data->flags)) in btusb_mtk_reset()
2659 usb_kill_anchored_urbs(&data->tx_anchor); in btusb_mtk_reset()
2661 err = btmtk_usb_subsys_reset(hdev, btmtk_data->dev_id); in btusb_mtk_reset()
2663 usb_queue_reset_device(data->intf); in btusb_mtk_reset()
2664 clear_bit(BTMTK_HW_RESET_ACTIVE, &btmtk_data->flags); in btusb_mtk_reset()
2673 BT_DBG("%s", hdev->name); in btusb_send_frame_mtk()
2694 btmtk_data->drv_name = btusb_driver.name; in btusb_mtk_setup()
2695 btmtk_data->intf = data->intf; in btusb_mtk_setup()
2696 btmtk_data->udev = data->udev; in btusb_mtk_setup()
2697 btmtk_data->ctrl_anchor = &data->ctrl_anchor; in btusb_mtk_setup()
2698 btmtk_data->reset_sync = btusb_mtk_reset; in btusb_mtk_setup()
2701 btmtk_data->isopkt_intf = usb_ifnum_to_if(data->udev, MTK_ISO_IFNUM); in btusb_mtk_setup()
2702 if (btmtk_data->isopkt_intf) in btusb_mtk_setup()
2713 if (test_bit(BTMTK_ISOPKT_RUNNING, &btmtk_data->flags)) in btusb_mtk_shutdown()
2720 /* Configure an out-of-band gpio as wake-up pin, if specified in device tree */
2725 struct device *dev = &data->udev->dev; in marvell_config_oob_wake()
2731 if (of_property_read_u16(dev->of_node, "marvell,wakeup-pin", &pin) || in marvell_config_oob_wake()
2732 of_property_read_u16(dev->of_node, "marvell,wakeup-gap-ms", &gap)) in marvell_config_oob_wake()
2735 /* Vendor specific command to configure a GPIO as wake-up pin */ in marvell_config_oob_wake()
2746 return -ENOMEM; in marvell_config_oob_wake()
2859 btdata->qca_dump.controller_id); in btusb_dump_hdr_qca()
2862 snprintf(buf, sizeof(buf), "Firmware Version: 0x%x\n", in btusb_dump_hdr_qca()
2863 btdata->qca_dump.fw_version); in btusb_dump_hdr_qca()
2871 btdata->qca_dump.id_vendor, btdata->qca_dump.id_product); in btusb_dump_hdr_qca()
2875 hdev->lmp_subver); in btusb_dump_hdr_qca()
2907 struct usb_device *udev = btdata->udev; in handle_dump_pkt_qca()
2910 sk_ptr = skb->data; in handle_dump_pkt_qca()
2911 sk_len = skb->len; in handle_dump_pkt_qca()
2915 if (le16_to_cpu(acl_hdr->handle) != QCA_MEMDUMP_ACL_HANDLE) in handle_dump_pkt_qca()
2918 sk_len -= HCI_ACL_HDR_SIZE; in handle_dump_pkt_qca()
2924 if ((event_hdr->evt != HCI_VENDOR_PKT) in handle_dump_pkt_qca()
2925 || (event_hdr->plen != (sk_len - HCI_EVENT_HDR_SIZE))) in handle_dump_pkt_qca()
2929 sk_len -= HCI_EVENT_HDR_SIZE; in handle_dump_pkt_qca()
2933 || (dump_hdr->vse_class != QCA_MEMDUMP_VSE_CLASS) in handle_dump_pkt_qca()
2934 || (dump_hdr->msg_type != QCA_MEMDUMP_MSG_TYPE)) in handle_dump_pkt_qca()
2938 seqno = le16_to_cpu(dump_hdr->seqno); in handle_dump_pkt_qca()
2940 set_bit(BTUSB_HW_SSR_ACTIVE, &btdata->flags); in handle_dump_pkt_qca()
2941 dump_size = le32_to_cpu(dump_hdr->ram_dump_size); in handle_dump_pkt_qca()
2943 ret = -EILSEQ; in handle_dump_pkt_qca()
2955 btdata->qca_dump.ram_dump_size = dump_size; in handle_dump_pkt_qca()
2956 btdata->qca_dump.ram_dump_seqno = 0; in handle_dump_pkt_qca()
2958 sk_len -= offsetof(struct qca_dump_hdr, data0); in handle_dump_pkt_qca()
2966 sk_len -= offsetof(struct qca_dump_hdr, data); in handle_dump_pkt_qca()
2969 if (!btdata->qca_dump.ram_dump_size) { in handle_dump_pkt_qca()
2970 ret = -EINVAL; in handle_dump_pkt_qca()
2975 if ((seqno > btdata->qca_dump.ram_dump_seqno + 1) && (seqno != QCA_LAST_SEQUENCE_NUM)) { in handle_dump_pkt_qca()
2976 dump_size = QCA_MEMDUMP_PKT_SIZE * (seqno - btdata->qca_dump.ram_dump_seqno - 1); in handle_dump_pkt_qca()
2980 btdata->qca_dump.ram_dump_seqno, seqno); in handle_dump_pkt_qca()
2981 btdata->qca_dump.ram_dump_seqno = seqno; in handle_dump_pkt_qca()
2986 skb_pull(skb, skb->len - sk_len); in handle_dump_pkt_qca()
2988 btdata->qca_dump.ram_dump_seqno++; in handle_dump_pkt_qca()
2992 btdata->qca_dump.ram_dump_seqno, btdata->qca_dump.ram_dump_size); in handle_dump_pkt_qca()
3000 if (btdata->qca_dump.ram_dump_size) in handle_dump_pkt_qca()
3002 btdata->qca_dump.ram_dump_size = 0; in handle_dump_pkt_qca()
3003 btdata->qca_dump.ram_dump_seqno = 0; in handle_dump_pkt_qca()
3004 clear_bit(BTUSB_HW_SSR_ACTIVE, &btdata->flags); in handle_dump_pkt_qca()
3061 u8 ver_offset; /* offset of version structure in rampatch */
3085 return -ENOMEM; in btusb_qca_send_vendor_req()
3094 dev_err(&udev->dev, "Failed to access otp area (%d)", err); in btusb_qca_send_vendor_req()
3111 struct usb_device *udev = btdata->udev; in btusb_setup_qca_download_fw()
3118 return -ENOMEM; in btusb_setup_qca_download_fw()
3120 count = firmware->size; in btusb_setup_qca_download_fw()
3123 memcpy(buf, firmware->data, size); in btusb_setup_qca_download_fw()
3139 count -= size; in btusb_setup_qca_download_fw()
3149 memcpy(buf, firmware->data + sent, size); in btusb_setup_qca_download_fw()
3156 sent, firmware->size, err); in btusb_setup_qca_download_fw()
3162 err = -EILSEQ; in btusb_setup_qca_download_fw()
3167 count -= size; in btusb_setup_qca_download_fw()
3186 ver_rom = le32_to_cpu(ver->rom_version); in btusb_setup_qca_load_rampatch()
3187 ver_patch = le32_to_cpu(ver->patch_version); in btusb_setup_qca_load_rampatch()
3191 err = request_firmware(&fw, fwname, &hdev->dev); in btusb_setup_qca_load_rampatch()
3200 rver = (struct qca_rampatch_version *)(fw->data + info->ver_offset); in btusb_setup_qca_load_rampatch()
3201 rver_rom_low = le16_to_cpu(rver->rom_version_low); in btusb_setup_qca_load_rampatch()
3202 rver_patch = le16_to_cpu(rver->patch_version); in btusb_setup_qca_load_rampatch()
3205 rver_rom_high = le16_to_cpu(rver->rom_version_high); in btusb_setup_qca_load_rampatch()
3216 bt_dev_err(hdev, "rampatch file version did not match with firmware"); in btusb_setup_qca_load_rampatch()
3217 err = -EINVAL; in btusb_setup_qca_load_rampatch()
3221 err = btusb_setup_qca_download_fw(hdev, fw, info->rampatch_hdr); in btusb_setup_qca_load_rampatch()
3232 u32 rom_version = le32_to_cpu(ver->rom_version); in btusb_generate_qca_nvm_name()
3233 u16 flag = le16_to_cpu(ver->flag); in btusb_generate_qca_nvm_name()
3246 u16 board_id = (ver->chip_id << 8) + ver->platform_id; in btusb_generate_qca_nvm_name()
3249 switch (le32_to_cpu(ver->ram_version)) { in btusb_generate_qca_nvm_name()
3283 err = request_firmware(&fw, fwname, &hdev->dev); in btusb_setup_qca_load_nvm()
3292 err = btusb_setup_qca_download_fw(hdev, fw, info->nvm_hdr); in btusb_setup_qca_load_nvm()
3299 /* identify the ROM version and check whether patches are needed */
3314 struct usb_device *udev = btdata->udev; in btusb_setup_qca()
3334 * and the high ROM version is not zero, we assume this chip no in btusb_setup_qca()
3341 return -ENODEV; in btusb_setup_qca()
3360 btdata->qca_dump.fw_version = le32_to_cpu(ver.patch_version); in btusb_setup_qca()
3361 btdata->qca_dump.controller_id = le32_to_cpu(ver.rom_version); in btusb_setup_qca()
3372 if (info->rom_version >= 0x00130201) in btusb_setup_qca()
3379 set_bit(HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN, &hdev->quirks); in btusb_setup_qca()
3387 struct usb_interface *intf = data->diag; in __set_diag_interface()
3390 if (!data->diag) in __set_diag_interface()
3391 return -ENODEV; in __set_diag_interface()
3393 data->diag_tx_ep = NULL; in __set_diag_interface()
3394 data->diag_rx_ep = NULL; in __set_diag_interface()
3396 for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) { in __set_diag_interface()
3399 ep_desc = &intf->cur_altsetting->endpoint[i].desc; in __set_diag_interface()
3401 if (!data->diag_tx_ep && usb_endpoint_is_bulk_out(ep_desc)) { in __set_diag_interface()
3402 data->diag_tx_ep = ep_desc; in __set_diag_interface()
3406 if (!data->diag_rx_ep && usb_endpoint_is_bulk_in(ep_desc)) { in __set_diag_interface()
3407 data->diag_rx_ep = ep_desc; in __set_diag_interface()
3412 if (!data->diag_tx_ep || !data->diag_rx_ep) { in __set_diag_interface()
3414 return -ENODEV; in __set_diag_interface()
3427 if (!data->diag_tx_ep) in alloc_diag_urb()
3428 return ERR_PTR(-ENODEV); in alloc_diag_urb()
3432 return ERR_PTR(-ENOMEM); in alloc_diag_urb()
3437 return ERR_PTR(-ENOMEM); in alloc_diag_urb()
3443 pipe = usb_sndbulkpipe(data->udev, data->diag_tx_ep->bEndpointAddress); in alloc_diag_urb()
3445 usb_fill_bulk_urb(urb, data->udev, pipe, in alloc_diag_urb()
3446 skb->data, skb->len, btusb_tx_complete, skb); in alloc_diag_urb()
3448 skb->dev = (void *)hdev; in alloc_diag_urb()
3458 if (!data->diag) in btusb_bcm_set_diag()
3459 return -ENODEV; in btusb_bcm_set_diag()
3461 if (!test_bit(HCI_RUNNING, &hdev->flags)) in btusb_bcm_set_diag()
3462 return -ENETDOWN; in btusb_bcm_set_diag()
3476 pm_wakeup_event(&data->udev->dev, 0); in btusb_oob_wake_handler()
3480 if (test_and_clear_bit(BTUSB_OOB_WAKE_ENABLED, &data->flags)) { in btusb_oob_wake_handler()
3490 { .compatible = "usb4ca,301a" }, /* QCA6174A (Lite-On) */
3499 struct device *dev = &data->udev->dev; in btusb_config_oob_wake()
3502 clear_bit(BTUSB_OOB_WAKE_ENABLED, &data->flags); in btusb_config_oob_wake()
3508 irq = of_irq_get_byname(dev->of_node, "wakeup"); in btusb_config_oob_wake()
3515 ret = devm_request_irq(&hdev->dev, irq, btusb_oob_wake_handler, in btusb_config_oob_wake()
3516 0, "OOB Wake-on-BT", data); in btusb_config_oob_wake()
3528 data->oob_wake_irq = irq; in btusb_config_oob_wake()
3529 bt_dev_info(hdev, "OOB Wake-on-BT configured at IRQ %u", irq); in btusb_config_oob_wake()
3537 interface_to_usbdev(intf)->quirks |= USB_QUIRK_RESET_RESUME; in btusb_check_needs_reset_resume()
3544 return device_may_wakeup(&data->udev->dev); in btusb_wakeup()
3564 struct btusb_data *data = file->private_data; in force_poll_sync_read()
3567 buf[0] = data->poll_sync ? 'Y' : 'N'; in force_poll_sync_read()
3577 struct btusb_data *data = file->private_data; in force_poll_sync_write()
3586 if (test_bit(HCI_UP, &data->hdev->flags)) in force_poll_sync_write()
3587 return -EPERM; in force_poll_sync_write()
3589 if (data->poll_sync == enable) in force_poll_sync_write()
3590 return -EALREADY; in force_poll_sync_write()
3592 data->poll_sync = enable; in force_poll_sync_write()
3616 if ((id->driver_info & BTUSB_IFNUM_2) && in btusb_probe()
3617 (intf->cur_altsetting->desc.bInterfaceNumber != 0) && in btusb_probe()
3618 (intf->cur_altsetting->desc.bInterfaceNumber != 2)) in btusb_probe()
3619 return -ENODEV; in btusb_probe()
3621 ifnum_base = intf->cur_altsetting->desc.bInterfaceNumber; in btusb_probe()
3623 if (!id->driver_info) { in btusb_probe()
3631 if (id->driver_info == BTUSB_IGNORE) in btusb_probe()
3632 return -ENODEV; in btusb_probe()
3634 if (id->driver_info & BTUSB_ATH3012) { in btusb_probe()
3640 if (le16_to_cpu(udev->descriptor.bcdDevice) <= 0x0001 && in btusb_probe()
3642 return -ENODEV; in btusb_probe()
3645 data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL); in btusb_probe()
3647 return -ENOMEM; in btusb_probe()
3649 for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) { in btusb_probe()
3650 ep_desc = &intf->cur_altsetting->endpoint[i].desc; in btusb_probe()
3652 if (!data->intr_ep && usb_endpoint_is_int_in(ep_desc)) { in btusb_probe()
3653 data->intr_ep = ep_desc; in btusb_probe()
3657 if (!data->bulk_tx_ep && usb_endpoint_is_bulk_out(ep_desc)) { in btusb_probe()
3658 data->bulk_tx_ep = ep_desc; in btusb_probe()
3662 if (!data->bulk_rx_ep && usb_endpoint_is_bulk_in(ep_desc)) { in btusb_probe()
3663 data->bulk_rx_ep = ep_desc; in btusb_probe()
3668 if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) in btusb_probe()
3669 return -ENODEV; in btusb_probe()
3671 if (id->driver_info & BTUSB_AMP) { in btusb_probe()
3672 data->cmdreq_type = USB_TYPE_CLASS | 0x01; in btusb_probe()
3673 data->cmdreq = 0x2b; in btusb_probe()
3675 data->cmdreq_type = USB_TYPE_CLASS; in btusb_probe()
3676 data->cmdreq = 0x00; in btusb_probe()
3679 data->udev = interface_to_usbdev(intf); in btusb_probe()
3680 data->intf = intf; in btusb_probe()
3682 INIT_WORK(&data->work, btusb_work); in btusb_probe()
3683 INIT_WORK(&data->waker, btusb_waker); in btusb_probe()
3684 INIT_DELAYED_WORK(&data->rx_work, btusb_rx_work); in btusb_probe()
3686 skb_queue_head_init(&data->acl_q); in btusb_probe()
3688 init_usb_anchor(&data->deferred); in btusb_probe()
3689 init_usb_anchor(&data->tx_anchor); in btusb_probe()
3690 spin_lock_init(&data->txlock); in btusb_probe()
3692 init_usb_anchor(&data->intr_anchor); in btusb_probe()
3693 init_usb_anchor(&data->bulk_anchor); in btusb_probe()
3694 init_usb_anchor(&data->isoc_anchor); in btusb_probe()
3695 init_usb_anchor(&data->diag_anchor); in btusb_probe()
3696 init_usb_anchor(&data->ctrl_anchor); in btusb_probe()
3697 spin_lock_init(&data->rxlock); in btusb_probe()
3701 data->recv_event = hci_recv_frame; in btusb_probe()
3702 data->recv_bulk = btusb_recv_bulk; in btusb_probe()
3704 if (id->driver_info & BTUSB_INTEL_COMBINED) { in btusb_probe()
3709 data->recv_event = btintel_recv_event; in btusb_probe()
3710 data->recv_bulk = btusb_recv_bulk_intel; in btusb_probe()
3711 } else if (id->driver_info & BTUSB_REALTEK) { in btusb_probe()
3715 data->recv_event = btusb_recv_event_realtek; in btusb_probe()
3716 } else if (id->driver_info & BTUSB_MEDIATEK) { in btusb_probe()
3721 data->recv_acl = hci_recv_frame; in btusb_probe()
3725 return -ENOMEM; in btusb_probe()
3727 hdev->bus = HCI_USB; in btusb_probe()
3730 data->hdev = hdev; in btusb_probe()
3732 SET_HCIDEV_DEV(hdev, &intf->dev); in btusb_probe()
3734 reset_gpio = gpiod_get_optional(&data->udev->dev, "reset", in btusb_probe()
3740 data->reset_gpio = reset_gpio; in btusb_probe()
3743 hdev->open = btusb_open; in btusb_probe()
3744 hdev->close = btusb_close; in btusb_probe()
3745 hdev->flush = btusb_flush; in btusb_probe()
3746 hdev->send = btusb_send_frame; in btusb_probe()
3747 hdev->notify = btusb_notify; in btusb_probe()
3748 hdev->wakeup = btusb_wakeup; in btusb_probe()
3756 if (id->driver_info & BTUSB_MARVELL && data->oob_wake_irq) { in btusb_probe()
3762 if (id->driver_info & BTUSB_CW6622) in btusb_probe()
3763 set_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks); in btusb_probe()
3765 if (id->driver_info & BTUSB_BCM2045) in btusb_probe()
3766 set_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks); in btusb_probe()
3768 if (id->driver_info & BTUSB_BCM92035) in btusb_probe()
3769 hdev->setup = btusb_setup_bcm92035; in btusb_probe()
3772 (id->driver_info & BTUSB_BCM_PATCHRAM)) { in btusb_probe()
3773 hdev->manufacturer = 15; in btusb_probe()
3774 hdev->setup = btbcm_setup_patchram; in btusb_probe()
3775 hdev->set_diag = btusb_bcm_set_diag; in btusb_probe()
3776 hdev->set_bdaddr = btbcm_set_bdaddr; in btusb_probe()
3779 data->diag = usb_ifnum_to_if(data->udev, ifnum_base + 2); in btusb_probe()
3783 (id->driver_info & BTUSB_BCM_APPLE)) { in btusb_probe()
3784 hdev->manufacturer = 15; in btusb_probe()
3785 hdev->setup = btbcm_setup_apple; in btusb_probe()
3786 hdev->set_diag = btusb_bcm_set_diag; in btusb_probe()
3789 data->diag = usb_ifnum_to_if(data->udev, ifnum_base + 2); in btusb_probe()
3793 if (id->driver_info & BTUSB_INTEL_COMBINED) { in btusb_probe()
3799 hdev->send = btusb_send_frame_intel; in btusb_probe()
3800 hdev->cmd_timeout = btusb_intel_cmd_timeout; in btusb_probe()
3802 if (id->driver_info & BTUSB_INTEL_NO_WBS_SUPPORT) in btusb_probe()
3805 if (id->driver_info & BTUSB_INTEL_BROKEN_INITIAL_NCMD) in btusb_probe()
3808 if (id->driver_info & BTUSB_INTEL_BROKEN_SHUTDOWN_LED) in btusb_probe()
3812 if (id->driver_info & BTUSB_MARVELL) in btusb_probe()
3813 hdev->set_bdaddr = btusb_set_bdaddr_marvell; in btusb_probe()
3816 (id->driver_info & BTUSB_MEDIATEK)) { in btusb_probe()
3817 hdev->setup = btusb_mtk_setup; in btusb_probe()
3818 hdev->shutdown = btusb_mtk_shutdown; in btusb_probe()
3819 hdev->manufacturer = 70; in btusb_probe()
3820 hdev->cmd_timeout = btmtk_reset_sync; in btusb_probe()
3821 hdev->set_bdaddr = btmtk_set_bdaddr; in btusb_probe()
3822 hdev->send = btusb_send_frame_mtk; in btusb_probe()
3823 set_bit(HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN, &hdev->quirks); in btusb_probe()
3824 set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks); in btusb_probe()
3825 data->recv_acl = btmtk_usb_recv_acl; in btusb_probe()
3826 data->suspend = btmtk_usb_suspend; in btusb_probe()
3827 data->resume = btmtk_usb_resume; in btusb_probe()
3830 if (id->driver_info & BTUSB_SWAVE) { in btusb_probe()
3831 set_bit(HCI_QUIRK_FIXUP_INQUIRY_MODE, &hdev->quirks); in btusb_probe()
3832 set_bit(HCI_QUIRK_BROKEN_LOCAL_COMMANDS, &hdev->quirks); in btusb_probe()
3835 if (id->driver_info & BTUSB_INTEL_BOOT) { in btusb_probe()
3836 hdev->manufacturer = 2; in btusb_probe()
3837 set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); in btusb_probe()
3840 if (id->driver_info & BTUSB_ATH3012) { in btusb_probe()
3841 data->setup_on_usb = btusb_setup_qca; in btusb_probe()
3842 hdev->set_bdaddr = btusb_set_bdaddr_ath3012; in btusb_probe()
3843 set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); in btusb_probe()
3844 set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); in btusb_probe()
3847 if (id->driver_info & BTUSB_QCA_ROME) { in btusb_probe()
3848 data->setup_on_usb = btusb_setup_qca; in btusb_probe()
3849 hdev->shutdown = btusb_shutdown_qca; in btusb_probe()
3850 hdev->set_bdaddr = btusb_set_bdaddr_ath3012; in btusb_probe()
3851 hdev->cmd_timeout = btusb_qca_cmd_timeout; in btusb_probe()
3852 set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); in btusb_probe()
3856 if (id->driver_info & BTUSB_QCA_WCN6855) { in btusb_probe()
3857 data->qca_dump.id_vendor = id->idVendor; in btusb_probe()
3858 data->qca_dump.id_product = id->idProduct; in btusb_probe()
3859 data->recv_event = btusb_recv_evt_qca; in btusb_probe()
3860 data->recv_acl = btusb_recv_acl_qca; in btusb_probe()
3862 data->setup_on_usb = btusb_setup_qca; in btusb_probe()
3863 hdev->shutdown = btusb_shutdown_qca; in btusb_probe()
3864 hdev->set_bdaddr = btusb_set_bdaddr_wcn6855; in btusb_probe()
3865 hdev->cmd_timeout = btusb_qca_cmd_timeout; in btusb_probe()
3866 set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); in btusb_probe()
3870 if (id->driver_info & BTUSB_AMP) { in btusb_probe()
3872 data->isoc = NULL; in btusb_probe()
3875 data->isoc = usb_ifnum_to_if(data->udev, ifnum_base + 1); in btusb_probe()
3876 data->isoc_ifnum = ifnum_base + 1; in btusb_probe()
3880 (id->driver_info & BTUSB_REALTEK)) { in btusb_probe()
3882 hdev->setup = btusb_setup_realtek; in btusb_probe()
3883 hdev->shutdown = btrtl_shutdown_realtek; in btusb_probe()
3884 hdev->cmd_timeout = btusb_rtl_cmd_timeout; in btusb_probe()
3885 hdev->hw_error = btusb_rtl_hw_error; in btusb_probe()
3887 /* Realtek devices need to set remote wakeup on auto-suspend */ in btusb_probe()
3888 set_bit(BTUSB_WAKEUP_AUTOSUSPEND, &data->flags); in btusb_probe()
3889 set_bit(BTUSB_USE_ALT3_FOR_WBS, &data->flags); in btusb_probe()
3892 if (id->driver_info & BTUSB_ACTIONS_SEMI) { in btusb_probe()
3894 set_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks); in btusb_probe()
3895 set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks); in btusb_probe()
3896 set_bit(HCI_QUIRK_BROKEN_SET_RPA_TIMEOUT, &hdev->quirks); in btusb_probe()
3897 set_bit(HCI_QUIRK_BROKEN_EXT_SCAN, &hdev->quirks); in btusb_probe()
3898 set_bit(HCI_QUIRK_BROKEN_READ_ENC_KEY_SIZE, &hdev->quirks); in btusb_probe()
3902 set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); in btusb_probe()
3904 if (force_scofix || id->driver_info & BTUSB_WRONG_SCO_MTU) { in btusb_probe()
3906 set_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks); in btusb_probe()
3909 if (id->driver_info & BTUSB_BROKEN_ISOC) in btusb_probe()
3910 data->isoc = NULL; in btusb_probe()
3912 if (id->driver_info & BTUSB_WIDEBAND_SPEECH) in btusb_probe()
3913 set_bit(HCI_QUIRK_WIDEBAND_SPEECH_SUPPORTED, &hdev->quirks); in btusb_probe()
3915 if (id->driver_info & BTUSB_INVALID_LE_STATES) in btusb_probe()
3916 set_bit(HCI_QUIRK_BROKEN_LE_STATES, &hdev->quirks); in btusb_probe()
3918 if (id->driver_info & BTUSB_DIGIANSWER) { in btusb_probe()
3919 data->cmdreq_type = USB_TYPE_VENDOR; in btusb_probe()
3920 set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); in btusb_probe()
3923 if (id->driver_info & BTUSB_CSR) { in btusb_probe()
3924 struct usb_device *udev = data->udev; in btusb_probe()
3925 u16 bcdDevice = le16_to_cpu(udev->descriptor.bcdDevice); in btusb_probe()
3929 set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks); in btusb_probe()
3932 set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); in btusb_probe()
3935 if (le16_to_cpu(udev->descriptor.idVendor) == 0x0a12 && in btusb_probe()
3936 le16_to_cpu(udev->descriptor.idProduct) == 0x0001) in btusb_probe()
3937 hdev->setup = btusb_setup_csr; in btusb_probe()
3940 if (id->driver_info & BTUSB_SNIFFER) { in btusb_probe()
3941 struct usb_device *udev = data->udev; in btusb_probe()
3944 if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x997) in btusb_probe()
3945 set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); in btusb_probe()
3948 if (id->driver_info & BTUSB_INTEL_BOOT) { in btusb_probe()
3952 err = usb_set_interface(data->udev, 0, 0); in btusb_probe()
3959 if (data->isoc) { in btusb_probe()
3961 data->isoc, data); in btusb_probe()
3966 if (IS_ENABLED(CONFIG_BT_HCIBTUSB_BCM) && data->diag) { in btusb_probe()
3968 data->diag, data)) in btusb_probe()
3971 data->diag = NULL; in btusb_probe()
3975 usb_enable_autosuspend(data->udev); in btusb_probe()
3977 data->poll_sync = enable_poll_sync; in btusb_probe()
3985 debugfs_create_file("force_poll_sync", 0644, hdev->debugfs, data, in btusb_probe()
3991 if (data->reset_gpio) in btusb_probe()
3992 gpiod_put(data->reset_gpio); in btusb_probe()
4007 hdev = data->hdev; in btusb_disconnect()
4008 usb_set_intfdata(data->intf, NULL); in btusb_disconnect()
4010 if (data->isoc) in btusb_disconnect()
4011 usb_set_intfdata(data->isoc, NULL); in btusb_disconnect()
4013 if (data->diag) in btusb_disconnect()
4014 usb_set_intfdata(data->diag, NULL); in btusb_disconnect()
4018 if (intf == data->intf) { in btusb_disconnect()
4019 if (data->isoc) in btusb_disconnect()
4020 usb_driver_release_interface(&btusb_driver, data->isoc); in btusb_disconnect()
4021 if (data->diag) in btusb_disconnect()
4022 usb_driver_release_interface(&btusb_driver, data->diag); in btusb_disconnect()
4023 } else if (intf == data->isoc) { in btusb_disconnect()
4024 if (data->diag) in btusb_disconnect()
4025 usb_driver_release_interface(&btusb_driver, data->diag); in btusb_disconnect()
4026 usb_driver_release_interface(&btusb_driver, data->intf); in btusb_disconnect()
4027 } else if (intf == data->diag) { in btusb_disconnect()
4028 usb_driver_release_interface(&btusb_driver, data->intf); in btusb_disconnect()
4029 if (data->isoc) in btusb_disconnect()
4030 usb_driver_release_interface(&btusb_driver, data->isoc); in btusb_disconnect()
4033 if (data->oob_wake_irq) in btusb_disconnect()
4034 device_init_wakeup(&data->udev->dev, false); in btusb_disconnect()
4036 if (data->reset_gpio) in btusb_disconnect()
4037 gpiod_put(data->reset_gpio); in btusb_disconnect()
4049 /* Don't auto-suspend if there are connections; external suspend calls in btusb_suspend()
4052 if (PMSG_IS_AUTO(message) && hci_conn_count(data->hdev)) in btusb_suspend()
4053 return -EBUSY; in btusb_suspend()
4055 if (data->suspend_count++) in btusb_suspend()
4058 spin_lock_irq(&data->txlock); in btusb_suspend()
4059 if (!(PMSG_IS_AUTO(message) && data->tx_in_flight)) { in btusb_suspend()
4060 set_bit(BTUSB_SUSPENDING, &data->flags); in btusb_suspend()
4061 spin_unlock_irq(&data->txlock); in btusb_suspend()
4063 spin_unlock_irq(&data->txlock); in btusb_suspend()
4064 data->suspend_count--; in btusb_suspend()
4065 return -EBUSY; in btusb_suspend()
4068 cancel_work_sync(&data->work); in btusb_suspend()
4070 if (data->suspend) in btusb_suspend()
4071 data->suspend(data->hdev); in btusb_suspend()
4074 usb_kill_anchored_urbs(&data->tx_anchor); in btusb_suspend()
4076 if (data->oob_wake_irq && device_may_wakeup(&data->udev->dev)) { in btusb_suspend()
4077 set_bit(BTUSB_OOB_WAKE_ENABLED, &data->flags); in btusb_suspend()
4078 enable_irq_wake(data->oob_wake_irq); in btusb_suspend()
4079 enable_irq(data->oob_wake_irq); in btusb_suspend()
4087 if (test_bit(BTUSB_WAKEUP_AUTOSUSPEND, &data->flags)) { in btusb_suspend()
4089 device_can_wakeup(&data->udev->dev)) in btusb_suspend()
4090 data->udev->do_remote_wakeup = 1; in btusb_suspend()
4092 !device_may_wakeup(&data->udev->dev)) { in btusb_suspend()
4093 data->udev->do_remote_wakeup = 0; in btusb_suspend()
4094 data->udev->reset_resume = 1; in btusb_suspend()
4106 while ((urb = usb_get_from_anchor(&data->deferred))) { in play_deferred()
4107 usb_anchor_urb(urb, &data->tx_anchor); in play_deferred()
4111 if (err != -EPERM && err != -ENODEV) in play_deferred()
4113 data->hdev->name, urb, -err); in play_deferred()
4114 kfree(urb->setup_packet); in play_deferred()
4120 data->tx_in_flight++; in play_deferred()
4125 while ((urb = usb_get_from_anchor(&data->deferred))) { in play_deferred()
4126 kfree(urb->setup_packet); in play_deferred()
4134 struct hci_dev *hdev = data->hdev; in btusb_resume()
4139 if (--data->suspend_count) in btusb_resume()
4143 if (test_and_clear_bit(BTUSB_OOB_WAKE_ENABLED, &data->flags)) { in btusb_resume()
4144 disable_irq(data->oob_wake_irq); in btusb_resume()
4145 disable_irq_wake(data->oob_wake_irq); in btusb_resume()
4148 if (!test_bit(HCI_RUNNING, &hdev->flags)) in btusb_resume()
4151 if (test_bit(BTUSB_INTR_RUNNING, &data->flags)) { in btusb_resume()
4154 clear_bit(BTUSB_INTR_RUNNING, &data->flags); in btusb_resume()
4159 if (test_bit(BTUSB_BULK_RUNNING, &data->flags)) { in btusb_resume()
4162 clear_bit(BTUSB_BULK_RUNNING, &data->flags); in btusb_resume()
4169 if (test_bit(BTUSB_ISOC_RUNNING, &data->flags)) { in btusb_resume()
4171 clear_bit(BTUSB_ISOC_RUNNING, &data->flags); in btusb_resume()
4176 if (data->resume) in btusb_resume()
4177 data->resume(hdev); in btusb_resume()
4179 spin_lock_irq(&data->txlock); in btusb_resume()
4181 clear_bit(BTUSB_SUSPENDING, &data->flags); in btusb_resume()
4182 spin_unlock_irq(&data->txlock); in btusb_resume()
4183 schedule_work(&data->work); in btusb_resume()
4188 usb_scuttle_anchored_urbs(&data->deferred); in btusb_resume()
4190 spin_lock_irq(&data->txlock); in btusb_resume()
4191 clear_bit(BTUSB_SUSPENDING, &data->flags); in btusb_resume()
4192 spin_unlock_irq(&data->txlock); in btusb_resume()
4202 struct hci_dev *hdev = data->hdev; in btusb_coredump()
4204 if (hdev->dump.coredump) in btusb_coredump()
4205 hdev->dump.coredump(hdev); in btusb_coredump()
4243 MODULE_DESCRIPTION("Generic Bluetooth USB driver ver " VERSION);
4244 MODULE_VERSION(VERSION);