Lines Matching refs:adapter

52 mwifiex_map_pci_memory(struct mwifiex_adapter *adapter, struct sk_buff *skb,  in mwifiex_map_pci_memory()  argument
55 struct pcie_service_card *card = adapter->card; in mwifiex_map_pci_memory()
60 mwifiex_dbg(adapter, ERROR, "failed to map pci memory!\n"); in mwifiex_map_pci_memory()
68 static void mwifiex_unmap_pci_memory(struct mwifiex_adapter *adapter, in mwifiex_unmap_pci_memory() argument
71 struct pcie_service_card *card = adapter->card; in mwifiex_unmap_pci_memory()
81 static bool mwifiex_pcie_ok_to_access_hw(struct mwifiex_adapter *adapter) in mwifiex_pcie_ok_to_access_hw() argument
84 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_ok_to_access_hw()
92 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_ok_to_access_hw()
113 struct mwifiex_adapter *adapter; in mwifiex_pcie_suspend() local
120 if (!card || !card->adapter) { in mwifiex_pcie_suspend()
129 adapter = card->adapter; in mwifiex_pcie_suspend()
131 hs_actived = mwifiex_enable_hs(adapter); in mwifiex_pcie_suspend()
134 adapter->is_suspended = true; in mwifiex_pcie_suspend()
135 adapter->hs_enabling = false; in mwifiex_pcie_suspend()
150 struct mwifiex_adapter *adapter; in mwifiex_pcie_resume() local
156 if (!card || !card->adapter) { in mwifiex_pcie_resume()
165 adapter = card->adapter; in mwifiex_pcie_resume()
167 if (!adapter->is_suspended) { in mwifiex_pcie_resume()
168 mwifiex_dbg(adapter, WARN, in mwifiex_pcie_resume()
173 adapter->is_suspended = false; in mwifiex_pcie_resume()
175 mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA), in mwifiex_pcie_resume()
228 struct mwifiex_adapter *adapter; in mwifiex_pcie_remove() local
235 adapter = card->adapter; in mwifiex_pcie_remove()
236 if (!adapter || !adapter->priv_num) in mwifiex_pcie_remove()
241 if (adapter->is_suspended) in mwifiex_pcie_remove()
245 mwifiex_deauthenticate_all(adapter); in mwifiex_pcie_remove()
247 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); in mwifiex_pcie_remove()
254 mwifiex_remove_card(card->adapter, &add_remove_card_sem); in mwifiex_pcie_remove()
309 static int mwifiex_write_reg(struct mwifiex_adapter *adapter, int reg, u32 data) in mwifiex_write_reg() argument
311 struct pcie_service_card *card = adapter->card; in mwifiex_write_reg()
321 static int mwifiex_read_reg(struct mwifiex_adapter *adapter, int reg, u32 *data) in mwifiex_read_reg() argument
323 struct pcie_service_card *card = adapter->card; in mwifiex_read_reg()
331 static int mwifiex_read_reg_byte(struct mwifiex_adapter *adapter, in mwifiex_read_reg_byte() argument
334 struct pcie_service_card *card = adapter->card; in mwifiex_read_reg_byte()
344 static void mwifiex_pcie_dev_wakeup_delay(struct mwifiex_adapter *adapter) in mwifiex_pcie_dev_wakeup_delay() argument
348 while (mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_pcie_dev_wakeup_delay()
359 static void mwifiex_delay_for_sleep_cookie(struct mwifiex_adapter *adapter, in mwifiex_delay_for_sleep_cookie() argument
362 struct pcie_service_card *card = adapter->card; in mwifiex_delay_for_sleep_cookie()
371 mwifiex_dbg(adapter, INFO, in mwifiex_delay_for_sleep_cookie()
379 mwifiex_dbg(adapter, INFO, in mwifiex_delay_for_sleep_cookie()
384 static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter) in mwifiex_pm_wakeup_card() argument
387 struct pcie_service_card *card = adapter->card; in mwifiex_pm_wakeup_card()
390 mwifiex_dbg(adapter, EVENT, in mwifiex_pm_wakeup_card()
394 mwifiex_pcie_dev_wakeup_delay(adapter); in mwifiex_pm_wakeup_card()
397 if (mwifiex_read_reg(adapter, reg->fw_status, &fw_status)) { in mwifiex_pm_wakeup_card()
398 mwifiex_dbg(adapter, ERROR, in mwifiex_pm_wakeup_card()
404 mwifiex_pcie_dev_wakeup_delay(adapter); in mwifiex_pm_wakeup_card()
405 mwifiex_dbg(adapter, INFO, in mwifiex_pm_wakeup_card()
407 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_pm_wakeup_card()
418 static int mwifiex_pm_wakeup_card_complete(struct mwifiex_adapter *adapter) in mwifiex_pm_wakeup_card_complete() argument
420 mwifiex_dbg(adapter, CMD, in mwifiex_pm_wakeup_card_complete()
432 static int mwifiex_pcie_disable_host_int(struct mwifiex_adapter *adapter) in mwifiex_pcie_disable_host_int() argument
434 if (mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_pcie_disable_host_int()
435 if (mwifiex_write_reg(adapter, PCIE_HOST_INT_MASK, in mwifiex_pcie_disable_host_int()
437 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_disable_host_int()
452 static int mwifiex_pcie_enable_host_int(struct mwifiex_adapter *adapter) in mwifiex_pcie_enable_host_int() argument
454 if (mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_pcie_enable_host_int()
456 if (mwifiex_write_reg(adapter, PCIE_HOST_INT_MASK, in mwifiex_pcie_enable_host_int()
458 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_enable_host_int()
470 static int mwifiex_init_txq_ring(struct mwifiex_adapter *adapter) in mwifiex_init_txq_ring() argument
472 struct pcie_service_card *card = adapter->card; in mwifiex_init_txq_ring()
500 static int mwifiex_init_rxq_ring(struct mwifiex_adapter *adapter) in mwifiex_init_rxq_ring() argument
502 struct pcie_service_card *card = adapter->card; in mwifiex_init_rxq_ring()
515 mwifiex_dbg(adapter, ERROR, in mwifiex_init_rxq_ring()
521 if (mwifiex_map_pci_memory(adapter, skb, in mwifiex_init_rxq_ring()
528 mwifiex_dbg(adapter, INFO, in mwifiex_init_rxq_ring()
560 static int mwifiex_pcie_init_evt_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_init_evt_ring() argument
562 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_init_evt_ring()
572 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_init_evt_ring()
579 if (mwifiex_map_pci_memory(adapter, skb, MAX_EVENT_SIZE, in mwifiex_pcie_init_evt_ring()
585 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_init_evt_ring()
605 static void mwifiex_cleanup_txq_ring(struct mwifiex_adapter *adapter) in mwifiex_cleanup_txq_ring() argument
607 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_txq_ring()
619 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_txq_ring()
628 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_txq_ring()
643 static void mwifiex_cleanup_rxq_ring(struct mwifiex_adapter *adapter) in mwifiex_cleanup_rxq_ring() argument
645 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_rxq_ring()
657 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_rxq_ring()
666 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_rxq_ring()
681 static void mwifiex_cleanup_evt_ring(struct mwifiex_adapter *adapter) in mwifiex_cleanup_evt_ring() argument
683 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_evt_ring()
692 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_evt_ring()
705 static int mwifiex_pcie_create_txbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_create_txbd_ring() argument
707 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_create_txbd_ring()
731 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_create_txbd_ring()
738 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_create_txbd_ring()
743 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_create_txbd_ring()
749 return mwifiex_init_txq_ring(adapter); in mwifiex_pcie_create_txbd_ring()
752 static int mwifiex_pcie_delete_txbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_txbd_ring() argument
754 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_txbd_ring()
757 mwifiex_cleanup_txq_ring(adapter); in mwifiex_pcie_delete_txbd_ring()
775 static int mwifiex_pcie_create_rxbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_create_rxbd_ring() argument
777 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_create_rxbd_ring()
795 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_create_rxbd_ring()
802 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_create_rxbd_ring()
808 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_create_rxbd_ring()
814 return mwifiex_init_rxq_ring(adapter); in mwifiex_pcie_create_rxbd_ring()
820 static int mwifiex_pcie_delete_rxbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_rxbd_ring() argument
822 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_rxbd_ring()
825 mwifiex_cleanup_rxq_ring(adapter); in mwifiex_pcie_delete_rxbd_ring()
843 static int mwifiex_pcie_create_evtbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_create_evtbd_ring() argument
845 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_create_evtbd_ring()
859 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_create_evtbd_ring()
866 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_create_evtbd_ring()
872 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_create_evtbd_ring()
878 return mwifiex_pcie_init_evt_ring(adapter); in mwifiex_pcie_create_evtbd_ring()
884 static int mwifiex_pcie_delete_evtbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_evtbd_ring() argument
886 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_evtbd_ring()
889 mwifiex_cleanup_evt_ring(adapter); in mwifiex_pcie_delete_evtbd_ring()
907 static int mwifiex_pcie_alloc_cmdrsp_buf(struct mwifiex_adapter *adapter) in mwifiex_pcie_alloc_cmdrsp_buf() argument
909 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_alloc_cmdrsp_buf()
915 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_alloc_cmdrsp_buf()
920 if (mwifiex_map_pci_memory(adapter, skb, MWIFIEX_UPLD_SIZE, in mwifiex_pcie_alloc_cmdrsp_buf()
932 static int mwifiex_pcie_delete_cmdrsp_buf(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_cmdrsp_buf() argument
936 if (!adapter) in mwifiex_pcie_delete_cmdrsp_buf()
939 card = adapter->card; in mwifiex_pcie_delete_cmdrsp_buf()
942 mwifiex_unmap_pci_memory(adapter, card->cmdrsp_buf, in mwifiex_pcie_delete_cmdrsp_buf()
948 mwifiex_unmap_pci_memory(adapter, card->cmd_buf, in mwifiex_pcie_delete_cmdrsp_buf()
957 static int mwifiex_pcie_alloc_sleep_cookie_buf(struct mwifiex_adapter *adapter) in mwifiex_pcie_alloc_sleep_cookie_buf() argument
959 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_alloc_sleep_cookie_buf()
964 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_alloc_sleep_cookie_buf()
971 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_alloc_sleep_cookie_buf()
981 static int mwifiex_pcie_delete_sleep_cookie_buf(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_sleep_cookie_buf() argument
985 if (!adapter) in mwifiex_pcie_delete_sleep_cookie_buf()
988 card = adapter->card; in mwifiex_pcie_delete_sleep_cookie_buf()
1004 static int mwifiex_clean_pcie_ring_buf(struct mwifiex_adapter *adapter) in mwifiex_clean_pcie_ring_buf() argument
1006 struct pcie_service_card *card = adapter->card; in mwifiex_clean_pcie_ring_buf()
1013 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_clean_pcie_ring_buf()
1015 mwifiex_dbg(adapter, ERROR, in mwifiex_clean_pcie_ring_buf()
1026 static int mwifiex_pcie_send_data_complete(struct mwifiex_adapter *adapter) in mwifiex_pcie_send_data_complete() argument
1032 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_data_complete()
1035 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_send_data_complete()
1036 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_send_data_complete()
1039 if (mwifiex_read_reg(adapter, reg->tx_rdptr, &rdptr)) { in mwifiex_pcie_send_data_complete()
1040 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_data_complete()
1045 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data_complete()
1061 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data_complete()
1064 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_pcie_send_data_complete()
1070 mwifiex_write_data_complete(adapter, skb, 0, in mwifiex_pcie_send_data_complete()
1073 mwifiex_write_data_complete(adapter, skb, 0, 0); in mwifiex_pcie_send_data_complete()
1103 adapter->data_sent = false; in mwifiex_pcie_send_data_complete()
1109 mwifiex_clean_pcie_ring_buf(adapter); in mwifiex_pcie_send_data_complete()
1123 mwifiex_pcie_send_data(struct mwifiex_adapter *adapter, struct sk_buff *skb, in mwifiex_pcie_send_data() argument
1126 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_data()
1136 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_data()
1142 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_send_data()
1143 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_send_data()
1146 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data()
1152 adapter->data_sent = true; in mwifiex_pcie_send_data()
1159 if (mwifiex_map_pci_memory(adapter, skb, skb->len, in mwifiex_pcie_send_data()
1200 if (mwifiex_write_reg(adapter, reg->tx_wrptr, in mwifiex_pcie_send_data()
1202 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_data()
1210 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data()
1212 adapter->data_sent = false; in mwifiex_pcie_send_data()
1215 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_send_data()
1217 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_data()
1223 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data()
1228 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_send_data()
1230 adapter->data_sent = true; in mwifiex_pcie_send_data()
1232 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_send_data()
1234 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_data()
1241 mwifiex_unmap_pci_memory(adapter, skb, PCI_DMA_TODEVICE); in mwifiex_pcie_send_data()
1255 static int mwifiex_pcie_process_recv_data(struct mwifiex_adapter *adapter) in mwifiex_pcie_process_recv_data() argument
1257 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_recv_data()
1266 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_process_recv_data()
1267 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_process_recv_data()
1270 if (mwifiex_read_reg(adapter, reg->rx_wrptr, &wrptr)) { in mwifiex_pcie_process_recv_data()
1271 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_recv_data()
1295 mwifiex_unmap_pci_memory(adapter, skb_data, PCI_DMA_FROMDEVICE); in mwifiex_pcie_process_recv_data()
1305 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_recv_data()
1311 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_process_recv_data()
1315 if (adapter->rx_work_enabled) { in mwifiex_pcie_process_recv_data()
1316 skb_queue_tail(&adapter->rx_data_q, skb_data); in mwifiex_pcie_process_recv_data()
1317 adapter->data_received = true; in mwifiex_pcie_process_recv_data()
1318 atomic_inc(&adapter->rx_pending); in mwifiex_pcie_process_recv_data()
1320 mwifiex_handle_rx_packet(adapter, skb_data); in mwifiex_pcie_process_recv_data()
1327 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_recv_data()
1332 if (mwifiex_map_pci_memory(adapter, skb_tmp, in mwifiex_pcie_process_recv_data()
1339 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_process_recv_data()
1364 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_process_recv_data()
1370 if (mwifiex_write_reg(adapter, reg->rx_rdptr, in mwifiex_pcie_process_recv_data()
1372 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_process_recv_data()
1379 if (mwifiex_read_reg(adapter, reg->rx_wrptr, &wrptr)) { in mwifiex_pcie_process_recv_data()
1380 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_recv_data()
1385 mwifiex_dbg(adapter, DATA, in mwifiex_pcie_process_recv_data()
1398 mwifiex_pcie_send_boot_cmd(struct mwifiex_adapter *adapter, struct sk_buff *skb) in mwifiex_pcie_send_boot_cmd() argument
1401 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_boot_cmd()
1405 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_boot_cmd()
1411 if (mwifiex_map_pci_memory(adapter, skb, skb->len , PCI_DMA_TODEVICE)) in mwifiex_pcie_send_boot_cmd()
1419 if (mwifiex_write_reg(adapter, reg->cmd_addr_lo, (u32)buf_pa)) { in mwifiex_pcie_send_boot_cmd()
1420 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_boot_cmd()
1423 mwifiex_unmap_pci_memory(adapter, skb, PCI_DMA_TODEVICE); in mwifiex_pcie_send_boot_cmd()
1430 if (mwifiex_write_reg(adapter, reg->cmd_addr_hi, in mwifiex_pcie_send_boot_cmd()
1432 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_boot_cmd()
1435 mwifiex_unmap_pci_memory(adapter, skb, PCI_DMA_TODEVICE); in mwifiex_pcie_send_boot_cmd()
1440 if (mwifiex_write_reg(adapter, reg->cmd_size, skb->len)) { in mwifiex_pcie_send_boot_cmd()
1441 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_boot_cmd()
1444 mwifiex_unmap_pci_memory(adapter, skb, PCI_DMA_TODEVICE); in mwifiex_pcie_send_boot_cmd()
1449 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_send_boot_cmd()
1451 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_boot_cmd()
1453 mwifiex_unmap_pci_memory(adapter, skb, PCI_DMA_TODEVICE); in mwifiex_pcie_send_boot_cmd()
1463 static int mwifiex_pcie_init_fw_port(struct mwifiex_adapter *adapter) in mwifiex_pcie_init_fw_port() argument
1465 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_init_fw_port()
1470 if (mwifiex_write_reg(adapter, reg->rx_rdptr, card->rxbd_rdptr | in mwifiex_pcie_init_fw_port()
1472 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_init_fw_port()
1482 mwifiex_pcie_send_cmd(struct mwifiex_adapter *adapter, struct sk_buff *skb) in mwifiex_pcie_send_cmd() argument
1484 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_cmd()
1491 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1499 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1504 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_send_cmd()
1505 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_send_cmd()
1507 adapter->cmd_sent = true; in mwifiex_pcie_send_cmd()
1512 if (mwifiex_map_pci_memory(adapter, skb, skb->len, PCI_DMA_TODEVICE)) in mwifiex_pcie_send_cmd()
1531 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_lo, in mwifiex_pcie_send_cmd()
1533 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1540 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_hi, in mwifiex_pcie_send_cmd()
1542 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1551 if (mwifiex_write_reg(adapter, reg->cmd_addr_lo, in mwifiex_pcie_send_cmd()
1553 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1559 if (mwifiex_write_reg(adapter, reg->cmd_addr_hi, in mwifiex_pcie_send_cmd()
1561 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1568 if (mwifiex_write_reg(adapter, reg->cmd_size, in mwifiex_pcie_send_cmd()
1570 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1577 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_send_cmd()
1579 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_send_cmd()
1587 adapter->cmd_sent = false; in mwifiex_pcie_send_cmd()
1595 static int mwifiex_pcie_process_cmd_complete(struct mwifiex_adapter *adapter) in mwifiex_pcie_process_cmd_complete() argument
1597 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_cmd_complete()
1604 mwifiex_dbg(adapter, CMD, in mwifiex_pcie_process_cmd_complete()
1607 mwifiex_unmap_pci_memory(adapter, skb, PCI_DMA_FROMDEVICE); in mwifiex_pcie_process_cmd_complete()
1611 mwifiex_unmap_pci_memory(adapter, card->cmd_buf, in mwifiex_pcie_process_cmd_complete()
1621 if (!adapter->curr_cmd) { in mwifiex_pcie_process_cmd_complete()
1622 if (adapter->ps_state == PS_STATE_SLEEP_CFM) { in mwifiex_pcie_process_cmd_complete()
1623 mwifiex_process_sleep_confirm_resp(adapter, skb->data, in mwifiex_pcie_process_cmd_complete()
1625 mwifiex_pcie_enable_host_int(adapter); in mwifiex_pcie_process_cmd_complete()
1626 if (mwifiex_write_reg(adapter, in mwifiex_pcie_process_cmd_complete()
1629 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_cmd_complete()
1633 mwifiex_delay_for_sleep_cookie(adapter, in mwifiex_pcie_process_cmd_complete()
1636 mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_process_cmd_complete()
1639 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_cmd_complete()
1642 memcpy(adapter->upld_buf, skb->data, in mwifiex_pcie_process_cmd_complete()
1645 if (mwifiex_map_pci_memory(adapter, skb, MWIFIEX_UPLD_SIZE, in mwifiex_pcie_process_cmd_complete()
1648 } else if (mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_pcie_process_cmd_complete()
1649 adapter->curr_cmd->resp_skb = skb; in mwifiex_pcie_process_cmd_complete()
1650 adapter->cmd_resp_received = true; in mwifiex_pcie_process_cmd_complete()
1658 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_lo, 0)) { in mwifiex_pcie_process_cmd_complete()
1659 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_cmd_complete()
1665 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_hi, 0)) { in mwifiex_pcie_process_cmd_complete()
1666 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_cmd_complete()
1678 static int mwifiex_pcie_cmdrsp_complete(struct mwifiex_adapter *adapter, in mwifiex_pcie_cmdrsp_complete() argument
1681 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_cmdrsp_complete()
1686 if (mwifiex_map_pci_memory(adapter, skb, MWIFIEX_UPLD_SIZE, in mwifiex_pcie_cmdrsp_complete()
1697 static int mwifiex_pcie_process_event_ready(struct mwifiex_adapter *adapter) in mwifiex_pcie_process_event_ready() argument
1699 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_event_ready()
1705 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_process_event_ready()
1706 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_process_event_ready()
1708 if (adapter->event_received) { in mwifiex_pcie_process_event_ready()
1709 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_process_event_ready()
1716 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_event_ready()
1722 if (mwifiex_read_reg(adapter, reg->evt_wrptr, &wrptr)) { in mwifiex_pcie_process_event_ready()
1723 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_event_ready()
1728 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_process_event_ready()
1739 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_process_event_ready()
1742 mwifiex_unmap_pci_memory(adapter, skb_cmd, PCI_DMA_FROMDEVICE); in mwifiex_pcie_process_event_ready()
1751 adapter->event_cause = event; in mwifiex_pcie_process_event_ready()
1758 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_process_event_ready()
1762 memcpy(adapter->event_body, skb_cmd->data + in mwifiex_pcie_process_event_ready()
1766 adapter->event_received = true; in mwifiex_pcie_process_event_ready()
1767 adapter->event_skb = skb_cmd; in mwifiex_pcie_process_event_ready()
1774 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_process_event_ready()
1776 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_process_event_ready()
1788 static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter, in mwifiex_pcie_event_complete() argument
1791 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_event_complete()
1802 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_event_complete()
1809 if (mwifiex_read_reg(adapter, reg->evt_wrptr, &wrptr)) { in mwifiex_pcie_event_complete()
1810 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_event_complete()
1818 if (mwifiex_map_pci_memory(adapter, skb, in mwifiex_pcie_event_complete()
1829 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_event_complete()
1840 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_event_complete()
1845 if (mwifiex_write_reg(adapter, reg->evt_rdptr, in mwifiex_pcie_event_complete()
1847 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_event_complete()
1852 mwifiex_dbg(adapter, EVENT, in mwifiex_pcie_event_complete()
1854 ret = mwifiex_pcie_process_event_ready(adapter); in mwifiex_pcie_event_complete()
1866 static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, in mwifiex_prog_fw_w_helper() argument
1876 struct pcie_service_card *card = adapter->card; in mwifiex_prog_fw_w_helper()
1880 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
1885 mwifiex_dbg(adapter, INFO, in mwifiex_prog_fw_w_helper()
1889 if (mwifiex_pcie_disable_host_int(adapter)) { in mwifiex_prog_fw_w_helper()
1890 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
1910 ret = mwifiex_read_reg(adapter, reg->cmd_size, in mwifiex_prog_fw_w_helper()
1913 mwifiex_dbg(adapter, FATAL, in mwifiex_prog_fw_w_helper()
1925 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
1937 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
1943 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
1957 mwifiex_dbg(adapter, INFO, "."); in mwifiex_prog_fw_w_helper()
1970 if (mwifiex_pcie_send_boot_cmd(adapter, skb)) { in mwifiex_prog_fw_w_helper()
1971 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
1979 if (mwifiex_read_reg(adapter, PCIE_CPU_INT_STATUS, in mwifiex_prog_fw_w_helper()
1981 mwifiex_dbg(adapter, ERROR, in mwifiex_prog_fw_w_helper()
1985 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_prog_fw_w_helper()
1993 mwifiex_unmap_pci_memory(adapter, skb, PCI_DMA_TODEVICE); in mwifiex_prog_fw_w_helper()
1998 mwifiex_dbg(adapter, MSG, in mwifiex_prog_fw_w_helper()
2014 mwifiex_check_fw_status(struct mwifiex_adapter *adapter, u32 poll_num) in mwifiex_check_fw_status() argument
2018 struct pcie_service_card *card = adapter->card; in mwifiex_check_fw_status()
2023 if (mwifiex_write_reg(adapter, PCIE_HOST_INT_STATUS_MASK, in mwifiex_check_fw_status()
2025 mwifiex_dbg(adapter, ERROR, in mwifiex_check_fw_status()
2030 mwifiex_dbg(adapter, INFO, in mwifiex_check_fw_status()
2032 if (mwifiex_write_reg(adapter, reg->drv_rdy, in mwifiex_check_fw_status()
2034 mwifiex_dbg(adapter, ERROR, in mwifiex_check_fw_status()
2041 if (mwifiex_read_reg(adapter, reg->fw_status, in mwifiex_check_fw_status()
2058 if (mwifiex_read_reg(adapter, reg->fw_status, in mwifiex_check_fw_status()
2062 mwifiex_dbg(adapter, INFO, in mwifiex_check_fw_status()
2064 adapter->winner = 1; in mwifiex_check_fw_status()
2066 mwifiex_dbg(adapter, ERROR, in mwifiex_check_fw_status()
2068 ret, adapter->winner); in mwifiex_check_fw_status()
2078 static void mwifiex_interrupt_status(struct mwifiex_adapter *adapter) in mwifiex_interrupt_status() argument
2083 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_interrupt_status()
2086 if (mwifiex_read_reg(adapter, PCIE_HOST_INT_STATUS, &pcie_ireg)) { in mwifiex_interrupt_status()
2087 mwifiex_dbg(adapter, ERROR, "Read register failed\n"); in mwifiex_interrupt_status()
2093 mwifiex_pcie_disable_host_int(adapter); in mwifiex_interrupt_status()
2096 if (mwifiex_write_reg(adapter, PCIE_HOST_INT_STATUS, in mwifiex_interrupt_status()
2098 mwifiex_dbg(adapter, ERROR, in mwifiex_interrupt_status()
2102 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2103 adapter->int_status |= pcie_ireg; in mwifiex_interrupt_status()
2104 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2106 if (!adapter->pps_uapsd_mode && in mwifiex_interrupt_status()
2107 adapter->ps_state == PS_STATE_SLEEP && in mwifiex_interrupt_status()
2108 mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_interrupt_status()
2112 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_interrupt_status()
2113 adapter->pm_wakeup_fw_try = false; in mwifiex_interrupt_status()
2114 del_timer(&adapter->wakeup_timer); in mwifiex_interrupt_status()
2129 struct mwifiex_adapter *adapter; in mwifiex_pcie_interrupt() local
2137 if (!card || !card->adapter) { in mwifiex_pcie_interrupt()
2139 card ? card->adapter : NULL); in mwifiex_pcie_interrupt()
2142 adapter = card->adapter; in mwifiex_pcie_interrupt()
2144 if (adapter->surprise_removed) in mwifiex_pcie_interrupt()
2147 mwifiex_interrupt_status(adapter); in mwifiex_pcie_interrupt()
2148 mwifiex_queue_main_work(adapter); in mwifiex_pcie_interrupt()
2167 static int mwifiex_process_int_status(struct mwifiex_adapter *adapter) in mwifiex_process_int_status() argument
2173 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_process_int_status()
2175 pcie_ireg = adapter->int_status; in mwifiex_process_int_status()
2176 adapter->int_status = 0; in mwifiex_process_int_status()
2177 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_process_int_status()
2182 mwifiex_dbg(adapter, INTR, in mwifiex_process_int_status()
2184 ret = mwifiex_pcie_send_data_complete(adapter); in mwifiex_process_int_status()
2190 mwifiex_dbg(adapter, INTR, in mwifiex_process_int_status()
2192 ret = mwifiex_pcie_process_recv_data(adapter); in mwifiex_process_int_status()
2198 mwifiex_dbg(adapter, INTR, in mwifiex_process_int_status()
2200 ret = mwifiex_pcie_process_event_ready(adapter); in mwifiex_process_int_status()
2207 if (adapter->cmd_sent) { in mwifiex_process_int_status()
2208 mwifiex_dbg(adapter, INTR, in mwifiex_process_int_status()
2210 adapter->cmd_sent = false; in mwifiex_process_int_status()
2213 ret = mwifiex_pcie_process_cmd_complete(adapter); in mwifiex_process_int_status()
2218 if (mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_process_int_status()
2219 if (mwifiex_read_reg(adapter, PCIE_HOST_INT_STATUS, in mwifiex_process_int_status()
2221 mwifiex_dbg(adapter, ERROR, in mwifiex_process_int_status()
2227 if (mwifiex_write_reg(adapter, in mwifiex_process_int_status()
2230 mwifiex_dbg(adapter, ERROR, in mwifiex_process_int_status()
2238 mwifiex_dbg(adapter, INTR, in mwifiex_process_int_status()
2240 adapter->cmd_sent, adapter->data_sent); in mwifiex_process_int_status()
2241 if (adapter->ps_state != PS_STATE_SLEEP) in mwifiex_process_int_status()
2242 mwifiex_pcie_enable_host_int(adapter); in mwifiex_process_int_status()
2257 static int mwifiex_pcie_host_to_card(struct mwifiex_adapter *adapter, u8 type, in mwifiex_pcie_host_to_card() argument
2262 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_host_to_card()
2268 return mwifiex_pcie_send_data(adapter, skb, tx_param); in mwifiex_pcie_host_to_card()
2270 return mwifiex_pcie_send_cmd(adapter, skb); in mwifiex_pcie_host_to_card()
2277 mwifiex_pcie_rdwr_firmware(struct mwifiex_adapter *adapter, u8 doneflag) in mwifiex_pcie_rdwr_firmware() argument
2281 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_rdwr_firmware()
2284 ret = mwifiex_write_reg(adapter, reg->fw_dump_ctrl, FW_DUMP_HOST_READY); in mwifiex_pcie_rdwr_firmware()
2286 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_rdwr_firmware()
2292 mwifiex_read_reg_byte(adapter, reg->fw_dump_ctrl, &ctrl_data); in mwifiex_pcie_rdwr_firmware()
2298 mwifiex_dbg(adapter, WARN, in mwifiex_pcie_rdwr_firmware()
2300 ret = mwifiex_write_reg(adapter, reg->fw_dump_ctrl, in mwifiex_pcie_rdwr_firmware()
2303 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_rdwr_firmware()
2311 mwifiex_dbg(adapter, ERROR, "Fail to pull ctrl_data\n"); in mwifiex_pcie_rdwr_firmware()
2316 static void mwifiex_pcie_fw_dump(struct mwifiex_adapter *adapter) in mwifiex_pcie_fw_dump() argument
2318 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_fw_dump()
2339 mwifiex_dbg(adapter, DUMP, "== mwifiex firmware dump start ==\n"); in mwifiex_pcie_fw_dump()
2342 stat = mwifiex_pcie_rdwr_firmware(adapter, doneflag); in mwifiex_pcie_fw_dump()
2347 mwifiex_read_reg_byte(adapter, reg, &dump_num); in mwifiex_pcie_fw_dump()
2353 stat = mwifiex_pcie_rdwr_firmware(adapter, doneflag); in mwifiex_pcie_fw_dump()
2360 mwifiex_read_reg_byte(adapter, reg, &read_reg); in mwifiex_pcie_fw_dump()
2366 mwifiex_dbg(adapter, MSG, "Firmware dump Finished!\n"); in mwifiex_pcie_fw_dump()
2367 ret = mwifiex_write_reg(adapter, creg->fw_dump_ctrl, in mwifiex_pcie_fw_dump()
2370 mwifiex_dbg(adapter, ERROR, "PCIE write err\n"); in mwifiex_pcie_fw_dump()
2376 mwifiex_dbg(adapter, DUMP, in mwifiex_pcie_fw_dump()
2381 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_fw_dump()
2389 mwifiex_dbg(adapter, DUMP, "Start %s output, please wait...\n", in mwifiex_pcie_fw_dump()
2393 stat = mwifiex_pcie_rdwr_firmware(adapter, doneflag); in mwifiex_pcie_fw_dump()
2400 mwifiex_read_reg_byte(adapter, reg, dbg_ptr); in mwifiex_pcie_fw_dump()
2404 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_fw_dump()
2413 mwifiex_dbg(adapter, DUMP, in mwifiex_pcie_fw_dump()
2419 mwifiex_dbg(adapter, DUMP, "== mwifiex firmware dump end ==\n"); in mwifiex_pcie_fw_dump()
2422 static void mwifiex_pcie_device_dump_work(struct mwifiex_adapter *adapter) in mwifiex_pcie_device_dump_work() argument
2424 mwifiex_drv_info_dump(adapter); in mwifiex_pcie_device_dump_work()
2425 mwifiex_pcie_fw_dump(adapter); in mwifiex_pcie_device_dump_work()
2426 mwifiex_upload_device_dump(adapter); in mwifiex_pcie_device_dump_work()
2440 static void mwifiex_pcie_device_dump(struct mwifiex_adapter *adapter) in mwifiex_pcie_device_dump() argument
2442 save_adapter = adapter; in mwifiex_pcie_device_dump()
2461 static int mwifiex_pcie_init(struct mwifiex_adapter *adapter) in mwifiex_pcie_init() argument
2463 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_init()
2476 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_init()
2480 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_init()
2487 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_init()
2494 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_init()
2500 mwifiex_dbg(adapter, ERROR, "iomap(0) error\n"); in mwifiex_pcie_init()
2506 mwifiex_dbg(adapter, ERROR, "req_reg(2) error\n"); in mwifiex_pcie_init()
2511 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_init()
2517 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_init()
2522 ret = mwifiex_pcie_create_txbd_ring(adapter); in mwifiex_pcie_init()
2525 ret = mwifiex_pcie_create_rxbd_ring(adapter); in mwifiex_pcie_init()
2528 ret = mwifiex_pcie_create_evtbd_ring(adapter); in mwifiex_pcie_init()
2531 ret = mwifiex_pcie_alloc_cmdrsp_buf(adapter); in mwifiex_pcie_init()
2535 ret = mwifiex_pcie_alloc_sleep_cookie_buf(adapter); in mwifiex_pcie_init()
2544 mwifiex_pcie_delete_cmdrsp_buf(adapter); in mwifiex_pcie_init()
2546 mwifiex_pcie_delete_evtbd_ring(adapter); in mwifiex_pcie_init()
2548 mwifiex_pcie_delete_rxbd_ring(adapter); in mwifiex_pcie_init()
2550 mwifiex_pcie_delete_txbd_ring(adapter); in mwifiex_pcie_init()
2577 static void mwifiex_pcie_cleanup(struct mwifiex_adapter *adapter) in mwifiex_pcie_cleanup() argument
2579 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_cleanup()
2584 mwifiex_dbg(adapter, INFO, in mwifiex_pcie_cleanup()
2586 if (mwifiex_write_reg(adapter, reg->drv_rdy, 0x00000000)) in mwifiex_pcie_cleanup()
2587 mwifiex_dbg(adapter, ERROR, in mwifiex_pcie_cleanup()
2607 static int mwifiex_register_dev(struct mwifiex_adapter *adapter) in mwifiex_register_dev() argument
2610 struct pcie_service_card *card = adapter->card; in mwifiex_register_dev()
2614 card->adapter = adapter; in mwifiex_register_dev()
2619 mwifiex_dbg(adapter, ERROR, in mwifiex_register_dev()
2621 adapter->card = NULL; in mwifiex_register_dev()
2625 adapter->dev = &pdev->dev; in mwifiex_register_dev()
2626 adapter->tx_buf_size = card->pcie.tx_buf_size; in mwifiex_register_dev()
2627 adapter->mem_type_mapping_tbl = mem_type_mapping_tbl; in mwifiex_register_dev()
2628 adapter->num_mem_types = ARRAY_SIZE(mem_type_mapping_tbl); in mwifiex_register_dev()
2629 strcpy(adapter->fw_name, card->pcie.firmware); in mwifiex_register_dev()
2630 adapter->ext_scan = card->pcie.can_ext_scan; in mwifiex_register_dev()
2641 static void mwifiex_unregister_dev(struct mwifiex_adapter *adapter) in mwifiex_unregister_dev() argument
2643 struct pcie_service_card *card = adapter->card; in mwifiex_unregister_dev()
2647 mwifiex_dbg(adapter, INFO, in mwifiex_unregister_dev()
2653 mwifiex_pcie_delete_sleep_cookie_buf(adapter); in mwifiex_unregister_dev()
2655 mwifiex_pcie_delete_cmdrsp_buf(adapter); in mwifiex_unregister_dev()
2656 mwifiex_pcie_delete_evtbd_ring(adapter); in mwifiex_unregister_dev()
2657 mwifiex_pcie_delete_rxbd_ring(adapter); in mwifiex_unregister_dev()
2658 mwifiex_pcie_delete_txbd_ring(adapter); in mwifiex_unregister_dev()