ath9k: merge a few reset / calibration fixes
authorFelix Fietkau <nbd@openwrt.org>
Mon, 18 Nov 2013 19:58:53 +0000 (19:58 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Mon, 18 Nov 2013 19:58:53 +0000 (19:58 +0000)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
SVN-Revision: 38854

package/kernel/mac80211/patches/300-pending_work.patch
package/kernel/mac80211/patches/402-ath9k-fix-invalid-mac-address-handling.patch
package/kernel/mac80211/patches/510-ath9k_intr_mitigation_tweak.patch
package/kernel/mac80211/patches/512-ath9k_channelbw_debugfs.patch
package/kernel/mac80211/patches/513-ath9k_add_pci_ids.patch
package/kernel/mac80211/patches/523-mac80211_configure_antenna_gain.patch
package/kernel/mac80211/patches/524-ath9k_use_configured_antenna_gain.patch
package/kernel/mac80211/patches/542-ath9k_debugfs_diag.patch
package/kernel/mac80211/patches/543-ath9k-allow-to-disable-bands-via-platform-data.patch
package/kernel/mac80211/patches/550-ath9k_entropy_from_adc.patch

index b0788e0046acefb2220f53dc42729c96a839e1fa..4b0337276d0bf55ec815877f20c37898512bfedd 100644 (file)
  }
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -454,7 +454,6 @@ static void ath9k_hw_init_config(struct 
+@@ -17,6 +17,7 @@
+ #include <linux/io.h>
+ #include <linux/slab.h>
+ #include <linux/module.h>
++#include <linux/time.h>
+ #include <asm/unaligned.h>
+ #include "hw.h"
+@@ -454,7 +455,6 @@ static void ath9k_hw_init_config(struct 
        }
  
        ah->config.rx_intr_mitigation = true;
  
        /*
         * We need this for PCI devices only (Cardbus, PCI, miniPCI)
+@@ -1502,8 +1502,9 @@ static bool ath9k_hw_channel_change(stru
+       int r;
+       if (pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH) {
+-              band_switch = IS_CHAN_5GHZ(ah->curchan) != IS_CHAN_5GHZ(chan);
+-              mode_diff = (chan->channelFlags != ah->curchan->channelFlags);
++              u32 flags_diff = chan->channelFlags ^ ah->curchan->channelFlags;
++              band_switch = !!(flags_diff & CHANNEL_5GHZ);
++              mode_diff = !!(flags_diff & ~CHANNEL_HT);
+       }
+       for (qnum = 0; qnum < AR_NUM_QCU; qnum++) {
+@@ -1815,7 +1816,7 @@ static int ath9k_hw_do_fastcc(struct ath
+        * If cross-band fcc is not supoprted, bail out if channelFlags differ.
+        */
+       if (!(pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH) &&
+-          chan->channelFlags != ah->curchan->channelFlags)
++          ((chan->channelFlags ^ ah->curchan->channelFlags) & ~CHANNEL_HT))
+               goto fail;
+       if (!ath9k_hw_check_alive(ah))
+@@ -1856,10 +1857,12 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+                  struct ath9k_hw_cal_data *caldata, bool fastcc)
+ {
+       struct ath_common *common = ath9k_hw_common(ah);
++      struct timespec ts;
+       u32 saveLedState;
+       u32 saveDefAntenna;
+       u32 macStaId1;
+       u64 tsf = 0;
++      s64 usec = 0;
+       int r;
+       bool start_mci_reset = false;
+       bool save_fullsleep = ah->chip_fullsleep;
+@@ -1902,10 +1905,10 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+       macStaId1 = REG_READ(ah, AR_STA_ID1) & AR_STA_ID1_BASE_RATE_11B;
+-      /* For chips on which RTC reset is done, save TSF before it gets cleared */
+-      if (AR_SREV_9100(ah) ||
+-          (AR_SREV_9280(ah) && ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL)))
+-              tsf = ath9k_hw_gettsf64(ah);
++      /* Save TSF before chip reset, a cold reset clears it */
++      tsf = ath9k_hw_gettsf64(ah);
++      getrawmonotonic(&ts);
++      usec = ts.tv_sec * 1000 + ts.tv_nsec / 1000;
+       saveLedState = REG_READ(ah, AR_CFG_LED) &
+               (AR_CFG_LED_ASSOC_CTL | AR_CFG_LED_MODE_SEL |
+@@ -1938,8 +1941,9 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+       }
+       /* Restore TSF */
+-      if (tsf)
+-              ath9k_hw_settsf64(ah, tsf);
++      getrawmonotonic(&ts);
++      usec = ts.tv_sec * 1000 + ts.tv_nsec / 1000 - usec;
++      ath9k_hw_settsf64(ah, tsf + usec);
+       if (AR_SREV_9280_20_OR_LATER(ah))
+               REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, AR_GPIO_JTAG_DISABLE);
 --- a/drivers/net/wireless/ath/ath9k/hw.h
 +++ b/drivers/net/wireless/ath/ath9k/hw.h
 @@ -283,7 +283,6 @@ struct ath9k_ops_config {
  
 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
-@@ -701,6 +701,54 @@ static int ar9550_hw_get_modes_txgain_in
+@@ -641,11 +641,12 @@ static void ar9003_hw_override_ini(struc
+               else
+                       ah->enabled_cals &= ~TX_IQ_CAL;
+-              if (REG_READ(ah, AR_PHY_CL_CAL_CTL) & AR_PHY_CL_CAL_ENABLE)
+-                      ah->enabled_cals |= TX_CL_CAL;
+-              else
+-                      ah->enabled_cals &= ~TX_CL_CAL;
+       }
++
++      if (REG_READ(ah, AR_PHY_CL_CAL_CTL) & AR_PHY_CL_CAL_ENABLE)
++              ah->enabled_cals |= TX_CL_CAL;
++      else
++              ah->enabled_cals &= ~TX_CL_CAL;
+ }
+ static void ar9003_hw_prog_ini(struct ath_hw *ah,
+@@ -701,6 +702,54 @@ static int ar9550_hw_get_modes_txgain_in
        return ret;
  }
  
  static int ar9003_hw_process_ini(struct ath_hw *ah,
                                 struct ath9k_channel *chan)
  {
-@@ -726,6 +774,8 @@ static int ar9003_hw_process_ini(struct 
+@@ -726,6 +775,8 @@ static int ar9003_hw_process_ini(struct 
                                           modesIndex);
        }
  
                skb = ieee80211_get_buffered_bc(rt2x00dev->hw, vif);
        }
  }
