]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/net/wireless/ath/ath9k/hw.c
Merge branch 'master' into tk71
[mv-sheeva.git] / drivers / net / wireless / ath / ath9k / hw.c
index 3384ca1645622e4d3307d957ff193198f6b7e888..9f01e50d5cda718e391f9582f71064f82c5f8733 100644 (file)
@@ -54,13 +54,6 @@ static void ath9k_hw_init_mode_regs(struct ath_hw *ah)
        ath9k_hw_private_ops(ah)->init_mode_regs(ah);
 }
 
-static bool ath9k_hw_macversion_supported(struct ath_hw *ah)
-{
-       struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
-
-       return priv_ops->macversion_supported(ah->hw_version.macVersion);
-}
-
 static u32 ath9k_hw_compute_pll_control(struct ath_hw *ah,
                                        struct ath9k_channel *chan)
 {
@@ -88,29 +81,32 @@ static void ath9k_hw_ani_cache_ini_regs(struct ath_hw *ah)
 /* Helper Functions */
 /********************/
 
-static u32 ath9k_hw_mac_clks(struct ath_hw *ah, u32 usecs)
+static void ath9k_hw_set_clockrate(struct ath_hw *ah)
 {
        struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
+       struct ath_common *common = ath9k_hw_common(ah);
+       unsigned int clockrate;
 
        if (!ah->curchan) /* should really check for CCK instead */
-               return usecs *ATH9K_CLOCK_RATE_CCK;
-       if (conf->channel->band == IEEE80211_BAND_2GHZ)
-               return usecs *ATH9K_CLOCK_RATE_2GHZ_OFDM;
-
-       if (ah->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK)
-               return usecs * ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM;
+               clockrate = ATH9K_CLOCK_RATE_CCK;
+       else if (conf->channel->band == IEEE80211_BAND_2GHZ)
+               clockrate = ATH9K_CLOCK_RATE_2GHZ_OFDM;
+       else if (ah->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK)
+               clockrate = ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM;
        else
-               return usecs * ATH9K_CLOCK_RATE_5GHZ_OFDM;
+               clockrate = ATH9K_CLOCK_RATE_5GHZ_OFDM;
+
+       if (conf_is_ht40(conf))
+               clockrate *= 2;
+
+       common->clockrate = clockrate;
 }
 
 static u32 ath9k_hw_mac_to_clks(struct ath_hw *ah, u32 usecs)
 {
-       struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
+       struct ath_common *common = ath9k_hw_common(ah);
 
-       if (conf_is_ht40(conf))
-               return ath9k_hw_mac_clks(ah, usecs) * 2;
-       else
-               return ath9k_hw_mac_clks(ah, usecs);
+       return usecs * common->clockrate;
 }
 
 bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout)
@@ -126,9 +122,9 @@ bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout)
                udelay(AH_TIME_QUANTUM);
        }
 
-       ath_print(ath9k_hw_common(ah), ATH_DBG_ANY,
-                 "timeout (%d us) on reg 0x%x: 0x%08x & 0x%08x != 0x%08x\n",
-                 timeout, reg, REG_READ(ah, reg), mask, val);
+       ath_dbg(ath9k_hw_common(ah), ATH_DBG_ANY,
+               "timeout (%d us) on reg 0x%x: 0x%08x & 0x%08x != 0x%08x\n",
+               timeout, reg, REG_READ(ah, reg), mask, val);
 
        return false;
 }
@@ -208,8 +204,8 @@ u16 ath9k_hw_computetxtime(struct ath_hw *ah,
                }
                break;
        default:
-               ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
-                         "Unknown phy %u (rate ix %u)\n", phy, rateix);
+               ath_err(ath9k_hw_common(ah),
+                       "Unknown phy %u (rate ix %u)\n", phy, rateix);
                txTime = 0;
                break;
        }
@@ -281,11 +277,9 @@ static void ath9k_hw_read_revisions(struct ath_hw *ah)
 
 static void ath9k_hw_disablepcie(struct ath_hw *ah)
 {
-       if (AR_SREV_9100(ah))
+       if (!AR_SREV_5416(ah))
                return;
 
-       ENABLE_REGWRITE_BUFFER(ah);
-
        REG_WRITE(ah, AR_PCIE_SERDES, 0x9248fc00);
        REG_WRITE(ah, AR_PCIE_SERDES, 0x24924924);
        REG_WRITE(ah, AR_PCIE_SERDES, 0x28000029);
@@ -297,9 +291,6 @@ static void ath9k_hw_disablepcie(struct ath_hw *ah)
        REG_WRITE(ah, AR_PCIE_SERDES, 0x000e1007);
 
        REG_WRITE(ah, AR_PCIE_SERDES2, 0x00000000);
-
-       REGWRITE_BUFFER_FLUSH(ah);
-       DISABLE_REGWRITE_BUFFER(ah);
 }
 
 /* This should work for all families including legacy */
@@ -308,10 +299,9 @@ static bool ath9k_hw_chip_test(struct ath_hw *ah)
        struct ath_common *common = ath9k_hw_common(ah);
        u32 regAddr[2] = { AR_STA_ID0 };
        u32 regHold[2];
-       u32 patternData[4] = { 0x55555555,
-                              0xaaaaaaaa,
-                              0x66666666,
-                              0x99999999 };
+       static const u32 patternData[4] = {
+               0x55555555, 0xaaaaaaaa, 0x66666666, 0x99999999
+       };
        int i, j, loop_max;
 
        if (!AR_SREV_9300_20_OR_LATER(ah)) {
@@ -330,11 +320,9 @@ static bool ath9k_hw_chip_test(struct ath_hw *ah)
                        REG_WRITE(ah, addr, wrData);
                        rdData = REG_READ(ah, addr);
                        if (rdData != wrData) {
-                               ath_print(common, ATH_DBG_FATAL,
-                                         "address test failed "
-                                         "addr: 0x%08x - wr:0x%08x != "
-                                         "rd:0x%08x\n",
-                                         addr, wrData, rdData);
+                               ath_err(common,
+                                       "address test failed addr: 0x%08x - wr:0x%08x != rd:0x%08x\n",
+                                       addr, wrData, rdData);
                                return false;
                        }
                }
@@ -343,11 +331,9 @@ static bool ath9k_hw_chip_test(struct ath_hw *ah)
                        REG_WRITE(ah, addr, wrData);
                        rdData = REG_READ(ah, addr);
                        if (wrData != rdData) {
-                               ath_print(common, ATH_DBG_FATAL,
-                                         "address test failed "
-                                         "addr: 0x%08x - wr:0x%08x != "
-                                         "rd:0x%08x\n",
-                                         addr, wrData, rdData);
+                               ath_err(common,
+                                       "address test failed addr: 0x%08x - wr:0x%08x != rd:0x%08x\n",
+                                       addr, wrData, rdData);
                                return false;
                        }
                }
@@ -371,10 +357,6 @@ static void ath9k_hw_init_config(struct ath_hw *ah)
        ah->config.pcie_clock_req = 0;
        ah->config.pcie_waen = 0;
        ah->config.analog_shiftreg = 1;
-       ah->config.ofdm_trig_low = 200;
-       ah->config.ofdm_trig_high = 500;
-       ah->config.cck_trig_high = 200;
-       ah->config.cck_trig_low = 100;
        ah->config.enable_ani = true;
 
        for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
@@ -387,6 +369,9 @@ static void ath9k_hw_init_config(struct ath_hw *ah)
        else
                ah->config.ht_enable = 0;
 
+       /* PAPRD needs some more work to be enabled */
+       ah->config.paprd_disable = 1;
+
        ah->config.rx_intr_mitigation = true;
        ah->config.pcieSerDesWrite = true;
 
@@ -421,17 +406,12 @@ static void ath9k_hw_init_defaults(struct ath_hw *ah)
        ah->hw_version.magic = AR5416_MAGIC;
        ah->hw_version.subvendorid = 0;
 
