- ath9k_hw_init_mode_regs(ah);
-
- if (!ah->is_pciexpress)
---- a/drivers/net/wireless/ath/ath9k/main.c
-+++ b/drivers/net/wireless/ath/ath9k/main.c
-@@ -118,7 +118,7 @@ void ath9k_ps_restore(struct ath_softc *
- if (--sc->ps_usecount != 0)
- goto unlock;
-
-- if (sc->ps_idle)
-+ if (sc->ps_idle && (sc->ps_flags & PS_WAIT_FOR_TX_ACK))
- mode = ATH9K_PM_FULL_SLEEP;
- else if (sc->ps_enabled &&
- !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
-@@ -286,7 +286,7 @@ static bool ath_complete_reset(struct at
- ath_start_ani(common);
- }
-
-- if (ath9k_hw_ops(ah)->antdiv_comb_conf_get && sc->ant_rx != 3) {
-+ if ((ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB) && sc->ant_rx != 3) {
- struct ath_hw_antcomb_conf div_ant_conf;
- u8 lna_conf;
-
-@@ -332,7 +332,8 @@ static int ath_reset_internal(struct ath
- hchan = ah->curchan;
- }
-
-- if (fastcc && !ath9k_hw_check_alive(ah))
-+ if (fastcc && (ah->chip_fullsleep ||
-+ !ath9k_hw_check_alive(ah)))
- fastcc = false;
-
- if (!ath_prepare_reset(sc, retry_tx, flush))
-@@ -561,7 +562,6 @@ void ath_ani_calibrate(unsigned long dat
- /* Long calibration runs independently of short calibration. */
- if ((timestamp - common->ani.longcal_timer) >= long_cal_interval) {
- longcal = true;
-- ath_dbg(common, ATH_DBG_ANI, "longcal @%lu\n", jiffies);
- common->ani.longcal_timer = timestamp;
- }
-
-@@ -569,8 +569,6 @@ void ath_ani_calibrate(unsigned long dat
- if (!common->ani.caldone) {
- if ((timestamp - common->ani.shortcal_timer) >= short_cal_interval) {
- shortcal = true;
-- ath_dbg(common, ATH_DBG_ANI,
-- "shortcal @%lu\n", jiffies);
- common->ani.shortcal_timer = timestamp;
- common->ani.resetcal_timer = timestamp;
- }
-@@ -584,8 +582,9 @@ void ath_ani_calibrate(unsigned long dat
- }
-
- /* Verify whether we must check ANI */
-- if ((timestamp - common->ani.checkani_timer) >=
-- ah->config.ani_poll_interval) {
-+ if (sc->sc_ah->config.enable_ani
-+ && (timestamp - common->ani.checkani_timer) >=
-+ ah->config.ani_poll_interval) {
- aniflag = true;
- common->ani.checkani_timer = timestamp;
- }
-@@ -605,6 +604,11 @@ void ath_ani_calibrate(unsigned long dat
- ah->rxchainmask, longcal);
- }
-
-+ ath_dbg(common, ATH_DBG_ANI,
-+ "Calibration @%lu finished: %s %s %s, caldone: %s\n", jiffies,
-+ longcal ? "long" : "", shortcal ? "short" : "",
-+ aniflag ? "ani" : "", common->ani.caldone ? "true" : "false");
-+
- ath9k_ps_restore(sc);
-
- set_timer:
-@@ -886,82 +890,6 @@ chip_reset:
- #undef SCHED_INTR
- }
-
--static void ath_radio_enable(struct ath_softc *sc, struct ieee80211_hw *hw)
--{
-- struct ath_hw *ah = sc->sc_ah;
-- struct ath_common *common = ath9k_hw_common(ah);
-- struct ieee80211_channel *channel = hw->conf.channel;
-- int r;
--
-- ath9k_ps_wakeup(sc);
-- spin_lock_bh(&sc->sc_pcu_lock);
-- atomic_set(&ah->intr_ref_cnt, -1);
--
-- ath9k_hw_configpcipowersave(ah, false);
--
-- if (!ah->curchan)
-- ah->curchan = ath9k_cmn_get_curchannel(sc->hw, ah);
--
-- r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
-- if (r) {
-- ath_err(common,
-- "Unable to reset channel (%u MHz), reset status %d\n",
-- channel->center_freq, r);
-- }
--
-- ath_complete_reset(sc, true);
--
-- /* Enable LED */
-- ath9k_hw_cfg_output(ah, ah->led_pin,
-- AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
-- ath9k_hw_set_gpio(ah, ah->led_pin, 0);
--
-- spin_unlock_bh(&sc->sc_pcu_lock);
--
-- ath9k_ps_restore(sc);
--}
--
--void ath_radio_disable(struct ath_softc *sc, struct ieee80211_hw *hw)
--{
-- struct ath_hw *ah = sc->sc_ah;
-- struct ieee80211_channel *channel = hw->conf.channel;
-- int r;
--
-- ath9k_ps_wakeup(sc);
--
-- ath_cancel_work(sc);
--
-- spin_lock_bh(&sc->sc_pcu_lock);
--
-- /*
-- * Keep the LED on when the radio is disabled
-- * during idle unassociated state.
-- */
-- if (!sc->ps_idle) {
-- ath9k_hw_set_gpio(ah, ah->led_pin, 1);
-- ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
-- }
--
-- ath_prepare_reset(sc, false, true);
--
-- if (!ah->curchan)
-- ah->curchan = ath9k_cmn_get_curchannel(hw, ah);
--
-- r = ath9k_hw_reset(ah, ah->curchan, ah->caldata, false);
-- if (r) {
-- ath_err(ath9k_hw_common(sc->sc_ah),
-- "Unable to reset channel (%u MHz), reset status %d\n",
-- channel->center_freq, r);
-- }
--
-- ath9k_hw_phy_disable(ah);
--
-- ath9k_hw_configpcipowersave(ah, true);
--
-- spin_unlock_bh(&sc->sc_pcu_lock);
-- ath9k_ps_restore(sc);
--}
--
- static int ath_reset(struct ath_softc *sc, bool retry_tx)
- {
- int r;
-@@ -1097,6 +1025,9 @@ static int ath9k_start(struct ieee80211_
- * and then setup of the interrupt mask.
- */
- spin_lock_bh(&sc->sc_pcu_lock);
-+
-+ atomic_set(&ah->intr_ref_cnt, -1);
-+
- r = ath9k_hw_reset(ah, init_channel, ah->caldata, false);
- if (r) {
- ath_err(common,
-@@ -1138,6 +1069,18 @@ static int ath9k_start(struct ieee80211_
- goto mutex_unlock;
- }
-
-+ if (ah->led_pin >= 0) {
-+ ath9k_hw_cfg_output(ah, ah->led_pin,
-+ AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
-+ ath9k_hw_set_gpio(ah, ah->led_pin, 0);
-+ }
-+
-+ /*
-+ * Reset key cache to sane defaults (all entries cleared) instead of
-+ * semi-random values after suspend/resume.
-+ */
-+ ath9k_cmn_init_crypto(sc->sc_ah);
-+
- spin_unlock_bh(&sc->sc_pcu_lock);
-
- if ((ah->btcoex_hw.scheme != ATH_BTCOEX_CFG_NONE) &&
-@@ -1183,6 +1126,13 @@ static void ath9k_tx(struct ieee80211_hw
- }
- }
-
-+ /*
-+ * Cannot tx while the hardware is in full sleep, it first needs a full
-+ * chip reset to recover from that
-+ */
-+ if (unlikely(sc->sc_ah->power_mode == ATH9K_PM_FULL_SLEEP))
-+ goto exit;
-+
- if (unlikely(sc->sc_ah->power_mode != ATH9K_PM_AWAKE)) {
- /*
- * We are using PS-Poll and mac80211 can request TX while in
-@@ -1229,6 +1179,7 @@ static void ath9k_stop(struct ieee80211_
- struct ath_softc *sc = hw->priv;
- struct ath_hw *ah = sc->sc_ah;
- struct ath_common *common = ath9k_hw_common(ah);
-+ bool prev_idle;
-
- mutex_lock(&sc->mutex);
-
-@@ -1259,35 +1210,45 @@ static void ath9k_stop(struct ieee80211_
- * before setting the invalid flag. */
- ath9k_hw_disable_interrupts(ah);
-
-- if (!(sc->sc_flags & SC_OP_INVALID)) {
-- ath_drain_all_txq(sc, false);
-- ath_stoprecv(sc);
-- ath9k_hw_phy_disable(ah);
-- } else
-- sc->rx.rxlink = NULL;
-+ spin_unlock_bh(&sc->sc_pcu_lock);
-+
-+ /* we can now sync irq and kill any running tasklets, since we already
-+ * disabled interrupts and not holding a spin lock */
-+ synchronize_irq(sc->irq);
-+ tasklet_kill(&sc->intr_tq);
-+ tasklet_kill(&sc->bcon_tasklet);
-+
-+ prev_idle = sc->ps_idle;
-+ sc->ps_idle = true;
-+
-+ spin_lock_bh(&sc->sc_pcu_lock);
-+
-+ if (ah->led_pin >= 0) {
-+ ath9k_hw_set_gpio(ah, ah->led_pin, 1);
-+ ath9k_hw_cfg_gpio_input(ah, ah->led_pin);
-+ }
-+
-+ ath_prepare_reset(sc, false, true);
-
- if (sc->rx.frag) {
- dev_kfree_skb_any(sc->rx.frag);
- sc->rx.frag = NULL;