Lines Matching refs:btdev

164 	struct nokia_bt_dev *btdev = data;  in wakeup_handler()  local
165 struct device *dev = &btdev->serdev->dev; in wakeup_handler()
166 int wake_state = gpiod_get_value(btdev->wakeup_host); in wakeup_handler()
168 if (btdev->rx_enabled == wake_state) in wakeup_handler()
176 btdev->rx_enabled = wake_state; in wakeup_handler()
183 struct nokia_bt_dev *btdev = hu->priv; in nokia_reset() local
184 struct device *dev = &btdev->serdev->dev; in nokia_reset()
188 gpiod_set_value_cansleep(btdev->reset, 1); in nokia_reset()
189 gpiod_set_value_cansleep(btdev->wakeup_bt, 1); in nokia_reset()
194 err = gpiod_get_value_cansleep(btdev->wakeup_host); in nokia_reset()
201 serdev_device_write_flush(btdev->serdev); in nokia_reset()
204 nokia_flow_control(btdev->serdev, false); in nokia_reset()
205 serdev_device_set_baudrate(btdev->serdev, INIT_BAUD_RATE); in nokia_reset()
207 gpiod_set_value_cansleep(btdev->reset, 0); in nokia_reset()
210 err = serdev_device_wait_for_cts(btdev->serdev, true, 200); in nokia_reset()
216 nokia_flow_control(btdev->serdev, true); in nokia_reset()
223 struct nokia_bt_dev *btdev = hu->priv; in nokia_send_alive_packet() local
224 struct device *dev = &btdev->serdev->dev; in nokia_send_alive_packet()
230 init_completion(&btdev->init_completion); in nokia_send_alive_packet()
250 if (!wait_for_completion_interruptible_timeout(&btdev->init_completion, in nokia_send_alive_packet()
255 if (btdev->init_error < 0) in nokia_send_alive_packet()
256 return btdev->init_error; in nokia_send_alive_packet()
263 struct nokia_bt_dev *btdev = hu->priv; in nokia_send_negotiation() local
264 struct device *dev = &btdev->serdev->dev; in nokia_send_negotiation()
269 u16 baud = DIV_ROUND_CLOSEST(btdev->sysclk_speed * 10, SETUP_BAUD_RATE); in nokia_send_negotiation()
270 int sysclk = btdev->sysclk_speed / 1000; in nokia_send_negotiation()
290 btdev->init_error = 0; in nokia_send_negotiation()
291 init_completion(&btdev->init_completion); in nokia_send_negotiation()
298 if (!wait_for_completion_interruptible_timeout(&btdev->init_completion, in nokia_send_negotiation()
303 if (btdev->init_error < 0) in nokia_send_negotiation()
304 return btdev->init_error; in nokia_send_negotiation()
310 nokia_flow_control(btdev->serdev, false); in nokia_send_negotiation()
311 serdev_device_set_baudrate(btdev->serdev, SETUP_BAUD_RATE); in nokia_send_negotiation()
312 err = serdev_device_wait_for_cts(btdev->serdev, true, 200); in nokia_send_negotiation()
317 nokia_flow_control(btdev->serdev, true); in nokia_send_negotiation()
326 struct nokia_bt_dev *btdev = hu->priv; in nokia_setup_fw() local
327 struct device *dev = &btdev->serdev->dev; in nokia_setup_fw()
336 if (btdev->man_id == NOKIA_ID_BCM2048) { in nokia_setup_fw()
338 } else if (btdev->man_id == NOKIA_ID_TI1271) { in nokia_setup_fw()
395 struct nokia_bt_dev *btdev = hu->priv; in nokia_setup() local
396 struct device *dev = &btdev->serdev->dev; in nokia_setup()
399 btdev->initialized = false; in nokia_setup()
401 nokia_flow_control(btdev->serdev, false); in nokia_setup()
405 if (btdev->tx_enabled) { in nokia_setup()
406 gpiod_set_value_cansleep(btdev->wakeup_bt, 0); in nokia_setup()
407 pm_runtime_put(&btdev->serdev->dev); in nokia_setup()
408 btdev->tx_enabled = false; in nokia_setup()
441 nokia_flow_control(btdev->serdev, false); in nokia_setup()
442 serdev_device_set_baudrate(btdev->serdev, MAX_BAUD_RATE); in nokia_setup()
443 nokia_flow_control(btdev->serdev, true); in nokia_setup()
445 if (btdev->man_id == NOKIA_ID_BCM2048) { in nokia_setup()
453 gpiod_set_value_cansleep(btdev->wakeup_bt, 0); in nokia_setup()
455 btdev->tx_enabled = false; in nokia_setup()
456 btdev->initialized = true; in nokia_setup()
478 struct nokia_bt_dev *btdev = hu->priv; in nokia_flush() local
480 dev_dbg(&btdev->serdev->dev, "flush device"); in nokia_flush()
482 skb_queue_purge(&btdev->txq); in nokia_flush()
489 struct nokia_bt_dev *btdev = hu->priv; in nokia_close() local
490 struct device *dev = &btdev->serdev->dev; in nokia_close()
494 btdev->initialized = false; in nokia_close()
496 skb_queue_purge(&btdev->txq); in nokia_close()
498 kfree_skb(btdev->rx_skb); in nokia_close()
501 gpiod_set_value(btdev->reset, 1); in nokia_close()
502 gpiod_set_value(btdev->wakeup_bt, 0); in nokia_close()
504 pm_runtime_disable(&btdev->serdev->dev); in nokia_close()
512 struct nokia_bt_dev *btdev = hu->priv; in nokia_enqueue() local
526 skb_queue_tail(&btdev->txq, skb); in nokia_enqueue()
535 struct nokia_bt_dev *btdev = hu->priv; in nokia_recv_negotiation_packet() local
536 struct device *dev = &btdev->serdev->dev; in nokia_recv_negotiation_packet()
543 btdev->init_error = -EIO; in nokia_recv_negotiation_packet()
552 btdev->init_error = -EINVAL; in nokia_recv_negotiation_packet()
557 btdev->man_id = evt->man_id; in nokia_recv_negotiation_packet()
558 btdev->ver_id = evt->ver_id; in nokia_recv_negotiation_packet()
564 complete(&btdev->init_completion); in nokia_recv_negotiation_packet()
572 struct nokia_bt_dev *btdev = hu->priv; in nokia_recv_alive_packet() local
573 struct device *dev = &btdev->serdev->dev; in nokia_recv_alive_packet()
581 btdev->init_error = -EIO; in nokia_recv_alive_packet()
591 btdev->init_error = -EINVAL; in nokia_recv_alive_packet()
599 complete(&btdev->init_completion); in nokia_recv_alive_packet()
625 struct nokia_bt_dev *btdev = hu->priv; in nokia_recv() local
626 struct device *dev = &btdev->serdev->dev; in nokia_recv()
632 btdev->rx_skb = h4_recv_buf(hu->hdev, btdev->rx_skb, data, count, in nokia_recv()
634 if (IS_ERR(btdev->rx_skb)) { in nokia_recv()
635 err = PTR_ERR(btdev->rx_skb); in nokia_recv()
637 btdev->rx_skb = NULL; in nokia_recv()
646 struct nokia_bt_dev *btdev = hu->priv; in nokia_dequeue() local
647 struct device *dev = &btdev->serdev->dev; in nokia_dequeue()
648 struct sk_buff *result = skb_dequeue(&btdev->txq); in nokia_dequeue()
650 if (!btdev->initialized) in nokia_dequeue()
653 if (btdev->tx_enabled == !!result) in nokia_dequeue()
658 gpiod_set_value_cansleep(btdev->wakeup_bt, 1); in nokia_dequeue()
660 serdev_device_wait_until_sent(btdev->serdev, 0); in nokia_dequeue()
661 gpiod_set_value_cansleep(btdev->wakeup_bt, 0); in nokia_dequeue()
665 btdev->tx_enabled = !!result; in nokia_dequeue()
686 struct nokia_bt_dev *btdev; in nokia_bluetooth_serdev_probe() local
690 btdev = devm_kzalloc(dev, sizeof(*btdev), GFP_KERNEL); in nokia_bluetooth_serdev_probe()
691 if (!btdev) in nokia_bluetooth_serdev_probe()
694 btdev->hu.serdev = btdev->serdev = serdev; in nokia_bluetooth_serdev_probe()
695 serdev_device_set_drvdata(serdev, btdev); in nokia_bluetooth_serdev_probe()
697 btdev->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); in nokia_bluetooth_serdev_probe()
698 if (IS_ERR(btdev->reset)) { in nokia_bluetooth_serdev_probe()
699 err = PTR_ERR(btdev->reset); in nokia_bluetooth_serdev_probe()
704 btdev->wakeup_host = devm_gpiod_get(dev, "host-wakeup", GPIOD_IN); in nokia_bluetooth_serdev_probe()
705 if (IS_ERR(btdev->wakeup_host)) { in nokia_bluetooth_serdev_probe()
706 err = PTR_ERR(btdev->wakeup_host); in nokia_bluetooth_serdev_probe()
711 btdev->wake_irq = gpiod_to_irq(btdev->wakeup_host); in nokia_bluetooth_serdev_probe()
713 err = devm_request_threaded_irq(dev, btdev->wake_irq, NULL, in nokia_bluetooth_serdev_probe()
716 "wakeup", btdev); in nokia_bluetooth_serdev_probe()
722 btdev->wakeup_bt = devm_gpiod_get(dev, "bluetooth-wakeup", in nokia_bluetooth_serdev_probe()
724 if (IS_ERR(btdev->wakeup_bt)) { in nokia_bluetooth_serdev_probe()
725 err = PTR_ERR(btdev->wakeup_bt); in nokia_bluetooth_serdev_probe()
742 btdev->sysclk_speed = clk_get_rate(sysclk); in nokia_bluetooth_serdev_probe()
745 skb_queue_head_init(&btdev->txq); in nokia_bluetooth_serdev_probe()
747 btdev->hu.priv = btdev; in nokia_bluetooth_serdev_probe()
748 btdev->hu.alignment = 2; /* Nokia H4+ is word aligned */ in nokia_bluetooth_serdev_probe()
750 err = hci_uart_register_device(&btdev->hu, &nokia_proto); in nokia_bluetooth_serdev_probe()
761 struct nokia_bt_dev *btdev = serdev_device_get_drvdata(serdev); in nokia_bluetooth_serdev_remove() local
763 hci_uart_unregister_device(&btdev->hu); in nokia_bluetooth_serdev_remove()