-       ah->ah_flags = 0;
-       if (!AR_SREV_9100(ah))
-               ah->ah_flags = AH_USE_EEPROM;
-
        ah->atim_window = 0;
        ah->sta_id1_defaults =
                AR_STA_ID1_CRPT_MIC_ENABLE |
                AR_STA_ID1_MCAST_KSRCH;
-       ah->beacon_interval = 100;
        ah->enable_32kHz_clock = DONT_USE_32KHZ;
-       ah->slottime = (u32) -1;
+       ah->slottime = 20;
        ah->globaltxtimeout = (u32) -1;
        ah->power_mode = ATH9K_PM_UNDEFINED;
 }
@@ -442,7 +422,7 @@ static int ath9k_hw_init_macaddr(struct ath_hw *ah)
        u32 sum;
        int i;
        u16 eeval;
-       u32 EEP_MAC[] = { EEP_MAC_LSW, EEP_MAC_MID, EEP_MAC_MSW };
+       static const u32 EEP_MAC[] = { EEP_MAC_LSW, EEP_MAC_MID, EEP_MAC_MSW };
 
        sum = 0;
        for (i = 0; i < 3; i++) {
@@ -459,9 +439,10 @@ static int ath9k_hw_init_macaddr(struct ath_hw *ah)
 
 static int ath9k_hw_post_init(struct ath_hw *ah)
 {
+       struct ath_common *common = ath9k_hw_common(ah);
        int ecode;
 
-       if (!AR_SREV_9271(ah)) {
+       if (common->bus_ops->ath_bus_type != ATH_USB) {
                if (!ath9k_hw_chip_test(ah))
                        return -ENODEV;
        }
@@ -476,16 +457,16 @@ static int ath9k_hw_post_init(struct ath_hw *ah)
        if (ecode != 0)
                return ecode;
 
-       ath_print(ath9k_hw_common(ah), ATH_DBG_CONFIG,
-                 "Eeprom VER: %d, REV: %d\n",
-                 ah->eep_ops->get_eeprom_ver(ah),
-                 ah->eep_ops->get_eeprom_rev(ah));
+       ath_dbg(ath9k_hw_common(ah), ATH_DBG_CONFIG,
+               "Eeprom VER: %d, REV: %d\n",
+               ah->eep_ops->get_eeprom_ver(ah),
+               ah->eep_ops->get_eeprom_rev(ah));
 
        ecode = ath9k_hw_rf_alloc_ext_banks(ah);
        if (ecode) {
-               ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
-                         "Failed allocating banks for "
-                         "external radio\n");
+               ath_err(ath9k_hw_common(ah),
+                       "Failed allocating banks for external radio\n");
+               ath9k_hw_rf_free_ext_banks(ah);
                return ecode;
        }
 
@@ -515,8 +496,7 @@ static int __ath9k_hw_init(struct ath_hw *ah)
                ah->hw_version.macVersion = AR_SREV_VERSION_9100;
 
        if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON)) {
-               ath_print(common, ATH_DBG_FATAL,
-                         "Couldn't reset chip\n");
+               ath_err(common, "Couldn't reset chip\n");
                return -EIO;
        }
 
@@ -526,7 +506,7 @@ static int __ath9k_hw_init(struct ath_hw *ah)
        ath9k_hw_attach_ops(ah);
 
        if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) {
-               ath_print(common, ATH_DBG_FATAL, "Couldn't wakeup chip\n");
+               ath_err(common, "Couldn't wakeup chip\n");
                return -EIO;
        }
 
@@ -542,7 +522,7 @@ static int __ath9k_hw_init(struct ath_hw *ah)
                }
        }
 
