Lines Matching refs:qca

191 	struct qca_data *qca = hu->priv;  in serial_clock_vote()  local
194 bool old_vote = (qca->tx_vote | qca->rx_vote); in serial_clock_vote()
199 diff = jiffies_to_msecs(jiffies - qca->vote_last_jif); in serial_clock_vote()
202 qca->vote_off_ms += diff; in serial_clock_vote()
204 qca->vote_on_ms += diff; in serial_clock_vote()
208 qca->tx_vote = true; in serial_clock_vote()
209 qca->tx_votes_on++; in serial_clock_vote()
214 qca->rx_vote = true; in serial_clock_vote()
215 qca->rx_votes_on++; in serial_clock_vote()
220 qca->tx_vote = false; in serial_clock_vote()
221 qca->tx_votes_off++; in serial_clock_vote()
222 new_vote = qca->rx_vote | qca->tx_vote; in serial_clock_vote()
226 qca->rx_vote = false; in serial_clock_vote()
227 qca->rx_votes_off++; in serial_clock_vote()
228 new_vote = qca->rx_vote | qca->tx_vote; in serial_clock_vote()
245 diff = jiffies_to_msecs(jiffies - qca->vote_last_jif); in serial_clock_vote()
248 qca->votes_on++; in serial_clock_vote()
249 qca->vote_off_ms += diff; in serial_clock_vote()
251 qca->votes_off++; in serial_clock_vote()
252 qca->vote_on_ms += diff; in serial_clock_vote()
254 qca->vote_last_jif = jiffies; in serial_clock_vote()
265 struct qca_data *qca = hu->priv; in send_hci_ibs_cmd() local
278 skb_queue_tail(&qca->txq, skb); in send_hci_ibs_cmd()
285 struct qca_data *qca = container_of(work, struct qca_data, in qca_wq_awake_device() local
287 struct hci_uart *hu = qca->hu; in qca_wq_awake_device()
295 spin_lock(&qca->hci_ibs_lock); in qca_wq_awake_device()
301 qca->ibs_sent_wakes++; in qca_wq_awake_device()
304 retrans_delay = msecs_to_jiffies(qca->wake_retrans); in qca_wq_awake_device()
305 mod_timer(&qca->wake_retrans_timer, jiffies + retrans_delay); in qca_wq_awake_device()
307 spin_unlock(&qca->hci_ibs_lock); in qca_wq_awake_device()
315 struct qca_data *qca = container_of(work, struct qca_data, in qca_wq_awake_rx() local
317 struct hci_uart *hu = qca->hu; in qca_wq_awake_rx()
323 spin_lock(&qca->hci_ibs_lock); in qca_wq_awake_rx()
324 qca->rx_ibs_state = HCI_IBS_RX_AWAKE; in qca_wq_awake_rx()
332 qca->ibs_sent_wacks++; in qca_wq_awake_rx()
334 spin_unlock(&qca->hci_ibs_lock); in qca_wq_awake_rx()
342 struct qca_data *qca = container_of(work, struct qca_data, in qca_wq_serial_rx_clock_vote_off() local
344 struct hci_uart *hu = qca->hu; in qca_wq_serial_rx_clock_vote_off()
353 struct qca_data *qca = container_of(work, struct qca_data, in qca_wq_serial_tx_clock_vote_off() local
355 struct hci_uart *hu = qca->hu; in qca_wq_serial_tx_clock_vote_off()
370 struct qca_data *qca = from_timer(qca, t, tx_idle_timer); in hci_ibs_tx_idle_timeout() local
371 struct hci_uart *hu = qca->hu; in hci_ibs_tx_idle_timeout()
374 BT_DBG("hu %p idle timeout in %d state", hu, qca->tx_ibs_state); in hci_ibs_tx_idle_timeout()
376 spin_lock_irqsave_nested(&qca->hci_ibs_lock, in hci_ibs_tx_idle_timeout()
379 switch (qca->tx_ibs_state) { in hci_ibs_tx_idle_timeout()
386 qca->tx_ibs_state = HCI_IBS_TX_ASLEEP; in hci_ibs_tx_idle_timeout()
387 qca->ibs_sent_slps++; in hci_ibs_tx_idle_timeout()
388 queue_work(qca->workqueue, &qca->ws_tx_vote_off); in hci_ibs_tx_idle_timeout()
396 BT_ERR("Spurious timeout tx state %d", qca->tx_ibs_state); in hci_ibs_tx_idle_timeout()
400 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in hci_ibs_tx_idle_timeout()
405 struct qca_data *qca = from_timer(qca, t, wake_retrans_timer); in hci_ibs_wake_retrans_timeout() local
406 struct hci_uart *hu = qca->hu; in hci_ibs_wake_retrans_timeout()
411 hu, qca->tx_ibs_state); in hci_ibs_wake_retrans_timeout()
413 spin_lock_irqsave_nested(&qca->hci_ibs_lock, in hci_ibs_wake_retrans_timeout()
416 switch (qca->tx_ibs_state) { in hci_ibs_wake_retrans_timeout()
424 qca->ibs_sent_wakes++; in hci_ibs_wake_retrans_timeout()
425 retrans_delay = msecs_to_jiffies(qca->wake_retrans); in hci_ibs_wake_retrans_timeout()
426 mod_timer(&qca->wake_retrans_timer, jiffies + retrans_delay); in hci_ibs_wake_retrans_timeout()
434 BT_ERR("Spurious timeout tx state %d", qca->tx_ibs_state); in hci_ibs_wake_retrans_timeout()
438 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in hci_ibs_wake_retrans_timeout()
448 struct qca_data *qca; in qca_open() local
453 qca = kzalloc(sizeof(struct qca_data), GFP_KERNEL); in qca_open()
454 if (!qca) in qca_open()
457 skb_queue_head_init(&qca->txq); in qca_open()
458 skb_queue_head_init(&qca->tx_wait_q); in qca_open()
459 spin_lock_init(&qca->hci_ibs_lock); in qca_open()
460 qca->workqueue = alloc_ordered_workqueue("qca_wq", 0); in qca_open()
461 if (!qca->workqueue) { in qca_open()
463 kfree(qca); in qca_open()
467 INIT_WORK(&qca->ws_awake_rx, qca_wq_awake_rx); in qca_open()
468 INIT_WORK(&qca->ws_awake_device, qca_wq_awake_device); in qca_open()
469 INIT_WORK(&qca->ws_rx_vote_off, qca_wq_serial_rx_clock_vote_off); in qca_open()
470 INIT_WORK(&qca->ws_tx_vote_off, qca_wq_serial_tx_clock_vote_off); in qca_open()
472 qca->hu = hu; in qca_open()
475 qca->tx_ibs_state = HCI_IBS_TX_ASLEEP; in qca_open()
476 qca->rx_ibs_state = HCI_IBS_RX_ASLEEP; in qca_open()
479 qca->tx_vote = false; in qca_open()
480 qca->rx_vote = false; in qca_open()
481 qca->flags = 0; in qca_open()
483 qca->ibs_sent_wacks = 0; in qca_open()
484 qca->ibs_sent_slps = 0; in qca_open()
485 qca->ibs_sent_wakes = 0; in qca_open()
486 qca->ibs_recv_wacks = 0; in qca_open()
487 qca->ibs_recv_slps = 0; in qca_open()
488 qca->ibs_recv_wakes = 0; in qca_open()
489 qca->vote_last_jif = jiffies; in qca_open()
490 qca->vote_on_ms = 0; in qca_open()
491 qca->vote_off_ms = 0; in qca_open()
492 qca->votes_on = 0; in qca_open()
493 qca->votes_off = 0; in qca_open()
494 qca->tx_votes_on = 0; in qca_open()
495 qca->tx_votes_off = 0; in qca_open()
496 qca->rx_votes_on = 0; in qca_open()
497 qca->rx_votes_off = 0; in qca_open()
499 hu->priv = qca; in qca_open()
512 destroy_workqueue(qca->workqueue); in qca_open()
513 kfree_skb(qca->rx_skb); in qca_open()
515 kfree(qca); in qca_open()
521 timer_setup(&qca->wake_retrans_timer, hci_ibs_wake_retrans_timeout, 0); in qca_open()
522 qca->wake_retrans = IBS_WAKE_RETRANS_TIMEOUT_MS; in qca_open()
524 timer_setup(&qca->tx_idle_timer, hci_ibs_tx_idle_timeout, 0); in qca_open()
525 qca->tx_idle_delay = IBS_TX_IDLE_TIMEOUT_MS; in qca_open()
528 qca->tx_idle_delay, qca->wake_retrans); in qca_open()
536 struct qca_data *qca = hu->priv; in qca_debugfs_init() local
547 debugfs_create_u8("tx_ibs_state", mode, ibs_dir, &qca->tx_ibs_state); in qca_debugfs_init()
548 debugfs_create_u8("rx_ibs_state", mode, ibs_dir, &qca->rx_ibs_state); in qca_debugfs_init()
550 &qca->ibs_sent_slps); in qca_debugfs_init()
552 &qca->ibs_sent_wakes); in qca_debugfs_init()
554 &qca->ibs_sent_wacks); in qca_debugfs_init()
556 &qca->ibs_recv_slps); in qca_debugfs_init()
558 &qca->ibs_recv_wakes); in qca_debugfs_init()
560 &qca->ibs_recv_wacks); in qca_debugfs_init()
561 debugfs_create_bool("tx_vote", mode, ibs_dir, &qca->tx_vote); in qca_debugfs_init()
562 debugfs_create_u64("tx_votes_on", mode, ibs_dir, &qca->tx_votes_on); in qca_debugfs_init()
563 debugfs_create_u64("tx_votes_off", mode, ibs_dir, &qca->tx_votes_off); in qca_debugfs_init()
564 debugfs_create_bool("rx_vote", mode, ibs_dir, &qca->rx_vote); in qca_debugfs_init()
565 debugfs_create_u64("rx_votes_on", mode, ibs_dir, &qca->rx_votes_on); in qca_debugfs_init()
566 debugfs_create_u64("rx_votes_off", mode, ibs_dir, &qca->rx_votes_off); in qca_debugfs_init()
567 debugfs_create_u64("votes_on", mode, ibs_dir, &qca->votes_on); in qca_debugfs_init()
568 debugfs_create_u64("votes_off", mode, ibs_dir, &qca->votes_off); in qca_debugfs_init()
569 debugfs_create_u32("vote_on_ms", mode, ibs_dir, &qca->vote_on_ms); in qca_debugfs_init()
570 debugfs_create_u32("vote_off_ms", mode, ibs_dir, &qca->vote_off_ms); in qca_debugfs_init()
574 debugfs_create_u32("wake_retrans", mode, ibs_dir, &qca->wake_retrans); in qca_debugfs_init()
576 &qca->tx_idle_delay); in qca_debugfs_init()
582 struct qca_data *qca = hu->priv; in qca_flush() local
586 skb_queue_purge(&qca->tx_wait_q); in qca_flush()
587 skb_queue_purge(&qca->txq); in qca_flush()
596 struct qca_data *qca = hu->priv; in qca_close() local
602 skb_queue_purge(&qca->tx_wait_q); in qca_close()
603 skb_queue_purge(&qca->txq); in qca_close()
604 del_timer(&qca->tx_idle_timer); in qca_close()
605 del_timer(&qca->wake_retrans_timer); in qca_close()
606 destroy_workqueue(qca->workqueue); in qca_close()
607 qca->hu = NULL; in qca_close()
619 kfree_skb(qca->rx_skb); in qca_close()
623 kfree(qca); in qca_close()
633 struct qca_data *qca = hu->priv; in device_want_to_wakeup() local
637 spin_lock_irqsave(&qca->hci_ibs_lock, flags); in device_want_to_wakeup()
639 qca->ibs_recv_wakes++; in device_want_to_wakeup()
641 switch (qca->rx_ibs_state) { in device_want_to_wakeup()
646 queue_work(qca->workqueue, &qca->ws_awake_rx); in device_want_to_wakeup()
647 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in device_want_to_wakeup()
658 qca->ibs_sent_wacks++; in device_want_to_wakeup()
664 qca->rx_ibs_state); in device_want_to_wakeup()
668 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in device_want_to_wakeup()
679 struct qca_data *qca = hu->priv; in device_want_to_sleep() local
683 spin_lock_irqsave(&qca->hci_ibs_lock, flags); in device_want_to_sleep()
685 qca->ibs_recv_slps++; in device_want_to_sleep()
687 switch (qca->rx_ibs_state) { in device_want_to_sleep()
690 qca->rx_ibs_state = HCI_IBS_RX_ASLEEP; in device_want_to_sleep()
692 queue_work(qca->workqueue, &qca->ws_rx_vote_off); in device_want_to_sleep()
701 qca->rx_ibs_state); in device_want_to_sleep()
705 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in device_want_to_sleep()
713 struct qca_data *qca = hu->priv; in device_woke_up() local
718 spin_lock_irqsave(&qca->hci_ibs_lock, flags); in device_woke_up()
720 qca->ibs_recv_wacks++; in device_woke_up()
722 switch (qca->tx_ibs_state) { in device_woke_up()
726 qca->tx_ibs_state); in device_woke_up()
731 while ((skb = skb_dequeue(&qca->tx_wait_q))) in device_woke_up()
732 skb_queue_tail(&qca->txq, skb); in device_woke_up()
735 del_timer(&qca->wake_retrans_timer); in device_woke_up()
736 idle_delay = msecs_to_jiffies(qca->tx_idle_delay); in device_woke_up()
737 mod_timer(&qca->tx_idle_timer, jiffies + idle_delay); in device_woke_up()
738 qca->tx_ibs_state = HCI_IBS_TX_AWAKE; in device_woke_up()
746 qca->tx_ibs_state); in device_woke_up()
750 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in device_woke_up()
762 struct qca_data *qca = hu->priv; in qca_enqueue() local
765 qca->tx_ibs_state); in qca_enqueue()
773 if (!test_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags)) { in qca_enqueue()
774 skb_queue_tail(&qca->txq, skb); in qca_enqueue()
778 spin_lock_irqsave(&qca->hci_ibs_lock, flags); in qca_enqueue()
781 switch (qca->tx_ibs_state) { in qca_enqueue()
784 skb_queue_tail(&qca->txq, skb); in qca_enqueue()
785 idle_delay = msecs_to_jiffies(qca->tx_idle_delay); in qca_enqueue()
786 mod_timer(&qca->tx_idle_timer, jiffies + idle_delay); in qca_enqueue()
792 skb_queue_tail(&qca->tx_wait_q, skb); in qca_enqueue()
794 qca->tx_ibs_state = HCI_IBS_TX_WAKING; in qca_enqueue()
796 queue_work(qca->workqueue, &qca->ws_awake_device); in qca_enqueue()
802 skb_queue_tail(&qca->tx_wait_q, skb); in qca_enqueue()
807 qca->tx_ibs_state); in qca_enqueue()
812 spin_unlock_irqrestore(&qca->hci_ibs_lock, flags); in qca_enqueue()
885 struct qca_data *qca = hu->priv; in qca_recv() local
890 qca->rx_skb = h4_recv_buf(hu->hdev, qca->rx_skb, data, count, in qca_recv()
892 if (IS_ERR(qca->rx_skb)) { in qca_recv()
893 int err = PTR_ERR(qca->rx_skb); in qca_recv()
895 qca->rx_skb = NULL; in qca_recv()
904 struct qca_data *qca = hu->priv; in qca_dequeue() local
906 return skb_dequeue(&qca->txq); in qca_dequeue()
948 struct qca_data *qca = hu->priv; in qca_set_baudrate() local
975 skb_queue_tail(&qca->txq, skb); in qca_set_baudrate()
1003 struct qca_data *qca = hu->priv; in qca_send_power_pulse() local
1027 skb_queue_tail(&qca->txq, skb); in qca_send_power_pulse()
1140 struct qca_data *qca = hu->priv; in qca_setup() local
1153 clear_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags); in qca_setup()
1190 set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags); in qca_setup()
1320 static int qca_init_regulators(struct qca_power *qca, in qca_init_regulators() argument
1325 qca->vreg_bulk = devm_kcalloc(qca->dev, num_vregs, in qca_init_regulators()
1328 if (!qca->vreg_bulk) in qca_init_regulators()
1332 qca->vreg_bulk[i].supply = vregs[i].name; in qca_init_regulators()
1334 return devm_regulator_bulk_get(qca->dev, num_vregs, qca->vreg_bulk); in qca_init_regulators()