Lines Matching +full:no +full:- +full:read +full:- +full:rollover

4  * Copyright 2011-2020 NXP
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
14 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
193 if (!of_match_node(mwifiex_pcie_of_match_table, dev->of_node)) { in mwifiex_pcie_probe_of()
195 return -EINVAL; in mwifiex_pcie_probe_of()
207 struct pcie_service_card *card = adapter->card; in mwifiex_map_pci_memory()
210 mapping.addr = dma_map_single(&card->dev->dev, skb->data, size, flags); in mwifiex_map_pci_memory()
211 if (dma_mapping_error(&card->dev->dev, mapping.addr)) { in mwifiex_map_pci_memory()
213 return -1; in mwifiex_map_pci_memory()
223 struct pcie_service_card *card = adapter->card; in mwifiex_unmap_pci_memory()
227 dma_unmap_single(&card->dev->dev, mapping.addr, mapping.len, flags); in mwifiex_unmap_pci_memory()
235 struct pcie_service_card *card = adapter->card; in mwifiex_write_reg()
237 iowrite32(data, card->pci_mmap1 + reg); in mwifiex_write_reg()
246 struct pcie_service_card *card = adapter->card; in mwifiex_read_reg()
248 *data = ioread32(card->pci_mmap1 + reg); in mwifiex_read_reg()
259 struct pcie_service_card *card = adapter->card; in mwifiex_read_reg_byte()
261 *data = ioread8(card->pci_mmap1 + reg); in mwifiex_read_reg_byte()
272 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_ok_to_access_hw()
273 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_ok_to_access_hw()
275 if (!reg->sleep_cookie) in mwifiex_pcie_ok_to_access_hw()
278 if (card->sleep_cookie_vbase) { in mwifiex_pcie_ok_to_access_hw()
279 cookie_value = get_unaligned_le32(card->sleep_cookie_vbase); in mwifiex_pcie_ok_to_access_hw()
306 wait_for_completion(&card->fw_done); in mwifiex_pcie_suspend()
308 adapter = card->adapter; in mwifiex_pcie_suspend()
320 clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags); in mwifiex_pcie_suspend()
322 return -EFAULT; in mwifiex_pcie_suspend()
325 flush_workqueue(adapter->workqueue); in mwifiex_pcie_suspend()
328 set_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_pcie_suspend()
329 clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags); in mwifiex_pcie_suspend()
348 if (!card->adapter) { in mwifiex_pcie_resume()
353 adapter = card->adapter; in mwifiex_pcie_resume()
355 if (!test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)) { in mwifiex_pcie_resume()
361 clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_pcie_resume()
384 pdev->vendor, pdev->device, pdev->revision); in mwifiex_pcie_probe()
386 card = devm_kzalloc(&pdev->dev, sizeof(*card), GFP_KERNEL); in mwifiex_pcie_probe()
388 return -ENOMEM; in mwifiex_pcie_probe()
390 init_completion(&card->fw_done); in mwifiex_pcie_probe()
392 card->dev = pdev; in mwifiex_pcie_probe()
394 if (ent->driver_data) { in mwifiex_pcie_probe()
395 struct mwifiex_pcie_device *data = (void *)ent->driver_data; in mwifiex_pcie_probe()
396 card->pcie.reg = data->reg; in mwifiex_pcie_probe()
397 card->pcie.blksz_fw_dl = data->blksz_fw_dl; in mwifiex_pcie_probe()
398 card->pcie.tx_buf_size = data->tx_buf_size; in mwifiex_pcie_probe()
399 card->pcie.can_dump_fw = data->can_dump_fw; in mwifiex_pcie_probe()
400 card->pcie.mem_type_mapping_tbl = data->mem_type_mapping_tbl; in mwifiex_pcie_probe()
401 card->pcie.num_mem_types = data->num_mem_types; in mwifiex_pcie_probe()
402 card->pcie.can_ext_scan = data->can_ext_scan; in mwifiex_pcie_probe()
403 INIT_WORK(&card->work, mwifiex_pcie_work); in mwifiex_pcie_probe()
407 if (pdev->dev.of_node) { in mwifiex_pcie_probe()
408 ret = mwifiex_pcie_probe_of(&pdev->dev); in mwifiex_pcie_probe()
413 if (mwifiex_add_card(card, &card->fw_done, &pcie_ops, in mwifiex_pcie_probe()
414 MWIFIEX_PCIE, &pdev->dev)) { in mwifiex_pcie_probe()
416 return -1; in mwifiex_pcie_probe()
436 wait_for_completion(&card->fw_done); in mwifiex_pcie_remove()
438 adapter = card->adapter; in mwifiex_pcie_remove()
439 if (!adapter || !adapter->priv_num) in mwifiex_pcie_remove()
442 reg = card->pcie.reg; in mwifiex_pcie_remove()
444 ret = mwifiex_read_reg(adapter, reg->fw_status, &fw_status); in mwifiex_pcie_remove()
446 fw_status = -1; in mwifiex_pcie_remove()
448 if (fw_status == FIRMWARE_READY_PCIE && !adapter->mfg_mode) { in mwifiex_pcie_remove()
477 &card->work_flags)) in mwifiex_pcie_coredump()
478 schedule_work(&card->work); in mwifiex_pcie_coredump()
513 struct mwifiex_adapter *adapter = card->adapter; in mwifiex_pcie_reset_prepare()
516 dev_err(&pdev->dev, "%s: adapter structure is not valid\n", in mwifiex_pcie_reset_prepare()
522 "%s: vendor=0x%4.04x device=0x%4.04x rev=%d Pre-FLR\n", in mwifiex_pcie_reset_prepare()
523 __func__, pdev->vendor, pdev->device, pdev->revision); in mwifiex_pcie_reset_prepare()
526 clear_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags); in mwifiex_pcie_reset_prepare()
527 clear_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags); in mwifiex_pcie_reset_prepare()
539 struct mwifiex_adapter *adapter = card->adapter; in mwifiex_pcie_reset_done()
543 dev_err(&pdev->dev, "%s: adapter structure is not valid\n", in mwifiex_pcie_reset_done()
549 "%s: vendor=0x%4.04x device=0x%4.04x rev=%d Post-FLR\n", in mwifiex_pcie_reset_done()
550 __func__, pdev->vendor, pdev->device, pdev->revision); in mwifiex_pcie_reset_done()
554 dev_err(&pdev->dev, "reinit failed: %d\n", ret); in mwifiex_pcie_reset_done()
607 struct pcie_service_card *card = adapter->card; in mwifiex_delay_for_sleep_cookie()
610 struct sk_buff *cmdrsp = card->cmdrsp_buf; in mwifiex_delay_for_sleep_cookie()
613 dma_sync_single_for_cpu(&card->dev->dev, in mwifiex_delay_for_sleep_cookie()
616 buffer = cmdrsp->data; in mwifiex_delay_for_sleep_cookie()
624 dma_sync_single_for_device(&card->dev->dev, in mwifiex_delay_for_sleep_cookie()
639 struct pcie_service_card *card = adapter->card; in mwifiex_pm_wakeup_card()
640 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pm_wakeup_card()
645 if (reg->sleep_cookie) in mwifiex_pm_wakeup_card()
649 if (mwifiex_write_reg(adapter, reg->fw_status, FIRMWARE_READY_PCIE)) { in mwifiex_pm_wakeup_card()
652 return -1; in mwifiex_pm_wakeup_card()
655 if (reg->sleep_cookie) { in mwifiex_pm_wakeup_card()
659 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_pm_wakeup_card()
681 * The host interrupt mask is read, the disable bit is reset and
691 return -1; in mwifiex_pcie_disable_host_int()
695 atomic_set(&adapter->tx_hw_pending, 0); in mwifiex_pcie_disable_host_int()
718 return -1; in mwifiex_pcie_enable_host_int()
730 struct pcie_service_card *card = adapter->card; in mwifiex_init_txq_ring()
731 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_init_txq_ring()
737 card->tx_buf_list[i] = NULL; in mwifiex_init_txq_ring()
738 if (reg->pfu_enabled) { in mwifiex_init_txq_ring()
739 card->txbd_ring[i] = (void *)card->txbd_ring_vbase + in mwifiex_init_txq_ring()
741 desc2 = card->txbd_ring[i]; in mwifiex_init_txq_ring()
744 card->txbd_ring[i] = (void *)card->txbd_ring_vbase + in mwifiex_init_txq_ring()
746 desc = card->txbd_ring[i]; in mwifiex_init_txq_ring()
760 struct pcie_service_card *card = adapter->card; in mwifiex_init_rxq_ring()
761 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_init_rxq_ring()
775 kfree(card->rxbd_ring_vbase); in mwifiex_init_rxq_ring()
776 return -ENOMEM; in mwifiex_init_rxq_ring()
782 return -1; in mwifiex_init_rxq_ring()
788 skb, skb->len, skb->data, (u32)buf_pa, in mwifiex_init_rxq_ring()
791 card->rx_buf_list[i] = skb; in mwifiex_init_rxq_ring()
792 if (reg->pfu_enabled) { in mwifiex_init_rxq_ring()
793 card->rxbd_ring[i] = (void *)card->rxbd_ring_vbase + in mwifiex_init_rxq_ring()
795 desc2 = card->rxbd_ring[i]; in mwifiex_init_rxq_ring()
796 desc2->paddr = buf_pa; in mwifiex_init_rxq_ring()
797 desc2->len = (u16)skb->len; in mwifiex_init_rxq_ring()
798 desc2->frag_len = (u16)skb->len; in mwifiex_init_rxq_ring()
799 desc2->flags = reg->ring_flag_eop | reg->ring_flag_sop; in mwifiex_init_rxq_ring()
800 desc2->offset = 0; in mwifiex_init_rxq_ring()
802 card->rxbd_ring[i] = (void *)(card->rxbd_ring_vbase + in mwifiex_init_rxq_ring()
804 desc = card->rxbd_ring[i]; in mwifiex_init_rxq_ring()
805 desc->paddr = buf_pa; in mwifiex_init_rxq_ring()
806 desc->len = (u16)skb->len; in mwifiex_init_rxq_ring()
807 desc->flags = 0; in mwifiex_init_rxq_ring()
820 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_init_evt_ring()
832 kfree(card->evtbd_ring_vbase); in mwifiex_pcie_init_evt_ring()
833 return -ENOMEM; in mwifiex_pcie_init_evt_ring()
840 kfree(card->evtbd_ring_vbase); in mwifiex_pcie_init_evt_ring()
841 return -1; in mwifiex_pcie_init_evt_ring()
848 skb, skb->len, skb->data, (u32)buf_pa, in mwifiex_pcie_init_evt_ring()
851 card->evt_buf_list[i] = skb; in mwifiex_pcie_init_evt_ring()
852 card->evtbd_ring[i] = (void *)(card->evtbd_ring_vbase + in mwifiex_pcie_init_evt_ring()
854 desc = card->evtbd_ring[i]; in mwifiex_pcie_init_evt_ring()
855 desc->paddr = buf_pa; in mwifiex_pcie_init_evt_ring()
856 desc->len = (u16)skb->len; in mwifiex_pcie_init_evt_ring()
857 desc->flags = 0; in mwifiex_pcie_init_evt_ring()
868 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_txq_ring()
869 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_cleanup_txq_ring()
876 if (reg->pfu_enabled) { in mwifiex_cleanup_txq_ring()
877 desc2 = card->txbd_ring[i]; in mwifiex_cleanup_txq_ring()
878 if (card->tx_buf_list[i]) { in mwifiex_cleanup_txq_ring()
879 skb = card->tx_buf_list[i]; in mwifiex_cleanup_txq_ring()
886 desc = card->txbd_ring[i]; in mwifiex_cleanup_txq_ring()
887 if (card->tx_buf_list[i]) { in mwifiex_cleanup_txq_ring()
888 skb = card->tx_buf_list[i]; in mwifiex_cleanup_txq_ring()
895 card->tx_buf_list[i] = NULL; in mwifiex_cleanup_txq_ring()
898 atomic_set(&adapter->tx_hw_pending, 0); in mwifiex_cleanup_txq_ring()
907 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_rxq_ring()
908 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_cleanup_rxq_ring()
915 if (reg->pfu_enabled) { in mwifiex_cleanup_rxq_ring()
916 desc2 = card->rxbd_ring[i]; in mwifiex_cleanup_rxq_ring()
917 if (card->rx_buf_list[i]) { in mwifiex_cleanup_rxq_ring()
918 skb = card->rx_buf_list[i]; in mwifiex_cleanup_rxq_ring()
925 desc = card->rxbd_ring[i]; in mwifiex_cleanup_rxq_ring()
926 if (card->rx_buf_list[i]) { in mwifiex_cleanup_rxq_ring()
927 skb = card->rx_buf_list[i]; in mwifiex_cleanup_rxq_ring()
934 card->rx_buf_list[i] = NULL; in mwifiex_cleanup_rxq_ring()
945 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_evt_ring()
951 desc = card->evtbd_ring[i]; in mwifiex_cleanup_evt_ring()
952 if (card->evt_buf_list[i]) { in mwifiex_cleanup_evt_ring()
953 skb = card->evt_buf_list[i]; in mwifiex_cleanup_evt_ring()
958 card->evt_buf_list[i] = NULL; in mwifiex_cleanup_evt_ring()
969 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_create_txbd_ring()
970 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_create_txbd_ring()
973 * driver maintaines the write pointer and firmware maintaines the read in mwifiex_pcie_create_txbd_ring()
974 * pointer. The write pointer starts at 0 (zero) while the read pointer in mwifiex_pcie_create_txbd_ring()
975 * starts at zero with rollover bit set in mwifiex_pcie_create_txbd_ring()
977 card->txbd_wrptr = 0; in mwifiex_pcie_create_txbd_ring()
979 if (reg->pfu_enabled) in mwifiex_pcie_create_txbd_ring()
980 card->txbd_rdptr = 0; in mwifiex_pcie_create_txbd_ring()
982 card->txbd_rdptr |= reg->tx_rollover_ind; in mwifiex_pcie_create_txbd_ring()
986 if (reg->pfu_enabled) in mwifiex_pcie_create_txbd_ring()
987 card->txbd_ring_size = sizeof(struct mwifiex_pfu_buf_desc) * in mwifiex_pcie_create_txbd_ring()
990 card->txbd_ring_size = sizeof(struct mwifiex_pcie_buf_desc) * in mwifiex_pcie_create_txbd_ring()
995 card->txbd_ring_size); in mwifiex_pcie_create_txbd_ring()
996 card->txbd_ring_vbase = dma_alloc_coherent(&card->dev->dev, in mwifiex_pcie_create_txbd_ring()
997 card->txbd_ring_size, in mwifiex_pcie_create_txbd_ring()
998 &card->txbd_ring_pbase, in mwifiex_pcie_create_txbd_ring()
1000 if (!card->txbd_ring_vbase) { in mwifiex_pcie_create_txbd_ring()
1003 card->txbd_ring_size); in mwifiex_pcie_create_txbd_ring()
1004 return -ENOMEM; in mwifiex_pcie_create_txbd_ring()
1008 "info: txbd_ring - base: %p, pbase: %#x:%x, len: %#x\n", in mwifiex_pcie_create_txbd_ring()
1009 card->txbd_ring_vbase, (u32)card->txbd_ring_pbase, in mwifiex_pcie_create_txbd_ring()
1010 (u32)((u64)card->txbd_ring_pbase >> 32), in mwifiex_pcie_create_txbd_ring()
1011 card->txbd_ring_size); in mwifiex_pcie_create_txbd_ring()
1018 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_txbd_ring()
1019 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_delete_txbd_ring()
1023 if (card->txbd_ring_vbase) in mwifiex_pcie_delete_txbd_ring()
1024 dma_free_coherent(&card->dev->dev, card->txbd_ring_size, in mwifiex_pcie_delete_txbd_ring()
1025 card->txbd_ring_vbase, in mwifiex_pcie_delete_txbd_ring()
1026 card->txbd_ring_pbase); in mwifiex_pcie_delete_txbd_ring()
1027 card->txbd_ring_size = 0; in mwifiex_pcie_delete_txbd_ring()
1028 card->txbd_wrptr = 0; in mwifiex_pcie_delete_txbd_ring()
1029 card->txbd_rdptr = 0 | reg->tx_rollover_ind; in mwifiex_pcie_delete_txbd_ring()
1030 card->txbd_ring_vbase = NULL; in mwifiex_pcie_delete_txbd_ring()
1031 card->txbd_ring_pbase = 0; in mwifiex_pcie_delete_txbd_ring()
1041 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_create_rxbd_ring()
1042 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_create_rxbd_ring()
1045 * driver maintaines the read pointer and firmware maintaines the write in mwifiex_pcie_create_rxbd_ring()
1046 * pointer. The write pointer starts at 0 (zero) while the read pointer in mwifiex_pcie_create_rxbd_ring()
1047 * starts at zero with rollover bit set in mwifiex_pcie_create_rxbd_ring()
1049 card->rxbd_wrptr = 0; in mwifiex_pcie_create_rxbd_ring()
1050 card->rxbd_rdptr = reg->rx_rollover_ind; in mwifiex_pcie_create_rxbd_ring()
1052 if (reg->pfu_enabled) in mwifiex_pcie_create_rxbd_ring()
1053 card->rxbd_ring_size = sizeof(struct mwifiex_pfu_buf_desc) * in mwifiex_pcie_create_rxbd_ring()
1056 card->rxbd_ring_size = sizeof(struct mwifiex_pcie_buf_desc) * in mwifiex_pcie_create_rxbd_ring()
1061 card->rxbd_ring_size); in mwifiex_pcie_create_rxbd_ring()
1062 card->rxbd_ring_vbase = dma_alloc_coherent(&card->dev->dev, in mwifiex_pcie_create_rxbd_ring()
1063 card->rxbd_ring_size, in mwifiex_pcie_create_rxbd_ring()
1064 &card->rxbd_ring_pbase, in mwifiex_pcie_create_rxbd_ring()
1066 if (!card->rxbd_ring_vbase) { in mwifiex_pcie_create_rxbd_ring()
1069 card->rxbd_ring_size); in mwifiex_pcie_create_rxbd_ring()
1070 return -ENOMEM; in mwifiex_pcie_create_rxbd_ring()
1074 "info: rxbd_ring - base: %p, pbase: %#x:%x, len: %#x\n", in mwifiex_pcie_create_rxbd_ring()
1075 card->rxbd_ring_vbase, (u32)card->rxbd_ring_pbase, in mwifiex_pcie_create_rxbd_ring()
1076 (u32)((u64)card->rxbd_ring_pbase >> 32), in mwifiex_pcie_create_rxbd_ring()
1077 card->rxbd_ring_size); in mwifiex_pcie_create_rxbd_ring()
1087 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_rxbd_ring()
1088 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_delete_rxbd_ring()
1092 if (card->rxbd_ring_vbase) in mwifiex_pcie_delete_rxbd_ring()
1093 dma_free_coherent(&card->dev->dev, card->rxbd_ring_size, in mwifiex_pcie_delete_rxbd_ring()
1094 card->rxbd_ring_vbase, in mwifiex_pcie_delete_rxbd_ring()
1095 card->rxbd_ring_pbase); in mwifiex_pcie_delete_rxbd_ring()
1096 card->rxbd_ring_size = 0; in mwifiex_pcie_delete_rxbd_ring()
1097 card->rxbd_wrptr = 0; in mwifiex_pcie_delete_rxbd_ring()
1098 card->rxbd_rdptr = 0 | reg->rx_rollover_ind; in mwifiex_pcie_delete_rxbd_ring()
1099 card->rxbd_ring_vbase = NULL; in mwifiex_pcie_delete_rxbd_ring()
1100 card->rxbd_ring_pbase = 0; in mwifiex_pcie_delete_rxbd_ring()
1110 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_create_evtbd_ring()
1111 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_create_evtbd_ring()
1114 * driver maintaines the read pointer and firmware maintaines the write in mwifiex_pcie_create_evtbd_ring()
1115 * pointer. The write pointer starts at 0 (zero) while the read pointer in mwifiex_pcie_create_evtbd_ring()
1116 * starts at zero with rollover bit set in mwifiex_pcie_create_evtbd_ring()
1118 card->evtbd_wrptr = 0; in mwifiex_pcie_create_evtbd_ring()
1119 card->evtbd_rdptr = reg->evt_rollover_ind; in mwifiex_pcie_create_evtbd_ring()
1121 card->evtbd_ring_size = sizeof(struct mwifiex_evt_buf_desc) * in mwifiex_pcie_create_evtbd_ring()
1126 card->evtbd_ring_size); in mwifiex_pcie_create_evtbd_ring()
1127 card->evtbd_ring_vbase = dma_alloc_coherent(&card->dev->dev, in mwifiex_pcie_create_evtbd_ring()
1128 card->evtbd_ring_size, in mwifiex_pcie_create_evtbd_ring()
1129 &card->evtbd_ring_pbase, in mwifiex_pcie_create_evtbd_ring()
1131 if (!card->evtbd_ring_vbase) { in mwifiex_pcie_create_evtbd_ring()
1134 card->evtbd_ring_size); in mwifiex_pcie_create_evtbd_ring()
1135 return -ENOMEM; in mwifiex_pcie_create_evtbd_ring()
1139 "info: CMDRSP/EVT bd_ring - base: %p pbase: %#x:%x len: %#x\n", in mwifiex_pcie_create_evtbd_ring()
1140 card->evtbd_ring_vbase, (u32)card->evtbd_ring_pbase, in mwifiex_pcie_create_evtbd_ring()
1141 (u32)((u64)card->evtbd_ring_pbase >> 32), in mwifiex_pcie_create_evtbd_ring()
1142 card->evtbd_ring_size); in mwifiex_pcie_create_evtbd_ring()
1152 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_evtbd_ring()
1153 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_delete_evtbd_ring()
1157 if (card->evtbd_ring_vbase) in mwifiex_pcie_delete_evtbd_ring()
1158 dma_free_coherent(&card->dev->dev, card->evtbd_ring_size, in mwifiex_pcie_delete_evtbd_ring()
1159 card->evtbd_ring_vbase, in mwifiex_pcie_delete_evtbd_ring()
1160 card->evtbd_ring_pbase); in mwifiex_pcie_delete_evtbd_ring()
1161 card->evtbd_wrptr = 0; in mwifiex_pcie_delete_evtbd_ring()
1162 card->evtbd_rdptr = 0 | reg->evt_rollover_ind; in mwifiex_pcie_delete_evtbd_ring()
1163 card->evtbd_ring_size = 0; in mwifiex_pcie_delete_evtbd_ring()
1164 card->evtbd_ring_vbase = NULL; in mwifiex_pcie_delete_evtbd_ring()
1165 card->evtbd_ring_pbase = 0; in mwifiex_pcie_delete_evtbd_ring()
1175 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_alloc_cmdrsp_buf()
1183 return -ENOMEM; in mwifiex_pcie_alloc_cmdrsp_buf()
1189 return -1; in mwifiex_pcie_alloc_cmdrsp_buf()
1192 card->cmdrsp_buf = skb; in mwifiex_pcie_alloc_cmdrsp_buf()
1207 card = adapter->card; in mwifiex_pcie_delete_cmdrsp_buf()
1209 if (card && card->cmdrsp_buf) { in mwifiex_pcie_delete_cmdrsp_buf()
1210 mwifiex_unmap_pci_memory(adapter, card->cmdrsp_buf, in mwifiex_pcie_delete_cmdrsp_buf()
1212 dev_kfree_skb_any(card->cmdrsp_buf); in mwifiex_pcie_delete_cmdrsp_buf()
1213 card->cmdrsp_buf = NULL; in mwifiex_pcie_delete_cmdrsp_buf()
1216 if (card && card->cmd_buf) { in mwifiex_pcie_delete_cmdrsp_buf()
1217 mwifiex_unmap_pci_memory(adapter, card->cmd_buf, in mwifiex_pcie_delete_cmdrsp_buf()
1219 dev_kfree_skb_any(card->cmd_buf); in mwifiex_pcie_delete_cmdrsp_buf()
1220 card->cmd_buf = NULL; in mwifiex_pcie_delete_cmdrsp_buf()
1230 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_alloc_sleep_cookie_buf()
1233 card->sleep_cookie_vbase = dma_alloc_coherent(&card->dev->dev, in mwifiex_pcie_alloc_sleep_cookie_buf()
1235 &card->sleep_cookie_pbase, in mwifiex_pcie_alloc_sleep_cookie_buf()
1237 if (!card->sleep_cookie_vbase) { in mwifiex_pcie_alloc_sleep_cookie_buf()
1240 return -ENOMEM; in mwifiex_pcie_alloc_sleep_cookie_buf()
1244 put_unaligned(tmp, card->sleep_cookie_vbase); in mwifiex_pcie_alloc_sleep_cookie_buf()
1248 get_unaligned(card->sleep_cookie_vbase)); in mwifiex_pcie_alloc_sleep_cookie_buf()
1263 card = adapter->card; in mwifiex_pcie_delete_sleep_cookie_buf()
1265 if (card && card->sleep_cookie_vbase) { in mwifiex_pcie_delete_sleep_cookie_buf()
1266 dma_free_coherent(&card->dev->dev, sizeof(u32), in mwifiex_pcie_delete_sleep_cookie_buf()
1267 card->sleep_cookie_vbase, in mwifiex_pcie_delete_sleep_cookie_buf()
1268 card->sleep_cookie_pbase); in mwifiex_pcie_delete_sleep_cookie_buf()
1269 card->sleep_cookie_vbase = NULL; in mwifiex_pcie_delete_sleep_cookie_buf()
1281 struct pcie_service_card *card = adapter->card; in mwifiex_clean_pcie_ring_buf()
1283 if (!mwifiex_pcie_txbd_empty(card, card->txbd_rdptr)) { in mwifiex_clean_pcie_ring_buf()
1284 card->txbd_flush = 1; in mwifiex_clean_pcie_ring_buf()
1286 * send dnld-rdy intr again, wait for completion. in mwifiex_clean_pcie_ring_buf()
1291 "failed to assert dnld-rdy interrupt.\n"); in mwifiex_clean_pcie_ring_buf()
1292 return -1; in mwifiex_clean_pcie_ring_buf()
1307 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_data_complete()
1308 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_send_data_complete()
1313 /* Read the TX ring read pointer set by firmware */ in mwifiex_pcie_send_data_complete()
1314 if (mwifiex_read_reg(adapter, reg->tx_rdptr, &rdptr)) { in mwifiex_pcie_send_data_complete()
1316 "SEND COMP: failed to read reg->tx_rdptr\n"); in mwifiex_pcie_send_data_complete()
1317 return -1; in mwifiex_pcie_send_data_complete()
1322 card->txbd_rdptr, rdptr); in mwifiex_pcie_send_data_complete()
1324 num_tx_buffs = MWIFIEX_MAX_TXRX_BD << reg->tx_start_ptr; in mwifiex_pcie_send_data_complete()
1326 while (((card->txbd_rdptr & reg->tx_mask) != in mwifiex_pcie_send_data_complete()
1327 (rdptr & reg->tx_mask)) || in mwifiex_pcie_send_data_complete()
1328 ((card->txbd_rdptr & reg->tx_rollover_ind) != in mwifiex_pcie_send_data_complete()
1329 (rdptr & reg->tx_rollover_ind))) { in mwifiex_pcie_send_data_complete()
1330 wrdoneidx = (card->txbd_rdptr & reg->tx_mask) >> in mwifiex_pcie_send_data_complete()
1331 reg->tx_start_ptr; in mwifiex_pcie_send_data_complete()
1333 skb = card->tx_buf_list[wrdoneidx]; in mwifiex_pcie_send_data_complete()
1344 if (card->txbd_flush) in mwifiex_pcie_send_data_complete()
1346 -1); in mwifiex_pcie_send_data_complete()
1349 atomic_dec(&adapter->tx_hw_pending); in mwifiex_pcie_send_data_complete()
1352 card->tx_buf_list[wrdoneidx] = NULL; in mwifiex_pcie_send_data_complete()
1354 if (reg->pfu_enabled) { in mwifiex_pcie_send_data_complete()
1355 desc2 = card->txbd_ring[wrdoneidx]; in mwifiex_pcie_send_data_complete()
1358 desc = card->txbd_ring[wrdoneidx]; in mwifiex_pcie_send_data_complete()
1361 switch (card->dev->device) { in mwifiex_pcie_send_data_complete()
1363 card->txbd_rdptr++; in mwifiex_pcie_send_data_complete()
1367 card->txbd_rdptr += reg->ring_tx_start_ptr; in mwifiex_pcie_send_data_complete()
1372 if ((card->txbd_rdptr & reg->tx_mask) == num_tx_buffs) in mwifiex_pcie_send_data_complete()
1373 card->txbd_rdptr = ((card->txbd_rdptr & in mwifiex_pcie_send_data_complete()
1374 reg->tx_rollover_ind) ^ in mwifiex_pcie_send_data_complete()
1375 reg->tx_rollover_ind); in mwifiex_pcie_send_data_complete()
1379 adapter->data_sent = false; in mwifiex_pcie_send_data_complete()
1381 if (card->txbd_flush) { in mwifiex_pcie_send_data_complete()
1382 if (mwifiex_pcie_txbd_empty(card, card->txbd_rdptr)) in mwifiex_pcie_send_data_complete()
1383 card->txbd_flush = 0; in mwifiex_pcie_send_data_complete()
1402 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_data()
1403 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_send_data()
1410 if (!(skb->data && skb->len)) { in mwifiex_pcie_send_data()
1413 __func__, skb->data, skb->len); in mwifiex_pcie_send_data()
1414 return -1; in mwifiex_pcie_send_data()
1420 num_tx_buffs = MWIFIEX_MAX_TXRX_BD << reg->tx_start_ptr; in mwifiex_pcie_send_data()
1423 card->txbd_rdptr, card->txbd_wrptr); in mwifiex_pcie_send_data()
1427 adapter->data_sent = true; in mwifiex_pcie_send_data()
1428 payload = skb->data; in mwifiex_pcie_send_data()
1429 put_unaligned_le16((u16)skb->len, payload + 0); in mwifiex_pcie_send_data()
1432 if (mwifiex_map_pci_memory(adapter, skb, skb->len, in mwifiex_pcie_send_data()
1434 return -1; in mwifiex_pcie_send_data()
1436 wrindx = (card->txbd_wrptr & reg->tx_mask) >> reg->tx_start_ptr; in mwifiex_pcie_send_data()
1438 card->tx_buf_list[wrindx] = skb; in mwifiex_pcie_send_data()
1439 atomic_inc(&adapter->tx_hw_pending); in mwifiex_pcie_send_data()
1441 if (reg->pfu_enabled) { in mwifiex_pcie_send_data()
1442 desc2 = card->txbd_ring[wrindx]; in mwifiex_pcie_send_data()
1443 desc2->paddr = buf_pa; in mwifiex_pcie_send_data()
1444 desc2->len = (u16)skb->len; in mwifiex_pcie_send_data()
1445 desc2->frag_len = (u16)skb->len; in mwifiex_pcie_send_data()
1446 desc2->offset = 0; in mwifiex_pcie_send_data()
1447 desc2->flags = MWIFIEX_BD_FLAG_FIRST_DESC | in mwifiex_pcie_send_data()
1450 desc = card->txbd_ring[wrindx]; in mwifiex_pcie_send_data()
1451 desc->paddr = buf_pa; in mwifiex_pcie_send_data()
1452 desc->len = (u16)skb->len; in mwifiex_pcie_send_data()
1453 desc->flags = MWIFIEX_BD_FLAG_FIRST_DESC | in mwifiex_pcie_send_data()
1457 switch (card->dev->device) { in mwifiex_pcie_send_data()
1459 card->txbd_wrptr++; in mwifiex_pcie_send_data()
1463 card->txbd_wrptr += reg->ring_tx_start_ptr; in mwifiex_pcie_send_data()
1467 if ((card->txbd_wrptr & reg->tx_mask) == num_tx_buffs) in mwifiex_pcie_send_data()
1468 card->txbd_wrptr = ((card->txbd_wrptr & in mwifiex_pcie_send_data()
1469 reg->tx_rollover_ind) ^ in mwifiex_pcie_send_data()
1470 reg->tx_rollover_ind); in mwifiex_pcie_send_data()
1472 rx_val = card->rxbd_rdptr & reg->rx_wrap_mask; in mwifiex_pcie_send_data()
1473 /* Write the TX ring write pointer in to reg->tx_wrptr */ in mwifiex_pcie_send_data()
1474 if (mwifiex_write_reg(adapter, reg->tx_wrptr, in mwifiex_pcie_send_data()
1475 card->txbd_wrptr | rx_val)) { in mwifiex_pcie_send_data()
1477 "SEND DATA: failed to write reg->tx_wrptr\n"); in mwifiex_pcie_send_data()
1478 ret = -1; in mwifiex_pcie_send_data()
1482 tx_param->next_pkt_len) { in mwifiex_pcie_send_data()
1485 "SEND DATA: delay dnld-rdy interrupt.\n"); in mwifiex_pcie_send_data()
1486 adapter->data_sent = false; in mwifiex_pcie_send_data()
1492 "SEND DATA: failed to assert dnld-rdy interrupt.\n"); in mwifiex_pcie_send_data()
1493 ret = -1; in mwifiex_pcie_send_data()
1500 card->txbd_rdptr, card->txbd_wrptr); in mwifiex_pcie_send_data()
1504 adapter->data_sent = true; in mwifiex_pcie_send_data()
1509 "SEND DATA: failed to assert door-bell intr\n"); in mwifiex_pcie_send_data()
1510 return -EBUSY; in mwifiex_pcie_send_data()
1513 return -EINPROGRESS; in mwifiex_pcie_send_data()
1516 card->tx_buf_list[wrindx] = NULL; in mwifiex_pcie_send_data()
1517 atomic_dec(&adapter->tx_hw_pending); in mwifiex_pcie_send_data()
1518 if (reg->pfu_enabled) in mwifiex_pcie_send_data()
1532 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_recv_data()
1533 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_process_recv_data()
1544 /* Read the RX ring Write pointer set by firmware */ in mwifiex_pcie_process_recv_data()
1545 if (mwifiex_read_reg(adapter, reg->rx_wrptr, &wrptr)) { in mwifiex_pcie_process_recv_data()
1547 "RECV DATA: failed to read reg->rx_wrptr\n"); in mwifiex_pcie_process_recv_data()
1548 ret = -1; in mwifiex_pcie_process_recv_data()
1551 card->rxbd_wrptr = wrptr; in mwifiex_pcie_process_recv_data()
1553 while (((wrptr & reg->rx_mask) != in mwifiex_pcie_process_recv_data()
1554 (card->rxbd_rdptr & reg->rx_mask)) || in mwifiex_pcie_process_recv_data()
1555 ((wrptr & reg->rx_rollover_ind) == in mwifiex_pcie_process_recv_data()
1556 (card->rxbd_rdptr & reg->rx_rollover_ind))) { in mwifiex_pcie_process_recv_data()
1560 rd_index = card->rxbd_rdptr & reg->rx_mask; in mwifiex_pcie_process_recv_data()
1561 skb_data = card->rx_buf_list[rd_index]; in mwifiex_pcie_process_recv_data()
1567 return -ENOMEM; in mwifiex_pcie_process_recv_data()
1570 card->rx_buf_list[rd_index] = NULL; in mwifiex_pcie_process_recv_data()
1572 /* Get data length from interface header - in mwifiex_pcie_process_recv_data()
1575 rx_len = get_unaligned_le16(skb_data->data); in mwifiex_pcie_process_recv_data()
1576 if (WARN_ON(rx_len <= adapter->intf_hdr_len || in mwifiex_pcie_process_recv_data()
1580 rx_len, card->rxbd_rdptr, wrptr); in mwifiex_pcie_process_recv_data()
1586 card->rxbd_rdptr, wrptr, rx_len); in mwifiex_pcie_process_recv_data()
1587 skb_pull(skb_data, adapter->intf_hdr_len); in mwifiex_pcie_process_recv_data()
1588 if (adapter->rx_work_enabled) { in mwifiex_pcie_process_recv_data()
1589 skb_queue_tail(&adapter->rx_data_q, skb_data); in mwifiex_pcie_process_recv_data()
1590 adapter->data_received = true; in mwifiex_pcie_process_recv_data()
1591 atomic_inc(&adapter->rx_pending); in mwifiex_pcie_process_recv_data()
1602 return -ENOMEM; in mwifiex_pcie_process_recv_data()
1608 return -1; in mwifiex_pcie_process_recv_data()
1615 card->rx_buf_list[rd_index] = skb_tmp; in mwifiex_pcie_process_recv_data()
1617 if (reg->pfu_enabled) { in mwifiex_pcie_process_recv_data()
1618 desc2 = card->rxbd_ring[rd_index]; in mwifiex_pcie_process_recv_data()
1619 desc2->paddr = buf_pa; in mwifiex_pcie_process_recv_data()
1620 desc2->len = skb_tmp->len; in mwifiex_pcie_process_recv_data()
1621 desc2->frag_len = skb_tmp->len; in mwifiex_pcie_process_recv_data()
1622 desc2->offset = 0; in mwifiex_pcie_process_recv_data()
1623 desc2->flags = reg->ring_flag_sop | reg->ring_flag_eop; in mwifiex_pcie_process_recv_data()
1625 desc = card->rxbd_ring[rd_index]; in mwifiex_pcie_process_recv_data()
1626 desc->paddr = buf_pa; in mwifiex_pcie_process_recv_data()
1627 desc->len = skb_tmp->len; in mwifiex_pcie_process_recv_data()
1628 desc->flags = 0; in mwifiex_pcie_process_recv_data()
1631 if ((++card->rxbd_rdptr & reg->rx_mask) == in mwifiex_pcie_process_recv_data()
1633 card->rxbd_rdptr = ((card->rxbd_rdptr & in mwifiex_pcie_process_recv_data()
1634 reg->rx_rollover_ind) ^ in mwifiex_pcie_process_recv_data()
1635 reg->rx_rollover_ind); in mwifiex_pcie_process_recv_data()
1639 card->rxbd_rdptr, wrptr); in mwifiex_pcie_process_recv_data()
1641 tx_val = card->txbd_wrptr & reg->tx_wrap_mask; in mwifiex_pcie_process_recv_data()
1642 /* Write the RX ring read pointer in to reg->rx_rdptr */ in mwifiex_pcie_process_recv_data()
1643 if (mwifiex_write_reg(adapter, reg->rx_rdptr, in mwifiex_pcie_process_recv_data()
1644 card->rxbd_rdptr | tx_val)) { in mwifiex_pcie_process_recv_data()
1646 "RECV DATA: failed to write reg->rx_rdptr\n"); in mwifiex_pcie_process_recv_data()
1647 ret = -1; in mwifiex_pcie_process_recv_data()
1651 /* Read the RX ring Write pointer set by firmware */ in mwifiex_pcie_process_recv_data()
1652 if (mwifiex_read_reg(adapter, reg->rx_wrptr, &wrptr)) { in mwifiex_pcie_process_recv_data()
1654 "RECV DATA: failed to read reg->rx_wrptr\n"); in mwifiex_pcie_process_recv_data()
1655 ret = -1; in mwifiex_pcie_process_recv_data()
1660 card->rxbd_wrptr = wrptr; in mwifiex_pcie_process_recv_data()
1674 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_boot_cmd()
1675 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_send_boot_cmd()
1677 if (!(skb->data && skb->len)) { in mwifiex_pcie_send_boot_cmd()
1680 __func__, skb->data, skb->len); in mwifiex_pcie_send_boot_cmd()
1681 return -1; in mwifiex_pcie_send_boot_cmd()
1684 if (mwifiex_map_pci_memory(adapter, skb, skb->len, DMA_TO_DEVICE)) in mwifiex_pcie_send_boot_cmd()
1685 return -1; in mwifiex_pcie_send_boot_cmd()
1692 if (mwifiex_write_reg(adapter, reg->cmd_addr_lo, (u32)buf_pa)) { in mwifiex_pcie_send_boot_cmd()
1697 return -1; in mwifiex_pcie_send_boot_cmd()
1703 if (mwifiex_write_reg(adapter, reg->cmd_addr_hi, in mwifiex_pcie_send_boot_cmd()
1709 return -1; in mwifiex_pcie_send_boot_cmd()
1713 if (mwifiex_write_reg(adapter, reg->cmd_size, skb->len)) { in mwifiex_pcie_send_boot_cmd()
1718 return -1; in mwifiex_pcie_send_boot_cmd()
1725 "%s: failed to assert door-bell intr\n", __func__); in mwifiex_pcie_send_boot_cmd()
1727 return -1; in mwifiex_pcie_send_boot_cmd()
1738 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_init_fw_port()
1739 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_init_fw_port()
1740 int tx_wrap = card->txbd_wrptr & reg->tx_wrap_mask; in mwifiex_pcie_init_fw_port()
1742 /* Write the RX ring read pointer in to reg->rx_rdptr */ in mwifiex_pcie_init_fw_port()
1743 if (mwifiex_write_reg(adapter, reg->rx_rdptr, card->rxbd_rdptr | in mwifiex_pcie_init_fw_port()
1746 "RECV DATA: failed to write reg->rx_rdptr\n"); in mwifiex_pcie_init_fw_port()
1747 return -1; in mwifiex_pcie_init_fw_port()
1757 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_cmd()
1758 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_send_cmd()
1761 u8 *payload = (u8 *)skb->data; in mwifiex_pcie_send_cmd()
1763 if (!(skb->data && skb->len)) { in mwifiex_pcie_send_cmd()
1766 __func__, skb->data, skb->len); in mwifiex_pcie_send_cmd()
1767 return -1; in mwifiex_pcie_send_cmd()
1771 if (!card->cmdrsp_buf) { in mwifiex_pcie_send_cmd()
1773 "No response buffer available, send command failed\n"); in mwifiex_pcie_send_cmd()
1774 return -EBUSY; in mwifiex_pcie_send_cmd()
1780 adapter->cmd_sent = true; in mwifiex_pcie_send_cmd()
1782 put_unaligned_le16((u16)skb->len, &payload[0]); in mwifiex_pcie_send_cmd()
1785 if (mwifiex_map_pci_memory(adapter, skb, skb->len, DMA_TO_DEVICE)) in mwifiex_pcie_send_cmd()
1786 return -1; in mwifiex_pcie_send_cmd()
1788 card->cmd_buf = skb; in mwifiex_pcie_send_cmd()
1805 if (card->cmdrsp_buf) { in mwifiex_pcie_send_cmd()
1806 cmdrsp_buf_pa = MWIFIEX_SKB_DMA_ADDR(card->cmdrsp_buf); in mwifiex_pcie_send_cmd()
1809 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_lo, in mwifiex_pcie_send_cmd()
1813 ret = -1; in mwifiex_pcie_send_cmd()
1818 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_hi, in mwifiex_pcie_send_cmd()
1822 ret = -1; in mwifiex_pcie_send_cmd()
1827 cmd_buf_pa = MWIFIEX_SKB_DMA_ADDR(card->cmd_buf); in mwifiex_pcie_send_cmd()
1828 /* Write the lower 32bits of the physical address to reg->cmd_addr_lo */ in mwifiex_pcie_send_cmd()
1829 if (mwifiex_write_reg(adapter, reg->cmd_addr_lo, in mwifiex_pcie_send_cmd()
1833 ret = -1; in mwifiex_pcie_send_cmd()
1836 /* Write the upper 32bits of the physical address to reg->cmd_addr_hi */ in mwifiex_pcie_send_cmd()
1837 if (mwifiex_write_reg(adapter, reg->cmd_addr_hi, in mwifiex_pcie_send_cmd()
1841 ret = -1; in mwifiex_pcie_send_cmd()
1845 /* Write the command length to reg->cmd_size */ in mwifiex_pcie_send_cmd()
1846 if (mwifiex_write_reg(adapter, reg->cmd_size, in mwifiex_pcie_send_cmd()
1847 card->cmd_buf->len)) { in mwifiex_pcie_send_cmd()
1849 "Failed to write cmd len to reg->cmd_size\n"); in mwifiex_pcie_send_cmd()
1850 ret = -1; in mwifiex_pcie_send_cmd()
1858 "Failed to assert door-bell intr\n"); in mwifiex_pcie_send_cmd()
1859 ret = -1; in mwifiex_pcie_send_cmd()
1865 adapter->cmd_sent = false; in mwifiex_pcie_send_cmd()
1875 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_cmd_complete()
1876 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_process_cmd_complete()
1877 struct sk_buff *skb = card->cmdrsp_buf; in mwifiex_pcie_process_cmd_complete()
1884 if (adapter->curr_cmd) in mwifiex_pcie_process_cmd_complete()
1887 dma_sync_single_for_cpu(&card->dev->dev, in mwifiex_pcie_process_cmd_complete()
1892 if (card->cmd_buf) { in mwifiex_pcie_process_cmd_complete()
1893 mwifiex_unmap_pci_memory(adapter, card->cmd_buf, in mwifiex_pcie_process_cmd_complete()
1895 dev_kfree_skb_any(card->cmd_buf); in mwifiex_pcie_process_cmd_complete()
1896 card->cmd_buf = NULL; in mwifiex_pcie_process_cmd_complete()
1899 rx_len = get_unaligned_le16(skb->data); in mwifiex_pcie_process_cmd_complete()
1900 skb_put(skb, MWIFIEX_UPLD_SIZE - skb->len); in mwifiex_pcie_process_cmd_complete()
1903 if (!adapter->curr_cmd) { in mwifiex_pcie_process_cmd_complete()
1904 if (adapter->ps_state == PS_STATE_SLEEP_CFM) { in mwifiex_pcie_process_cmd_complete()
1905 dma_sync_single_for_device(&card->dev->dev, in mwifiex_pcie_process_cmd_complete()
1914 return -1; in mwifiex_pcie_process_cmd_complete()
1920 skb_pull(skb, adapter->intf_hdr_len); in mwifiex_pcie_process_cmd_complete()
1921 while (reg->sleep_cookie && (count++ < 10) && in mwifiex_pcie_process_cmd_complete()
1925 mwifiex_process_sleep_confirm_resp(adapter, skb->data, in mwifiex_pcie_process_cmd_complete()
1926 skb->len); in mwifiex_pcie_process_cmd_complete()
1929 "There is no command but got cmdrsp\n"); in mwifiex_pcie_process_cmd_complete()
1931 memcpy(adapter->upld_buf, skb->data, in mwifiex_pcie_process_cmd_complete()
1932 min_t(u32, MWIFIEX_SIZE_OF_CMD_BUFFER, skb->len)); in mwifiex_pcie_process_cmd_complete()
1933 skb_push(skb, adapter->intf_hdr_len); in mwifiex_pcie_process_cmd_complete()
1936 return -1; in mwifiex_pcie_process_cmd_complete()
1938 skb_pull(skb, adapter->intf_hdr_len); in mwifiex_pcie_process_cmd_complete()
1939 adapter->curr_cmd->resp_skb = skb; in mwifiex_pcie_process_cmd_complete()
1940 adapter->cmd_resp_received = true; in mwifiex_pcie_process_cmd_complete()
1943 card->cmdrsp_buf = NULL; in mwifiex_pcie_process_cmd_complete()
1945 /* Clear the cmd-rsp buffer address in scratch registers. This in mwifiex_pcie_process_cmd_complete()
1948 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_lo, 0)) { in mwifiex_pcie_process_cmd_complete()
1951 return -1; in mwifiex_pcie_process_cmd_complete()
1955 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_hi, 0)) { in mwifiex_pcie_process_cmd_complete()
1958 return -1; in mwifiex_pcie_process_cmd_complete()
1971 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_cmdrsp_complete()
1974 card->cmdrsp_buf = skb; in mwifiex_pcie_cmdrsp_complete()
1975 skb_push(card->cmdrsp_buf, adapter->intf_hdr_len); in mwifiex_pcie_cmdrsp_complete()
1978 return -1; in mwifiex_pcie_cmdrsp_complete()
1989 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_event_ready()
1990 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_process_event_ready()
1991 u32 rdptr = card->evtbd_rdptr & MWIFIEX_EVTBD_MASK; in mwifiex_pcie_process_event_ready()
1998 if (adapter->event_received) { in mwifiex_pcie_process_event_ready()
2007 "info: Invalid read pointer...\n"); in mwifiex_pcie_process_event_ready()
2008 return -1; in mwifiex_pcie_process_event_ready()
2011 /* Read the event ring write pointer set by firmware */ in mwifiex_pcie_process_event_ready()
2012 if (mwifiex_read_reg(adapter, reg->evt_wrptr, &wrptr)) { in mwifiex_pcie_process_event_ready()
2014 "EventReady: failed to read reg->evt_wrptr\n"); in mwifiex_pcie_process_event_ready()
2015 return -1; in mwifiex_pcie_process_event_ready()
2020 card->evtbd_rdptr, wrptr); in mwifiex_pcie_process_event_ready()
2021 if (((wrptr & MWIFIEX_EVTBD_MASK) != (card->evtbd_rdptr in mwifiex_pcie_process_event_ready()
2023 ((wrptr & reg->evt_rollover_ind) == in mwifiex_pcie_process_event_ready()
2024 (card->evtbd_rdptr & reg->evt_rollover_ind))) { in mwifiex_pcie_process_event_ready()
2030 "info: Read Index: %d\n", rdptr); in mwifiex_pcie_process_event_ready()
2031 skb_cmd = card->evt_buf_list[rdptr]; in mwifiex_pcie_process_event_ready()
2036 card->evt_buf_list[rdptr] = NULL; in mwifiex_pcie_process_event_ready()
2037 desc = card->evtbd_ring[rdptr]; in mwifiex_pcie_process_event_ready()
2041 &skb_cmd->data[adapter->intf_hdr_len]); in mwifiex_pcie_process_event_ready()
2042 adapter->event_cause = event; in mwifiex_pcie_process_event_ready()
2045 memcpy(&data_len, skb_cmd->data, sizeof(__le16)); in mwifiex_pcie_process_event_ready()
2048 skb_pull(skb_cmd, adapter->intf_hdr_len); in mwifiex_pcie_process_event_ready()
2054 memcpy(adapter->event_body, skb_cmd->data + in mwifiex_pcie_process_event_ready()
2055 MWIFIEX_EVENT_HEADER_LEN, evt_len - in mwifiex_pcie_process_event_ready()
2058 adapter->event_received = true; in mwifiex_pcie_process_event_ready()
2059 adapter->event_skb = skb_cmd; in mwifiex_pcie_process_event_ready()
2061 /* Do not update the event read pointer here, wait till the in mwifiex_pcie_process_event_ready()
2070 return -1; in mwifiex_pcie_process_event_ready()
2083 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_event_complete()
2084 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_event_complete()
2086 u32 rdptr = card->evtbd_rdptr & MWIFIEX_EVTBD_MASK; in mwifiex_pcie_event_complete()
2097 return -EINVAL; in mwifiex_pcie_event_complete()
2100 /* Read the event ring write pointer set by firmware */ in mwifiex_pcie_event_complete()
2101 if (mwifiex_read_reg(adapter, reg->evt_wrptr, &wrptr)) { in mwifiex_pcie_event_complete()
2103 "event_complete: failed to read reg->evt_wrptr\n"); in mwifiex_pcie_event_complete()
2104 return -1; in mwifiex_pcie_event_complete()
2107 if (!card->evt_buf_list[rdptr]) { in mwifiex_pcie_event_complete()
2108 skb_push(skb, adapter->intf_hdr_len); in mwifiex_pcie_event_complete()
2109 skb_put(skb, MAX_EVENT_SIZE - skb->len); in mwifiex_pcie_event_complete()
2113 return -1; in mwifiex_pcie_event_complete()
2114 card->evt_buf_list[rdptr] = skb; in mwifiex_pcie_event_complete()
2115 desc = card->evtbd_ring[rdptr]; in mwifiex_pcie_event_complete()
2116 desc->paddr = MWIFIEX_SKB_DMA_ADDR(skb); in mwifiex_pcie_event_complete()
2117 desc->len = (u16)skb->len; in mwifiex_pcie_event_complete()
2118 desc->flags = 0; in mwifiex_pcie_event_complete()
2123 rdptr, card->evt_buf_list[rdptr], skb); in mwifiex_pcie_event_complete()
2126 if ((++card->evtbd_rdptr & MWIFIEX_EVTBD_MASK) == MWIFIEX_MAX_EVT_BD) { in mwifiex_pcie_event_complete()
2127 card->evtbd_rdptr = ((card->evtbd_rdptr & in mwifiex_pcie_event_complete()
2128 reg->evt_rollover_ind) ^ in mwifiex_pcie_event_complete()
2129 reg->evt_rollover_ind); in mwifiex_pcie_event_complete()
2134 card->evtbd_rdptr, wrptr); in mwifiex_pcie_event_complete()
2136 /* Write the event ring read pointer in to reg->evt_rdptr */ in mwifiex_pcie_event_complete()
2137 if (mwifiex_write_reg(adapter, reg->evt_rdptr, in mwifiex_pcie_event_complete()
2138 card->evtbd_rdptr)) { in mwifiex_pcie_event_complete()
2140 "event_complete: failed to read reg->evt_rdptr\n"); in mwifiex_pcie_event_complete()
2141 return -1; in mwifiex_pcie_event_complete()
2157 * the offset of tail wifi-only part. If the image is already wifi-only,
2170 if (offset + sizeof(fwdata->header) < sizeof(fwdata->header) || in mwifiex_extract_wifi_fw()
2171 offset + sizeof(fwdata->header) >= firmware_len) { in mwifiex_extract_wifi_fw()
2173 "extract wifi-only fw failure!\n"); in mwifiex_extract_wifi_fw()
2174 ret = -1; in mwifiex_extract_wifi_fw()
2179 dnld_cmd = le32_to_cpu(fwdata->header.dnld_cmd); in mwifiex_extract_wifi_fw()
2180 data_len = le32_to_cpu(fwdata->header.data_length); in mwifiex_extract_wifi_fw()
2183 offset += sizeof(fwdata->header); in mwifiex_extract_wifi_fw()
2189 ret = -1; in mwifiex_extract_wifi_fw()
2193 /* Image start with cmd1, already wifi-only firmware */ in mwifiex_extract_wifi_fw()
2196 "input wifi-only firmware\n"); in mwifiex_extract_wifi_fw()
2202 "no cmd7 before cmd1!\n"); in mwifiex_extract_wifi_fw()
2203 ret = -1; in mwifiex_extract_wifi_fw()
2213 ret = -1; in mwifiex_extract_wifi_fw()
2223 ret = -1; in mwifiex_extract_wifi_fw()
2229 "extract wifi-only fw failure!\n"); in mwifiex_extract_wifi_fw()
2230 ret = -1; in mwifiex_extract_wifi_fw()
2242 ret = -1; in mwifiex_extract_wifi_fw()
2262 u8 *firmware = fw->fw_buf; in mwifiex_prog_fw_w_helper()
2263 u32 firmware_len = fw->fw_len; in mwifiex_prog_fw_w_helper()
2268 struct pcie_service_card *card = adapter->card; in mwifiex_prog_fw_w_helper()
2269 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_prog_fw_w_helper()
2273 "No firmware image found! Terminating download\n"); in mwifiex_prog_fw_w_helper()
2274 return -1; in mwifiex_prog_fw_w_helper()
2284 return -1; in mwifiex_prog_fw_w_helper()
2289 ret = -ENOMEM; in mwifiex_prog_fw_w_helper()
2295 mwifiex_dbg(adapter, FATAL, "Failed to read scratch register 13\n"); in mwifiex_prog_fw_w_helper()
2320 ret = mwifiex_read_reg(adapter, reg->cmd_size, in mwifiex_prog_fw_w_helper()
2338 ret = -1; in mwifiex_prog_fw_w_helper()
2350 ret = -1; in mwifiex_prog_fw_w_helper()
2362 /* Set blocksize to transfer - checking for in mwifiex_prog_fw_w_helper()
2364 if (firmware_len - offset < txlen) in mwifiex_prog_fw_w_helper()
2365 txlen = firmware_len - offset; in mwifiex_prog_fw_w_helper()
2367 tx_blocks = (txlen + card->pcie.blksz_fw_dl - 1) / in mwifiex_prog_fw_w_helper()
2368 card->pcie.blksz_fw_dl; in mwifiex_prog_fw_w_helper()
2371 memmove(skb->data, &firmware[offset], txlen); in mwifiex_prog_fw_w_helper()
2374 skb_put(skb, MWIFIEX_UPLD_SIZE - skb->len); in mwifiex_prog_fw_w_helper()
2375 skb_trim(skb, tx_blocks * card->pcie.blksz_fw_dl); in mwifiex_prog_fw_w_helper()
2381 ret = -1; in mwifiex_prog_fw_w_helper()
2390 "%s: Failed to read\t" in mwifiex_prog_fw_w_helper()
2395 ret = -1; in mwifiex_prog_fw_w_helper()
2407 ret = -1; in mwifiex_prog_fw_w_helper()
2434 struct pcie_service_card *card = adapter->card; in mwifiex_check_fw_status()
2435 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_check_fw_status()
2443 return -1; in mwifiex_check_fw_status()
2448 if (mwifiex_write_reg(adapter, reg->drv_rdy, in mwifiex_check_fw_status()
2452 return -1; in mwifiex_check_fw_status()
2457 if (mwifiex_read_reg(adapter, reg->fw_status, in mwifiex_check_fw_status()
2459 ret = -1; in mwifiex_check_fw_status()
2473 ret = -1; in mwifiex_check_fw_status()
2487 struct pcie_service_card *card = adapter->card; in mwifiex_check_winner_status()
2488 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_check_winner_status()
2490 if (mwifiex_read_reg(adapter, reg->fw_status, &winner)) { in mwifiex_check_winner_status()
2491 ret = -1; in mwifiex_check_winner_status()
2493 mwifiex_dbg(adapter, INFO, "PCI-E is the winner\n"); in mwifiex_check_winner_status()
2494 adapter->winner = 1; in mwifiex_check_winner_status()
2497 "PCI-E is not the winner <%#x>", winner); in mwifiex_check_winner_status()
2511 struct pcie_service_card *card = adapter->card; in mwifiex_interrupt_status()
2513 if (card->msi_enable) { in mwifiex_interrupt_status()
2514 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2515 adapter->int_status = 1; in mwifiex_interrupt_status()
2516 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2523 if (card->msix_enable && msg_id >= 0) { in mwifiex_interrupt_status()
2528 mwifiex_dbg(adapter, ERROR, "Read register failed\n"); in mwifiex_interrupt_status()
2547 if (!adapter->pps_uapsd_mode && in mwifiex_interrupt_status()
2548 adapter->ps_state == PS_STATE_SLEEP && in mwifiex_interrupt_status()
2554 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_interrupt_status()
2555 adapter->pm_wakeup_fw_try = false; in mwifiex_interrupt_status()
2556 del_timer(&adapter->wakeup_timer); in mwifiex_interrupt_status()
2559 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2560 adapter->int_status |= pcie_ireg; in mwifiex_interrupt_status()
2561 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2574 struct pci_dev *pdev = ctx->dev; in mwifiex_pcie_interrupt()
2580 if (!card->adapter) { in mwifiex_pcie_interrupt()
2582 card ? card->adapter : NULL); in mwifiex_pcie_interrupt()
2585 adapter = card->adapter; in mwifiex_pcie_interrupt()
2587 if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags)) in mwifiex_pcie_interrupt()
2590 if (card->msix_enable) in mwifiex_pcie_interrupt()
2591 mwifiex_interrupt_status(adapter, ctx->msg_id); in mwifiex_pcie_interrupt()
2593 mwifiex_interrupt_status(adapter, -1); in mwifiex_pcie_interrupt()
2604 * The following interrupts are checked and handled by this function -
2605 * - Data sent
2606 * - Command sent
2607 * - Command received
2608 * - Packets received
2609 * - Events received
2619 struct pcie_service_card *card = adapter->card; in mwifiex_process_int_status()
2621 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_process_int_status()
2622 if (!card->msi_enable) { in mwifiex_process_int_status()
2624 pcie_ireg = adapter->int_status; in mwifiex_process_int_status()
2626 adapter->int_status = 0; in mwifiex_process_int_status()
2627 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_process_int_status()
2629 if (card->msi_enable) { in mwifiex_process_int_status()
2634 "Read register failed\n"); in mwifiex_process_int_status()
2635 return -1; in mwifiex_process_int_status()
2644 return -1; in mwifiex_process_int_status()
2646 if (!adapter->pps_uapsd_mode && in mwifiex_process_int_status()
2647 adapter->ps_state == PS_STATE_SLEEP) { in mwifiex_process_int_status()
2648 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_process_int_status()
2649 adapter->pm_wakeup_fw_try = false; in mwifiex_process_int_status()
2650 del_timer(&adapter->wakeup_timer); in mwifiex_process_int_status()
2675 if (adapter->cmd_sent) { in mwifiex_process_int_status()
2678 adapter->cmd_sent = false; in mwifiex_process_int_status()
2688 adapter->cmd_sent, adapter->data_sent); in mwifiex_process_int_status()
2689 if (!card->msi_enable && !card->msix_enable && in mwifiex_process_int_status()
2690 adapter->ps_state != PS_STATE_SLEEP) in mwifiex_process_int_status()
2713 return -1; in mwifiex_pcie_host_to_card()
2733 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_reg_dump()
2734 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_reg_dump()
2744 if (mwifiex_read_reg(adapter, reg->fw_status, &value)) { in mwifiex_pcie_reg_dump()
2745 mwifiex_dbg(adapter, ERROR, "failed to read firmware status"); in mwifiex_pcie_reg_dump()
2762 return p - drv_buf; in mwifiex_pcie_reg_dump()
2765 /* This function read/write firmware */
2772 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_rdwr_firmware()
2773 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_rdwr_firmware()
2775 if (mwifiex_read_reg(adapter, reg->fw_status, &fw_status)) in mwifiex_pcie_rdwr_firmware()
2778 ret = mwifiex_write_reg(adapter, reg->fw_dump_ctrl, in mwifiex_pcie_rdwr_firmware()
2779 reg->fw_dump_host_ready); in mwifiex_pcie_rdwr_firmware()
2787 mwifiex_read_reg_byte(adapter, reg->fw_dump_ctrl, &ctrl_data); in mwifiex_pcie_rdwr_firmware()
2792 if (ctrl_data != reg->fw_dump_host_ready) { in mwifiex_pcie_rdwr_firmware()
2794 "The ctrl reg was changed, re-try again!\n"); in mwifiex_pcie_rdwr_firmware()
2795 ret = mwifiex_write_reg(adapter, reg->fw_dump_ctrl, in mwifiex_pcie_rdwr_firmware()
2796 reg->fw_dump_host_ready); in mwifiex_pcie_rdwr_firmware()
2813 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_fw_dump()
2814 const struct mwifiex_pcie_card_reg *creg = card->pcie.reg; in mwifiex_pcie_fw_dump()
2822 if (!card->pcie.can_dump_fw) in mwifiex_pcie_fw_dump()
2825 for (idx = 0; idx < adapter->num_mem_types; idx++) { in mwifiex_pcie_fw_dump()
2827 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_pcie_fw_dump()
2829 if (entry->mem_ptr) { in mwifiex_pcie_fw_dump()
2830 vfree(entry->mem_ptr); in mwifiex_pcie_fw_dump()
2831 entry->mem_ptr = NULL; in mwifiex_pcie_fw_dump()
2833 entry->mem_size = 0; in mwifiex_pcie_fw_dump()
2838 /* Read the number of the memories which will dump */ in mwifiex_pcie_fw_dump()
2843 reg = creg->fw_dump_start; in mwifiex_pcie_fw_dump()
2852 /* Read the length of every memory which will dump */ in mwifiex_pcie_fw_dump()
2855 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_pcie_fw_dump()
2862 reg = creg->fw_dump_start; in mwifiex_pcie_fw_dump()
2874 ret = mwifiex_write_reg(adapter, creg->fw_dump_ctrl, in mwifiex_pcie_fw_dump()
2875 creg->fw_dump_read_done); in mwifiex_pcie_fw_dump()
2884 "%s_SIZE=0x%x\n", entry->mem_name, memory_size); in mwifiex_pcie_fw_dump()
2885 entry->mem_ptr = vmalloc(memory_size + 1); in mwifiex_pcie_fw_dump()
2886 entry->mem_size = memory_size; in mwifiex_pcie_fw_dump()
2887 if (!entry->mem_ptr) { in mwifiex_pcie_fw_dump()
2889 "Vmalloc %s failed\n", entry->mem_name); in mwifiex_pcie_fw_dump()
2892 dbg_ptr = entry->mem_ptr; in mwifiex_pcie_fw_dump()
2895 doneflag = entry->done_flag; in mwifiex_pcie_fw_dump()
2897 entry->mem_name); in mwifiex_pcie_fw_dump()
2904 reg_start = creg->fw_dump_start; in mwifiex_pcie_fw_dump()
2905 reg_end = creg->fw_dump_end; in mwifiex_pcie_fw_dump()
2913 "pre-allocated buf not enough\n"); in mwifiex_pcie_fw_dump()
2918 memcpy(tmp_ptr, entry->mem_ptr, memory_size); in mwifiex_pcie_fw_dump()
2919 vfree(entry->mem_ptr); in mwifiex_pcie_fw_dump()
2920 entry->mem_ptr = tmp_ptr; in mwifiex_pcie_fw_dump()
2922 dbg_ptr = entry->mem_ptr + memory_size; in mwifiex_pcie_fw_dump()
2924 end_ptr = entry->mem_ptr + memory_size; in mwifiex_pcie_fw_dump()
2932 entry->mem_name, dbg_ptr - entry->mem_ptr); in mwifiex_pcie_fw_dump()
2941 adapter->devdump_data = vzalloc(MWIFIEX_FW_DUMP_SIZE); in mwifiex_pcie_device_dump_work()
2942 if (!adapter->devdump_data) { in mwifiex_pcie_device_dump_work()
2956 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_card_reset_work()
2961 pci_try_reset_function(card->dev); in mwifiex_pcie_card_reset_work()
2970 &card->work_flags)) in mwifiex_pcie_work()
2971 mwifiex_pcie_device_dump_work(card->adapter); in mwifiex_pcie_work()
2973 &card->work_flags)) in mwifiex_pcie_work()
2974 mwifiex_pcie_card_reset_work(card->adapter); in mwifiex_pcie_work()
2980 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_device_dump()
2983 &card->work_flags)) in mwifiex_pcie_device_dump()
2984 schedule_work(&card->work); in mwifiex_pcie_device_dump()
2989 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_card_reset()
2991 if (!test_and_set_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags)) in mwifiex_pcie_card_reset()
2992 schedule_work(&card->work); in mwifiex_pcie_card_reset()
2997 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_alloc_buffers()
2998 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_alloc_buffers()
3001 card->cmdrsp_buf = NULL; in mwifiex_pcie_alloc_buffers()
3026 if (reg->sleep_cookie) { in mwifiex_pcie_alloc_buffers()
3033 card->sleep_cookie_vbase = NULL; in mwifiex_pcie_alloc_buffers()
3052 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_free_buffers()
3053 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_free_buffers()
3055 if (reg->sleep_cookie) in mwifiex_pcie_free_buffers()
3065 * This function initializes the PCI-E host memory space, WCB rings, etc.
3069 struct pcie_service_card *card = adapter->card; in mwifiex_init_pcie()
3071 struct pci_dev *pdev = card->dev; in mwifiex_init_pcie()
3081 ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in mwifiex_init_pcie()
3092 card->pci_mmap = pci_iomap(pdev, 0, 0); in mwifiex_init_pcie()
3093 if (!card->pci_mmap) { in mwifiex_init_pcie()
3095 ret = -EIO; in mwifiex_init_pcie()
3103 card->pci_mmap1 = pci_iomap(pdev, 2, 0); in mwifiex_init_pcie()
3104 if (!card->pci_mmap1) { in mwifiex_init_pcie()
3106 ret = -EIO; in mwifiex_init_pcie()
3111 card->pci_mmap, card->pci_mmap1); in mwifiex_init_pcie()
3120 pci_iounmap(pdev, card->pci_mmap1); in mwifiex_init_pcie()
3124 pci_iounmap(pdev, card->pci_mmap); in mwifiex_init_pcie()
3139 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_pcie()
3140 struct pci_dev *pdev = card->dev; in mwifiex_cleanup_pcie()
3141 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_cleanup_pcie()
3145 cancel_work_sync(&card->work); in mwifiex_cleanup_pcie()
3147 ret = mwifiex_read_reg(adapter, reg->fw_status, &fw_status); in mwifiex_cleanup_pcie()
3151 if (mwifiex_write_reg(adapter, reg->drv_rdy, 0x00000000)) in mwifiex_cleanup_pcie()
3153 "Failed to write driver not-ready signature\n"); in mwifiex_cleanup_pcie()
3158 pci_iounmap(pdev, card->pci_mmap); in mwifiex_cleanup_pcie()
3159 pci_iounmap(pdev, card->pci_mmap1); in mwifiex_cleanup_pcie()
3169 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_request_irq()
3170 struct pci_dev *pdev = card->dev; in mwifiex_pcie_request_irq()
3172 if (card->pcie.reg->msix_support) { in mwifiex_pcie_request_irq()
3174 card->msix_entries[i].entry = i; in mwifiex_pcie_request_irq()
3175 ret = pci_enable_msix_exact(pdev, card->msix_entries, in mwifiex_pcie_request_irq()
3179 card->msix_ctx[i].dev = pdev; in mwifiex_pcie_request_irq()
3180 card->msix_ctx[i].msg_id = i; in mwifiex_pcie_request_irq()
3182 ret = request_irq(card->msix_entries[i].vector, in mwifiex_pcie_request_irq()
3185 &card->msix_ctx[i]); in mwifiex_pcie_request_irq()
3194 free_irq(card->msix_entries[j].vector, in mwifiex_pcie_request_irq()
3195 &card->msix_ctx[i]); in mwifiex_pcie_request_irq()
3199 card->msix_enable = 1; in mwifiex_pcie_request_irq()
3208 card->msi_enable = 1; in mwifiex_pcie_request_irq()
3210 mwifiex_dbg(adapter, INFO, "msi_enable = %d\n", card->msi_enable); in mwifiex_pcie_request_irq()
3212 card->share_irq_ctx.dev = pdev; in mwifiex_pcie_request_irq()
3213 card->share_irq_ctx.msg_id = -1; in mwifiex_pcie_request_irq()
3214 ret = request_irq(pdev->irq, mwifiex_pcie_interrupt, IRQF_SHARED, in mwifiex_pcie_request_irq()
3215 "MRVL_PCIE", &card->share_irq_ctx); in mwifiex_pcie_request_irq()
3218 return -1; in mwifiex_pcie_request_irq()
3227 * Read revision id register to get revision id
3233 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_get_fw_name()
3235 switch (card->dev->device) { in mwifiex_pcie_get_fw_name()
3237 strcpy(adapter->fw_name, PCIE8766_DEFAULT_FW_NAME); in mwifiex_pcie_get_fw_name()
3245 strcpy(adapter->fw_name, PCIE8897_A0_FW_NAME); in mwifiex_pcie_get_fw_name()
3248 strcpy(adapter->fw_name, PCIE8897_B0_FW_NAME); in mwifiex_pcie_get_fw_name()
3251 strcpy(adapter->fw_name, PCIE8897_DEFAULT_FW_NAME); in mwifiex_pcie_get_fw_name()
3266 strcpy(adapter->fw_name, PCIEUART8997_FW_NAME_V4); in mwifiex_pcie_get_fw_name()
3268 strcpy(adapter->fw_name, PCIEUSB8997_FW_NAME_V4); in mwifiex_pcie_get_fw_name()
3282 struct pcie_service_card *card = adapter->card; in mwifiex_register_dev()
3285 card->adapter = adapter; in mwifiex_register_dev()
3288 return -1; in mwifiex_register_dev()
3290 adapter->tx_buf_size = card->pcie.tx_buf_size; in mwifiex_register_dev()
3291 adapter->mem_type_mapping_tbl = card->pcie.mem_type_mapping_tbl; in mwifiex_register_dev()
3292 adapter->num_mem_types = card->pcie.num_mem_types; in mwifiex_register_dev()
3293 adapter->ext_scan = card->pcie.can_ext_scan; in mwifiex_register_dev()
3307 struct pcie_service_card *card = adapter->card; in mwifiex_unregister_dev()
3308 struct pci_dev *pdev = card->dev; in mwifiex_unregister_dev()
3311 if (card->msix_enable) { in mwifiex_unregister_dev()
3313 synchronize_irq(card->msix_entries[i].vector); in mwifiex_unregister_dev()
3316 free_irq(card->msix_entries[i].vector, in mwifiex_unregister_dev()
3317 &card->msix_ctx[i]); in mwifiex_unregister_dev()
3319 card->msix_enable = 0; in mwifiex_unregister_dev()
3324 free_irq(card->dev->irq, &card->share_irq_ctx); in mwifiex_unregister_dev()
3326 if (card->msi_enable) in mwifiex_unregister_dev()
3329 card->adapter = NULL; in mwifiex_unregister_dev()
3333 * This function initializes the PCI-E host memory space, WCB rings, etc.,
3334 * similar to mwifiex_init_pcie(), but without resetting PCI-E state.
3338 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_up_dev()
3339 struct pci_dev *pdev = card->dev; in mwifiex_pcie_up_dev()
3344 adapter->tx_buf_size = card->pcie.tx_buf_size; in mwifiex_pcie_up_dev()
3351 /* This function cleans up the PCI-E host memory space. */
3354 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_down_dev()
3355 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_down_dev()
3356 struct pci_dev *pdev = card->dev; in mwifiex_pcie_down_dev()
3358 if (mwifiex_write_reg(adapter, reg->drv_rdy, 0x00000000)) in mwifiex_pcie_down_dev()
3359 mwifiex_dbg(adapter, ERROR, "Failed to write driver not-ready signature\n"); in mwifiex_pcie_down_dev()
3363 adapter->seq_num = 0; in mwifiex_pcie_down_dev()
3400 MODULE_DESCRIPTION("Marvell WiFi-Ex PCI-Express Driver version " PCIE_VERSION);