Lines Matching refs:btdev
173 struct nokia_bt_dev *btdev = data; in wakeup_handler() local
174 struct device *dev = &btdev->serdev->dev; in wakeup_handler()
175 int wake_state = gpiod_get_value(btdev->wakeup_host); in wakeup_handler()
177 if (btdev->rx_enabled == wake_state) in wakeup_handler()
185 btdev->rx_enabled = wake_state; in wakeup_handler()
192 struct nokia_bt_dev *btdev = hu->priv; in nokia_reset() local
193 struct device *dev = &btdev->serdev->dev; in nokia_reset()
197 gpiod_set_value_cansleep(btdev->reset, 1); in nokia_reset()
198 gpiod_set_value_cansleep(btdev->wakeup_bt, 1); in nokia_reset()
203 err = gpiod_get_value_cansleep(btdev->wakeup_host); in nokia_reset()
210 serdev_device_write_flush(btdev->serdev); in nokia_reset()
213 nokia_flow_control(btdev->serdev, false); in nokia_reset()
214 serdev_device_set_baudrate(btdev->serdev, INIT_BAUD_RATE); in nokia_reset()
216 gpiod_set_value_cansleep(btdev->reset, 0); in nokia_reset()
219 err = serdev_device_wait_for_cts(btdev->serdev, true, 200); in nokia_reset()
225 nokia_flow_control(btdev->serdev, true); in nokia_reset()
232 struct nokia_bt_dev *btdev = hu->priv; in nokia_send_alive_packet() local
233 struct device *dev = &btdev->serdev->dev; in nokia_send_alive_packet()
239 init_completion(&btdev->init_completion); in nokia_send_alive_packet()
259 if (!wait_for_completion_interruptible_timeout(&btdev->init_completion, in nokia_send_alive_packet()
264 if (btdev->init_error < 0) in nokia_send_alive_packet()
265 return btdev->init_error; in nokia_send_alive_packet()
272 struct nokia_bt_dev *btdev = hu->priv; in nokia_send_negotiation() local
273 struct device *dev = &btdev->serdev->dev; in nokia_send_negotiation()
278 u16 baud = DIV_ROUND_CLOSEST(btdev->sysclk_speed * 10, SETUP_BAUD_RATE); in nokia_send_negotiation()
279 int sysclk = btdev->sysclk_speed / 1000; in nokia_send_negotiation()
299 btdev->init_error = 0; in nokia_send_negotiation()
300 init_completion(&btdev->init_completion); in nokia_send_negotiation()
307 if (!wait_for_completion_interruptible_timeout(&btdev->init_completion, in nokia_send_negotiation()
312 if (btdev->init_error < 0) in nokia_send_negotiation()
313 return btdev->init_error; in nokia_send_negotiation()
319 nokia_flow_control(btdev->serdev, false); in nokia_send_negotiation()
320 serdev_device_set_baudrate(btdev->serdev, SETUP_BAUD_RATE); in nokia_send_negotiation()
321 err = serdev_device_wait_for_cts(btdev->serdev, true, 200); in nokia_send_negotiation()
326 nokia_flow_control(btdev->serdev, true); in nokia_send_negotiation()
335 struct nokia_bt_dev *btdev = hu->priv; in nokia_setup_fw() local
336 struct device *dev = &btdev->serdev->dev; in nokia_setup_fw()
345 if (btdev->man_id == NOKIA_ID_BCM2048) { in nokia_setup_fw()
347 } else if (btdev->man_id == NOKIA_ID_TI1271) { in nokia_setup_fw()
404 struct nokia_bt_dev *btdev = hu->priv; in nokia_setup() local
405 struct device *dev = &btdev->serdev->dev; in nokia_setup()
408 btdev->initialized = false; in nokia_setup()
410 nokia_flow_control(btdev->serdev, false); in nokia_setup()
414 if (btdev->tx_enabled) { in nokia_setup()
415 gpiod_set_value_cansleep(btdev->wakeup_bt, 0); in nokia_setup()
416 pm_runtime_put(&btdev->serdev->dev); in nokia_setup()
417 btdev->tx_enabled = false; in nokia_setup()
450 nokia_flow_control(btdev->serdev, false); in nokia_setup()
451 serdev_device_set_baudrate(btdev->serdev, MAX_BAUD_RATE); in nokia_setup()
452 nokia_flow_control(btdev->serdev, true); in nokia_setup()
454 if (btdev->man_id == NOKIA_ID_BCM2048) { in nokia_setup()
462 gpiod_set_value_cansleep(btdev->wakeup_bt, 0); in nokia_setup()
464 btdev->tx_enabled = false; in nokia_setup()
465 btdev->initialized = true; in nokia_setup()
487 struct nokia_bt_dev *btdev = hu->priv; in nokia_flush() local
489 dev_dbg(&btdev->serdev->dev, "flush device"); in nokia_flush()
491 skb_queue_purge(&btdev->txq); in nokia_flush()
498 struct nokia_bt_dev *btdev = hu->priv; in nokia_close() local
499 struct device *dev = &btdev->serdev->dev; in nokia_close()
503 btdev->initialized = false; in nokia_close()
505 skb_queue_purge(&btdev->txq); in nokia_close()
507 kfree_skb(btdev->rx_skb); in nokia_close()
510 gpiod_set_value(btdev->reset, 1); in nokia_close()
511 gpiod_set_value(btdev->wakeup_bt, 0); in nokia_close()
513 pm_runtime_disable(&btdev->serdev->dev); in nokia_close()
521 struct nokia_bt_dev *btdev = hu->priv; in nokia_enqueue() local
535 skb_queue_tail(&btdev->txq, skb); in nokia_enqueue()
544 struct nokia_bt_dev *btdev = hu->priv; in nokia_recv_negotiation_packet() local
545 struct device *dev = &btdev->serdev->dev; in nokia_recv_negotiation_packet()
552 btdev->init_error = -EIO; in nokia_recv_negotiation_packet()
561 btdev->init_error = -EINVAL; in nokia_recv_negotiation_packet()
566 btdev->man_id = evt->man_id; in nokia_recv_negotiation_packet()
567 btdev->ver_id = evt->ver_id; in nokia_recv_negotiation_packet()
573 complete(&btdev->init_completion); in nokia_recv_negotiation_packet()
581 struct nokia_bt_dev *btdev = hu->priv; in nokia_recv_alive_packet() local
582 struct device *dev = &btdev->serdev->dev; in nokia_recv_alive_packet()
590 btdev->init_error = -EIO; in nokia_recv_alive_packet()
600 btdev->init_error = -EINVAL; in nokia_recv_alive_packet()
608 complete(&btdev->init_completion); in nokia_recv_alive_packet()
634 struct nokia_bt_dev *btdev = hu->priv; in nokia_recv() local
635 struct device *dev = &btdev->serdev->dev; in nokia_recv()
641 btdev->rx_skb = h4_recv_buf(hu->hdev, btdev->rx_skb, data, count, in nokia_recv()
643 if (IS_ERR(btdev->rx_skb)) { in nokia_recv()
644 err = PTR_ERR(btdev->rx_skb); in nokia_recv()
646 btdev->rx_skb = NULL; in nokia_recv()
655 struct nokia_bt_dev *btdev = hu->priv; in nokia_dequeue() local
656 struct device *dev = &btdev->serdev->dev; in nokia_dequeue()
657 struct sk_buff *result = skb_dequeue(&btdev->txq); in nokia_dequeue()
659 if (!btdev->initialized) in nokia_dequeue()
662 if (btdev->tx_enabled == !!result) in nokia_dequeue()
667 gpiod_set_value_cansleep(btdev->wakeup_bt, 1); in nokia_dequeue()
669 serdev_device_wait_until_sent(btdev->serdev, 0); in nokia_dequeue()
670 gpiod_set_value_cansleep(btdev->wakeup_bt, 0); in nokia_dequeue()
674 btdev->tx_enabled = !!result; in nokia_dequeue()
695 struct nokia_bt_dev *btdev; in nokia_bluetooth_serdev_probe() local
699 btdev = devm_kzalloc(dev, sizeof(*btdev), GFP_KERNEL); in nokia_bluetooth_serdev_probe()
700 if (!btdev) in nokia_bluetooth_serdev_probe()
703 btdev->hu.serdev = btdev->serdev = serdev; in nokia_bluetooth_serdev_probe()
704 serdev_device_set_drvdata(serdev, btdev); in nokia_bluetooth_serdev_probe()
706 btdev->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); in nokia_bluetooth_serdev_probe()
707 if (IS_ERR(btdev->reset)) { in nokia_bluetooth_serdev_probe()
708 err = PTR_ERR(btdev->reset); in nokia_bluetooth_serdev_probe()
713 btdev->wakeup_host = devm_gpiod_get(dev, "host-wakeup", GPIOD_IN); in nokia_bluetooth_serdev_probe()
714 if (IS_ERR(btdev->wakeup_host)) { in nokia_bluetooth_serdev_probe()
715 err = PTR_ERR(btdev->wakeup_host); in nokia_bluetooth_serdev_probe()
720 btdev->wake_irq = gpiod_to_irq(btdev->wakeup_host); in nokia_bluetooth_serdev_probe()
722 err = devm_request_threaded_irq(dev, btdev->wake_irq, NULL, in nokia_bluetooth_serdev_probe()
725 "wakeup", btdev); in nokia_bluetooth_serdev_probe()
731 btdev->wakeup_bt = devm_gpiod_get(dev, "bluetooth-wakeup", in nokia_bluetooth_serdev_probe()
733 if (IS_ERR(btdev->wakeup_bt)) { in nokia_bluetooth_serdev_probe()
734 err = PTR_ERR(btdev->wakeup_bt); in nokia_bluetooth_serdev_probe()
747 btdev->sysclk_speed = clk_get_rate(sysclk); in nokia_bluetooth_serdev_probe()
750 skb_queue_head_init(&btdev->txq); in nokia_bluetooth_serdev_probe()
752 btdev->hu.priv = btdev; in nokia_bluetooth_serdev_probe()
753 btdev->hu.alignment = 2; /* Nokia H4+ is word aligned */ in nokia_bluetooth_serdev_probe()
755 err = hci_uart_register_device(&btdev->hu, &nokia_proto); in nokia_bluetooth_serdev_probe()
766 struct nokia_bt_dev *btdev = serdev_device_get_drvdata(serdev); in nokia_bluetooth_serdev_remove() local
768 hci_uart_unregister_device(&btdev->hu); in nokia_bluetooth_serdev_remove()