ath9k: allow disabling bands via platform data
authorFelix Fietkau <nbd@openwrt.org>
Sat, 25 Oct 2014 15:19:34 +0000 (17:19 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 27 Oct 2014 18:16:19 +0000 (14:16 -0400)
Some devices have multiple bands enables in the EEPROM data, even though
they are only calibrated for one. Allow platform data to disable
unsupported bands.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/ath9k/hw.c
drivers/net/wireless/ath/ath9k/hw.h
drivers/net/wireless/ath/ath9k/init.c
include/linux/ath9k_platform.h

index 85a78176b80964a8f3b31f7997ec35eb380182c6..47f410ed7cd4916d5c4a0d3c62593bea190be3e5 100644 (file)
@@ -2344,17 +2344,25 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
        }
 
        eeval = ah->eep_ops->get_eeprom(ah, EEP_OP_MODE);
-       if ((eeval & (AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A)) == 0) {
-               ath_err(common,
-                       "no band has been marked as supported in EEPROM\n");
-               return -EINVAL;
+
+       if (eeval & AR5416_OPFLAGS_11A) {
+               if (ah->disable_5ghz)
+                       ath_warn(common, "disabling 5GHz band\n");
+               else
+                       pCap->hw_caps |= ATH9K_HW_CAP_5GHZ;
        }
 
-       if (eeval & AR5416_OPFLAGS_11A)
-               pCap->hw_caps |= ATH9K_HW_CAP_5GHZ;
+       if (eeval & AR5416_OPFLAGS_11G) {
+               if (ah->disable_2ghz)
+                       ath_warn(common, "disabling 2GHz band\n");
+               else
+                       pCap->hw_caps |= ATH9K_HW_CAP_2GHZ;
+       }
 
-       if (eeval & AR5416_OPFLAGS_11G)
-               pCap->hw_caps |= ATH9K_HW_CAP_2GHZ;
+       if ((pCap->hw_caps & (ATH9K_HW_CAP_2GHZ | ATH9K_HW_CAP_5GHZ)) == 0) {
+               ath_err(common, "both bands are disabled\n");
+               return -EINVAL;
+       }
 
        if (AR_SREV_9485(ah) ||
            AR_SREV_9285(ah) ||
index c6dba9b4afdf8157fb0f79b020f0d51560a7333d..e49721e85f6a17879d68ae6c03075bcaf1847cbc 100644 (file)
@@ -930,6 +930,8 @@ struct ath_hw {
        bool is_clk_25mhz;
        int (*get_mac_revision)(void);
        int (*external_reset)(void);
+       bool disable_2ghz;
+       bool disable_5ghz;
 
        const struct firmware *eeprom_blob;
 
index 5d9c711b6aa052dddc05273abc915f497f3b2573..2294109f79e9bfb96f02a66b37000638246d11b9 100644 (file)
@@ -531,6 +531,8 @@ static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
                ah->is_clk_25mhz = pdata->is_clk_25mhz;
                ah->get_mac_revision = pdata->get_mac_revision;
                ah->external_reset = pdata->external_reset;
+               ah->disable_2ghz = pdata->disable_2ghz;
+               ah->disable_5ghz = pdata->disable_5ghz;
                if (!pdata->endian_check)
                        ah->ah_flags |= AH_NO_EEP_SWAP;
        }
index 43501657bce9a8288f6941cc6f1829b67d04f86d..33eb274cd0e6b61be2b000e3e30c82f2ea6c7f1e 100644 (file)
@@ -34,6 +34,8 @@ struct ath9k_platform_data {
        bool endian_check;
        bool is_clk_25mhz;
        bool tx_gain_buffalo;
+       bool disable_2ghz;
+       bool disable_5ghz;
 
        int (*get_mac_revision)(void);
        int (*external_reset)(void);