ath9k: Define bus agnostic bluetooth coex prep helper
authorLuis R. Rodriguez <lrodriguez@atheros.com>
Thu, 10 Sep 2009 19:12:23 +0000 (12:12 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 7 Oct 2009 20:39:27 +0000 (16:39 -0400)
We disable ASPM when enabling bluetooth coexistance. Disabling
ASPM is a bus specific operation. In the future other buses may
support bluetooth coexistance, an example is USB. To this end
move the current routine which disables ASPM into pci.c, and declare
it the PCI bt_coex_prep() helper. Additionally, since ASPM is
a PCI-Express primitive ensure we don't ever try to muck with ASPM
registers on non PCI-express devices.

This also cleans up hw.c to not include bus specific headers or
utilities.

Cc: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Cc: Stephen Chen <stephen.chen@atheros.com>
Cc: Zhifeng Cai <zhifeng.cai@atheros.com>
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/ath9k.h
drivers/net/wireless/ath/ath9k/hw.c
drivers/net/wireless/ath/ath9k/hw.h
drivers/net/wireless/ath/ath9k/main.c
drivers/net/wireless/ath/ath9k/pci.c

index 0c64c801a150a6555f6157b7e7faba074b444c6b..0962505430e2ddf2c29a0e1abcc420fddb126cb6 100644 (file)
@@ -545,6 +545,7 @@ struct ath_bus_ops {
        void            (*read_cachesize)(struct ath_softc *sc, int *csz);
        void            (*cleanup)(struct ath_softc *sc);
        bool            (*eeprom_read)(struct ath_hw *ah, u32 off, u16 *data);
+       void            (*bt_coex_prep)(struct ath_softc *sc);
 };
 
 struct ath_wiphy;
index 4e14c307b3daa243b1317c89d6da6145c247ab30..a3b1ce32cfcb239ee74df5ff80b9afe1c6430a42 100644 (file)
@@ -16,7 +16,6 @@
 
 #include <linux/io.h>
 #include <asm/unaligned.h>
-#include <linux/pci.h>
 
 #include "hw.h"
 #include "ath9k.h"
@@ -4294,16 +4293,3 @@ void ath_gen_timer_isr(struct ath_hw *ah)
                timer->trigger(timer->arg);
        }
 }
-
-/*
- * Primitive to disable ASPM
- */
-void ath_pcie_aspm_disable(struct ath_softc *sc)
-{
-       struct pci_dev *pdev = to_pci_dev(sc->dev);
-       u8 aspm;
-
-       pci_read_config_byte(pdev, ATH_PCIE_CAP_LINK_CTRL, &aspm);
-       aspm &= ~(ATH_PCIE_CAP_LINK_L0S | ATH_PCIE_CAP_LINK_L1);
-       pci_write_config_byte(pdev, ATH_PCIE_CAP_LINK_CTRL, aspm);
-}
index f1dc98927c4a21569b82d622d1b7ac84cb81614e..f460a06b86ac161f60bddb07f04f3989575006ea 100644 (file)
@@ -679,5 +679,4 @@ u32 ath9k_hw_gettsf32(struct ath_hw *ah);
 #define ATH_PCIE_CAP_LINK_L0S  1
 #define ATH_PCIE_CAP_LINK_L1   2
 
-void ath_pcie_aspm_disable(struct ath_softc *sc);
 #endif
index dc8d47e4d0f54844691fde6f032c6338709621d6..27ab378ae535b23b15d606700f999d48d5ad7fd2 100644 (file)
@@ -2241,7 +2241,8 @@ static int ath9k_start(struct ieee80211_hw *hw)
                                           AR_STOMP_LOW_WLAN_WGHT);
                ath9k_hw_btcoex_enable(ah);
 
-               ath_pcie_aspm_disable(sc);
+               if (sc->bus_ops->bt_coex_prep)
+                       sc->bus_ops->bt_coex_prep(sc);
                if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
                        ath9k_btcoex_timer_resume(sc);
        }
index 903dd8ad9d430820a67668754d20c4abd48bbf41..f59d22491cedd51b876bef85474a45208d7f3ea8 100644 (file)
@@ -75,10 +75,27 @@ static bool ath_pci_eeprom_read(struct ath_hw *ah, u32 off, u16 *data)
        return true;
 }
 
+/*
+ * Bluetooth coexistance requires disabling ASPM.
+ */
+static void ath_pci_bt_coex_prep(struct ath_softc *sc)
+{
+       struct pci_dev *pdev = to_pci_dev(sc->dev);
+       u8 aspm;
+
+       if (!pdev->is_pcie)
+               return;
+
+       pci_read_config_byte(pdev, ATH_PCIE_CAP_LINK_CTRL, &aspm);
+       aspm &= ~(ATH_PCIE_CAP_LINK_L0S | ATH_PCIE_CAP_LINK_L1);
+       pci_write_config_byte(pdev, ATH_PCIE_CAP_LINK_CTRL, aspm);
+}
+
 static struct ath_bus_ops ath_pci_bus_ops = {
        .read_cachesize = ath_pci_read_cachesize,
        .cleanup = ath_pci_cleanup,
        .eeprom_read = ath_pci_eeprom_read,
+       .bt_coex_prep = ath_pci_bt_coex_prep,
 };
 
 static int ath_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)