Lines Matching refs:bdev
173 struct btmtksdio_dev *bdev = hci_get_drvdata(hdev); in mtk_hci_wmt_sync() local
192 set_bit(BTMTKSDIO_TX_WAIT_VND_EVT, &bdev->tx_state); in mtk_hci_wmt_sync()
196 clear_bit(BTMTKSDIO_TX_WAIT_VND_EVT, &bdev->tx_state); in mtk_hci_wmt_sync()
209 err = wait_on_bit_timeout(&bdev->tx_state, BTMTKSDIO_TX_WAIT_VND_EVT, in mtk_hci_wmt_sync()
213 clear_bit(BTMTKSDIO_TX_WAIT_VND_EVT, &bdev->tx_state); in mtk_hci_wmt_sync()
219 clear_bit(BTMTKSDIO_TX_WAIT_VND_EVT, &bdev->tx_state); in mtk_hci_wmt_sync()
224 wmt_evt = (struct btmtk_hci_wmt_evt *)bdev->evt_skb->data; in mtk_hci_wmt_sync()
254 kfree_skb(bdev->evt_skb); in mtk_hci_wmt_sync()
255 bdev->evt_skb = NULL; in mtk_hci_wmt_sync()
260 static int btmtksdio_tx_packet(struct btmtksdio_dev *bdev, in btmtksdio_tx_packet() argument
282 err = sdio_writesb(bdev->func, MTK_REG_CTDR, skb->data, in btmtksdio_tx_packet()
287 bdev->hdev->stat.byte_tx += skb->len; in btmtksdio_tx_packet()
299 static u32 btmtksdio_drv_own_query(struct btmtksdio_dev *bdev) in btmtksdio_drv_own_query() argument
301 return sdio_readl(bdev->func, MTK_REG_CHLPCR, NULL); in btmtksdio_drv_own_query()
306 struct btmtksdio_dev *bdev = container_of(work, struct btmtksdio_dev, in btmtksdio_tx_work() local
311 pm_runtime_get_sync(bdev->dev); in btmtksdio_tx_work()
313 sdio_claim_host(bdev->func); in btmtksdio_tx_work()
315 while ((skb = skb_dequeue(&bdev->txq))) { in btmtksdio_tx_work()
316 err = btmtksdio_tx_packet(bdev, skb); in btmtksdio_tx_work()
318 bdev->hdev->stat.err_tx++; in btmtksdio_tx_work()
319 skb_queue_head(&bdev->txq, skb); in btmtksdio_tx_work()
324 sdio_release_host(bdev->func); in btmtksdio_tx_work()
326 pm_runtime_mark_last_busy(bdev->dev); in btmtksdio_tx_work()
327 pm_runtime_put_autosuspend(bdev->dev); in btmtksdio_tx_work()
332 struct btmtksdio_dev *bdev = hci_get_drvdata(hdev); in btmtksdio_recv_event() local
346 if (test_bit(BTMTKSDIO_TX_WAIT_VND_EVT, &bdev->tx_state)) { in btmtksdio_recv_event()
347 bdev->evt_skb = skb_clone(skb, GFP_KERNEL); in btmtksdio_recv_event()
348 if (!bdev->evt_skb) { in btmtksdio_recv_event()
360 &bdev->tx_state)) { in btmtksdio_recv_event()
363 wake_up_bit(&bdev->tx_state, BTMTKSDIO_TX_WAIT_VND_EVT); in btmtksdio_recv_event()
370 kfree_skb(bdev->evt_skb); in btmtksdio_recv_event()
371 bdev->evt_skb = NULL; in btmtksdio_recv_event()
383 static int btmtksdio_rx_packet(struct btmtksdio_dev *bdev, u16 rx_size) in btmtksdio_rx_packet() argument
402 err = sdio_readsb(bdev->func, skb->data, MTK_REG_CRDR, rx_size); in btmtksdio_rx_packet()
414 bt_dev_err(bdev->hdev, "Rx size in sdio header is mismatched "); in btmtksdio_rx_packet()
433 bt_dev_err(bdev->hdev, "Invalid bt type 0x%02x", in btmtksdio_rx_packet()
440 bt_dev_err(bdev->hdev, "The size of bt header is mismatched"); in btmtksdio_rx_packet()
460 bt_dev_err(bdev->hdev, "The size of bt payload is mismatched"); in btmtksdio_rx_packet()
468 (&pkts[i])->recv(bdev->hdev, skb); in btmtksdio_rx_packet()
470 bdev->hdev->stat.byte_rx += rx_size; in btmtksdio_rx_packet()
482 struct btmtksdio_dev *bdev = sdio_get_drvdata(func); in btmtksdio_interrupt() local
492 sdio_release_host(bdev->func); in btmtksdio_interrupt()
494 pm_runtime_get_sync(bdev->dev); in btmtksdio_interrupt()
496 sdio_claim_host(bdev->func); in btmtksdio_interrupt()
515 bt_dev_err(bdev->hdev, "CHISR is 0"); in btmtksdio_interrupt()
518 bt_dev_dbg(bdev->hdev, "Get fw own back"); in btmtksdio_interrupt()
521 schedule_work(&bdev->tx_work); in btmtksdio_interrupt()
523 bt_dev_warn(bdev->hdev, "Tx fifo overflow"); in btmtksdio_interrupt()
528 if (btmtksdio_rx_packet(bdev, rx_size) < 0) in btmtksdio_interrupt()
529 bdev->hdev->stat.err_rx++; in btmtksdio_interrupt()
535 pm_runtime_mark_last_busy(bdev->dev); in btmtksdio_interrupt()
536 pm_runtime_put_autosuspend(bdev->dev); in btmtksdio_interrupt()
541 struct btmtksdio_dev *bdev = hci_get_drvdata(hdev); in btmtksdio_open() local
545 sdio_claim_host(bdev->func); in btmtksdio_open()
547 err = sdio_enable_func(bdev->func); in btmtksdio_open()
552 sdio_writel(bdev->func, C_FW_OWN_REQ_CLR, MTK_REG_CHLPCR, &err); in btmtksdio_open()
556 err = readx_poll_timeout(btmtksdio_drv_own_query, bdev, status, in btmtksdio_open()
559 bt_dev_err(bdev->hdev, "Cannot get ownership from device"); in btmtksdio_open()
564 sdio_writel(bdev->func, C_INT_EN_CLR, MTK_REG_CHLPCR, &err); in btmtksdio_open()
568 sdio_writel(bdev->func, 0, MTK_REG_CHIER, &err); in btmtksdio_open()
572 err = sdio_claim_irq(bdev->func, btmtksdio_interrupt); in btmtksdio_open()
576 err = sdio_set_block_size(bdev->func, MTK_SDIO_BLOCK_SIZE); in btmtksdio_open()
583 sdio_writel(bdev->func, SDIO_INT_CTL | SDIO_RE_INIT_EN, in btmtksdio_open()
589 sdio_writel(bdev->func, C_INT_CLR_CTRL, MTK_REG_CHCR, &err); in btmtksdio_open()
594 sdio_writel(bdev->func, RX_DONE_INT | TX_EMPTY | TX_FIFO_OVERFLOW, in btmtksdio_open()
600 sdio_writel(bdev->func, C_INT_EN_SET, MTK_REG_CHLPCR, &err); in btmtksdio_open()
604 sdio_release_host(bdev->func); in btmtksdio_open()
609 sdio_release_irq(bdev->func); in btmtksdio_open()
612 sdio_disable_func(bdev->func); in btmtksdio_open()
615 sdio_release_host(bdev->func); in btmtksdio_open()
622 struct btmtksdio_dev *bdev = hci_get_drvdata(hdev); in btmtksdio_close() local
626 sdio_claim_host(bdev->func); in btmtksdio_close()
629 sdio_writel(bdev->func, C_INT_EN_CLR, MTK_REG_CHLPCR, NULL); in btmtksdio_close()
631 sdio_release_irq(bdev->func); in btmtksdio_close()
634 sdio_writel(bdev->func, C_FW_OWN_REQ_SET, MTK_REG_CHLPCR, NULL); in btmtksdio_close()
636 err = readx_poll_timeout(btmtksdio_drv_own_query, bdev, status, in btmtksdio_close()
639 bt_dev_err(bdev->hdev, "Cannot return ownership to device"); in btmtksdio_close()
641 sdio_disable_func(bdev->func); in btmtksdio_close()
643 sdio_release_host(bdev->func); in btmtksdio_close()
650 struct btmtksdio_dev *bdev = hci_get_drvdata(hdev); in btmtksdio_flush() local
652 skb_queue_purge(&bdev->txq); in btmtksdio_flush()
654 cancel_work_sync(&bdev->tx_work); in btmtksdio_flush()
773 struct btmtksdio_dev *bdev = hci_get_drvdata(hdev); in btmtksdio_setup() local
803 err = mtk_setup_firmware(hdev, bdev->data->fwname); in btmtksdio_setup()
859 pm_runtime_set_autosuspend_delay(bdev->dev, in btmtksdio_setup()
861 pm_runtime_use_autosuspend(bdev->dev); in btmtksdio_setup()
863 err = pm_runtime_set_active(bdev->dev); in btmtksdio_setup()
870 pm_runtime_forbid(bdev->dev); in btmtksdio_setup()
871 pm_runtime_enable(bdev->dev); in btmtksdio_setup()
874 pm_runtime_allow(bdev->dev); in btmtksdio_setup()
883 struct btmtksdio_dev *bdev = hci_get_drvdata(hdev); in btmtksdio_shutdown() local
891 pm_runtime_get_sync(bdev->dev); in btmtksdio_shutdown()
906 pm_runtime_put_noidle(bdev->dev); in btmtksdio_shutdown()
907 pm_runtime_disable(bdev->dev); in btmtksdio_shutdown()
914 struct btmtksdio_dev *bdev = hci_get_drvdata(hdev); in btmtksdio_send_frame() local
933 skb_queue_tail(&bdev->txq, skb); in btmtksdio_send_frame()
935 schedule_work(&bdev->tx_work); in btmtksdio_send_frame()
943 struct btmtksdio_dev *bdev; in btmtksdio_probe() local
947 bdev = devm_kzalloc(&func->dev, sizeof(*bdev), GFP_KERNEL); in btmtksdio_probe()
948 if (!bdev) in btmtksdio_probe()
951 bdev->data = (void *)id->driver_data; in btmtksdio_probe()
952 if (!bdev->data) in btmtksdio_probe()
955 bdev->dev = &func->dev; in btmtksdio_probe()
956 bdev->func = func; in btmtksdio_probe()
958 INIT_WORK(&bdev->tx_work, btmtksdio_tx_work); in btmtksdio_probe()
959 skb_queue_head_init(&bdev->txq); in btmtksdio_probe()
968 bdev->hdev = hdev; in btmtksdio_probe()
971 hci_set_drvdata(hdev, bdev); in btmtksdio_probe()
991 sdio_set_drvdata(func, bdev); in btmtksdio_probe()
998 if (pm_runtime_enabled(bdev->dev)) in btmtksdio_probe()
999 pm_runtime_disable(bdev->dev); in btmtksdio_probe()
1010 pm_runtime_put_noidle(bdev->dev); in btmtksdio_probe()
1017 struct btmtksdio_dev *bdev = sdio_get_drvdata(func); in btmtksdio_remove() local
1020 if (!bdev) in btmtksdio_remove()
1024 pm_runtime_get_noresume(bdev->dev); in btmtksdio_remove()
1026 hdev = bdev->hdev; in btmtksdio_remove()
1037 struct btmtksdio_dev *bdev; in btmtksdio_runtime_suspend() local
1041 bdev = sdio_get_drvdata(func); in btmtksdio_runtime_suspend()
1042 if (!bdev) in btmtksdio_runtime_suspend()
1045 sdio_claim_host(bdev->func); in btmtksdio_runtime_suspend()
1047 sdio_writel(bdev->func, C_FW_OWN_REQ_SET, MTK_REG_CHLPCR, &err); in btmtksdio_runtime_suspend()
1051 err = readx_poll_timeout(btmtksdio_drv_own_query, bdev, status, in btmtksdio_runtime_suspend()
1054 bt_dev_info(bdev->hdev, "status (%d) return ownership to device", err); in btmtksdio_runtime_suspend()
1056 sdio_release_host(bdev->func); in btmtksdio_runtime_suspend()
1064 struct btmtksdio_dev *bdev; in btmtksdio_runtime_resume() local
1068 bdev = sdio_get_drvdata(func); in btmtksdio_runtime_resume()
1069 if (!bdev) in btmtksdio_runtime_resume()
1072 sdio_claim_host(bdev->func); in btmtksdio_runtime_resume()
1074 sdio_writel(bdev->func, C_FW_OWN_REQ_CLR, MTK_REG_CHLPCR, &err); in btmtksdio_runtime_resume()
1078 err = readx_poll_timeout(btmtksdio_drv_own_query, bdev, status, in btmtksdio_runtime_resume()
1081 bt_dev_info(bdev->hdev, "status (%d) get ownership from device", err); in btmtksdio_runtime_resume()
1083 sdio_release_host(bdev->func); in btmtksdio_runtime_resume()