18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (c) 2008-2009 Atheros Communications Inc. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any 58c2ecf20Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above 68c2ecf20Sopenharmony_ci * copyright notice and this permission notice appear in all copies. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 98c2ecf20Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 108c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 118c2ecf20Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 128c2ecf20Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 138c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 148c2ecf20Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 158c2ecf20Sopenharmony_ci */ 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#include <linux/nl80211.h> 208c2ecf20Sopenharmony_ci#include <linux/pci.h> 218c2ecf20Sopenharmony_ci#include <linux/etherdevice.h> 228c2ecf20Sopenharmony_ci#include <linux/module.h> 238c2ecf20Sopenharmony_ci#include "../ath.h" 248c2ecf20Sopenharmony_ci#include "ath5k.h" 258c2ecf20Sopenharmony_ci#include "debug.h" 268c2ecf20Sopenharmony_ci#include "base.h" 278c2ecf20Sopenharmony_ci#include "reg.h" 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci/* Known PCI ids */ 308c2ecf20Sopenharmony_cistatic const struct pci_device_id ath5k_pci_id_table[] = { 318c2ecf20Sopenharmony_ci { PCI_VDEVICE(ATHEROS, 0x0207) }, /* 5210 early */ 328c2ecf20Sopenharmony_ci { PCI_VDEVICE(ATHEROS, 0x0007) }, /* 5210 */ 338c2ecf20Sopenharmony_ci { PCI_VDEVICE(ATHEROS, 0x0011) }, /* 5311 - this is on AHB bus !*/ 348c2ecf20Sopenharmony_ci { PCI_VDEVICE(ATHEROS, 0x0012) }, /* 5211 */ 358c2ecf20Sopenharmony_ci { PCI_VDEVICE(ATHEROS, 0x0013) }, /* 5212 */ 368c2ecf20Sopenharmony_ci { PCI_VDEVICE(3COM_2, 0x0013) }, /* 3com 5212 */ 378c2ecf20Sopenharmony_ci { PCI_VDEVICE(3COM, 0x0013) }, /* 3com 3CRDAG675 5212 */ 388c2ecf20Sopenharmony_ci { PCI_VDEVICE(ATHEROS, 0x1014) }, /* IBM minipci 5212 */ 398c2ecf20Sopenharmony_ci { PCI_VDEVICE(ATHEROS, 0x0014) }, /* 5212 compatible */ 408c2ecf20Sopenharmony_ci { PCI_VDEVICE(ATHEROS, 0x0015) }, /* 5212 compatible */ 418c2ecf20Sopenharmony_ci { PCI_VDEVICE(ATHEROS, 0x0016) }, /* 5212 compatible */ 428c2ecf20Sopenharmony_ci { PCI_VDEVICE(ATHEROS, 0x0017) }, /* 5212 compatible */ 438c2ecf20Sopenharmony_ci { PCI_VDEVICE(ATHEROS, 0x0018) }, /* 5212 compatible */ 448c2ecf20Sopenharmony_ci { PCI_VDEVICE(ATHEROS, 0x0019) }, /* 5212 compatible */ 458c2ecf20Sopenharmony_ci { PCI_VDEVICE(ATHEROS, 0x001a) }, /* 2413 Griffin-lite */ 468c2ecf20Sopenharmony_ci { PCI_VDEVICE(ATHEROS, 0x001b) }, /* 5413 Eagle */ 478c2ecf20Sopenharmony_ci { PCI_VDEVICE(ATHEROS, 0x001c) }, /* PCI-E cards */ 488c2ecf20Sopenharmony_ci { PCI_VDEVICE(ATHEROS, 0x001d) }, /* 2417 Nala */ 498c2ecf20Sopenharmony_ci { PCI_VDEVICE(ATHEROS, 0xff1b) }, /* AR5BXB63 */ 508c2ecf20Sopenharmony_ci { 0 } 518c2ecf20Sopenharmony_ci}; 528c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(pci, ath5k_pci_id_table); 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci/* return bus cachesize in 4B word units */ 558c2ecf20Sopenharmony_cistatic void ath5k_pci_read_cachesize(struct ath_common *common, int *csz) 568c2ecf20Sopenharmony_ci{ 578c2ecf20Sopenharmony_ci struct ath5k_hw *ah = (struct ath5k_hw *) common->priv; 588c2ecf20Sopenharmony_ci u8 u8tmp; 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_ci pci_read_config_byte(ah->pdev, PCI_CACHE_LINE_SIZE, &u8tmp); 618c2ecf20Sopenharmony_ci *csz = (int)u8tmp; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci /* 648c2ecf20Sopenharmony_ci * This check was put in to avoid "unpleasant" consequences if 658c2ecf20Sopenharmony_ci * the bootrom has not fully initialized all PCI devices. 668c2ecf20Sopenharmony_ci * Sometimes the cache line size register is not set 678c2ecf20Sopenharmony_ci */ 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci if (*csz == 0) 708c2ecf20Sopenharmony_ci *csz = L1_CACHE_BYTES >> 2; /* Use the default size */ 718c2ecf20Sopenharmony_ci} 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci/* 748c2ecf20Sopenharmony_ci * Read from eeprom 758c2ecf20Sopenharmony_ci */ 768c2ecf20Sopenharmony_cistatic bool 778c2ecf20Sopenharmony_ciath5k_pci_eeprom_read(struct ath_common *common, u32 offset, u16 *data) 788c2ecf20Sopenharmony_ci{ 798c2ecf20Sopenharmony_ci struct ath5k_hw *ah = (struct ath5k_hw *) common->ah; 808c2ecf20Sopenharmony_ci u32 status, timeout; 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci /* 838c2ecf20Sopenharmony_ci * Initialize EEPROM access 848c2ecf20Sopenharmony_ci */ 858c2ecf20Sopenharmony_ci if (ah->ah_version == AR5K_AR5210) { 868c2ecf20Sopenharmony_ci AR5K_REG_ENABLE_BITS(ah, AR5K_PCICFG, AR5K_PCICFG_EEAE); 878c2ecf20Sopenharmony_ci (void)ath5k_hw_reg_read(ah, AR5K_EEPROM_BASE + (4 * offset)); 888c2ecf20Sopenharmony_ci } else { 898c2ecf20Sopenharmony_ci ath5k_hw_reg_write(ah, offset, AR5K_EEPROM_BASE); 908c2ecf20Sopenharmony_ci AR5K_REG_ENABLE_BITS(ah, AR5K_EEPROM_CMD, 918c2ecf20Sopenharmony_ci AR5K_EEPROM_CMD_READ); 928c2ecf20Sopenharmony_ci } 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci for (timeout = AR5K_TUNE_REGISTER_TIMEOUT; timeout > 0; timeout--) { 958c2ecf20Sopenharmony_ci status = ath5k_hw_reg_read(ah, AR5K_EEPROM_STATUS); 968c2ecf20Sopenharmony_ci if (status & AR5K_EEPROM_STAT_RDDONE) { 978c2ecf20Sopenharmony_ci if (status & AR5K_EEPROM_STAT_RDERR) 988c2ecf20Sopenharmony_ci return false; 998c2ecf20Sopenharmony_ci *data = (u16)(ath5k_hw_reg_read(ah, AR5K_EEPROM_DATA) & 1008c2ecf20Sopenharmony_ci 0xffff); 1018c2ecf20Sopenharmony_ci return true; 1028c2ecf20Sopenharmony_ci } 1038c2ecf20Sopenharmony_ci usleep_range(15, 20); 1048c2ecf20Sopenharmony_ci } 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci return false; 1078c2ecf20Sopenharmony_ci} 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ciint ath5k_hw_read_srev(struct ath5k_hw *ah) 1108c2ecf20Sopenharmony_ci{ 1118c2ecf20Sopenharmony_ci ah->ah_mac_srev = ath5k_hw_reg_read(ah, AR5K_SREV); 1128c2ecf20Sopenharmony_ci return 0; 1138c2ecf20Sopenharmony_ci} 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ci/* 1168c2ecf20Sopenharmony_ci * Read the MAC address from eeprom or platform_data 1178c2ecf20Sopenharmony_ci */ 1188c2ecf20Sopenharmony_cistatic int ath5k_pci_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac) 1198c2ecf20Sopenharmony_ci{ 1208c2ecf20Sopenharmony_ci u8 mac_d[ETH_ALEN] = {}; 1218c2ecf20Sopenharmony_ci u32 total, offset; 1228c2ecf20Sopenharmony_ci u16 data; 1238c2ecf20Sopenharmony_ci int octet; 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci AR5K_EEPROM_READ(0x20, data); 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci for (offset = 0x1f, octet = 0, total = 0; offset >= 0x1d; offset--) { 1288c2ecf20Sopenharmony_ci AR5K_EEPROM_READ(offset, data); 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_ci total += data; 1318c2ecf20Sopenharmony_ci mac_d[octet + 1] = data & 0xff; 1328c2ecf20Sopenharmony_ci mac_d[octet] = data >> 8; 1338c2ecf20Sopenharmony_ci octet += 2; 1348c2ecf20Sopenharmony_ci } 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci if (!total || total == 3 * 0xffff) 1378c2ecf20Sopenharmony_ci return -EINVAL; 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci memcpy(mac, mac_d, ETH_ALEN); 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci return 0; 1428c2ecf20Sopenharmony_ci} 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci/* Common ath_bus_opts structure */ 1468c2ecf20Sopenharmony_cistatic const struct ath_bus_ops ath_pci_bus_ops = { 1478c2ecf20Sopenharmony_ci .ath_bus_type = ATH_PCI, 1488c2ecf20Sopenharmony_ci .read_cachesize = ath5k_pci_read_cachesize, 1498c2ecf20Sopenharmony_ci .eeprom_read = ath5k_pci_eeprom_read, 1508c2ecf20Sopenharmony_ci .eeprom_read_mac = ath5k_pci_eeprom_read_mac, 1518c2ecf20Sopenharmony_ci}; 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci/********************\ 1548c2ecf20Sopenharmony_ci* PCI Initialization * 1558c2ecf20Sopenharmony_ci\********************/ 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_cistatic int 1588c2ecf20Sopenharmony_ciath5k_pci_probe(struct pci_dev *pdev, 1598c2ecf20Sopenharmony_ci const struct pci_device_id *id) 1608c2ecf20Sopenharmony_ci{ 1618c2ecf20Sopenharmony_ci void __iomem *mem; 1628c2ecf20Sopenharmony_ci struct ath5k_hw *ah; 1638c2ecf20Sopenharmony_ci struct ieee80211_hw *hw; 1648c2ecf20Sopenharmony_ci int ret; 1658c2ecf20Sopenharmony_ci u8 csz; 1668c2ecf20Sopenharmony_ci 1678c2ecf20Sopenharmony_ci /* 1688c2ecf20Sopenharmony_ci * L0s needs to be disabled on all ath5k cards. 1698c2ecf20Sopenharmony_ci * 1708c2ecf20Sopenharmony_ci * For distributions shipping with CONFIG_PCIEASPM (this will be enabled 1718c2ecf20Sopenharmony_ci * by default in the future in 2.6.36) this will also mean both L1 and 1728c2ecf20Sopenharmony_ci * L0s will be disabled when a pre 1.1 PCIe device is detected. We do 1738c2ecf20Sopenharmony_ci * know L1 works correctly even for all ath5k pre 1.1 PCIe devices 1748c2ecf20Sopenharmony_ci * though but cannot currently undue the effect of a blacklist, for 1758c2ecf20Sopenharmony_ci * details you can read pcie_aspm_sanity_check() and see how it adjusts 1768c2ecf20Sopenharmony_ci * the device link capability. 1778c2ecf20Sopenharmony_ci * 1788c2ecf20Sopenharmony_ci * It may be possible in the future to implement some PCI API to allow 1798c2ecf20Sopenharmony_ci * drivers to override blacklists for pre 1.1 PCIe but for now it is 1808c2ecf20Sopenharmony_ci * best to accept that both L0s and L1 will be disabled completely for 1818c2ecf20Sopenharmony_ci * distributions shipping with CONFIG_PCIEASPM rather than having this 1828c2ecf20Sopenharmony_ci * issue present. Motivation for adding this new API will be to help 1838c2ecf20Sopenharmony_ci * with power consumption for some of these devices. 1848c2ecf20Sopenharmony_ci */ 1858c2ecf20Sopenharmony_ci pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S); 1868c2ecf20Sopenharmony_ci 1878c2ecf20Sopenharmony_ci ret = pci_enable_device(pdev); 1888c2ecf20Sopenharmony_ci if (ret) { 1898c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "can't enable device\n"); 1908c2ecf20Sopenharmony_ci goto err; 1918c2ecf20Sopenharmony_ci } 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ci /* XXX 32-bit addressing only */ 1948c2ecf20Sopenharmony_ci ret = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 1958c2ecf20Sopenharmony_ci if (ret) { 1968c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "32-bit DMA not available\n"); 1978c2ecf20Sopenharmony_ci goto err_dis; 1988c2ecf20Sopenharmony_ci } 1998c2ecf20Sopenharmony_ci 2008c2ecf20Sopenharmony_ci /* 2018c2ecf20Sopenharmony_ci * Cache line size is used to size and align various 2028c2ecf20Sopenharmony_ci * structures used to communicate with the hardware. 2038c2ecf20Sopenharmony_ci */ 2048c2ecf20Sopenharmony_ci pci_read_config_byte(pdev, PCI_CACHE_LINE_SIZE, &csz); 2058c2ecf20Sopenharmony_ci if (csz == 0) { 2068c2ecf20Sopenharmony_ci /* 2078c2ecf20Sopenharmony_ci * Linux 2.4.18 (at least) writes the cache line size 2088c2ecf20Sopenharmony_ci * register as a 16-bit wide register which is wrong. 2098c2ecf20Sopenharmony_ci * We must have this setup properly for rx buffer 2108c2ecf20Sopenharmony_ci * DMA to work so force a reasonable value here if it 2118c2ecf20Sopenharmony_ci * comes up zero. 2128c2ecf20Sopenharmony_ci */ 2138c2ecf20Sopenharmony_ci csz = L1_CACHE_BYTES >> 2; 2148c2ecf20Sopenharmony_ci pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, csz); 2158c2ecf20Sopenharmony_ci } 2168c2ecf20Sopenharmony_ci /* 2178c2ecf20Sopenharmony_ci * The default setting of latency timer yields poor results, 2188c2ecf20Sopenharmony_ci * set it to the value used by other systems. It may be worth 2198c2ecf20Sopenharmony_ci * tweaking this setting more. 2208c2ecf20Sopenharmony_ci */ 2218c2ecf20Sopenharmony_ci pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 0xa8); 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci /* Enable bus mastering */ 2248c2ecf20Sopenharmony_ci pci_set_master(pdev); 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci /* 2278c2ecf20Sopenharmony_ci * Disable the RETRY_TIMEOUT register (0x41) to keep 2288c2ecf20Sopenharmony_ci * PCI Tx retries from interfering with C3 CPU state. 2298c2ecf20Sopenharmony_ci */ 2308c2ecf20Sopenharmony_ci pci_write_config_byte(pdev, 0x41, 0); 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci ret = pci_request_region(pdev, 0, "ath5k"); 2338c2ecf20Sopenharmony_ci if (ret) { 2348c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "cannot reserve PCI memory region\n"); 2358c2ecf20Sopenharmony_ci goto err_dis; 2368c2ecf20Sopenharmony_ci } 2378c2ecf20Sopenharmony_ci 2388c2ecf20Sopenharmony_ci mem = pci_iomap(pdev, 0, 0); 2398c2ecf20Sopenharmony_ci if (!mem) { 2408c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "cannot remap PCI memory region\n"); 2418c2ecf20Sopenharmony_ci ret = -EIO; 2428c2ecf20Sopenharmony_ci goto err_reg; 2438c2ecf20Sopenharmony_ci } 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci /* 2468c2ecf20Sopenharmony_ci * Allocate hw (mac80211 main struct) 2478c2ecf20Sopenharmony_ci * and hw->priv (driver private data) 2488c2ecf20Sopenharmony_ci */ 2498c2ecf20Sopenharmony_ci hw = ieee80211_alloc_hw(sizeof(*ah), &ath5k_hw_ops); 2508c2ecf20Sopenharmony_ci if (hw == NULL) { 2518c2ecf20Sopenharmony_ci dev_err(&pdev->dev, "cannot allocate ieee80211_hw\n"); 2528c2ecf20Sopenharmony_ci ret = -ENOMEM; 2538c2ecf20Sopenharmony_ci goto err_map; 2548c2ecf20Sopenharmony_ci } 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_ci dev_info(&pdev->dev, "registered as '%s'\n", wiphy_name(hw->wiphy)); 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci ah = hw->priv; 2598c2ecf20Sopenharmony_ci ah->hw = hw; 2608c2ecf20Sopenharmony_ci ah->pdev = pdev; 2618c2ecf20Sopenharmony_ci ah->dev = &pdev->dev; 2628c2ecf20Sopenharmony_ci ah->irq = pdev->irq; 2638c2ecf20Sopenharmony_ci ah->devid = id->device; 2648c2ecf20Sopenharmony_ci ah->iobase = mem; /* So we can unmap it on detach */ 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci /* Initialize */ 2678c2ecf20Sopenharmony_ci ret = ath5k_init_ah(ah, &ath_pci_bus_ops); 2688c2ecf20Sopenharmony_ci if (ret) 2698c2ecf20Sopenharmony_ci goto err_free; 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci /* Set private data */ 2728c2ecf20Sopenharmony_ci pci_set_drvdata(pdev, hw); 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ci return 0; 2758c2ecf20Sopenharmony_cierr_free: 2768c2ecf20Sopenharmony_ci ieee80211_free_hw(hw); 2778c2ecf20Sopenharmony_cierr_map: 2788c2ecf20Sopenharmony_ci pci_iounmap(pdev, mem); 2798c2ecf20Sopenharmony_cierr_reg: 2808c2ecf20Sopenharmony_ci pci_release_region(pdev, 0); 2818c2ecf20Sopenharmony_cierr_dis: 2828c2ecf20Sopenharmony_ci pci_disable_device(pdev); 2838c2ecf20Sopenharmony_cierr: 2848c2ecf20Sopenharmony_ci return ret; 2858c2ecf20Sopenharmony_ci} 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_cistatic void 2888c2ecf20Sopenharmony_ciath5k_pci_remove(struct pci_dev *pdev) 2898c2ecf20Sopenharmony_ci{ 2908c2ecf20Sopenharmony_ci struct ieee80211_hw *hw = pci_get_drvdata(pdev); 2918c2ecf20Sopenharmony_ci struct ath5k_hw *ah = hw->priv; 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci ath5k_deinit_ah(ah); 2948c2ecf20Sopenharmony_ci pci_iounmap(pdev, ah->iobase); 2958c2ecf20Sopenharmony_ci pci_release_region(pdev, 0); 2968c2ecf20Sopenharmony_ci pci_disable_device(pdev); 2978c2ecf20Sopenharmony_ci ieee80211_free_hw(hw); 2988c2ecf20Sopenharmony_ci} 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci#ifdef CONFIG_PM_SLEEP 3018c2ecf20Sopenharmony_cistatic int ath5k_pci_suspend(struct device *dev) 3028c2ecf20Sopenharmony_ci{ 3038c2ecf20Sopenharmony_ci struct ieee80211_hw *hw = dev_get_drvdata(dev); 3048c2ecf20Sopenharmony_ci struct ath5k_hw *ah = hw->priv; 3058c2ecf20Sopenharmony_ci 3068c2ecf20Sopenharmony_ci ath5k_led_off(ah); 3078c2ecf20Sopenharmony_ci return 0; 3088c2ecf20Sopenharmony_ci} 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_cistatic int ath5k_pci_resume(struct device *dev) 3118c2ecf20Sopenharmony_ci{ 3128c2ecf20Sopenharmony_ci struct pci_dev *pdev = to_pci_dev(dev); 3138c2ecf20Sopenharmony_ci struct ieee80211_hw *hw = pci_get_drvdata(pdev); 3148c2ecf20Sopenharmony_ci struct ath5k_hw *ah = hw->priv; 3158c2ecf20Sopenharmony_ci 3168c2ecf20Sopenharmony_ci /* 3178c2ecf20Sopenharmony_ci * Suspend/Resume resets the PCI configuration space, so we have to 3188c2ecf20Sopenharmony_ci * re-disable the RETRY_TIMEOUT register (0x41) to keep 3198c2ecf20Sopenharmony_ci * PCI Tx retries from interfering with C3 CPU state 3208c2ecf20Sopenharmony_ci */ 3218c2ecf20Sopenharmony_ci pci_write_config_byte(pdev, 0x41, 0); 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci ath5k_led_enable(ah); 3248c2ecf20Sopenharmony_ci return 0; 3258c2ecf20Sopenharmony_ci} 3268c2ecf20Sopenharmony_ci 3278c2ecf20Sopenharmony_cistatic SIMPLE_DEV_PM_OPS(ath5k_pm_ops, ath5k_pci_suspend, ath5k_pci_resume); 3288c2ecf20Sopenharmony_ci#define ATH5K_PM_OPS (&ath5k_pm_ops) 3298c2ecf20Sopenharmony_ci#else 3308c2ecf20Sopenharmony_ci#define ATH5K_PM_OPS NULL 3318c2ecf20Sopenharmony_ci#endif /* CONFIG_PM_SLEEP */ 3328c2ecf20Sopenharmony_ci 3338c2ecf20Sopenharmony_cistatic struct pci_driver ath5k_pci_driver = { 3348c2ecf20Sopenharmony_ci .name = KBUILD_MODNAME, 3358c2ecf20Sopenharmony_ci .id_table = ath5k_pci_id_table, 3368c2ecf20Sopenharmony_ci .probe = ath5k_pci_probe, 3378c2ecf20Sopenharmony_ci .remove = ath5k_pci_remove, 3388c2ecf20Sopenharmony_ci .driver.pm = ATH5K_PM_OPS, 3398c2ecf20Sopenharmony_ci}; 3408c2ecf20Sopenharmony_ci 3418c2ecf20Sopenharmony_cimodule_pci_driver(ath5k_pci_driver); 342