Lines Matching refs:ar
100 static void ath10k_pci_buffer_cleanup(struct ath10k *ar);
101 static int ath10k_pci_cold_reset(struct ath10k *ar);
102 static int ath10k_pci_safe_chip_reset(struct ath10k *ar);
103 static int ath10k_pci_init_irq(struct ath10k *ar);
104 static int ath10k_pci_deinit_irq(struct ath10k *ar);
105 static int ath10k_pci_request_irq(struct ath10k *ar);
106 static void ath10k_pci_free_irq(struct ath10k *ar);
107 static int ath10k_pci_bmi_wait(struct ath10k *ar,
111 static int ath10k_pci_qca99x0_chip_reset(struct ath10k *ar);
429 static bool ath10k_pci_is_awake(struct ath10k *ar) in ath10k_pci_is_awake() argument
431 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_is_awake()
438 static void __ath10k_pci_wake(struct ath10k *ar) in __ath10k_pci_wake() argument
440 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in __ath10k_pci_wake()
444 ath10k_dbg(ar, ATH10K_DBG_PCI_PS, "pci ps wake reg refcount %lu awake %d\n", in __ath10k_pci_wake()
452 static void __ath10k_pci_sleep(struct ath10k *ar) in __ath10k_pci_sleep() argument
454 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in __ath10k_pci_sleep()
458 ath10k_dbg(ar, ATH10K_DBG_PCI_PS, "pci ps sleep reg refcount %lu awake %d\n", in __ath10k_pci_sleep()
467 static int ath10k_pci_wake_wait(struct ath10k *ar) in ath10k_pci_wake_wait() argument
473 if (ath10k_pci_is_awake(ar)) { in ath10k_pci_wake_wait()
475 …ath10k_warn(ar, "device wakeup took %d ms which is unusually long, otherwise it works normally.\n", in ath10k_pci_wake_wait()
490 static int ath10k_pci_force_wake(struct ath10k *ar) in ath10k_pci_force_wake() argument
492 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_force_wake()
506 ret = ath10k_pci_wake_wait(ar); in ath10k_pci_force_wake()
516 static void ath10k_pci_force_sleep(struct ath10k *ar) in ath10k_pci_force_sleep() argument
518 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_force_sleep()
531 static int ath10k_pci_wake(struct ath10k *ar) in ath10k_pci_wake() argument
533 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_wake()
542 ath10k_dbg(ar, ATH10K_DBG_PCI_PS, "pci ps wake refcount %lu awake %d\n", in ath10k_pci_wake()
549 __ath10k_pci_wake(ar); in ath10k_pci_wake()
551 ret = ath10k_pci_wake_wait(ar); in ath10k_pci_wake()
566 static void ath10k_pci_sleep(struct ath10k *ar) in ath10k_pci_sleep() argument
568 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_sleep()
576 ath10k_dbg(ar, ATH10K_DBG_PCI_PS, "pci ps sleep refcount %lu awake %d\n", in ath10k_pci_sleep()
594 struct ath10k *ar = ar_pci->ar; in ath10k_pci_ps_timer() local
599 ath10k_dbg(ar, ATH10K_DBG_PCI_PS, "pci ps timer refcount %lu awake %d\n", in ath10k_pci_ps_timer()
605 __ath10k_pci_sleep(ar); in ath10k_pci_ps_timer()
611 static void ath10k_pci_sleep_sync(struct ath10k *ar) in ath10k_pci_sleep_sync() argument
613 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_sleep_sync()
617 ath10k_pci_force_sleep(ar); in ath10k_pci_sleep_sync()
625 __ath10k_pci_sleep(ar); in ath10k_pci_sleep_sync()
629 static void ath10k_bus_pci_write32(struct ath10k *ar, u32 offset, u32 value) in ath10k_bus_pci_write32() argument
631 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_bus_pci_write32()
635 ath10k_warn(ar, "refusing to write mmio out of bounds at 0x%08x - 0x%08zx (max 0x%08zx)\n", in ath10k_bus_pci_write32()
640 ret = ath10k_pci_wake(ar); in ath10k_bus_pci_write32()
642 ath10k_warn(ar, "failed to wake target for write32 of 0x%08x at 0x%08x: %d\n", in ath10k_bus_pci_write32()
648 ath10k_pci_sleep(ar); in ath10k_bus_pci_write32()
651 static u32 ath10k_bus_pci_read32(struct ath10k *ar, u32 offset) in ath10k_bus_pci_read32() argument
653 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_bus_pci_read32()
658 ath10k_warn(ar, "refusing to read mmio out of bounds at 0x%08x - 0x%08zx (max 0x%08zx)\n", in ath10k_bus_pci_read32()
663 ret = ath10k_pci_wake(ar); in ath10k_bus_pci_read32()
665 ath10k_warn(ar, "failed to wake target for read32 at 0x%08x: %d\n", in ath10k_bus_pci_read32()
671 ath10k_pci_sleep(ar); in ath10k_bus_pci_read32()
676 inline void ath10k_pci_write32(struct ath10k *ar, u32 offset, u32 value) in ath10k_pci_write32() argument
678 struct ath10k_ce *ce = ath10k_ce_priv(ar); in ath10k_pci_write32()
680 ce->bus_ops->write32(ar, offset, value); in ath10k_pci_write32()
683 inline u32 ath10k_pci_read32(struct ath10k *ar, u32 offset) in ath10k_pci_read32() argument
685 struct ath10k_ce *ce = ath10k_ce_priv(ar); in ath10k_pci_read32()
687 return ce->bus_ops->read32(ar, offset); in ath10k_pci_read32()
690 u32 ath10k_pci_soc_read32(struct ath10k *ar, u32 addr) in ath10k_pci_soc_read32() argument
692 return ath10k_pci_read32(ar, RTC_SOC_BASE_ADDRESS + addr); in ath10k_pci_soc_read32()
695 void ath10k_pci_soc_write32(struct ath10k *ar, u32 addr, u32 val) in ath10k_pci_soc_write32() argument
697 ath10k_pci_write32(ar, RTC_SOC_BASE_ADDRESS + addr, val); in ath10k_pci_soc_write32()
700 u32 ath10k_pci_reg_read32(struct ath10k *ar, u32 addr) in ath10k_pci_reg_read32() argument
702 return ath10k_pci_read32(ar, PCIE_LOCAL_BASE_ADDRESS + addr); in ath10k_pci_reg_read32()
705 void ath10k_pci_reg_write32(struct ath10k *ar, u32 addr, u32 val) in ath10k_pci_reg_write32() argument
707 ath10k_pci_write32(ar, PCIE_LOCAL_BASE_ADDRESS + addr, val); in ath10k_pci_reg_write32()
710 bool ath10k_pci_irq_pending(struct ath10k *ar) in ath10k_pci_irq_pending() argument
715 cause = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS + in ath10k_pci_irq_pending()
723 void ath10k_pci_disable_and_clear_legacy_irq(struct ath10k *ar) in ath10k_pci_disable_and_clear_legacy_irq() argument
729 ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + PCIE_INTR_ENABLE_ADDRESS, in ath10k_pci_disable_and_clear_legacy_irq()
731 ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + PCIE_INTR_CLR_ADDRESS, in ath10k_pci_disable_and_clear_legacy_irq()
737 (void)ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS + in ath10k_pci_disable_and_clear_legacy_irq()
741 void ath10k_pci_enable_legacy_irq(struct ath10k *ar) in ath10k_pci_enable_legacy_irq() argument
743 ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + in ath10k_pci_enable_legacy_irq()
750 (void)ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS + in ath10k_pci_enable_legacy_irq()
754 static inline const char *ath10k_pci_get_irq_method(struct ath10k *ar) in ath10k_pci_get_irq_method() argument
756 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_get_irq_method()
766 struct ath10k *ar = pipe->hif_ce_state; in __ath10k_pci_rx_post_buf() local
767 struct ath10k_ce *ce = ath10k_ce_priv(ar); in __ath10k_pci_rx_post_buf()
779 paddr = dma_map_single(ar->dev, skb->data, in __ath10k_pci_rx_post_buf()
782 if (unlikely(dma_mapping_error(ar->dev, paddr))) { in __ath10k_pci_rx_post_buf()
783 ath10k_warn(ar, "failed to dma map pci rx buf\n"); in __ath10k_pci_rx_post_buf()
794 dma_unmap_single(ar->dev, paddr, skb->len + skb_tailroom(skb), in __ath10k_pci_rx_post_buf()
805 struct ath10k *ar = pipe->hif_ce_state; in ath10k_pci_rx_post_pipe() local
806 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_rx_post_pipe()
807 struct ath10k_ce *ce = ath10k_ce_priv(ar); in ath10k_pci_rx_post_pipe()
826 ath10k_warn(ar, "failed to post pci rx buf: %d\n", ret); in ath10k_pci_rx_post_pipe()
835 void ath10k_pci_rx_post(struct ath10k *ar) in ath10k_pci_rx_post() argument
837 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_rx_post()
847 struct ath10k *ar = ar_pci->ar; in ath10k_pci_rx_replenish_retry() local
849 ath10k_pci_rx_post(ar); in ath10k_pci_rx_replenish_retry()
852 static u32 ath10k_pci_qca988x_targ_cpu_to_ce_addr(struct ath10k *ar, u32 addr) in ath10k_pci_qca988x_targ_cpu_to_ce_addr() argument
856 val = (ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS + CORE_CTRL_ADDRESS) in ath10k_pci_qca988x_targ_cpu_to_ce_addr()
867 static u32 ath10k_pci_qca6174_targ_cpu_to_ce_addr(struct ath10k *ar, u32 addr) in ath10k_pci_qca6174_targ_cpu_to_ce_addr() argument
871 val = (ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS + CORE_CTRL_ADDRESS) in ath10k_pci_qca6174_targ_cpu_to_ce_addr()
877 static u32 ath10k_pci_qca99x0_targ_cpu_to_ce_addr(struct ath10k *ar, u32 addr) in ath10k_pci_qca99x0_targ_cpu_to_ce_addr() argument
881 val = ath10k_pci_read32(ar, PCIE_BAR_REG_ADDRESS); in ath10k_pci_qca99x0_targ_cpu_to_ce_addr()
886 static u32 ath10k_pci_targ_cpu_to_ce_addr(struct ath10k *ar, u32 addr) in ath10k_pci_targ_cpu_to_ce_addr() argument
888 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_targ_cpu_to_ce_addr()
893 return ar_pci->targ_cpu_to_ce_addr(ar, addr); in ath10k_pci_targ_cpu_to_ce_addr()
901 static int ath10k_pci_diag_read_mem(struct ath10k *ar, u32 address, void *data, in ath10k_pci_diag_read_mem() argument
904 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_diag_read_mem()
926 data_buf = dma_alloc_coherent(ar->dev, alloc_nbytes, &ce_data_base, in ath10k_pci_diag_read_mem()
940 address = ath10k_pci_targ_cpu_to_ce_addr(ar, address); in ath10k_pci_diag_read_mem()
1000 dma_free_coherent(ar->dev, alloc_nbytes, data_buf, in ath10k_pci_diag_read_mem()
1008 static int ath10k_pci_diag_read32(struct ath10k *ar, u32 address, u32 *value) in ath10k_pci_diag_read32() argument
1013 ret = ath10k_pci_diag_read_mem(ar, address, &val, sizeof(val)); in ath10k_pci_diag_read32()
1019 static int __ath10k_pci_diag_read_hi(struct ath10k *ar, void *dest, in __ath10k_pci_diag_read_hi() argument
1027 ret = ath10k_pci_diag_read32(ar, host_addr, &addr); in __ath10k_pci_diag_read_hi()
1029 ath10k_warn(ar, "failed to get memcpy hi address for firmware address %d: %d\n", in __ath10k_pci_diag_read_hi()
1034 ret = ath10k_pci_diag_read_mem(ar, addr, dest, len); in __ath10k_pci_diag_read_hi()
1036 ath10k_warn(ar, "failed to memcpy firmware memory from %d (%d B): %d\n", in __ath10k_pci_diag_read_hi()
1044 #define ath10k_pci_diag_read_hi(ar, dest, src, len) \ argument
1045 __ath10k_pci_diag_read_hi(ar, dest, HI_ITEM(src), len)
1047 int ath10k_pci_diag_write_mem(struct ath10k *ar, u32 address, in ath10k_pci_diag_write_mem() argument
1050 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_diag_write_mem()
1070 data_buf = dma_alloc_coherent(ar->dev, alloc_nbytes, &ce_data_base, in ath10k_pci_diag_write_mem()
1087 address = ath10k_pci_targ_cpu_to_ce_addr(ar, address); in ath10k_pci_diag_write_mem()
1150 dma_free_coherent(ar->dev, alloc_nbytes, data_buf, in ath10k_pci_diag_write_mem()
1155 ath10k_warn(ar, "failed to write diag value at 0x%x: %d\n", in ath10k_pci_diag_write_mem()
1163 static int ath10k_pci_diag_write32(struct ath10k *ar, u32 address, u32 value) in ath10k_pci_diag_write32() argument
1167 return ath10k_pci_diag_write_mem(ar, address, &val, sizeof(val)); in ath10k_pci_diag_write32()
1173 struct ath10k *ar = ce_state->ar; in ath10k_pci_htc_tx_cb() local
1187 ath10k_htc_tx_completion_handler(ar, skb); in ath10k_pci_htc_tx_cb()
1191 void (*callback)(struct ath10k *ar, in ath10k_pci_process_rx_cb() argument
1194 struct ath10k *ar = ce_state->ar; in ath10k_pci_process_rx_cb() local
1195 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_process_rx_cb()
1207 dma_unmap_single(ar->dev, ATH10K_SKB_RXCB(skb)->paddr, in ath10k_pci_process_rx_cb()
1211 ath10k_warn(ar, "rxed more than expected (nbytes %d, max %d)", in ath10k_pci_process_rx_cb()
1222 ath10k_dbg(ar, ATH10K_DBG_PCI, "pci rx ce pipe %d len %d\n", in ath10k_pci_process_rx_cb()
1224 ath10k_dbg_dump(ar, ATH10K_DBG_PCI_DUMP, NULL, "pci rx: ", in ath10k_pci_process_rx_cb()
1227 callback(ar, skb); in ath10k_pci_process_rx_cb()
1234 void (*callback)(struct ath10k *ar, in ath10k_pci_process_htt_rx_cb() argument
1237 struct ath10k *ar = ce_state->ar; in ath10k_pci_process_htt_rx_cb() local
1238 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_process_htt_rx_cb()
1258 ath10k_warn(ar, "rxed more than expected (nbytes %d, max %d)", in ath10k_pci_process_htt_rx_cb()
1263 dma_sync_single_for_cpu(ar->dev, ATH10K_SKB_RXCB(skb)->paddr, in ath10k_pci_process_htt_rx_cb()
1271 ath10k_dbg(ar, ATH10K_DBG_PCI, "pci rx ce pipe %d len %d\n", in ath10k_pci_process_htt_rx_cb()
1273 ath10k_dbg_dump(ar, ATH10K_DBG_PCI_DUMP, NULL, "pci rx: ", in ath10k_pci_process_htt_rx_cb()
1277 callback(ar, skb); in ath10k_pci_process_htt_rx_cb()
1283 dma_sync_single_for_device(ar->dev, ATH10K_SKB_RXCB(skb)->paddr, in ath10k_pci_process_htt_rx_cb()
1301 ath10k_ce_per_engine_service(ce_state->ar, 4); in ath10k_pci_htt_htc_rx_cb()
1318 struct ath10k *ar = ce_state->ar; in ath10k_pci_htt_tx_cb() local
1326 dma_unmap_single(ar->dev, ATH10K_SKB_CB(skb)->paddr, in ath10k_pci_htt_tx_cb()
1328 ath10k_htt_hif_tx_complete(ar, skb); in ath10k_pci_htt_tx_cb()
1332 static void ath10k_pci_htt_rx_deliver(struct ath10k *ar, struct sk_buff *skb) in ath10k_pci_htt_rx_deliver() argument
1335 ath10k_htt_t2h_msg_handler(ar, skb); in ath10k_pci_htt_rx_deliver()
1344 ath10k_ce_per_engine_service(ce_state->ar, 4); in ath10k_pci_htt_rx_cb()
1349 int ath10k_pci_hif_tx_sg(struct ath10k *ar, u8 pipe_id, in ath10k_pci_hif_tx_sg() argument
1352 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_hif_tx_sg()
1353 struct ath10k_ce *ce = ath10k_ce_priv(ar); in ath10k_pci_hif_tx_sg()
1375 ath10k_dbg(ar, ATH10K_DBG_PCI, in ath10k_pci_hif_tx_sg()
1378 ath10k_dbg_dump(ar, ATH10K_DBG_PCI_DUMP, NULL, "pci tx data: ", in ath10k_pci_hif_tx_sg()
1393 ath10k_dbg(ar, ATH10K_DBG_PCI, in ath10k_pci_hif_tx_sg()
1396 ath10k_dbg_dump(ar, ATH10K_DBG_PCI_DUMP, NULL, "pci tx data: ", in ath10k_pci_hif_tx_sg()
1419 int ath10k_pci_hif_diag_read(struct ath10k *ar, u32 address, void *buf, in ath10k_pci_hif_diag_read() argument
1422 return ath10k_pci_diag_read_mem(ar, address, buf, buf_len); in ath10k_pci_hif_diag_read()
1425 u16 ath10k_pci_hif_get_free_queue_number(struct ath10k *ar, u8 pipe) in ath10k_pci_hif_get_free_queue_number() argument
1427 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_hif_get_free_queue_number()
1429 ath10k_dbg(ar, ATH10K_DBG_PCI, "pci hif get free queue number\n"); in ath10k_pci_hif_get_free_queue_number()
1434 static void ath10k_pci_dump_registers(struct ath10k *ar, in ath10k_pci_dump_registers() argument
1440 lockdep_assert_held(&ar->dump_mutex); in ath10k_pci_dump_registers()
1442 ret = ath10k_pci_diag_read_hi(ar, ®_dump_values[0], in ath10k_pci_dump_registers()
1446 ath10k_err(ar, "failed to read firmware dump area: %d\n", ret); in ath10k_pci_dump_registers()
1452 ath10k_err(ar, "firmware register dump:\n"); in ath10k_pci_dump_registers()
1454 ath10k_err(ar, "[%02d]: 0x%08X 0x%08X 0x%08X 0x%08X\n", in ath10k_pci_dump_registers()
1468 static int ath10k_pci_dump_memory_section(struct ath10k *ar, in ath10k_pci_dump_memory_section() argument
1482 ath10k_warn(ar, "incorrect memdump region 0x%x with section start address 0x%x.\n", in ath10k_pci_dump_memory_section()
1503 ath10k_warn(ar, "incorrect ramdump format with start address 0x%x and stop address 0x%x\n", in ath10k_pci_dump_memory_section()
1517 ath10k_warn(ar, "next ramdump section 0x%x is smaller than current end address 0x%x\n", in ath10k_pci_dump_memory_section()
1527 ath10k_warn(ar, "ramdump buffer is too small: %zu\n", buf_len); in ath10k_pci_dump_memory_section()
1534 ret = ath10k_pci_diag_read_mem(ar, cur_section->start, in ath10k_pci_dump_memory_section()
1537 ath10k_warn(ar, "failed to read ramdump from section 0x%x: %d\n", in ath10k_pci_dump_memory_section()
1563 static int ath10k_pci_set_ram_config(struct ath10k *ar, u32 config) in ath10k_pci_set_ram_config() argument
1567 ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + in ath10k_pci_set_ram_config()
1570 val = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS + in ath10k_pci_set_ram_config()
1573 ath10k_warn(ar, "failed to set RAM config from 0x%x to 0x%x\n", in ath10k_pci_set_ram_config()
1582 static int ath10k_pci_dump_memory_sram(struct ath10k *ar, in ath10k_pci_dump_memory_sram() argument
1586 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_dump_memory_sram()
1601 static int ath10k_pci_dump_memory_reg(struct ath10k *ar, in ath10k_pci_dump_memory_reg() argument
1605 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_dump_memory_reg()
1609 mutex_lock(&ar->conf_mutex); in ath10k_pci_dump_memory_reg()
1610 if (ar->state != ATH10K_STATE_ON) { in ath10k_pci_dump_memory_reg()
1611 ath10k_warn(ar, "Skipping pci_dump_memory_reg invalid state\n"); in ath10k_pci_dump_memory_reg()
1621 mutex_unlock(&ar->conf_mutex); in ath10k_pci_dump_memory_reg()
1626 static int ath10k_pci_dump_memory_generic(struct ath10k *ar, in ath10k_pci_dump_memory_generic() argument
1634 return ath10k_pci_dump_memory_section(ar, in ath10k_pci_dump_memory_generic()
1642 ret = ath10k_pci_diag_read_mem(ar, in ath10k_pci_dump_memory_generic()
1647 ath10k_warn(ar, "failed to copy ramdump region %s: %d\n", in ath10k_pci_dump_memory_generic()
1655 static void ath10k_pci_dump_memory(struct ath10k *ar, in ath10k_pci_dump_memory() argument
1666 lockdep_assert_held(&ar->dump_mutex); in ath10k_pci_dump_memory()
1671 mem_layout = ath10k_coredump_get_mem_layout(ar); in ath10k_pci_dump_memory()
1686 ath10k_warn(ar, "memory region %s size %d is larger that remaining ramdump buffer size %zu\n", in ath10k_pci_dump_memory()
1700 ret = ath10k_pci_set_ram_config(ar, shift); in ath10k_pci_dump_memory()
1702 ath10k_warn(ar, "failed to switch ram config to IRAM for section %s: %d\n", in ath10k_pci_dump_memory()
1715 count = ath10k_pci_dump_memory_sram(ar, current_region, buf); in ath10k_pci_dump_memory()
1718 ret = ath10k_pci_dump_memory_reg(ar, current_region, buf); in ath10k_pci_dump_memory()
1725 ret = ath10k_pci_dump_memory_generic(ar, current_region, buf); in ath10k_pci_dump_memory()
1753 struct ath10k *ar = ar_pci->ar; in ath10k_pci_fw_dump_work() local
1756 mutex_lock(&ar->dump_mutex); in ath10k_pci_fw_dump_work()
1758 spin_lock_bh(&ar->data_lock); in ath10k_pci_fw_dump_work()
1759 ar->stats.fw_crash_counter++; in ath10k_pci_fw_dump_work()
1760 spin_unlock_bh(&ar->data_lock); in ath10k_pci_fw_dump_work()
1762 crash_data = ath10k_coredump_new(ar); in ath10k_pci_fw_dump_work()
1769 ath10k_err(ar, "firmware crashed! (guid %s)\n", guid); in ath10k_pci_fw_dump_work()
1770 ath10k_print_driver_info(ar); in ath10k_pci_fw_dump_work()
1771 ath10k_pci_dump_registers(ar, crash_data); in ath10k_pci_fw_dump_work()
1772 ath10k_ce_dump_registers(ar, crash_data); in ath10k_pci_fw_dump_work()
1773 ath10k_pci_dump_memory(ar, crash_data); in ath10k_pci_fw_dump_work()
1775 mutex_unlock(&ar->dump_mutex); in ath10k_pci_fw_dump_work()
1777 ath10k_core_start_recovery(ar); in ath10k_pci_fw_dump_work()
1780 static void ath10k_pci_fw_crashed_dump(struct ath10k *ar) in ath10k_pci_fw_crashed_dump() argument
1782 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_fw_crashed_dump()
1784 queue_work(ar->workqueue, &ar_pci->dump_work); in ath10k_pci_fw_crashed_dump()
1787 void ath10k_pci_hif_send_complete_check(struct ath10k *ar, u8 pipe, in ath10k_pci_hif_send_complete_check() argument
1790 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_hif_send_complete_check()
1792 ath10k_dbg(ar, ATH10K_DBG_PCI, "pci hif send complete check\n"); in ath10k_pci_hif_send_complete_check()
1803 resources = ath10k_pci_hif_get_free_queue_number(ar, pipe); in ath10k_pci_hif_send_complete_check()
1812 ath10k_ce_per_engine_service(ar, pipe); in ath10k_pci_hif_send_complete_check()
1815 static void ath10k_pci_rx_retry_sync(struct ath10k *ar) in ath10k_pci_rx_retry_sync() argument
1817 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_rx_retry_sync()
1822 int ath10k_pci_hif_map_service_to_pipe(struct ath10k *ar, u16 service_id, in ath10k_pci_hif_map_service_to_pipe() argument
1825 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_hif_map_service_to_pipe()
1830 ath10k_dbg(ar, ATH10K_DBG_PCI, "pci hif map service\n"); in ath10k_pci_hif_map_service_to_pipe()
1868 void ath10k_pci_hif_get_default_pipe(struct ath10k *ar, in ath10k_pci_hif_get_default_pipe() argument
1871 ath10k_dbg(ar, ATH10K_DBG_PCI, "pci hif get default pipe\n"); in ath10k_pci_hif_get_default_pipe()
1873 (void)ath10k_pci_hif_map_service_to_pipe(ar, in ath10k_pci_hif_get_default_pipe()
1878 void ath10k_pci_irq_msi_fw_mask(struct ath10k *ar) in ath10k_pci_irq_msi_fw_mask() argument
1882 switch (ar->hw_rev) { in ath10k_pci_irq_msi_fw_mask()
1887 val = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS + in ath10k_pci_irq_msi_fw_mask()
1890 ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + in ath10k_pci_irq_msi_fw_mask()
1906 static void ath10k_pci_irq_msi_fw_unmask(struct ath10k *ar) in ath10k_pci_irq_msi_fw_unmask() argument
1910 switch (ar->hw_rev) { in ath10k_pci_irq_msi_fw_unmask()
1915 val = ath10k_pci_read32(ar, SOC_CORE_BASE_ADDRESS + in ath10k_pci_irq_msi_fw_unmask()
1918 ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + in ath10k_pci_irq_msi_fw_unmask()
1934 static void ath10k_pci_irq_disable(struct ath10k *ar) in ath10k_pci_irq_disable() argument
1936 ath10k_ce_disable_interrupts(ar); in ath10k_pci_irq_disable()
1937 ath10k_pci_disable_and_clear_legacy_irq(ar); in ath10k_pci_irq_disable()
1938 ath10k_pci_irq_msi_fw_mask(ar); in ath10k_pci_irq_disable()
1941 static void ath10k_pci_irq_sync(struct ath10k *ar) in ath10k_pci_irq_sync() argument
1943 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_irq_sync()
1948 static void ath10k_pci_irq_enable(struct ath10k *ar) in ath10k_pci_irq_enable() argument
1950 ath10k_ce_enable_interrupts(ar); in ath10k_pci_irq_enable()
1951 ath10k_pci_enable_legacy_irq(ar); in ath10k_pci_irq_enable()
1952 ath10k_pci_irq_msi_fw_unmask(ar); in ath10k_pci_irq_enable()
1955 static int ath10k_pci_hif_start(struct ath10k *ar) in ath10k_pci_hif_start() argument
1957 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_hif_start()
1959 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif start\n"); in ath10k_pci_hif_start()
1961 ath10k_core_napi_enable(ar); in ath10k_pci_hif_start()
1963 ath10k_pci_irq_enable(ar); in ath10k_pci_hif_start()
1964 ath10k_pci_rx_post(ar); in ath10k_pci_hif_start()
1974 struct ath10k *ar; in ath10k_pci_rx_pipe_cleanup() local
1980 ar = pci_pipe->hif_ce_state; in ath10k_pci_rx_pipe_cleanup()
1997 dma_unmap_single(ar->dev, ATH10K_SKB_RXCB(skb)->paddr, in ath10k_pci_rx_pipe_cleanup()
2006 struct ath10k *ar; in ath10k_pci_tx_pipe_cleanup() local
2012 ar = pci_pipe->hif_ce_state; in ath10k_pci_tx_pipe_cleanup()
2029 ath10k_htc_tx_completion_handler(ar, skb); in ath10k_pci_tx_pipe_cleanup()
2041 static void ath10k_pci_buffer_cleanup(struct ath10k *ar) in ath10k_pci_buffer_cleanup() argument
2043 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_buffer_cleanup()
2055 void ath10k_pci_ce_deinit(struct ath10k *ar) in ath10k_pci_ce_deinit() argument
2060 ath10k_ce_deinit_pipe(ar, i); in ath10k_pci_ce_deinit()
2063 void ath10k_pci_flush(struct ath10k *ar) in ath10k_pci_flush() argument
2065 ath10k_pci_rx_retry_sync(ar); in ath10k_pci_flush()
2066 ath10k_pci_buffer_cleanup(ar); in ath10k_pci_flush()
2069 static void ath10k_pci_hif_stop(struct ath10k *ar) in ath10k_pci_hif_stop() argument
2071 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_hif_stop()
2074 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif stop\n"); in ath10k_pci_hif_stop()
2076 ath10k_pci_irq_disable(ar); in ath10k_pci_hif_stop()
2077 ath10k_pci_irq_sync(ar); in ath10k_pci_hif_stop()
2079 ath10k_core_napi_sync_disable(ar); in ath10k_pci_hif_stop()
2094 ath10k_pci_safe_chip_reset(ar); in ath10k_pci_hif_stop()
2096 ath10k_pci_flush(ar); in ath10k_pci_hif_stop()
2103 int ath10k_pci_hif_exchange_bmi_msg(struct ath10k *ar, in ath10k_pci_hif_exchange_bmi_msg() argument
2107 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_hif_exchange_bmi_msg()
2130 req_paddr = dma_map_single(ar->dev, treq, req_len, DMA_TO_DEVICE); in ath10k_pci_hif_exchange_bmi_msg()
2131 ret = dma_mapping_error(ar->dev, req_paddr); in ath10k_pci_hif_exchange_bmi_msg()
2144 resp_paddr = dma_map_single(ar->dev, tresp, *resp_len, in ath10k_pci_hif_exchange_bmi_msg()
2146 ret = dma_mapping_error(ar->dev, resp_paddr); in ath10k_pci_hif_exchange_bmi_msg()
2162 ret = ath10k_pci_bmi_wait(ar, ce_tx, ce_rx, &xfer); in ath10k_pci_hif_exchange_bmi_msg()
2180 dma_unmap_single(ar->dev, resp_paddr, in ath10k_pci_hif_exchange_bmi_msg()
2184 dma_unmap_single(ar->dev, req_paddr, req_len, DMA_TO_DEVICE); in ath10k_pci_hif_exchange_bmi_msg()
2209 struct ath10k *ar = ce_state->ar; in ath10k_pci_bmi_recv_data() local
2221 ath10k_warn(ar, "unexpected: BMI data received; ignoring\n"); in ath10k_pci_bmi_recv_data()
2229 static int ath10k_pci_bmi_wait(struct ath10k *ar, in ath10k_pci_bmi_wait() argument
2256 ath10k_dbg(ar, ATH10K_DBG_BMI, in ath10k_pci_bmi_wait()
2266 static int ath10k_pci_wake_target_cpu(struct ath10k *ar) in ath10k_pci_wake_target_cpu() argument
2271 val = ath10k_pci_read32(ar, addr); in ath10k_pci_wake_target_cpu()
2273 ath10k_pci_write32(ar, addr, val); in ath10k_pci_wake_target_cpu()
2278 static int ath10k_pci_get_num_banks(struct ath10k *ar) in ath10k_pci_get_num_banks() argument
2280 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_get_num_banks()
2292 switch (MS(ar->bus_param.chip_id, SOC_CHIP_ID_REV)) { in ath10k_pci_get_num_banks()
2310 ath10k_warn(ar, "unknown number of banks, assuming 1\n"); in ath10k_pci_get_num_banks()
2314 static int ath10k_bus_get_num_banks(struct ath10k *ar) in ath10k_bus_get_num_banks() argument
2316 struct ath10k_ce *ce = ath10k_ce_priv(ar); in ath10k_bus_get_num_banks()
2318 return ce->bus_ops->get_num_banks(ar); in ath10k_bus_get_num_banks()
2321 int ath10k_pci_init_config(struct ath10k *ar) in ath10k_pci_init_config() argument
2323 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_init_config()
2340 ret = ath10k_pci_diag_read32(ar, interconnect_targ_addr, in ath10k_pci_init_config()
2343 ath10k_err(ar, "Failed to get pcie state addr: %d\n", ret); in ath10k_pci_init_config()
2349 ath10k_err(ar, "Invalid pcie state addr\n"); in ath10k_pci_init_config()
2353 ret = ath10k_pci_diag_read32(ar, (pcie_state_targ_addr + in ath10k_pci_init_config()
2358 ath10k_err(ar, "Failed to get pipe cfg addr: %d\n", ret); in ath10k_pci_init_config()
2364 ath10k_err(ar, "Invalid pipe cfg addr\n"); in ath10k_pci_init_config()
2368 ret = ath10k_pci_diag_write_mem(ar, pipe_cfg_targ_addr, in ath10k_pci_init_config()
2374 ath10k_err(ar, "Failed to write pipe cfg: %d\n", ret); in ath10k_pci_init_config()
2378 ret = ath10k_pci_diag_read32(ar, (pcie_state_targ_addr + in ath10k_pci_init_config()
2383 ath10k_err(ar, "Failed to get svc/pipe map: %d\n", ret); in ath10k_pci_init_config()
2389 ath10k_err(ar, "Invalid svc_to_pipe map\n"); in ath10k_pci_init_config()
2393 ret = ath10k_pci_diag_write_mem(ar, svc_to_pipe_map, in ath10k_pci_init_config()
2397 ath10k_err(ar, "Failed to write svc/pipe map: %d\n", ret); in ath10k_pci_init_config()
2401 ret = ath10k_pci_diag_read32(ar, (pcie_state_targ_addr + in ath10k_pci_init_config()
2406 ath10k_err(ar, "Failed to get pcie config_flags: %d\n", ret); in ath10k_pci_init_config()
2412 ret = ath10k_pci_diag_write32(ar, (pcie_state_targ_addr + in ath10k_pci_init_config()
2417 ath10k_err(ar, "Failed to write pcie config_flags: %d\n", ret); in ath10k_pci_init_config()
2424 ret = ath10k_pci_diag_read32(ar, ealloc_targ_addr, &ealloc_value); in ath10k_pci_init_config()
2426 ath10k_err(ar, "Failed to get early alloc val: %d\n", ret); in ath10k_pci_init_config()
2433 ealloc_value |= ((ath10k_bus_get_num_banks(ar) << in ath10k_pci_init_config()
2437 ret = ath10k_pci_diag_write32(ar, ealloc_targ_addr, ealloc_value); in ath10k_pci_init_config()
2439 ath10k_err(ar, "Failed to set early alloc val: %d\n", ret); in ath10k_pci_init_config()
2446 ret = ath10k_pci_diag_read32(ar, flag2_targ_addr, &flag2_value); in ath10k_pci_init_config()
2448 ath10k_err(ar, "Failed to get option val: %d\n", ret); in ath10k_pci_init_config()
2454 ret = ath10k_pci_diag_write32(ar, flag2_targ_addr, flag2_value); in ath10k_pci_init_config()
2456 ath10k_err(ar, "Failed to set option val: %d\n", ret); in ath10k_pci_init_config()
2463 static void ath10k_pci_override_ce_config(struct ath10k *ar) in ath10k_pci_override_ce_config() argument
2467 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_override_ce_config()
2487 int ath10k_pci_alloc_pipes(struct ath10k *ar) in ath10k_pci_alloc_pipes() argument
2489 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_alloc_pipes()
2491 struct ath10k_ce *ce = ath10k_ce_priv(ar); in ath10k_pci_alloc_pipes()
2498 pipe->hif_ce_state = ar; in ath10k_pci_alloc_pipes()
2500 ret = ath10k_ce_alloc_pipe(ar, i, &ar_pci->attr[i]); in ath10k_pci_alloc_pipes()
2502 ath10k_err(ar, "failed to allocate copy engine pipe %d: %d\n", in ath10k_pci_alloc_pipes()
2519 void ath10k_pci_free_pipes(struct ath10k *ar) in ath10k_pci_free_pipes() argument
2524 ath10k_ce_free_pipe(ar, i); in ath10k_pci_free_pipes()
2527 int ath10k_pci_init_pipes(struct ath10k *ar) in ath10k_pci_init_pipes() argument
2529 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_init_pipes()
2533 ret = ath10k_ce_init_pipe(ar, i, &ar_pci->attr[i]); in ath10k_pci_init_pipes()
2535 ath10k_err(ar, "failed to initialize copy engine pipe %d: %d\n", in ath10k_pci_init_pipes()
2544 static bool ath10k_pci_has_fw_crashed(struct ath10k *ar) in ath10k_pci_has_fw_crashed() argument
2546 return ath10k_pci_read32(ar, FW_INDICATOR_ADDRESS) & in ath10k_pci_has_fw_crashed()
2550 static void ath10k_pci_fw_crashed_clear(struct ath10k *ar) in ath10k_pci_fw_crashed_clear() argument
2554 val = ath10k_pci_read32(ar, FW_INDICATOR_ADDRESS); in ath10k_pci_fw_crashed_clear()
2556 ath10k_pci_write32(ar, FW_INDICATOR_ADDRESS, val); in ath10k_pci_fw_crashed_clear()
2559 static bool ath10k_pci_has_device_gone(struct ath10k *ar) in ath10k_pci_has_device_gone() argument
2563 val = ath10k_pci_read32(ar, FW_INDICATOR_ADDRESS); in ath10k_pci_has_device_gone()
2568 static void ath10k_pci_warm_reset_si0(struct ath10k *ar) in ath10k_pci_warm_reset_si0() argument
2572 val = ath10k_pci_soc_read32(ar, SOC_RESET_CONTROL_ADDRESS); in ath10k_pci_warm_reset_si0()
2573 ath10k_pci_soc_write32(ar, SOC_RESET_CONTROL_ADDRESS, in ath10k_pci_warm_reset_si0()
2575 val = ath10k_pci_soc_read32(ar, SOC_RESET_CONTROL_ADDRESS); in ath10k_pci_warm_reset_si0()
2579 val = ath10k_pci_soc_read32(ar, SOC_RESET_CONTROL_ADDRESS); in ath10k_pci_warm_reset_si0()
2580 ath10k_pci_soc_write32(ar, SOC_RESET_CONTROL_ADDRESS, in ath10k_pci_warm_reset_si0()
2582 val = ath10k_pci_soc_read32(ar, SOC_RESET_CONTROL_ADDRESS); in ath10k_pci_warm_reset_si0()
2587 static void ath10k_pci_warm_reset_cpu(struct ath10k *ar) in ath10k_pci_warm_reset_cpu() argument
2591 ath10k_pci_write32(ar, FW_INDICATOR_ADDRESS, 0); in ath10k_pci_warm_reset_cpu()
2593 val = ath10k_pci_soc_read32(ar, SOC_RESET_CONTROL_ADDRESS); in ath10k_pci_warm_reset_cpu()
2594 ath10k_pci_soc_write32(ar, SOC_RESET_CONTROL_ADDRESS, in ath10k_pci_warm_reset_cpu()
2598 static void ath10k_pci_warm_reset_ce(struct ath10k *ar) in ath10k_pci_warm_reset_ce() argument
2602 val = ath10k_pci_soc_read32(ar, SOC_RESET_CONTROL_ADDRESS); in ath10k_pci_warm_reset_ce()
2604 ath10k_pci_soc_write32(ar, SOC_RESET_CONTROL_ADDRESS, in ath10k_pci_warm_reset_ce()
2607 ath10k_pci_soc_write32(ar, SOC_RESET_CONTROL_ADDRESS, in ath10k_pci_warm_reset_ce()
2611 static void ath10k_pci_warm_reset_clear_lf(struct ath10k *ar) in ath10k_pci_warm_reset_clear_lf() argument
2615 val = ath10k_pci_soc_read32(ar, SOC_LF_TIMER_CONTROL0_ADDRESS); in ath10k_pci_warm_reset_clear_lf()
2616 ath10k_pci_soc_write32(ar, SOC_LF_TIMER_CONTROL0_ADDRESS, in ath10k_pci_warm_reset_clear_lf()
2620 static int ath10k_pci_warm_reset(struct ath10k *ar) in ath10k_pci_warm_reset() argument
2624 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot warm reset\n"); in ath10k_pci_warm_reset()
2626 spin_lock_bh(&ar->data_lock); in ath10k_pci_warm_reset()
2627 ar->stats.fw_warm_reset_counter++; in ath10k_pci_warm_reset()
2628 spin_unlock_bh(&ar->data_lock); in ath10k_pci_warm_reset()
2630 ath10k_pci_irq_disable(ar); in ath10k_pci_warm_reset()
2637 ath10k_pci_warm_reset_si0(ar); in ath10k_pci_warm_reset()
2638 ath10k_pci_warm_reset_cpu(ar); in ath10k_pci_warm_reset()
2639 ath10k_pci_init_pipes(ar); in ath10k_pci_warm_reset()
2640 ath10k_pci_wait_for_target_init(ar); in ath10k_pci_warm_reset()
2642 ath10k_pci_warm_reset_clear_lf(ar); in ath10k_pci_warm_reset()
2643 ath10k_pci_warm_reset_ce(ar); in ath10k_pci_warm_reset()
2644 ath10k_pci_warm_reset_cpu(ar); in ath10k_pci_warm_reset()
2645 ath10k_pci_init_pipes(ar); in ath10k_pci_warm_reset()
2647 ret = ath10k_pci_wait_for_target_init(ar); in ath10k_pci_warm_reset()
2649 ath10k_warn(ar, "failed to wait for target init: %d\n", ret); in ath10k_pci_warm_reset()
2653 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot warm reset complete\n"); in ath10k_pci_warm_reset()
2658 static int ath10k_pci_qca99x0_soft_chip_reset(struct ath10k *ar) in ath10k_pci_qca99x0_soft_chip_reset() argument
2660 ath10k_pci_irq_disable(ar); in ath10k_pci_qca99x0_soft_chip_reset()
2661 return ath10k_pci_qca99x0_chip_reset(ar); in ath10k_pci_qca99x0_soft_chip_reset()
2664 static int ath10k_pci_safe_chip_reset(struct ath10k *ar) in ath10k_pci_safe_chip_reset() argument
2666 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_safe_chip_reset()
2671 return ar_pci->pci_soft_reset(ar); in ath10k_pci_safe_chip_reset()
2674 static int ath10k_pci_qca988x_chip_reset(struct ath10k *ar) in ath10k_pci_qca988x_chip_reset() argument
2679 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot 988x chip reset\n"); in ath10k_pci_qca988x_chip_reset()
2689 ret = ath10k_pci_warm_reset(ar); in ath10k_pci_qca988x_chip_reset()
2691 ath10k_warn(ar, "failed to warm reset attempt %d of %d: %d\n", in ath10k_pci_qca988x_chip_reset()
2706 ret = ath10k_pci_init_pipes(ar); in ath10k_pci_qca988x_chip_reset()
2708 ath10k_warn(ar, "failed to init copy engine: %d\n", in ath10k_pci_qca988x_chip_reset()
2713 ret = ath10k_pci_diag_read32(ar, QCA988X_HOST_INTEREST_ADDRESS, in ath10k_pci_qca988x_chip_reset()
2716 ath10k_warn(ar, "failed to poke copy engine: %d\n", in ath10k_pci_qca988x_chip_reset()
2721 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot chip reset complete (warm)\n"); in ath10k_pci_qca988x_chip_reset()
2726 ath10k_warn(ar, "refusing cold reset as requested\n"); in ath10k_pci_qca988x_chip_reset()
2730 ret = ath10k_pci_cold_reset(ar); in ath10k_pci_qca988x_chip_reset()
2732 ath10k_warn(ar, "failed to cold reset: %d\n", ret); in ath10k_pci_qca988x_chip_reset()
2736 ret = ath10k_pci_wait_for_target_init(ar); in ath10k_pci_qca988x_chip_reset()
2738 ath10k_warn(ar, "failed to wait for target after cold reset: %d\n", in ath10k_pci_qca988x_chip_reset()
2743 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot qca988x chip reset complete (cold)\n"); in ath10k_pci_qca988x_chip_reset()
2748 static int ath10k_pci_qca6174_chip_reset(struct ath10k *ar) in ath10k_pci_qca6174_chip_reset() argument
2752 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot qca6174 chip reset\n"); in ath10k_pci_qca6174_chip_reset()
2756 ret = ath10k_pci_cold_reset(ar); in ath10k_pci_qca6174_chip_reset()
2758 ath10k_warn(ar, "failed to cold reset: %d\n", ret); in ath10k_pci_qca6174_chip_reset()
2762 ret = ath10k_pci_wait_for_target_init(ar); in ath10k_pci_qca6174_chip_reset()
2764 ath10k_warn(ar, "failed to wait for target after cold reset: %d\n", in ath10k_pci_qca6174_chip_reset()
2769 ret = ath10k_pci_warm_reset(ar); in ath10k_pci_qca6174_chip_reset()
2771 ath10k_warn(ar, "failed to warm reset: %d\n", ret); in ath10k_pci_qca6174_chip_reset()
2775 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot qca6174 chip reset complete (cold)\n"); in ath10k_pci_qca6174_chip_reset()
2780 static int ath10k_pci_qca99x0_chip_reset(struct ath10k *ar) in ath10k_pci_qca99x0_chip_reset() argument
2784 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot qca99x0 chip reset\n"); in ath10k_pci_qca99x0_chip_reset()
2786 ret = ath10k_pci_cold_reset(ar); in ath10k_pci_qca99x0_chip_reset()
2788 ath10k_warn(ar, "failed to cold reset: %d\n", ret); in ath10k_pci_qca99x0_chip_reset()
2792 ret = ath10k_pci_wait_for_target_init(ar); in ath10k_pci_qca99x0_chip_reset()
2794 ath10k_warn(ar, "failed to wait for target after cold reset: %d\n", in ath10k_pci_qca99x0_chip_reset()
2799 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot qca99x0 chip reset complete (cold)\n"); in ath10k_pci_qca99x0_chip_reset()
2804 static int ath10k_pci_chip_reset(struct ath10k *ar) in ath10k_pci_chip_reset() argument
2806 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_chip_reset()
2811 return ar_pci->pci_hard_reset(ar); in ath10k_pci_chip_reset()
2814 static int ath10k_pci_hif_power_up(struct ath10k *ar, in ath10k_pci_hif_power_up() argument
2817 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_hif_power_up()
2820 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif power up\n"); in ath10k_pci_hif_power_up()
2837 ret = ath10k_pci_chip_reset(ar); in ath10k_pci_hif_power_up()
2839 if (ath10k_pci_has_fw_crashed(ar)) { in ath10k_pci_hif_power_up()
2840 ath10k_warn(ar, "firmware crashed during chip reset\n"); in ath10k_pci_hif_power_up()
2841 ath10k_pci_fw_crashed_clear(ar); in ath10k_pci_hif_power_up()
2842 ath10k_pci_fw_crashed_dump(ar); in ath10k_pci_hif_power_up()
2845 ath10k_err(ar, "failed to reset chip: %d\n", ret); in ath10k_pci_hif_power_up()
2849 ret = ath10k_pci_init_pipes(ar); in ath10k_pci_hif_power_up()
2851 ath10k_err(ar, "failed to initialize CE: %d\n", ret); in ath10k_pci_hif_power_up()
2855 ret = ath10k_pci_init_config(ar); in ath10k_pci_hif_power_up()
2857 ath10k_err(ar, "failed to setup init config: %d\n", ret); in ath10k_pci_hif_power_up()
2861 ret = ath10k_pci_wake_target_cpu(ar); in ath10k_pci_hif_power_up()
2863 ath10k_err(ar, "could not wake up target CPU: %d\n", ret); in ath10k_pci_hif_power_up()
2870 ath10k_pci_ce_deinit(ar); in ath10k_pci_hif_power_up()
2876 void ath10k_pci_hif_power_down(struct ath10k *ar) in ath10k_pci_hif_power_down() argument
2878 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif power down\n"); in ath10k_pci_hif_power_down()
2885 static int ath10k_pci_hif_suspend(struct ath10k *ar) in ath10k_pci_hif_suspend() argument
2891 static int ath10k_pci_suspend(struct ath10k *ar) in ath10k_pci_suspend() argument
2898 ath10k_pci_sleep_sync(ar); in ath10k_pci_suspend()
2903 static int ath10k_pci_hif_resume(struct ath10k *ar) in ath10k_pci_hif_resume() argument
2909 static int ath10k_pci_resume(struct ath10k *ar) in ath10k_pci_resume() argument
2911 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_resume()
2916 ret = ath10k_pci_force_wake(ar); in ath10k_pci_resume()
2918 ath10k_err(ar, "failed to wake up target: %d\n", ret); in ath10k_pci_resume()
2949 static void ath10k_pci_enable_eeprom(struct ath10k *ar) in ath10k_pci_enable_eeprom() argument
2952 ath10k_pci_soc_write32(ar, CLOCK_CONTROL_OFFSET, 0x0); in ath10k_pci_enable_eeprom()
2955 ath10k_pci_write32(ar, in ath10k_pci_enable_eeprom()
2962 ath10k_pci_write32(ar, in ath10k_pci_enable_eeprom()
2968 ath10k_pci_write32(ar, in ath10k_pci_enable_eeprom()
2974 ath10k_pci_write32(ar, in ath10k_pci_enable_eeprom()
2985 static int ath10k_pci_read_eeprom(struct ath10k *ar, u16 addr, u8 *out) in ath10k_pci_read_eeprom() argument
2994 ath10k_pci_write32(ar, SI_BASE_ADDRESS + SI_TX_DATA0_OFFSET, reg); in ath10k_pci_read_eeprom()
2997 ath10k_pci_write32(ar, SI_BASE_ADDRESS + SI_CS_OFFSET, in ath10k_pci_read_eeprom()
3006 reg = ath10k_pci_read32(ar, SI_BASE_ADDRESS + SI_CS_OFFSET); in ath10k_pci_read_eeprom()
3015 ath10k_err(ar, "timeout while reading device EEPROM at %04x\n", in ath10k_pci_read_eeprom()
3021 ath10k_pci_write32(ar, SI_BASE_ADDRESS + SI_CS_OFFSET, reg); in ath10k_pci_read_eeprom()
3024 ath10k_err(ar, "failed to read device EEPROM at %04x\n", addr); in ath10k_pci_read_eeprom()
3029 reg = ath10k_pci_read32(ar, SI_BASE_ADDRESS + SI_RX_DATA0_OFFSET); in ath10k_pci_read_eeprom()
3035 static int ath10k_pci_hif_fetch_cal_eeprom(struct ath10k *ar, void **data, in ath10k_pci_hif_fetch_cal_eeprom() argument
3042 if (!QCA_REV_9887(ar)) in ath10k_pci_hif_fetch_cal_eeprom()
3045 calsize = ar->hw_params.cal_data_len; in ath10k_pci_hif_fetch_cal_eeprom()
3050 ath10k_pci_enable_eeprom(ar); in ath10k_pci_hif_fetch_cal_eeprom()
3053 ret = ath10k_pci_read_eeprom(ar, i, &caldata[i]); in ath10k_pci_hif_fetch_cal_eeprom()
3099 struct ath10k *ar = arg; in ath10k_pci_interrupt_handler() local
3100 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_interrupt_handler()
3103 if (ath10k_pci_has_device_gone(ar)) in ath10k_pci_interrupt_handler()
3106 ret = ath10k_pci_force_wake(ar); in ath10k_pci_interrupt_handler()
3108 ath10k_warn(ar, "failed to wake device up on irq: %d\n", ret); in ath10k_pci_interrupt_handler()
3113 !ath10k_pci_irq_pending(ar)) in ath10k_pci_interrupt_handler()
3116 ath10k_pci_disable_and_clear_legacy_irq(ar); in ath10k_pci_interrupt_handler()
3117 ath10k_pci_irq_msi_fw_mask(ar); in ath10k_pci_interrupt_handler()
3118 napi_schedule(&ar->napi); in ath10k_pci_interrupt_handler()
3125 struct ath10k *ar = container_of(ctx, struct ath10k, napi); in ath10k_pci_napi_poll() local
3128 if (ath10k_pci_has_fw_crashed(ar)) { in ath10k_pci_napi_poll()
3129 ath10k_pci_fw_crashed_clear(ar); in ath10k_pci_napi_poll()
3130 ath10k_pci_fw_crashed_dump(ar); in ath10k_pci_napi_poll()
3135 ath10k_ce_per_engine_service_any(ar); in ath10k_pci_napi_poll()
3137 done = ath10k_htt_txrx_compl_task(ar, budget); in ath10k_pci_napi_poll()
3149 if (ath10k_ce_interrupt_summary(ar)) { in ath10k_pci_napi_poll()
3153 ath10k_pci_enable_legacy_irq(ar); in ath10k_pci_napi_poll()
3154 ath10k_pci_irq_msi_fw_unmask(ar); in ath10k_pci_napi_poll()
3161 static int ath10k_pci_request_irq_msi(struct ath10k *ar) in ath10k_pci_request_irq_msi() argument
3163 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_request_irq_msi()
3168 IRQF_SHARED, "ath10k_pci", ar); in ath10k_pci_request_irq_msi()
3170 ath10k_warn(ar, "failed to request MSI irq %d: %d\n", in ath10k_pci_request_irq_msi()
3178 static int ath10k_pci_request_irq_legacy(struct ath10k *ar) in ath10k_pci_request_irq_legacy() argument
3180 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_request_irq_legacy()
3185 IRQF_SHARED, "ath10k_pci", ar); in ath10k_pci_request_irq_legacy()
3187 ath10k_warn(ar, "failed to request legacy irq %d: %d\n", in ath10k_pci_request_irq_legacy()
3195 static int ath10k_pci_request_irq(struct ath10k *ar) in ath10k_pci_request_irq() argument
3197 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_request_irq()
3201 return ath10k_pci_request_irq_legacy(ar); in ath10k_pci_request_irq()
3203 return ath10k_pci_request_irq_msi(ar); in ath10k_pci_request_irq()
3209 static void ath10k_pci_free_irq(struct ath10k *ar) in ath10k_pci_free_irq() argument
3211 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_free_irq()
3213 free_irq(ar_pci->pdev->irq, ar); in ath10k_pci_free_irq()
3216 void ath10k_pci_init_napi(struct ath10k *ar) in ath10k_pci_init_napi() argument
3218 netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_pci_napi_poll, in ath10k_pci_init_napi()
3222 static int ath10k_pci_init_irq(struct ath10k *ar) in ath10k_pci_init_irq() argument
3224 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_init_irq()
3227 ath10k_pci_init_napi(ar); in ath10k_pci_init_irq()
3230 ath10k_info(ar, "limiting irq mode to: %d\n", in ath10k_pci_init_irq()
3254 ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + PCIE_INTR_ENABLE_ADDRESS, in ath10k_pci_init_irq()
3260 static void ath10k_pci_deinit_irq_legacy(struct ath10k *ar) in ath10k_pci_deinit_irq_legacy() argument
3262 ath10k_pci_write32(ar, SOC_CORE_BASE_ADDRESS + PCIE_INTR_ENABLE_ADDRESS, in ath10k_pci_deinit_irq_legacy()
3266 static int ath10k_pci_deinit_irq(struct ath10k *ar) in ath10k_pci_deinit_irq() argument
3268 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_deinit_irq()
3272 ath10k_pci_deinit_irq_legacy(ar); in ath10k_pci_deinit_irq()
3282 int ath10k_pci_wait_for_target_init(struct ath10k *ar) in ath10k_pci_wait_for_target_init() argument
3284 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_wait_for_target_init()
3288 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot waiting target to initialise\n"); in ath10k_pci_wait_for_target_init()
3293 val = ath10k_pci_read32(ar, FW_INDICATOR_ADDRESS); in ath10k_pci_wait_for_target_init()
3295 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot target indicator %x\n", in ath10k_pci_wait_for_target_init()
3311 ath10k_pci_enable_legacy_irq(ar); in ath10k_pci_wait_for_target_init()
3316 ath10k_pci_disable_and_clear_legacy_irq(ar); in ath10k_pci_wait_for_target_init()
3317 ath10k_pci_irq_msi_fw_mask(ar); in ath10k_pci_wait_for_target_init()
3320 ath10k_err(ar, "failed to read device register, device is gone\n"); in ath10k_pci_wait_for_target_init()
3325 ath10k_warn(ar, "device has crashed during init\n"); in ath10k_pci_wait_for_target_init()
3330 ath10k_err(ar, "failed to receive initialized event from target: %08x\n", in ath10k_pci_wait_for_target_init()
3335 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot target initialised\n"); in ath10k_pci_wait_for_target_init()
3339 static int ath10k_pci_cold_reset(struct ath10k *ar) in ath10k_pci_cold_reset() argument
3343 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot cold reset\n"); in ath10k_pci_cold_reset()
3345 spin_lock_bh(&ar->data_lock); in ath10k_pci_cold_reset()
3347 ar->stats.fw_cold_reset_counter++; in ath10k_pci_cold_reset()
3349 spin_unlock_bh(&ar->data_lock); in ath10k_pci_cold_reset()
3352 val = ath10k_pci_reg_read32(ar, SOC_GLOBAL_RESET_ADDRESS); in ath10k_pci_cold_reset()
3354 ath10k_pci_reg_write32(ar, SOC_GLOBAL_RESET_ADDRESS, val); in ath10k_pci_cold_reset()
3365 ath10k_pci_reg_write32(ar, SOC_GLOBAL_RESET_ADDRESS, val); in ath10k_pci_cold_reset()
3369 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot cold reset complete\n"); in ath10k_pci_cold_reset()
3374 static int ath10k_pci_claim(struct ath10k *ar) in ath10k_pci_claim() argument
3376 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_claim()
3380 pci_set_drvdata(pdev, ar); in ath10k_pci_claim()
3384 ath10k_err(ar, "failed to enable pci device: %d\n", ret); in ath10k_pci_claim()
3390 ath10k_err(ar, "failed to request region BAR%d: %d\n", BAR_NUM, in ath10k_pci_claim()
3398 ath10k_err(ar, "failed to set dma mask to 32-bit: %d\n", ret); in ath10k_pci_claim()
3408 ath10k_err(ar, "failed to iomap BAR%d\n", BAR_NUM); in ath10k_pci_claim()
3413 ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot pci_mem 0x%pK\n", ar_pci->mem); in ath10k_pci_claim()
3428 static void ath10k_pci_release(struct ath10k *ar) in ath10k_pci_release() argument
3430 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_release()
3456 int ath10k_pci_setup_resource(struct ath10k *ar) in ath10k_pci_setup_resource() argument
3458 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_setup_resource()
3459 struct ath10k_ce *ce = ath10k_ce_priv(ar); in ath10k_pci_setup_resource()
3492 if (QCA_REV_6174(ar) || QCA_REV_9377(ar)) in ath10k_pci_setup_resource()
3493 ath10k_pci_override_ce_config(ar); in ath10k_pci_setup_resource()
3495 ret = ath10k_pci_alloc_pipes(ar); in ath10k_pci_setup_resource()
3497 ath10k_err(ar, "failed to allocate copy engine pipes: %d\n", in ath10k_pci_setup_resource()
3513 void ath10k_pci_release_resource(struct ath10k *ar) in ath10k_pci_release_resource() argument
3515 struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); in ath10k_pci_release_resource()
3517 ath10k_pci_rx_retry_sync(ar); in ath10k_pci_release_resource()
3518 netif_napi_del(&ar->napi); in ath10k_pci_release_resource()
3519 ath10k_pci_ce_deinit(ar); in ath10k_pci_release_resource()
3520 ath10k_pci_free_pipes(ar); in ath10k_pci_release_resource()
3536 struct ath10k *ar; in ath10k_pci_probe() local
3541 int (*pci_soft_reset)(struct ath10k *ar); in ath10k_pci_probe()
3542 int (*pci_hard_reset)(struct ath10k *ar); in ath10k_pci_probe()
3543 u32 (*targ_cpu_to_ce_addr)(struct ath10k *ar, u32 addr); in ath10k_pci_probe()
3603 ar = ath10k_core_create(sizeof(*ar_pci), &pdev->dev, ATH10K_BUS_PCI, in ath10k_pci_probe()
3605 if (!ar) { in ath10k_pci_probe()
3610 ath10k_dbg(ar, ATH10K_DBG_BOOT, "pci probe %04x:%04x %04x:%04x\n", in ath10k_pci_probe()
3614 ar_pci = ath10k_pci_priv(ar); in ath10k_pci_probe()
3617 ar_pci->ar = ar; in ath10k_pci_probe()
3618 ar->dev_id = pci_dev->device; in ath10k_pci_probe()
3624 ar->ce_priv = &ar_pci->ce; in ath10k_pci_probe()
3626 ar->id.vendor = pdev->vendor; in ath10k_pci_probe()
3627 ar->id.device = pdev->device; in ath10k_pci_probe()
3628 ar->id.subsystem_vendor = pdev->subsystem_vendor; in ath10k_pci_probe()
3629 ar->id.subsystem_device = pdev->subsystem_device; in ath10k_pci_probe()
3633 ret = ath10k_pci_setup_resource(ar); in ath10k_pci_probe()
3635 ath10k_err(ar, "failed to setup resource: %d\n", ret); in ath10k_pci_probe()
3639 ret = ath10k_pci_claim(ar); in ath10k_pci_probe()
3641 ath10k_err(ar, "failed to claim device: %d\n", ret); in ath10k_pci_probe()
3645 ret = ath10k_pci_force_wake(ar); in ath10k_pci_probe()
3647 ath10k_warn(ar, "failed to wake up device : %d\n", ret); in ath10k_pci_probe()
3651 ath10k_pci_ce_deinit(ar); in ath10k_pci_probe()
3652 ath10k_pci_irq_disable(ar); in ath10k_pci_probe()
3654 ret = ath10k_pci_init_irq(ar); in ath10k_pci_probe()
3656 ath10k_err(ar, "failed to init irqs: %d\n", ret); in ath10k_pci_probe()
3660 ath10k_info(ar, "pci irq %s oper_irq_mode %d irq_mode %d reset_mode %d\n", in ath10k_pci_probe()
3661 ath10k_pci_get_irq_method(ar), ar_pci->oper_irq_mode, in ath10k_pci_probe()
3664 ret = ath10k_pci_request_irq(ar); in ath10k_pci_probe()
3666 ath10k_warn(ar, "failed to request irqs: %d\n", ret); in ath10k_pci_probe()
3678 ath10k_pci_soc_read32(ar, SOC_CHIP_ID_ADDRESS); in ath10k_pci_probe()
3688 ret = ath10k_pci_chip_reset(ar); in ath10k_pci_probe()
3690 ath10k_err(ar, "failed to reset chip: %d\n", ret); in ath10k_pci_probe()
3694 bus_params.chip_id = ath10k_pci_soc_read32(ar, SOC_CHIP_ID_ADDRESS); in ath10k_pci_probe()
3705 ret = ath10k_core_register(ar, &bus_params); in ath10k_pci_probe()
3707 ath10k_err(ar, "failed to register driver core: %d\n", ret); in ath10k_pci_probe()
3714 ath10k_err(ar, "device %04x with chip_id %08x isn't supported\n", in ath10k_pci_probe()
3718 ath10k_pci_free_irq(ar); in ath10k_pci_probe()
3721 ath10k_pci_release_resource(ar); in ath10k_pci_probe()
3724 ath10k_pci_sleep_sync(ar); in ath10k_pci_probe()
3725 ath10k_pci_release(ar); in ath10k_pci_probe()
3728 ath10k_pci_free_pipes(ar); in ath10k_pci_probe()
3731 ath10k_core_destroy(ar); in ath10k_pci_probe()
3738 struct ath10k *ar = pci_get_drvdata(pdev); in ath10k_pci_remove() local
3740 ath10k_dbg(ar, ATH10K_DBG_PCI, "pci remove\n"); in ath10k_pci_remove()
3742 if (!ar) in ath10k_pci_remove()
3745 ath10k_core_unregister(ar); in ath10k_pci_remove()
3746 ath10k_pci_free_irq(ar); in ath10k_pci_remove()
3747 ath10k_pci_deinit_irq(ar); in ath10k_pci_remove()
3748 ath10k_pci_release_resource(ar); in ath10k_pci_remove()
3749 ath10k_pci_sleep_sync(ar); in ath10k_pci_remove()
3750 ath10k_pci_release(ar); in ath10k_pci_remove()
3751 ath10k_core_destroy(ar); in ath10k_pci_remove()
3758 struct ath10k *ar = dev_get_drvdata(dev); in ath10k_pci_pm_suspend() local
3761 ret = ath10k_pci_suspend(ar); in ath10k_pci_pm_suspend()
3763 ath10k_warn(ar, "failed to suspend hif: %d\n", ret); in ath10k_pci_pm_suspend()
3770 struct ath10k *ar = dev_get_drvdata(dev); in ath10k_pci_pm_resume() local
3773 ret = ath10k_pci_resume(ar); in ath10k_pci_pm_resume()
3775 ath10k_warn(ar, "failed to resume hif: %d\n", ret); in ath10k_pci_pm_resume()