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
194 if (!of_match_node(mwifiex_pcie_of_match_table, dev->of_node)) { in mwifiex_pcie_probe_of()
196 return -EINVAL; in mwifiex_pcie_probe_of()
208 struct pcie_service_card *card = adapter->card; in mwifiex_map_pci_memory()
211 mapping.addr = dma_map_single(&card->dev->dev, skb->data, size, flags); in mwifiex_map_pci_memory()
212 if (dma_mapping_error(&card->dev->dev, mapping.addr)) { in mwifiex_map_pci_memory()
214 return -1; in mwifiex_map_pci_memory()
224 struct pcie_service_card *card = adapter->card; in mwifiex_unmap_pci_memory()
228 dma_unmap_single(&card->dev->dev, mapping.addr, mapping.len, flags); in mwifiex_unmap_pci_memory()
236 struct pcie_service_card *card = adapter->card; in mwifiex_write_reg()
238 iowrite32(data, card->pci_mmap1 + reg); in mwifiex_write_reg()
247 struct pcie_service_card *card = adapter->card; in mwifiex_read_reg()
249 *data = ioread32(card->pci_mmap1 + reg); in mwifiex_read_reg()
260 struct pcie_service_card *card = adapter->card; in mwifiex_read_reg_byte()
262 *data = ioread8(card->pci_mmap1 + reg); in mwifiex_read_reg_byte()
273 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_ok_to_access_hw()
274 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_ok_to_access_hw()
276 if (!reg->sleep_cookie) in mwifiex_pcie_ok_to_access_hw()
279 if (card->sleep_cookie_vbase) { in mwifiex_pcie_ok_to_access_hw()
280 cookie_value = get_unaligned_le32(card->sleep_cookie_vbase); in mwifiex_pcie_ok_to_access_hw()
307 wait_for_completion(&card->fw_done); in mwifiex_pcie_suspend()
309 adapter = card->adapter; in mwifiex_pcie_suspend()
321 clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags); in mwifiex_pcie_suspend()
323 return -EFAULT; in mwifiex_pcie_suspend()
326 flush_workqueue(adapter->workqueue); in mwifiex_pcie_suspend()
329 set_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_pcie_suspend()
330 clear_bit(MWIFIEX_IS_HS_ENABLING, &adapter->work_flags); in mwifiex_pcie_suspend()
349 if (!card->adapter) { in mwifiex_pcie_resume()
354 adapter = card->adapter; in mwifiex_pcie_resume()
356 if (!test_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags)) { in mwifiex_pcie_resume()
362 clear_bit(MWIFIEX_IS_SUSPENDED, &adapter->work_flags); in mwifiex_pcie_resume()
385 pdev->vendor, pdev->device, pdev->revision); in mwifiex_pcie_probe()
387 card = devm_kzalloc(&pdev->dev, sizeof(*card), GFP_KERNEL); in mwifiex_pcie_probe()
389 return -ENOMEM; in mwifiex_pcie_probe()
391 init_completion(&card->fw_done); in mwifiex_pcie_probe()
393 card->dev = pdev; in mwifiex_pcie_probe()
395 if (ent->driver_data) { in mwifiex_pcie_probe()
396 struct mwifiex_pcie_device *data = (void *)ent->driver_data; in mwifiex_pcie_probe()
397 card->pcie.reg = data->reg; in mwifiex_pcie_probe()
398 card->pcie.blksz_fw_dl = data->blksz_fw_dl; in mwifiex_pcie_probe()
399 card->pcie.tx_buf_size = data->tx_buf_size; in mwifiex_pcie_probe()
400 card->pcie.can_dump_fw = data->can_dump_fw; in mwifiex_pcie_probe()
401 card->pcie.mem_type_mapping_tbl = data->mem_type_mapping_tbl; in mwifiex_pcie_probe()
402 card->pcie.num_mem_types = data->num_mem_types; in mwifiex_pcie_probe()
403 card->pcie.can_ext_scan = data->can_ext_scan; in mwifiex_pcie_probe()
404 INIT_WORK(&card->work, mwifiex_pcie_work); in mwifiex_pcie_probe()
408 if (pdev->dev.of_node) { in mwifiex_pcie_probe()
409 ret = mwifiex_pcie_probe_of(&pdev->dev); in mwifiex_pcie_probe()
417 if (mwifiex_add_card(card, &card->fw_done, &pcie_ops, in mwifiex_pcie_probe()
418 MWIFIEX_PCIE, &pdev->dev)) { in mwifiex_pcie_probe()
420 return -1; in mwifiex_pcie_probe()
439 wait_for_completion(&card->fw_done); in mwifiex_pcie_remove()
441 adapter = card->adapter; in mwifiex_pcie_remove()
442 if (!adapter || !adapter->priv_num) in mwifiex_pcie_remove()
445 reg = card->pcie.reg; in mwifiex_pcie_remove()
447 mwifiex_read_reg(adapter, reg->fw_status, &fw_status); in mwifiex_pcie_remove()
449 fw_status = -1; in mwifiex_pcie_remove()
451 if (fw_status == FIRMWARE_READY_PCIE && !adapter->mfg_mode) { in mwifiex_pcie_remove()
480 &card->work_flags)) in mwifiex_pcie_coredump()
481 schedule_work(&card->work); in mwifiex_pcie_coredump()
516 struct mwifiex_adapter *adapter = card->adapter; in mwifiex_pcie_reset_prepare()
519 dev_err(&pdev->dev, "%s: adapter structure is not valid\n", in mwifiex_pcie_reset_prepare()
525 "%s: vendor=0x%4.04x device=0x%4.04x rev=%d Pre-FLR\n", in mwifiex_pcie_reset_prepare()
526 __func__, pdev->vendor, pdev->device, pdev->revision); in mwifiex_pcie_reset_prepare()
529 clear_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags); in mwifiex_pcie_reset_prepare()
530 clear_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags); in mwifiex_pcie_reset_prepare()
533 * hangups, so we power-cycle the card instead. in mwifiex_pcie_reset_prepare()
535 if (card->quirks & QUIRK_FW_RST_D3COLD) in mwifiex_pcie_reset_prepare()
540 card->pci_reset_ongoing = true; in mwifiex_pcie_reset_prepare()
551 struct mwifiex_adapter *adapter = card->adapter; in mwifiex_pcie_reset_done()
555 dev_err(&pdev->dev, "%s: adapter structure is not valid\n", in mwifiex_pcie_reset_done()
561 "%s: vendor=0x%4.04x device=0x%4.04x rev=%d Post-FLR\n", in mwifiex_pcie_reset_done()
562 __func__, pdev->vendor, pdev->device, pdev->revision); in mwifiex_pcie_reset_done()
566 dev_err(&pdev->dev, "reinit failed: %d\n", ret); in mwifiex_pcie_reset_done()
570 card->pci_reset_ongoing = false; in mwifiex_pcie_reset_done()
621 struct pcie_service_card *card = adapter->card; in mwifiex_delay_for_sleep_cookie()
624 struct sk_buff *cmdrsp = card->cmdrsp_buf; in mwifiex_delay_for_sleep_cookie()
627 dma_sync_single_for_cpu(&card->dev->dev, in mwifiex_delay_for_sleep_cookie()
630 buffer = cmdrsp->data; in mwifiex_delay_for_sleep_cookie()
638 dma_sync_single_for_device(&card->dev->dev, in mwifiex_delay_for_sleep_cookie()
653 struct pcie_service_card *card = adapter->card; in mwifiex_pm_wakeup_card()
654 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pm_wakeup_card()
659 if (reg->sleep_cookie) in mwifiex_pm_wakeup_card()
663 if (mwifiex_write_reg(adapter, reg->fw_status, FIRMWARE_READY_PCIE)) { in mwifiex_pm_wakeup_card()
666 return -1; in mwifiex_pm_wakeup_card()
669 if (reg->sleep_cookie) { in mwifiex_pm_wakeup_card()
673 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_pm_wakeup_card()
695 * The host interrupt mask is read, the disable bit is reset and
705 return -1; in mwifiex_pcie_disable_host_int()
709 atomic_set(&adapter->tx_hw_pending, 0); in mwifiex_pcie_disable_host_int()
732 return -1; in mwifiex_pcie_enable_host_int()
744 struct pcie_service_card *card = adapter->card; in mwifiex_init_txq_ring()
745 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_init_txq_ring()
751 card->tx_buf_list[i] = NULL; in mwifiex_init_txq_ring()
752 if (reg->pfu_enabled) { in mwifiex_init_txq_ring()
753 card->txbd_ring[i] = (void *)card->txbd_ring_vbase + in mwifiex_init_txq_ring()
755 desc2 = card->txbd_ring[i]; in mwifiex_init_txq_ring()
758 card->txbd_ring[i] = (void *)card->txbd_ring_vbase + in mwifiex_init_txq_ring()
760 desc = card->txbd_ring[i]; in mwifiex_init_txq_ring()
774 struct pcie_service_card *card = adapter->card; in mwifiex_init_rxq_ring()
775 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_init_rxq_ring()
789 kfree(card->rxbd_ring_vbase); in mwifiex_init_rxq_ring()
790 return -ENOMEM; in mwifiex_init_rxq_ring()
796 return -1; in mwifiex_init_rxq_ring()
802 skb, skb->len, skb->data, (u32)buf_pa, in mwifiex_init_rxq_ring()
805 card->rx_buf_list[i] = skb; in mwifiex_init_rxq_ring()
806 if (reg->pfu_enabled) { in mwifiex_init_rxq_ring()
807 card->rxbd_ring[i] = (void *)card->rxbd_ring_vbase + in mwifiex_init_rxq_ring()
809 desc2 = card->rxbd_ring[i]; in mwifiex_init_rxq_ring()
810 desc2->paddr = buf_pa; in mwifiex_init_rxq_ring()
811 desc2->len = (u16)skb->len; in mwifiex_init_rxq_ring()
812 desc2->frag_len = (u16)skb->len; in mwifiex_init_rxq_ring()
813 desc2->flags = reg->ring_flag_eop | reg->ring_flag_sop; in mwifiex_init_rxq_ring()
814 desc2->offset = 0; in mwifiex_init_rxq_ring()
816 card->rxbd_ring[i] = (void *)(card->rxbd_ring_vbase + in mwifiex_init_rxq_ring()
818 desc = card->rxbd_ring[i]; in mwifiex_init_rxq_ring()
819 desc->paddr = buf_pa; in mwifiex_init_rxq_ring()
820 desc->len = (u16)skb->len; in mwifiex_init_rxq_ring()
821 desc->flags = 0; in mwifiex_init_rxq_ring()
834 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_init_evt_ring()
846 kfree(card->evtbd_ring_vbase); in mwifiex_pcie_init_evt_ring()
847 return -ENOMEM; in mwifiex_pcie_init_evt_ring()
854 kfree(card->evtbd_ring_vbase); in mwifiex_pcie_init_evt_ring()
855 return -1; in mwifiex_pcie_init_evt_ring()
862 skb, skb->len, skb->data, (u32)buf_pa, in mwifiex_pcie_init_evt_ring()
865 card->evt_buf_list[i] = skb; in mwifiex_pcie_init_evt_ring()
866 card->evtbd_ring[i] = (void *)(card->evtbd_ring_vbase + in mwifiex_pcie_init_evt_ring()
868 desc = card->evtbd_ring[i]; in mwifiex_pcie_init_evt_ring()
869 desc->paddr = buf_pa; in mwifiex_pcie_init_evt_ring()
870 desc->len = (u16)skb->len; in mwifiex_pcie_init_evt_ring()
871 desc->flags = 0; in mwifiex_pcie_init_evt_ring()
882 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_txq_ring()
883 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_cleanup_txq_ring()
890 if (reg->pfu_enabled) { in mwifiex_cleanup_txq_ring()
891 desc2 = card->txbd_ring[i]; in mwifiex_cleanup_txq_ring()
892 if (card->tx_buf_list[i]) { in mwifiex_cleanup_txq_ring()
893 skb = card->tx_buf_list[i]; in mwifiex_cleanup_txq_ring()
900 desc = card->txbd_ring[i]; in mwifiex_cleanup_txq_ring()
901 if (card->tx_buf_list[i]) { in mwifiex_cleanup_txq_ring()
902 skb = card->tx_buf_list[i]; in mwifiex_cleanup_txq_ring()
909 card->tx_buf_list[i] = NULL; in mwifiex_cleanup_txq_ring()
912 atomic_set(&adapter->tx_hw_pending, 0); in mwifiex_cleanup_txq_ring()
921 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_rxq_ring()
922 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_cleanup_rxq_ring()
929 if (reg->pfu_enabled) { in mwifiex_cleanup_rxq_ring()
930 desc2 = card->rxbd_ring[i]; in mwifiex_cleanup_rxq_ring()
931 if (card->rx_buf_list[i]) { in mwifiex_cleanup_rxq_ring()
932 skb = card->rx_buf_list[i]; in mwifiex_cleanup_rxq_ring()
939 desc = card->rxbd_ring[i]; in mwifiex_cleanup_rxq_ring()
940 if (card->rx_buf_list[i]) { in mwifiex_cleanup_rxq_ring()
941 skb = card->rx_buf_list[i]; in mwifiex_cleanup_rxq_ring()
948 card->rx_buf_list[i] = NULL; in mwifiex_cleanup_rxq_ring()
959 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_evt_ring()
965 desc = card->evtbd_ring[i]; in mwifiex_cleanup_evt_ring()
966 if (card->evt_buf_list[i]) { in mwifiex_cleanup_evt_ring()
967 skb = card->evt_buf_list[i]; in mwifiex_cleanup_evt_ring()
972 card->evt_buf_list[i] = NULL; in mwifiex_cleanup_evt_ring()
983 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_create_txbd_ring()
984 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_create_txbd_ring()
987 * driver maintaines the write pointer and firmware maintaines the read in mwifiex_pcie_create_txbd_ring()
988 * pointer. The write pointer starts at 0 (zero) while the read pointer in mwifiex_pcie_create_txbd_ring()
989 * starts at zero with rollover bit set in mwifiex_pcie_create_txbd_ring()
991 card->txbd_wrptr = 0; in mwifiex_pcie_create_txbd_ring()
993 if (reg->pfu_enabled) in mwifiex_pcie_create_txbd_ring()
994 card->txbd_rdptr = 0; in mwifiex_pcie_create_txbd_ring()
996 card->txbd_rdptr |= reg->tx_rollover_ind; in mwifiex_pcie_create_txbd_ring()
1000 if (reg->pfu_enabled) in mwifiex_pcie_create_txbd_ring()
1001 card->txbd_ring_size = sizeof(struct mwifiex_pfu_buf_desc) * in mwifiex_pcie_create_txbd_ring()
1004 card->txbd_ring_size = sizeof(struct mwifiex_pcie_buf_desc) * in mwifiex_pcie_create_txbd_ring()
1009 card->txbd_ring_size); in mwifiex_pcie_create_txbd_ring()
1010 card->txbd_ring_vbase = dma_alloc_coherent(&card->dev->dev, in mwifiex_pcie_create_txbd_ring()
1011 card->txbd_ring_size, in mwifiex_pcie_create_txbd_ring()
1012 &card->txbd_ring_pbase, in mwifiex_pcie_create_txbd_ring()
1014 if (!card->txbd_ring_vbase) { in mwifiex_pcie_create_txbd_ring()
1017 card->txbd_ring_size); in mwifiex_pcie_create_txbd_ring()
1018 return -ENOMEM; in mwifiex_pcie_create_txbd_ring()
1022 "info: txbd_ring - base: %p, pbase: %#x:%x, len: %#x\n", in mwifiex_pcie_create_txbd_ring()
1023 card->txbd_ring_vbase, (u32)card->txbd_ring_pbase, in mwifiex_pcie_create_txbd_ring()
1024 (u32)((u64)card->txbd_ring_pbase >> 32), in mwifiex_pcie_create_txbd_ring()
1025 card->txbd_ring_size); in mwifiex_pcie_create_txbd_ring()
1032 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_txbd_ring()
1033 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_delete_txbd_ring()
1037 if (card->txbd_ring_vbase) in mwifiex_pcie_delete_txbd_ring()
1038 dma_free_coherent(&card->dev->dev, card->txbd_ring_size, in mwifiex_pcie_delete_txbd_ring()
1039 card->txbd_ring_vbase, in mwifiex_pcie_delete_txbd_ring()
1040 card->txbd_ring_pbase); in mwifiex_pcie_delete_txbd_ring()
1041 card->txbd_ring_size = 0; in mwifiex_pcie_delete_txbd_ring()
1042 card->txbd_wrptr = 0; in mwifiex_pcie_delete_txbd_ring()
1043 card->txbd_rdptr = 0 | reg->tx_rollover_ind; in mwifiex_pcie_delete_txbd_ring()
1044 card->txbd_ring_vbase = NULL; in mwifiex_pcie_delete_txbd_ring()
1045 card->txbd_ring_pbase = 0; in mwifiex_pcie_delete_txbd_ring()
1055 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_create_rxbd_ring()
1056 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_create_rxbd_ring()
1059 * driver maintaines the read pointer and firmware maintaines the write in mwifiex_pcie_create_rxbd_ring()
1060 * pointer. The write pointer starts at 0 (zero) while the read pointer in mwifiex_pcie_create_rxbd_ring()
1061 * starts at zero with rollover bit set in mwifiex_pcie_create_rxbd_ring()
1063 card->rxbd_wrptr = 0; in mwifiex_pcie_create_rxbd_ring()
1064 card->rxbd_rdptr = reg->rx_rollover_ind; in mwifiex_pcie_create_rxbd_ring()
1066 if (reg->pfu_enabled) in mwifiex_pcie_create_rxbd_ring()
1067 card->rxbd_ring_size = sizeof(struct mwifiex_pfu_buf_desc) * in mwifiex_pcie_create_rxbd_ring()
1070 card->rxbd_ring_size = sizeof(struct mwifiex_pcie_buf_desc) * in mwifiex_pcie_create_rxbd_ring()
1075 card->rxbd_ring_size); in mwifiex_pcie_create_rxbd_ring()
1076 card->rxbd_ring_vbase = dma_alloc_coherent(&card->dev->dev, in mwifiex_pcie_create_rxbd_ring()
1077 card->rxbd_ring_size, in mwifiex_pcie_create_rxbd_ring()
1078 &card->rxbd_ring_pbase, in mwifiex_pcie_create_rxbd_ring()
1080 if (!card->rxbd_ring_vbase) { in mwifiex_pcie_create_rxbd_ring()
1083 card->rxbd_ring_size); in mwifiex_pcie_create_rxbd_ring()
1084 return -ENOMEM; in mwifiex_pcie_create_rxbd_ring()
1088 "info: rxbd_ring - base: %p, pbase: %#x:%x, len: %#x\n", in mwifiex_pcie_create_rxbd_ring()
1089 card->rxbd_ring_vbase, (u32)card->rxbd_ring_pbase, in mwifiex_pcie_create_rxbd_ring()
1090 (u32)((u64)card->rxbd_ring_pbase >> 32), in mwifiex_pcie_create_rxbd_ring()
1091 card->rxbd_ring_size); in mwifiex_pcie_create_rxbd_ring()
1101 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_rxbd_ring()
1102 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_delete_rxbd_ring()
1106 if (card->rxbd_ring_vbase) in mwifiex_pcie_delete_rxbd_ring()
1107 dma_free_coherent(&card->dev->dev, card->rxbd_ring_size, in mwifiex_pcie_delete_rxbd_ring()
1108 card->rxbd_ring_vbase, in mwifiex_pcie_delete_rxbd_ring()
1109 card->rxbd_ring_pbase); in mwifiex_pcie_delete_rxbd_ring()
1110 card->rxbd_ring_size = 0; in mwifiex_pcie_delete_rxbd_ring()
1111 card->rxbd_wrptr = 0; in mwifiex_pcie_delete_rxbd_ring()
1112 card->rxbd_rdptr = 0 | reg->rx_rollover_ind; in mwifiex_pcie_delete_rxbd_ring()
1113 card->rxbd_ring_vbase = NULL; in mwifiex_pcie_delete_rxbd_ring()
1114 card->rxbd_ring_pbase = 0; in mwifiex_pcie_delete_rxbd_ring()
1124 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_create_evtbd_ring()
1125 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_create_evtbd_ring()
1128 * driver maintaines the read pointer and firmware maintaines the write in mwifiex_pcie_create_evtbd_ring()
1129 * pointer. The write pointer starts at 0 (zero) while the read pointer in mwifiex_pcie_create_evtbd_ring()
1130 * starts at zero with rollover bit set in mwifiex_pcie_create_evtbd_ring()
1132 card->evtbd_wrptr = 0; in mwifiex_pcie_create_evtbd_ring()
1133 card->evtbd_rdptr = reg->evt_rollover_ind; in mwifiex_pcie_create_evtbd_ring()
1135 card->evtbd_ring_size = sizeof(struct mwifiex_evt_buf_desc) * in mwifiex_pcie_create_evtbd_ring()
1140 card->evtbd_ring_size); in mwifiex_pcie_create_evtbd_ring()
1141 card->evtbd_ring_vbase = dma_alloc_coherent(&card->dev->dev, in mwifiex_pcie_create_evtbd_ring()
1142 card->evtbd_ring_size, in mwifiex_pcie_create_evtbd_ring()
1143 &card->evtbd_ring_pbase, in mwifiex_pcie_create_evtbd_ring()
1145 if (!card->evtbd_ring_vbase) { in mwifiex_pcie_create_evtbd_ring()
1148 card->evtbd_ring_size); in mwifiex_pcie_create_evtbd_ring()
1149 return -ENOMEM; in mwifiex_pcie_create_evtbd_ring()
1153 "info: CMDRSP/EVT bd_ring - base: %p pbase: %#x:%x len: %#x\n", in mwifiex_pcie_create_evtbd_ring()
1154 card->evtbd_ring_vbase, (u32)card->evtbd_ring_pbase, in mwifiex_pcie_create_evtbd_ring()
1155 (u32)((u64)card->evtbd_ring_pbase >> 32), in mwifiex_pcie_create_evtbd_ring()
1156 card->evtbd_ring_size); in mwifiex_pcie_create_evtbd_ring()
1166 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_evtbd_ring()
1167 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_delete_evtbd_ring()
1171 if (card->evtbd_ring_vbase) in mwifiex_pcie_delete_evtbd_ring()
1172 dma_free_coherent(&card->dev->dev, card->evtbd_ring_size, in mwifiex_pcie_delete_evtbd_ring()
1173 card->evtbd_ring_vbase, in mwifiex_pcie_delete_evtbd_ring()
1174 card->evtbd_ring_pbase); in mwifiex_pcie_delete_evtbd_ring()
1175 card->evtbd_wrptr = 0; in mwifiex_pcie_delete_evtbd_ring()
1176 card->evtbd_rdptr = 0 | reg->evt_rollover_ind; in mwifiex_pcie_delete_evtbd_ring()
1177 card->evtbd_ring_size = 0; in mwifiex_pcie_delete_evtbd_ring()
1178 card->evtbd_ring_vbase = NULL; in mwifiex_pcie_delete_evtbd_ring()
1179 card->evtbd_ring_pbase = 0; in mwifiex_pcie_delete_evtbd_ring()
1189 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_alloc_cmdrsp_buf()
1197 return -ENOMEM; in mwifiex_pcie_alloc_cmdrsp_buf()
1203 return -1; in mwifiex_pcie_alloc_cmdrsp_buf()
1206 card->cmdrsp_buf = skb; in mwifiex_pcie_alloc_cmdrsp_buf()
1221 card = adapter->card; in mwifiex_pcie_delete_cmdrsp_buf()
1223 if (card && card->cmdrsp_buf) { in mwifiex_pcie_delete_cmdrsp_buf()
1224 mwifiex_unmap_pci_memory(adapter, card->cmdrsp_buf, in mwifiex_pcie_delete_cmdrsp_buf()
1226 dev_kfree_skb_any(card->cmdrsp_buf); in mwifiex_pcie_delete_cmdrsp_buf()
1227 card->cmdrsp_buf = NULL; in mwifiex_pcie_delete_cmdrsp_buf()
1230 if (card && card->cmd_buf) { in mwifiex_pcie_delete_cmdrsp_buf()
1231 mwifiex_unmap_pci_memory(adapter, card->cmd_buf, in mwifiex_pcie_delete_cmdrsp_buf()
1233 dev_kfree_skb_any(card->cmd_buf); in mwifiex_pcie_delete_cmdrsp_buf()
1234 card->cmd_buf = NULL; in mwifiex_pcie_delete_cmdrsp_buf()
1244 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_alloc_sleep_cookie_buf()
1247 card->sleep_cookie_vbase = dma_alloc_coherent(&card->dev->dev, in mwifiex_pcie_alloc_sleep_cookie_buf()
1249 &card->sleep_cookie_pbase, in mwifiex_pcie_alloc_sleep_cookie_buf()
1251 if (!card->sleep_cookie_vbase) { in mwifiex_pcie_alloc_sleep_cookie_buf()
1254 return -ENOMEM; in mwifiex_pcie_alloc_sleep_cookie_buf()
1256 cookie = (u32 *)card->sleep_cookie_vbase; in mwifiex_pcie_alloc_sleep_cookie_buf()
1275 card = adapter->card; in mwifiex_pcie_delete_sleep_cookie_buf()
1277 if (card && card->sleep_cookie_vbase) { in mwifiex_pcie_delete_sleep_cookie_buf()
1278 dma_free_coherent(&card->dev->dev, sizeof(u32), in mwifiex_pcie_delete_sleep_cookie_buf()
1279 card->sleep_cookie_vbase, in mwifiex_pcie_delete_sleep_cookie_buf()
1280 card->sleep_cookie_pbase); in mwifiex_pcie_delete_sleep_cookie_buf()
1281 card->sleep_cookie_vbase = NULL; in mwifiex_pcie_delete_sleep_cookie_buf()
1293 struct pcie_service_card *card = adapter->card; in mwifiex_clean_pcie_ring_buf()
1295 if (!mwifiex_pcie_txbd_empty(card, card->txbd_rdptr)) { in mwifiex_clean_pcie_ring_buf()
1296 card->txbd_flush = 1; in mwifiex_clean_pcie_ring_buf()
1298 * send dnld-rdy intr again, wait for completion. in mwifiex_clean_pcie_ring_buf()
1303 "failed to assert dnld-rdy interrupt.\n"); in mwifiex_clean_pcie_ring_buf()
1304 return -1; in mwifiex_clean_pcie_ring_buf()
1319 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_data_complete()
1320 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_send_data_complete()
1325 /* Read the TX ring read pointer set by firmware */ in mwifiex_pcie_send_data_complete()
1326 if (mwifiex_read_reg(adapter, reg->tx_rdptr, &rdptr)) { in mwifiex_pcie_send_data_complete()
1328 "SEND COMP: failed to read reg->tx_rdptr\n"); in mwifiex_pcie_send_data_complete()
1329 return -1; in mwifiex_pcie_send_data_complete()
1334 card->txbd_rdptr, rdptr); in mwifiex_pcie_send_data_complete()
1336 num_tx_buffs = MWIFIEX_MAX_TXRX_BD << reg->tx_start_ptr; in mwifiex_pcie_send_data_complete()
1338 while (((card->txbd_rdptr & reg->tx_mask) != in mwifiex_pcie_send_data_complete()
1339 (rdptr & reg->tx_mask)) || in mwifiex_pcie_send_data_complete()
1340 ((card->txbd_rdptr & reg->tx_rollover_ind) != in mwifiex_pcie_send_data_complete()
1341 (rdptr & reg->tx_rollover_ind))) { in mwifiex_pcie_send_data_complete()
1342 wrdoneidx = (card->txbd_rdptr & reg->tx_mask) >> in mwifiex_pcie_send_data_complete()
1343 reg->tx_start_ptr; in mwifiex_pcie_send_data_complete()
1345 skb = card->tx_buf_list[wrdoneidx]; in mwifiex_pcie_send_data_complete()
1356 if (card->txbd_flush) in mwifiex_pcie_send_data_complete()
1358 -1); in mwifiex_pcie_send_data_complete()
1361 atomic_dec(&adapter->tx_hw_pending); in mwifiex_pcie_send_data_complete()
1364 card->tx_buf_list[wrdoneidx] = NULL; in mwifiex_pcie_send_data_complete()
1366 if (reg->pfu_enabled) { in mwifiex_pcie_send_data_complete()
1367 desc2 = card->txbd_ring[wrdoneidx]; in mwifiex_pcie_send_data_complete()
1370 desc = card->txbd_ring[wrdoneidx]; in mwifiex_pcie_send_data_complete()
1373 switch (card->dev->device) { in mwifiex_pcie_send_data_complete()
1375 card->txbd_rdptr++; in mwifiex_pcie_send_data_complete()
1379 card->txbd_rdptr += reg->ring_tx_start_ptr; in mwifiex_pcie_send_data_complete()
1384 if ((card->txbd_rdptr & reg->tx_mask) == num_tx_buffs) in mwifiex_pcie_send_data_complete()
1385 card->txbd_rdptr = ((card->txbd_rdptr & in mwifiex_pcie_send_data_complete()
1386 reg->tx_rollover_ind) ^ in mwifiex_pcie_send_data_complete()
1387 reg->tx_rollover_ind); in mwifiex_pcie_send_data_complete()
1391 adapter->data_sent = false; in mwifiex_pcie_send_data_complete()
1393 if (card->txbd_flush) { in mwifiex_pcie_send_data_complete()
1394 if (mwifiex_pcie_txbd_empty(card, card->txbd_rdptr)) in mwifiex_pcie_send_data_complete()
1395 card->txbd_flush = 0; in mwifiex_pcie_send_data_complete()
1414 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_data()
1415 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_send_data()
1422 if (!(skb->data && skb->len)) { in mwifiex_pcie_send_data()
1425 __func__, skb->data, skb->len); in mwifiex_pcie_send_data()
1426 return -1; in mwifiex_pcie_send_data()
1432 num_tx_buffs = MWIFIEX_MAX_TXRX_BD << reg->tx_start_ptr; in mwifiex_pcie_send_data()
1435 card->txbd_rdptr, card->txbd_wrptr); in mwifiex_pcie_send_data()
1439 adapter->data_sent = true; in mwifiex_pcie_send_data()
1440 payload = skb->data; in mwifiex_pcie_send_data()
1441 put_unaligned_le16((u16)skb->len, payload + 0); in mwifiex_pcie_send_data()
1444 if (mwifiex_map_pci_memory(adapter, skb, skb->len, in mwifiex_pcie_send_data()
1446 return -1; in mwifiex_pcie_send_data()
1448 wrindx = (card->txbd_wrptr & reg->tx_mask) >> reg->tx_start_ptr; in mwifiex_pcie_send_data()
1450 card->tx_buf_list[wrindx] = skb; in mwifiex_pcie_send_data()
1451 atomic_inc(&adapter->tx_hw_pending); in mwifiex_pcie_send_data()
1453 if (reg->pfu_enabled) { in mwifiex_pcie_send_data()
1454 desc2 = card->txbd_ring[wrindx]; in mwifiex_pcie_send_data()
1455 desc2->paddr = buf_pa; in mwifiex_pcie_send_data()
1456 desc2->len = (u16)skb->len; in mwifiex_pcie_send_data()
1457 desc2->frag_len = (u16)skb->len; in mwifiex_pcie_send_data()
1458 desc2->offset = 0; in mwifiex_pcie_send_data()
1459 desc2->flags = MWIFIEX_BD_FLAG_FIRST_DESC | in mwifiex_pcie_send_data()
1462 desc = card->txbd_ring[wrindx]; in mwifiex_pcie_send_data()
1463 desc->paddr = buf_pa; in mwifiex_pcie_send_data()
1464 desc->len = (u16)skb->len; in mwifiex_pcie_send_data()
1465 desc->flags = MWIFIEX_BD_FLAG_FIRST_DESC | in mwifiex_pcie_send_data()
1469 switch (card->dev->device) { in mwifiex_pcie_send_data()
1471 card->txbd_wrptr++; in mwifiex_pcie_send_data()
1475 card->txbd_wrptr += reg->ring_tx_start_ptr; in mwifiex_pcie_send_data()
1479 if ((card->txbd_wrptr & reg->tx_mask) == num_tx_buffs) in mwifiex_pcie_send_data()
1480 card->txbd_wrptr = ((card->txbd_wrptr & in mwifiex_pcie_send_data()
1481 reg->tx_rollover_ind) ^ in mwifiex_pcie_send_data()
1482 reg->tx_rollover_ind); in mwifiex_pcie_send_data()
1484 rx_val = card->rxbd_rdptr & reg->rx_wrap_mask; in mwifiex_pcie_send_data()
1485 /* Write the TX ring write pointer in to reg->tx_wrptr */ in mwifiex_pcie_send_data()
1486 if (mwifiex_write_reg(adapter, reg->tx_wrptr, in mwifiex_pcie_send_data()
1487 card->txbd_wrptr | rx_val)) { in mwifiex_pcie_send_data()
1489 "SEND DATA: failed to write reg->tx_wrptr\n"); in mwifiex_pcie_send_data()
1490 ret = -1; in mwifiex_pcie_send_data()
1494 tx_param->next_pkt_len) { in mwifiex_pcie_send_data()
1497 "SEND DATA: delay dnld-rdy interrupt.\n"); in mwifiex_pcie_send_data()
1498 adapter->data_sent = false; in mwifiex_pcie_send_data()
1504 "SEND DATA: failed to assert dnld-rdy interrupt.\n"); in mwifiex_pcie_send_data()
1505 ret = -1; in mwifiex_pcie_send_data()
1512 card->txbd_rdptr, card->txbd_wrptr); in mwifiex_pcie_send_data()
1516 adapter->data_sent = true; in mwifiex_pcie_send_data()
1521 "SEND DATA: failed to assert door-bell intr\n"); in mwifiex_pcie_send_data()
1522 return -EBUSY; in mwifiex_pcie_send_data()
1525 return -EINPROGRESS; in mwifiex_pcie_send_data()
1528 card->tx_buf_list[wrindx] = NULL; in mwifiex_pcie_send_data()
1529 atomic_dec(&adapter->tx_hw_pending); in mwifiex_pcie_send_data()
1530 if (reg->pfu_enabled) in mwifiex_pcie_send_data()
1544 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_recv_data()
1545 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_process_recv_data()
1556 /* Read the RX ring Write pointer set by firmware */ in mwifiex_pcie_process_recv_data()
1557 if (mwifiex_read_reg(adapter, reg->rx_wrptr, &wrptr)) { in mwifiex_pcie_process_recv_data()
1559 "RECV DATA: failed to read reg->rx_wrptr\n"); in mwifiex_pcie_process_recv_data()
1560 ret = -1; in mwifiex_pcie_process_recv_data()
1563 card->rxbd_wrptr = wrptr; in mwifiex_pcie_process_recv_data()
1565 while (((wrptr & reg->rx_mask) != in mwifiex_pcie_process_recv_data()
1566 (card->rxbd_rdptr & reg->rx_mask)) || in mwifiex_pcie_process_recv_data()
1567 ((wrptr & reg->rx_rollover_ind) == in mwifiex_pcie_process_recv_data()
1568 (card->rxbd_rdptr & reg->rx_rollover_ind))) { in mwifiex_pcie_process_recv_data()
1572 rd_index = card->rxbd_rdptr & reg->rx_mask; in mwifiex_pcie_process_recv_data()
1573 skb_data = card->rx_buf_list[rd_index]; in mwifiex_pcie_process_recv_data()
1579 return -ENOMEM; in mwifiex_pcie_process_recv_data()
1582 card->rx_buf_list[rd_index] = NULL; in mwifiex_pcie_process_recv_data()
1584 /* Get data length from interface header - in mwifiex_pcie_process_recv_data()
1587 rx_len = get_unaligned_le16(skb_data->data); in mwifiex_pcie_process_recv_data()
1588 if (WARN_ON(rx_len <= adapter->intf_hdr_len || in mwifiex_pcie_process_recv_data()
1592 rx_len, card->rxbd_rdptr, wrptr); in mwifiex_pcie_process_recv_data()
1598 card->rxbd_rdptr, wrptr, rx_len); in mwifiex_pcie_process_recv_data()
1599 skb_pull(skb_data, adapter->intf_hdr_len); in mwifiex_pcie_process_recv_data()
1600 if (adapter->rx_work_enabled) { in mwifiex_pcie_process_recv_data()
1601 skb_queue_tail(&adapter->rx_data_q, skb_data); in mwifiex_pcie_process_recv_data()
1602 adapter->data_received = true; in mwifiex_pcie_process_recv_data()
1603 atomic_inc(&adapter->rx_pending); in mwifiex_pcie_process_recv_data()
1614 return -ENOMEM; in mwifiex_pcie_process_recv_data()
1620 return -1; in mwifiex_pcie_process_recv_data()
1627 card->rx_buf_list[rd_index] = skb_tmp; in mwifiex_pcie_process_recv_data()
1629 if (reg->pfu_enabled) { in mwifiex_pcie_process_recv_data()
1630 desc2 = card->rxbd_ring[rd_index]; in mwifiex_pcie_process_recv_data()
1631 desc2->paddr = buf_pa; in mwifiex_pcie_process_recv_data()
1632 desc2->len = skb_tmp->len; in mwifiex_pcie_process_recv_data()
1633 desc2->frag_len = skb_tmp->len; in mwifiex_pcie_process_recv_data()
1634 desc2->offset = 0; in mwifiex_pcie_process_recv_data()
1635 desc2->flags = reg->ring_flag_sop | reg->ring_flag_eop; in mwifiex_pcie_process_recv_data()
1637 desc = card->rxbd_ring[rd_index]; in mwifiex_pcie_process_recv_data()
1638 desc->paddr = buf_pa; in mwifiex_pcie_process_recv_data()
1639 desc->len = skb_tmp->len; in mwifiex_pcie_process_recv_data()
1640 desc->flags = 0; in mwifiex_pcie_process_recv_data()
1643 if ((++card->rxbd_rdptr & reg->rx_mask) == in mwifiex_pcie_process_recv_data()
1645 card->rxbd_rdptr = ((card->rxbd_rdptr & in mwifiex_pcie_process_recv_data()
1646 reg->rx_rollover_ind) ^ in mwifiex_pcie_process_recv_data()
1647 reg->rx_rollover_ind); in mwifiex_pcie_process_recv_data()
1651 card->rxbd_rdptr, wrptr); in mwifiex_pcie_process_recv_data()
1653 tx_val = card->txbd_wrptr & reg->tx_wrap_mask; in mwifiex_pcie_process_recv_data()
1654 /* Write the RX ring read pointer in to reg->rx_rdptr */ in mwifiex_pcie_process_recv_data()
1655 if (mwifiex_write_reg(adapter, reg->rx_rdptr, in mwifiex_pcie_process_recv_data()
1656 card->rxbd_rdptr | tx_val)) { in mwifiex_pcie_process_recv_data()
1658 "RECV DATA: failed to write reg->rx_rdptr\n"); in mwifiex_pcie_process_recv_data()
1659 ret = -1; in mwifiex_pcie_process_recv_data()
1663 /* Read the RX ring Write pointer set by firmware */ in mwifiex_pcie_process_recv_data()
1664 if (mwifiex_read_reg(adapter, reg->rx_wrptr, &wrptr)) { in mwifiex_pcie_process_recv_data()
1666 "RECV DATA: failed to read reg->rx_wrptr\n"); in mwifiex_pcie_process_recv_data()
1667 ret = -1; in mwifiex_pcie_process_recv_data()
1672 card->rxbd_wrptr = wrptr; in mwifiex_pcie_process_recv_data()
1686 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_boot_cmd()
1687 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_send_boot_cmd()
1689 if (!(skb->data && skb->len)) { in mwifiex_pcie_send_boot_cmd()
1692 __func__, skb->data, skb->len); in mwifiex_pcie_send_boot_cmd()
1693 return -1; in mwifiex_pcie_send_boot_cmd()
1696 if (mwifiex_map_pci_memory(adapter, skb, skb->len, DMA_TO_DEVICE)) in mwifiex_pcie_send_boot_cmd()
1697 return -1; in mwifiex_pcie_send_boot_cmd()
1704 if (mwifiex_write_reg(adapter, reg->cmd_addr_lo, (u32)buf_pa)) { in mwifiex_pcie_send_boot_cmd()
1709 return -1; in mwifiex_pcie_send_boot_cmd()
1715 if (mwifiex_write_reg(adapter, reg->cmd_addr_hi, in mwifiex_pcie_send_boot_cmd()
1721 return -1; in mwifiex_pcie_send_boot_cmd()
1725 if (mwifiex_write_reg(adapter, reg->cmd_size, skb->len)) { in mwifiex_pcie_send_boot_cmd()
1730 return -1; in mwifiex_pcie_send_boot_cmd()
1737 "%s: failed to assert door-bell intr\n", __func__); in mwifiex_pcie_send_boot_cmd()
1739 return -1; in mwifiex_pcie_send_boot_cmd()
1750 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_init_fw_port()
1751 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_init_fw_port()
1752 int tx_wrap = card->txbd_wrptr & reg->tx_wrap_mask; in mwifiex_pcie_init_fw_port()
1754 /* Write the RX ring read pointer in to reg->rx_rdptr */ in mwifiex_pcie_init_fw_port()
1755 if (mwifiex_write_reg(adapter, reg->rx_rdptr, card->rxbd_rdptr | in mwifiex_pcie_init_fw_port()
1758 "RECV DATA: failed to write reg->rx_rdptr\n"); in mwifiex_pcie_init_fw_port()
1759 return -1; in mwifiex_pcie_init_fw_port()
1769 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_cmd()
1770 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_send_cmd()
1773 u8 *payload = (u8 *)skb->data; in mwifiex_pcie_send_cmd()
1775 if (!(skb->data && skb->len)) { in mwifiex_pcie_send_cmd()
1778 __func__, skb->data, skb->len); in mwifiex_pcie_send_cmd()
1779 return -1; in mwifiex_pcie_send_cmd()
1783 if (!card->cmdrsp_buf) { in mwifiex_pcie_send_cmd()
1785 "No response buffer available, send command failed\n"); in mwifiex_pcie_send_cmd()
1786 return -EBUSY; in mwifiex_pcie_send_cmd()
1792 adapter->cmd_sent = true; in mwifiex_pcie_send_cmd()
1794 put_unaligned_le16((u16)skb->len, &payload[0]); in mwifiex_pcie_send_cmd()
1797 if (mwifiex_map_pci_memory(adapter, skb, skb->len, DMA_TO_DEVICE)) in mwifiex_pcie_send_cmd()
1798 return -1; in mwifiex_pcie_send_cmd()
1800 card->cmd_buf = skb; in mwifiex_pcie_send_cmd()
1817 if (card->cmdrsp_buf) { in mwifiex_pcie_send_cmd()
1818 cmdrsp_buf_pa = MWIFIEX_SKB_DMA_ADDR(card->cmdrsp_buf); in mwifiex_pcie_send_cmd()
1821 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_lo, in mwifiex_pcie_send_cmd()
1825 ret = -1; in mwifiex_pcie_send_cmd()
1830 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_hi, in mwifiex_pcie_send_cmd()
1834 ret = -1; in mwifiex_pcie_send_cmd()
1839 cmd_buf_pa = MWIFIEX_SKB_DMA_ADDR(card->cmd_buf); in mwifiex_pcie_send_cmd()
1840 /* Write the lower 32bits of the physical address to reg->cmd_addr_lo */ in mwifiex_pcie_send_cmd()
1841 if (mwifiex_write_reg(adapter, reg->cmd_addr_lo, in mwifiex_pcie_send_cmd()
1845 ret = -1; in mwifiex_pcie_send_cmd()
1848 /* Write the upper 32bits of the physical address to reg->cmd_addr_hi */ in mwifiex_pcie_send_cmd()
1849 if (mwifiex_write_reg(adapter, reg->cmd_addr_hi, in mwifiex_pcie_send_cmd()
1853 ret = -1; in mwifiex_pcie_send_cmd()
1857 /* Write the command length to reg->cmd_size */ in mwifiex_pcie_send_cmd()
1858 if (mwifiex_write_reg(adapter, reg->cmd_size, in mwifiex_pcie_send_cmd()
1859 card->cmd_buf->len)) { in mwifiex_pcie_send_cmd()
1861 "Failed to write cmd len to reg->cmd_size\n"); in mwifiex_pcie_send_cmd()
1862 ret = -1; in mwifiex_pcie_send_cmd()
1870 "Failed to assert door-bell intr\n"); in mwifiex_pcie_send_cmd()
1871 ret = -1; in mwifiex_pcie_send_cmd()
1877 adapter->cmd_sent = false; in mwifiex_pcie_send_cmd()
1887 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_cmd_complete()
1888 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_process_cmd_complete()
1889 struct sk_buff *skb = card->cmdrsp_buf; in mwifiex_pcie_process_cmd_complete()
1896 if (adapter->curr_cmd) in mwifiex_pcie_process_cmd_complete()
1899 dma_sync_single_for_cpu(&card->dev->dev, in mwifiex_pcie_process_cmd_complete()
1904 if (card->cmd_buf) { in mwifiex_pcie_process_cmd_complete()
1905 mwifiex_unmap_pci_memory(adapter, card->cmd_buf, in mwifiex_pcie_process_cmd_complete()
1907 dev_kfree_skb_any(card->cmd_buf); in mwifiex_pcie_process_cmd_complete()
1908 card->cmd_buf = NULL; in mwifiex_pcie_process_cmd_complete()
1911 rx_len = get_unaligned_le16(skb->data); in mwifiex_pcie_process_cmd_complete()
1912 skb_put(skb, MWIFIEX_UPLD_SIZE - skb->len); in mwifiex_pcie_process_cmd_complete()
1915 if (!adapter->curr_cmd) { in mwifiex_pcie_process_cmd_complete()
1916 if (adapter->ps_state == PS_STATE_SLEEP_CFM) { in mwifiex_pcie_process_cmd_complete()
1917 dma_sync_single_for_device(&card->dev->dev, in mwifiex_pcie_process_cmd_complete()
1926 return -1; in mwifiex_pcie_process_cmd_complete()
1932 skb_pull(skb, adapter->intf_hdr_len); in mwifiex_pcie_process_cmd_complete()
1933 while (reg->sleep_cookie && (count++ < 10) && in mwifiex_pcie_process_cmd_complete()
1937 mwifiex_process_sleep_confirm_resp(adapter, skb->data, in mwifiex_pcie_process_cmd_complete()
1938 skb->len); in mwifiex_pcie_process_cmd_complete()
1941 "There is no command but got cmdrsp\n"); in mwifiex_pcie_process_cmd_complete()
1943 memcpy(adapter->upld_buf, skb->data, in mwifiex_pcie_process_cmd_complete()
1944 min_t(u32, MWIFIEX_SIZE_OF_CMD_BUFFER, skb->len)); in mwifiex_pcie_process_cmd_complete()
1945 skb_push(skb, adapter->intf_hdr_len); in mwifiex_pcie_process_cmd_complete()
1948 return -1; in mwifiex_pcie_process_cmd_complete()
1950 skb_pull(skb, adapter->intf_hdr_len); in mwifiex_pcie_process_cmd_complete()
1951 adapter->curr_cmd->resp_skb = skb; in mwifiex_pcie_process_cmd_complete()
1952 adapter->cmd_resp_received = true; in mwifiex_pcie_process_cmd_complete()
1955 card->cmdrsp_buf = NULL; in mwifiex_pcie_process_cmd_complete()
1957 /* Clear the cmd-rsp buffer address in scratch registers. This in mwifiex_pcie_process_cmd_complete()
1960 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_lo, 0)) { in mwifiex_pcie_process_cmd_complete()
1963 return -1; in mwifiex_pcie_process_cmd_complete()
1967 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_hi, 0)) { in mwifiex_pcie_process_cmd_complete()
1970 return -1; in mwifiex_pcie_process_cmd_complete()
1983 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_cmdrsp_complete()
1986 card->cmdrsp_buf = skb; in mwifiex_pcie_cmdrsp_complete()
1987 skb_push(card->cmdrsp_buf, adapter->intf_hdr_len); in mwifiex_pcie_cmdrsp_complete()
1990 return -1; in mwifiex_pcie_cmdrsp_complete()
2001 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_event_ready()
2002 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_process_event_ready()
2003 u32 rdptr = card->evtbd_rdptr & MWIFIEX_EVTBD_MASK; in mwifiex_pcie_process_event_ready()
2010 if (adapter->event_received) { in mwifiex_pcie_process_event_ready()
2019 "info: Invalid read pointer...\n"); in mwifiex_pcie_process_event_ready()
2020 return -1; in mwifiex_pcie_process_event_ready()
2023 /* Read the event ring write pointer set by firmware */ in mwifiex_pcie_process_event_ready()
2024 if (mwifiex_read_reg(adapter, reg->evt_wrptr, &wrptr)) { in mwifiex_pcie_process_event_ready()
2026 "EventReady: failed to read reg->evt_wrptr\n"); in mwifiex_pcie_process_event_ready()
2027 return -1; in mwifiex_pcie_process_event_ready()
2032 card->evtbd_rdptr, wrptr); in mwifiex_pcie_process_event_ready()
2033 if (((wrptr & MWIFIEX_EVTBD_MASK) != (card->evtbd_rdptr in mwifiex_pcie_process_event_ready()
2035 ((wrptr & reg->evt_rollover_ind) == in mwifiex_pcie_process_event_ready()
2036 (card->evtbd_rdptr & reg->evt_rollover_ind))) { in mwifiex_pcie_process_event_ready()
2042 "info: Read Index: %d\n", rdptr); in mwifiex_pcie_process_event_ready()
2043 skb_cmd = card->evt_buf_list[rdptr]; in mwifiex_pcie_process_event_ready()
2048 card->evt_buf_list[rdptr] = NULL; in mwifiex_pcie_process_event_ready()
2049 desc = card->evtbd_ring[rdptr]; in mwifiex_pcie_process_event_ready()
2053 &skb_cmd->data[adapter->intf_hdr_len]); in mwifiex_pcie_process_event_ready()
2054 adapter->event_cause = event; in mwifiex_pcie_process_event_ready()
2057 memcpy(&data_len, skb_cmd->data, sizeof(__le16)); in mwifiex_pcie_process_event_ready()
2060 skb_pull(skb_cmd, adapter->intf_hdr_len); in mwifiex_pcie_process_event_ready()
2066 memcpy(adapter->event_body, skb_cmd->data + in mwifiex_pcie_process_event_ready()
2067 MWIFIEX_EVENT_HEADER_LEN, evt_len - in mwifiex_pcie_process_event_ready()
2070 adapter->event_received = true; in mwifiex_pcie_process_event_ready()
2071 adapter->event_skb = skb_cmd; in mwifiex_pcie_process_event_ready()
2073 /* Do not update the event read pointer here, wait till the in mwifiex_pcie_process_event_ready()
2082 return -1; in mwifiex_pcie_process_event_ready()
2095 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_event_complete()
2096 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_event_complete()
2098 u32 rdptr = card->evtbd_rdptr & MWIFIEX_EVTBD_MASK; in mwifiex_pcie_event_complete()
2109 return -EINVAL; in mwifiex_pcie_event_complete()
2112 /* Read the event ring write pointer set by firmware */ in mwifiex_pcie_event_complete()
2113 if (mwifiex_read_reg(adapter, reg->evt_wrptr, &wrptr)) { in mwifiex_pcie_event_complete()
2115 "event_complete: failed to read reg->evt_wrptr\n"); in mwifiex_pcie_event_complete()
2116 return -1; in mwifiex_pcie_event_complete()
2119 if (!card->evt_buf_list[rdptr]) { in mwifiex_pcie_event_complete()
2120 skb_push(skb, adapter->intf_hdr_len); in mwifiex_pcie_event_complete()
2121 skb_put(skb, MAX_EVENT_SIZE - skb->len); in mwifiex_pcie_event_complete()
2125 return -1; in mwifiex_pcie_event_complete()
2126 card->evt_buf_list[rdptr] = skb; in mwifiex_pcie_event_complete()
2127 desc = card->evtbd_ring[rdptr]; in mwifiex_pcie_event_complete()
2128 desc->paddr = MWIFIEX_SKB_DMA_ADDR(skb); in mwifiex_pcie_event_complete()
2129 desc->len = (u16)skb->len; in mwifiex_pcie_event_complete()
2130 desc->flags = 0; in mwifiex_pcie_event_complete()
2135 rdptr, card->evt_buf_list[rdptr], skb); in mwifiex_pcie_event_complete()
2138 if ((++card->evtbd_rdptr & MWIFIEX_EVTBD_MASK) == MWIFIEX_MAX_EVT_BD) { in mwifiex_pcie_event_complete()
2139 card->evtbd_rdptr = ((card->evtbd_rdptr & in mwifiex_pcie_event_complete()
2140 reg->evt_rollover_ind) ^ in mwifiex_pcie_event_complete()
2141 reg->evt_rollover_ind); in mwifiex_pcie_event_complete()
2146 card->evtbd_rdptr, wrptr); in mwifiex_pcie_event_complete()
2148 /* Write the event ring read pointer in to reg->evt_rdptr */ in mwifiex_pcie_event_complete()
2149 if (mwifiex_write_reg(adapter, reg->evt_rdptr, in mwifiex_pcie_event_complete()
2150 card->evtbd_rdptr)) { in mwifiex_pcie_event_complete()
2152 "event_complete: failed to read reg->evt_rdptr\n"); in mwifiex_pcie_event_complete()
2153 return -1; in mwifiex_pcie_event_complete()
2169 * the offset of tail wifi-only part. If the image is already wifi-only,
2182 if (offset + sizeof(fwdata->header) < sizeof(fwdata->header) || in mwifiex_extract_wifi_fw()
2183 offset + sizeof(fwdata->header) >= firmware_len) { in mwifiex_extract_wifi_fw()
2185 "extract wifi-only fw failure!\n"); in mwifiex_extract_wifi_fw()
2186 ret = -1; in mwifiex_extract_wifi_fw()
2191 dnld_cmd = le32_to_cpu(fwdata->header.dnld_cmd); in mwifiex_extract_wifi_fw()
2192 data_len = le32_to_cpu(fwdata->header.data_length); in mwifiex_extract_wifi_fw()
2195 offset += sizeof(fwdata->header); in mwifiex_extract_wifi_fw()
2201 ret = -1; in mwifiex_extract_wifi_fw()
2205 /* Image start with cmd1, already wifi-only firmware */ in mwifiex_extract_wifi_fw()
2208 "input wifi-only firmware\n"); in mwifiex_extract_wifi_fw()
2214 "no cmd7 before cmd1!\n"); in mwifiex_extract_wifi_fw()
2215 ret = -1; in mwifiex_extract_wifi_fw()
2225 ret = -1; in mwifiex_extract_wifi_fw()
2235 ret = -1; in mwifiex_extract_wifi_fw()
2241 "extract wifi-only fw failure!\n"); in mwifiex_extract_wifi_fw()
2242 ret = -1; in mwifiex_extract_wifi_fw()
2254 ret = -1; in mwifiex_extract_wifi_fw()
2274 u8 *firmware = fw->fw_buf; in mwifiex_prog_fw_w_helper()
2275 u32 firmware_len = fw->fw_len; in mwifiex_prog_fw_w_helper()
2280 struct pcie_service_card *card = adapter->card; in mwifiex_prog_fw_w_helper()
2281 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_prog_fw_w_helper()
2285 "No firmware image found! Terminating download\n"); in mwifiex_prog_fw_w_helper()
2286 return -1; in mwifiex_prog_fw_w_helper()
2296 return -1; in mwifiex_prog_fw_w_helper()
2301 ret = -ENOMEM; in mwifiex_prog_fw_w_helper()
2307 mwifiex_dbg(adapter, FATAL, "Failed to read scratch register 13\n"); in mwifiex_prog_fw_w_helper()
2332 ret = mwifiex_read_reg(adapter, reg->cmd_size, in mwifiex_prog_fw_w_helper()
2350 ret = -1; in mwifiex_prog_fw_w_helper()
2362 ret = -1; in mwifiex_prog_fw_w_helper()
2374 /* Set blocksize to transfer - checking for in mwifiex_prog_fw_w_helper()
2376 if (firmware_len - offset < txlen) in mwifiex_prog_fw_w_helper()
2377 txlen = firmware_len - offset; in mwifiex_prog_fw_w_helper()
2379 tx_blocks = (txlen + card->pcie.blksz_fw_dl - 1) / in mwifiex_prog_fw_w_helper()
2380 card->pcie.blksz_fw_dl; in mwifiex_prog_fw_w_helper()
2383 memmove(skb->data, &firmware[offset], txlen); in mwifiex_prog_fw_w_helper()
2386 skb_put(skb, MWIFIEX_UPLD_SIZE - skb->len); in mwifiex_prog_fw_w_helper()
2387 skb_trim(skb, tx_blocks * card->pcie.blksz_fw_dl); in mwifiex_prog_fw_w_helper()
2393 ret = -1; in mwifiex_prog_fw_w_helper()
2402 "%s: Failed to read\t" in mwifiex_prog_fw_w_helper()
2407 ret = -1; in mwifiex_prog_fw_w_helper()
2419 ret = -1; in mwifiex_prog_fw_w_helper()
2446 struct pcie_service_card *card = adapter->card; in mwifiex_check_fw_status()
2447 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_check_fw_status()
2455 return -1; in mwifiex_check_fw_status()
2460 if (mwifiex_write_reg(adapter, reg->drv_rdy, in mwifiex_check_fw_status()
2464 return -1; in mwifiex_check_fw_status()
2469 if (mwifiex_read_reg(adapter, reg->fw_status, in mwifiex_check_fw_status()
2471 ret = -1; in mwifiex_check_fw_status()
2485 ret = -1; in mwifiex_check_fw_status()
2499 struct pcie_service_card *card = adapter->card; in mwifiex_check_winner_status()
2500 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_check_winner_status()
2502 if (mwifiex_read_reg(adapter, reg->fw_status, &winner)) { in mwifiex_check_winner_status()
2503 ret = -1; in mwifiex_check_winner_status()
2505 mwifiex_dbg(adapter, INFO, "PCI-E is the winner\n"); in mwifiex_check_winner_status()
2506 adapter->winner = 1; in mwifiex_check_winner_status()
2509 "PCI-E is not the winner <%#x>", winner); in mwifiex_check_winner_status()
2523 struct pcie_service_card *card = adapter->card; in mwifiex_interrupt_status()
2525 if (card->msi_enable) { in mwifiex_interrupt_status()
2526 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2527 adapter->int_status = 1; in mwifiex_interrupt_status()
2528 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2535 if (card->msix_enable && msg_id >= 0) { in mwifiex_interrupt_status()
2540 mwifiex_dbg(adapter, ERROR, "Read register failed\n"); in mwifiex_interrupt_status()
2559 if (!adapter->pps_uapsd_mode && in mwifiex_interrupt_status()
2560 adapter->ps_state == PS_STATE_SLEEP && in mwifiex_interrupt_status()
2566 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_interrupt_status()
2567 adapter->pm_wakeup_fw_try = false; in mwifiex_interrupt_status()
2568 del_timer(&adapter->wakeup_timer); in mwifiex_interrupt_status()
2571 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2572 adapter->int_status |= pcie_ireg; in mwifiex_interrupt_status()
2573 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2586 struct pci_dev *pdev = ctx->dev; in mwifiex_pcie_interrupt()
2592 if (!card->adapter) { in mwifiex_pcie_interrupt()
2594 card ? card->adapter : NULL); in mwifiex_pcie_interrupt()
2597 adapter = card->adapter; in mwifiex_pcie_interrupt()
2599 if (test_bit(MWIFIEX_SURPRISE_REMOVED, &adapter->work_flags)) in mwifiex_pcie_interrupt()
2602 if (card->msix_enable) in mwifiex_pcie_interrupt()
2603 mwifiex_interrupt_status(adapter, ctx->msg_id); in mwifiex_pcie_interrupt()
2605 mwifiex_interrupt_status(adapter, -1); in mwifiex_pcie_interrupt()
2616 * The following interrupts are checked and handled by this function -
2617 * - Data sent
2618 * - Command sent
2619 * - Command received
2620 * - Packets received
2621 * - Events received
2631 struct pcie_service_card *card = adapter->card; in mwifiex_process_int_status()
2633 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_process_int_status()
2634 if (!card->msi_enable) { in mwifiex_process_int_status()
2636 pcie_ireg = adapter->int_status; in mwifiex_process_int_status()
2638 adapter->int_status = 0; in mwifiex_process_int_status()
2639 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_process_int_status()
2641 if (card->msi_enable) { in mwifiex_process_int_status()
2646 "Read register failed\n"); in mwifiex_process_int_status()
2647 return -1; in mwifiex_process_int_status()
2656 return -1; in mwifiex_process_int_status()
2658 if (!adapter->pps_uapsd_mode && in mwifiex_process_int_status()
2659 adapter->ps_state == PS_STATE_SLEEP) { in mwifiex_process_int_status()
2660 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_process_int_status()
2661 adapter->pm_wakeup_fw_try = false; in mwifiex_process_int_status()
2662 del_timer(&adapter->wakeup_timer); in mwifiex_process_int_status()
2687 if (adapter->cmd_sent) { in mwifiex_process_int_status()
2690 adapter->cmd_sent = false; in mwifiex_process_int_status()
2700 adapter->cmd_sent, adapter->data_sent); in mwifiex_process_int_status()
2701 if (!card->msi_enable && !card->msix_enable && in mwifiex_process_int_status()
2702 adapter->ps_state != PS_STATE_SLEEP) in mwifiex_process_int_status()
2725 return -1; in mwifiex_pcie_host_to_card()
2745 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_reg_dump()
2746 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_reg_dump()
2756 if (mwifiex_read_reg(adapter, reg->fw_status, &value)) { in mwifiex_pcie_reg_dump()
2757 mwifiex_dbg(adapter, ERROR, "failed to read firmware status"); in mwifiex_pcie_reg_dump()
2774 return p - drv_buf; in mwifiex_pcie_reg_dump()
2777 /* This function read/write firmware */
2784 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_rdwr_firmware()
2785 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_rdwr_firmware()
2787 if (mwifiex_read_reg(adapter, reg->fw_status, &fw_status)) in mwifiex_pcie_rdwr_firmware()
2790 ret = mwifiex_write_reg(adapter, reg->fw_dump_ctrl, in mwifiex_pcie_rdwr_firmware()
2791 reg->fw_dump_host_ready); in mwifiex_pcie_rdwr_firmware()
2799 mwifiex_read_reg_byte(adapter, reg->fw_dump_ctrl, &ctrl_data); in mwifiex_pcie_rdwr_firmware()
2804 if (ctrl_data != reg->fw_dump_host_ready) { in mwifiex_pcie_rdwr_firmware()
2806 "The ctrl reg was changed, re-try again!\n"); in mwifiex_pcie_rdwr_firmware()
2807 ret = mwifiex_write_reg(adapter, reg->fw_dump_ctrl, in mwifiex_pcie_rdwr_firmware()
2808 reg->fw_dump_host_ready); in mwifiex_pcie_rdwr_firmware()
2825 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_fw_dump()
2826 const struct mwifiex_pcie_card_reg *creg = card->pcie.reg; in mwifiex_pcie_fw_dump()
2834 if (!card->pcie.can_dump_fw) in mwifiex_pcie_fw_dump()
2837 for (idx = 0; idx < adapter->num_mem_types; idx++) { in mwifiex_pcie_fw_dump()
2839 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_pcie_fw_dump()
2841 if (entry->mem_ptr) { in mwifiex_pcie_fw_dump()
2842 vfree(entry->mem_ptr); in mwifiex_pcie_fw_dump()
2843 entry->mem_ptr = NULL; in mwifiex_pcie_fw_dump()
2845 entry->mem_size = 0; in mwifiex_pcie_fw_dump()
2850 /* Read the number of the memories which will dump */ in mwifiex_pcie_fw_dump()
2855 reg = creg->fw_dump_start; in mwifiex_pcie_fw_dump()
2864 /* Read the length of every memory which will dump */ in mwifiex_pcie_fw_dump()
2867 &adapter->mem_type_mapping_tbl[idx]; in mwifiex_pcie_fw_dump()
2874 reg = creg->fw_dump_start; in mwifiex_pcie_fw_dump()
2886 ret = mwifiex_write_reg(adapter, creg->fw_dump_ctrl, in mwifiex_pcie_fw_dump()
2887 creg->fw_dump_read_done); in mwifiex_pcie_fw_dump()
2896 "%s_SIZE=0x%x\n", entry->mem_name, memory_size); in mwifiex_pcie_fw_dump()
2897 entry->mem_ptr = vmalloc(memory_size + 1); in mwifiex_pcie_fw_dump()
2898 entry->mem_size = memory_size; in mwifiex_pcie_fw_dump()
2899 if (!entry->mem_ptr) { in mwifiex_pcie_fw_dump()
2901 "Vmalloc %s failed\n", entry->mem_name); in mwifiex_pcie_fw_dump()
2904 dbg_ptr = entry->mem_ptr; in mwifiex_pcie_fw_dump()
2907 doneflag = entry->done_flag; in mwifiex_pcie_fw_dump()
2909 entry->mem_name); in mwifiex_pcie_fw_dump()
2916 reg_start = creg->fw_dump_start; in mwifiex_pcie_fw_dump()
2917 reg_end = creg->fw_dump_end; in mwifiex_pcie_fw_dump()
2925 "pre-allocated buf not enough\n"); in mwifiex_pcie_fw_dump()
2930 memcpy(tmp_ptr, entry->mem_ptr, memory_size); in mwifiex_pcie_fw_dump()
2931 vfree(entry->mem_ptr); in mwifiex_pcie_fw_dump()
2932 entry->mem_ptr = tmp_ptr; in mwifiex_pcie_fw_dump()
2934 dbg_ptr = entry->mem_ptr + memory_size; in mwifiex_pcie_fw_dump()
2936 end_ptr = entry->mem_ptr + memory_size; in mwifiex_pcie_fw_dump()
2944 entry->mem_name, dbg_ptr - entry->mem_ptr); in mwifiex_pcie_fw_dump()
2953 adapter->devdump_data = vzalloc(MWIFIEX_FW_DUMP_SIZE); in mwifiex_pcie_device_dump_work()
2954 if (!adapter->devdump_data) { in mwifiex_pcie_device_dump_work()
2968 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_card_reset_work()
2973 pci_try_reset_function(card->dev); in mwifiex_pcie_card_reset_work()
2982 &card->work_flags)) in mwifiex_pcie_work()
2983 mwifiex_pcie_device_dump_work(card->adapter); in mwifiex_pcie_work()
2985 &card->work_flags)) in mwifiex_pcie_work()
2986 mwifiex_pcie_card_reset_work(card->adapter); in mwifiex_pcie_work()
2992 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_device_dump()
2995 &card->work_flags)) in mwifiex_pcie_device_dump()
2996 schedule_work(&card->work); in mwifiex_pcie_device_dump()
3001 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_card_reset()
3003 if (!test_and_set_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags)) in mwifiex_pcie_card_reset()
3004 schedule_work(&card->work); in mwifiex_pcie_card_reset()
3009 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_alloc_buffers()
3010 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_alloc_buffers()
3013 card->cmdrsp_buf = NULL; in mwifiex_pcie_alloc_buffers()
3038 if (reg->sleep_cookie) { in mwifiex_pcie_alloc_buffers()
3045 card->sleep_cookie_vbase = NULL; in mwifiex_pcie_alloc_buffers()
3064 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_free_buffers()
3065 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_free_buffers()
3067 if (reg->sleep_cookie) in mwifiex_pcie_free_buffers()
3077 * This function initializes the PCI-E host memory space, WCB rings, etc.
3081 struct pcie_service_card *card = adapter->card; in mwifiex_init_pcie()
3083 struct pci_dev *pdev = card->dev; in mwifiex_init_pcie()
3093 ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in mwifiex_init_pcie()
3104 card->pci_mmap = pci_iomap(pdev, 0, 0); in mwifiex_init_pcie()
3105 if (!card->pci_mmap) { in mwifiex_init_pcie()
3107 ret = -EIO; in mwifiex_init_pcie()
3115 card->pci_mmap1 = pci_iomap(pdev, 2, 0); in mwifiex_init_pcie()
3116 if (!card->pci_mmap1) { in mwifiex_init_pcie()
3118 ret = -EIO; in mwifiex_init_pcie()
3123 card->pci_mmap, card->pci_mmap1); in mwifiex_init_pcie()
3132 pci_iounmap(pdev, card->pci_mmap1); in mwifiex_init_pcie()
3136 pci_iounmap(pdev, card->pci_mmap); in mwifiex_init_pcie()
3151 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_pcie()
3152 struct pci_dev *pdev = card->dev; in mwifiex_cleanup_pcie()
3153 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_cleanup_pcie()
3161 if (!card->pci_reset_ongoing) { in mwifiex_cleanup_pcie()
3163 cancel_work_sync(&card->work); in mwifiex_cleanup_pcie()
3170 mwifiex_read_reg(adapter, reg->fw_status, &fw_status); in mwifiex_cleanup_pcie()
3174 if (mwifiex_write_reg(adapter, reg->drv_rdy, 0x00000000)) in mwifiex_cleanup_pcie()
3176 "Failed to write driver not-ready signature\n"); in mwifiex_cleanup_pcie()
3181 pci_iounmap(pdev, card->pci_mmap); in mwifiex_cleanup_pcie()
3182 pci_iounmap(pdev, card->pci_mmap1); in mwifiex_cleanup_pcie()
3192 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_request_irq()
3193 struct pci_dev *pdev = card->dev; in mwifiex_pcie_request_irq()
3195 if (card->pcie.reg->msix_support) { in mwifiex_pcie_request_irq()
3197 card->msix_entries[i].entry = i; in mwifiex_pcie_request_irq()
3198 ret = pci_enable_msix_exact(pdev, card->msix_entries, in mwifiex_pcie_request_irq()
3202 card->msix_ctx[i].dev = pdev; in mwifiex_pcie_request_irq()
3203 card->msix_ctx[i].msg_id = i; in mwifiex_pcie_request_irq()
3205 ret = request_irq(card->msix_entries[i].vector, in mwifiex_pcie_request_irq()
3208 &card->msix_ctx[i]); in mwifiex_pcie_request_irq()
3217 free_irq(card->msix_entries[j].vector, in mwifiex_pcie_request_irq()
3218 &card->msix_ctx[i]); in mwifiex_pcie_request_irq()
3222 card->msix_enable = 1; in mwifiex_pcie_request_irq()
3231 card->msi_enable = 1; in mwifiex_pcie_request_irq()
3233 mwifiex_dbg(adapter, INFO, "msi_enable = %d\n", card->msi_enable); in mwifiex_pcie_request_irq()
3235 card->share_irq_ctx.dev = pdev; in mwifiex_pcie_request_irq()
3236 card->share_irq_ctx.msg_id = -1; in mwifiex_pcie_request_irq()
3237 ret = request_irq(pdev->irq, mwifiex_pcie_interrupt, IRQF_SHARED, in mwifiex_pcie_request_irq()
3238 "MRVL_PCIE", &card->share_irq_ctx); in mwifiex_pcie_request_irq()
3241 return -1; in mwifiex_pcie_request_irq()
3250 * Read revision id register to get revision id
3256 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_get_fw_name()
3258 switch (card->dev->device) { in mwifiex_pcie_get_fw_name()
3260 strcpy(adapter->fw_name, PCIE8766_DEFAULT_FW_NAME); in mwifiex_pcie_get_fw_name()
3268 strcpy(adapter->fw_name, PCIE8897_A0_FW_NAME); in mwifiex_pcie_get_fw_name()
3271 strcpy(adapter->fw_name, PCIE8897_B0_FW_NAME); in mwifiex_pcie_get_fw_name()
3274 strcpy(adapter->fw_name, PCIE8897_DEFAULT_FW_NAME); in mwifiex_pcie_get_fw_name()
3289 strcpy(adapter->fw_name, PCIEUART8997_FW_NAME_V4); in mwifiex_pcie_get_fw_name()
3291 strcpy(adapter->fw_name, PCIEUSB8997_FW_NAME_V4); in mwifiex_pcie_get_fw_name()
3305 struct pcie_service_card *card = adapter->card; in mwifiex_register_dev()
3308 card->adapter = adapter; in mwifiex_register_dev()
3311 return -1; in mwifiex_register_dev()
3313 adapter->tx_buf_size = card->pcie.tx_buf_size; in mwifiex_register_dev()
3314 adapter->mem_type_mapping_tbl = card->pcie.mem_type_mapping_tbl; in mwifiex_register_dev()
3315 adapter->num_mem_types = card->pcie.num_mem_types; in mwifiex_register_dev()
3316 adapter->ext_scan = card->pcie.can_ext_scan; in mwifiex_register_dev()
3330 struct pcie_service_card *card = adapter->card; in mwifiex_unregister_dev()
3331 struct pci_dev *pdev = card->dev; in mwifiex_unregister_dev()
3334 if (card->msix_enable) { in mwifiex_unregister_dev()
3336 synchronize_irq(card->msix_entries[i].vector); in mwifiex_unregister_dev()
3339 free_irq(card->msix_entries[i].vector, in mwifiex_unregister_dev()
3340 &card->msix_ctx[i]); in mwifiex_unregister_dev()
3342 card->msix_enable = 0; in mwifiex_unregister_dev()
3347 free_irq(card->dev->irq, &card->share_irq_ctx); in mwifiex_unregister_dev()
3349 if (card->msi_enable) in mwifiex_unregister_dev()
3352 card->adapter = NULL; in mwifiex_unregister_dev()
3356 * This function initializes the PCI-E host memory space, WCB rings, etc.,
3357 * similar to mwifiex_init_pcie(), but without resetting PCI-E state.
3361 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_up_dev()
3362 struct pci_dev *pdev = card->dev; in mwifiex_pcie_up_dev()
3367 adapter->tx_buf_size = card->pcie.tx_buf_size; in mwifiex_pcie_up_dev()
3374 /* This function cleans up the PCI-E host memory space. */
3377 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_down_dev()
3378 const struct mwifiex_pcie_card_reg *reg = card->pcie.reg; in mwifiex_pcie_down_dev()
3379 struct pci_dev *pdev = card->dev; in mwifiex_pcie_down_dev()
3381 if (mwifiex_write_reg(adapter, reg->drv_rdy, 0x00000000)) in mwifiex_pcie_down_dev()
3382 mwifiex_dbg(adapter, ERROR, "Failed to write driver not-ready signature\n"); in mwifiex_pcie_down_dev()
3386 adapter->seq_num = 0; in mwifiex_pcie_down_dev()
3423 MODULE_DESCRIPTION("Marvell WiFi-Ex PCI-Express Driver version " PCIE_VERSION);