Lines Matching refs:ab_pci
45 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_bus_wake_up() local
47 return mhi_device_get_sync(ab_pci->mhi_ctrl->mhi_dev); in ath11k_pci_bus_wake_up()
52 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_bus_release() local
54 mhi_device_put(ab_pci->mhi_ctrl->mhi_dev); in ath11k_pci_bus_release()
73 static inline void ath11k_pci_select_window(struct ath11k_pci *ab_pci, u32 offset) in ath11k_pci_select_window() argument
75 struct ath11k_base *ab = ab_pci->ab; in ath11k_pci_select_window()
79 lockdep_assert_held(&ab_pci->window_lock); in ath11k_pci_select_window()
81 if (window != ab_pci->register_window) { in ath11k_pci_select_window()
85 ab_pci->register_window = window; in ath11k_pci_select_window()
92 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_window_write32() local
98 spin_lock_bh(&ab_pci->window_lock); in ath11k_pci_window_write32()
99 ath11k_pci_select_window(ab_pci, offset); in ath11k_pci_window_write32()
102 spin_unlock_bh(&ab_pci->window_lock); in ath11k_pci_window_write32()
111 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_window_read32() local
117 spin_lock_bh(&ab_pci->window_lock); in ath11k_pci_window_read32()
118 ath11k_pci_select_window(ab_pci, offset); in ath11k_pci_window_read32()
121 spin_unlock_bh(&ab_pci->window_lock); in ath11k_pci_window_read32()
164 static inline void ath11k_pci_select_static_window(struct ath11k_pci *ab_pci) in ath11k_pci_select_static_window() argument
175 ab_pci->ab->mem + ATH11K_PCI_WINDOW_REG_ADDRESS); in ath11k_pci_select_static_window()
389 static void ath11k_pci_msi_config(struct ath11k_pci *ab_pci, bool enable) in ath11k_pci_msi_config() argument
391 struct pci_dev *dev = ab_pci->pdev; in ath11k_pci_msi_config()
404 static void ath11k_pci_msi_enable(struct ath11k_pci *ab_pci) in ath11k_pci_msi_enable() argument
406 ath11k_pci_msi_config(ab_pci, true); in ath11k_pci_msi_enable()
409 static void ath11k_pci_msi_disable(struct ath11k_pci *ab_pci) in ath11k_pci_msi_disable() argument
411 ath11k_pci_msi_config(ab_pci, false); in ath11k_pci_msi_disable()
414 static int ath11k_pci_alloc_msi(struct ath11k_pci *ab_pci) in ath11k_pci_alloc_msi() argument
416 struct ath11k_base *ab = ab_pci->ab; in ath11k_pci_alloc_msi()
418 struct pci_dev *pci_dev = ab_pci->pdev; in ath11k_pci_alloc_msi()
430 num_vectors = pci_alloc_irq_vectors(ab_pci->pdev, in ath11k_pci_alloc_msi()
444 ath11k_pci_msi_disable(ab_pci); in ath11k_pci_alloc_msi()
446 msi_desc = irq_get_msi_desc(ab_pci->pdev->irq); in ath11k_pci_alloc_msi()
470 pci_free_irq_vectors(ab_pci->pdev); in ath11k_pci_alloc_msi()
476 static void ath11k_pci_free_msi(struct ath11k_pci *ab_pci) in ath11k_pci_free_msi() argument
478 pci_free_irq_vectors(ab_pci->pdev); in ath11k_pci_free_msi()
481 static int ath11k_pci_config_msi_data(struct ath11k_pci *ab_pci) in ath11k_pci_config_msi_data() argument
485 msi_desc = irq_get_msi_desc(ab_pci->pdev->irq); in ath11k_pci_config_msi_data()
487 ath11k_err(ab_pci->ab, "msi_desc is NULL!\n"); in ath11k_pci_config_msi_data()
488 pci_free_irq_vectors(ab_pci->pdev); in ath11k_pci_config_msi_data()
492 ab_pci->ab->pci.msi.ep_base_data = msi_desc->msg.data; in ath11k_pci_config_msi_data()
494 ath11k_dbg(ab_pci->ab, ATH11K_DBG_PCI, "after request_irq msi_ep_base_data %d\n", in ath11k_pci_config_msi_data()
495 ab_pci->ab->pci.msi.ep_base_data); in ath11k_pci_config_msi_data()
500 static int ath11k_pci_claim(struct ath11k_pci *ab_pci, struct pci_dev *pdev) in ath11k_pci_claim() argument
502 struct ath11k_base *ab = ab_pci->ab; in ath11k_pci_claim()
507 if (device_id != ab_pci->dev_id) { in ath11k_pci_claim()
509 device_id, ab_pci->dev_id); in ath11k_pci_claim()
540 ab_pci->dma_mask = DMA_BIT_MASK(ATH11K_PCI_DMA_MASK); in ath11k_pci_claim()
573 static void ath11k_pci_free_region(struct ath11k_pci *ab_pci) in ath11k_pci_free_region() argument
575 struct ath11k_base *ab = ab_pci->ab; in ath11k_pci_free_region()
576 struct pci_dev *pci_dev = ab_pci->pdev; in ath11k_pci_free_region()
585 static void ath11k_pci_aspm_disable(struct ath11k_pci *ab_pci) in ath11k_pci_aspm_disable() argument
587 struct ath11k_base *ab = ab_pci->ab; in ath11k_pci_aspm_disable()
589 pcie_capability_read_word(ab_pci->pdev, PCI_EXP_LNKCTL, in ath11k_pci_aspm_disable()
590 &ab_pci->link_ctl); in ath11k_pci_aspm_disable()
593 ab_pci->link_ctl, in ath11k_pci_aspm_disable()
594 u16_get_bits(ab_pci->link_ctl, PCI_EXP_LNKCTL_ASPM_L0S), in ath11k_pci_aspm_disable()
595 u16_get_bits(ab_pci->link_ctl, PCI_EXP_LNKCTL_ASPM_L1)); in ath11k_pci_aspm_disable()
598 pcie_capability_clear_word(ab_pci->pdev, PCI_EXP_LNKCTL, in ath11k_pci_aspm_disable()
601 set_bit(ATH11K_PCI_ASPM_RESTORE, &ab_pci->flags); in ath11k_pci_aspm_disable()
604 static void ath11k_pci_aspm_restore(struct ath11k_pci *ab_pci) in ath11k_pci_aspm_restore() argument
606 if (test_and_clear_bit(ATH11K_PCI_ASPM_RESTORE, &ab_pci->flags)) in ath11k_pci_aspm_restore()
607 pcie_capability_clear_and_set_word(ab_pci->pdev, PCI_EXP_LNKCTL, in ath11k_pci_aspm_restore()
609 ab_pci->link_ctl & in ath11k_pci_aspm_restore()
615 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_power_up() local
618 ab_pci->register_window = 0; in ath11k_pci_power_up()
620 ath11k_pci_sw_reset(ab_pci->ab, true); in ath11k_pci_power_up()
625 ath11k_pci_aspm_disable(ab_pci); in ath11k_pci_power_up()
627 ath11k_pci_msi_enable(ab_pci); in ath11k_pci_power_up()
629 ret = ath11k_mhi_start(ab_pci); in ath11k_pci_power_up()
636 ath11k_pci_select_static_window(ab_pci); in ath11k_pci_power_up()
643 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_power_down() local
646 ath11k_pci_aspm_restore(ab_pci); in ath11k_pci_power_down()
648 ath11k_pci_force_wake(ab_pci->ab); in ath11k_pci_power_down()
650 ath11k_pci_msi_disable(ab_pci); in ath11k_pci_power_down()
652 ath11k_mhi_stop(ab_pci); in ath11k_pci_power_down()
654 ath11k_pci_sw_reset(ab_pci->ab, false); in ath11k_pci_power_down()
683 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_start() local
689 ath11k_pci_aspm_restore(ab_pci); in ath11k_pci_start()
732 static int ath11k_pci_set_irq_affinity_hint(struct ath11k_pci *ab_pci, in ath11k_pci_set_irq_affinity_hint() argument
735 if (test_bit(ATH11K_FLAG_MULTI_MSI_VECTORS, &ab_pci->ab->dev_flags)) in ath11k_pci_set_irq_affinity_hint()
738 return irq_set_affinity_hint(ab_pci->pdev->irq, m); in ath11k_pci_set_irq_affinity_hint()
745 struct ath11k_pci *ab_pci; in ath11k_pci_probe() local
750 ab = ath11k_core_alloc(&pdev->dev, sizeof(*ab_pci), ATH11K_BUS_PCI); in ath11k_pci_probe()
759 ab_pci = ath11k_pci_priv(ab); in ath11k_pci_probe()
760 ab_pci->dev_id = pci_dev->device; in ath11k_pci_probe()
761 ab_pci->ab = ab; in ath11k_pci_probe()
762 ab_pci->pdev = pdev; in ath11k_pci_probe()
766 spin_lock_init(&ab_pci->window_lock); in ath11k_pci_probe()
776 ret = ath11k_pci_claim(ab_pci, pdev); in ath11k_pci_probe()
879 ret = ath11k_pci_alloc_msi(ab_pci); in ath11k_pci_probe()
889 ret = ath11k_pci_set_irq_affinity_hint(ab_pci, cpumask_of(0)); in ath11k_pci_probe()
895 ret = ath11k_mhi_register(ab_pci); in ath11k_pci_probe()
924 ret = ath11k_pci_config_msi_data(ab_pci); in ath11k_pci_probe()
948 ath11k_mhi_unregister(ab_pci); in ath11k_pci_probe()
951 ath11k_pci_set_irq_affinity_hint(ab_pci, NULL); in ath11k_pci_probe()
954 ath11k_pci_free_msi(ab_pci); in ath11k_pci_probe()
957 ath11k_pci_free_region(ab_pci); in ath11k_pci_probe()
968 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_remove() local
970 ath11k_pci_set_irq_affinity_hint(ab_pci, NULL); in ath11k_pci_remove()
984 ath11k_mhi_unregister(ab_pci); in ath11k_pci_remove()
987 ath11k_pci_free_msi(ab_pci); in ath11k_pci_remove()
988 ath11k_pci_free_region(ab_pci); in ath11k_pci_remove()
998 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_shutdown() local
1000 ath11k_pci_set_irq_affinity_hint(ab_pci, NULL); in ath11k_pci_shutdown()