Lines Matching refs:btdev
159 struct nokia_bt_dev *btdev = data; in wakeup_handler() local
160 struct device *dev = &btdev->serdev->dev; in wakeup_handler()
161 int wake_state = gpiod_get_value(btdev->wakeup_host); in wakeup_handler()
163 if (btdev->rx_enabled == wake_state) in wakeup_handler()
171 btdev->rx_enabled = wake_state; in wakeup_handler()
178 struct nokia_bt_dev *btdev = hu->priv; in nokia_reset() local
179 struct device *dev = &btdev->serdev->dev; in nokia_reset()
183 gpiod_set_value_cansleep(btdev->reset, 1); in nokia_reset()
184 gpiod_set_value_cansleep(btdev->wakeup_bt, 1); in nokia_reset()
189 err = gpiod_get_value_cansleep(btdev->wakeup_host); in nokia_reset()
196 serdev_device_write_flush(btdev->serdev); in nokia_reset()
199 nokia_flow_control(btdev->serdev, false); in nokia_reset()
200 serdev_device_set_baudrate(btdev->serdev, INIT_BAUD_RATE); in nokia_reset()
202 gpiod_set_value_cansleep(btdev->reset, 0); in nokia_reset()
205 err = serdev_device_wait_for_cts(btdev->serdev, true, 200); in nokia_reset()
211 nokia_flow_control(btdev->serdev, true); in nokia_reset()
218 struct nokia_bt_dev *btdev = hu->priv; in nokia_send_alive_packet() local
219 struct device *dev = &btdev->serdev->dev; in nokia_send_alive_packet()
225 init_completion(&btdev->init_completion); in nokia_send_alive_packet()
245 if (!wait_for_completion_interruptible_timeout(&btdev->init_completion, in nokia_send_alive_packet()
250 if (btdev->init_error < 0) in nokia_send_alive_packet()
251 return btdev->init_error; in nokia_send_alive_packet()
258 struct nokia_bt_dev *btdev = hu->priv; in nokia_send_negotiation() local
259 struct device *dev = &btdev->serdev->dev; in nokia_send_negotiation()
264 u16 baud = DIV_ROUND_CLOSEST(btdev->sysclk_speed * 10, SETUP_BAUD_RATE); in nokia_send_negotiation()
265 int sysclk = btdev->sysclk_speed / 1000; in nokia_send_negotiation()
285 btdev->init_error = 0; in nokia_send_negotiation()
286 init_completion(&btdev->init_completion); in nokia_send_negotiation()
293 if (!wait_for_completion_interruptible_timeout(&btdev->init_completion, in nokia_send_negotiation()
298 if (btdev->init_error < 0) in nokia_send_negotiation()
299 return btdev->init_error; in nokia_send_negotiation()
305 nokia_flow_control(btdev->serdev, false); in nokia_send_negotiation()
306 serdev_device_set_baudrate(btdev->serdev, SETUP_BAUD_RATE); in nokia_send_negotiation()
307 err = serdev_device_wait_for_cts(btdev->serdev, true, 200); in nokia_send_negotiation()
312 nokia_flow_control(btdev->serdev, true); in nokia_send_negotiation()
321 struct nokia_bt_dev *btdev = hu->priv; in nokia_setup_fw() local
322 struct device *dev = &btdev->serdev->dev; in nokia_setup_fw()
331 if (btdev->man_id == NOKIA_ID_BCM2048) { in nokia_setup_fw()
333 } else if (btdev->man_id == NOKIA_ID_TI1271) { in nokia_setup_fw()
390 struct nokia_bt_dev *btdev = hu->priv; in nokia_setup() local
391 struct device *dev = &btdev->serdev->dev; in nokia_setup()
394 btdev->initialized = false; in nokia_setup()
396 nokia_flow_control(btdev->serdev, false); in nokia_setup()
400 if (btdev->tx_enabled) { in nokia_setup()
401 gpiod_set_value_cansleep(btdev->wakeup_bt, 0); in nokia_setup()
402 pm_runtime_put(&btdev->serdev->dev); in nokia_setup()
403 btdev->tx_enabled = false; in nokia_setup()
436 nokia_flow_control(btdev->serdev, false); in nokia_setup()
437 serdev_device_set_baudrate(btdev->serdev, MAX_BAUD_RATE); in nokia_setup()
438 nokia_flow_control(btdev->serdev, true); in nokia_setup()
440 if (btdev->man_id == NOKIA_ID_BCM2048) { in nokia_setup()
448 gpiod_set_value_cansleep(btdev->wakeup_bt, 0); in nokia_setup()
450 btdev->tx_enabled = false; in nokia_setup()
451 btdev->initialized = true; in nokia_setup()
473 struct nokia_bt_dev *btdev = hu->priv; in nokia_flush() local
475 dev_dbg(&btdev->serdev->dev, "flush device"); in nokia_flush()
477 skb_queue_purge(&btdev->txq); in nokia_flush()
484 struct nokia_bt_dev *btdev = hu->priv; in nokia_close() local
485 struct device *dev = &btdev->serdev->dev; in nokia_close()
489 btdev->initialized = false; in nokia_close()
491 skb_queue_purge(&btdev->txq); in nokia_close()
493 kfree_skb(btdev->rx_skb); in nokia_close()
496 gpiod_set_value(btdev->reset, 1); in nokia_close()
497 gpiod_set_value(btdev->wakeup_bt, 0); in nokia_close()
499 pm_runtime_disable(&btdev->serdev->dev); in nokia_close()
507 struct nokia_bt_dev *btdev = hu->priv; in nokia_enqueue() local
521 skb_queue_tail(&btdev->txq, skb); in nokia_enqueue()
530 struct nokia_bt_dev *btdev = hu->priv; in nokia_recv_negotiation_packet() local
531 struct device *dev = &btdev->serdev->dev; in nokia_recv_negotiation_packet()
538 btdev->init_error = -EIO; in nokia_recv_negotiation_packet()
547 btdev->init_error = -EINVAL; in nokia_recv_negotiation_packet()
552 btdev->man_id = evt->man_id; in nokia_recv_negotiation_packet()
553 btdev->ver_id = evt->ver_id; in nokia_recv_negotiation_packet()
559 complete(&btdev->init_completion); in nokia_recv_negotiation_packet()
567 struct nokia_bt_dev *btdev = hu->priv; in nokia_recv_alive_packet() local
568 struct device *dev = &btdev->serdev->dev; in nokia_recv_alive_packet()
576 btdev->init_error = -EIO; in nokia_recv_alive_packet()
586 btdev->init_error = -EINVAL; in nokia_recv_alive_packet()
594 complete(&btdev->init_completion); in nokia_recv_alive_packet()
620 struct nokia_bt_dev *btdev = hu->priv; in nokia_recv() local
621 struct device *dev = &btdev->serdev->dev; in nokia_recv()
627 btdev->rx_skb = h4_recv_buf(hu->hdev, btdev->rx_skb, data, count, in nokia_recv()
629 if (IS_ERR(btdev->rx_skb)) { in nokia_recv()
630 err = PTR_ERR(btdev->rx_skb); in nokia_recv()
632 btdev->rx_skb = NULL; in nokia_recv()
641 struct nokia_bt_dev *btdev = hu->priv; in nokia_dequeue() local
642 struct device *dev = &btdev->serdev->dev; in nokia_dequeue()
643 struct sk_buff *result = skb_dequeue(&btdev->txq); in nokia_dequeue()
645 if (!btdev->initialized) in nokia_dequeue()
648 if (btdev->tx_enabled == !!result) in nokia_dequeue()
653 gpiod_set_value_cansleep(btdev->wakeup_bt, 1); in nokia_dequeue()
655 serdev_device_wait_until_sent(btdev->serdev, 0); in nokia_dequeue()
656 gpiod_set_value_cansleep(btdev->wakeup_bt, 0); in nokia_dequeue()
660 btdev->tx_enabled = !!result; in nokia_dequeue()
681 struct nokia_bt_dev *btdev; in nokia_bluetooth_serdev_probe() local
685 btdev = devm_kzalloc(dev, sizeof(*btdev), GFP_KERNEL); in nokia_bluetooth_serdev_probe()
686 if (!btdev) in nokia_bluetooth_serdev_probe()
689 btdev->hu.serdev = btdev->serdev = serdev; in nokia_bluetooth_serdev_probe()
690 serdev_device_set_drvdata(serdev, btdev); in nokia_bluetooth_serdev_probe()
692 btdev->reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH); in nokia_bluetooth_serdev_probe()
693 if (IS_ERR(btdev->reset)) { in nokia_bluetooth_serdev_probe()
694 err = PTR_ERR(btdev->reset); in nokia_bluetooth_serdev_probe()
699 btdev->wakeup_host = devm_gpiod_get(dev, "host-wakeup", GPIOD_IN); in nokia_bluetooth_serdev_probe()
700 if (IS_ERR(btdev->wakeup_host)) { in nokia_bluetooth_serdev_probe()
701 err = PTR_ERR(btdev->wakeup_host); in nokia_bluetooth_serdev_probe()
706 btdev->wake_irq = gpiod_to_irq(btdev->wakeup_host); in nokia_bluetooth_serdev_probe()
708 err = devm_request_threaded_irq(dev, btdev->wake_irq, NULL, in nokia_bluetooth_serdev_probe()
711 "wakeup", btdev); in nokia_bluetooth_serdev_probe()
717 btdev->wakeup_bt = devm_gpiod_get(dev, "bluetooth-wakeup", in nokia_bluetooth_serdev_probe()
719 if (IS_ERR(btdev->wakeup_bt)) { in nokia_bluetooth_serdev_probe()
720 err = PTR_ERR(btdev->wakeup_bt); in nokia_bluetooth_serdev_probe()
737 btdev->sysclk_speed = clk_get_rate(sysclk); in nokia_bluetooth_serdev_probe()
740 skb_queue_head_init(&btdev->txq); in nokia_bluetooth_serdev_probe()
742 btdev->hu.priv = btdev; in nokia_bluetooth_serdev_probe()
743 btdev->hu.alignment = 2; /* Nokia H4+ is word aligned */ in nokia_bluetooth_serdev_probe()
745 err = hci_uart_register_device(&btdev->hu, &nokia_proto); in nokia_bluetooth_serdev_probe()
756 struct nokia_bt_dev *btdev = serdev_device_get_drvdata(serdev); in nokia_bluetooth_serdev_remove() local
758 hci_uart_unregister_device(&btdev->hu); in nokia_bluetooth_serdev_remove()