-       ath_print(common, ATH_DBG_RESET, "serialize_regmode is %d\n",
+       ath_dbg(common, ATH_DBG_RESET, "serialize_regmode is %d\n",
                ah->config.serialize_regmode);
 
        if (AR_SREV_9285(ah) || AR_SREV_9271(ah))
@@ -550,11 +530,22 @@ static int __ath9k_hw_init(struct ath_hw *ah)
        else
                ah->config.max_txtrig_level = MAX_TX_FIFO_THRESHOLD;
 
-       if (!ath9k_hw_macversion_supported(ah)) {
-               ath_print(common, ATH_DBG_FATAL,
-                         "Mac Chip Rev 0x%02x.%x is not supported by "
-                         "this driver\n", ah->hw_version.macVersion,
-                         ah->hw_version.macRev);
+       switch (ah->hw_version.macVersion) {
+       case AR_SREV_VERSION_5416_PCI:
+       case AR_SREV_VERSION_5416_PCIE:
+       case AR_SREV_VERSION_9160:
+       case AR_SREV_VERSION_9100:
+       case AR_SREV_VERSION_9280:
+       case AR_SREV_VERSION_9285:
+       case AR_SREV_VERSION_9287:
+       case AR_SREV_VERSION_9271:
+       case AR_SREV_VERSION_9300:
+       case AR_SREV_VERSION_9485:
+               break;
+       default:
+               ath_err(common,
+                       "Mac Chip Rev 0x%02x.%x is not supported by this driver\n",
+                       ah->hw_version.macVersion, ah->hw_version.macRev);
                return -EOPNOTSUPP;
        }
 
@@ -565,7 +556,7 @@ static int __ath9k_hw_init(struct ath_hw *ah)
        ath9k_hw_init_cal_settings(ah);
 
        ah->ani_function = ATH9K_ANI_ALL;
-       if (AR_SREV_9280_10_OR_LATER(ah) && !AR_SREV_9300_20_OR_LATER(ah))
+       if (AR_SREV_9280_20_OR_LATER(ah) && !AR_SREV_9300_20_OR_LATER(ah))
                ah->ani_function &= ~ATH9K_ANI_NOISE_IMMUNITY_LEVEL;
        if (!AR_SREV_9300_20_OR_LATER(ah))
                ah->ani_function &= ~ATH9K_ANI_MRC_CCK;
@@ -600,8 +591,7 @@ static int __ath9k_hw_init(struct ath_hw *ah)
 
        r = ath9k_hw_init_macaddr(ah);
        if (r) {
-               ath_print(common, ATH_DBG_FATAL,
-                         "Failed to initialize MAC address\n");
+               ath_err(common, "Failed to initialize MAC address\n");
                return r;
        }
 
@@ -635,21 +625,21 @@ int ath9k_hw_init(struct ath_hw *ah)
        case AR9287_DEVID_PCIE:
        case AR2427_DEVID_PCIE:
        case AR9300_DEVID_PCIE:
+       case AR9300_DEVID_AR9485_PCIE:
                break;
        default:
                if (common->bus_ops->ath_bus_type == ATH_USB)
                        break;
-               ath_print(common, ATH_DBG_FATAL,
-                         "Hardware device ID 0x%04x not supported\n",
-                         ah->hw_version.devid);
+               ath_err(common, "Hardware device ID 0x%04x not supported\n",
+                       ah->hw_version.devid);
                return -EOPNOTSUPP;
        }
 
        ret = __ath9k_hw_init(ah);
        if (ret) {
-               ath_print(common, ATH_DBG_FATAL,
-                         "Unable to initialize hardware; "
-                         "initialization status: %d\n", ret);
+               ath_err(common,
+                       "Unable to initialize hardware; initialization status: %d\n",
+                       ret);
                return ret;
        }
 
@@ -676,13 +666,17 @@ static void ath9k_hw_init_qos(struct ath_hw *ah)
        REG_WRITE(ah, AR_TXOP_12_15, 0xFFFFFFFF);
 
        REGWRITE_BUFFER_FLUSH(ah);
-       DISABLE_REGWRITE_BUFFER(ah);
 }
 
 static void ath9k_hw_init_pll(struct ath_hw *ah,
                              struct ath9k_channel *chan)
 {
-       u32 pll = ath9k_hw_compute_pll_control(ah, chan);
+       u32 pll;
+
+       if (AR_SREV_9485(ah))
+               REG_WRITE(ah, AR_RTC_PLL_CONTROL2, 0x886666);
+
+       pll = ath9k_hw_compute_pll_control(ah, chan);
 
        REG_WRITE(ah, AR_RTC_PLL_CONTROL, pll);
 
@@ -741,7 +735,6 @@ static void ath9k_hw_init_interrupt_masks(struct ath_hw *ah,
        }
 
        REGWRITE_BUFFER_FLUSH(ah);
-       DISABLE_REGWRITE_BUFFER(ah);
 
        if (AR_SREV_9300_20_OR_LATER(ah)) {
                REG_WRITE(ah, AR_INTR_PRIO_ASYNC_ENABLE, 0);
@@ -775,8 +768,8 @@ static void ath9k_hw_set_cts_timeout(struct ath_hw *ah, u32 us)
 static bool ath9k_hw_set_global_txtimeout(struct ath_hw *ah, u32 tu)
 {
        if (tu > 0xFFFF) {
-               ath_print(ath9k_hw_common(ah), ATH_DBG_XMIT,
-                         "bad global tx timeout %u\n", tu);
+               ath_dbg(ath9k_hw_common(ah), ATH_DBG_XMIT,
+                       "bad global tx timeout %u\n", tu);
                ah->globaltxtimeout = (u32) -1;
                return false;
        } else {
@@ -793,8 +786,8 @@ void ath9k_hw_init_global_settings(struct ath_hw *ah)
        int slottime;
        int sifstime;
 
-       ath_print(ath9k_hw_common(ah), ATH_DBG_RESET, "ah->misc_mode 0x%x\n",
-                 ah->misc_mode);
+       ath_dbg(ath9k_hw_common(ah), ATH_DBG_RESET, "ah->misc_mode 0x%x\n",
+               ah->misc_mode);
 
        if (ah->misc_mode != 0)
                REG_WRITE(ah, AR_PCU_MISC,
@@ -819,7 +812,7 @@ void ath9k_hw_init_global_settings(struct ath_hw *ah)
        if (conf->channel && conf->channel->band == IEEE80211_BAND_2GHZ)
                acktimeout += 64 - sifstime - ah->slottime;
 
-       ath9k_hw_setslottime(ah, slottime);
+       ath9k_hw_setslottime(ah, ah->slottime);
        ath9k_hw_set_ack_timeout(ah, acktimeout);
        ath9k_hw_set_cts_timeout(ah, acktimeout);
        if (ah->globaltxtimeout != (u32) -1)
@@ -885,7 +878,6 @@ static inline void ath9k_hw_set_dma(struct ath_hw *ah)
        REG_WRITE(ah, AR_TXCFG, regval | AR_TXCFG_DMASZ_128B);
 
        REGWRITE_BUFFER_FLUSH(ah);
-       DISABLE_REGWRITE_BUFFER(ah);
 
        /*
         * Restore TX Trigger Level to its pre-reset value.
@@ -933,7 +925,6 @@ static inline void ath9k_hw_set_dma(struct ath_hw *ah)
        }
 
        REGWRITE_BUFFER_FLUSH(ah);
-       DISABLE_REGWRITE_BUFFER(ah);
 
        if (AR_SREV_9300_20_OR_LATER(ah))
                ath9k_hw_reset_txstatus_ring(ah);
@@ -958,9 +949,12 @@ static void ath9k_hw_set_operating_mode(struct ath_hw *ah, int opmode)
                REG_SET_BIT(ah, AR_CFG, AR_CFG_AP_ADHOC_INDICATION);
                break;
        case NL80211_IFTYPE_STATION:
-       case NL80211_IFTYPE_MONITOR:
                REG_WRITE(ah, AR_STA_ID1, val | AR_STA_ID1_KSRCH_MODE);
                break;
+       default:
+               if (ah->is_monitoring)
+                       REG_WRITE(ah, AR_STA_ID1, val | AR_STA_ID1_KSRCH_MODE);
+               break;
        }
 }
 
@@ -1031,14 +1025,13 @@ static bool ath9k_hw_set_reset(struct ath_hw *ah, int type)
        REG_WRITE(ah, AR_RTC_RC, rst_flags);
 
        REGWRITE_BUFFER_FLUSH(ah);
-       DISABLE_REGWRITE_BUFFER(ah);
 
        udelay(50);
 
        REG_WRITE(ah, AR_RTC_RC, 0);
        if (!ath9k_hw_wait(ah, AR_RTC_RC, AR_RTC_RC_M, 0, AH_WAIT_TIMEOUT)) {
-               ath_print(ath9k_hw_common(ah), ATH_DBG_RESET,
-                         "RTC stuck in MAC reset\n");
+               ath_dbg(ath9k_hw_common(ah), ATH_DBG_RESET,
+                       "RTC stuck in MAC reset\n");
                return false;
        }
 
@@ -1070,7 +1063,6 @@ static bool ath9k_hw_set_reset_power_on(struct ath_hw *ah)
        udelay(2);
 
        REGWRITE_BUFFER_FLUSH(ah);
-       DISABLE_REGWRITE_BUFFER(ah);
 
        if (!AR_SREV_9300_20_OR_LATER(ah))
                udelay(2);
@@ -1085,8 +1077,8 @@ static bool ath9k_hw_set_reset_power_on(struct ath_hw *ah)
                           AR_RTC_STATUS_M,
                           AR_RTC_STATUS_ON,
                           AH_WAIT_TIMEOUT)) {
-               ath_print(ath9k_hw_common(ah), ATH_DBG_RESET,
-                         "RTC not waking up\n");
+               ath_dbg(ath9k_hw_common(ah), ATH_DBG_RESET,
+                       "RTC not waking up\n");
                return false;
        }
 
@@ -1146,16 +1138,14 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah,
 
        for (qnum = 0; qnum < AR_NUM_QCU; qnum++) {
                if (ath9k_hw_numtxpending(ah, qnum)) {
-                       ath_print(common, ATH_DBG_QUEUE,
-                                 "Transmit frames pending on "
-                                 "queue %d\n", qnum);
+                       ath_dbg(common, ATH_DBG_QUEUE,
+                               "Transmit frames pending on queue %d\n", qnum);
                        return false;
                }
        }
 
        if (!ath9k_hw_rfbus_req(ah)) {
-               ath_print(common, ATH_DBG_FATAL,
-                         "Could not kill baseband RX\n");
+               ath_err(common, "Could not kill baseband RX\n");
                return false;
        }
 
@@ -1163,17 +1153,17 @@ static bool ath9k_hw_channel_change(struct ath_hw *ah,
 
        r = ath9k_hw_rf_set_freq(ah, chan);
        if (r) {
-               ath_print(common, ATH_DBG_FATAL,
-                         "Failed to set channel\n");
+               ath_err(common, "Failed to set channel\n");
                return false;
        }
+       ath9k_hw_set_clockrate(ah);
 
        ah->eep_ops->set_txpower(ah, chan,
                             ath9k_regd_get_ctl(regulatory, chan),
                             channel->max_antenna_gain * 2,
                             channel->max_power * 2,
                             min((u32) MAX_RATE_POWER,
-                            (u32) regulatory->power_limit));
+                            (u32) regulatory->power_limit), false);
 
        ath9k_hw_rfbus_done(ah);
 
@@ -1190,7 +1180,7 @@ bool ath9k_hw_check_alive(struct ath_hw *ah)
        int count = 50;
        u32 reg;
 
-       if (AR_SREV_9285_10_OR_LATER(ah))
+       if (AR_SREV_9285_12_OR_LATER(ah))
                return true;
 
        do {
@@ -1227,10 +1217,10 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
        ah->txchainmask = common->tx_chainmask;
        ah->rxchainmask = common->rx_chainmask;
 
-       if (!ah->chip_fullsleep) {
+       if ((common->bus_ops->ath_bus_type != ATH_USB) && !ah->chip_fullsleep) {
                ath9k_hw_abortpcurecv(ah);
                if (!ath9k_hw_stopdmarecv(ah)) {
-                       ath_print(common, ATH_DBG_XMIT,
+                       ath_dbg(common, ATH_DBG_XMIT,
                                "Failed to stop receive dma\n");
                        bChannelChange = false;
                }
@@ -1239,7 +1229,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
        if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE))
                return -EIO;
 
-       if (curchan && !ah->chip_fullsleep && ah->caldata)
+       if (curchan && !ah->chip_fullsleep)
                ath9k_hw_getnf(ah, curchan);
 
        ah->caldata = caldata;
@@ -1258,11 +1248,13 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
            (chan->channel != ah->curchan->channel) &&
            ((chan->channelFlags & CHANNEL_ALL) ==
             (ah->curchan->channelFlags & CHANNEL_ALL)) &&
-           !AR_SREV_9280(ah)) {
+           (!AR_SREV_9280(ah) || AR_DEVID_7010(ah))) {
 
                if (ath9k_hw_channel_change(ah, chan)) {
                        ath9k_hw_loadnf(ah, ah->curchan);
                        ath9k_hw_start_nfcal(ah, true);
+                       if (AR_SREV_9271(ah))
+                               ar9002_hw_load_ani_reg(ah, chan);
                        return 0;
                }
        }
@@ -1284,6 +1276,8 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
 
        ath9k_hw_mark_phy_inactive(ah);
 
+       ah->paprd_table_write_done = false;
+
        /* Only required on the first reset */
        if (AR_SREV_9271(ah) && ah->htc_reset_init) {
                REG_WRITE(ah,
@@ -1293,7 +1287,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
        }
 
        if (!ath9k_hw_chip_reset(ah, chan)) {
-               ath_print(common, ATH_DBG_FATAL, "Chip reset failed\n");
+               ath_err(common, "Chip reset failed\n");
                return -EINVAL;
        }
 
@@ -1310,7 +1304,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
        if (tsf)
                ath9k_hw_settsf64(ah, tsf);
 
-       if (AR_SREV_9280_10_OR_LATER(ah))
+       if (AR_SREV_9280_20_OR_LATER(ah))
                REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, AR_GPIO_JTAG_DISABLE);
 
        if (!AR_SREV_9300_20_OR_LATER(ah))
@@ -1372,19 +1366,19 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
        REG_WRITE(ah, AR_RSSI_THR, INIT_RSSI_THR);
 
        REGWRITE_BUFFER_FLUSH(ah);
-       DISABLE_REGWRITE_BUFFER(ah);
 
        r = ath9k_hw_rf_set_freq(ah, chan);
        if (r)
                return r;
 
+       ath9k_hw_set_clockrate(ah);
+
        ENABLE_REGWRITE_BUFFER(ah);
 
        for (i = 0; i < AR_NUM_DCU; i++)
                REG_WRITE(ah, AR_DQCUMASK(i), 1 << i);
 
        REGWRITE_BUFFER_FLUSH(ah);
-       DISABLE_REGWRITE_BUFFER(ah);
 
        ah->intr_txqs = 0;
        for (i = 0; i < ah->caps.total_queues; i++)
@@ -1395,7 +1389,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
        ath9k_hw_init_qos(ah);
 
        if (ah->caps.hw_caps & ATH9K_HW_CAP_RFSILENT)
-               ath9k_enable_rfkill(ah);
+               ath9k_hw_cfg_gpio_input(ah, ah->rfkill_gpio);
 
        ath9k_hw_init_global_settings(ah);
 
@@ -1432,7 +1426,6 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
        REG_WRITE(ah, AR_CFG_LED, saveLedState | AR_CFG_SCLK_32KHZ);
 
        REGWRITE_BUFFER_FLUSH(ah);
-       DISABLE_REGWRITE_BUFFER(ah);
 
        /*
         * For big endian systems turn on swapping for descriptors
@@ -1441,13 +1434,13 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
                u32 mask;
                mask = REG_READ(ah, AR_CFG);
                if (mask & (AR_CFG_SWRB | AR_CFG_SWTB | AR_CFG_SWRG)) {
-                       ath_print(common, ATH_DBG_RESET,
+                       ath_dbg(common, ATH_DBG_RESET,
                                "CFG Byte Swap Set 0x%x\n", mask);
                } else {
                        mask =
                                INIT_CONFIG_STATUS | AR_CFG_SWRB | AR_CFG_SWTB;
                        REG_WRITE(ah, AR_CFG, mask);
-                       ath_print(common, ATH_DBG_RESET,
+                       ath_dbg(common, ATH_DBG_RESET,
                                "Setting CFG 0x%x\n", REG_READ(ah, AR_CFG));
                }
        } else {
@@ -1474,283 +1467,6 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
 }
 EXPORT_SYMBOL(ath9k_hw_reset);
 
-/************************/
-/* Key Cache Management */
-/************************/
-
-bool ath9k_hw_keyreset(struct ath_hw *ah, u16 entry)
-{
-       u32 keyType;
-
-       if (entry >= ah->caps.keycache_size) {
-               ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
-                         "keychache entry %u out of range\n", entry);
-               return false;
-       }
-
-       keyType = REG_READ(ah, AR_KEYTABLE_TYPE(entry));
-
-       REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), 0);
-       REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), 0);
-       REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), 0);
-       REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), 0);
-       REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), 0);
-       REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), AR_KEYTABLE_TYPE_CLR);
-       REG_WRITE(ah, AR_KEYTABLE_MAC0(entry), 0);
-       REG_WRITE(ah, AR_KEYTABLE_MAC1(entry), 0);
-
-       if (keyType == AR_KEYTABLE_TYPE_TKIP && ATH9K_IS_MIC_ENABLED(ah)) {
-               u16 micentry = entry + 64;
-
-               REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), 0);
-               REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), 0);
-               REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), 0);
-               REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), 0);
-
-       }
-
-       return true;
-}
-EXPORT_SYMBOL(ath9k_hw_keyreset);
-
-static bool ath9k_hw_keysetmac(struct ath_hw *ah, u16 entry, const u8 *mac)
-{
-       u32 macHi, macLo;
-       u32 unicast_flag = AR_KEYTABLE_VALID;
-
-       if (entry >= ah->caps.keycache_size) {
-               ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
-                         "keychache entry %u out of range\n", entry);
-               return false;
-       }
-
-       if (mac != NULL) {
-               /*
-                * AR_KEYTABLE_VALID indicates that the address is a unicast
-                * address, which must match the transmitter address for
-                * decrypting frames.
-                * Not setting this bit allows the hardware to use the key
-                * for multicast frame decryption.
-                */
-               if (mac[0] & 0x01)
-                       unicast_flag = 0;
-
-               macHi = (mac[5] << 8) | mac[4];
-               macLo = (mac[3] << 24) |
-                       (mac[2] << 16) |
-                       (mac[1] << 8) |
-                       mac[0];
-               macLo >>= 1;
-               macLo |= (macHi & 1) << 31;
-               macHi >>= 1;
-       } else {
-               macLo = macHi = 0;
-       }
-       REG_WRITE(ah, AR_KEYTABLE_MAC0(entry), macLo);
-       REG_WRITE(ah, AR_KEYTABLE_MAC1(entry), macHi | unicast_flag);
-
-       return true;
-}
-
-bool ath9k_hw_set_keycache_entry(struct ath_hw *ah, u16 entry,
-                                const struct ath9k_keyval *k,
-                                const u8 *mac)
-{
-       const struct ath9k_hw_capabilities *pCap = &ah->caps;
-       struct ath_common *common = ath9k_hw_common(ah);
-       u32 key0, key1, key2, key3, key4;
-       u32 keyType;
-
-       if (entry >= pCap->keycache_size) {
-               ath_print(common, ATH_DBG_FATAL,
-                         "keycache entry %u out of range\n", entry);
-               return false;
-       }
-
-       switch (k->kv_type) {
-       case ATH9K_CIPHER_AES_OCB:
-               keyType = AR_KEYTABLE_TYPE_AES;
-               break;
-       case ATH9K_CIPHER_AES_CCM:
-               if (!(pCap->hw_caps & ATH9K_HW_CAP_CIPHER_AESCCM)) {
-                       ath_print(common, ATH_DBG_ANY,
-                                 "AES-CCM not supported by mac rev 0x%x\n",
-                                 ah->hw_version.macRev);
-                       return false;
-               }
-               keyType = AR_KEYTABLE_TYPE_CCM;
-               break;
-       case ATH9K_CIPHER_TKIP:
-               keyType = AR_KEYTABLE_TYPE_TKIP;
-               if (ATH9K_IS_MIC_ENABLED(ah)
-                   && entry + 64 >= pCap->keycache_size) {
-                       ath_print(common, ATH_DBG_ANY,
-                                 "entry %u inappropriate for TKIP\n", entry);
-                       return false;
-               }
-               break;
-       case ATH9K_CIPHER_WEP:
-               if (k->kv_len < WLAN_KEY_LEN_WEP40) {
-                       ath_print(common, ATH_DBG_ANY,
-                                 "WEP key length %u too small\n", k->kv_len);
-                       return false;
-               }
-               if (k->kv_len <= WLAN_KEY_LEN_WEP40)
-                       keyType = AR_KEYTABLE_TYPE_40;
-               else if (k->kv_len <= WLAN_KEY_LEN_WEP104)
-                       keyType = AR_KEYTABLE_TYPE_104;
-               else
-                       keyType = AR_KEYTABLE_TYPE_128;
-               break;
-       case ATH9K_CIPHER_CLR:
-               keyType = AR_KEYTABLE_TYPE_CLR;
-               break;
-       default:
-               ath_print(common, ATH_DBG_FATAL,
-                         "cipher %u not supported\n", k->kv_type);
-               return false;
-       }
-
-       key0 = get_unaligned_le32(k->kv_val + 0);
-       key1 = get_unaligned_le16(k->kv_val + 4);
-       key2 = get_unaligned_le32(k->kv_val + 6);
-       key3 = get_unaligned_le16(k->kv_val + 10);
-       key4 = get_unaligned_le32(k->kv_val + 12);
-       if (k->kv_len <= WLAN_KEY_LEN_WEP104)
-               key4 &= 0xff;
-
-       /*
-        * Note: Key cache registers access special memory area that requires
-        * two 32-bit writes to actually update the values in the internal
-        * memory. Consequently, the exact order and pairs used here must be
-        * maintained.
-        */
-
-       if (keyType == AR_KEYTABLE_TYPE_TKIP && ATH9K_IS_MIC_ENABLED(ah)) {
-               u16 micentry = entry + 64;
-
-               /*
-                * Write inverted key[47:0] first to avoid Michael MIC errors
-                * on frames that could be sent or received at the same time.
-                * The correct key will be written in the end once everything
-                * else is ready.
-                */
-               REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), ~key0);
-               REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), ~key1);
-
-               /* Write key[95:48] */
-               REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), key2);
-               REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), key3);
-
-               /* Write key[127:96] and key type */
-               REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), key4);
-               REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), keyType);
-
-               /* Write MAC address for the entry */
-               (void) ath9k_hw_keysetmac(ah, entry, mac);
-
-               if (ah->misc_mode & AR_PCU_MIC_NEW_LOC_ENA) {
-                       /*
-                        * TKIP uses two key cache entries:
-                        * Michael MIC TX/RX keys in the same key cache entry
-                        * (idx = main index + 64):
-                        * key0 [31:0] = RX key [31:0]
-                        * key1 [15:0] = TX key [31:16]
-                        * key1 [31:16] = reserved
-                        * key2 [31:0] = RX key [63:32]
-                        * key3 [15:0] = TX key [15:0]
-                        * key3 [31:16] = reserved
-                        * key4 [31:0] = TX key [63:32]
-                        */
-                       u32 mic0, mic1, mic2, mic3, mic4;
-
-                       mic0 = get_unaligned_le32(k->kv_mic + 0);
-                       mic2 = get_unaligned_le32(k->kv_mic + 4);
-                       mic1 = get_unaligned_le16(k->kv_txmic + 2) & 0xffff;
-                       mic3 = get_unaligned_le16(k->kv_txmic + 0) & 0xffff;
-                       mic4 = get_unaligned_le32(k->kv_txmic + 4);
-
-                       /* Write RX[31:0] and TX[31:16] */
-                       REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), mic0);
-                       REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), mic1);
-
-                       /* Write RX[63:32] and TX[15:0] */
-                       REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), mic2);
-                       REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), mic3);
-
-                       /* Write TX[63:32] and keyType(reserved) */
-                       REG_WRITE(ah, AR_KEYTABLE_KEY4(micentry), mic4);
-                       REG_WRITE(ah, AR_KEYTABLE_TYPE(micentry),
-                                 AR_KEYTABLE_TYPE_CLR);
-
-               } else {
-                       /*
-                        * TKIP uses four key cache entries (two for group
-                        * keys):
-                        * Michael MIC TX/RX keys are in different key cache
-                        * entries (idx = main index + 64 for TX and
-                        * main index + 32 + 96 for RX):
-                        * key0 [31:0] = TX/RX MIC key [31:0]
-                        * key1 [31:0] = reserved
-                        * key2 [31:0] = TX/RX MIC key [63:32]
-                        * key3 [31:0] = reserved
-                        * key4 [31:0] = reserved
-                        *
-                        * Upper layer code will call this function separately
-                        * for TX and RX keys when these registers offsets are
-                        * used.
-                        */
-                       u32 mic0, mic2;
-
-                       mic0 = get_unaligned_le32(k->kv_mic + 0);
-                       mic2 = get_unaligned_le32(k->kv_mic + 4);
-
-                       /* Write MIC key[31:0] */
-                       REG_WRITE(ah, AR_KEYTABLE_KEY0(micentry), mic0);
-                       REG_WRITE(ah, AR_KEYTABLE_KEY1(micentry), 0);
-
-                       /* Write MIC key[63:32] */
-                       REG_WRITE(ah, AR_KEYTABLE_KEY2(micentry), mic2);
-                       REG_WRITE(ah, AR_KEYTABLE_KEY3(micentry), 0);
-
-                       /* Write TX[63:32] and keyType(reserved) */
-                       REG_WRITE(ah, AR_KEYTABLE_KEY4(micentry), 0);
-                       REG_WRITE(ah, AR_KEYTABLE_TYPE(micentry),
-                                 AR_KEYTABLE_TYPE_CLR);
-               }
-
-               /* MAC address registers are reserved for the MIC entry */
-               REG_WRITE(ah, AR_KEYTABLE_MAC0(micentry), 0);
-               REG_WRITE(ah, AR_KEYTABLE_MAC1(micentry), 0);
-
-               /*
-                * Write the correct (un-inverted) key[47:0] last to enable
-                * TKIP now that all other registers are set with correct
-                * values.
-                */
-               REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), key0);
-               REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), key1);
-       } else {
-               /* Write key[47:0] */
-               REG_WRITE(ah, AR_KEYTABLE_KEY0(entry), key0);
-               REG_WRITE(ah, AR_KEYTABLE_KEY1(entry), key1);
-
-               /* Write key[95:48] */
-               REG_WRITE(ah, AR_KEYTABLE_KEY2(entry), key2);
-               REG_WRITE(ah, AR_KEYTABLE_KEY3(entry), key3);
-
-               /* Write key[127:96] and key type */
-               REG_WRITE(ah, AR_KEYTABLE_KEY4(entry), key4);
-               REG_WRITE(ah, AR_KEYTABLE_TYPE(entry), keyType);
-
-               /* Write MAC address for the entry */
-               (void) ath9k_hw_keysetmac(ah, entry, mac);
-       }
-
-       return true;
-}
-EXPORT_SYMBOL(ath9k_hw_set_keycache_entry);
-
 /******************************/
 /* Power Management (Chipset) */
 /******************************/