+--- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
++++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
+@@ -1040,8 +1040,8 @@ static void ar9003_hw_cl_cal_post_proc(s
+       }
+ }
+-static bool ar9003_hw_init_cal(struct ath_hw *ah,
+-                             struct ath9k_channel *chan)
++static bool ar9003_hw_init_cal_pcoem(struct ath_hw *ah,
++                                   struct ath9k_channel *chan)
+ {
+       struct ath_common *common = ath9k_hw_common(ah);
+       struct ath9k_hw_cal_data *caldata = ah->caldata;
+@@ -1228,13 +1228,109 @@ skip_tx_iqcal:
+       return true;
+ }
++static bool ar9003_hw_init_cal_soc(struct ath_hw *ah,
++                                 struct ath9k_channel *chan)
++{
++      struct ath_common *common = ath9k_hw_common(ah);
++      struct ath9k_hw_cal_data *caldata = ah->caldata;
++      bool txiqcal_done = false;
++      bool is_reusable = true, status = true;
++      bool run_agc_cal = false, sep_iq_cal = false;
++
++      /* Use chip chainmask only for calibration */
++      ar9003_hw_set_chain_masks(ah, ah->caps.rx_chainmask, ah->caps.tx_chainmask);
++
++      if (ah->enabled_cals & TX_CL_CAL) {
++              REG_SET_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_CL_CAL_ENABLE);
++              run_agc_cal = true;
++      }
++
++      if (IS_CHAN_HALF_RATE(chan) || IS_CHAN_QUARTER_RATE(chan))
++              goto skip_tx_iqcal;
++
++      /* Do Tx IQ Calibration */
++      REG_RMW_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_1,
++                    AR_PHY_TX_IQCAL_CONTROL_1_IQCORR_I_Q_COFF_DELPT,
++                    DELPT);
++
++      /*
++       * For AR9485 or later chips, TxIQ cal runs as part of
++       * AGC calibration. Specifically, AR9550 in SoC chips.
++       */
++      if (ah->enabled_cals & TX_IQ_ON_AGC_CAL) {
++              txiqcal_done = true;
++              run_agc_cal = true;
++      } else {
++              sep_iq_cal = true;
++              run_agc_cal = true;
++      }
++
++      /*
++       * In the SoC family, this will run for AR9300, AR9331 and AR9340.
++       */
++      if (sep_iq_cal) {
++              txiqcal_done = ar9003_hw_tx_iq_cal_run(ah);
++              REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS);
++              udelay(5);
++              REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
++      }
++
++skip_tx_iqcal:
++      if (run_agc_cal || !(ah->ah_flags & AH_FASTCC)) {
++              /* Calibrate the AGC */
++              REG_WRITE(ah, AR_PHY_AGC_CONTROL,
++                        REG_READ(ah, AR_PHY_AGC_CONTROL) |
++                        AR_PHY_AGC_CONTROL_CAL);
++
++              /* Poll for offset calibration complete */
++              status = ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL,
++                                     AR_PHY_AGC_CONTROL_CAL,
++                                     0, AH_WAIT_TIMEOUT);
++      }
++
++      if (!status) {
++              ath_dbg(common, CALIBRATE,
++                      "offset calibration failed to complete in %d ms; noisy environment?\n",
++                      AH_WAIT_TIMEOUT / 1000);
++              return false;
++      }
++
++      if (txiqcal_done)
++              ar9003_hw_tx_iq_cal_post_proc(ah, is_reusable);
++
++      /* Revert chainmask to runtime parameters */
++      ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
++
++      /* Initialize list pointers */
++      ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
++
++      INIT_CAL(&ah->iq_caldata);
++      INSERT_CAL(ah, &ah->iq_caldata);
++      ath_dbg(common, CALIBRATE, "enabling IQ Calibration\n");
++
++      /* Initialize current pointer to first element in list */
++      ah->cal_list_curr = ah->cal_list;
++
++      if (ah->cal_list_curr)
++              ath9k_hw_reset_calibration(ah, ah->cal_list_curr);
++
++      if (caldata)
++              caldata->CalValid = 0;
++
++      return true;
++}
++
+ void ar9003_hw_attach_calib_ops(struct ath_hw *ah)
+ {
+       struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
+       struct ath_hw_ops *ops = ath9k_hw_ops(ah);
++      if (AR_SREV_9485(ah) || AR_SREV_9462(ah) || AR_SREV_9565(ah))
++              priv_ops->init_cal = ar9003_hw_init_cal_pcoem;
++      else
++              priv_ops->init_cal = ar9003_hw_init_cal_soc;
++
+       priv_ops->init_cal_settings = ar9003_hw_init_cal_settings;
+-      priv_ops->init_cal = ar9003_hw_init_cal;
+       priv_ops->setup_calibration = ar9003_hw_setup_calibration;
+       ops->calibrate = ar9003_hw_calibrate;
+--- a/drivers/net/wireless/ath/ath9k/common.c
++++ b/drivers/net/wireless/ath/ath9k/common.c
+@@ -98,10 +98,8 @@ struct ath9k_channel *ath9k_cmn_get_chan
+ {
+       struct ieee80211_channel *curchan = chandef->chan;
+       struct ath9k_channel *channel;
+-      u8 chan_idx;
+-      chan_idx = curchan->hw_value;
+-      channel = &ah->channels[chan_idx];
++      channel = &ah->channels[curchan->hw_value];
+       ath9k_cmn_update_ichannel(channel, chandef);
+       return channel;
index e347f534ff0fe6c848fed04ac58cfbba1e11f823..c803c1ac84a58b5654a6beb0bb3d33f76c78e109 100644 (file)
@@ -1,14 +1,14 @@
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -17,6 +17,7 @@
- #include <linux/io.h>
+@@ -18,6 +18,7 @@
  #include <linux/slab.h>
  #include <linux/module.h>
+ #include <linux/time.h>
 +#include <linux/etherdevice.h>
  #include <asm/unaligned.h>
  
  #include "hw.h"
-@@ -512,8 +513,16 @@ static int ath9k_hw_init_macaddr(struct 
+@@ -513,8 +514,16 @@ static int ath9k_hw_init_macaddr(struct 
                common->macaddr[2 * i] = eeval >> 8;
                common->macaddr[2 * i + 1] = eeval & 0xff;
        }
index c1c1ea84f378e17c5aec1f3fe25686e528de0ffc..7f61c5ccc01fa7699ff68f4b3598f8ba676dca37 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -2014,8 +2014,8 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+@@ -2019,8 +2019,8 @@ int ath9k_hw_reset(struct ath_hw *ah, st
                REG_WRITE(ah, AR_OBS, 8);
  
        if (ah->config.rx_intr_mitigation) {
index 2b16ae12785593e2e09c9a37c4325deb87489806..88e0756814fb8183f1baa2801d4aea0383699621 100644 (file)
        case NL80211_CHAN_WIDTH_5:
                flags |= CHANNEL_QUARTER;
                break;
-@@ -97,12 +111,13 @@ struct ath9k_channel *ath9k_cmn_get_chan
+@@ -97,10 +111,11 @@ struct ath9k_channel *ath9k_cmn_get_chan
                                            struct cfg80211_chan_def *chandef)
  {
        struct ieee80211_channel *curchan = chandef->chan;
 +      struct ath_common *common = ath9k_hw_common(ah);
        struct ath9k_channel *channel;
-       u8 chan_idx;
  
-       chan_idx = curchan->hw_value;
-       channel = &ah->channels[chan_idx];
+       channel = &ah->channels[curchan->hw_value];
 -      ath9k_cmn_update_ichannel(channel, chandef);
 +      ath9k_cmn_update_ichannel(common, channel, chandef);
  
index dd5bb2fb146dd9bf94b5913c45c4d7bba111ce24..649a73ecb3f8094b24be5981b1c4850863abc539 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -732,6 +732,7 @@ int ath9k_hw_init(struct ath_hw *ah)
+@@ -733,6 +733,7 @@ int ath9k_hw_init(struct ath_hw *ah)
        case AR9300_DEVID_AR9462:
        case AR9485_DEVID_AR1111:
        case AR9300_DEVID_AR9565:
index 6901184e3e279a1f71b1c599dd686e49e933be6f..12937e6eb1dd236e36e7ea746b77488df1f4ce79 100644 (file)
@@ -87,7 +87,7 @@
        CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
 --- a/net/mac80211/ieee80211_i.h
 +++ b/net/mac80211/ieee80211_i.h
-@@ -1179,6 +1179,7 @@ struct ieee80211_local {
+@@ -1182,6 +1182,7 @@ struct ieee80211_local {
        int dynamic_ps_forced_timeout;
  
        int user_power_level; /* in dBm, for all interfaces */
index 9f93869178790f55a62991a4e3e506a9dcff2dcd..3614b4afbe261f40ccaee920536cfd7798035d82 100644 (file)
@@ -10,7 +10,7 @@
  
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -2853,7 +2853,7 @@ void ath9k_hw_apply_txpower(struct ath_h
+@@ -2858,7 +2858,7 @@ void ath9k_hw_apply_txpower(struct ath_h
        channel = chan->chan;
        chan_pwr = min_t(int, channel->max_power * 2, MAX_RATE_POWER);
        new_pwr = min_t(int, chan_pwr, reg->power_limit);
index b17585575a48cb27badc6cb28706db9b0f8b7a20..ba64587e3fd224b0a0c1481b2308b63d302abe2e 100644 (file)
@@ -94,7 +94,7 @@
  void ath9k_debug_sync_cause(struct ath_common *common, u32 sync_cause);
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -1861,6 +1861,20 @@ fail:
+@@ -1863,6 +1863,20 @@ fail:
        return -EINVAL;
  }
  
  int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
                   struct ath9k_hw_cal_data *caldata, bool fastcc)
  {
-@@ -2060,6 +2074,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st
+@@ -2065,6 +2079,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st
        }
  
        ath9k_hw_apply_gpio_override(ah);
index 573a735282aaeb1a1741e8fbbaefecc557681967..c4e5703b9cca92a561d81065f0508e53560aa226 100644 (file)
@@ -12,7 +12,7 @@
  
 --- a/drivers/net/wireless/ath/ath9k/hw.c
 +++ b/drivers/net/wireless/ath/ath9k/hw.c
-@@ -2453,17 +2453,25 @@ int ath9k_hw_fill_cap_info(struct ath_hw
+@@ -2458,17 +2458,25 @@ int ath9k_hw_fill_cap_info(struct ath_hw
        }
  
        eeval = ah->eep_ops->get_eeprom(ah, EEP_OP_MODE);
index 4a96a32f33e340d584611838daed544ee543b7cb..f761790310ac8b0e8363c6cdf121597658a0ccab 100644 (file)
@@ -18,7 +18,7 @@
        void (*spectral_scan_trigger)(struct ath_hw *ah);
 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
-@@ -1759,6 +1759,26 @@ static void ar9003_hw_tx99_set_txpower(s
+@@ -1760,6 +1760,26 @@ static void ar9003_hw_tx99_set_txpower(s
                  ATH9K_POW_SM(p_pwr_array[ALL_TARGET_HT40_14],  0));
  }
  
@@ -45,7 +45,7 @@
  void ar9003_hw_attach_phy_ops(struct ath_hw *ah)
  {
        struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
-@@ -1789,6 +1809,7 @@ void ar9003_hw_attach_phy_ops(struct ath
+@@ -1790,6 +1810,7 @@ void ar9003_hw_attach_phy_ops(struct ath
        priv_ops->set_radar_params = ar9003_hw_set_radar_params;
        priv_ops->fast_chan_change = ar9003_hw_fast_chan_change;