Lines Matching refs:ab_pci

41 	struct ath11k_pci *ab_pci = ath11k_pci_priv(ab);  in ath11k_pci_bus_wake_up()  local
43 return mhi_device_get_sync(ab_pci->mhi_ctrl->mhi_dev); in ath11k_pci_bus_wake_up()
48 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_bus_release() local
50 mhi_device_put(ab_pci->mhi_ctrl->mhi_dev); in ath11k_pci_bus_release()
69 static inline void ath11k_pci_select_window(struct ath11k_pci *ab_pci, u32 offset) in ath11k_pci_select_window() argument
71 struct ath11k_base *ab = ab_pci->ab; in ath11k_pci_select_window()
75 lockdep_assert_held(&ab_pci->window_lock); in ath11k_pci_select_window()
77 if (window != ab_pci->register_window) { in ath11k_pci_select_window()
81 ab_pci->register_window = window; in ath11k_pci_select_window()
88 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_window_write32() local
94 spin_lock_bh(&ab_pci->window_lock); in ath11k_pci_window_write32()
95 ath11k_pci_select_window(ab_pci, offset); in ath11k_pci_window_write32()
98 spin_unlock_bh(&ab_pci->window_lock); in ath11k_pci_window_write32()
107 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_window_read32() local
113 spin_lock_bh(&ab_pci->window_lock); in ath11k_pci_window_read32()
114 ath11k_pci_select_window(ab_pci, offset); in ath11k_pci_window_read32()
117 spin_unlock_bh(&ab_pci->window_lock); in ath11k_pci_window_read32()
160 static inline void ath11k_pci_select_static_window(struct ath11k_pci *ab_pci) in ath11k_pci_select_static_window() argument
171 ab_pci->ab->mem + ATH11K_PCI_WINDOW_REG_ADDRESS); in ath11k_pci_select_static_window()
385 static void ath11k_pci_msi_config(struct ath11k_pci *ab_pci, bool enable) in ath11k_pci_msi_config() argument
387 struct pci_dev *dev = ab_pci->pdev; in ath11k_pci_msi_config()
400 static void ath11k_pci_msi_enable(struct ath11k_pci *ab_pci) in ath11k_pci_msi_enable() argument
402 ath11k_pci_msi_config(ab_pci, true); in ath11k_pci_msi_enable()
405 static void ath11k_pci_msi_disable(struct ath11k_pci *ab_pci) in ath11k_pci_msi_disable() argument
407 ath11k_pci_msi_config(ab_pci, false); in ath11k_pci_msi_disable()
410 static int ath11k_pci_alloc_msi(struct ath11k_pci *ab_pci) in ath11k_pci_alloc_msi() argument
412 struct ath11k_base *ab = ab_pci->ab; in ath11k_pci_alloc_msi()
414 struct pci_dev *pci_dev = ab_pci->pdev; in ath11k_pci_alloc_msi()
426 num_vectors = pci_alloc_irq_vectors(ab_pci->pdev, in ath11k_pci_alloc_msi()
440 ath11k_pci_msi_disable(ab_pci); in ath11k_pci_alloc_msi()
442 msi_desc = irq_get_msi_desc(ab_pci->pdev->irq); in ath11k_pci_alloc_msi()
466 pci_free_irq_vectors(ab_pci->pdev); in ath11k_pci_alloc_msi()
472 static void ath11k_pci_free_msi(struct ath11k_pci *ab_pci) in ath11k_pci_free_msi() argument
474 pci_free_irq_vectors(ab_pci->pdev); in ath11k_pci_free_msi()
477 static int ath11k_pci_config_msi_data(struct ath11k_pci *ab_pci) in ath11k_pci_config_msi_data() argument
481 msi_desc = irq_get_msi_desc(ab_pci->pdev->irq); in ath11k_pci_config_msi_data()
483 ath11k_err(ab_pci->ab, "msi_desc is NULL!\n"); in ath11k_pci_config_msi_data()
484 pci_free_irq_vectors(ab_pci->pdev); in ath11k_pci_config_msi_data()
488 ab_pci->ab->pci.msi.ep_base_data = msi_desc->msg.data; in ath11k_pci_config_msi_data()
490 ath11k_dbg(ab_pci->ab, ATH11K_DBG_PCI, "pci after request_irq msi_ep_base_data %d\n", in ath11k_pci_config_msi_data()
491 ab_pci->ab->pci.msi.ep_base_data); in ath11k_pci_config_msi_data()
496 static int ath11k_pci_claim(struct ath11k_pci *ab_pci, struct pci_dev *pdev) in ath11k_pci_claim() argument
498 struct ath11k_base *ab = ab_pci->ab; in ath11k_pci_claim()
503 if (device_id != ab_pci->dev_id) { in ath11k_pci_claim()
505 device_id, ab_pci->dev_id); in ath11k_pci_claim()
559 static void ath11k_pci_free_region(struct ath11k_pci *ab_pci) in ath11k_pci_free_region() argument
561 struct ath11k_base *ab = ab_pci->ab; in ath11k_pci_free_region()
562 struct pci_dev *pci_dev = ab_pci->pdev; in ath11k_pci_free_region()
572 static void ath11k_pci_aspm_disable(struct ath11k_pci *ab_pci) in ath11k_pci_aspm_disable() argument
574 struct ath11k_base *ab = ab_pci->ab; in ath11k_pci_aspm_disable()
576 pcie_capability_read_word(ab_pci->pdev, PCI_EXP_LNKCTL, in ath11k_pci_aspm_disable()
577 &ab_pci->link_ctl); in ath11k_pci_aspm_disable()
580 ab_pci->link_ctl, in ath11k_pci_aspm_disable()
581 u16_get_bits(ab_pci->link_ctl, PCI_EXP_LNKCTL_ASPM_L0S), in ath11k_pci_aspm_disable()
582 u16_get_bits(ab_pci->link_ctl, PCI_EXP_LNKCTL_ASPM_L1)); in ath11k_pci_aspm_disable()
585 pcie_capability_write_word(ab_pci->pdev, PCI_EXP_LNKCTL, in ath11k_pci_aspm_disable()
586 ab_pci->link_ctl & ~PCI_EXP_LNKCTL_ASPMC); in ath11k_pci_aspm_disable()
588 set_bit(ATH11K_PCI_ASPM_RESTORE, &ab_pci->flags); in ath11k_pci_aspm_disable()
591 static void ath11k_pci_aspm_restore(struct ath11k_pci *ab_pci) in ath11k_pci_aspm_restore() argument
593 if (test_and_clear_bit(ATH11K_PCI_ASPM_RESTORE, &ab_pci->flags)) in ath11k_pci_aspm_restore()
594 pcie_capability_write_word(ab_pci->pdev, PCI_EXP_LNKCTL, in ath11k_pci_aspm_restore()
595 ab_pci->link_ctl); in ath11k_pci_aspm_restore()
600 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_power_up() local
603 ab_pci->register_window = 0; in ath11k_pci_power_up()
605 ath11k_pci_sw_reset(ab_pci->ab, true); in ath11k_pci_power_up()
610 ath11k_pci_aspm_disable(ab_pci); in ath11k_pci_power_up()
612 ath11k_pci_msi_enable(ab_pci); in ath11k_pci_power_up()
614 ret = ath11k_mhi_start(ab_pci); in ath11k_pci_power_up()
621 ath11k_pci_select_static_window(ab_pci); in ath11k_pci_power_up()
628 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_power_down() local
631 ath11k_pci_aspm_restore(ab_pci); in ath11k_pci_power_down()
633 ath11k_pci_force_wake(ab_pci->ab); in ath11k_pci_power_down()
635 ath11k_pci_msi_disable(ab_pci); in ath11k_pci_power_down()
637 ath11k_mhi_stop(ab_pci); in ath11k_pci_power_down()
639 ath11k_pci_sw_reset(ab_pci->ab, false); in ath11k_pci_power_down()
668 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_start() local
674 ath11k_pci_aspm_restore(ab_pci); in ath11k_pci_start()
717 static int ath11k_pci_set_irq_affinity_hint(struct ath11k_pci *ab_pci, in ath11k_pci_set_irq_affinity_hint() argument
720 if (test_bit(ATH11K_FLAG_MULTI_MSI_VECTORS, &ab_pci->ab->dev_flags)) in ath11k_pci_set_irq_affinity_hint()
723 return irq_set_affinity_hint(ab_pci->pdev->irq, m); in ath11k_pci_set_irq_affinity_hint()
730 struct ath11k_pci *ab_pci; in ath11k_pci_probe() local
735 ab = ath11k_core_alloc(&pdev->dev, sizeof(*ab_pci), ATH11K_BUS_PCI); in ath11k_pci_probe()
744 ab_pci = ath11k_pci_priv(ab); in ath11k_pci_probe()
745 ab_pci->dev_id = pci_dev->device; in ath11k_pci_probe()
746 ab_pci->ab = ab; in ath11k_pci_probe()
747 ab_pci->pdev = pdev; in ath11k_pci_probe()
750 spin_lock_init(&ab_pci->window_lock); in ath11k_pci_probe()
760 ret = ath11k_pci_claim(ab_pci, pdev); in ath11k_pci_probe()
844 ret = ath11k_pci_alloc_msi(ab_pci); in ath11k_pci_probe()
854 ret = ath11k_mhi_register(ab_pci); in ath11k_pci_probe()
878 ret = ath11k_pci_set_irq_affinity_hint(ab_pci, cpumask_of(0)); in ath11k_pci_probe()
889 ret = ath11k_pci_config_msi_data(ab_pci); in ath11k_pci_probe()
903 ath11k_pci_set_irq_affinity_hint(ab_pci, NULL); in ath11k_pci_probe()
915 ath11k_mhi_unregister(ab_pci); in ath11k_pci_probe()
918 ath11k_pci_free_msi(ab_pci); in ath11k_pci_probe()
921 ath11k_pci_free_region(ab_pci); in ath11k_pci_probe()
932 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_remove() local
934 ath11k_pci_set_irq_affinity_hint(ab_pci, NULL); in ath11k_pci_remove()
948 ath11k_mhi_unregister(ab_pci); in ath11k_pci_remove()
951 ath11k_pci_free_msi(ab_pci); in ath11k_pci_remove()
952 ath11k_pci_free_region(ab_pci); in ath11k_pci_remove()
962 struct ath11k_pci *ab_pci = ath11k_pci_priv(ab); in ath11k_pci_shutdown() local
964 ath11k_pci_set_irq_affinity_hint(ab_pci, NULL); in ath11k_pci_shutdown()