Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next

Johan Hedberg says:

====================
pull request: linux-bluetooth 2019-11-11

Here's one more bluetooth-next pull request for the 5.5 kernel release.

- Several fixes for LE advertising
- Added PM support to hci_qca driver
- Added support for WCN3991 SoC in hci_qca driver
- Added DT bindings for BCM43540 module
- A few other small cleanups/fixes
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+242 -52
+1
Documentation/devicetree/bindings/net/broadcom-bluetooth.txt
··· 14 14 * "brcm,bcm4330-bt" 15 15 * "brcm,bcm43438-bt" 16 16 * "brcm,bcm4345c5" 17 + * "brcm,bcm43540-bt" 17 18 18 19 Optional properties: 19 20
+1
drivers/bluetooth/btmtksdio.c
··· 57 57 .driver_data = (kernel_ulong_t)&mt7668_data }, 58 58 { } /* Terminating entry */ 59 59 }; 60 + MODULE_DEVICE_TABLE(sdio, btmtksdio_table); 60 61 61 62 #define MTK_REG_CHLPCR 0x4 /* W1S */ 62 63 #define C_INT_EN_SET BIT(0)
+65 -27
drivers/bluetooth/btqca.c
··· 14 14 15 15 #define VERSION "0.1" 16 16 17 - int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version) 17 + int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, 18 + enum qca_btsoc_type soc_type) 18 19 { 19 20 struct sk_buff *skb; 20 21 struct edl_event_hdr *edl; 21 - struct rome_version *ver; 22 + struct qca_btsoc_version *ver; 22 23 char cmd; 23 24 int err = 0; 25 + u8 event_type = HCI_EV_VENDOR; 26 + u8 rlen = sizeof(*edl) + sizeof(*ver); 27 + u8 rtype = EDL_APP_VER_RES_EVT; 24 28 25 29 bt_dev_dbg(hdev, "QCA Version Request"); 26 30 31 + /* Unlike other SoC's sending version command response as payload to 32 + * VSE event. WCN3991 sends version command response as a payload to 33 + * command complete event. 34 + */ 35 + if (soc_type == QCA_WCN3991) { 36 + event_type = 0; 37 + rlen += 1; 38 + rtype = EDL_PATCH_VER_REQ_CMD; 39 + } 40 + 27 41 cmd = EDL_PATCH_VER_REQ_CMD; 28 42 skb = __hci_cmd_sync_ev(hdev, EDL_PATCH_CMD_OPCODE, EDL_PATCH_CMD_LEN, 29 - &cmd, HCI_EV_VENDOR, HCI_INIT_TIMEOUT); 43 + &cmd, event_type, HCI_INIT_TIMEOUT); 30 44 if (IS_ERR(skb)) { 31 45 err = PTR_ERR(skb); 32 46 bt_dev_err(hdev, "Reading QCA version information failed (%d)", ··· 48 34 return err; 49 35 } 50 36 51 - if (skb->len != sizeof(*edl) + sizeof(*ver)) { 37 + if (skb->len != rlen) { 52 38 bt_dev_err(hdev, "QCA Version size mismatch len %d", skb->len); 53 39 err = -EILSEQ; 54 40 goto out; ··· 62 48 } 63 49 64 50 if (edl->cresp != EDL_CMD_REQ_RES_EVT || 65 - edl->rtype != EDL_APP_VER_RES_EVT) { 51 + edl->rtype != rtype) { 66 52 bt_dev_err(hdev, "QCA Wrong packet received %d %d", edl->cresp, 67 53 edl->rtype); 68 54 err = -EIO; 69 55 goto out; 70 56 } 71 57 72 - ver = (struct rome_version *)(edl->data); 58 + if (soc_type == QCA_WCN3991) 59 + memmove(&edl->data, &edl->data[1], sizeof(*ver)); 60 + 61 + ver = (struct qca_btsoc_version *)(edl->data); 73 62 74 63 BT_DBG("%s: Product:0x%08x", hdev->name, le32_to_cpu(ver->product_id)); 75 64 BT_DBG("%s: Patch :0x%08x", hdev->name, le16_to_cpu(ver->patch_ver)); 76 - BT_DBG("%s: ROM :0x%08x", hdev->name, le16_to_cpu(ver->rome_ver)); 65 + BT_DBG("%s: ROM :0x%08x", hdev->name, le16_to_cpu(ver->rom_ver)); 77 66 BT_DBG("%s: SOC :0x%08x", hdev->name, le32_to_cpu(ver->soc_id)); 78 67 79 68 /* QCA chipset version can be decided by patch and SoC ··· 84 67 * and lower 2 bytes from patch will be used. 85 68 */ 86 69 *soc_version = (le32_to_cpu(ver->soc_id) << 16) | 87 - (le16_to_cpu(ver->rome_ver) & 0x0000ffff); 70 + (le16_to_cpu(ver->rom_ver) & 0x0000ffff); 88 71 if (*soc_version == 0) 89 72 err = -EILSEQ; 90 73 ··· 138 121 } 139 122 EXPORT_SYMBOL_GPL(qca_send_pre_shutdown_cmd); 140 123 141 - static void qca_tlv_check_data(struct rome_config *config, 124 + static void qca_tlv_check_data(struct qca_fw_config *config, 142 125 const struct firmware *fw) 143 126 { 144 127 const u8 *data; ··· 157 140 BT_DBG("TLV Type\t\t : 0x%x", type_len & 0x000000ff); 158 141 BT_DBG("Length\t\t : %d bytes", length); 159 142 160 - config->dnld_mode = ROME_SKIP_EVT_NONE; 161 - config->dnld_type = ROME_SKIP_EVT_NONE; 143 + config->dnld_mode = QCA_SKIP_EVT_NONE; 144 + config->dnld_type = QCA_SKIP_EVT_NONE; 162 145 163 146 switch (config->type) { 164 147 case TLV_TYPE_PATCH: ··· 240 223 } 241 224 242 225 static int qca_tlv_send_segment(struct hci_dev *hdev, int seg_size, 243 - const u8 *data, enum rome_tlv_dnld_mode mode) 226 + const u8 *data, enum qca_tlv_dnld_mode mode, 227 + enum qca_btsoc_type soc_type) 244 228 { 245 229 struct sk_buff *skb; 246 230 struct edl_event_hdr *edl; 247 231 struct tlv_seg_resp *tlv_resp; 248 232 u8 cmd[MAX_SIZE_PER_TLV_SEGMENT + 2]; 249 233 int err = 0; 234 + u8 event_type = HCI_EV_VENDOR; 235 + u8 rlen = (sizeof(*edl) + sizeof(*tlv_resp)); 236 + u8 rtype = EDL_TVL_DNLD_RES_EVT; 250 237 251 238 cmd[0] = EDL_PATCH_TLV_REQ_CMD; 252 239 cmd[1] = seg_size; 253 240 memcpy(cmd + 2, data, seg_size); 254 241 255 - if (mode == ROME_SKIP_EVT_VSE_CC || mode == ROME_SKIP_EVT_VSE) 242 + if (mode == QCA_SKIP_EVT_VSE_CC || mode == QCA_SKIP_EVT_VSE) 256 243 return __hci_cmd_send(hdev, EDL_PATCH_CMD_OPCODE, seg_size + 2, 257 244 cmd); 258 245 246 + /* Unlike other SoC's sending version command response as payload to 247 + * VSE event. WCN3991 sends version command response as a payload to 248 + * command complete event. 249 + */ 250 + if (soc_type == QCA_WCN3991) { 251 + event_type = 0; 252 + rlen = sizeof(*edl); 253 + rtype = EDL_PATCH_TLV_REQ_CMD; 254 + } 255 + 259 256 skb = __hci_cmd_sync_ev(hdev, EDL_PATCH_CMD_OPCODE, seg_size + 2, cmd, 260 - HCI_EV_VENDOR, HCI_INIT_TIMEOUT); 257 + event_type, HCI_INIT_TIMEOUT); 261 258 if (IS_ERR(skb)) { 262 259 err = PTR_ERR(skb); 263 260 bt_dev_err(hdev, "QCA Failed to send TLV segment (%d)", err); 264 261 return err; 265 262 } 266 263 267 - if (skb->len != sizeof(*edl) + sizeof(*tlv_resp)) { 264 + if (skb->len != rlen) { 268 265 bt_dev_err(hdev, "QCA TLV response size mismatch"); 269 266 err = -EILSEQ; 270 267 goto out; ··· 291 260 goto out; 292 261 } 293 262 294 - tlv_resp = (struct tlv_seg_resp *)(edl->data); 263 + if (edl->cresp != EDL_CMD_REQ_RES_EVT || edl->rtype != rtype) { 264 + bt_dev_err(hdev, "QCA TLV with error stat 0x%x rtype 0x%x", 265 + edl->cresp, edl->rtype); 266 + err = -EIO; 267 + } 295 268 296 - if (edl->cresp != EDL_CMD_REQ_RES_EVT || 297 - edl->rtype != EDL_TVL_DNLD_RES_EVT || tlv_resp->result != 0x00) { 269 + if (soc_type == QCA_WCN3991) 270 + goto out; 271 + 272 + tlv_resp = (struct tlv_seg_resp *)(edl->data); 273 + if (tlv_resp->result) { 298 274 bt_dev_err(hdev, "QCA TLV with error stat 0x%x rtype 0x%x (0x%x)", 299 275 edl->cresp, edl->rtype, tlv_resp->result); 300 - err = -EIO; 301 276 } 302 277 303 278 out: ··· 338 301 } 339 302 340 303 static int qca_download_firmware(struct hci_dev *hdev, 341 - struct rome_config *config) 304 + struct qca_fw_config *config, 305 + enum qca_btsoc_type soc_type) 342 306 { 343 307 const struct firmware *fw; 344 308 const u8 *segment; ··· 366 328 remain -= segsize; 367 329 /* The last segment is always acked regardless download mode */ 368 330 if (!remain || segsize < MAX_SIZE_PER_TLV_SEGMENT) 369 - config->dnld_mode = ROME_SKIP_EVT_NONE; 331 + config->dnld_mode = QCA_SKIP_EVT_NONE; 370 332 371 333 ret = qca_tlv_send_segment(hdev, segsize, segment, 372 - config->dnld_mode); 334 + config->dnld_mode, soc_type); 373 335 if (ret) 374 336 goto out; 375 337 ··· 382 344 * decrease the BT in initialization time. Here we will inject a command 383 345 * complete event to avoid a command timeout error message. 384 346 */ 385 - if (config->dnld_type == ROME_SKIP_EVT_VSE_CC || 386 - config->dnld_type == ROME_SKIP_EVT_VSE) 347 + if (config->dnld_type == QCA_SKIP_EVT_VSE_CC || 348 + config->dnld_type == QCA_SKIP_EVT_VSE) 387 349 ret = qca_inject_cmd_complete_event(hdev); 388 350 389 351 out: ··· 420 382 enum qca_btsoc_type soc_type, u32 soc_ver, 421 383 const char *firmware_name) 422 384 { 423 - struct rome_config config; 385 + struct qca_fw_config config; 424 386 int err; 425 387 u8 rom_ver = 0; 426 388 ··· 443 405 "qca/rampatch_%08x.bin", soc_ver); 444 406 } 445 407 446 - err = qca_download_firmware(hdev, &config); 408 + err = qca_download_firmware(hdev, &config, soc_type); 447 409 if (err < 0) { 448 410 bt_dev_err(hdev, "QCA Failed to download patch (%d)", err); 449 411 return err; ··· 464 426 snprintf(config.fwname, sizeof(config.fwname), 465 427 "qca/nvm_%08x.bin", soc_ver); 466 428 467 - err = qca_download_firmware(hdev, &config); 429 + err = qca_download_firmware(hdev, &config, soc_type); 468 430 if (err < 0) { 469 431 bt_dev_err(hdev, "QCA Failed to download NVM (%d)", err); 470 432 return err;
+18 -14
drivers/bluetooth/btqca.h
··· 56 56 QCA_BAUDRATE_RESERVED 57 57 }; 58 58 59 - enum rome_tlv_dnld_mode { 60 - ROME_SKIP_EVT_NONE, 61 - ROME_SKIP_EVT_VSE, 62 - ROME_SKIP_EVT_CC, 63 - ROME_SKIP_EVT_VSE_CC 59 + enum qca_tlv_dnld_mode { 60 + QCA_SKIP_EVT_NONE, 61 + QCA_SKIP_EVT_VSE, 62 + QCA_SKIP_EVT_CC, 63 + QCA_SKIP_EVT_VSE_CC 64 64 }; 65 65 66 - enum rome_tlv_type { 66 + enum qca_tlv_type { 67 67 TLV_TYPE_PATCH = 1, 68 68 TLV_TYPE_NVM 69 69 }; 70 70 71 - struct rome_config { 71 + struct qca_fw_config { 72 72 u8 type; 73 73 char fwname[64]; 74 74 uint8_t user_baud_rate; 75 - enum rome_tlv_dnld_mode dnld_mode; 76 - enum rome_tlv_dnld_mode dnld_type; 75 + enum qca_tlv_dnld_mode dnld_mode; 76 + enum qca_tlv_dnld_mode dnld_type; 77 77 }; 78 78 79 79 struct edl_event_hdr { ··· 82 82 __u8 data[0]; 83 83 } __packed; 84 84 85 - struct rome_version { 85 + struct qca_btsoc_version { 86 86 __le32 product_id; 87 87 __le16 patch_ver; 88 - __le16 rome_ver; 88 + __le16 rom_ver; 89 89 __le32 soc_id; 90 90 } __packed; 91 91 ··· 125 125 QCA_AR3002, 126 126 QCA_ROME, 127 127 QCA_WCN3990, 128 + QCA_WCN3991, 128 129 QCA_WCN3998, 129 130 }; 130 131 ··· 135 134 int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, 136 135 enum qca_btsoc_type soc_type, u32 soc_ver, 137 136 const char *firmware_name); 138 - int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version); 137 + int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, 138 + enum qca_btsoc_type); 139 139 int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr); 140 140 int qca_send_pre_shutdown_cmd(struct hci_dev *hdev); 141 141 static inline bool qca_is_wcn399x(enum qca_btsoc_type soc_type) 142 142 { 143 - return soc_type == QCA_WCN3990 || soc_type == QCA_WCN3998; 143 + return soc_type == QCA_WCN3990 || soc_type == QCA_WCN3991 || 144 + soc_type == QCA_WCN3998; 144 145 } 145 146 #else 146 147 ··· 158 155 return -EOPNOTSUPP; 159 156 } 160 157 161 - static inline int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version) 158 + static inline int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version, 159 + enum qca_btsoc_type) 162 160 { 163 161 return -EOPNOTSUPP; 164 162 }
+1 -1
drivers/bluetooth/btrtl.c
··· 778 778 rtl_dev_dbg(hdev, "skipping config entry 0x%x (len %u)", 779 779 le16_to_cpu(entry->offset), entry->len); 780 780 break; 781 - }; 781 + } 782 782 783 783 i += sizeof(*entry) + entry->len; 784 784 }
+1
drivers/bluetooth/hci_bcm.c
··· 1424 1424 { .compatible = "brcm,bcm4345c5" }, 1425 1425 { .compatible = "brcm,bcm4330-bt" }, 1426 1426 { .compatible = "brcm,bcm43438-bt" }, 1427 + { .compatible = "brcm,bcm43540-bt" }, 1427 1428 { }, 1428 1429 }; 1429 1430 MODULE_DEVICE_TABLE(of, bcm_bluetooth_of_match);
+3
drivers/bluetooth/hci_bcsp.c
··· 591 591 if (*ptr == 0xc0) { 592 592 BT_ERR("Short BCSP packet"); 593 593 kfree_skb(bcsp->rx_skb); 594 + bcsp->rx_skb = NULL; 594 595 bcsp->rx_state = BCSP_W4_PKT_START; 595 596 bcsp->rx_count = 0; 596 597 } else ··· 607 606 bcsp->rx_skb->data[2])) != bcsp->rx_skb->data[3]) { 608 607 BT_ERR("Error in BCSP hdr checksum"); 609 608 kfree_skb(bcsp->rx_skb); 609 + bcsp->rx_skb = NULL; 610 610 bcsp->rx_state = BCSP_W4_PKT_DELIMITER; 611 611 bcsp->rx_count = 0; 612 612 continue; ··· 632 630 bscp_get_crc(bcsp)); 633 631 634 632 kfree_skb(bcsp->rx_skb); 633 + bcsp->rx_skb = NULL; 635 634 bcsp->rx_state = BCSP_W4_PKT_DELIMITER; 636 635 bcsp->rx_count = 0; 637 636 continue;
+138 -5
drivers/bluetooth/hci_qca.c
··· 43 43 #define HCI_MAX_IBS_SIZE 10 44 44 45 45 #define IBS_WAKE_RETRANS_TIMEOUT_MS 100 46 - #define IBS_TX_IDLE_TIMEOUT_MS 2000 46 + #define IBS_BTSOC_TX_IDLE_TIMEOUT_MS 40 47 + #define IBS_HOST_TX_IDLE_TIMEOUT_MS 2000 47 48 #define CMD_TRANS_TIMEOUT_MS 100 48 49 49 50 /* susclk rate */ ··· 56 55 enum qca_flags { 57 56 QCA_IBS_ENABLED, 58 57 QCA_DROP_VENDOR_EVENT, 58 + QCA_SUSPENDING, 59 59 }; 60 60 61 61 /* HCI_IBS transmit side sleep protocol states */ ··· 102 100 struct work_struct ws_tx_vote_off; 103 101 unsigned long flags; 104 102 struct completion drop_ev_comp; 103 + wait_queue_head_t suspend_wait_q; 105 104 106 105 /* For debugging purpose */ 107 106 u64 ibs_sent_wacks; ··· 440 437 spin_lock_irqsave_nested(&qca->hci_ibs_lock, 441 438 flags, SINGLE_DEPTH_NESTING); 442 439 440 + /* Don't retransmit the HCI_IBS_WAKE_IND when suspending. */ 441 + if (test_bit(QCA_SUSPENDING, &qca->flags)) { 442 + spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); 443 + return; 444 + } 445 + 443 446 switch (qca->tx_ibs_state) { 444 447 case HCI_IBS_TX_WAKING: 445 448 /* No WAKE_ACK, retransmit WAKE */ ··· 505 496 INIT_WORK(&qca->ws_rx_vote_off, qca_wq_serial_rx_clock_vote_off); 506 497 INIT_WORK(&qca->ws_tx_vote_off, qca_wq_serial_tx_clock_vote_off); 507 498 499 + init_waitqueue_head(&qca->suspend_wait_q); 500 + 508 501 qca->hu = hu; 509 502 init_completion(&qca->drop_ev_comp); 510 503 ··· 543 532 qca->wake_retrans = IBS_WAKE_RETRANS_TIMEOUT_MS; 544 533 545 534 timer_setup(&qca->tx_idle_timer, hci_ibs_tx_idle_timeout, 0); 546 - qca->tx_idle_delay = IBS_TX_IDLE_TIMEOUT_MS; 535 + qca->tx_idle_delay = IBS_HOST_TX_IDLE_TIMEOUT_MS; 547 536 548 537 BT_DBG("HCI_UART_QCA open, tx_idle_delay=%u, wake_retrans=%u", 549 538 qca->tx_idle_delay, qca->wake_retrans); ··· 658 647 659 648 qca->ibs_recv_wakes++; 660 649 650 + /* Don't wake the rx up when suspending. */ 651 + if (test_bit(QCA_SUSPENDING, &qca->flags)) { 652 + spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); 653 + return; 654 + } 655 + 661 656 switch (qca->rx_ibs_state) { 662 657 case HCI_IBS_RX_ASLEEP: 663 658 /* Make sure clock is on - we may have turned clock off since ··· 728 711 break; 729 712 } 730 713 714 + wake_up_interruptible(&qca->suspend_wait_q); 715 + 731 716 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); 732 717 } 733 718 ··· 746 727 spin_lock_irqsave(&qca->hci_ibs_lock, flags); 747 728 748 729 qca->ibs_recv_wacks++; 730 + 731 + /* Don't react to the wake-up-acknowledgment when suspending. */ 732 + if (test_bit(QCA_SUSPENDING, &qca->flags)) { 733 + spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); 734 + return; 735 + } 749 736 750 737 switch (qca->tx_ibs_state) { 751 738 case HCI_IBS_TX_AWAKE: ··· 805 780 806 781 /* Don't go to sleep in middle of patch download or 807 782 * Out-Of-Band(GPIOs control) sleep is selected. 783 + * Don't wake the device up when suspending. 808 784 */ 809 - if (!test_bit(QCA_IBS_ENABLED, &qca->flags)) { 785 + if (!test_bit(QCA_IBS_ENABLED, &qca->flags) || 786 + test_bit(QCA_SUSPENDING, &qca->flags)) { 810 787 skb_queue_tail(&qca->txq, skb); 811 788 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); 812 789 return 0; ··· 1288 1261 if (ret) 1289 1262 return ret; 1290 1263 1291 - ret = qca_read_soc_version(hdev, &soc_ver); 1264 + ret = qca_read_soc_version(hdev, &soc_ver, soc_type); 1292 1265 if (ret) 1293 1266 return ret; 1294 1267 } else { ··· 1308 1281 1309 1282 if (!qca_is_wcn399x(soc_type)) { 1310 1283 /* Get QCA version information */ 1311 - ret = qca_read_soc_version(hdev, &soc_ver); 1284 + ret = qca_read_soc_version(hdev, &soc_ver, soc_type); 1312 1285 if (ret) 1313 1286 return ret; 1314 1287 } ··· 1357 1330 1358 1331 static const struct qca_vreg_data qca_soc_data_wcn3990 = { 1359 1332 .soc_type = QCA_WCN3990, 1333 + .vregs = (struct qca_vreg []) { 1334 + { "vddio", 15000 }, 1335 + { "vddxo", 80000 }, 1336 + { "vddrf", 300000 }, 1337 + { "vddch0", 450000 }, 1338 + }, 1339 + .num_vregs = 4, 1340 + }; 1341 + 1342 + static const struct qca_vreg_data qca_soc_data_wcn3991 = { 1343 + .soc_type = QCA_WCN3991, 1360 1344 .vregs = (struct qca_vreg []) { 1361 1345 { "vddio", 15000 }, 1362 1346 { "vddxo", 80000 }, ··· 1577 1539 hci_uart_unregister_device(&qcadev->serdev_hu); 1578 1540 } 1579 1541 1542 + static int __maybe_unused qca_suspend(struct device *dev) 1543 + { 1544 + struct hci_dev *hdev = container_of(dev, struct hci_dev, dev); 1545 + struct hci_uart *hu = hci_get_drvdata(hdev); 1546 + struct qca_data *qca = hu->priv; 1547 + unsigned long flags; 1548 + int ret = 0; 1549 + u8 cmd; 1550 + 1551 + set_bit(QCA_SUSPENDING, &qca->flags); 1552 + 1553 + /* Device is downloading patch or doesn't support in-band sleep. */ 1554 + if (!test_bit(QCA_IBS_ENABLED, &qca->flags)) 1555 + return 0; 1556 + 1557 + cancel_work_sync(&qca->ws_awake_device); 1558 + cancel_work_sync(&qca->ws_awake_rx); 1559 + 1560 + spin_lock_irqsave_nested(&qca->hci_ibs_lock, 1561 + flags, SINGLE_DEPTH_NESTING); 1562 + 1563 + switch (qca->tx_ibs_state) { 1564 + case HCI_IBS_TX_WAKING: 1565 + del_timer(&qca->wake_retrans_timer); 1566 + /* Fall through */ 1567 + case HCI_IBS_TX_AWAKE: 1568 + del_timer(&qca->tx_idle_timer); 1569 + 1570 + serdev_device_write_flush(hu->serdev); 1571 + cmd = HCI_IBS_SLEEP_IND; 1572 + ret = serdev_device_write_buf(hu->serdev, &cmd, sizeof(cmd)); 1573 + 1574 + if (ret < 0) { 1575 + BT_ERR("Failed to send SLEEP to device"); 1576 + break; 1577 + } 1578 + 1579 + qca->tx_ibs_state = HCI_IBS_TX_ASLEEP; 1580 + qca->ibs_sent_slps++; 1581 + 1582 + qca_wq_serial_tx_clock_vote_off(&qca->ws_tx_vote_off); 1583 + break; 1584 + 1585 + case HCI_IBS_TX_ASLEEP: 1586 + break; 1587 + 1588 + default: 1589 + BT_ERR("Spurious tx state %d", qca->tx_ibs_state); 1590 + ret = -EINVAL; 1591 + break; 1592 + } 1593 + 1594 + spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); 1595 + 1596 + if (ret < 0) 1597 + goto error; 1598 + 1599 + serdev_device_wait_until_sent(hu->serdev, 1600 + msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS)); 1601 + 1602 + /* Wait for HCI_IBS_SLEEP_IND sent by device to indicate its Tx is going 1603 + * to sleep, so that the packet does not wake the system later. 1604 + */ 1605 + 1606 + ret = wait_event_interruptible_timeout(qca->suspend_wait_q, 1607 + qca->rx_ibs_state == HCI_IBS_RX_ASLEEP, 1608 + msecs_to_jiffies(IBS_BTSOC_TX_IDLE_TIMEOUT_MS)); 1609 + 1610 + if (ret > 0) 1611 + return 0; 1612 + 1613 + if (ret == 0) 1614 + ret = -ETIMEDOUT; 1615 + 1616 + error: 1617 + clear_bit(QCA_SUSPENDING, &qca->flags); 1618 + 1619 + return ret; 1620 + } 1621 + 1622 + static int __maybe_unused qca_resume(struct device *dev) 1623 + { 1624 + struct hci_dev *hdev = container_of(dev, struct hci_dev, dev); 1625 + struct hci_uart *hu = hci_get_drvdata(hdev); 1626 + struct qca_data *qca = hu->priv; 1627 + 1628 + clear_bit(QCA_SUSPENDING, &qca->flags); 1629 + 1630 + return 0; 1631 + } 1632 + 1633 + static SIMPLE_DEV_PM_OPS(qca_pm_ops, qca_suspend, qca_resume); 1634 + 1580 1635 static const struct of_device_id qca_bluetooth_of_match[] = { 1581 1636 { .compatible = "qcom,qca6174-bt" }, 1582 1637 { .compatible = "qcom,wcn3990-bt", .data = &qca_soc_data_wcn3990}, 1638 + { .compatible = "qcom,wcn3991-bt", .data = &qca_soc_data_wcn3991}, 1583 1639 { .compatible = "qcom,wcn3998-bt", .data = &qca_soc_data_wcn3998}, 1584 1640 { /* sentinel */ } 1585 1641 }; ··· 1685 1553 .driver = { 1686 1554 .name = "hci_uart_qca", 1687 1555 .of_match_table = qca_bluetooth_of_match, 1556 + .pm = &qca_pm_ops, 1688 1557 }, 1689 1558 }; 1690 1559
+14 -5
net/bluetooth/hci_request.c
··· 904 904 { 905 905 struct adv_info *adv_instance; 906 906 907 - /* Ignore instance 0 */ 907 + /* Instance 0x00 always set local name */ 908 908 if (instance == 0x00) 909 - return 0; 909 + return 1; 910 910 911 911 adv_instance = hci_find_adv_instance(hdev, instance); 912 912 if (!adv_instance) ··· 923 923 u8 instance = hdev->cur_adv_instance; 924 924 struct adv_info *adv_instance; 925 925 926 - /* Ignore instance 0 */ 926 + /* Instance 0x00 always set local name */ 927 927 if (instance == 0x00) 928 - return 0; 928 + return 1; 929 929 930 930 adv_instance = hci_find_adv_instance(hdev, instance); 931 931 if (!adv_instance) ··· 1273 1273 1274 1274 instance_flags = get_adv_instance_flags(hdev, instance); 1275 1275 1276 + /* If instance already has the flags set skip adding it once 1277 + * again. 1278 + */ 1279 + if (adv_instance && eir_get_data(adv_instance->adv_data, 1280 + adv_instance->adv_data_len, EIR_FLAGS, 1281 + NULL)) 1282 + goto skip_flags; 1283 + 1276 1284 /* The Add Advertising command allows userspace to set both the general 1277 1285 * and limited discoverable flags. 1278 1286 */ ··· 1313 1305 } 1314 1306 } 1315 1307 1308 + skip_flags: 1316 1309 if (adv_instance) { 1317 1310 memcpy(ptr, adv_instance->adv_data, 1318 1311 adv_instance->adv_data_len); ··· 1699 1690 * scheduling it. 1700 1691 */ 1701 1692 if (adv_instance && adv_instance->duration) { 1702 - u16 duration = adv_instance->duration * MSEC_PER_SEC; 1693 + u16 duration = adv_instance->timeout * MSEC_PER_SEC; 1703 1694 1704 1695 /* Time = N * 10 ms */ 1705 1696 adv_set->duration = cpu_to_le16(duration / 10);