|
16 | 16 |
|
17 | 17 | #include <linux/nl80211.h> |
18 | 18 | #include <linux/pci.h> |
| 19 | +#include <linux/pci-aspm.h> |
19 | 20 | #include <linux/ath9k_platform.h> |
20 | 21 | #include "ath9k.h" |
21 | 22 |
|
@@ -115,12 +116,38 @@ static void ath_pci_extn_synch_enable(struct ath_common *common) |
115 | 116 | pci_write_config_byte(pdev, sc->sc_ah->caps.pcie_lcr_offset, lnkctl); |
116 | 117 | } |
117 | 118 |
|
| 119 | +static void ath_pci_aspm_init(struct ath_common *common) |
| 120 | +{ |
| 121 | + struct ath_softc *sc = (struct ath_softc *) common->priv; |
| 122 | + struct ath_hw *ah = sc->sc_ah; |
| 123 | + struct pci_dev *pdev = to_pci_dev(sc->dev); |
| 124 | + struct pci_dev *parent; |
| 125 | + int pos; |
| 126 | + u8 aspm; |
| 127 | + |
| 128 | + if (!pci_is_pcie(pdev)) |
| 129 | + return; |
| 130 | + |
| 131 | + parent = pdev->bus->self; |
| 132 | + if (WARN_ON(!parent)) |
| 133 | + return; |
| 134 | + |
| 135 | + pos = pci_pcie_cap(parent); |
| 136 | + pci_read_config_byte(parent, pos + PCI_EXP_LNKCTL, &aspm); |
| 137 | + if (aspm & (PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1)) { |
| 138 | + ah->aspm_enabled = true; |
| 139 | + /* Initialize PCIe PM and SERDES registers. */ |
| 140 | + ath9k_hw_configpcipowersave(ah, 0, 0); |
| 141 | + } |
| 142 | +} |
| 143 | + |
118 | 144 | static const struct ath_bus_ops ath_pci_bus_ops = { |
119 | 145 | .ath_bus_type = ATH_PCI, |
120 | 146 | .read_cachesize = ath_pci_read_cachesize, |
121 | 147 | .eeprom_read = ath_pci_eeprom_read, |
122 | 148 | .bt_coex_prep = ath_pci_bt_coex_prep, |
123 | 149 | .extn_synch_en = ath_pci_extn_synch_enable, |
| 150 | + .aspm_init = ath_pci_aspm_init, |
124 | 151 | }; |
125 | 152 |
|
126 | 153 | static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) |
|
0 commit comments