Lines Matching refs:adapter
205 mwifiex_map_pci_memory(struct mwifiex_adapter *adapter, struct sk_buff *skb, in mwifiex_map_pci_memory() argument
208 struct pcie_service_card *card = adapter->card; in mwifiex_map_pci_memory()
213 mwifiex_dbg(adapter, ERROR, "failed to map pci memory!\n"); in mwifiex_map_pci_memory()
221 static void mwifiex_unmap_pci_memory(struct mwifiex_adapter *adapter, in mwifiex_unmap_pci_memory() argument
224 struct pcie_service_card *card = adapter->card; in mwifiex_unmap_pci_memory()
234 static int mwifiex_write_reg(struct mwifiex_adapter *adapter, int reg, u32 data) in mwifiex_write_reg() argument
236 struct pcie_service_card *card = adapter->card; in mwifiex_write_reg()
245 static int mwifiex_read_reg(struct mwifiex_adapter *adapter, int reg, u32 *data) in mwifiex_read_reg() argument
247 struct pcie_service_card *card = adapter->card; in mwifiex_read_reg()
257 static int mwifiex_read_reg_byte(struct mwifiex_adapter *adapter, in mwifiex_read_reg_byte() argument
260 struct pcie_service_card *card = adapter->card; in mwifiex_read_reg_byte()
270 static bool mwifiex_pcie_ok_to_access_hw(struct mwifiex_adapter *adapter) in mwifiex_pcie_ok_to_access_hw() argument
273 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_ok_to_access_hw()
281 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_ok_to_access_hw()
302 struct mwifiex_adapter *adapter; in mwifiex_pcie_suspend() local
309 adapter = card->adapter; in mwifiex_pcie_suspend()
310 if (!adapter) { in mwifiex_pcie_suspend()
315 mwifiex_enable_wake(adapter); in mwifiex_pcie_suspend()
318 if (!mwifiex_enable_hs(adapter)) { in mwifiex_pcie_suspend()
319 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_suspend()
321 clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags); in mwifiex_pcie_suspend()
322 mwifiex_disable_wake(adapter); in mwifiex_pcie_suspend()
326 flush_workqueue(adapter->workqueue); in mwifiex_pcie_suspend()
329 set_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_pcie_suspend()
330 clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags); in mwifiex_pcie_suspend()
345 struct mwifiex_adapter *adapter; in mwifiex_pcie_resume() local
349 if (!card->adapter) { in mwifiex_pcie_resume()
354 adapter = card->adapter; in mwifiex_pcie_resume()
356 if (!test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)) { in mwifiex_pcie_resume()
357 mwifiex_dbg(adapter, WARN, in mwifiex_pcie_resume()
362 clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_pcie_resume()
364 mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA), in mwifiex_pcie_resume()
366 mwifiex_disable_wake(adapter); in mwifiex_pcie_resume()
429 struct mwifiex_adapter *adapter; in mwifiex_pcie_remove() local
439 adapter = card->adapter; in mwifiex_pcie_remove()
440 if (!adapter || !adapter->priv_num) in mwifiex_pcie_remove()
445 ret = mwifiex_read_reg(adapter, reg->fw_status, &fw_status); in mwifiex_pcie_remove()
449 if (fw_status == FIRMWARE_READY_PCIE && !adapter->mfg_mode) { in mwifiex_pcie_remove()
450 mwifiex_deauthenticate_all(adapter); in mwifiex_pcie_remove()
452 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); in mwifiex_pcie_remove()
459 mwifiex_remove_card(adapter); in mwifiex_pcie_remove()
514 struct mwifiex_adapter *adapter = card->adapter; in mwifiex_pcie_reset_prepare() local
516 if (!adapter) { in mwifiex_pcie_reset_prepare()
522 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_reset_prepare()
526 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()
801 if (mwifiex_map_pci_memory(adapter, skb, in mwifiex_init_rxq_ring()
808 mwifiex_dbg(adapter, INFO, in mwifiex_init_rxq_ring()
840 static int mwifiex_pcie_init_evt_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_init_evt_ring() argument
842 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_init_evt_ring()
852 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()
868 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_init_evt_ring()
888 static void mwifiex_cleanup_txq_ring(struct mwifiex_adapter *adapter) in mwifiex_cleanup_txq_ring() argument
890 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_txq_ring()
902 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_txq_ring()
911 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_txq_ring()
920 atomic_set(&adapter->tx_hw_pending, 0); in mwifiex_cleanup_txq_ring()
927 static void mwifiex_cleanup_rxq_ring(struct mwifiex_adapter *adapter) in mwifiex_cleanup_rxq_ring() argument
929 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_rxq_ring()
941 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_rxq_ring()
950 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_rxq_ring()
965 static void mwifiex_cleanup_evt_ring(struct mwifiex_adapter *adapter) in mwifiex_cleanup_evt_ring() argument
967 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_evt_ring()
976 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_evt_ring()
989 static int mwifiex_pcie_create_txbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_create_txbd_ring() argument
991 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_create_txbd_ring()
1015 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_create_txbd_ring()
1023 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_create_txbd_ring()
1029 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_create_txbd_ring()
1035 return mwifiex_init_txq_ring(adapter); in mwifiex_pcie_create_txbd_ring()
1038 static int mwifiex_pcie_delete_txbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_txbd_ring() argument
1040 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_txbd_ring()
1043 mwifiex_cleanup_txq_ring(adapter); in mwifiex_pcie_delete_txbd_ring()
1061 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 return mwifiex_init_rxq_ring(adapter); in mwifiex_pcie_create_rxbd_ring()
1107 static int mwifiex_pcie_delete_rxbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_rxbd_ring() argument
1109 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_rxbd_ring()
1112 mwifiex_cleanup_rxq_ring(adapter); in mwifiex_pcie_delete_rxbd_ring()
1130 static int mwifiex_pcie_create_evtbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_create_evtbd_ring() argument
1132 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_create_evtbd_ring()
1146 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_create_evtbd_ring()
1154 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_create_evtbd_ring()
1160 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_create_evtbd_ring()
1166 return mwifiex_pcie_init_evt_ring(adapter); in mwifiex_pcie_create_evtbd_ring()
1172 static int mwifiex_pcie_delete_evtbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_evtbd_ring() argument
1174 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_evtbd_ring()
1177 mwifiex_cleanup_evt_ring(adapter); in mwifiex_pcie_delete_evtbd_ring()
1195 static int mwifiex_pcie_alloc_cmdrsp_buf(struct mwifiex_adapter *adapter) in mwifiex_pcie_alloc_cmdrsp_buf() argument
1197 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_alloc_cmdrsp_buf()
1203 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_alloc_cmdrsp_buf()
1208 if (mwifiex_map_pci_memory(adapter, skb, MWIFIEX_UPLD_SIZE, in mwifiex_pcie_alloc_cmdrsp_buf()
1222 static int mwifiex_pcie_delete_cmdrsp_buf(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_cmdrsp_buf() argument
1226 if (!adapter) in mwifiex_pcie_delete_cmdrsp_buf()
1229 card = adapter->card; in mwifiex_pcie_delete_cmdrsp_buf()
1232 mwifiex_unmap_pci_memory(adapter, card->cmdrsp_buf, in mwifiex_pcie_delete_cmdrsp_buf()
1239 mwifiex_unmap_pci_memory(adapter, card->cmd_buf, in mwifiex_pcie_delete_cmdrsp_buf()
1250 static int mwifiex_pcie_alloc_sleep_cookie_buf(struct mwifiex_adapter *adapter) in mwifiex_pcie_alloc_sleep_cookie_buf() argument
1252 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_alloc_sleep_cookie_buf()
1260 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_alloc_sleep_cookie_buf()
1268 mwifiex_dbg(adapter, INFO, "alloc_scook: sleep cookie=0x%x\n", *cookie); in mwifiex_pcie_alloc_sleep_cookie_buf()
1276 static int mwifiex_pcie_delete_sleep_cookie_buf(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_sleep_cookie_buf() argument
1280 if (!adapter) in mwifiex_pcie_delete_sleep_cookie_buf()
1283 card = adapter->card; in mwifiex_pcie_delete_sleep_cookie_buf()
1299 static int mwifiex_clean_pcie_ring_buf(struct mwifiex_adapter *adapter) in mwifiex_clean_pcie_ring_buf() argument
1301 struct pcie_service_card *card = adapter->card; in mwifiex_clean_pcie_ring_buf()
1308 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_clean_pcie_ring_buf()
1310 mwifiex_dbg(adapter, ERROR, in mwifiex_clean_pcie_ring_buf()
1321 static int mwifiex_pcie_send_data_complete(struct mwifiex_adapter *adapter) in mwifiex_pcie_send_data_complete() argument
1327 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_data_complete()
1330 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_send_data_complete()
1331 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_send_data_complete()
1334 if (mwifiex_read_reg(adapter, reg->tx_rdptr, &rdptr)) { in mwifiex_pcie_send_data_complete()
1335 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_data_complete()
1340 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data_complete()
1356 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data_complete()
1359 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_pcie_send_data_complete()
1365 mwifiex_write_data_complete(adapter, skb, 0, in mwifiex_pcie_send_data_complete()
1368 mwifiex_write_data_complete(adapter, skb, 0, 0); in mwifiex_pcie_send_data_complete()
1369 atomic_dec(&adapter->tx_hw_pending); in mwifiex_pcie_send_data_complete()
1399 adapter->data_sent = false; in mwifiex_pcie_send_data_complete()
1405 mwifiex_clean_pcie_ring_buf(adapter); in mwifiex_pcie_send_data_complete()
1419 mwifiex_pcie_send_data(struct mwifiex_adapter *adapter, struct sk_buff *skb, in mwifiex_pcie_send_data() argument
1422 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_data()
1431 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_data()
1437 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_send_data()
1438 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_send_data()
1441 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data()
1447 adapter->data_sent = true; in mwifiex_pcie_send_data()
1452 if (mwifiex_map_pci_memory(adapter, skb, skb->len, in mwifiex_pcie_send_data()
1459 atomic_inc(&adapter->tx_hw_pending); in mwifiex_pcie_send_data()
1494 if (mwifiex_write_reg(adapter, reg->tx_wrptr, in mwifiex_pcie_send_data()
1496 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_data()
1507 mwifiex_read_reg(adapter, PCI_VENDOR_ID, &rx_val); in mwifiex_pcie_send_data()
1512 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data()
1514 adapter->data_sent = false; in mwifiex_pcie_send_data()
1517 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_send_data()
1519 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_data()
1525 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data()
1530 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data()
1532 adapter->data_sent = true; in mwifiex_pcie_send_data()
1534 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_send_data()
1536 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_data()
1543 mwifiex_unmap_pci_memory(adapter, skb, DMA_TO_DEVICE); in mwifiex_pcie_send_data()
1545 atomic_dec(&adapter->tx_hw_pending); in mwifiex_pcie_send_data()
1558 static int mwifiex_pcie_process_recv_data(struct mwifiex_adapter *adapter) in mwifiex_pcie_process_recv_data() argument
1560 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_recv_data()
1569 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_process_recv_data()
1570 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_process_recv_data()
1573 if (mwifiex_read_reg(adapter, reg->rx_wrptr, &wrptr)) { in mwifiex_pcie_process_recv_data()
1574 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_recv_data()
1597 mwifiex_unmap_pci_memory(adapter, skb_data, DMA_FROM_DEVICE); in mwifiex_pcie_process_recv_data()
1604 if (WARN_ON(rx_len <= adapter->intf_hdr_len || in mwifiex_pcie_process_recv_data()
1606 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_recv_data()
1612 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_process_recv_data()
1615 skb_pull(skb_data, adapter->intf_hdr_len); in mwifiex_pcie_process_recv_data()
1616 if (adapter->rx_work_enabled) { in mwifiex_pcie_process_recv_data()
1617 skb_queue_tail(&adapter->rx_data_q, skb_data); in mwifiex_pcie_process_recv_data()
1618 adapter->data_received = true; in mwifiex_pcie_process_recv_data()
1619 atomic_inc(&adapter->rx_pending); in mwifiex_pcie_process_recv_data()
1621 mwifiex_handle_rx_packet(adapter, skb_data); in mwifiex_pcie_process_recv_data()
1628 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_recv_data()
1633 if (mwifiex_map_pci_memory(adapter, skb_tmp, in mwifiex_pcie_process_recv_data()
1640 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_process_recv_data()
1665 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_process_recv_data()
1671 if (mwifiex_write_reg(adapter, reg->rx_rdptr, in mwifiex_pcie_process_recv_data()
1673 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_process_recv_data()
1680 if (mwifiex_read_reg(adapter, reg->rx_wrptr, &wrptr)) { in mwifiex_pcie_process_recv_data()
1681 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_recv_data()
1686 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_process_recv_data()
1699 mwifiex_pcie_send_boot_cmd(struct mwifiex_adapter *adapter, struct sk_buff *skb) in mwifiex_pcie_send_boot_cmd() argument
1702 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_boot_cmd()
1706 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_boot_cmd()
1712 if (mwifiex_map_pci_memory(adapter, skb, skb->len, DMA_TO_DEVICE)) in mwifiex_pcie_send_boot_cmd()
1720 if (mwifiex_write_reg(adapter, reg->cmd_addr_lo, (u32)buf_pa)) { in mwifiex_pcie_send_boot_cmd()
1721 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_boot_cmd()
1724 mwifiex_unmap_pci_memory(adapter, skb, DMA_TO_DEVICE); in mwifiex_pcie_send_boot_cmd()
1731 if (mwifiex_write_reg(adapter, reg->cmd_addr_hi, in mwifiex_pcie_send_boot_cmd()
1733 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_boot_cmd()
1736 mwifiex_unmap_pci_memory(adapter, skb, DMA_TO_DEVICE); in mwifiex_pcie_send_boot_cmd()
1741 if (mwifiex_write_reg(adapter, reg->cmd_size, skb->len)) { in mwifiex_pcie_send_boot_cmd()
1742 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_boot_cmd()
1745 mwifiex_unmap_pci_memory(adapter, skb, DMA_TO_DEVICE); in mwifiex_pcie_send_boot_cmd()
1750 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_send_boot_cmd()
1752 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_boot_cmd()
1754 mwifiex_unmap_pci_memory(adapter, skb, DMA_TO_DEVICE); in mwifiex_pcie_send_boot_cmd()
1764 static int mwifiex_pcie_init_fw_port(struct mwifiex_adapter *adapter) in mwifiex_pcie_init_fw_port() argument
1766 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_init_fw_port()
1771 if (mwifiex_write_reg(adapter, reg->rx_rdptr, card->rxbd_rdptr | in mwifiex_pcie_init_fw_port()
1773 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_init_fw_port()
1783 mwifiex_pcie_send_cmd(struct mwifiex_adapter *adapter, struct sk_buff *skb) in mwifiex_pcie_send_cmd() argument
1785 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_cmd()
1792 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1800 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1805 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_send_cmd()
1806 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_send_cmd()
1808 adapter->cmd_sent = true; in mwifiex_pcie_send_cmd()
1813 if (mwifiex_map_pci_memory(adapter, skb, skb->len, DMA_TO_DEVICE)) in mwifiex_pcie_send_cmd()
1837 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_lo, in mwifiex_pcie_send_cmd()
1839 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1846 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_hi, in mwifiex_pcie_send_cmd()
1848 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1857 if (mwifiex_write_reg(adapter, reg->cmd_addr_lo, in mwifiex_pcie_send_cmd()
1859 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1865 if (mwifiex_write_reg(adapter, reg->cmd_addr_hi, in mwifiex_pcie_send_cmd()
1867 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1874 if (mwifiex_write_reg(adapter, reg->cmd_size, in mwifiex_pcie_send_cmd()
1876 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1883 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_send_cmd()
1885 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1893 adapter->cmd_sent = false; in mwifiex_pcie_send_cmd()
1901 static int mwifiex_pcie_process_cmd_complete(struct mwifiex_adapter *adapter) in mwifiex_pcie_process_cmd_complete() argument
1903 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_cmd_complete()
1909 mwifiex_dbg(adapter, CMD, in mwifiex_pcie_process_cmd_complete()
1912 if (adapter->curr_cmd) in mwifiex_pcie_process_cmd_complete()
1913 mwifiex_unmap_pci_memory(adapter, skb, DMA_FROM_DEVICE); in mwifiex_pcie_process_cmd_complete()
1921 mwifiex_unmap_pci_memory(adapter, card->cmd_buf, in mwifiex_pcie_process_cmd_complete()
1931 if (!adapter->curr_cmd) { in mwifiex_pcie_process_cmd_complete()
1932 if (adapter->ps_state == PS_STATE_SLEEP_CFM) { in mwifiex_pcie_process_cmd_complete()
1937 if (mwifiex_write_reg(adapter, in mwifiex_pcie_process_cmd_complete()
1940 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_cmd_complete()
1944 mwifiex_delay_for_sleep_cookie(adapter, in mwifiex_pcie_process_cmd_complete()
1946 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_pcie_process_cmd_complete()
1948 skb_pull(skb, adapter->intf_hdr_len); in mwifiex_pcie_process_cmd_complete()
1950 mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_process_cmd_complete()
1952 mwifiex_pcie_enable_host_int(adapter); in mwifiex_pcie_process_cmd_complete()
1953 mwifiex_process_sleep_confirm_resp(adapter, skb->data, in mwifiex_pcie_process_cmd_complete()
1956 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_cmd_complete()
1959 memcpy(adapter->upld_buf, skb->data, in mwifiex_pcie_process_cmd_complete()
1961 skb_push(skb, adapter->intf_hdr_len); in mwifiex_pcie_process_cmd_complete()
1962 if (mwifiex_map_pci_memory(adapter, skb, MWIFIEX_UPLD_SIZE, in mwifiex_pcie_process_cmd_complete()
1965 } else if (mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_pcie_process_cmd_complete()
1966 skb_pull(skb, adapter->intf_hdr_len); in mwifiex_pcie_process_cmd_complete()
1967 adapter->curr_cmd->resp_skb = skb; in mwifiex_pcie_process_cmd_complete()
1968 adapter->cmd_resp_received = true; in mwifiex_pcie_process_cmd_complete()
1976 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_lo, 0)) { in mwifiex_pcie_process_cmd_complete()
1977 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_cmd_complete()
1983 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_hi, 0)) { in mwifiex_pcie_process_cmd_complete()
1984 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_cmd_complete()
1996 static int mwifiex_pcie_cmdrsp_complete(struct mwifiex_adapter *adapter, in mwifiex_pcie_cmdrsp_complete() argument
1999 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_cmdrsp_complete()
2003 skb_push(card->cmdrsp_buf, adapter->intf_hdr_len); in mwifiex_pcie_cmdrsp_complete()
2004 if (mwifiex_map_pci_memory(adapter, skb, MWIFIEX_UPLD_SIZE, in mwifiex_pcie_cmdrsp_complete()
2015 static int mwifiex_pcie_process_event_ready(struct mwifiex_adapter *adapter) in mwifiex_pcie_process_event_ready() argument
2017 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_event_ready()
2023 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_process_event_ready()
2024 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_process_event_ready()
2026 if (adapter->event_received) { in mwifiex_pcie_process_event_ready()
2027 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_process_event_ready()
2034 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_event_ready()
2040 if (mwifiex_read_reg(adapter, reg->evt_wrptr, &wrptr)) { in mwifiex_pcie_process_event_ready()
2041 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_event_ready()
2046 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_process_event_ready()
2057 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_process_event_ready()
2060 mwifiex_unmap_pci_memory(adapter, skb_cmd, DMA_FROM_DEVICE); in mwifiex_pcie_process_event_ready()
2069 &skb_cmd->data[adapter->intf_hdr_len]); in mwifiex_pcie_process_event_ready()
2070 adapter->event_cause = event; in mwifiex_pcie_process_event_ready()
2076 skb_pull(skb_cmd, adapter->intf_hdr_len); in mwifiex_pcie_process_event_ready()
2077 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_process_event_ready()
2082 memcpy(adapter->event_body, skb_cmd->data + in mwifiex_pcie_process_event_ready()
2086 adapter->event_received = true; in mwifiex_pcie_process_event_ready()
2087 adapter->event_skb = skb_cmd; in mwifiex_pcie_process_event_ready()
2094 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_process_event_ready()
2096 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_event_ready()
2108 static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter, in mwifiex_pcie_event_complete() argument
2111 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_event_complete()
2122 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_event_complete()
2129 if (mwifiex_read_reg(adapter, reg->evt_wrptr, &wrptr)) { in mwifiex_pcie_event_complete()
2130 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_event_complete()
2136 skb_push(skb, adapter->intf_hdr_len); in mwifiex_pcie_event_complete()
2138 if (mwifiex_map_pci_memory(adapter, skb, in mwifiex_pcie_event_complete()
2149 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_event_complete()
2160 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_event_complete()
2165 if (mwifiex_write_reg(adapter, reg->evt_rdptr, in mwifiex_pcie_event_complete()
2167 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_event_complete()
2172 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_event_complete()
2174 ret = mwifiex_pcie_process_event_ready(adapter); in mwifiex_pcie_event_complete()
2189 static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter, in mwifiex_extract_wifi_fw() argument
2200 mwifiex_dbg(adapter, ERROR, in mwifiex_extract_wifi_fw()
2216 mwifiex_dbg(adapter, ERROR, "bad FW parse\n"); in mwifiex_extract_wifi_fw()
2223 mwifiex_dbg(adapter, MSG, in mwifiex_extract_wifi_fw()
2229 mwifiex_dbg(adapter, ERROR, in mwifiex_extract_wifi_fw()
2240 mwifiex_dbg(adapter, ERROR, "bad FW parse\n"); in mwifiex_extract_wifi_fw()
2250 mwifiex_dbg(adapter, ERROR, "bad FW parse\n"); in mwifiex_extract_wifi_fw()
2256 mwifiex_dbg(adapter, ERROR, in mwifiex_extract_wifi_fw()
2268 mwifiex_dbg(adapter, ERROR, "unknown dnld_cmd %d\n", in mwifiex_extract_wifi_fw()
2286 static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, in mwifiex_prog_fw_w_helper() argument
2296 struct pcie_service_card *card = adapter->card; in mwifiex_prog_fw_w_helper()
2300 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
2305 mwifiex_dbg(adapter, INFO, in mwifiex_prog_fw_w_helper()
2309 if (mwifiex_pcie_disable_host_int(adapter)) { in mwifiex_prog_fw_w_helper()
2310 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
2321 ret = mwifiex_read_reg(adapter, PCIE_SCRATCH_13_REG, &val); in mwifiex_prog_fw_w_helper()
2323 mwifiex_dbg(adapter, FATAL, "Failed to read scratch register 13\n"); in mwifiex_prog_fw_w_helper()
2329 ret = mwifiex_extract_wifi_fw(adapter, firmware, firmware_len); in mwifiex_prog_fw_w_helper()
2331 mwifiex_dbg(adapter, ERROR, "Failed to extract wifi fw\n"); in mwifiex_prog_fw_w_helper()
2335 mwifiex_dbg(adapter, MSG, in mwifiex_prog_fw_w_helper()
2348 ret = mwifiex_read_reg(adapter, reg->cmd_size, in mwifiex_prog_fw_w_helper()
2351 mwifiex_dbg(adapter, FATAL, in mwifiex_prog_fw_w_helper()
2363 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
2375 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
2381 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
2406 if (mwifiex_pcie_send_boot_cmd(adapter, skb)) { in mwifiex_prog_fw_w_helper()
2407 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
2415 if (mwifiex_read_reg(adapter, PCIE_CPU_INT_STATUS, in mwifiex_prog_fw_w_helper()
2417 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
2421 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_prog_fw_w_helper()
2431 mwifiex_dbg(adapter, ERROR, "%s: Card failed to ACK download\n", in mwifiex_prog_fw_w_helper()
2433 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_prog_fw_w_helper()
2439 mwifiex_unmap_pci_memory(adapter, skb, DMA_TO_DEVICE); in mwifiex_prog_fw_w_helper()
2444 mwifiex_dbg(adapter, MSG, in mwifiex_prog_fw_w_helper()
2458 mwifiex_check_fw_status(struct mwifiex_adapter *adapter, u32 poll_num) in mwifiex_check_fw_status() argument
2462 struct pcie_service_card *card = adapter->card; in mwifiex_check_fw_status()
2467 if (mwifiex_write_reg(adapter, PCIE_HOST_INT_STATUS_MASK, in mwifiex_check_fw_status()
2469 mwifiex_dbg(adapter, ERROR, in mwifiex_check_fw_status()
2474 mwifiex_dbg(adapter, INFO, in mwifiex_check_fw_status()
2476 if (mwifiex_write_reg(adapter, reg->drv_rdy, in mwifiex_check_fw_status()
2478 mwifiex_dbg(adapter, ERROR, in mwifiex_check_fw_status()
2485 if (mwifiex_read_reg(adapter, reg->fw_status, in mwifiex_check_fw_status()
2491 mwifiex_dbg(adapter, INFO, "Try %d if FW is ready <%d,%#x>", in mwifiex_check_fw_status()
2511 mwifiex_check_winner_status(struct mwifiex_adapter *adapter) in mwifiex_check_winner_status() argument
2515 struct pcie_service_card *card = adapter->card; in mwifiex_check_winner_status()
2518 if (mwifiex_read_reg(adapter, reg->fw_status, &winner)) { in mwifiex_check_winner_status()
2521 mwifiex_dbg(adapter, INFO, "PCI-E is the winner\n"); in mwifiex_check_winner_status()
2522 adapter->winner = 1; in mwifiex_check_winner_status()
2524 mwifiex_dbg(adapter, ERROR, in mwifiex_check_winner_status()
2534 static void mwifiex_interrupt_status(struct mwifiex_adapter *adapter, in mwifiex_interrupt_status() argument
2539 struct pcie_service_card *card = adapter->card; in mwifiex_interrupt_status()
2542 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2543 adapter->int_status = 1; in mwifiex_interrupt_status()
2544 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2548 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_interrupt_status()
2554 if (mwifiex_read_reg(adapter, PCIE_HOST_INT_STATUS, in mwifiex_interrupt_status()
2556 mwifiex_dbg(adapter, ERROR, "Read register failed\n"); in mwifiex_interrupt_status()
2564 mwifiex_pcie_disable_host_int(adapter); in mwifiex_interrupt_status()
2567 if (mwifiex_write_reg(adapter, PCIE_HOST_INT_STATUS, in mwifiex_interrupt_status()
2569 mwifiex_dbg(adapter, ERROR, in mwifiex_interrupt_status()
2575 if (!adapter->pps_uapsd_mode && in mwifiex_interrupt_status()
2576 adapter->ps_state == PS_STATE_SLEEP && in mwifiex_interrupt_status()
2577 mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_interrupt_status()
2582 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_interrupt_status()
2583 adapter->pm_wakeup_fw_try = false; in mwifiex_interrupt_status()
2584 del_timer(&adapter->wakeup_timer); in mwifiex_interrupt_status()
2587 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2588 adapter->int_status |= pcie_ireg; in mwifiex_interrupt_status()
2589 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2590 mwifiex_dbg(adapter, INTR, "ireg: 0x%08x\n", pcie_ireg); in mwifiex_interrupt_status()
2604 struct mwifiex_adapter *adapter; in mwifiex_pcie_interrupt() local
2608 if (!card->adapter) { in mwifiex_pcie_interrupt()
2610 card ? card->adapter : NULL); in mwifiex_pcie_interrupt()
2613 adapter = card->adapter; in mwifiex_pcie_interrupt()
2615 if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags)) in mwifiex_pcie_interrupt()
2619 mwifiex_interrupt_status(adapter, ctx->msg_id); in mwifiex_pcie_interrupt()
2621 mwifiex_interrupt_status(adapter, -1); in mwifiex_pcie_interrupt()
2623 mwifiex_queue_main_work(adapter); in mwifiex_pcie_interrupt()
2642 static int mwifiex_process_int_status(struct mwifiex_adapter *adapter) in mwifiex_process_int_status() argument
2647 struct pcie_service_card *card = adapter->card; in mwifiex_process_int_status()
2649 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_process_int_status()
2652 pcie_ireg = adapter->int_status; in mwifiex_process_int_status()
2654 adapter->int_status = 0; in mwifiex_process_int_status()
2655 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_process_int_status()
2658 if (mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_process_int_status()
2659 if (mwifiex_read_reg(adapter, PCIE_HOST_INT_STATUS, in mwifiex_process_int_status()
2661 mwifiex_dbg(adapter, ERROR, in mwifiex_process_int_status()
2667 if (mwifiex_write_reg(adapter, in mwifiex_process_int_status()
2670 mwifiex_dbg(adapter, ERROR, in mwifiex_process_int_status()
2674 if (!adapter->pps_uapsd_mode && in mwifiex_process_int_status()
2675 adapter->ps_state == PS_STATE_SLEEP) { in mwifiex_process_int_status()
2676 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_process_int_status()
2677 adapter->pm_wakeup_fw_try = false; in mwifiex_process_int_status()
2678 del_timer(&adapter->wakeup_timer); in mwifiex_process_int_status()
2685 mwifiex_dbg(adapter, INTR, "info: TX DNLD Done\n"); in mwifiex_process_int_status()
2686 ret = mwifiex_pcie_send_data_complete(adapter); in mwifiex_process_int_status()
2691 mwifiex_dbg(adapter, INTR, "info: Rx DATA\n"); in mwifiex_process_int_status()
2692 ret = mwifiex_pcie_process_recv_data(adapter); in mwifiex_process_int_status()
2697 mwifiex_dbg(adapter, INTR, "info: Rx EVENT\n"); in mwifiex_process_int_status()
2698 ret = mwifiex_pcie_process_event_ready(adapter); in mwifiex_process_int_status()
2703 if (adapter->cmd_sent) { in mwifiex_process_int_status()
2704 mwifiex_dbg(adapter, INTR, in mwifiex_process_int_status()
2706 adapter->cmd_sent = false; in mwifiex_process_int_status()
2709 ret = mwifiex_pcie_process_cmd_complete(adapter); in mwifiex_process_int_status()
2714 mwifiex_dbg(adapter, INTR, in mwifiex_process_int_status()
2716 adapter->cmd_sent, adapter->data_sent); in mwifiex_process_int_status()
2718 adapter->ps_state != PS_STATE_SLEEP) in mwifiex_process_int_status()
2719 mwifiex_pcie_enable_host_int(adapter); in mwifiex_process_int_status()
2734 static int mwifiex_pcie_host_to_card(struct mwifiex_adapter *adapter, u8 type, in mwifiex_pcie_host_to_card() argument
2739 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_host_to_card()
2745 return mwifiex_pcie_send_data(adapter, skb, tx_param); in mwifiex_pcie_host_to_card()
2747 return mwifiex_pcie_send_cmd(adapter, skb); in mwifiex_pcie_host_to_card()
2755 mwifiex_pcie_reg_dump(struct mwifiex_adapter *adapter, char *drv_buf) in mwifiex_pcie_reg_dump() argument
2761 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_reg_dump()
2770 mwifiex_dbg(adapter, MSG, "PCIE register dump start\n"); in mwifiex_pcie_reg_dump()
2772 if (mwifiex_read_reg(adapter, reg->fw_status, &value)) { in mwifiex_pcie_reg_dump()
2773 mwifiex_dbg(adapter, ERROR, "failed to read firmware status"); in mwifiex_pcie_reg_dump()
2778 mwifiex_dbg(adapter, MSG, "pcie scratch register:"); in mwifiex_pcie_reg_dump()
2780 mwifiex_read_reg(adapter, pcie_scratch_reg[i], &value); in mwifiex_pcie_reg_dump()
2785 mwifiex_dbg(adapter, MSG, "%s\n", buf); in mwifiex_pcie_reg_dump()
2788 mwifiex_dbg(adapter, MSG, "PCIE register dump end\n"); in mwifiex_pcie_reg_dump()
2795 mwifiex_pcie_rdwr_firmware(struct mwifiex_adapter *adapter, u8 doneflag) in mwifiex_pcie_rdwr_firmware() argument
2800 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_rdwr_firmware()
2803 if (mwifiex_read_reg(adapter, reg->fw_status, &fw_status)) in mwifiex_pcie_rdwr_firmware()
2806 ret = mwifiex_write_reg(adapter, reg->fw_dump_ctrl, in mwifiex_pcie_rdwr_firmware()
2809 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_rdwr_firmware()
2815 mwifiex_read_reg_byte(adapter, reg->fw_dump_ctrl, &ctrl_data); in mwifiex_pcie_rdwr_firmware()
2821 mwifiex_dbg(adapter, WARN, in mwifiex_pcie_rdwr_firmware()
2823 ret = mwifiex_write_reg(adapter, reg->fw_dump_ctrl, in mwifiex_pcie_rdwr_firmware()
2826 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_rdwr_firmware()
2834 mwifiex_dbg(adapter, ERROR, "Fail to pull ctrl_data\n"); in mwifiex_pcie_rdwr_firmware()
2839 static void mwifiex_pcie_fw_dump(struct mwifiex_adapter *adapter) in mwifiex_pcie_fw_dump() argument
2841 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_fw_dump()
2853 for (idx = 0; idx < adapter->num_mem_types; idx++) { in mwifiex_pcie_fw_dump()
2855 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_pcie_fw_dump()
2864 mwifiex_dbg(adapter, MSG, "== mwifiex firmware dump start ==\n"); in mwifiex_pcie_fw_dump()
2867 stat = mwifiex_pcie_rdwr_firmware(adapter, doneflag); in mwifiex_pcie_fw_dump()
2872 mwifiex_read_reg_byte(adapter, reg, &fw_dump_num); in mwifiex_pcie_fw_dump()
2883 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_pcie_fw_dump()
2886 stat = mwifiex_pcie_rdwr_firmware(adapter, doneflag); in mwifiex_pcie_fw_dump()
2892 mwifiex_read_reg_byte(adapter, reg, &read_reg); in mwifiex_pcie_fw_dump()
2901 mwifiex_dbg(adapter, MSG, "Firmware dump Finished!\n"); in mwifiex_pcie_fw_dump()
2902 ret = mwifiex_write_reg(adapter, creg->fw_dump_ctrl, in mwifiex_pcie_fw_dump()
2905 mwifiex_dbg(adapter, ERROR, "PCIE write err\n"); in mwifiex_pcie_fw_dump()
2911 mwifiex_dbg(adapter, DUMP, in mwifiex_pcie_fw_dump()
2916 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_fw_dump()
2924 mwifiex_dbg(adapter, DUMP, "Start %s output, please wait...\n", in mwifiex_pcie_fw_dump()
2928 stat = mwifiex_pcie_rdwr_firmware(adapter, doneflag); in mwifiex_pcie_fw_dump()
2935 mwifiex_read_reg_byte(adapter, reg, dbg_ptr); in mwifiex_pcie_fw_dump()
2940 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_fw_dump()
2958 mwifiex_dbg(adapter, DUMP, in mwifiex_pcie_fw_dump()
2964 mwifiex_dbg(adapter, MSG, "== mwifiex firmware dump end ==\n"); in mwifiex_pcie_fw_dump()
2967 static void mwifiex_pcie_device_dump_work(struct mwifiex_adapter *adapter) in mwifiex_pcie_device_dump_work() argument
2969 adapter->devdump_data = vzalloc(MWIFIEX_FW_DUMP_SIZE); in mwifiex_pcie_device_dump_work()
2970 if (!adapter->devdump_data) { in mwifiex_pcie_device_dump_work()
2971 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_device_dump_work()
2976 mwifiex_drv_info_dump(adapter); in mwifiex_pcie_device_dump_work()
2977 mwifiex_pcie_fw_dump(adapter); in mwifiex_pcie_device_dump_work()
2978 mwifiex_prepare_fw_dump_info(adapter); in mwifiex_pcie_device_dump_work()
2979 mwifiex_upload_device_dump(adapter); in mwifiex_pcie_device_dump_work()
2982 static void mwifiex_pcie_card_reset_work(struct mwifiex_adapter *adapter) in mwifiex_pcie_card_reset_work() argument
2984 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_card_reset_work()
2999 mwifiex_pcie_device_dump_work(card->adapter); in mwifiex_pcie_work()
3002 mwifiex_pcie_card_reset_work(card->adapter); in mwifiex_pcie_work()
3006 static void mwifiex_pcie_device_dump(struct mwifiex_adapter *adapter) in mwifiex_pcie_device_dump() argument
3008 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_device_dump()
3015 static void mwifiex_pcie_card_reset(struct mwifiex_adapter *adapter) in mwifiex_pcie_card_reset() argument
3017 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_card_reset()
3023 static int mwifiex_pcie_alloc_buffers(struct mwifiex_adapter *adapter) in mwifiex_pcie_alloc_buffers() argument
3025 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_alloc_buffers()
3030 ret = mwifiex_pcie_create_txbd_ring(adapter); in mwifiex_pcie_alloc_buffers()
3032 mwifiex_dbg(adapter, ERROR, "Failed to create txbd ring\n"); in mwifiex_pcie_alloc_buffers()
3036 ret = mwifiex_pcie_create_rxbd_ring(adapter); in mwifiex_pcie_alloc_buffers()
3038 mwifiex_dbg(adapter, ERROR, "Failed to create rxbd ring\n"); in mwifiex_pcie_alloc_buffers()
3042 ret = mwifiex_pcie_create_evtbd_ring(adapter); in mwifiex_pcie_alloc_buffers()
3044 mwifiex_dbg(adapter, ERROR, "Failed to create evtbd ring\n"); in mwifiex_pcie_alloc_buffers()
3048 ret = mwifiex_pcie_alloc_cmdrsp_buf(adapter); in mwifiex_pcie_alloc_buffers()
3050 mwifiex_dbg(adapter, ERROR, "Failed to allocate cmdbuf buffer\n"); in mwifiex_pcie_alloc_buffers()
3055 ret = mwifiex_pcie_alloc_sleep_cookie_buf(adapter); in mwifiex_pcie_alloc_buffers()
3057 mwifiex_dbg(adapter, ERROR, "Failed to allocate sleep_cookie buffer\n"); in mwifiex_pcie_alloc_buffers()
3067 mwifiex_pcie_delete_cmdrsp_buf(adapter); in mwifiex_pcie_alloc_buffers()
3069 mwifiex_pcie_delete_evtbd_ring(adapter); in mwifiex_pcie_alloc_buffers()
3071 mwifiex_pcie_delete_rxbd_ring(adapter); in mwifiex_pcie_alloc_buffers()
3073 mwifiex_pcie_delete_txbd_ring(adapter); in mwifiex_pcie_alloc_buffers()
3078 static void mwifiex_pcie_free_buffers(struct mwifiex_adapter *adapter) in mwifiex_pcie_free_buffers() argument
3080 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_free_buffers()
3084 mwifiex_pcie_delete_sleep_cookie_buf(adapter); in mwifiex_pcie_free_buffers()
3086 mwifiex_pcie_delete_cmdrsp_buf(adapter); in mwifiex_pcie_free_buffers()
3087 mwifiex_pcie_delete_evtbd_ring(adapter); in mwifiex_pcie_free_buffers()
3088 mwifiex_pcie_delete_rxbd_ring(adapter); in mwifiex_pcie_free_buffers()
3089 mwifiex_pcie_delete_txbd_ring(adapter); in mwifiex_pcie_free_buffers()
3095 static int mwifiex_init_pcie(struct mwifiex_adapter *adapter) in mwifiex_init_pcie() argument
3097 struct pcie_service_card *card = adapter->card; in mwifiex_init_pcie()
3141 ret = mwifiex_pcie_alloc_buffers(adapter); in mwifiex_init_pcie()
3165 static void mwifiex_cleanup_pcie(struct mwifiex_adapter *adapter) in mwifiex_cleanup_pcie() argument
3167 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_pcie()
3179 mwifiex_dbg(adapter, MSG, "performing cancel_work_sync()...\n"); in mwifiex_cleanup_pcie()
3181 mwifiex_dbg(adapter, MSG, "cancel_work_sync() done\n"); in mwifiex_cleanup_pcie()
3183 mwifiex_dbg(adapter, MSG, in mwifiex_cleanup_pcie()
3187 ret = mwifiex_read_reg(adapter, reg->fw_status, &fw_status); in mwifiex_cleanup_pcie()
3189 mwifiex_dbg(adapter, INFO, in mwifiex_cleanup_pcie()
3191 if (mwifiex_write_reg(adapter, reg->drv_rdy, 0x00000000)) in mwifiex_cleanup_pcie()
3192 mwifiex_dbg(adapter, ERROR, in mwifiex_cleanup_pcie()
3203 mwifiex_pcie_free_buffers(adapter); in mwifiex_cleanup_pcie()
3206 static int mwifiex_pcie_request_irq(struct mwifiex_adapter *adapter) in mwifiex_pcie_request_irq() argument
3209 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_request_irq()
3231 mwifiex_dbg(adapter, INFO, "request_irq fail: %d\n", in mwifiex_pcie_request_irq()
3238 mwifiex_dbg(adapter, MSG, "MSIx enabled!"); in mwifiex_pcie_request_irq()
3250 mwifiex_dbg(adapter, INFO, "msi_enable = %d\n", card->msi_enable); in mwifiex_pcie_request_irq()
3269 static void mwifiex_pcie_get_fw_name(struct mwifiex_adapter *adapter) in mwifiex_pcie_get_fw_name() argument
3273 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_get_fw_name()
3277 strcpy(adapter->fw_name, PCIE8766_DEFAULT_FW_NAME); in mwifiex_pcie_get_fw_name()
3280 mwifiex_write_reg(adapter, 0x0c58, 0x80c00000); in mwifiex_pcie_get_fw_name()
3281 mwifiex_read_reg(adapter, 0x0c58, &revision_id); in mwifiex_pcie_get_fw_name()
3285 strcpy(adapter->fw_name, PCIE8897_A0_FW_NAME); in mwifiex_pcie_get_fw_name()
3288 strcpy(adapter->fw_name, PCIE8897_B0_FW_NAME); in mwifiex_pcie_get_fw_name()
3291 strcpy(adapter->fw_name, PCIE8897_DEFAULT_FW_NAME); in mwifiex_pcie_get_fw_name()
3297 mwifiex_read_reg(adapter, 0x8, &revision_id); in mwifiex_pcie_get_fw_name()
3298 mwifiex_read_reg(adapter, 0x0cd0, &version); in mwifiex_pcie_get_fw_name()
3299 mwifiex_read_reg(adapter, 0x0cd4, &magic); in mwifiex_pcie_get_fw_name()
3306 strcpy(adapter->fw_name, PCIEUART8997_FW_NAME_V4); in mwifiex_pcie_get_fw_name()
3308 strcpy(adapter->fw_name, PCIEUSB8997_FW_NAME_V4); in mwifiex_pcie_get_fw_name()
3320 static int mwifiex_register_dev(struct mwifiex_adapter *adapter) in mwifiex_register_dev() argument
3322 struct pcie_service_card *card = adapter->card; in mwifiex_register_dev()
3325 card->adapter = adapter; in mwifiex_register_dev()
3327 if (mwifiex_pcie_request_irq(adapter)) in mwifiex_register_dev()
3330 adapter->tx_buf_size = card->pcie.tx_buf_size; in mwifiex_register_dev()
3331 adapter->mem_type_mapping_tbl = card->pcie.mem_type_mapping_tbl; in mwifiex_register_dev()
3332 adapter->num_mem_types = card->pcie.num_mem_types; in mwifiex_register_dev()
3333 adapter->ext_scan = card->pcie.can_ext_scan; in mwifiex_register_dev()
3334 mwifiex_pcie_get_fw_name(adapter); in mwifiex_register_dev()
3345 static void mwifiex_unregister_dev(struct mwifiex_adapter *adapter) in mwifiex_unregister_dev() argument
3347 struct pcie_service_card *card = adapter->card; in mwifiex_unregister_dev()
3362 mwifiex_dbg(adapter, INFO, in mwifiex_unregister_dev()
3369 card->adapter = NULL; in mwifiex_unregister_dev()
3376 static void mwifiex_pcie_up_dev(struct mwifiex_adapter *adapter) in mwifiex_pcie_up_dev() argument
3378 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_up_dev()
3384 adapter->tx_buf_size = card->pcie.tx_buf_size; in mwifiex_pcie_up_dev()
3386 mwifiex_pcie_alloc_buffers(adapter); in mwifiex_pcie_up_dev()
3392 static void mwifiex_pcie_down_dev(struct mwifiex_adapter *adapter) in mwifiex_pcie_down_dev() argument
3394 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_down_dev()
3398 if (mwifiex_write_reg(adapter, reg->drv_rdy, 0x00000000)) in mwifiex_pcie_down_dev()
3399 mwifiex_dbg(adapter, ERROR, "Failed to write driver not-ready signature\n"); in mwifiex_pcie_down_dev()
3403 adapter->seq_num = 0; in mwifiex_pcie_down_dev()
3405 mwifiex_pcie_free_buffers(adapter); in mwifiex_pcie_down_dev()