@@ -1852,9 +1568,9 @@ static bool ath9k_hw_set_power_awake(struct ath_hw *ah, int setChip)
                                    AR_RTC_FORCE_WAKE_EN);
                }
                if (i == 0) {
-                       ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
-                                 "Failed to wakeup in %uus\n",
-                                 POWER_UP_TIME / 20);
+                       ath_err(ath9k_hw_common(ah),
+                               "Failed to wakeup in %uus\n",
+                               POWER_UP_TIME / 20);
                        return false;
                }
        }
@@ -1878,8 +1594,8 @@ bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode)
        if (ah->power_mode == mode)
                return status;
 
-       ath_print(common, ATH_DBG_RESET, "%s -> %s\n",
-                 modes[ah->power_mode], modes[mode]);
+       ath_dbg(common, ATH_DBG_RESET, "%s -> %s\n",
+               modes[ah->power_mode], modes[mode]);
 
        switch (mode) {
        case ATH9K_PM_AWAKE:
@@ -1893,12 +1609,20 @@ bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode)
                ath9k_set_power_network_sleep(ah, setChip);
                break;
        default:
-               ath_print(common, ATH_DBG_FATAL,
-                         "Unknown power mode %u\n", mode);
+               ath_err(common, "Unknown power mode %u\n", mode);
                return false;
        }
        ah->power_mode = mode;
 
