Lines Matching +full:vdddig +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0-only
5 * HCI_IBS (HCI In-Band Sleep) is Qualcomm's power management
13 * Written by Ohad Ben-Cohen <ohad@bencohen.org>
245 if (hu->serdev) { in qca_soc_type()
246 struct qca_serdev *qsd = serdev_device_get_drvdata(hu->serdev); in qca_soc_type()
248 soc_type = qsd->btsoc_type; in qca_soc_type()
258 if (hu->serdev) { in qca_get_firmware_name()
259 struct qca_serdev *qsd = serdev_device_get_drvdata(hu->serdev); in qca_get_firmware_name()
261 return qsd->firmware_name; in qca_get_firmware_name()
286 struct qca_data *qca = hu->priv; in serial_clock_vote()
289 bool old_vote = (qca->tx_vote | qca->rx_vote); in serial_clock_vote()
294 diff = jiffies_to_msecs(jiffies - qca->vote_last_jif); in serial_clock_vote()
297 qca->vote_off_ms += diff; in serial_clock_vote()
299 qca->vote_on_ms += diff; in serial_clock_vote()
303 qca->tx_vote = true; in serial_clock_vote()
304 qca->tx_votes_on++; in serial_clock_vote()
308 qca->rx_vote = true; in serial_clock_vote()
309 qca->rx_votes_on++; in serial_clock_vote()
313 qca->tx_vote = false; in serial_clock_vote()
314 qca->tx_votes_off++; in serial_clock_vote()
318 qca->rx_vote = false; in serial_clock_vote()
319 qca->rx_votes_off++; in serial_clock_vote()
327 new_vote = qca->rx_vote | qca->tx_vote; in serial_clock_vote()
331 __serial_clock_on(hu->tty); in serial_clock_vote()
333 __serial_clock_off(hu->tty); in serial_clock_vote()
338 diff = jiffies_to_msecs(jiffies - qca->vote_last_jif); in serial_clock_vote()
341 qca->votes_on++; in serial_clock_vote()
342 qca->vote_off_ms += diff; in serial_clock_vote()
344 qca->votes_off++; in serial_clock_vote()
345 qca->vote_on_ms += diff; in serial_clock_vote()
347 qca->vote_last_jif = jiffies; in serial_clock_vote()
358 struct qca_data *qca = hu->priv; in send_hci_ibs_cmd()
365 return -ENOMEM; in send_hci_ibs_cmd()
371 skb_queue_tail(&qca->txq, skb); in send_hci_ibs_cmd()
380 struct hci_uart *hu = qca->hu; in qca_wq_awake_device()
389 spin_lock_irqsave(&qca->hci_ibs_lock, flags); in qca_wq_awake_device()
395 qca->ibs_sent_wakes++; in qca_wq_awake_device()
398 retrans_delay = msecs_to_jiffies(qca->wake_retrans); in qca_wq_awake_device()
399 mod_timer(&qca->wake_retrans_timer, jiffies + retrans_delay); in qca_wq_awake_device()
401 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in qca_wq_awake_device()
411 struct hci_uart *hu = qca->hu; in qca_wq_awake_rx()
418 spin_lock_irqsave(&qca->hci_ibs_lock, flags); in qca_wq_awake_rx()
419 qca->rx_ibs_state = HCI_IBS_RX_AWAKE; in qca_wq_awake_rx()
427 qca->ibs_sent_wacks++; in qca_wq_awake_rx()
429 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in qca_wq_awake_rx()
439 struct hci_uart *hu = qca->hu; in qca_wq_serial_rx_clock_vote_off()
450 struct hci_uart *hu = qca->hu; in qca_wq_serial_tx_clock_vote_off()
466 struct hci_uart *hu = qca->hu; in hci_ibs_tx_idle_timeout()
469 BT_DBG("hu %p idle timeout in %d state", hu, qca->tx_ibs_state); in hci_ibs_tx_idle_timeout()
471 spin_lock_irqsave_nested(&qca->hci_ibs_lock, in hci_ibs_tx_idle_timeout()
474 switch (qca->tx_ibs_state) { in hci_ibs_tx_idle_timeout()
481 qca->tx_ibs_state = HCI_IBS_TX_ASLEEP; in hci_ibs_tx_idle_timeout()
482 qca->ibs_sent_slps++; in hci_ibs_tx_idle_timeout()
483 queue_work(qca->workqueue, &qca->ws_tx_vote_off); in hci_ibs_tx_idle_timeout()
489 BT_ERR("Spurious timeout tx state %d", qca->tx_ibs_state); in hci_ibs_tx_idle_timeout()
493 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in hci_ibs_tx_idle_timeout()
499 struct hci_uart *hu = qca->hu; in hci_ibs_wake_retrans_timeout()
504 hu, qca->tx_ibs_state); in hci_ibs_wake_retrans_timeout()
506 spin_lock_irqsave_nested(&qca->hci_ibs_lock, in hci_ibs_wake_retrans_timeout()
510 if (test_bit(QCA_SUSPENDING, &qca->flags)) { in hci_ibs_wake_retrans_timeout()
511 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in hci_ibs_wake_retrans_timeout()
515 switch (qca->tx_ibs_state) { in hci_ibs_wake_retrans_timeout()
523 qca->ibs_sent_wakes++; in hci_ibs_wake_retrans_timeout()
524 retrans_delay = msecs_to_jiffies(qca->wake_retrans); in hci_ibs_wake_retrans_timeout()
525 mod_timer(&qca->wake_retrans_timer, jiffies + retrans_delay); in hci_ibs_wake_retrans_timeout()
531 BT_ERR("Spurious timeout tx state %d", qca->tx_ibs_state); in hci_ibs_wake_retrans_timeout()
535 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in hci_ibs_wake_retrans_timeout()
546 struct hci_uart *hu = qca->hu; in qca_controller_memdump_timeout()
548 mutex_lock(&qca->hci_memdump_lock); in qca_controller_memdump_timeout()
549 if (test_bit(QCA_MEMDUMP_COLLECTION, &qca->flags)) { in qca_controller_memdump_timeout()
550 qca->memdump_state = QCA_MEMDUMP_TIMEOUT; in qca_controller_memdump_timeout()
551 if (!test_bit(QCA_HW_ERROR_EVENT, &qca->flags)) { in qca_controller_memdump_timeout()
555 hci_reset_dev(hu->hdev); in qca_controller_memdump_timeout()
559 mutex_unlock(&qca->hci_memdump_lock); in qca_controller_memdump_timeout()
572 return -EOPNOTSUPP; in qca_open()
576 return -ENOMEM; in qca_open()
578 skb_queue_head_init(&qca->txq); in qca_open()
579 skb_queue_head_init(&qca->tx_wait_q); in qca_open()
580 skb_queue_head_init(&qca->rx_memdump_q); in qca_open()
581 spin_lock_init(&qca->hci_ibs_lock); in qca_open()
582 mutex_init(&qca->hci_memdump_lock); in qca_open()
583 qca->workqueue = alloc_ordered_workqueue("qca_wq", 0); in qca_open()
584 if (!qca->workqueue) { in qca_open()
587 return -ENOMEM; in qca_open()
590 INIT_WORK(&qca->ws_awake_rx, qca_wq_awake_rx); in qca_open()
591 INIT_WORK(&qca->ws_awake_device, qca_wq_awake_device); in qca_open()
592 INIT_WORK(&qca->ws_rx_vote_off, qca_wq_serial_rx_clock_vote_off); in qca_open()
593 INIT_WORK(&qca->ws_tx_vote_off, qca_wq_serial_tx_clock_vote_off); in qca_open()
594 INIT_WORK(&qca->ctrl_memdump_evt, qca_controller_memdump); in qca_open()
595 INIT_DELAYED_WORK(&qca->ctrl_memdump_timeout, in qca_open()
597 init_waitqueue_head(&qca->suspend_wait_q); in qca_open()
599 qca->hu = hu; in qca_open()
600 init_completion(&qca->drop_ev_comp); in qca_open()
602 /* Assume we start with both sides asleep -- extra wakes OK */ in qca_open()
603 qca->tx_ibs_state = HCI_IBS_TX_ASLEEP; in qca_open()
604 qca->rx_ibs_state = HCI_IBS_RX_ASLEEP; in qca_open()
606 qca->vote_last_jif = jiffies; in qca_open()
608 hu->priv = qca; in qca_open()
610 if (hu->serdev) { in qca_open()
611 qcadev = serdev_device_get_drvdata(hu->serdev); in qca_open()
613 switch (qcadev->btsoc_type) { in qca_open()
619 hu->init_speed = qcadev->init_speed; in qca_open()
626 if (qcadev->oper_speed) in qca_open()
627 hu->oper_speed = qcadev->oper_speed; in qca_open()
630 timer_setup(&qca->wake_retrans_timer, hci_ibs_wake_retrans_timeout, 0); in qca_open()
631 qca->wake_retrans = IBS_WAKE_RETRANS_TIMEOUT_MS; in qca_open()
633 timer_setup(&qca->tx_idle_timer, hci_ibs_tx_idle_timeout, 0); in qca_open()
634 qca->tx_idle_delay = IBS_HOST_TX_IDLE_TIMEOUT_MS; in qca_open()
637 qca->tx_idle_delay, qca->wake_retrans); in qca_open()
645 struct qca_data *qca = hu->priv; in qca_debugfs_init()
649 if (!hdev->debugfs) in qca_debugfs_init()
652 if (test_and_set_bit(QCA_DEBUGFS_CREATED, &qca->flags)) in qca_debugfs_init()
655 ibs_dir = debugfs_create_dir("ibs", hdev->debugfs); in qca_debugfs_init()
659 debugfs_create_u8("tx_ibs_state", mode, ibs_dir, &qca->tx_ibs_state); in qca_debugfs_init()
660 debugfs_create_u8("rx_ibs_state", mode, ibs_dir, &qca->rx_ibs_state); in qca_debugfs_init()
662 &qca->ibs_sent_slps); in qca_debugfs_init()
664 &qca->ibs_sent_wakes); in qca_debugfs_init()
666 &qca->ibs_sent_wacks); in qca_debugfs_init()
668 &qca->ibs_recv_slps); in qca_debugfs_init()
670 &qca->ibs_recv_wakes); in qca_debugfs_init()
672 &qca->ibs_recv_wacks); in qca_debugfs_init()
673 debugfs_create_bool("tx_vote", mode, ibs_dir, &qca->tx_vote); in qca_debugfs_init()
674 debugfs_create_u64("tx_votes_on", mode, ibs_dir, &qca->tx_votes_on); in qca_debugfs_init()
675 debugfs_create_u64("tx_votes_off", mode, ibs_dir, &qca->tx_votes_off); in qca_debugfs_init()
676 debugfs_create_bool("rx_vote", mode, ibs_dir, &qca->rx_vote); in qca_debugfs_init()
677 debugfs_create_u64("rx_votes_on", mode, ibs_dir, &qca->rx_votes_on); in qca_debugfs_init()
678 debugfs_create_u64("rx_votes_off", mode, ibs_dir, &qca->rx_votes_off); in qca_debugfs_init()
679 debugfs_create_u64("votes_on", mode, ibs_dir, &qca->votes_on); in qca_debugfs_init()
680 debugfs_create_u64("votes_off", mode, ibs_dir, &qca->votes_off); in qca_debugfs_init()
681 debugfs_create_u32("vote_on_ms", mode, ibs_dir, &qca->vote_on_ms); in qca_debugfs_init()
682 debugfs_create_u32("vote_off_ms", mode, ibs_dir, &qca->vote_off_ms); in qca_debugfs_init()
686 debugfs_create_u32("wake_retrans", mode, ibs_dir, &qca->wake_retrans); in qca_debugfs_init()
688 &qca->tx_idle_delay); in qca_debugfs_init()
694 struct qca_data *qca = hu->priv; in qca_flush()
698 skb_queue_purge(&qca->tx_wait_q); in qca_flush()
699 skb_queue_purge(&qca->txq); in qca_flush()
707 struct qca_data *qca = hu->priv; in qca_close()
713 skb_queue_purge(&qca->tx_wait_q); in qca_close()
714 skb_queue_purge(&qca->txq); in qca_close()
715 skb_queue_purge(&qca->rx_memdump_q); in qca_close()
722 timer_shutdown_sync(&qca->tx_idle_timer); in qca_close()
723 timer_shutdown_sync(&qca->wake_retrans_timer); in qca_close()
724 destroy_workqueue(qca->workqueue); in qca_close()
725 qca->hu = NULL; in qca_close()
727 kfree_skb(qca->rx_skb); in qca_close()
729 hu->priv = NULL; in qca_close()
736 /* Called upon a wake-up-indication from the device.
741 struct qca_data *qca = hu->priv; in device_want_to_wakeup()
745 spin_lock_irqsave(&qca->hci_ibs_lock, flags); in device_want_to_wakeup()
747 qca->ibs_recv_wakes++; in device_want_to_wakeup()
750 if (test_bit(QCA_SUSPENDING, &qca->flags)) { in device_want_to_wakeup()
751 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in device_want_to_wakeup()
755 switch (qca->rx_ibs_state) { in device_want_to_wakeup()
757 /* Make sure clock is on - we may have turned clock off since in device_want_to_wakeup()
760 queue_work(qca->workqueue, &qca->ws_awake_rx); in device_want_to_wakeup()
761 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in device_want_to_wakeup()
772 qca->ibs_sent_wacks++; in device_want_to_wakeup()
778 qca->rx_ibs_state); in device_want_to_wakeup()
782 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in device_want_to_wakeup()
788 /* Called upon a sleep-indication from the device.
793 struct qca_data *qca = hu->priv; in device_want_to_sleep()
795 BT_DBG("hu %p want to sleep in %d state", hu, qca->rx_ibs_state); in device_want_to_sleep()
797 spin_lock_irqsave(&qca->hci_ibs_lock, flags); in device_want_to_sleep()
799 qca->ibs_recv_slps++; in device_want_to_sleep()
801 switch (qca->rx_ibs_state) { in device_want_to_sleep()
804 qca->rx_ibs_state = HCI_IBS_RX_ASLEEP; in device_want_to_sleep()
806 queue_work(qca->workqueue, &qca->ws_rx_vote_off); in device_want_to_sleep()
815 qca->rx_ibs_state); in device_want_to_sleep()
819 wake_up_interruptible(&qca->suspend_wait_q); in device_want_to_sleep()
821 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in device_want_to_sleep()
824 /* Called upon wake-up-acknowledgement from the device
829 struct qca_data *qca = hu->priv; in device_woke_up()
834 spin_lock_irqsave(&qca->hci_ibs_lock, flags); in device_woke_up()
836 qca->ibs_recv_wacks++; in device_woke_up()
838 /* Don't react to the wake-up-acknowledgment when suspending. */ in device_woke_up()
839 if (test_bit(QCA_SUSPENDING, &qca->flags)) { in device_woke_up()
840 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in device_woke_up()
844 switch (qca->tx_ibs_state) { in device_woke_up()
848 qca->tx_ibs_state); in device_woke_up()
853 while ((skb = skb_dequeue(&qca->tx_wait_q))) in device_woke_up()
854 skb_queue_tail(&qca->txq, skb); in device_woke_up()
857 del_timer(&qca->wake_retrans_timer); in device_woke_up()
858 idle_delay = msecs_to_jiffies(qca->tx_idle_delay); in device_woke_up()
859 mod_timer(&qca->tx_idle_timer, jiffies + idle_delay); in device_woke_up()
860 qca->tx_ibs_state = HCI_IBS_TX_AWAKE; in device_woke_up()
866 qca->tx_ibs_state); in device_woke_up()
870 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in device_woke_up()
882 struct qca_data *qca = hu->priv; in qca_enqueue()
885 qca->tx_ibs_state); in qca_enqueue()
887 if (test_bit(QCA_SSR_TRIGGERED, &qca->flags)) { in qca_enqueue()
889 bt_dev_dbg(hu->hdev, "SSR is in progress"); in qca_enqueue()
897 spin_lock_irqsave(&qca->hci_ibs_lock, flags); in qca_enqueue()
900 * Out-Of-Band(GPIOs control) sleep is selected. in qca_enqueue()
903 if (test_bit(QCA_IBS_DISABLED, &qca->flags) || in qca_enqueue()
904 test_bit(QCA_SUSPENDING, &qca->flags)) { in qca_enqueue()
905 skb_queue_tail(&qca->txq, skb); in qca_enqueue()
906 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in qca_enqueue()
911 switch (qca->tx_ibs_state) { in qca_enqueue()
914 skb_queue_tail(&qca->txq, skb); in qca_enqueue()
915 idle_delay = msecs_to_jiffies(qca->tx_idle_delay); in qca_enqueue()
916 mod_timer(&qca->tx_idle_timer, jiffies + idle_delay); in qca_enqueue()
922 skb_queue_tail(&qca->tx_wait_q, skb); in qca_enqueue()
924 qca->tx_ibs_state = HCI_IBS_TX_WAKING; in qca_enqueue()
926 queue_work(qca->workqueue, &qca->ws_awake_device); in qca_enqueue()
932 skb_queue_tail(&qca->tx_wait_q, skb); in qca_enqueue()
937 qca->tx_ibs_state); in qca_enqueue()
942 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in qca_enqueue()
990 if (get_unaligned_le16(skb->data) == QCA_DEBUG_HANDLE) in qca_recv_acl_data()
999 struct qca_data *qca = hu->priv; in qca_dmp_hdr()
1003 qca->controller_id); in qca_dmp_hdr()
1007 qca->fw_version); in qca_dmp_hdr()
1014 hu->serdev->dev.driver->name); in qca_dmp_hdr()
1022 struct hci_uart *hu = qca->hu; in qca_controller_memdump()
1025 struct qca_memdump_info *qca_memdump = qca->qca_memdump; in qca_controller_memdump()
1032 while ((skb = skb_dequeue(&qca->rx_memdump_q))) { in qca_controller_memdump()
1034 mutex_lock(&qca->hci_memdump_lock); in qca_controller_memdump()
1038 if (qca->memdump_state == QCA_MEMDUMP_TIMEOUT || in qca_controller_memdump()
1039 qca->memdump_state == QCA_MEMDUMP_COLLECTED) { in qca_controller_memdump()
1040 mutex_unlock(&qca->hci_memdump_lock); in qca_controller_memdump()
1047 mutex_unlock(&qca->hci_memdump_lock); in qca_controller_memdump()
1051 qca->qca_memdump = qca_memdump; in qca_controller_memdump()
1054 qca->memdump_state = QCA_MEMDUMP_COLLECTING; in qca_controller_memdump()
1055 cmd_hdr = (void *) skb->data; in qca_controller_memdump()
1056 seq_no = __le16_to_cpu(cmd_hdr->seq_no); in qca_controller_memdump()
1067 set_bit(QCA_IBS_DISABLED, &qca->flags); in qca_controller_memdump()
1068 set_bit(QCA_MEMDUMP_COLLECTION, &qca->flags); in qca_controller_memdump()
1069 dump = (void *) skb->data; in qca_controller_memdump()
1070 qca_memdump->ram_dump_size = __le32_to_cpu(dump->dump_size); in qca_controller_memdump()
1071 if (!(qca_memdump->ram_dump_size)) { in qca_controller_memdump()
1072 bt_dev_err(hu->hdev, "Rx invalid memdump size"); in qca_controller_memdump()
1075 mutex_unlock(&qca->hci_memdump_lock); in qca_controller_memdump()
1079 queue_delayed_work(qca->workqueue, in qca_controller_memdump()
1080 &qca->ctrl_memdump_timeout, in qca_controller_memdump()
1082 skb_pull(skb, sizeof(qca_memdump->ram_dump_size)); in qca_controller_memdump()
1083 qca_memdump->current_seq_no = 0; in qca_controller_memdump()
1084 qca_memdump->received_dump = 0; in qca_controller_memdump()
1085 ret = hci_devcd_init(hu->hdev, qca_memdump->ram_dump_size); in qca_controller_memdump()
1086 bt_dev_info(hu->hdev, "hci_devcd_init Return:%d", in qca_controller_memdump()
1089 kfree(qca->qca_memdump); in qca_controller_memdump()
1090 qca->qca_memdump = NULL; in qca_controller_memdump()
1091 qca->memdump_state = QCA_MEMDUMP_COLLECTED; in qca_controller_memdump()
1092 cancel_delayed_work(&qca->ctrl_memdump_timeout); in qca_controller_memdump()
1093 clear_bit(QCA_MEMDUMP_COLLECTION, &qca->flags); in qca_controller_memdump()
1094 clear_bit(QCA_IBS_DISABLED, &qca->flags); in qca_controller_memdump()
1095 mutex_unlock(&qca->hci_memdump_lock); in qca_controller_memdump()
1099 bt_dev_info(hu->hdev, "QCA collecting dump of size:%u", in qca_controller_memdump()
1100 qca_memdump->ram_dump_size); in qca_controller_memdump()
1107 if (!test_bit(QCA_MEMDUMP_COLLECTION, &qca->flags)) { in qca_controller_memdump()
1108 bt_dev_err(hu->hdev, "QCA: Discarding other packets"); in qca_controller_memdump()
1111 mutex_unlock(&qca->hci_memdump_lock); in qca_controller_memdump()
1122 while ((seq_no > qca_memdump->current_seq_no + 1) && in qca_controller_memdump()
1125 bt_dev_err(hu->hdev, "QCA controller missed packet:%d", in qca_controller_memdump()
1126 qca_memdump->current_seq_no); in qca_controller_memdump()
1127 rx_size = qca_memdump->received_dump; in qca_controller_memdump()
1129 if (rx_size > qca_memdump->ram_dump_size) { in qca_controller_memdump()
1130 bt_dev_err(hu->hdev, in qca_controller_memdump()
1132 qca_memdump->received_dump); in qca_controller_memdump()
1135 hci_devcd_append_pattern(hu->hdev, 0x00, in qca_controller_memdump()
1137 qca_memdump->received_dump += QCA_DUMP_PACKET_SIZE; in qca_controller_memdump()
1138 qca_memdump->current_seq_no++; in qca_controller_memdump()
1141 rx_size = qca_memdump->received_dump + skb->len; in qca_controller_memdump()
1142 if (rx_size <= qca_memdump->ram_dump_size) { in qca_controller_memdump()
1144 (seq_no != qca_memdump->current_seq_no)) { in qca_controller_memdump()
1145 bt_dev_err(hu->hdev, in qca_controller_memdump()
1149 bt_dev_dbg(hu->hdev, in qca_controller_memdump()
1151 seq_no, skb->len); in qca_controller_memdump()
1152 hci_devcd_append(hu->hdev, skb); in qca_controller_memdump()
1153 qca_memdump->current_seq_no += 1; in qca_controller_memdump()
1154 qca_memdump->received_dump = rx_size; in qca_controller_memdump()
1156 bt_dev_err(hu->hdev, in qca_controller_memdump()
1158 qca_memdump->current_seq_no); in qca_controller_memdump()
1162 bt_dev_info(hu->hdev, in qca_controller_memdump()
1164 qca_memdump->received_dump, in qca_controller_memdump()
1165 qca_memdump->ram_dump_size); in qca_controller_memdump()
1166 hci_devcd_complete(hu->hdev); in qca_controller_memdump()
1167 cancel_delayed_work(&qca->ctrl_memdump_timeout); in qca_controller_memdump()
1168 kfree(qca->qca_memdump); in qca_controller_memdump()
1169 qca->qca_memdump = NULL; in qca_controller_memdump()
1170 qca->memdump_state = QCA_MEMDUMP_COLLECTED; in qca_controller_memdump()
1171 clear_bit(QCA_MEMDUMP_COLLECTION, &qca->flags); in qca_controller_memdump()
1174 mutex_unlock(&qca->hci_memdump_lock); in qca_controller_memdump()
1183 struct qca_data *qca = hu->priv; in qca_controller_memdump_event()
1185 set_bit(QCA_SSR_TRIGGERED, &qca->flags); in qca_controller_memdump_event()
1186 skb_queue_tail(&qca->rx_memdump_q, skb); in qca_controller_memdump_event()
1187 queue_work(qca->workqueue, &qca->ctrl_memdump_evt); in qca_controller_memdump_event()
1195 struct qca_data *qca = hu->priv; in qca_recv_event()
1197 if (test_bit(QCA_DROP_VENDOR_EVENT, &qca->flags)) { in qca_recv_event()
1198 struct hci_event_hdr *hdr = (void *)skb->data; in qca_recv_event()
1210 if (hdr->evt == HCI_EV_VENDOR) in qca_recv_event()
1211 complete(&qca->drop_ev_comp); in qca_recv_event()
1222 if ((skb->data[0] == HCI_VENDOR_PKT) && in qca_recv_event()
1223 (get_unaligned_be16(skb->data + 2) == QCA_SSR_DUMP_HANDLE)) in qca_recv_event()
1261 struct qca_data *qca = hu->priv; in qca_recv()
1263 if (!test_bit(HCI_UART_REGISTERED, &hu->flags)) in qca_recv()
1264 return -EUNATCH; in qca_recv()
1266 qca->rx_skb = h4_recv_buf(hu->hdev, qca->rx_skb, data, count, in qca_recv()
1268 if (IS_ERR(qca->rx_skb)) { in qca_recv()
1269 int err = PTR_ERR(qca->rx_skb); in qca_recv()
1270 bt_dev_err(hu->hdev, "Frame reassembly failed (%d)", err); in qca_recv()
1271 qca->rx_skb = NULL; in qca_recv()
1280 struct qca_data *qca = hu->priv; in qca_dequeue()
1282 return skb_dequeue(&qca->txq); in qca_dequeue()
1324 struct qca_data *qca = hu->priv; in qca_set_baudrate()
1329 return -EINVAL; in qca_set_baudrate()
1336 return -ENOMEM; in qca_set_baudrate()
1343 skb_queue_tail(&qca->txq, skb); in qca_set_baudrate()
1348 while (!skb_queue_empty(&qca->txq)) in qca_set_baudrate()
1351 if (hu->serdev) in qca_set_baudrate()
1352 serdev_device_wait_until_sent(hu->serdev, in qca_set_baudrate()
1376 if (hu->serdev) in host_set_baudrate()
1377 serdev_device_set_baudrate(hu->serdev, speed); in host_set_baudrate()
1391 * For example, wcn3990 supports RF COEX antenna for both Wi-Fi/BT in qca_send_power_pulse()
1393 * Wi-Fi/BT. Powering up the power sources will not enable BT, until in qca_send_power_pulse()
1398 bt_dev_dbg(hu->hdev, "sending power pulse %02x to controller", cmd); in qca_send_power_pulse()
1400 serdev_device_write_flush(hu->serdev); in qca_send_power_pulse()
1402 ret = serdev_device_write_buf(hu->serdev, &cmd, sizeof(cmd)); in qca_send_power_pulse()
1404 bt_dev_err(hu->hdev, "failed to send power pulse %02x", cmd); in qca_send_power_pulse()
1408 serdev_device_wait_until_sent(hu->serdev, timeout); in qca_send_power_pulse()
1426 if (hu->init_speed) in qca_get_speed()
1427 speed = hu->init_speed; in qca_get_speed()
1428 else if (hu->proto->init_speed) in qca_get_speed()
1429 speed = hu->proto->init_speed; in qca_get_speed()
1431 if (hu->oper_speed) in qca_get_speed()
1432 speed = hu->oper_speed; in qca_get_speed()
1433 else if (hu->proto->oper_speed) in qca_get_speed()
1434 speed = hu->proto->oper_speed; in qca_get_speed()
1452 return -EINVAL; in qca_check_speeds()
1458 return -EINVAL; in qca_check_speeds()
1467 struct qca_data *qca = hu->priv; in qca_set_speed()
1501 reinit_completion(&qca->drop_ev_comp); in qca_set_speed()
1502 set_bit(QCA_DROP_VENDOR_EVENT, &qca->flags); in qca_set_speed()
1510 bt_dev_dbg(hu->hdev, "Set UART speed to %d", speed); in qca_set_speed()
1511 ret = qca_set_baudrate(hu->hdev, qca_baudrate); in qca_set_speed()
1538 if (!wait_for_completion_timeout(&qca->drop_ev_comp, in qca_set_speed()
1540 bt_dev_err(hu->hdev, in qca_set_speed()
1542 ret = -ETIMEDOUT; in qca_set_speed()
1545 clear_bit(QCA_DROP_VENDOR_EVENT, &qca->flags); in qca_set_speed()
1558 struct qca_data *qca = hu->priv; in qca_send_crashbuffer()
1563 bt_dev_err(hu->hdev, "Failed to allocate memory for skb packet"); in qca_send_crashbuffer()
1564 return -ENOMEM; in qca_send_crashbuffer()
1574 bt_dev_info(hu->hdev, "crash the soc to collect controller dump"); in qca_send_crashbuffer()
1575 skb_queue_tail(&qca->txq, skb); in qca_send_crashbuffer()
1584 struct qca_data *qca = hu->priv; in qca_wait_for_dump_collection()
1586 wait_on_bit_timeout(&qca->flags, QCA_MEMDUMP_COLLECTION, in qca_wait_for_dump_collection()
1589 clear_bit(QCA_MEMDUMP_COLLECTION, &qca->flags); in qca_wait_for_dump_collection()
1595 struct qca_data *qca = hu->priv; in qca_hw_error()
1597 set_bit(QCA_SSR_TRIGGERED, &qca->flags); in qca_hw_error()
1598 set_bit(QCA_HW_ERROR_EVENT, &qca->flags); in qca_hw_error()
1599 bt_dev_info(hdev, "mem_dump_status: %d", qca->memdump_state); in qca_hw_error()
1601 if (qca->memdump_state == QCA_MEMDUMP_IDLE) { in qca_hw_error()
1608 set_bit(QCA_MEMDUMP_COLLECTION, &qca->flags); in qca_hw_error()
1611 } else if (qca->memdump_state == QCA_MEMDUMP_COLLECTING) { in qca_hw_error()
1619 mutex_lock(&qca->hci_memdump_lock); in qca_hw_error()
1620 if (qca->memdump_state != QCA_MEMDUMP_COLLECTED) { in qca_hw_error()
1621 bt_dev_err(hu->hdev, "clearing allocated memory due to memdump timeout"); in qca_hw_error()
1622 hci_devcd_abort(hu->hdev); in qca_hw_error()
1623 if (qca->qca_memdump) { in qca_hw_error()
1624 kfree(qca->qca_memdump); in qca_hw_error()
1625 qca->qca_memdump = NULL; in qca_hw_error()
1627 qca->memdump_state = QCA_MEMDUMP_TIMEOUT; in qca_hw_error()
1628 cancel_delayed_work(&qca->ctrl_memdump_timeout); in qca_hw_error()
1630 mutex_unlock(&qca->hci_memdump_lock); in qca_hw_error()
1632 if (qca->memdump_state == QCA_MEMDUMP_TIMEOUT || in qca_hw_error()
1633 qca->memdump_state == QCA_MEMDUMP_COLLECTED) { in qca_hw_error()
1634 cancel_work_sync(&qca->ctrl_memdump_evt); in qca_hw_error()
1635 skb_queue_purge(&qca->rx_memdump_q); in qca_hw_error()
1638 clear_bit(QCA_HW_ERROR_EVENT, &qca->flags); in qca_hw_error()
1644 struct qca_data *qca = hu->priv; in qca_cmd_timeout()
1646 set_bit(QCA_SSR_TRIGGERED, &qca->flags); in qca_cmd_timeout()
1647 if (qca->memdump_state == QCA_MEMDUMP_IDLE) { in qca_cmd_timeout()
1648 set_bit(QCA_MEMDUMP_COLLECTION, &qca->flags); in qca_cmd_timeout()
1651 } else if (qca->memdump_state == QCA_MEMDUMP_COLLECTING) { in qca_cmd_timeout()
1659 mutex_lock(&qca->hci_memdump_lock); in qca_cmd_timeout()
1660 if (qca->memdump_state != QCA_MEMDUMP_COLLECTED) { in qca_cmd_timeout()
1661 qca->memdump_state = QCA_MEMDUMP_TIMEOUT; in qca_cmd_timeout()
1662 if (!test_bit(QCA_HW_ERROR_EVENT, &qca->flags)) { in qca_cmd_timeout()
1666 hci_reset_dev(hu->hdev); in qca_cmd_timeout()
1669 mutex_unlock(&qca->hci_memdump_lock); in qca_cmd_timeout()
1677 if (!hu->serdev) in qca_wakeup()
1684 wakeup = device_may_wakeup(&hu->serdev->ctrl->dev); in qca_wakeup()
1685 bt_dev_dbg(hu->hdev, "wakeup status : %d", wakeup); in qca_wakeup()
1699 serdev_device_close(hu->serdev); in qca_port_reopen()
1700 ret = serdev_device_open(hu->serdev); in qca_port_reopen()
1702 bt_dev_err(hu->hdev, "failed to open port"); in qca_port_reopen()
1721 qcadev = serdev_device_get_drvdata(hu->serdev); in qca_regulator_init()
1723 if (!qcadev->bt_power->vregs_on) { in qca_regulator_init()
1724 serdev_device_close(hu->serdev); in qca_regulator_init()
1729 ret = serdev_device_open(hu->serdev); in qca_regulator_init()
1731 bt_dev_err(hu->hdev, "failed to open port"); in qca_regulator_init()
1753 if (qcadev->bt_en) { in qca_regulator_init()
1754 gpiod_set_value_cansleep(qcadev->bt_en, 0); in qca_regulator_init()
1756 gpiod_set_value_cansleep(qcadev->bt_en, 1); in qca_regulator_init()
1758 if (qcadev->sw_ctrl) { in qca_regulator_init()
1759 sw_ctrl_state = gpiod_get_value_cansleep(qcadev->sw_ctrl); in qca_regulator_init()
1760 bt_dev_dbg(hu->hdev, "SW_CTRL is %d", sw_ctrl_state); in qca_regulator_init()
1788 struct qca_data *qca = hu->priv; in qca_power_on()
1791 /* Non-serdev device usually is powered by external power in qca_power_on()
1794 if (!hu->serdev) in qca_power_on()
1810 qcadev = serdev_device_get_drvdata(hu->serdev); in qca_power_on()
1811 if (qcadev->bt_en) { in qca_power_on()
1812 gpiod_set_value_cansleep(qcadev->bt_en, 1); in qca_power_on()
1818 clear_bit(QCA_BT_OFF, &qca->flags); in qca_power_on()
1834 /* QCA uses 1 as non-HCI data path id for HFP */ in qca_get_data_path_id()
1841 bt_dev_info(hdev, "HFP non-HCI data transport is supported"); in qca_configure_hfp_offload()
1842 hdev->get_data_path_id = qca_get_data_path_id; in qca_configure_hfp_offload()
1843 /* Do not need to send HCI_Configure_Data_Path to configure non-HCI in qca_configure_hfp_offload()
1846 hdev->get_codec_config_data = NULL; in qca_configure_hfp_offload()
1852 struct hci_dev *hdev = hu->hdev; in qca_setup()
1853 struct qca_data *qca = hu->priv; in qca_setup()
1867 clear_bit(QCA_ROM_FW, &qca->flags); in qca_setup()
1869 set_bit(QCA_IBS_DISABLED, &qca->flags); in qca_setup()
1874 set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); in qca_setup()
1905 qca->memdump_state = QCA_MEMDUMP_IDLE; in qca_setup()
1912 clear_bit(QCA_SSR_TRIGGERED, &qca->flags); in qca_setup()
1922 qcadev = serdev_device_get_drvdata(hu->serdev); in qca_setup()
1923 if (qcadev->bdaddr_property_broken) in qca_setup()
1924 set_bit(HCI_QUIRK_BDADDR_PROPERTY_BROKEN, &hdev->quirks); in qca_setup()
1968 clear_bit(QCA_IBS_DISABLED, &qca->flags); in qca_setup()
1970 hu->hdev->hw_error = qca_hw_error; in qca_setup()
1971 hu->hdev->cmd_timeout = qca_cmd_timeout; in qca_setup()
1972 if (hu->serdev) { in qca_setup()
1973 if (device_can_wakeup(hu->serdev->ctrl->dev.parent)) in qca_setup()
1974 hu->hdev->wakeup = qca_wakeup; in qca_setup()
1976 } else if (ret == -ENOENT) { in qca_setup()
1977 /* No patch/nvm-config found, run with original fw/config */ in qca_setup()
1978 set_bit(QCA_ROM_FW, &qca->flags); in qca_setup()
1980 } else if (ret == -EAGAIN) { in qca_setup()
1982 * Userspace firmware loader will return -EAGAIN in case no in qca_setup()
1983 * patch/nvm-config is found, so run with original fw/config. in qca_setup()
1985 set_bit(QCA_ROM_FW, &qca->flags); in qca_setup()
1993 if (hu->serdev) { in qca_setup()
1994 serdev_device_close(hu->serdev); in qca_setup()
1995 ret = serdev_device_open(hu->serdev); in qca_setup()
2007 hu->hdev->set_bdaddr = qca_set_bdaddr_rome; in qca_setup()
2009 hu->hdev->set_bdaddr = qca_set_bdaddr; in qca_setup()
2014 qca->fw_version = le16_to_cpu(ver.patch_ver); in qca_setup()
2015 qca->controller_id = le16_to_cpu(ver.rom_ver); in qca_setup()
2128 { "vdddig", 126000 },
2140 struct qca_data *qca = hu->priv; in qca_power_shutdown()
2150 spin_lock_irqsave(&qca->hci_ibs_lock, flags); in qca_power_shutdown()
2151 set_bit(QCA_IBS_DISABLED, &qca->flags); in qca_power_shutdown()
2153 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in qca_power_shutdown()
2155 /* Non-serdev device usually is powered by external power in qca_power_shutdown()
2158 if (!hu->serdev) in qca_power_shutdown()
2161 qcadev = serdev_device_get_drvdata(hu->serdev); in qca_power_shutdown()
2162 power = qcadev->bt_power; in qca_power_shutdown()
2164 if (power && power->pwrseq) { in qca_power_shutdown()
2165 pwrseq_power_off(power->pwrseq); in qca_power_shutdown()
2166 set_bit(QCA_BT_OFF, &qca->flags); in qca_power_shutdown()
2182 gpiod_set_value_cansleep(qcadev->bt_en, 0); in qca_power_shutdown()
2185 if (qcadev->sw_ctrl) { in qca_power_shutdown()
2186 sw_ctrl_state = gpiod_get_value_cansleep(qcadev->sw_ctrl); in qca_power_shutdown()
2187 bt_dev_dbg(hu->hdev, "SW_CTRL is %d", sw_ctrl_state); in qca_power_shutdown()
2192 gpiod_set_value_cansleep(qcadev->bt_en, 0); in qca_power_shutdown()
2195 set_bit(QCA_BT_OFF, &qca->flags); in qca_power_shutdown()
2201 struct qca_data *qca = hu->priv; in qca_power_off()
2204 hu->hdev->hw_error = NULL; in qca_power_off()
2205 hu->hdev->cmd_timeout = NULL; in qca_power_off()
2207 del_timer_sync(&qca->wake_retrans_timer); in qca_power_off()
2208 del_timer_sync(&qca->tx_idle_timer); in qca_power_off()
2212 && qca->memdump_state == QCA_MEMDUMP_IDLE) { in qca_power_off()
2223 struct qca_power *power = qcadev->bt_power; in qca_regulator_enable()
2226 if (power->pwrseq) in qca_regulator_enable()
2227 return pwrseq_power_on(power->pwrseq); in qca_regulator_enable()
2230 if (power->vregs_on) in qca_regulator_enable()
2233 BT_DBG("enabling %d regulators)", power->num_vregs); in qca_regulator_enable()
2235 ret = regulator_bulk_enable(power->num_vregs, power->vreg_bulk); in qca_regulator_enable()
2239 power->vregs_on = true; in qca_regulator_enable()
2241 ret = clk_prepare_enable(qcadev->susclk); in qca_regulator_enable()
2255 power = qcadev->bt_power; in qca_regulator_disable()
2258 if (!power->vregs_on) in qca_regulator_disable()
2261 regulator_bulk_disable(power->num_vregs, power->vreg_bulk); in qca_regulator_disable()
2262 power->vregs_on = false; in qca_regulator_disable()
2264 clk_disable_unprepare(qcadev->susclk); in qca_regulator_disable()
2274 bulk = devm_kcalloc(qca->dev, num_vregs, sizeof(*bulk), GFP_KERNEL); in qca_init_regulators()
2276 return -ENOMEM; in qca_init_regulators()
2279 bulk[i].supply = vregs[i].name; in qca_init_regulators()
2281 ret = devm_regulator_bulk_get(qca->dev, num_vregs, bulk); in qca_init_regulators()
2291 qca->vreg_bulk = bulk; in qca_init_regulators()
2292 qca->num_vregs = num_vregs; in qca_init_regulators()
2312 qcadev = devm_kzalloc(&serdev->dev, sizeof(*qcadev), GFP_KERNEL); in qca_serdev_probe()
2314 return -ENOMEM; in qca_serdev_probe()
2316 qcadev->serdev_hu.serdev = serdev; in qca_serdev_probe()
2317 data = device_get_match_data(&serdev->dev); in qca_serdev_probe()
2319 device_property_read_string(&serdev->dev, "firmware-name", in qca_serdev_probe()
2320 &qcadev->firmware_name); in qca_serdev_probe()
2321 device_property_read_u32(&serdev->dev, "max-speed", in qca_serdev_probe()
2322 &qcadev->oper_speed); in qca_serdev_probe()
2323 if (!qcadev->oper_speed) in qca_serdev_probe()
2326 qcadev->bdaddr_property_broken = device_property_read_bool(&serdev->dev, in qca_serdev_probe()
2327 "qcom,local-bd-address-broken"); in qca_serdev_probe()
2330 qcadev->btsoc_type = data->soc_type; in qca_serdev_probe()
2332 qcadev->btsoc_type = QCA_ROME; in qca_serdev_probe()
2334 switch (qcadev->btsoc_type) { in qca_serdev_probe()
2343 qcadev->bt_power = devm_kzalloc(&serdev->dev, in qca_serdev_probe()
2346 if (!qcadev->bt_power) in qca_serdev_probe()
2347 return -ENOMEM; in qca_serdev_probe()
2353 switch (qcadev->btsoc_type) { in qca_serdev_probe()
2356 if (!device_property_present(&serdev->dev, "enable-gpios")) { in qca_serdev_probe()
2359 * node doesn't have the 'enable-gpios' property then in qca_serdev_probe()
2363 qcadev->bt_power->pwrseq = devm_pwrseq_get(&serdev->dev, in qca_serdev_probe()
2365 if (IS_ERR(qcadev->bt_power->pwrseq)) in qca_serdev_probe()
2366 return PTR_ERR(qcadev->bt_power->pwrseq); in qca_serdev_probe()
2376 qcadev->bt_power->dev = &serdev->dev; in qca_serdev_probe()
2377 err = qca_init_regulators(qcadev->bt_power, data->vregs, in qca_serdev_probe()
2378 data->num_vregs); in qca_serdev_probe()
2384 qcadev->bt_power->vregs_on = false; in qca_serdev_probe()
2386 qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable", in qca_serdev_probe()
2388 if (IS_ERR(qcadev->bt_en) && in qca_serdev_probe()
2389 (data->soc_type == QCA_WCN6750 || in qca_serdev_probe()
2390 data->soc_type == QCA_WCN6855)) { in qca_serdev_probe()
2391 dev_err(&serdev->dev, "failed to acquire BT_EN gpio\n"); in qca_serdev_probe()
2392 return PTR_ERR(qcadev->bt_en); in qca_serdev_probe()
2395 if (!qcadev->bt_en) in qca_serdev_probe()
2398 qcadev->sw_ctrl = devm_gpiod_get_optional(&serdev->dev, "swctrl", in qca_serdev_probe()
2400 if (IS_ERR(qcadev->sw_ctrl) && in qca_serdev_probe()
2401 (data->soc_type == QCA_WCN6750 || in qca_serdev_probe()
2402 data->soc_type == QCA_WCN6855 || in qca_serdev_probe()
2403 data->soc_type == QCA_WCN7850)) { in qca_serdev_probe()
2404 dev_err(&serdev->dev, "failed to acquire SW_CTRL gpio\n"); in qca_serdev_probe()
2405 return PTR_ERR(qcadev->sw_ctrl); in qca_serdev_probe()
2408 qcadev->susclk = devm_clk_get_optional(&serdev->dev, NULL); in qca_serdev_probe()
2409 if (IS_ERR(qcadev->susclk)) { in qca_serdev_probe()
2410 dev_err(&serdev->dev, "failed to acquire clk\n"); in qca_serdev_probe()
2411 return PTR_ERR(qcadev->susclk); in qca_serdev_probe()
2416 if (dev_of_node(&serdev->dev)) { in qca_serdev_probe()
2417 qcadev->bt_power->pwrseq = devm_pwrseq_get(&serdev->dev, in qca_serdev_probe()
2419 if (IS_ERR(qcadev->bt_power->pwrseq)) in qca_serdev_probe()
2420 return PTR_ERR(qcadev->bt_power->pwrseq); in qca_serdev_probe()
2426 qcadev->bt_en = devm_gpiod_get_optional(&serdev->dev, "enable", in qca_serdev_probe()
2428 if (IS_ERR(qcadev->bt_en)) { in qca_serdev_probe()
2429 dev_err(&serdev->dev, "failed to acquire enable gpio\n"); in qca_serdev_probe()
2430 return PTR_ERR(qcadev->bt_en); in qca_serdev_probe()
2433 if (!qcadev->bt_en) in qca_serdev_probe()
2436 qcadev->susclk = devm_clk_get_optional(&serdev->dev, NULL); in qca_serdev_probe()
2437 if (IS_ERR(qcadev->susclk)) { in qca_serdev_probe()
2438 dev_warn(&serdev->dev, "failed to acquire clk\n"); in qca_serdev_probe()
2439 return PTR_ERR(qcadev->susclk); in qca_serdev_probe()
2441 err = clk_set_rate(qcadev->susclk, SUSCLK_RATE_32KHZ); in qca_serdev_probe()
2445 err = clk_prepare_enable(qcadev->susclk); in qca_serdev_probe()
2449 err = devm_add_action_or_reset(&serdev->dev, in qca_serdev_probe()
2451 qcadev->susclk); in qca_serdev_probe()
2457 err = hci_uart_register_device(&qcadev->serdev_hu, &qca_proto); in qca_serdev_probe()
2463 hdev = qcadev->serdev_hu.hdev; in qca_serdev_probe()
2466 set_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks); in qca_serdev_probe()
2467 hdev->shutdown = qca_power_off; in qca_serdev_probe()
2474 if (data->capabilities & QCA_CAP_WIDEBAND_SPEECH) in qca_serdev_probe()
2476 &hdev->quirks); in qca_serdev_probe()
2478 if (!(data->capabilities & QCA_CAP_VALID_LE_STATES)) in qca_serdev_probe()
2479 set_bit(HCI_QUIRK_BROKEN_LE_STATES, &hdev->quirks); in qca_serdev_probe()
2488 struct qca_power *power = qcadev->bt_power; in qca_serdev_remove()
2490 switch (qcadev->btsoc_type) { in qca_serdev_remove()
2498 if (power->vregs_on) in qca_serdev_remove()
2499 qca_power_shutdown(&qcadev->serdev_hu); in qca_serdev_remove()
2505 hci_uart_unregister_device(&qcadev->serdev_hu); in qca_serdev_remove()
2514 struct hci_uart *hu = &qcadev->serdev_hu; in qca_serdev_shutdown()
2515 struct hci_dev *hdev = hu->hdev; in qca_serdev_shutdown()
2519 if (qcadev->btsoc_type == QCA_QCA6390) { in qca_serdev_shutdown()
2521 * state and the state will ensure next hdev->setup() success. in qca_serdev_shutdown()
2523 * hdev->setup() can do its job regardless of SoC state, so in qca_serdev_shutdown()
2525 * if HCI_SETUP is set, it means that hdev->setup() was never in qca_serdev_shutdown()
2529 if (test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks) || in qca_serdev_shutdown()
2534 * here, so also fix the use-after-free issue caused by that in qca_serdev_shutdown()
2563 struct hci_uart *hu = &qcadev->serdev_hu; in qca_suspend()
2564 struct qca_data *qca = hu->priv; in qca_suspend()
2571 set_bit(QCA_SUSPENDING, &qca->flags); in qca_suspend()
2574 * support in-band sleep in qca_suspend()
2576 if (test_bit(QCA_ROM_FW, &qca->flags)) in qca_suspend()
2583 if (test_bit(QCA_BT_OFF, &qca->flags) && in qca_suspend()
2584 !test_bit(QCA_SSR_TRIGGERED, &qca->flags)) in qca_suspend()
2587 if (test_bit(QCA_IBS_DISABLED, &qca->flags) || in qca_suspend()
2588 test_bit(QCA_SSR_TRIGGERED, &qca->flags)) { in qca_suspend()
2589 wait_timeout = test_bit(QCA_SSR_TRIGGERED, &qca->flags) ? in qca_suspend()
2597 wait_on_bit_timeout(&qca->flags, QCA_IBS_DISABLED, in qca_suspend()
2600 if (test_bit(QCA_IBS_DISABLED, &qca->flags)) { in qca_suspend()
2601 bt_dev_err(hu->hdev, "SSR or FW download time out"); in qca_suspend()
2602 ret = -ETIMEDOUT; in qca_suspend()
2607 cancel_work_sync(&qca->ws_awake_device); in qca_suspend()
2608 cancel_work_sync(&qca->ws_awake_rx); in qca_suspend()
2610 spin_lock_irqsave_nested(&qca->hci_ibs_lock, in qca_suspend()
2613 switch (qca->tx_ibs_state) { in qca_suspend()
2615 del_timer(&qca->wake_retrans_timer); in qca_suspend()
2618 del_timer(&qca->tx_idle_timer); in qca_suspend()
2620 serdev_device_write_flush(hu->serdev); in qca_suspend()
2622 ret = serdev_device_write_buf(hu->serdev, &cmd, sizeof(cmd)); in qca_suspend()
2629 qca->tx_ibs_state = HCI_IBS_TX_ASLEEP; in qca_suspend()
2630 qca->ibs_sent_slps++; in qca_suspend()
2638 BT_ERR("Spurious tx state %d", qca->tx_ibs_state); in qca_suspend()
2639 ret = -EINVAL; in qca_suspend()
2643 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in qca_suspend()
2649 serdev_device_wait_until_sent(hu->serdev, in qca_suspend()
2657 ret = wait_event_interruptible_timeout(qca->suspend_wait_q, in qca_suspend()
2658 qca->rx_ibs_state == HCI_IBS_RX_ASLEEP, in qca_suspend()
2661 ret = -ETIMEDOUT; in qca_suspend()
2668 clear_bit(QCA_SUSPENDING, &qca->flags); in qca_suspend()
2677 struct hci_uart *hu = &qcadev->serdev_hu; in qca_resume()
2678 struct qca_data *qca = hu->priv; in qca_resume()
2680 clear_bit(QCA_SUSPENDING, &qca->flags); in qca_resume()
2689 { .compatible = "qcom,qca2066-bt", .data = &qca_soc_data_qca2066},
2690 { .compatible = "qcom,qca6174-bt" },
2691 { .compatible = "qcom,qca6390-bt", .data = &qca_soc_data_qca6390},
2692 { .compatible = "qcom,qca9377-bt" },
2693 { .compatible = "qcom,wcn3988-bt", .data = &qca_soc_data_wcn3988},
2694 { .compatible = "qcom,wcn3990-bt", .data = &qca_soc_data_wcn3990},
2695 { .compatible = "qcom,wcn3991-bt", .data = &qca_soc_data_wcn3991},
2696 { .compatible = "qcom,wcn3998-bt", .data = &qca_soc_data_wcn3998},
2697 { .compatible = "qcom,wcn6750-bt", .data = &qca_soc_data_wcn6750},
2698 { .compatible = "qcom,wcn6855-bt", .data = &qca_soc_data_wcn6855},
2699 { .compatible = "qcom,wcn7850-bt", .data = &qca_soc_data_wcn7850},
2722 struct hci_uart *hu = &qcadev->serdev_hu; in hciqca_coredump()
2723 struct hci_dev *hdev = hu->hdev; in hciqca_coredump()
2725 if (hdev->dump.coredump) in hciqca_coredump()
2726 hdev->dump.coredump(hdev); in hciqca_coredump()