17 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20 #include <linux/pci.h>
23 #include <linux/module.h>
73 "%s: eeprom read failed, offset %08x is out of range\n",
77 *data =
pdata->eeprom_data[off];
99 static void ath_pci_extn_synch_enable(
struct ath_common *common)
105 pci_read_config_byte(pdev, sc->
sc_ah->caps.pcie_lcr_offset, &lnkctl);
107 pci_write_config_byte(pdev, sc->
sc_ah->caps.pcie_lcr_offset, lnkctl);
111 static void ath_pci_aspm_init(
struct ath_common *common)
122 parent =
pdev->bus->self;
139 ath_info(common,
"Disabling ASPM since BTCOEX is enabled\n");
147 ath9k_hw_configpcipowersave(ah,
false);
148 ath_info(common,
"ASPM enabled: 0x%x\n", aspm);
152 static const struct ath_bus_ops ath_pci_bus_ops = {
154 .read_cachesize = ath_pci_read_cachesize,
155 .eeprom_read = ath_pci_eeprom_read,
156 .extn_synch_en = ath_pci_extn_synch_enable,
157 .aspm_init = ath_pci_aspm_init,
175 pr_err(
"32-bit DMA not available\n");
179 ret = pci_set_consistent_dma_mask(pdev,
DMA_BIT_MASK(32));
181 pr_err(
"32-bit DMA consistent DMA enable failed\n");
214 pci_read_config_dword(pdev, 0x40, &val);
215 if ((val & 0x0000ff00) != 0)
216 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
220 dev_err(&pdev->
dev,
"PCI memory region reserve error\n");
225 mem = pci_iomap(pdev, 0, 0);
227 pr_err(
"PCI memory map error\n") ;
234 dev_err(&pdev->
dev,
"No memory for ieee80211_hw\n");
239 SET_IEEE80211_DEV(hw, &pdev->
dev);
240 pci_set_drvdata(pdev, hw);
260 dev_err(&pdev->
dev,
"Failed to initialize device\n");
266 hw_name, (
unsigned long)mem, pdev->
irq);
285 static void ath_pci_remove(
struct pci_dev *pdev)
317 ath9k_stop_btcoex(sc);
324 static int ath_pci_resume(
struct device *device)
330 struct ath_common *common = ath9k_hw_common(ah);
338 pci_read_config_dword(pdev, 0x40, &val);
339 if ((val & 0x0000ff00) != 0)
340 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
342 ath_pci_aspm_init(common);
348 static const struct dev_pm_ops ath9k_pm_ops = {
350 .resume = ath_pci_resume,
351 .freeze = ath_pci_suspend,
352 .thaw = ath_pci_resume,
353 .poweroff = ath_pci_suspend,
354 .restore = ath_pci_resume,
357 #define ATH9K_PM_OPS (&ath9k_pm_ops)
361 #define ATH9K_PM_OPS NULL
370 .id_table = ath_pci_id_table,
371 .probe = ath_pci_probe,
372 .remove = ath_pci_remove,
378 return pci_register_driver(&ath_pci_driver);