+       /*
+        * XXX: If this warning never comes up after a while then
+        * simply keep the ATH_DBG_WARN_ON_ONCE() but make
+        * ath9k_hw_setpower() return type void.
+        */
+
+       if (!(ah->ah_flags & AH_UNPLUGGED))
+               ATH_DBG_WARN_ON_ONCE(!status);
+
        return status;
 }
 EXPORT_SYMBOL(ath9k_hw_setpower);
@@ -1911,18 +1635,9 @@ void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period)
 {
        int flags = 0;
 
-       ah->beacon_interval = beacon_period;
-
        ENABLE_REGWRITE_BUFFER(ah);
 
        switch (ah->opmode) {
-       case NL80211_IFTYPE_STATION:
-       case NL80211_IFTYPE_MONITOR:
-               REG_WRITE(ah, AR_NEXT_TBTT_TIMER, TU_TO_USEC(next_beacon));
-               REG_WRITE(ah, AR_NEXT_DMA_BEACON_ALERT, 0xffff);
-               REG_WRITE(ah, AR_NEXT_SWBA, 0x7ffff);
-               flags |= AR_TBTT_TIMER_EN;
-               break;
        case NL80211_IFTYPE_ADHOC:
        case NL80211_IFTYPE_MESH_POINT:
                REG_SET_BIT(ah, AR_TXCFG,
@@ -1946,9 +1661,9 @@ void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period)
                        AR_TBTT_TIMER_EN | AR_DBA_TIMER_EN | AR_SWBA_TIMER_EN;
                break;
        default:
-               ath_print(ath9k_hw_common(ah), ATH_DBG_BEACON,
-                         "%s: unsupported opmode: %d\n",
-                         __func__, ah->opmode);
+               ath_dbg(ath9k_hw_common(ah), ATH_DBG_BEACON,
+                       "%s: unsupported opmode: %d\n",
+                       __func__, ah->opmode);
                return;
                break;
        }
@@ -1959,7 +1674,6 @@ void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period)
        REG_WRITE(ah, AR_NDP_PERIOD, TU_TO_USEC(beacon_period));
 
        REGWRITE_BUFFER_FLUSH(ah);
