Lines Matching refs:adapter

192 static int mwifiex_pcie_delete_rxbd_ring(struct mwifiex_adapter *adapter);
193 static int mwifiex_pcie_delete_evtbd_ring(struct mwifiex_adapter *adapter);
196 mwifiex_map_pci_memory(struct mwifiex_adapter *adapter, struct sk_buff *skb, in mwifiex_map_pci_memory() argument
199 struct pcie_service_card *card = adapter->card; in mwifiex_map_pci_memory()
204 mwifiex_dbg(adapter, ERROR, "failed to map pci memory!\n"); in mwifiex_map_pci_memory()
212 static void mwifiex_unmap_pci_memory(struct mwifiex_adapter *adapter, in mwifiex_unmap_pci_memory() argument
215 struct pcie_service_card *card = adapter->card; in mwifiex_unmap_pci_memory()
225 static int mwifiex_write_reg(struct mwifiex_adapter *adapter, int reg, u32 data) in mwifiex_write_reg() argument
227 struct pcie_service_card *card = adapter->card; in mwifiex_write_reg()
236 static int mwifiex_read_reg(struct mwifiex_adapter *adapter, int reg, u32 *data) in mwifiex_read_reg() argument
238 struct pcie_service_card *card = adapter->card; in mwifiex_read_reg()
248 static int mwifiex_read_reg_byte(struct mwifiex_adapter *adapter, in mwifiex_read_reg_byte() argument
251 struct pcie_service_card *card = adapter->card; in mwifiex_read_reg_byte()
261 static bool mwifiex_pcie_ok_to_access_hw(struct mwifiex_adapter *adapter) in mwifiex_pcie_ok_to_access_hw() argument
264 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_ok_to_access_hw()
272 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_ok_to_access_hw()
293 struct mwifiex_adapter *adapter; in mwifiex_pcie_suspend() local
300 adapter = card->adapter; in mwifiex_pcie_suspend()
301 if (!adapter) { in mwifiex_pcie_suspend()
306 mwifiex_enable_wake(adapter); in mwifiex_pcie_suspend()
309 if (!mwifiex_enable_hs(adapter)) { in mwifiex_pcie_suspend()
310 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_suspend()
312 clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags); in mwifiex_pcie_suspend()
313 mwifiex_disable_wake(adapter); in mwifiex_pcie_suspend()
317 flush_workqueue(adapter->workqueue); in mwifiex_pcie_suspend()
320 set_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_pcie_suspend()
321 clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags); in mwifiex_pcie_suspend()
336 struct mwifiex_adapter *adapter; in mwifiex_pcie_resume() local
340 if (!card->adapter) { in mwifiex_pcie_resume()
345 adapter = card->adapter; in mwifiex_pcie_resume()
347 if (!test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)) { in mwifiex_pcie_resume()
348 mwifiex_dbg(adapter, WARN, in mwifiex_pcie_resume()
353 clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_pcie_resume()
355 mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA), in mwifiex_pcie_resume()
357 mwifiex_disable_wake(adapter); in mwifiex_pcie_resume()
423 struct mwifiex_adapter *adapter; in mwifiex_pcie_remove() local
432 adapter = card->adapter; in mwifiex_pcie_remove()
433 if (!adapter || !adapter->priv_num) in mwifiex_pcie_remove()
438 mwifiex_read_reg(adapter, reg->fw_status, &fw_status); in mwifiex_pcie_remove()
442 if (fw_status == FIRMWARE_READY_PCIE && !adapter->mfg_mode) { in mwifiex_pcie_remove()
443 mwifiex_deauthenticate_all(adapter); in mwifiex_pcie_remove()
445 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); in mwifiex_pcie_remove()
452 mwifiex_remove_card(adapter); in mwifiex_pcie_remove()
507 struct mwifiex_adapter *adapter = card->adapter; in mwifiex_pcie_reset_prepare() local
509 if (!adapter) { in mwifiex_pcie_reset_prepare()
515 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_reset_prepare()
519 mwifiex_shutdown_sw(adapter); in mwifiex_pcie_reset_prepare()
529 mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__); in mwifiex_pcie_reset_prepare()
542 struct mwifiex_adapter *adapter = card->adapter; in mwifiex_pcie_reset_done() local
545 if (!adapter) { in mwifiex_pcie_reset_done()
551 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_reset_done()
555 ret = mwifiex_reinit_sw(adapter); in mwifiex_pcie_reset_done()
559 mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__); in mwifiex_pcie_reset_done()
594 static void mwifiex_pcie_dev_wakeup_delay(struct mwifiex_adapter *adapter) in mwifiex_pcie_dev_wakeup_delay() argument
598 while (mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_pcie_dev_wakeup_delay()
609 static void mwifiex_delay_for_sleep_cookie(struct mwifiex_adapter *adapter, in mwifiex_delay_for_sleep_cookie() argument
612 struct pcie_service_card *card = adapter->card; in mwifiex_delay_for_sleep_cookie()
625 mwifiex_dbg(adapter, INFO, in mwifiex_delay_for_sleep_cookie()
637 mwifiex_dbg(adapter, INFO, in mwifiex_delay_for_sleep_cookie()
645 static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter) in mwifiex_pm_wakeup_card() argument
647 struct pcie_service_card *card = adapter->card; in mwifiex_pm_wakeup_card()
651 mwifiex_dbg(adapter, EVENT, in mwifiex_pm_wakeup_card()
655 mwifiex_pcie_dev_wakeup_delay(adapter); in mwifiex_pm_wakeup_card()
662 READ_ONCE(adapter->int_status) != 0, in mwifiex_pm_wakeup_card()
665 adapter, reg->fw_status, FIRMWARE_READY_PCIE)) { in mwifiex_pm_wakeup_card()
667 READ_ONCE(adapter->int_status) != 0, in mwifiex_pm_wakeup_card()
670 adapter, reg->fw_status, FIRMWARE_READY_PCIE)) { in mwifiex_pm_wakeup_card()
671 mwifiex_dbg(adapter, ERROR, in mwifiex_pm_wakeup_card()
678 mwifiex_pcie_dev_wakeup_delay(adapter); in mwifiex_pm_wakeup_card()
679 mwifiex_dbg(adapter, INFO, in mwifiex_pm_wakeup_card()
681 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_pm_wakeup_card()
692 static int mwifiex_pm_wakeup_card_complete(struct mwifiex_adapter *adapter) in mwifiex_pm_wakeup_card_complete() argument
694 mwifiex_dbg(adapter, CMD, in mwifiex_pm_wakeup_card_complete()
706 static int mwifiex_pcie_disable_host_int(struct mwifiex_adapter *adapter) in mwifiex_pcie_disable_host_int() argument
708 if (mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_pcie_disable_host_int()
709 if (mwifiex_write_reg(adapter, PCIE_HOST_INT_MASK, in mwifiex_pcie_disable_host_int()
711 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_disable_host_int()
717 atomic_set(&adapter->tx_hw_pending, 0); in mwifiex_pcie_disable_host_int()
721 static void mwifiex_pcie_disable_host_int_noerr(struct mwifiex_adapter *adapter) in mwifiex_pcie_disable_host_int_noerr() argument
723 WARN_ON(mwifiex_pcie_disable_host_int(adapter)); in mwifiex_pcie_disable_host_int_noerr()
732 static int mwifiex_pcie_enable_host_int(struct mwifiex_adapter *adapter) in mwifiex_pcie_enable_host_int() argument
734 if (mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_pcie_enable_host_int()
736 if (mwifiex_write_reg(adapter, PCIE_HOST_INT_MASK, in mwifiex_pcie_enable_host_int()
738 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_enable_host_int()
750 static int mwifiex_init_txq_ring(struct mwifiex_adapter *adapter) in mwifiex_init_txq_ring() argument
752 struct pcie_service_card *card = adapter->card; in mwifiex_init_txq_ring()
780 static int mwifiex_init_rxq_ring(struct mwifiex_adapter *adapter) in mwifiex_init_rxq_ring() argument
782 struct pcie_service_card *card = adapter->card; in mwifiex_init_rxq_ring()
795 mwifiex_dbg(adapter, ERROR, in mwifiex_init_rxq_ring()
800 if (mwifiex_map_pci_memory(adapter, skb, in mwifiex_init_rxq_ring()
809 mwifiex_dbg(adapter, INFO, in mwifiex_init_rxq_ring()
841 static int mwifiex_pcie_init_evt_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_init_evt_ring() argument
843 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_init_evt_ring()
853 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_init_evt_ring()
859 if (mwifiex_map_pci_memory(adapter, skb, MAX_EVENT_SIZE, in mwifiex_pcie_init_evt_ring()
867 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_init_evt_ring()
887 static void mwifiex_cleanup_txq_ring(struct mwifiex_adapter *adapter) in mwifiex_cleanup_txq_ring() argument
889 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_txq_ring()
901 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_txq_ring()
910 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_txq_ring()
919 atomic_set(&adapter->tx_hw_pending, 0); in mwifiex_cleanup_txq_ring()
926 static void mwifiex_cleanup_rxq_ring(struct mwifiex_adapter *adapter) in mwifiex_cleanup_rxq_ring() argument
928 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_rxq_ring()
940 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_rxq_ring()
949 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_rxq_ring()
964 static void mwifiex_cleanup_evt_ring(struct mwifiex_adapter *adapter) in mwifiex_cleanup_evt_ring() argument
966 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_evt_ring()
975 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_evt_ring()
988 static int mwifiex_pcie_create_txbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_create_txbd_ring() argument
990 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_create_txbd_ring()
1014 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_create_txbd_ring()
1022 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_create_txbd_ring()
1028 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_create_txbd_ring()
1034 return mwifiex_init_txq_ring(adapter); in mwifiex_pcie_create_txbd_ring()
1037 static int mwifiex_pcie_delete_txbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_txbd_ring() argument
1039 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_txbd_ring()
1042 mwifiex_cleanup_txq_ring(adapter); in mwifiex_pcie_delete_txbd_ring()
1060 static int mwifiex_pcie_create_rxbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_create_rxbd_ring() argument
1063 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_create_rxbd_ring()
1081 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_create_rxbd_ring()
1089 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_create_rxbd_ring()
1095 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_create_rxbd_ring()
1101 ret = mwifiex_init_rxq_ring(adapter); in mwifiex_pcie_create_rxbd_ring()
1103 mwifiex_pcie_delete_rxbd_ring(adapter); in mwifiex_pcie_create_rxbd_ring()
1110 static int mwifiex_pcie_delete_rxbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_rxbd_ring() argument
1112 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_rxbd_ring()
1115 mwifiex_cleanup_rxq_ring(adapter); in mwifiex_pcie_delete_rxbd_ring()
1133 static int mwifiex_pcie_create_evtbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_create_evtbd_ring() argument
1136 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_create_evtbd_ring()
1150 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_create_evtbd_ring()
1158 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_create_evtbd_ring()
1164 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_create_evtbd_ring()
1170 ret = mwifiex_pcie_init_evt_ring(adapter); in mwifiex_pcie_create_evtbd_ring()
1172 mwifiex_pcie_delete_evtbd_ring(adapter); in mwifiex_pcie_create_evtbd_ring()
1179 static int mwifiex_pcie_delete_evtbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_evtbd_ring() argument
1181 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_evtbd_ring()
1184 mwifiex_cleanup_evt_ring(adapter); in mwifiex_pcie_delete_evtbd_ring()
1202 static int mwifiex_pcie_alloc_cmdrsp_buf(struct mwifiex_adapter *adapter) in mwifiex_pcie_alloc_cmdrsp_buf() argument
1204 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_alloc_cmdrsp_buf()
1210 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_alloc_cmdrsp_buf()
1215 if (mwifiex_map_pci_memory(adapter, skb, MWIFIEX_UPLD_SIZE, in mwifiex_pcie_alloc_cmdrsp_buf()
1229 static int mwifiex_pcie_delete_cmdrsp_buf(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_cmdrsp_buf() argument
1233 if (!adapter) in mwifiex_pcie_delete_cmdrsp_buf()
1236 card = adapter->card; in mwifiex_pcie_delete_cmdrsp_buf()
1239 mwifiex_unmap_pci_memory(adapter, card->cmdrsp_buf, in mwifiex_pcie_delete_cmdrsp_buf()
1246 mwifiex_unmap_pci_memory(adapter, card->cmd_buf, in mwifiex_pcie_delete_cmdrsp_buf()
1257 static int mwifiex_pcie_alloc_sleep_cookie_buf(struct mwifiex_adapter *adapter) in mwifiex_pcie_alloc_sleep_cookie_buf() argument
1259 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_alloc_sleep_cookie_buf()
1267 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_alloc_sleep_cookie_buf()
1275 mwifiex_dbg(adapter, INFO, "alloc_scook: sleep cookie=0x%x\n", *cookie); in mwifiex_pcie_alloc_sleep_cookie_buf()
1283 static int mwifiex_pcie_delete_sleep_cookie_buf(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_sleep_cookie_buf() argument
1287 if (!adapter) in mwifiex_pcie_delete_sleep_cookie_buf()
1290 card = adapter->card; in mwifiex_pcie_delete_sleep_cookie_buf()
1306 static int mwifiex_clean_pcie_ring_buf(struct mwifiex_adapter *adapter) in mwifiex_clean_pcie_ring_buf() argument
1308 struct pcie_service_card *card = adapter->card; in mwifiex_clean_pcie_ring_buf()
1315 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_clean_pcie_ring_buf()
1317 mwifiex_dbg(adapter, ERROR, in mwifiex_clean_pcie_ring_buf()
1328 static int mwifiex_pcie_send_data_complete(struct mwifiex_adapter *adapter) in mwifiex_pcie_send_data_complete() argument
1334 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_data_complete()
1337 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_send_data_complete()
1338 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_send_data_complete()
1341 if (mwifiex_read_reg(adapter, reg->tx_rdptr, &rdptr)) { in mwifiex_pcie_send_data_complete()
1342 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_data_complete()
1347 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data_complete()
1363 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data_complete()
1366 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_pcie_send_data_complete()
1372 mwifiex_write_data_complete(adapter, skb, 0, in mwifiex_pcie_send_data_complete()
1375 mwifiex_write_data_complete(adapter, skb, 0, 0); in mwifiex_pcie_send_data_complete()
1376 atomic_dec(&adapter->tx_hw_pending); in mwifiex_pcie_send_data_complete()
1406 adapter->data_sent = false; in mwifiex_pcie_send_data_complete()
1412 mwifiex_clean_pcie_ring_buf(adapter); in mwifiex_pcie_send_data_complete()
1426 mwifiex_pcie_send_data(struct mwifiex_adapter *adapter, struct sk_buff *skb, in mwifiex_pcie_send_data() argument
1429 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_data()
1438 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_data()
1444 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_send_data()
1445 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_send_data()
1448 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data()
1454 adapter->data_sent = true; in mwifiex_pcie_send_data()
1459 if (mwifiex_map_pci_memory(adapter, skb, skb->len, in mwifiex_pcie_send_data()
1466 atomic_inc(&adapter->tx_hw_pending); in mwifiex_pcie_send_data()
1501 if (mwifiex_write_reg(adapter, reg->tx_wrptr, in mwifiex_pcie_send_data()
1503 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_data()
1514 mwifiex_read_reg(adapter, PCI_VENDOR_ID, &rx_val); in mwifiex_pcie_send_data()
1519 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data()
1521 adapter->data_sent = false; in mwifiex_pcie_send_data()
1524 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_send_data()
1526 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_data()
1532 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data()
1537 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data()
1539 adapter->data_sent = true; in mwifiex_pcie_send_data()
1541 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_send_data()
1543 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_data()
1550 mwifiex_unmap_pci_memory(adapter, skb, DMA_TO_DEVICE); in mwifiex_pcie_send_data()
1552 atomic_dec(&adapter->tx_hw_pending); in mwifiex_pcie_send_data()
1565 static int mwifiex_pcie_process_recv_data(struct mwifiex_adapter *adapter) in mwifiex_pcie_process_recv_data() argument
1567 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_recv_data()
1576 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_process_recv_data()
1577 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_process_recv_data()
1580 if (mwifiex_read_reg(adapter, reg->rx_wrptr, &wrptr)) { in mwifiex_pcie_process_recv_data()
1581 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_recv_data()
1604 mwifiex_unmap_pci_memory(adapter, skb_data, DMA_FROM_DEVICE); in mwifiex_pcie_process_recv_data()
1611 if (WARN_ON(rx_len <= adapter->intf_hdr_len || in mwifiex_pcie_process_recv_data()
1613 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_recv_data()
1619 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_process_recv_data()
1622 skb_pull(skb_data, adapter->intf_hdr_len); in mwifiex_pcie_process_recv_data()
1623 if (adapter->rx_work_enabled) { in mwifiex_pcie_process_recv_data()
1624 skb_queue_tail(&adapter->rx_data_q, skb_data); in mwifiex_pcie_process_recv_data()
1625 adapter->data_received = true; in mwifiex_pcie_process_recv_data()
1626 atomic_inc(&adapter->rx_pending); in mwifiex_pcie_process_recv_data()
1628 mwifiex_handle_rx_packet(adapter, skb_data); in mwifiex_pcie_process_recv_data()
1635 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_recv_data()
1640 if (mwifiex_map_pci_memory(adapter, skb_tmp, in mwifiex_pcie_process_recv_data()
1647 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_process_recv_data()
1672 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_process_recv_data()
1678 if (mwifiex_write_reg(adapter, reg->rx_rdptr, in mwifiex_pcie_process_recv_data()
1680 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_process_recv_data()
1687 if (mwifiex_read_reg(adapter, reg->rx_wrptr, &wrptr)) { in mwifiex_pcie_process_recv_data()
1688 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_recv_data()
1693 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_process_recv_data()
1706 mwifiex_pcie_send_boot_cmd(struct mwifiex_adapter *adapter, struct sk_buff *skb) in mwifiex_pcie_send_boot_cmd() argument
1709 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_boot_cmd()
1713 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_boot_cmd()
1719 if (mwifiex_map_pci_memory(adapter, skb, skb->len, DMA_TO_DEVICE)) in mwifiex_pcie_send_boot_cmd()
1727 if (mwifiex_write_reg(adapter, reg->cmd_addr_lo, (u32)buf_pa)) { in mwifiex_pcie_send_boot_cmd()
1728 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_boot_cmd()
1731 mwifiex_unmap_pci_memory(adapter, skb, DMA_TO_DEVICE); in mwifiex_pcie_send_boot_cmd()
1738 if (mwifiex_write_reg(adapter, reg->cmd_addr_hi, in mwifiex_pcie_send_boot_cmd()
1740 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_boot_cmd()
1743 mwifiex_unmap_pci_memory(adapter, skb, DMA_TO_DEVICE); in mwifiex_pcie_send_boot_cmd()
1748 if (mwifiex_write_reg(adapter, reg->cmd_size, skb->len)) { in mwifiex_pcie_send_boot_cmd()
1749 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_boot_cmd()
1752 mwifiex_unmap_pci_memory(adapter, skb, DMA_TO_DEVICE); in mwifiex_pcie_send_boot_cmd()
1757 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_send_boot_cmd()
1759 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_boot_cmd()
1761 mwifiex_unmap_pci_memory(adapter, skb, DMA_TO_DEVICE); in mwifiex_pcie_send_boot_cmd()
1771 static int mwifiex_pcie_init_fw_port(struct mwifiex_adapter *adapter) in mwifiex_pcie_init_fw_port() argument
1773 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_init_fw_port()
1778 if (mwifiex_write_reg(adapter, reg->rx_rdptr, card->rxbd_rdptr | in mwifiex_pcie_init_fw_port()
1780 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_init_fw_port()
1790 mwifiex_pcie_send_cmd(struct mwifiex_adapter *adapter, struct sk_buff *skb) in mwifiex_pcie_send_cmd() argument
1792 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_cmd()
1799 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1807 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1812 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_send_cmd()
1813 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_send_cmd()
1815 adapter->cmd_sent = true; in mwifiex_pcie_send_cmd()
1820 if (mwifiex_map_pci_memory(adapter, skb, skb->len, DMA_TO_DEVICE)) in mwifiex_pcie_send_cmd()
1844 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_lo, in mwifiex_pcie_send_cmd()
1846 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1853 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_hi, in mwifiex_pcie_send_cmd()
1855 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1864 if (mwifiex_write_reg(adapter, reg->cmd_addr_lo, in mwifiex_pcie_send_cmd()
1866 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1872 if (mwifiex_write_reg(adapter, reg->cmd_addr_hi, in mwifiex_pcie_send_cmd()
1874 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1881 if (mwifiex_write_reg(adapter, reg->cmd_size, in mwifiex_pcie_send_cmd()
1883 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1890 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_send_cmd()
1892 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1900 adapter->cmd_sent = false; in mwifiex_pcie_send_cmd()
1908 static int mwifiex_pcie_process_cmd_complete(struct mwifiex_adapter *adapter) in mwifiex_pcie_process_cmd_complete() argument
1910 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_cmd_complete()
1916 mwifiex_dbg(adapter, CMD, in mwifiex_pcie_process_cmd_complete()
1919 if (adapter->curr_cmd) in mwifiex_pcie_process_cmd_complete()
1920 mwifiex_unmap_pci_memory(adapter, skb, DMA_FROM_DEVICE); in mwifiex_pcie_process_cmd_complete()
1928 mwifiex_unmap_pci_memory(adapter, card->cmd_buf, in mwifiex_pcie_process_cmd_complete()
1938 if (!adapter->curr_cmd) { in mwifiex_pcie_process_cmd_complete()
1939 if (adapter->ps_state == PS_STATE_SLEEP_CFM) { in mwifiex_pcie_process_cmd_complete()
1944 if (mwifiex_write_reg(adapter, in mwifiex_pcie_process_cmd_complete()
1947 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_cmd_complete()
1951 mwifiex_delay_for_sleep_cookie(adapter, in mwifiex_pcie_process_cmd_complete()
1953 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_pcie_process_cmd_complete()
1955 skb_pull(skb, adapter->intf_hdr_len); in mwifiex_pcie_process_cmd_complete()
1957 mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_process_cmd_complete()
1959 mwifiex_pcie_enable_host_int(adapter); in mwifiex_pcie_process_cmd_complete()
1960 mwifiex_process_sleep_confirm_resp(adapter, skb->data, in mwifiex_pcie_process_cmd_complete()
1963 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_cmd_complete()
1966 memcpy(adapter->upld_buf, skb->data, in mwifiex_pcie_process_cmd_complete()
1968 skb_push(skb, adapter->intf_hdr_len); in mwifiex_pcie_process_cmd_complete()
1969 if (mwifiex_map_pci_memory(adapter, skb, MWIFIEX_UPLD_SIZE, in mwifiex_pcie_process_cmd_complete()
1972 } else if (mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_pcie_process_cmd_complete()
1973 skb_pull(skb, adapter->intf_hdr_len); in mwifiex_pcie_process_cmd_complete()
1974 adapter->curr_cmd->resp_skb = skb; in mwifiex_pcie_process_cmd_complete()
1975 adapter->cmd_resp_received = true; in mwifiex_pcie_process_cmd_complete()
1983 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_lo, 0)) { in mwifiex_pcie_process_cmd_complete()
1984 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_cmd_complete()
1990 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_hi, 0)) { in mwifiex_pcie_process_cmd_complete()
1991 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_cmd_complete()
2003 static int mwifiex_pcie_cmdrsp_complete(struct mwifiex_adapter *adapter, in mwifiex_pcie_cmdrsp_complete() argument
2006 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_cmdrsp_complete()
2010 skb_push(card->cmdrsp_buf, adapter->intf_hdr_len); in mwifiex_pcie_cmdrsp_complete()
2011 if (mwifiex_map_pci_memory(adapter, skb, MWIFIEX_UPLD_SIZE, in mwifiex_pcie_cmdrsp_complete()
2022 static int mwifiex_pcie_process_event_ready(struct mwifiex_adapter *adapter) in mwifiex_pcie_process_event_ready() argument
2024 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_event_ready()
2030 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_process_event_ready()
2031 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_process_event_ready()
2033 if (adapter->event_received) { in mwifiex_pcie_process_event_ready()
2034 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_process_event_ready()
2041 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_event_ready()
2047 if (mwifiex_read_reg(adapter, reg->evt_wrptr, &wrptr)) { in mwifiex_pcie_process_event_ready()
2048 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_event_ready()
2053 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_process_event_ready()
2064 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_process_event_ready()
2067 mwifiex_unmap_pci_memory(adapter, skb_cmd, DMA_FROM_DEVICE); in mwifiex_pcie_process_event_ready()
2076 &skb_cmd->data[adapter->intf_hdr_len]); in mwifiex_pcie_process_event_ready()
2077 adapter->event_cause = event; in mwifiex_pcie_process_event_ready()
2083 skb_pull(skb_cmd, adapter->intf_hdr_len); in mwifiex_pcie_process_event_ready()
2084 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_process_event_ready()
2089 memcpy(adapter->event_body, skb_cmd->data + in mwifiex_pcie_process_event_ready()
2093 adapter->event_received = true; in mwifiex_pcie_process_event_ready()
2094 adapter->event_skb = skb_cmd; in mwifiex_pcie_process_event_ready()
2101 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_process_event_ready()
2103 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_event_ready()
2115 static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter, in mwifiex_pcie_event_complete() argument
2118 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_event_complete()
2129 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_event_complete()
2136 if (mwifiex_read_reg(adapter, reg->evt_wrptr, &wrptr)) { in mwifiex_pcie_event_complete()
2137 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_event_complete()
2143 skb_push(skb, adapter->intf_hdr_len); in mwifiex_pcie_event_complete()
2145 if (mwifiex_map_pci_memory(adapter, skb, in mwifiex_pcie_event_complete()
2156 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_event_complete()
2167 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_event_complete()
2172 if (mwifiex_write_reg(adapter, reg->evt_rdptr, in mwifiex_pcie_event_complete()
2174 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_event_complete()
2179 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_event_complete()
2181 ret = mwifiex_pcie_process_event_ready(adapter); in mwifiex_pcie_event_complete()
2196 static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter, in mwifiex_extract_wifi_fw() argument
2207 mwifiex_dbg(adapter, ERROR, in mwifiex_extract_wifi_fw()
2223 mwifiex_dbg(adapter, ERROR, "bad FW parse\n"); in mwifiex_extract_wifi_fw()
2230 mwifiex_dbg(adapter, MSG, in mwifiex_extract_wifi_fw()
2236 mwifiex_dbg(adapter, ERROR, in mwifiex_extract_wifi_fw()
2247 mwifiex_dbg(adapter, ERROR, "bad FW parse\n"); in mwifiex_extract_wifi_fw()
2257 mwifiex_dbg(adapter, ERROR, "bad FW parse\n"); in mwifiex_extract_wifi_fw()
2263 mwifiex_dbg(adapter, ERROR, in mwifiex_extract_wifi_fw()
2275 mwifiex_dbg(adapter, ERROR, "unknown dnld_cmd %d\n", in mwifiex_extract_wifi_fw()
2293 static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, in mwifiex_prog_fw_w_helper() argument
2303 struct pcie_service_card *card = adapter->card; in mwifiex_prog_fw_w_helper()
2307 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
2312 mwifiex_dbg(adapter, INFO, in mwifiex_prog_fw_w_helper()
2316 if (mwifiex_pcie_disable_host_int(adapter)) { in mwifiex_prog_fw_w_helper()
2317 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
2328 ret = mwifiex_read_reg(adapter, PCIE_SCRATCH_13_REG, &val); in mwifiex_prog_fw_w_helper()
2330 mwifiex_dbg(adapter, FATAL, "Failed to read scratch register 13\n"); in mwifiex_prog_fw_w_helper()
2336 ret = mwifiex_extract_wifi_fw(adapter, firmware, firmware_len); in mwifiex_prog_fw_w_helper()
2338 mwifiex_dbg(adapter, ERROR, "Failed to extract wifi fw\n"); in mwifiex_prog_fw_w_helper()
2342 mwifiex_dbg(adapter, MSG, in mwifiex_prog_fw_w_helper()
2355 ret = mwifiex_read_reg(adapter, reg->cmd_size, in mwifiex_prog_fw_w_helper()
2358 mwifiex_dbg(adapter, FATAL, in mwifiex_prog_fw_w_helper()
2370 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
2382 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
2388 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
2413 if (mwifiex_pcie_send_boot_cmd(adapter, skb)) { in mwifiex_prog_fw_w_helper()
2414 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
2422 if (mwifiex_read_reg(adapter, PCIE_CPU_INT_STATUS, in mwifiex_prog_fw_w_helper()
2424 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
2428 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_prog_fw_w_helper()
2438 mwifiex_dbg(adapter, ERROR, "%s: Card failed to ACK download\n", in mwifiex_prog_fw_w_helper()
2440 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_prog_fw_w_helper()
2446 mwifiex_unmap_pci_memory(adapter, skb, DMA_TO_DEVICE); in mwifiex_prog_fw_w_helper()
2451 mwifiex_dbg(adapter, MSG, in mwifiex_prog_fw_w_helper()
2465 mwifiex_check_fw_status(struct mwifiex_adapter *adapter, u32 poll_num) in mwifiex_check_fw_status() argument
2469 struct pcie_service_card *card = adapter->card; in mwifiex_check_fw_status()
2474 if (mwifiex_write_reg(adapter, PCIE_HOST_INT_STATUS_MASK, in mwifiex_check_fw_status()
2476 mwifiex_dbg(adapter, ERROR, in mwifiex_check_fw_status()
2481 mwifiex_dbg(adapter, INFO, in mwifiex_check_fw_status()
2483 if (mwifiex_write_reg(adapter, reg->drv_rdy, in mwifiex_check_fw_status()
2485 mwifiex_dbg(adapter, ERROR, in mwifiex_check_fw_status()
2492 if (mwifiex_read_reg(adapter, reg->fw_status, in mwifiex_check_fw_status()
2498 mwifiex_dbg(adapter, INFO, "Try %d if FW is ready <%d,%#x>", in mwifiex_check_fw_status()
2518 mwifiex_check_winner_status(struct mwifiex_adapter *adapter) in mwifiex_check_winner_status() argument
2522 struct pcie_service_card *card = adapter->card; in mwifiex_check_winner_status()
2525 if (mwifiex_read_reg(adapter, reg->fw_status, &winner)) { in mwifiex_check_winner_status()
2528 mwifiex_dbg(adapter, INFO, "PCI-E is the winner\n"); in mwifiex_check_winner_status()
2529 adapter->winner = 1; in mwifiex_check_winner_status()
2531 mwifiex_dbg(adapter, ERROR, in mwifiex_check_winner_status()
2541 static void mwifiex_interrupt_status(struct mwifiex_adapter *adapter, in mwifiex_interrupt_status() argument
2546 struct pcie_service_card *card = adapter->card; in mwifiex_interrupt_status()
2549 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2550 adapter->int_status = 1; in mwifiex_interrupt_status()
2551 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2555 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_interrupt_status()
2561 if (mwifiex_read_reg(adapter, PCIE_HOST_INT_STATUS, in mwifiex_interrupt_status()
2563 mwifiex_dbg(adapter, ERROR, "Read register failed\n"); in mwifiex_interrupt_status()
2571 mwifiex_pcie_disable_host_int(adapter); in mwifiex_interrupt_status()
2574 if (mwifiex_write_reg(adapter, PCIE_HOST_INT_STATUS, in mwifiex_interrupt_status()
2576 mwifiex_dbg(adapter, ERROR, in mwifiex_interrupt_status()
2582 if (!adapter->pps_uapsd_mode && in mwifiex_interrupt_status()
2583 adapter->ps_state == PS_STATE_SLEEP && in mwifiex_interrupt_status()
2584 mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_interrupt_status()
2589 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_interrupt_status()
2590 adapter->pm_wakeup_fw_try = false; in mwifiex_interrupt_status()
2591 del_timer(&adapter->wakeup_timer); in mwifiex_interrupt_status()
2594 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2595 adapter->int_status |= pcie_ireg; in mwifiex_interrupt_status()
2596 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2597 mwifiex_dbg(adapter, INTR, "ireg: 0x%08x\n", pcie_ireg); in mwifiex_interrupt_status()
2611 struct mwifiex_adapter *adapter; in mwifiex_pcie_interrupt() local
2615 if (!card->adapter) { in mwifiex_pcie_interrupt()
2617 card ? card->adapter : NULL); in mwifiex_pcie_interrupt()
2620 adapter = card->adapter; in mwifiex_pcie_interrupt()
2622 if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags)) in mwifiex_pcie_interrupt()
2626 mwifiex_interrupt_status(adapter, ctx->msg_id); in mwifiex_pcie_interrupt()
2628 mwifiex_interrupt_status(adapter, -1); in mwifiex_pcie_interrupt()
2630 mwifiex_queue_main_work(adapter); in mwifiex_pcie_interrupt()
2649 static int mwifiex_process_int_status(struct mwifiex_adapter *adapter) in mwifiex_process_int_status() argument
2654 struct pcie_service_card *card = adapter->card; in mwifiex_process_int_status()
2656 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_process_int_status()
2659 pcie_ireg = adapter->int_status; in mwifiex_process_int_status()
2661 adapter->int_status = 0; in mwifiex_process_int_status()
2662 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_process_int_status()
2665 if (mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_process_int_status()
2666 if (mwifiex_read_reg(adapter, PCIE_HOST_INT_STATUS, in mwifiex_process_int_status()
2668 mwifiex_dbg(adapter, ERROR, in mwifiex_process_int_status()
2674 if (mwifiex_write_reg(adapter, in mwifiex_process_int_status()
2677 mwifiex_dbg(adapter, ERROR, in mwifiex_process_int_status()
2681 if (!adapter->pps_uapsd_mode && in mwifiex_process_int_status()
2682 adapter->ps_state == PS_STATE_SLEEP) { in mwifiex_process_int_status()
2683 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_process_int_status()
2684 adapter->pm_wakeup_fw_try = false; in mwifiex_process_int_status()
2685 del_timer(&adapter->wakeup_timer); in mwifiex_process_int_status()
2692 mwifiex_dbg(adapter, INTR, "info: TX DNLD Done\n"); in mwifiex_process_int_status()
2693 ret = mwifiex_pcie_send_data_complete(adapter); in mwifiex_process_int_status()
2698 mwifiex_dbg(adapter, INTR, "info: Rx DATA\n"); in mwifiex_process_int_status()
2699 ret = mwifiex_pcie_process_recv_data(adapter); in mwifiex_process_int_status()
2704 mwifiex_dbg(adapter, INTR, "info: Rx EVENT\n"); in mwifiex_process_int_status()
2705 ret = mwifiex_pcie_process_event_ready(adapter); in mwifiex_process_int_status()
2710 if (adapter->cmd_sent) { in mwifiex_process_int_status()
2711 mwifiex_dbg(adapter, INTR, in mwifiex_process_int_status()
2713 adapter->cmd_sent = false; in mwifiex_process_int_status()
2716 ret = mwifiex_pcie_process_cmd_complete(adapter); in mwifiex_process_int_status()
2721 mwifiex_dbg(adapter, INTR, in mwifiex_process_int_status()
2723 adapter->cmd_sent, adapter->data_sent); in mwifiex_process_int_status()
2725 adapter->ps_state != PS_STATE_SLEEP) in mwifiex_process_int_status()
2726 mwifiex_pcie_enable_host_int(adapter); in mwifiex_process_int_status()
2741 static int mwifiex_pcie_host_to_card(struct mwifiex_adapter *adapter, u8 type, in mwifiex_pcie_host_to_card() argument
2746 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_host_to_card()
2752 return mwifiex_pcie_send_data(adapter, skb, tx_param); in mwifiex_pcie_host_to_card()
2754 return mwifiex_pcie_send_cmd(adapter, skb); in mwifiex_pcie_host_to_card()
2762 mwifiex_pcie_reg_dump(struct mwifiex_adapter *adapter, char *drv_buf) in mwifiex_pcie_reg_dump() argument
2768 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_reg_dump()
2777 mwifiex_dbg(adapter, MSG, "PCIE register dump start\n"); in mwifiex_pcie_reg_dump()
2779 if (mwifiex_read_reg(adapter, reg->fw_status, &value)) { in mwifiex_pcie_reg_dump()
2780 mwifiex_dbg(adapter, ERROR, "failed to read firmware status"); in mwifiex_pcie_reg_dump()
2785 mwifiex_dbg(adapter, MSG, "pcie scratch register:"); in mwifiex_pcie_reg_dump()
2787 mwifiex_read_reg(adapter, pcie_scratch_reg[i], &value); in mwifiex_pcie_reg_dump()
2792 mwifiex_dbg(adapter, MSG, "%s\n", buf); in mwifiex_pcie_reg_dump()
2795 mwifiex_dbg(adapter, MSG, "PCIE register dump end\n"); in mwifiex_pcie_reg_dump()
2802 mwifiex_pcie_rdwr_firmware(struct mwifiex_adapter *adapter, u8 doneflag) in mwifiex_pcie_rdwr_firmware() argument
2807 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_rdwr_firmware()
2810 if (mwifiex_read_reg(adapter, reg->fw_status, &fw_status)) in mwifiex_pcie_rdwr_firmware()
2813 ret = mwifiex_write_reg(adapter, reg->fw_dump_ctrl, in mwifiex_pcie_rdwr_firmware()
2816 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_rdwr_firmware()
2822 mwifiex_read_reg_byte(adapter, reg->fw_dump_ctrl, &ctrl_data); in mwifiex_pcie_rdwr_firmware()
2828 mwifiex_dbg(adapter, WARN, in mwifiex_pcie_rdwr_firmware()
2830 ret = mwifiex_write_reg(adapter, reg->fw_dump_ctrl, in mwifiex_pcie_rdwr_firmware()
2833 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_rdwr_firmware()
2841 mwifiex_dbg(adapter, ERROR, "Fail to pull ctrl_data\n"); in mwifiex_pcie_rdwr_firmware()
2846 static void mwifiex_pcie_fw_dump(struct mwifiex_adapter *adapter) in mwifiex_pcie_fw_dump() argument
2848 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_fw_dump()
2860 for (idx = 0; idx < adapter->num_mem_types; idx++) { in mwifiex_pcie_fw_dump()
2862 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_pcie_fw_dump()
2871 mwifiex_dbg(adapter, MSG, "== mwifiex firmware dump start ==\n"); in mwifiex_pcie_fw_dump()
2874 stat = mwifiex_pcie_rdwr_firmware(adapter, doneflag); in mwifiex_pcie_fw_dump()
2879 mwifiex_read_reg_byte(adapter, reg, &fw_dump_num); in mwifiex_pcie_fw_dump()
2890 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_pcie_fw_dump()
2893 stat = mwifiex_pcie_rdwr_firmware(adapter, doneflag); in mwifiex_pcie_fw_dump()
2899 mwifiex_read_reg_byte(adapter, reg, &read_reg); in mwifiex_pcie_fw_dump()
2908 mwifiex_dbg(adapter, MSG, "Firmware dump Finished!\n"); in mwifiex_pcie_fw_dump()
2909 ret = mwifiex_write_reg(adapter, creg->fw_dump_ctrl, in mwifiex_pcie_fw_dump()
2912 mwifiex_dbg(adapter, ERROR, "PCIE write err\n"); in mwifiex_pcie_fw_dump()
2918 mwifiex_dbg(adapter, DUMP, in mwifiex_pcie_fw_dump()
2923 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_fw_dump()
2931 mwifiex_dbg(adapter, DUMP, "Start %s output, please wait...\n", in mwifiex_pcie_fw_dump()
2935 stat = mwifiex_pcie_rdwr_firmware(adapter, doneflag); in mwifiex_pcie_fw_dump()
2942 mwifiex_read_reg_byte(adapter, reg, dbg_ptr); in mwifiex_pcie_fw_dump()
2947 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_fw_dump()
2965 mwifiex_dbg(adapter, DUMP, in mwifiex_pcie_fw_dump()
2971 mwifiex_dbg(adapter, MSG, "== mwifiex firmware dump end ==\n"); in mwifiex_pcie_fw_dump()
2974 static void mwifiex_pcie_device_dump_work(struct mwifiex_adapter *adapter) in mwifiex_pcie_device_dump_work() argument
2976 adapter->devdump_data = vzalloc(MWIFIEX_FW_DUMP_SIZE); in mwifiex_pcie_device_dump_work()
2977 if (!adapter->devdump_data) { in mwifiex_pcie_device_dump_work()
2978 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_device_dump_work()
2983 mwifiex_drv_info_dump(adapter); in mwifiex_pcie_device_dump_work()
2984 mwifiex_pcie_fw_dump(adapter); in mwifiex_pcie_device_dump_work()
2985 mwifiex_prepare_fw_dump_info(adapter); in mwifiex_pcie_device_dump_work()
2986 mwifiex_upload_device_dump(adapter); in mwifiex_pcie_device_dump_work()
2989 static void mwifiex_pcie_card_reset_work(struct mwifiex_adapter *adapter) in mwifiex_pcie_card_reset_work() argument
2991 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_card_reset_work()
3006 mwifiex_pcie_device_dump_work(card->adapter); in mwifiex_pcie_work()
3009 mwifiex_pcie_card_reset_work(card->adapter); in mwifiex_pcie_work()
3013 static void mwifiex_pcie_device_dump(struct mwifiex_adapter *adapter) in mwifiex_pcie_device_dump() argument
3015 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_device_dump()
3022 static void mwifiex_pcie_card_reset(struct mwifiex_adapter *adapter) in mwifiex_pcie_card_reset() argument
3024 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_card_reset()
3030 static int mwifiex_pcie_alloc_buffers(struct mwifiex_adapter *adapter) in mwifiex_pcie_alloc_buffers() argument
3032 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_alloc_buffers()
3037 ret = mwifiex_pcie_create_txbd_ring(adapter); in mwifiex_pcie_alloc_buffers()
3039 mwifiex_dbg(adapter, ERROR, "Failed to create txbd ring\n"); in mwifiex_pcie_alloc_buffers()
3043 ret = mwifiex_pcie_create_rxbd_ring(adapter); in mwifiex_pcie_alloc_buffers()
3045 mwifiex_dbg(adapter, ERROR, "Failed to create rxbd ring\n"); in mwifiex_pcie_alloc_buffers()
3049 ret = mwifiex_pcie_create_evtbd_ring(adapter); in mwifiex_pcie_alloc_buffers()
3051 mwifiex_dbg(adapter, ERROR, "Failed to create evtbd ring\n"); in mwifiex_pcie_alloc_buffers()
3055 ret = mwifiex_pcie_alloc_cmdrsp_buf(adapter); in mwifiex_pcie_alloc_buffers()
3057 mwifiex_dbg(adapter, ERROR, "Failed to allocate cmdbuf buffer\n"); in mwifiex_pcie_alloc_buffers()
3062 ret = mwifiex_pcie_alloc_sleep_cookie_buf(adapter); in mwifiex_pcie_alloc_buffers()
3064 mwifiex_dbg(adapter, ERROR, "Failed to allocate sleep_cookie buffer\n"); in mwifiex_pcie_alloc_buffers()
3074 mwifiex_pcie_delete_cmdrsp_buf(adapter); in mwifiex_pcie_alloc_buffers()
3076 mwifiex_pcie_delete_evtbd_ring(adapter); in mwifiex_pcie_alloc_buffers()
3078 mwifiex_pcie_delete_rxbd_ring(adapter); in mwifiex_pcie_alloc_buffers()
3080 mwifiex_pcie_delete_txbd_ring(adapter); in mwifiex_pcie_alloc_buffers()
3085 static void mwifiex_pcie_free_buffers(struct mwifiex_adapter *adapter) in mwifiex_pcie_free_buffers() argument
3087 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_free_buffers()
3091 mwifiex_pcie_delete_sleep_cookie_buf(adapter); in mwifiex_pcie_free_buffers()
3093 mwifiex_pcie_delete_cmdrsp_buf(adapter); in mwifiex_pcie_free_buffers()
3094 mwifiex_pcie_delete_evtbd_ring(adapter); in mwifiex_pcie_free_buffers()
3095 mwifiex_pcie_delete_rxbd_ring(adapter); in mwifiex_pcie_free_buffers()
3096 mwifiex_pcie_delete_txbd_ring(adapter); in mwifiex_pcie_free_buffers()
3102 static int mwifiex_init_pcie(struct mwifiex_adapter *adapter) in mwifiex_init_pcie() argument
3104 struct pcie_service_card *card = adapter->card; in mwifiex_init_pcie()
3148 ret = mwifiex_pcie_alloc_buffers(adapter); in mwifiex_init_pcie()
3153 adapter->ignore_btcoex_events = true; in mwifiex_init_pcie()
3175 static void mwifiex_cleanup_pcie(struct mwifiex_adapter *adapter) in mwifiex_cleanup_pcie() argument
3177 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_pcie()
3188 mwifiex_dbg(adapter, MSG, "performing cancel_work_sync()...\n"); in mwifiex_cleanup_pcie()
3190 mwifiex_dbg(adapter, MSG, "cancel_work_sync() done\n"); in mwifiex_cleanup_pcie()
3192 mwifiex_dbg(adapter, MSG, in mwifiex_cleanup_pcie()
3196 mwifiex_read_reg(adapter, reg->fw_status, &fw_status); in mwifiex_cleanup_pcie()
3198 mwifiex_dbg(adapter, INFO, in mwifiex_cleanup_pcie()
3200 if (mwifiex_write_reg(adapter, reg->drv_rdy, 0x00000000)) in mwifiex_cleanup_pcie()
3201 mwifiex_dbg(adapter, ERROR, in mwifiex_cleanup_pcie()
3212 mwifiex_pcie_free_buffers(adapter); in mwifiex_cleanup_pcie()
3215 static int mwifiex_pcie_request_irq(struct mwifiex_adapter *adapter) in mwifiex_pcie_request_irq() argument
3218 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_request_irq()
3240 mwifiex_dbg(adapter, INFO, "request_irq fail: %d\n", in mwifiex_pcie_request_irq()
3247 mwifiex_dbg(adapter, MSG, "MSIx enabled!"); in mwifiex_pcie_request_irq()
3259 mwifiex_dbg(adapter, INFO, "msi_enable = %d\n", card->msi_enable); in mwifiex_pcie_request_irq()
3278 static void mwifiex_pcie_get_fw_name(struct mwifiex_adapter *adapter) in mwifiex_pcie_get_fw_name() argument
3282 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_get_fw_name()
3286 strcpy(adapter->fw_name, PCIE8766_DEFAULT_FW_NAME); in mwifiex_pcie_get_fw_name()
3289 mwifiex_write_reg(adapter, 0x0c58, 0x80c00000); in mwifiex_pcie_get_fw_name()
3290 mwifiex_read_reg(adapter, 0x0c58, &revision_id); in mwifiex_pcie_get_fw_name()
3294 strcpy(adapter->fw_name, PCIE8897_A0_FW_NAME); in mwifiex_pcie_get_fw_name()
3297 strcpy(adapter->fw_name, PCIE8897_B0_FW_NAME); in mwifiex_pcie_get_fw_name()
3300 strcpy(adapter->fw_name, PCIE8897_DEFAULT_FW_NAME); in mwifiex_pcie_get_fw_name()
3306 mwifiex_read_reg(adapter, 0x8, &revision_id); in mwifiex_pcie_get_fw_name()
3307 mwifiex_read_reg(adapter, 0x0cd0, &version); in mwifiex_pcie_get_fw_name()
3308 mwifiex_read_reg(adapter, 0x0cd4, &magic); in mwifiex_pcie_get_fw_name()
3315 strcpy(adapter->fw_name, PCIEUART8997_FW_NAME_V4); in mwifiex_pcie_get_fw_name()
3317 strcpy(adapter->fw_name, PCIEUSB8997_FW_NAME_V4); in mwifiex_pcie_get_fw_name()
3329 static int mwifiex_register_dev(struct mwifiex_adapter *adapter) in mwifiex_register_dev() argument
3331 struct pcie_service_card *card = adapter->card; in mwifiex_register_dev()
3334 card->adapter = adapter; in mwifiex_register_dev()
3336 if (mwifiex_pcie_request_irq(adapter)) in mwifiex_register_dev()
3339 adapter->tx_buf_size = card->pcie.tx_buf_size; in mwifiex_register_dev()
3340 adapter->mem_type_mapping_tbl = card->pcie.mem_type_mapping_tbl; in mwifiex_register_dev()
3341 adapter->num_mem_types = card->pcie.num_mem_types; in mwifiex_register_dev()
3342 adapter->ext_scan = card->pcie.can_ext_scan; in mwifiex_register_dev()
3343 mwifiex_pcie_get_fw_name(adapter); in mwifiex_register_dev()
3354 static void mwifiex_unregister_dev(struct mwifiex_adapter *adapter) in mwifiex_unregister_dev() argument
3356 struct pcie_service_card *card = adapter->card; in mwifiex_unregister_dev()
3371 mwifiex_dbg(adapter, INFO, in mwifiex_unregister_dev()
3378 card->adapter = NULL; in mwifiex_unregister_dev()
3385 static void mwifiex_pcie_up_dev(struct mwifiex_adapter *adapter) in mwifiex_pcie_up_dev() argument
3387 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_up_dev()
3393 adapter->tx_buf_size = card->pcie.tx_buf_size; in mwifiex_pcie_up_dev()
3395 mwifiex_pcie_alloc_buffers(adapter); in mwifiex_pcie_up_dev()
3401 static void mwifiex_pcie_down_dev(struct mwifiex_adapter *adapter) in mwifiex_pcie_down_dev() argument
3403 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_down_dev()
3407 if (mwifiex_write_reg(adapter, reg->drv_rdy, 0x00000000)) in mwifiex_pcie_down_dev()
3408 mwifiex_dbg(adapter, ERROR, "Failed to write driver not-ready signature\n"); in mwifiex_pcie_down_dev()
3412 adapter->seq_num = 0; in mwifiex_pcie_down_dev()
3414 mwifiex_pcie_free_buffers(adapter); in mwifiex_pcie_down_dev()