Lines Matching refs:adapter

52 mwifiex_map_pci_memory(struct mwifiex_adapter *adapter, struct sk_buff *skb,  in mwifiex_map_pci_memory()  argument
55 struct pcie_service_card *card = adapter->card; in mwifiex_map_pci_memory()
60 dev_err(adapter->dev, "failed to map pci memory!\n"); in mwifiex_map_pci_memory()
68 static void mwifiex_unmap_pci_memory(struct mwifiex_adapter *adapter, in mwifiex_unmap_pci_memory() argument
71 struct pcie_service_card *card = adapter->card; in mwifiex_unmap_pci_memory()
81 static bool mwifiex_pcie_ok_to_access_hw(struct mwifiex_adapter *adapter) in mwifiex_pcie_ok_to_access_hw() argument
84 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_ok_to_access_hw()
92 dev_dbg(adapter->dev, "info: ACCESS_HW: sleep cookie=0x%x\n", in mwifiex_pcie_ok_to_access_hw()
112 struct mwifiex_adapter *adapter; in mwifiex_pcie_suspend() local
119 if (!card || !card->adapter) { in mwifiex_pcie_suspend()
128 adapter = card->adapter; in mwifiex_pcie_suspend()
130 hs_actived = mwifiex_enable_hs(adapter); in mwifiex_pcie_suspend()
133 adapter->is_suspended = true; in mwifiex_pcie_suspend()
134 adapter->hs_enabling = false; in mwifiex_pcie_suspend()
149 struct mwifiex_adapter *adapter; in mwifiex_pcie_resume() local
155 if (!card || !card->adapter) { in mwifiex_pcie_resume()
164 adapter = card->adapter; in mwifiex_pcie_resume()
166 if (!adapter->is_suspended) { in mwifiex_pcie_resume()
167 dev_warn(adapter->dev, "Device already resumed\n"); in mwifiex_pcie_resume()
171 adapter->is_suspended = false; in mwifiex_pcie_resume()
173 mwifiex_cancel_hs(mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_STA), in mwifiex_pcie_resume()
226 struct mwifiex_adapter *adapter; in mwifiex_pcie_remove() local
233 adapter = card->adapter; in mwifiex_pcie_remove()
234 if (!adapter || !adapter->priv_num) in mwifiex_pcie_remove()
239 if (adapter->is_suspended) in mwifiex_pcie_remove()
243 mwifiex_deauthenticate_all(adapter); in mwifiex_pcie_remove()
245 priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); in mwifiex_pcie_remove()
252 mwifiex_remove_card(card->adapter, &add_remove_card_sem); in mwifiex_pcie_remove()
302 static int mwifiex_write_reg(struct mwifiex_adapter *adapter, int reg, u32 data) in mwifiex_write_reg() argument
304 struct pcie_service_card *card = adapter->card; in mwifiex_write_reg()
314 static int mwifiex_read_reg(struct mwifiex_adapter *adapter, int reg, u32 *data) in mwifiex_read_reg() argument
316 struct pcie_service_card *card = adapter->card; in mwifiex_read_reg()
324 static int mwifiex_read_reg_byte(struct mwifiex_adapter *adapter, in mwifiex_read_reg_byte() argument
327 struct pcie_service_card *card = adapter->card; in mwifiex_read_reg_byte()
337 static void mwifiex_pcie_dev_wakeup_delay(struct mwifiex_adapter *adapter) in mwifiex_pcie_dev_wakeup_delay() argument
341 while (mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_pcie_dev_wakeup_delay()
352 static void mwifiex_delay_for_sleep_cookie(struct mwifiex_adapter *adapter, in mwifiex_delay_for_sleep_cookie() argument
355 struct pcie_service_card *card = adapter->card; in mwifiex_delay_for_sleep_cookie()
364 dev_dbg(adapter->dev, in mwifiex_delay_for_sleep_cookie()
372 dev_dbg(adapter->dev, in mwifiex_delay_for_sleep_cookie()
377 static int mwifiex_pm_wakeup_card(struct mwifiex_adapter *adapter) in mwifiex_pm_wakeup_card() argument
380 struct pcie_service_card *card = adapter->card; in mwifiex_pm_wakeup_card()
383 dev_dbg(adapter->dev, "event: Wakeup device...\n"); in mwifiex_pm_wakeup_card()
386 mwifiex_pcie_dev_wakeup_delay(adapter); in mwifiex_pm_wakeup_card()
389 if (mwifiex_read_reg(adapter, reg->fw_status, &fw_status)) { in mwifiex_pm_wakeup_card()
390 dev_warn(adapter->dev, "Reading fw_status register failed\n"); in mwifiex_pm_wakeup_card()
395 mwifiex_pcie_dev_wakeup_delay(adapter); in mwifiex_pm_wakeup_card()
396 dev_dbg(adapter->dev, "PCIE wakeup: Setting PS_STATE_AWAKE\n"); in mwifiex_pm_wakeup_card()
397 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_pm_wakeup_card()
408 static int mwifiex_pm_wakeup_card_complete(struct mwifiex_adapter *adapter) in mwifiex_pm_wakeup_card_complete() argument
410 dev_dbg(adapter->dev, "cmd: Wakeup device completed\n"); in mwifiex_pm_wakeup_card_complete()
421 static int mwifiex_pcie_disable_host_int(struct mwifiex_adapter *adapter) in mwifiex_pcie_disable_host_int() argument
423 if (mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_pcie_disable_host_int()
424 if (mwifiex_write_reg(adapter, PCIE_HOST_INT_MASK, in mwifiex_pcie_disable_host_int()
426 dev_warn(adapter->dev, "Disable host interrupt failed\n"); in mwifiex_pcie_disable_host_int()
440 static int mwifiex_pcie_enable_host_int(struct mwifiex_adapter *adapter) in mwifiex_pcie_enable_host_int() argument
442 if (mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_pcie_enable_host_int()
444 if (mwifiex_write_reg(adapter, PCIE_HOST_INT_MASK, in mwifiex_pcie_enable_host_int()
446 dev_warn(adapter->dev, "Enable host interrupt failed\n"); in mwifiex_pcie_enable_host_int()
457 static int mwifiex_init_txq_ring(struct mwifiex_adapter *adapter) in mwifiex_init_txq_ring() argument
459 struct pcie_service_card *card = adapter->card; in mwifiex_init_txq_ring()
487 static int mwifiex_init_rxq_ring(struct mwifiex_adapter *adapter) in mwifiex_init_rxq_ring() argument
489 struct pcie_service_card *card = adapter->card; in mwifiex_init_rxq_ring()
502 dev_err(adapter->dev, in mwifiex_init_rxq_ring()
508 if (mwifiex_map_pci_memory(adapter, skb, in mwifiex_init_rxq_ring()
515 dev_dbg(adapter->dev, in mwifiex_init_rxq_ring()
547 static int mwifiex_pcie_init_evt_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_init_evt_ring() argument
549 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_init_evt_ring()
559 dev_err(adapter->dev, in mwifiex_pcie_init_evt_ring()
566 if (mwifiex_map_pci_memory(adapter, skb, MAX_EVENT_SIZE, in mwifiex_pcie_init_evt_ring()
572 dev_dbg(adapter->dev, in mwifiex_pcie_init_evt_ring()
592 static void mwifiex_cleanup_txq_ring(struct mwifiex_adapter *adapter) in mwifiex_cleanup_txq_ring() argument
594 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_txq_ring()
606 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_txq_ring()
615 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_txq_ring()
630 static void mwifiex_cleanup_rxq_ring(struct mwifiex_adapter *adapter) in mwifiex_cleanup_rxq_ring() argument
632 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_rxq_ring()
644 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_rxq_ring()
653 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_rxq_ring()
668 static void mwifiex_cleanup_evt_ring(struct mwifiex_adapter *adapter) in mwifiex_cleanup_evt_ring() argument
670 struct pcie_service_card *card = adapter->card; in mwifiex_cleanup_evt_ring()
679 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_cleanup_evt_ring()
692 static int mwifiex_pcie_create_txbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_create_txbd_ring() argument
694 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_create_txbd_ring()
718 dev_dbg(adapter->dev, "info: txbd_ring: Allocating %d bytes\n", in mwifiex_pcie_create_txbd_ring()
724 dev_err(adapter->dev, in mwifiex_pcie_create_txbd_ring()
729 dev_dbg(adapter->dev, in mwifiex_pcie_create_txbd_ring()
734 return mwifiex_init_txq_ring(adapter); in mwifiex_pcie_create_txbd_ring()
737 static int mwifiex_pcie_delete_txbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_txbd_ring() argument
739 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_txbd_ring()
742 mwifiex_cleanup_txq_ring(adapter); in mwifiex_pcie_delete_txbd_ring()
760 static int mwifiex_pcie_create_rxbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_create_rxbd_ring() argument
762 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_create_rxbd_ring()
780 dev_dbg(adapter->dev, "info: rxbd_ring: Allocating %d bytes\n", in mwifiex_pcie_create_rxbd_ring()
786 dev_err(adapter->dev, in mwifiex_pcie_create_rxbd_ring()
792 dev_dbg(adapter->dev, in mwifiex_pcie_create_rxbd_ring()
798 return mwifiex_init_rxq_ring(adapter); in mwifiex_pcie_create_rxbd_ring()
804 static int mwifiex_pcie_delete_rxbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_rxbd_ring() argument
806 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_rxbd_ring()
809 mwifiex_cleanup_rxq_ring(adapter); in mwifiex_pcie_delete_rxbd_ring()
827 static int mwifiex_pcie_create_evtbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_create_evtbd_ring() argument
829 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_create_evtbd_ring()
843 dev_dbg(adapter->dev, "info: evtbd_ring: Allocating %d bytes\n", in mwifiex_pcie_create_evtbd_ring()
849 dev_err(adapter->dev, in mwifiex_pcie_create_evtbd_ring()
855 dev_dbg(adapter->dev, in mwifiex_pcie_create_evtbd_ring()
861 return mwifiex_pcie_init_evt_ring(adapter); in mwifiex_pcie_create_evtbd_ring()
867 static int mwifiex_pcie_delete_evtbd_ring(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_evtbd_ring() argument
869 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_delete_evtbd_ring()
872 mwifiex_cleanup_evt_ring(adapter); in mwifiex_pcie_delete_evtbd_ring()
890 static int mwifiex_pcie_alloc_cmdrsp_buf(struct mwifiex_adapter *adapter) in mwifiex_pcie_alloc_cmdrsp_buf() argument
892 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_alloc_cmdrsp_buf()
898 dev_err(adapter->dev, in mwifiex_pcie_alloc_cmdrsp_buf()
903 if (mwifiex_map_pci_memory(adapter, skb, MWIFIEX_UPLD_SIZE, in mwifiex_pcie_alloc_cmdrsp_buf()
915 static int mwifiex_pcie_delete_cmdrsp_buf(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_cmdrsp_buf() argument
919 if (!adapter) in mwifiex_pcie_delete_cmdrsp_buf()
922 card = adapter->card; in mwifiex_pcie_delete_cmdrsp_buf()
925 mwifiex_unmap_pci_memory(adapter, card->cmdrsp_buf, in mwifiex_pcie_delete_cmdrsp_buf()
931 mwifiex_unmap_pci_memory(adapter, card->cmd_buf, in mwifiex_pcie_delete_cmdrsp_buf()
940 static int mwifiex_pcie_alloc_sleep_cookie_buf(struct mwifiex_adapter *adapter) in mwifiex_pcie_alloc_sleep_cookie_buf() argument
942 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_alloc_sleep_cookie_buf()
947 dev_err(adapter->dev, "pci_alloc_consistent failed!\n"); in mwifiex_pcie_alloc_sleep_cookie_buf()
953 dev_dbg(adapter->dev, "alloc_scook: sleep cookie=0x%x\n", in mwifiex_pcie_alloc_sleep_cookie_buf()
962 static int mwifiex_pcie_delete_sleep_cookie_buf(struct mwifiex_adapter *adapter) in mwifiex_pcie_delete_sleep_cookie_buf() argument
966 if (!adapter) in mwifiex_pcie_delete_sleep_cookie_buf()
969 card = adapter->card; in mwifiex_pcie_delete_sleep_cookie_buf()
985 static int mwifiex_clean_pcie_ring_buf(struct mwifiex_adapter *adapter) in mwifiex_clean_pcie_ring_buf() argument
987 struct pcie_service_card *card = adapter->card; in mwifiex_clean_pcie_ring_buf()
994 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_clean_pcie_ring_buf()
996 dev_err(adapter->dev, in mwifiex_clean_pcie_ring_buf()
1007 static int mwifiex_pcie_send_data_complete(struct mwifiex_adapter *adapter) in mwifiex_pcie_send_data_complete() argument
1013 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_data_complete()
1016 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_send_data_complete()
1017 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_send_data_complete()
1020 if (mwifiex_read_reg(adapter, reg->tx_rdptr, &rdptr)) { in mwifiex_pcie_send_data_complete()
1021 dev_err(adapter->dev, in mwifiex_pcie_send_data_complete()
1026 dev_dbg(adapter->dev, "SEND COMP: rdptr_prev=0x%x, rdptr=0x%x\n", in mwifiex_pcie_send_data_complete()
1041 dev_dbg(adapter->dev, in mwifiex_pcie_send_data_complete()
1044 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_pcie_send_data_complete()
1050 mwifiex_write_data_complete(adapter, skb, 0, in mwifiex_pcie_send_data_complete()
1053 mwifiex_write_data_complete(adapter, skb, 0, 0); in mwifiex_pcie_send_data_complete()
1082 adapter->data_sent = false; in mwifiex_pcie_send_data_complete()
1088 mwifiex_clean_pcie_ring_buf(adapter); in mwifiex_pcie_send_data_complete()
1102 mwifiex_pcie_send_data(struct mwifiex_adapter *adapter, struct sk_buff *skb, in mwifiex_pcie_send_data() argument
1105 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_data()
1115 dev_err(adapter->dev, "%s(): invalid parameter <%p, %#x>\n", in mwifiex_pcie_send_data()
1120 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_send_data()
1121 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_send_data()
1124 dev_dbg(adapter->dev, "info: SEND DATA: <Rd: %#x, Wr: %#x>\n", in mwifiex_pcie_send_data()
1129 adapter->data_sent = true; in mwifiex_pcie_send_data()
1136 if (mwifiex_map_pci_memory(adapter, skb, skb->len, in mwifiex_pcie_send_data()
1176 if (mwifiex_write_reg(adapter, reg->tx_wrptr, in mwifiex_pcie_send_data()
1178 dev_err(adapter->dev, in mwifiex_pcie_send_data()
1186 dev_dbg(adapter->dev, in mwifiex_pcie_send_data()
1188 adapter->data_sent = false; in mwifiex_pcie_send_data()
1191 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_send_data()
1193 dev_err(adapter->dev, in mwifiex_pcie_send_data()
1199 dev_dbg(adapter->dev, "info: SEND DATA: Updated <Rd: %#x, Wr: " in mwifiex_pcie_send_data()
1203 dev_dbg(adapter->dev, in mwifiex_pcie_send_data()
1205 adapter->data_sent = true; in mwifiex_pcie_send_data()
1207 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_send_data()
1209 dev_err(adapter->dev, in mwifiex_pcie_send_data()
1216 mwifiex_unmap_pci_memory(adapter, skb, PCI_DMA_TODEVICE); in mwifiex_pcie_send_data()
1230 static int mwifiex_pcie_process_recv_data(struct mwifiex_adapter *adapter) in mwifiex_pcie_process_recv_data() argument
1232 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_recv_data()
1241 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_process_recv_data()
1242 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_process_recv_data()
1245 if (mwifiex_read_reg(adapter, reg->rx_wrptr, &wrptr)) { in mwifiex_pcie_process_recv_data()
1246 dev_err(adapter->dev, in mwifiex_pcie_process_recv_data()
1270 mwifiex_unmap_pci_memory(adapter, skb_data, PCI_DMA_FROMDEVICE); in mwifiex_pcie_process_recv_data()
1280 dev_err(adapter->dev, in mwifiex_pcie_process_recv_data()
1286 dev_dbg(adapter->dev, in mwifiex_pcie_process_recv_data()
1290 if (adapter->rx_work_enabled) { in mwifiex_pcie_process_recv_data()
1291 skb_queue_tail(&adapter->rx_data_q, skb_data); in mwifiex_pcie_process_recv_data()
1292 adapter->data_received = true; in mwifiex_pcie_process_recv_data()
1293 atomic_inc(&adapter->rx_pending); in mwifiex_pcie_process_recv_data()
1295 mwifiex_handle_rx_packet(adapter, skb_data); in mwifiex_pcie_process_recv_data()
1302 dev_err(adapter->dev, in mwifiex_pcie_process_recv_data()
1307 if (mwifiex_map_pci_memory(adapter, skb_tmp, in mwifiex_pcie_process_recv_data()
1314 dev_dbg(adapter->dev, in mwifiex_pcie_process_recv_data()
1339 dev_dbg(adapter->dev, "info: RECV DATA: <Rd: %#x, Wr: %#x>\n", in mwifiex_pcie_process_recv_data()
1344 if (mwifiex_write_reg(adapter, reg->rx_rdptr, in mwifiex_pcie_process_recv_data()
1346 dev_err(adapter->dev, in mwifiex_pcie_process_recv_data()
1353 if (mwifiex_read_reg(adapter, reg->rx_wrptr, &wrptr)) { in mwifiex_pcie_process_recv_data()
1354 dev_err(adapter->dev, in mwifiex_pcie_process_recv_data()
1359 dev_dbg(adapter->dev, in mwifiex_pcie_process_recv_data()
1372 mwifiex_pcie_send_boot_cmd(struct mwifiex_adapter *adapter, struct sk_buff *skb) in mwifiex_pcie_send_boot_cmd() argument
1375 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_boot_cmd()
1379 dev_err(adapter->dev, in mwifiex_pcie_send_boot_cmd()
1385 if (mwifiex_map_pci_memory(adapter, skb, skb->len , PCI_DMA_TODEVICE)) in mwifiex_pcie_send_boot_cmd()
1393 if (mwifiex_write_reg(adapter, reg->cmd_addr_lo, (u32)buf_pa)) { in mwifiex_pcie_send_boot_cmd()
1394 dev_err(adapter->dev, in mwifiex_pcie_send_boot_cmd()
1397 mwifiex_unmap_pci_memory(adapter, skb, PCI_DMA_TODEVICE); in mwifiex_pcie_send_boot_cmd()
1404 if (mwifiex_write_reg(adapter, reg->cmd_addr_hi, in mwifiex_pcie_send_boot_cmd()
1406 dev_err(adapter->dev, in mwifiex_pcie_send_boot_cmd()
1409 mwifiex_unmap_pci_memory(adapter, skb, PCI_DMA_TODEVICE); in mwifiex_pcie_send_boot_cmd()
1414 if (mwifiex_write_reg(adapter, reg->cmd_size, skb->len)) { in mwifiex_pcie_send_boot_cmd()
1415 dev_err(adapter->dev, in mwifiex_pcie_send_boot_cmd()
1418 mwifiex_unmap_pci_memory(adapter, skb, PCI_DMA_TODEVICE); in mwifiex_pcie_send_boot_cmd()
1423 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_send_boot_cmd()
1425 dev_err(adapter->dev, in mwifiex_pcie_send_boot_cmd()
1427 mwifiex_unmap_pci_memory(adapter, skb, PCI_DMA_TODEVICE); in mwifiex_pcie_send_boot_cmd()
1437 static int mwifiex_pcie_init_fw_port(struct mwifiex_adapter *adapter) in mwifiex_pcie_init_fw_port() argument
1439 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_init_fw_port()
1444 if (mwifiex_write_reg(adapter, reg->rx_rdptr, card->rxbd_rdptr | in mwifiex_pcie_init_fw_port()
1446 dev_err(adapter->dev, in mwifiex_pcie_init_fw_port()
1456 mwifiex_pcie_send_cmd(struct mwifiex_adapter *adapter, struct sk_buff *skb) in mwifiex_pcie_send_cmd() argument
1458 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_send_cmd()
1465 dev_err(adapter->dev, "Invalid parameter in %s <%p, %#x>\n", in mwifiex_pcie_send_cmd()
1472 dev_err(adapter->dev, in mwifiex_pcie_send_cmd()
1477 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_send_cmd()
1478 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_send_cmd()
1480 adapter->cmd_sent = true; in mwifiex_pcie_send_cmd()
1485 if (mwifiex_map_pci_memory(adapter, skb, skb->len, PCI_DMA_TODEVICE)) in mwifiex_pcie_send_cmd()
1504 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_lo, in mwifiex_pcie_send_cmd()
1506 dev_err(adapter->dev, in mwifiex_pcie_send_cmd()
1513 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_hi, in mwifiex_pcie_send_cmd()
1515 dev_err(adapter->dev, in mwifiex_pcie_send_cmd()
1524 if (mwifiex_write_reg(adapter, reg->cmd_addr_lo, in mwifiex_pcie_send_cmd()
1526 dev_err(adapter->dev, in mwifiex_pcie_send_cmd()
1532 if (mwifiex_write_reg(adapter, reg->cmd_addr_hi, in mwifiex_pcie_send_cmd()
1534 dev_err(adapter->dev, in mwifiex_pcie_send_cmd()
1541 if (mwifiex_write_reg(adapter, reg->cmd_size, in mwifiex_pcie_send_cmd()
1543 dev_err(adapter->dev, in mwifiex_pcie_send_cmd()
1550 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_send_cmd()
1552 dev_err(adapter->dev, in mwifiex_pcie_send_cmd()
1560 adapter->cmd_sent = false; in mwifiex_pcie_send_cmd()
1568 static int mwifiex_pcie_process_cmd_complete(struct mwifiex_adapter *adapter) in mwifiex_pcie_process_cmd_complete() argument
1570 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_cmd_complete()
1577 dev_dbg(adapter->dev, "info: Rx CMD Response\n"); in mwifiex_pcie_process_cmd_complete()
1579 mwifiex_unmap_pci_memory(adapter, skb, PCI_DMA_FROMDEVICE); in mwifiex_pcie_process_cmd_complete()
1583 mwifiex_unmap_pci_memory(adapter, card->cmd_buf, in mwifiex_pcie_process_cmd_complete()
1593 if (!adapter->curr_cmd) { in mwifiex_pcie_process_cmd_complete()
1594 if (adapter->ps_state == PS_STATE_SLEEP_CFM) { in mwifiex_pcie_process_cmd_complete()
1595 mwifiex_process_sleep_confirm_resp(adapter, skb->data, in mwifiex_pcie_process_cmd_complete()
1597 mwifiex_pcie_enable_host_int(adapter); in mwifiex_pcie_process_cmd_complete()
1598 if (mwifiex_write_reg(adapter, in mwifiex_pcie_process_cmd_complete()
1601 dev_warn(adapter->dev, in mwifiex_pcie_process_cmd_complete()
1605 mwifiex_delay_for_sleep_cookie(adapter, in mwifiex_pcie_process_cmd_complete()
1608 mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_process_cmd_complete()
1611 dev_err(adapter->dev, in mwifiex_pcie_process_cmd_complete()
1614 memcpy(adapter->upld_buf, skb->data, in mwifiex_pcie_process_cmd_complete()
1617 if (mwifiex_map_pci_memory(adapter, skb, MWIFIEX_UPLD_SIZE, in mwifiex_pcie_process_cmd_complete()
1620 } else if (mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_pcie_process_cmd_complete()
1621 adapter->curr_cmd->resp_skb = skb; in mwifiex_pcie_process_cmd_complete()
1622 adapter->cmd_resp_received = true; in mwifiex_pcie_process_cmd_complete()
1630 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_lo, 0)) { in mwifiex_pcie_process_cmd_complete()
1631 dev_err(adapter->dev, in mwifiex_pcie_process_cmd_complete()
1637 if (mwifiex_write_reg(adapter, reg->cmdrsp_addr_hi, 0)) { in mwifiex_pcie_process_cmd_complete()
1638 dev_err(adapter->dev, in mwifiex_pcie_process_cmd_complete()
1650 static int mwifiex_pcie_cmdrsp_complete(struct mwifiex_adapter *adapter, in mwifiex_pcie_cmdrsp_complete() argument
1653 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_cmdrsp_complete()
1658 if (mwifiex_map_pci_memory(adapter, skb, MWIFIEX_UPLD_SIZE, in mwifiex_pcie_cmdrsp_complete()
1669 static int mwifiex_pcie_process_event_ready(struct mwifiex_adapter *adapter) in mwifiex_pcie_process_event_ready() argument
1671 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_process_event_ready()
1677 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_pcie_process_event_ready()
1678 mwifiex_pm_wakeup_card(adapter); in mwifiex_pcie_process_event_ready()
1680 if (adapter->event_received) { in mwifiex_pcie_process_event_ready()
1681 dev_dbg(adapter->dev, "info: Event being processed, " in mwifiex_pcie_process_event_ready()
1687 dev_dbg(adapter->dev, "info: Invalid read pointer...\n"); in mwifiex_pcie_process_event_ready()
1692 if (mwifiex_read_reg(adapter, reg->evt_wrptr, &wrptr)) { in mwifiex_pcie_process_event_ready()
1693 dev_err(adapter->dev, in mwifiex_pcie_process_event_ready()
1698 dev_dbg(adapter->dev, "info: EventReady: Initial <Rd: 0x%x, Wr: 0x%x>", in mwifiex_pcie_process_event_ready()
1708 dev_dbg(adapter->dev, "info: Read Index: %d\n", rdptr); in mwifiex_pcie_process_event_ready()
1710 mwifiex_unmap_pci_memory(adapter, skb_cmd, PCI_DMA_FROMDEVICE); in mwifiex_pcie_process_event_ready()
1719 adapter->event_cause = event; in mwifiex_pcie_process_event_ready()
1726 dev_dbg(adapter->dev, "info: Event length: %d\n", evt_len); in mwifiex_pcie_process_event_ready()
1729 memcpy(adapter->event_body, skb_cmd->data + in mwifiex_pcie_process_event_ready()
1733 adapter->event_received = true; in mwifiex_pcie_process_event_ready()
1734 adapter->event_skb = skb_cmd; in mwifiex_pcie_process_event_ready()
1741 if (mwifiex_write_reg(adapter, PCIE_CPU_INT_EVENT, in mwifiex_pcie_process_event_ready()
1743 dev_warn(adapter->dev, in mwifiex_pcie_process_event_ready()
1755 static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter, in mwifiex_pcie_event_complete() argument
1758 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_event_complete()
1769 dev_err(adapter->dev, "event_complete: Invalid rdptr 0x%x\n", in mwifiex_pcie_event_complete()
1775 if (mwifiex_read_reg(adapter, reg->evt_wrptr, &wrptr)) { in mwifiex_pcie_event_complete()
1776 dev_err(adapter->dev, in mwifiex_pcie_event_complete()
1783 if (mwifiex_map_pci_memory(adapter, skb, in mwifiex_pcie_event_complete()
1794 dev_dbg(adapter->dev, in mwifiex_pcie_event_complete()
1805 dev_dbg(adapter->dev, "info: Updated <Rd: 0x%x, Wr: 0x%x>", in mwifiex_pcie_event_complete()
1809 if (mwifiex_write_reg(adapter, reg->evt_rdptr, in mwifiex_pcie_event_complete()
1811 dev_err(adapter->dev, in mwifiex_pcie_event_complete()
1816 dev_dbg(adapter->dev, "info: Check Events Again\n"); in mwifiex_pcie_event_complete()
1817 ret = mwifiex_pcie_process_event_ready(adapter); in mwifiex_pcie_event_complete()
1829 static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, in mwifiex_prog_fw_w_helper() argument
1839 struct pcie_service_card *card = adapter->card; in mwifiex_prog_fw_w_helper()
1843 dev_err(adapter->dev, in mwifiex_prog_fw_w_helper()
1848 dev_dbg(adapter->dev, "info: Downloading FW image (%d bytes)\n", in mwifiex_prog_fw_w_helper()
1851 if (mwifiex_pcie_disable_host_int(adapter)) { in mwifiex_prog_fw_w_helper()
1852 dev_err(adapter->dev, in mwifiex_prog_fw_w_helper()
1872 ret = mwifiex_read_reg(adapter, reg->cmd_size, in mwifiex_prog_fw_w_helper()
1875 dev_warn(adapter->dev, in mwifiex_prog_fw_w_helper()
1903 dev_err(adapter->dev, "FW CRC error indicated by the " in mwifiex_prog_fw_w_helper()
1916 dev_dbg(adapter->dev, "."); in mwifiex_prog_fw_w_helper()
1929 if (mwifiex_pcie_send_boot_cmd(adapter, skb)) { in mwifiex_prog_fw_w_helper()
1930 dev_err(adapter->dev, in mwifiex_prog_fw_w_helper()
1938 if (mwifiex_read_reg(adapter, PCIE_CPU_INT_STATUS, in mwifiex_prog_fw_w_helper()
1940 dev_err(adapter->dev, "%s: Failed to read " in mwifiex_prog_fw_w_helper()
1943 mwifiex_unmap_pci_memory(adapter, skb, in mwifiex_prog_fw_w_helper()
1951 mwifiex_unmap_pci_memory(adapter, skb, PCI_DMA_TODEVICE); in mwifiex_prog_fw_w_helper()
1956 dev_notice(adapter->dev, in mwifiex_prog_fw_w_helper()
1972 mwifiex_check_fw_status(struct mwifiex_adapter *adapter, u32 poll_num) in mwifiex_check_fw_status() argument
1976 struct pcie_service_card *card = adapter->card; in mwifiex_check_fw_status()
1981 if (mwifiex_write_reg(adapter, PCIE_HOST_INT_STATUS_MASK, in mwifiex_check_fw_status()
1983 dev_warn(adapter->dev, "Write register failed\n"); in mwifiex_check_fw_status()
1987 dev_dbg(adapter->dev, "Setting driver ready signature\n"); in mwifiex_check_fw_status()
1988 if (mwifiex_write_reg(adapter, reg->drv_rdy, in mwifiex_check_fw_status()
1990 dev_err(adapter->dev, in mwifiex_check_fw_status()
1997 if (mwifiex_read_reg(adapter, reg->fw_status, in mwifiex_check_fw_status()
2014 if (mwifiex_read_reg(adapter, reg->fw_status, in mwifiex_check_fw_status()
2018 dev_err(adapter->dev, "PCI-E is the winner\n"); in mwifiex_check_fw_status()
2019 adapter->winner = 1; in mwifiex_check_fw_status()
2021 dev_err(adapter->dev, in mwifiex_check_fw_status()
2023 ret, adapter->winner); in mwifiex_check_fw_status()
2033 static void mwifiex_interrupt_status(struct mwifiex_adapter *adapter) in mwifiex_interrupt_status() argument
2038 if (!mwifiex_pcie_ok_to_access_hw(adapter)) in mwifiex_interrupt_status()
2041 if (mwifiex_read_reg(adapter, PCIE_HOST_INT_STATUS, &pcie_ireg)) { in mwifiex_interrupt_status()
2042 dev_warn(adapter->dev, "Read register failed\n"); in mwifiex_interrupt_status()
2048 mwifiex_pcie_disable_host_int(adapter); in mwifiex_interrupt_status()
2051 if (mwifiex_write_reg(adapter, PCIE_HOST_INT_STATUS, in mwifiex_interrupt_status()
2053 dev_warn(adapter->dev, "Write register failed\n"); in mwifiex_interrupt_status()
2056 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2057 adapter->int_status |= pcie_ireg; in mwifiex_interrupt_status()
2058 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_interrupt_status()
2060 if (!adapter->pps_uapsd_mode && in mwifiex_interrupt_status()
2061 adapter->ps_state == PS_STATE_SLEEP && in mwifiex_interrupt_status()
2062 mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_interrupt_status()
2066 adapter->ps_state = PS_STATE_AWAKE; in mwifiex_interrupt_status()
2067 adapter->pm_wakeup_fw_try = false; in mwifiex_interrupt_status()
2068 del_timer(&adapter->wakeup_timer); in mwifiex_interrupt_status()
2083 struct mwifiex_adapter *adapter; in mwifiex_pcie_interrupt() local
2091 if (!card || !card->adapter) { in mwifiex_pcie_interrupt()
2093 card ? card->adapter : NULL); in mwifiex_pcie_interrupt()
2096 adapter = card->adapter; in mwifiex_pcie_interrupt()
2098 if (adapter->surprise_removed) in mwifiex_pcie_interrupt()
2101 mwifiex_interrupt_status(adapter); in mwifiex_pcie_interrupt()
2102 mwifiex_queue_main_work(adapter); in mwifiex_pcie_interrupt()
2121 static int mwifiex_process_int_status(struct mwifiex_adapter *adapter) in mwifiex_process_int_status() argument
2127 spin_lock_irqsave(&adapter->int_lock, flags); in mwifiex_process_int_status()
2129 pcie_ireg = adapter->int_status; in mwifiex_process_int_status()
2130 adapter->int_status = 0; in mwifiex_process_int_status()
2131 spin_unlock_irqrestore(&adapter->int_lock, flags); in mwifiex_process_int_status()
2136 dev_dbg(adapter->dev, "info: TX DNLD Done\n"); in mwifiex_process_int_status()
2137 ret = mwifiex_pcie_send_data_complete(adapter); in mwifiex_process_int_status()
2143 dev_dbg(adapter->dev, "info: Rx DATA\n"); in mwifiex_process_int_status()
2144 ret = mwifiex_pcie_process_recv_data(adapter); in mwifiex_process_int_status()
2150 dev_dbg(adapter->dev, "info: Rx EVENT\n"); in mwifiex_process_int_status()
2151 ret = mwifiex_pcie_process_event_ready(adapter); in mwifiex_process_int_status()
2158 if (adapter->cmd_sent) { in mwifiex_process_int_status()
2159 dev_dbg(adapter->dev, in mwifiex_process_int_status()
2161 adapter->cmd_sent = false; in mwifiex_process_int_status()
2164 ret = mwifiex_pcie_process_cmd_complete(adapter); in mwifiex_process_int_status()
2169 if (mwifiex_pcie_ok_to_access_hw(adapter)) { in mwifiex_process_int_status()
2170 if (mwifiex_read_reg(adapter, PCIE_HOST_INT_STATUS, in mwifiex_process_int_status()
2172 dev_warn(adapter->dev, in mwifiex_process_int_status()
2178 if (mwifiex_write_reg(adapter, in mwifiex_process_int_status()
2181 dev_warn(adapter->dev, in mwifiex_process_int_status()
2189 dev_dbg(adapter->dev, "info: cmd_sent=%d data_sent=%d\n", in mwifiex_process_int_status()
2190 adapter->cmd_sent, adapter->data_sent); in mwifiex_process_int_status()
2191 if (adapter->ps_state != PS_STATE_SLEEP) in mwifiex_process_int_status()
2192 mwifiex_pcie_enable_host_int(adapter); in mwifiex_process_int_status()
2207 static int mwifiex_pcie_host_to_card(struct mwifiex_adapter *adapter, u8 type, in mwifiex_pcie_host_to_card() argument
2212 dev_err(adapter->dev, "Passed NULL skb to %s\n", __func__); in mwifiex_pcie_host_to_card()
2217 return mwifiex_pcie_send_data(adapter, skb, tx_param); in mwifiex_pcie_host_to_card()
2219 return mwifiex_pcie_send_cmd(adapter, skb); in mwifiex_pcie_host_to_card()
2226 mwifiex_pcie_rdwr_firmware(struct mwifiex_adapter *adapter, u8 doneflag) in mwifiex_pcie_rdwr_firmware() argument
2230 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_rdwr_firmware()
2233 ret = mwifiex_write_reg(adapter, reg->fw_dump_ctrl, FW_DUMP_HOST_READY); in mwifiex_pcie_rdwr_firmware()
2235 dev_err(adapter->dev, "PCIE write err\n"); in mwifiex_pcie_rdwr_firmware()
2240 mwifiex_read_reg_byte(adapter, reg->fw_dump_ctrl, &ctrl_data); in mwifiex_pcie_rdwr_firmware()
2246 dev_info(adapter->dev, in mwifiex_pcie_rdwr_firmware()
2248 ret = mwifiex_write_reg(adapter, reg->fw_dump_ctrl, in mwifiex_pcie_rdwr_firmware()
2251 dev_err(adapter->dev, "PCIE write err\n"); in mwifiex_pcie_rdwr_firmware()
2258 dev_err(adapter->dev, "Fail to pull ctrl_data\n"); in mwifiex_pcie_rdwr_firmware()
2263 static void mwifiex_pcie_fw_dump_work(struct mwifiex_adapter *adapter) in mwifiex_pcie_fw_dump_work() argument
2265 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_fw_dump_work()
2287 dev_info(adapter->dev, "== mwifiex firmware dump start ==\n"); in mwifiex_pcie_fw_dump_work()
2290 stat = mwifiex_pcie_rdwr_firmware(adapter, doneflag); in mwifiex_pcie_fw_dump_work()
2295 mwifiex_read_reg_byte(adapter, reg, &dump_num); in mwifiex_pcie_fw_dump_work()
2301 stat = mwifiex_pcie_rdwr_firmware(adapter, doneflag); in mwifiex_pcie_fw_dump_work()
2308 mwifiex_read_reg_byte(adapter, reg, &read_reg); in mwifiex_pcie_fw_dump_work()
2314 dev_info(adapter->dev, "Firmware dump Finished!\n"); in mwifiex_pcie_fw_dump_work()
2315 ret = mwifiex_write_reg(adapter, creg->fw_dump_ctrl, in mwifiex_pcie_fw_dump_work()
2318 dev_err(adapter->dev, "PCIE write err\n"); in mwifiex_pcie_fw_dump_work()
2324 dev_info(adapter->dev, in mwifiex_pcie_fw_dump_work()
2329 dev_err(adapter->dev, in mwifiex_pcie_fw_dump_work()
2337 dev_info(adapter->dev, "Start %s output, please wait...\n", in mwifiex_pcie_fw_dump_work()
2341 stat = mwifiex_pcie_rdwr_firmware(adapter, doneflag); in mwifiex_pcie_fw_dump_work()
2348 mwifiex_read_reg_byte(adapter, reg, dbg_ptr); in mwifiex_pcie_fw_dump_work()
2352 dev_err(adapter->dev, in mwifiex_pcie_fw_dump_work()
2361 dev_info(adapter->dev, "%s done: size=0x%tx\n", in mwifiex_pcie_fw_dump_work()
2366 dev_info(adapter->dev, "== mwifiex firmware dump end ==\n"); in mwifiex_pcie_fw_dump_work()
2368 kobject_uevent_env(&adapter->wiphy->dev.kobj, KOBJ_CHANGE, env); in mwifiex_pcie_fw_dump_work()
2371 adapter->curr_mem_idx = 0; in mwifiex_pcie_fw_dump_work()
2385 static void mwifiex_pcie_fw_dump(struct mwifiex_adapter *adapter) in mwifiex_pcie_fw_dump() argument
2387 save_adapter = adapter; in mwifiex_pcie_fw_dump()
2406 static int mwifiex_pcie_init(struct mwifiex_adapter *adapter) in mwifiex_pcie_init() argument
2408 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_init()
2421 dev_dbg(adapter->dev, "try set_consistent_dma_mask(32)\n"); in mwifiex_pcie_init()
2424 dev_err(adapter->dev, "set_dma_mask(32) failed\n"); in mwifiex_pcie_init()
2430 dev_err(adapter->dev, "set_consistent_dma_mask(64) failed\n"); in mwifiex_pcie_init()
2436 dev_err(adapter->dev, "req_reg(0) error\n"); in mwifiex_pcie_init()
2441 dev_err(adapter->dev, "iomap(0) error\n"); in mwifiex_pcie_init()
2447 dev_err(adapter->dev, "req_reg(2) error\n"); in mwifiex_pcie_init()
2452 dev_err(adapter->dev, "iomap(2) error\n"); in mwifiex_pcie_init()
2457 dev_dbg(adapter->dev, in mwifiex_pcie_init()
2462 ret = mwifiex_pcie_create_txbd_ring(adapter); in mwifiex_pcie_init()
2465 ret = mwifiex_pcie_create_rxbd_ring(adapter); in mwifiex_pcie_init()
2468 ret = mwifiex_pcie_create_evtbd_ring(adapter); in mwifiex_pcie_init()
2471 ret = mwifiex_pcie_alloc_cmdrsp_buf(adapter); in mwifiex_pcie_init()
2475 ret = mwifiex_pcie_alloc_sleep_cookie_buf(adapter); in mwifiex_pcie_init()
2484 mwifiex_pcie_delete_cmdrsp_buf(adapter); in mwifiex_pcie_init()
2486 mwifiex_pcie_delete_evtbd_ring(adapter); in mwifiex_pcie_init()
2488 mwifiex_pcie_delete_rxbd_ring(adapter); in mwifiex_pcie_init()
2490 mwifiex_pcie_delete_txbd_ring(adapter); in mwifiex_pcie_init()
2517 static void mwifiex_pcie_cleanup(struct mwifiex_adapter *adapter) in mwifiex_pcie_cleanup() argument
2519 struct pcie_service_card *card = adapter->card; in mwifiex_pcie_cleanup()
2524 dev_dbg(adapter->dev, "Clearing driver ready signature\n"); in mwifiex_pcie_cleanup()
2525 if (mwifiex_write_reg(adapter, reg->drv_rdy, 0x00000000)) in mwifiex_pcie_cleanup()
2526 dev_err(adapter->dev, in mwifiex_pcie_cleanup()
2546 static int mwifiex_register_dev(struct mwifiex_adapter *adapter) in mwifiex_register_dev() argument
2549 struct pcie_service_card *card = adapter->card; in mwifiex_register_dev()
2553 card->adapter = adapter; in mwifiex_register_dev()
2559 adapter->card = NULL; in mwifiex_register_dev()
2563 adapter->dev = &pdev->dev; in mwifiex_register_dev()
2564 adapter->tx_buf_size = card->pcie.tx_buf_size; in mwifiex_register_dev()
2565 adapter->mem_type_mapping_tbl = mem_type_mapping_tbl; in mwifiex_register_dev()
2566 adapter->num_mem_types = ARRAY_SIZE(mem_type_mapping_tbl); in mwifiex_register_dev()
2567 strcpy(adapter->fw_name, card->pcie.firmware); in mwifiex_register_dev()
2568 adapter->ext_scan = card->pcie.can_ext_scan; in mwifiex_register_dev()
2579 static void mwifiex_unregister_dev(struct mwifiex_adapter *adapter) in mwifiex_unregister_dev() argument
2581 struct pcie_service_card *card = adapter->card; in mwifiex_unregister_dev()
2585 dev_dbg(adapter->dev, "%s(): calling free_irq()\n", __func__); in mwifiex_unregister_dev()
2590 mwifiex_pcie_delete_sleep_cookie_buf(adapter); in mwifiex_unregister_dev()
2592 mwifiex_pcie_delete_cmdrsp_buf(adapter); in mwifiex_unregister_dev()
2593 mwifiex_pcie_delete_evtbd_ring(adapter); in mwifiex_unregister_dev()
2594 mwifiex_pcie_delete_rxbd_ring(adapter); in mwifiex_unregister_dev()
2595 mwifiex_pcie_delete_txbd_ring(adapter); in mwifiex_unregister_dev()