-       DISABLE_REGWRITE_BUFFER(ah);
 
        beacon_period &= ~ATH9K_BEACON_ENA;
        if (beacon_period & ATH9K_BEACON_RESET_TSF) {
@@ -1987,7 +1701,6 @@ void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah,
                  TU_TO_USEC(bs->bs_intval & ATH9K_BEACON_PERIOD));
 
        REGWRITE_BUFFER_FLUSH(ah);
-       DISABLE_REGWRITE_BUFFER(ah);
 
        REG_RMW_FIELD(ah, AR_RSSI_THR,
                      AR_RSSI_THR_BM_THR, bs->bs_bmissthreshold);
@@ -2006,10 +1719,10 @@ void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah,
        else
                nextTbtt = bs->bs_nexttbtt;
 
-       ath_print(common, ATH_DBG_BEACON, "next DTIM %d\n", bs->bs_nextdtim);
-       ath_print(common, ATH_DBG_BEACON, "next beacon %d\n", nextTbtt);
-       ath_print(common, ATH_DBG_BEACON, "beacon period %d\n", beaconintval);
-       ath_print(common, ATH_DBG_BEACON, "DTIM period %d\n", dtimperiod);
+       ath_dbg(common, ATH_DBG_BEACON, "next DTIM %d\n", bs->bs_nextdtim);
+       ath_dbg(common, ATH_DBG_BEACON, "next beacon %d\n", nextTbtt);
+       ath_dbg(common, ATH_DBG_BEACON, "beacon period %d\n", beaconintval);
+       ath_dbg(common, ATH_DBG_BEACON, "DTIM period %d\n", dtimperiod);
 
        ENABLE_REGWRITE_BUFFER(ah);
 
@@ -2033,7 +1746,6 @@ void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah,
        REG_WRITE(ah, AR_DTIM_PERIOD, TU_TO_USEC(dtimperiod));
 
        REGWRITE_BUFFER_FLUSH(ah);
-       DISABLE_REGWRITE_BUFFER(ah);
 
        REG_SET_BIT(ah, AR_TIMER_MODE,
                    AR_TBTT_TIMER_EN | AR_TIM_TIMER_EN |
@@ -2056,12 +1768,13 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
        struct ath_btcoex_hw *btcoex_hw = &ah->btcoex_hw;
 
        u16 capField = 0, eeval;
+       u8 ant_div_ctl1, tx_chainmask, rx_chainmask;
 
        eeval = ah->eep_ops->get_eeprom(ah, EEP_REG_0);
        regulatory->current_rd = eeval;
 
        eeval = ah->eep_ops->get_eeprom(ah, EEP_REG_1);
-       if (AR_SREV_9285_10_OR_LATER(ah))
+       if (AR_SREV_9285_12_OR_LATER(ah))
                eeval |= AR9285_RDEXT_DEFAULT;
        regulatory->current_rd_ext = eeval;
 
@@ -2074,48 +1787,22 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
                        regulatory->current_rd += 5;
                else if (regulatory->current_rd == 0x41)
                        regulatory->current_rd = 0x43;
-               ath_print(common, ATH_DBG_REGULATORY,
-                         "regdomain mapped to 0x%x\n", regulatory->current_rd);
+               ath_dbg(common, ATH_DBG_REGULATORY,
+                       "regdomain mapped to 0x%x\n", regulatory->current_rd);
        }
 
        eeval = ah->eep_ops->get_eeprom(ah, EEP_OP_MODE);
        if ((eeval & (AR5416_OPFLAGS_11G | AR5416_OPFLAGS_11A)) == 0) {
-               ath_print(common, ATH_DBG_FATAL,
-                         "no band has been marked as supported in EEPROM.\n");
+               ath_err(common,
+                       "no band has been marked as supported in EEPROM\n");
                return -EINVAL;
        }
 
