Lines Matching refs:ab_pci

48 	struct ath11k_pci *ab_pci = ath11k_pci_priv(ab);  in ath11k_pci_bus_wake_up()  local
50 return mhi_device_get_sync(ab_pci->mhi_ctrl->mhi_dev); in ath11k_pci_bus_wake_up()
55 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_bus_release() local
57 mhi_device_put(ab_pci->mhi_ctrl->mhi_dev); in ath11k_pci_bus_release()
76 static inline void ath11k_pci_select_window(struct ath11k_pci *ab_pci, u32 offset) in ath11k_pci_select_window() argument
78 struct ath11k_base *ab = ab_pci->ab; in ath11k_pci_select_window()
82 lockdep_assert_held(&ab_pci->window_lock); in ath11k_pci_select_window()
84 if (window != ab_pci->register_window) { in ath11k_pci_select_window()
94 ab_pci->register_window = window; in ath11k_pci_select_window()
101 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_window_write32() local
107 spin_lock_bh(&ab_pci->window_lock); in ath11k_pci_window_write32()
108 ath11k_pci_select_window(ab_pci, offset); in ath11k_pci_window_write32()
115 spin_unlock_bh(&ab_pci->window_lock); in ath11k_pci_window_write32()
128 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_window_read32() local
134 spin_lock_bh(&ab_pci->window_lock); in ath11k_pci_window_read32()
135 ath11k_pci_select_window(ab_pci, offset); in ath11k_pci_window_read32()
142 spin_unlock_bh(&ab_pci->window_lock); in ath11k_pci_window_read32()
189 static inline void ath11k_pci_select_static_window(struct ath11k_pci *ab_pci) in ath11k_pci_select_static_window() argument
201 ab_pci->ab->mem + ATH11K_PCI_WINDOW_REG_ADDRESS); in ath11k_pci_select_static_window()
203 (char *)ab_pci->ab->mem + ATH11K_PCI_WINDOW_REG_ADDRESS); in ath11k_pci_select_static_window()
418 static void ath11k_pci_msi_config(struct ath11k_pci *ab_pci, bool enable) in ath11k_pci_msi_config() argument
420 struct pci_dev *dev = ab_pci->pdev; in ath11k_pci_msi_config()
433 static void ath11k_pci_msi_enable(struct ath11k_pci *ab_pci) in ath11k_pci_msi_enable() argument
435 ath11k_pci_msi_config(ab_pci, true); in ath11k_pci_msi_enable()
438 static void ath11k_pci_msi_disable(struct ath11k_pci *ab_pci) in ath11k_pci_msi_disable() argument
440 ath11k_pci_msi_config(ab_pci, false); in ath11k_pci_msi_disable()
443 static int ath11k_pci_alloc_msi(struct ath11k_pci *ab_pci) in ath11k_pci_alloc_msi() argument
445 struct ath11k_base *ab = ab_pci->ab; in ath11k_pci_alloc_msi()
447 struct pci_dev *pci_dev = ab_pci->pdev; in ath11k_pci_alloc_msi()
459 num_vectors = pci_alloc_irq_vectors(ab_pci->pdev, in ath11k_pci_alloc_msi()
473 ath11k_pci_msi_disable(ab_pci); in ath11k_pci_alloc_msi()
475 msi_desc = irq_get_msi_desc(ab_pci->pdev->irq); in ath11k_pci_alloc_msi()
499 pci_free_irq_vectors(ab_pci->pdev); in ath11k_pci_alloc_msi()
505 static void ath11k_pci_free_msi(struct ath11k_pci *ab_pci) in ath11k_pci_free_msi() argument
507 pci_free_irq_vectors(ab_pci->pdev); in ath11k_pci_free_msi()
510 static int ath11k_pci_config_msi_data(struct ath11k_pci *ab_pci) in ath11k_pci_config_msi_data() argument
514 msi_desc = irq_get_msi_desc(ab_pci->pdev->irq); in ath11k_pci_config_msi_data()
516 ath11k_err(ab_pci->ab, "msi_desc is NULL!\n"); in ath11k_pci_config_msi_data()
517 pci_free_irq_vectors(ab_pci->pdev); in ath11k_pci_config_msi_data()
521 ab_pci->ab->pci.msi.ep_base_data = msi_desc->msg.data; in ath11k_pci_config_msi_data()
523 ath11k_dbg(ab_pci->ab, ATH11K_DBG_PCI, "after request_irq msi_ep_base_data %d\n", in ath11k_pci_config_msi_data()
524 ab_pci->ab->pci.msi.ep_base_data); in ath11k_pci_config_msi_data()
529 static int ath11k_pci_claim(struct ath11k_pci *ab_pci, struct pci_dev *pdev) in ath11k_pci_claim() argument
531 struct ath11k_base *ab = ab_pci->ab; in ath11k_pci_claim()
536 if (device_id != ab_pci->dev_id) { in ath11k_pci_claim()
538 device_id, ab_pci->dev_id); in ath11k_pci_claim()
592 static void ath11k_pci_free_region(struct ath11k_pci *ab_pci) in ath11k_pci_free_region() argument
594 struct ath11k_base *ab = ab_pci->ab; in ath11k_pci_free_region()
595 struct pci_dev *pci_dev = ab_pci->pdev; in ath11k_pci_free_region()
604 static void ath11k_pci_aspm_disable(struct ath11k_pci *ab_pci) in ath11k_pci_aspm_disable() argument
606 struct ath11k_base *ab = ab_pci->ab; in ath11k_pci_aspm_disable()
608 pcie_capability_read_word(ab_pci->pdev, PCI_EXP_LNKCTL, in ath11k_pci_aspm_disable()
609 &ab_pci->link_ctl); in ath11k_pci_aspm_disable()
612 ab_pci->link_ctl, in ath11k_pci_aspm_disable()
613 u16_get_bits(ab_pci->link_ctl, PCI_EXP_LNKCTL_ASPM_L0S), in ath11k_pci_aspm_disable()
614 u16_get_bits(ab_pci->link_ctl, PCI_EXP_LNKCTL_ASPM_L1)); in ath11k_pci_aspm_disable()
617 pcie_capability_write_word(ab_pci->pdev, PCI_EXP_LNKCTL, in ath11k_pci_aspm_disable()
618 ab_pci->link_ctl & ~PCI_EXP_LNKCTL_ASPMC); in ath11k_pci_aspm_disable()
620 set_bit(ATH11K_PCI_ASPM_RESTORE, &ab_pci->flags); in ath11k_pci_aspm_disable()
623 static void ath11k_pci_aspm_restore(struct ath11k_pci *ab_pci) in ath11k_pci_aspm_restore() argument
625 if (test_and_clear_bit(ATH11K_PCI_ASPM_RESTORE, &ab_pci->flags)) in ath11k_pci_aspm_restore()
626 pcie_capability_write_word(ab_pci->pdev, PCI_EXP_LNKCTL, in ath11k_pci_aspm_restore()
627 ab_pci->link_ctl); in ath11k_pci_aspm_restore()
632 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_power_up() local
635 ab_pci->register_window = 0; in ath11k_pci_power_up()
637 ath11k_pci_sw_reset(ab_pci->ab, true); in ath11k_pci_power_up()
642 ath11k_pci_aspm_disable(ab_pci); in ath11k_pci_power_up()
644 ath11k_pci_msi_enable(ab_pci); in ath11k_pci_power_up()
646 ret = ath11k_mhi_start(ab_pci); in ath11k_pci_power_up()
653 ath11k_pci_select_static_window(ab_pci); in ath11k_pci_power_up()
660 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_power_down() local
663 ath11k_pci_aspm_restore(ab_pci); in ath11k_pci_power_down()
665 ath11k_pci_force_wake(ab_pci->ab); in ath11k_pci_power_down()
667 ath11k_pci_msi_disable(ab_pci); in ath11k_pci_power_down()
669 ath11k_mhi_stop(ab_pci); in ath11k_pci_power_down()
671 ath11k_pci_sw_reset(ab_pci->ab, false); in ath11k_pci_power_down()
700 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_start() local
706 ath11k_pci_aspm_restore(ab_pci); in ath11k_pci_start()
749 static int ath11k_pci_set_irq_affinity_hint(struct ath11k_pci *ab_pci, in ath11k_pci_set_irq_affinity_hint() argument
756 if (test_bit(ATH11K_FLAG_MULTI_MSI_VECTORS, &ab_pci->ab->dev_flags)) in ath11k_pci_set_irq_affinity_hint()
759 return irq_set_affinity_hint(ab_pci->pdev->irq, m); in ath11k_pci_set_irq_affinity_hint()
766 struct ath11k_pci *ab_pci; in ath11k_pci_probe() local
775 ab = ath11k_core_alloc(&pdev->dev, sizeof(*ab_pci), ATH11K_BUS_PCI); in ath11k_pci_probe()
784 ab_pci = ath11k_pci_priv(ab); in ath11k_pci_probe()
785 ab_pci->dev_id = pci_dev->device; in ath11k_pci_probe()
786 ab_pci->ab = ab; in ath11k_pci_probe()
787 ab_pci->pdev = pdev; in ath11k_pci_probe()
791 spin_lock_init(&ab_pci->window_lock); in ath11k_pci_probe()
803 ret = ath11k_pci_claim(ab_pci, pdev); in ath11k_pci_probe()
887 ret = ath11k_pci_alloc_msi(ab_pci); in ath11k_pci_probe()
897 ret = ath11k_mhi_register(ab_pci); in ath11k_pci_probe()
921 ret = ath11k_pci_set_irq_affinity_hint(ab_pci, cpumask_of(0)); in ath11k_pci_probe()
932 ret = ath11k_pci_config_msi_data(ab_pci); in ath11k_pci_probe()
947 ath11k_pci_set_irq_affinity_hint(ab_pci, NULL); in ath11k_pci_probe()
959 ath11k_mhi_unregister(ab_pci); in ath11k_pci_probe()
962 ath11k_pci_free_msi(ab_pci); in ath11k_pci_probe()
965 ath11k_pci_free_region(ab_pci); in ath11k_pci_probe()
976 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_remove() local
978 ath11k_pci_set_irq_affinity_hint(ab_pci, NULL); in ath11k_pci_remove()
992 ath11k_mhi_unregister(ab_pci); in ath11k_pci_remove()
995 ath11k_pci_free_msi(ab_pci); in ath11k_pci_remove()
996 ath11k_pci_free_region(ab_pci); in ath11k_pci_remove()
1006 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_shutdown() local
1008 ath11k_pci_set_irq_affinity_hint(ab_pci, NULL); in ath11k_pci_shutdown()