-       bitmap_zero(pCap->wireless_modes, ATH9K_MODE_MAX);
-
-       if (eeval & AR5416_OPFLAGS_11A) {
-               set_bit(ATH9K_MODE_11A, pCap->wireless_modes);
-               if (ah->config.ht_enable) {
-                       if (!(eeval & AR5416_OPFLAGS_N_5G_HT20))
-                               set_bit(ATH9K_MODE_11NA_HT20,
-                                       pCap->wireless_modes);
-                       if (!(eeval & AR5416_OPFLAGS_N_5G_HT40)) {
-                               set_bit(ATH9K_MODE_11NA_HT40PLUS,
-                                       pCap->wireless_modes);
-                               set_bit(ATH9K_MODE_11NA_HT40MINUS,
-                                       pCap->wireless_modes);
-                       }
-               }
-       }
+       if (eeval & AR5416_OPFLAGS_11A)
+               pCap->hw_caps |= ATH9K_HW_CAP_5GHZ;
 
-       if (eeval & AR5416_OPFLAGS_11G) {
-               set_bit(ATH9K_MODE_11G, pCap->wireless_modes);
-               if (ah->config.ht_enable) {
-                       if (!(eeval & AR5416_OPFLAGS_N_2G_HT20))
-                               set_bit(ATH9K_MODE_11NG_HT20,
-                                       pCap->wireless_modes);
-                       if (!(eeval & AR5416_OPFLAGS_N_2G_HT40)) {
-                               set_bit(ATH9K_MODE_11NG_HT40PLUS,
-                                       pCap->wireless_modes);
-                               set_bit(ATH9K_MODE_11NG_HT40MINUS,
-                                       pCap->wireless_modes);
-                       }
-               }
-       }
+       if (eeval & AR5416_OPFLAGS_11G)
+               pCap->hw_caps |= ATH9K_HW_CAP_2GHZ;
 
        pCap->tx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_TX_MASK);
        /*
@@ -2131,8 +1818,11 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
                /* Use rx_chainmask from EEPROM. */
                pCap->rx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_RX_MASK);
 
-       if (!(AR_SREV_9280(ah) && (ah->hw_version.macRev == 0)))
-               ah->misc_mode |= AR_PCU_MIC_NEW_LOC_ENA;
+       ah->misc_mode |= AR_PCU_MIC_NEW_LOC_ENA;
+
+       /* enable key search for every frame in an aggregate */
+       if (AR_SREV_9300_20_OR_LATER(ah))
+               ah->misc_mode |= AR_PCU_ALWAYS_PERFORM_KEYSEARCH;
 
        pCap->low_2ghz_chan = 2312;
        pCap->high_2ghz_chan = 2732;
@@ -2140,24 +1830,13 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
        pCap->low_5ghz_chan = 4920;
        pCap->high_5ghz_chan = 6100;
 
-       pCap->hw_caps &= ~ATH9K_HW_CAP_CIPHER_CKIP;
-       pCap->hw_caps |= ATH9K_HW_CAP_CIPHER_TKIP;
-       pCap->hw_caps |= ATH9K_HW_CAP_CIPHER_AESCCM;
-
-       pCap->hw_caps &= ~ATH9K_HW_CAP_MIC_CKIP;
-       pCap->hw_caps |= ATH9K_HW_CAP_MIC_TKIP;
-       pCap->hw_caps |= ATH9K_HW_CAP_MIC_AESCCM;
+       common->crypt_caps |= ATH_CRYPT_CAP_CIPHER_AESCCM;
 
        if (ah->config.ht_enable)
                pCap->hw_caps |= ATH9K_HW_CAP_HT;
        else
                pCap->hw_caps &= ~ATH9K_HW_CAP_HT;
 
-       pCap->hw_caps |= ATH9K_HW_CAP_GTT;
-       pCap->hw_caps |= ATH9K_HW_CAP_VEOL;
-       pCap->hw_caps |= ATH9K_HW_CAP_BSSIDMASK;
-       pCap->hw_caps &= ~ATH9K_HW_CAP_MCAST_KEYSEARCH;
-
        if (capField & AR_EEPROM_EEPCAP_MAXQCU)
                pCap->total_queues =
                        MS(capField, AR_EEPROM_EEPCAP_MAXQCU);
@@ -2170,8 +1849,6 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
        else
                pCap->keycache_size = AR_KEYTABLE_SIZE;
 
-       pCap->hw_caps |= ATH9K_HW_CAP_FASTCC;
-
        if (AR_SREV_9285(ah) || AR_SREV_9271(ah))
                pCap->tx_triglevel_max = MAX_TX_FIFO_THRESHOLD >> 1;
        else
@@ -2181,9 +1858,9 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
                pCap->num_gpio_pins = AR9271_NUM_GPIO;
        else if (AR_DEVID_7010(ah))
                pCap->num_gpio_pins = AR7010_NUM_GPIO;
-       else if (AR_SREV_9285_10_OR_LATER(ah))
+       else if (AR_SREV_9285_12_OR_LATER(ah))
                pCap->num_gpio_pins = AR9285_NUM_GPIO;
-       else if (AR_SREV_9280_10_OR_LATER(ah))
+       else if (AR_SREV_9280_20_OR_LATER(ah))
                pCap->num_gpio_pins = AR928X_NUM_GPIO;
        else
                pCap->num_gpio_pins = AR_NUM_GPIO;
@@ -2235,13 +1912,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
            AR_SREV_5416(ah))
                pCap->reg_cap |= AR_EEPROM_EEREGCAP_EN_FCC_MIDBAND;
 
-       pCap->num_antcfg_5ghz =
-               ah->eep_ops->get_num_ant_config(ah, ATH9K_HAL_FREQ_BAND_5GHZ);
-       pCap->num_antcfg_2ghz =
-               ah->eep_ops->get_num_ant_config(ah, ATH9K_HAL_FREQ_BAND_2GHZ);
-
-       if (AR_SREV_9280_10_OR_LATER(ah) &&
-           ath9k_hw_btcoex_supported(ah)) {
+       if (AR_SREV_9280_20_OR_LATER(ah) && common->btcoex_enabled) {
                btcoex_hw->btactive_gpio = ATH_BTACTIVE_GPIO;
                btcoex_hw->wlanactive_gpio = ATH_WLANACTIVE_GPIO;
 
@@ -2256,14 +1927,17 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
        }
 
        if (AR_SREV_9300_20_OR_LATER(ah)) {
-               pCap->hw_caps |= ATH9K_HW_CAP_EDMA | ATH9K_HW_CAP_LDPC |
-                                ATH9K_HW_CAP_FASTCLOCK;
+               pCap->hw_caps |= ATH9K_HW_CAP_EDMA | ATH9K_HW_CAP_FASTCLOCK;
+               if (!AR_SREV_9485(ah))
+                       pCap->hw_caps |= ATH9K_HW_CAP_LDPC;
+
                pCap->rx_hp_qdepth = ATH9K_HW_RX_HP_QDEPTH;
                pCap->rx_lp_qdepth = ATH9K_HW_RX_LP_QDEPTH;
                pCap->rx_status_len = sizeof(struct ar9003_rxs);
                pCap->tx_desc_len = sizeof(struct ar9003_txc);
                pCap->txs_len = sizeof(struct ar9003_txs);
-               if (ah->eep_ops->get_eeprom(ah, EEP_PAPRD))
+               if (!ah->config.paprd_disable &&
+                   ah->eep_ops->get_eeprom(ah, EEP_PAPRD))
                        pCap->hw_caps |= ATH9K_HW_CAP_PAPRD;
        } else {
                pCap->tx_desc_len = sizeof(struct ath_desc);
@@ -2277,9 +1951,43 @@ int ath9k_hw_fill_cap_info(struct ath_hw *ah)
        if (AR_SREV_9300_20_OR_LATER(ah))
                pCap->hw_caps |= ATH9K_HW_CAP_RAC_SUPPORTED;
 
-       if (AR_SREV_9287_10_OR_LATER(ah) || AR_SREV_9271(ah))
+       if (AR_SREV_9300_20_OR_LATER(ah))
+               ah->ent_mode = REG_READ(ah, AR_ENT_OTP);
+
+       if (AR_SREV_9287_11_OR_LATER(ah) || AR_SREV_9271(ah))
                pCap->hw_caps |= ATH9K_HW_CAP_SGI_20;
 
+       if (AR_SREV_9285(ah))
+               if (ah->eep_ops->get_eeprom(ah, EEP_MODAL_VER) >= 3) {
+                       ant_div_ctl1 =
+                               ah->eep_ops->get_eeprom(ah, EEP_ANT_DIV_CTL1);
+                       if ((ant_div_ctl1 & 0x1) && ((ant_div_ctl1 >> 3) & 0x1))
+                               pCap->hw_caps |= ATH9K_HW_CAP_ANT_DIV_COMB;
+               }
+       if (AR_SREV_9300_20_OR_LATER(ah)) {
+               if (ah->eep_ops->get_eeprom(ah, EEP_CHAIN_MASK_REDUCE))
+                       pCap->hw_caps |= ATH9K_HW_CAP_APM;
+       }
+
+
+
+       if (AR_SREV_9485_10(ah)) {
+               pCap->pcie_lcr_extsync_en = true;
+               pCap->pcie_lcr_offset = 0x80;
+       }
+
+       tx_chainmask = pCap->tx_chainmask;
+       rx_chainmask = pCap->rx_chainmask;
+       while (tx_chainmask || rx_chainmask) {
+               if (tx_chainmask & BIT(0))
+                       pCap->max_txchains++;
+               if (rx_chainmask & BIT(0))
+                       pCap->max_rxchains++;
+
+               tx_chainmask >>= 1;
+               rx_chainmask >>= 1;
+       }
+
        return 0;
 }
 
@@ -2350,14 +2058,15 @@ u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio)
                val = REG_READ(ah, AR7010_GPIO_IN);
                return (MS(val, AR7010_GPIO_IN_VAL) & AR_GPIO_BIT(gpio)) == 0;
        } else if (AR_SREV_9300_20_OR_LATER(ah))
-               return MS_REG_READ(AR9300, gpio) != 0;
+               return (MS(REG_READ(ah, AR_GPIO_IN), AR9300_GPIO_IN_VAL) &
+                       AR_GPIO_BIT(gpio)) != 0;
        else if (AR_SREV_9271(ah))
                return MS_REG_READ(AR9271, gpio) != 0;
-       else if (AR_SREV_9287_10_OR_LATER(ah))
+       else if (AR_SREV_9287_11_OR_LATER(ah))
                return MS_REG_READ(AR9287, gpio) != 0;
-       else if (AR_SREV_9285_10_OR_LATER(ah))
+       else if (AR_SREV_9285_12_OR_LATER(ah))
                return MS_REG_READ(AR9285, gpio) != 0;
-       else if (AR_SREV_9280_10_OR_LATER(ah))
+       else if (AR_SREV_9280_20_OR_LATER(ah))
                return MS_REG_READ(AR928X, gpio) != 0;
        else
                return MS_REG_READ(AR, gpio) != 0;
@@ -2456,7 +2165,6 @@ void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits)
                          REG_READ(ah, AR_RXCFG) & ~AR_RXCFG_ZLFDMA);
 
        REGWRITE_BUFFER_FLUSH(ah);
-       DISABLE_REGWRITE_BUFFER(ah);
 }
 EXPORT_SYMBOL(ath9k_hw_setrxfilter);
 
@@ -2483,7 +2191,7 @@ bool ath9k_hw_disable(struct ath_hw *ah)
 }
 EXPORT_SYMBOL(ath9k_hw_disable);
 
-void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit)
+void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test)
 {
        struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
        struct ath9k_channel *chan = ah->curchan;
@@ -2496,7 +2204,7 @@ void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit)
                                 channel->max_antenna_gain * 2,
                                 channel->max_power * 2,
                                 min((u32) MAX_RATE_POWER,
-                                (u32) regulatory->power_limit));
+                                (u32) regulatory->power_limit), test);
 }
 EXPORT_SYMBOL(ath9k_hw_set_txpowerlimit);
 
@@ -2556,8 +2264,8 @@ void ath9k_hw_reset_tsf(struct ath_hw *ah)
 {
        if (!ath9k_hw_wait(ah, AR_SLP32_MODE, AR_SLP32_TSF_WRITE_STATUS, 0,
                           AH_TSF_WRITE_TIMEOUT))
-               ath_print(ath9k_hw_common(ah), ATH_DBG_RESET,
-                         "AR_SLP32_TSF_WRITE_STATUS limit exceeded\n");
+               ath_dbg(ath9k_hw_common(ah), ATH_DBG_RESET,
+                       "AR_SLP32_TSF_WRITE_STATUS limit exceeded\n");
 
        REG_WRITE(ah, AR_RESET_TSF, AR_RESET_TSF_ONCE);
 }
@@ -2630,11 +2338,10 @@ static u32 rightmost_index(struct ath_gen_timer_table *timer_table, u32 *mask)
        return timer_table->gen_timer_index[b];
 }
 
-u32 ath9k_hw_gettsf32(struct ath_hw *ah)
+static u32 ath9k_hw_gettsf32(struct ath_hw *ah)
 {
        return REG_READ(ah, AR_TSF_L32);
 }
-EXPORT_SYMBOL(ath9k_hw_gettsf32);
 
 struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah,
                                          void (*trigger)(void *),
@@ -2648,9 +2355,9 @@ struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah,
        timer = kzalloc(sizeof(struct ath_gen_timer), GFP_KERNEL);
 
        if (timer == NULL) {
-               ath_print(ath9k_hw_common(ah), ATH_DBG_FATAL,
-                         "Failed to allocate memory"
-                         "for hw timer[%d]\n", timer_index);
+               ath_err(ath9k_hw_common(ah),
+                       "Failed to allocate memory for hw timer[%d]\n",
+                       timer_index);
                return NULL;
        }
 
@@ -2679,9 +2386,9 @@ void ath9k_hw_gen_timer_start(struct ath_hw *ah,
 
        tsf = ath9k_hw_gettsf32(ah);
 
-       ath_print(ath9k_hw_common(ah), ATH_DBG_HWTIMER,
-                 "curent tsf %x period %x"
-                 "timer_next %x\n", tsf, timer_period, timer_next);
+       ath_dbg(ath9k_hw_common(ah), ATH_DBG_HWTIMER,
+               "current tsf %x period %x timer_next %x\n",
+               tsf, timer_period, timer_next);
 
        /*
         * Pull timer_next forward if the current TSF already passed it
@@ -2761,8 +2468,8 @@ void ath_gen_timer_isr(struct ath_hw *ah)
                index = rightmost_index(timer_table, &thresh_mask);
                timer = timer_table->timers[index];
                BUG_ON(!timer);
-               ath_print(common, ATH_DBG_HWTIMER,
-                         "TSF overflow for Gen timer %d\n", index);
+               ath_dbg(common, ATH_DBG_HWTIMER,
+                       "TSF overflow for Gen timer %d\n", index);
                timer->overflow(timer->arg);
        }
 
@@ -2770,8 +2477,8 @@ void ath_gen_timer_isr(struct ath_hw *ah)
                index = rightmost_index(timer_table, &trigger_mask);
                timer = timer_table->timers[index];
                BUG_ON(!timer);
-               ath_print(common, ATH_DBG_HWTIMER,
-                         "Gen timer[%d] trigger\n", index);
+               ath_dbg(common, ATH_DBG_HWTIMER,
+                       "Gen timer[%d] trigger\n", index);
                timer->trigger(timer->arg);
        }
 }
@@ -2854,7 +2561,7 @@ void ath9k_hw_name(struct ath_hw *ah, char *hw_name, size_t len)
        int used;
 
        /* chipsets >= AR9280 are single-chip */
-       if (AR_SREV_9280_10_OR_LATER(ah)) {
+       if (AR_SREV_9280_20_OR_LATER(ah)) {
                used = snprintf(hw_name, len,
                               "Atheros AR%s Rev:%x",
                               ath9k_hw_mac_bb_name(ah->hw_version.macVersion),