1 --- a/drivers/net/wireless/ath/ath9k/hw.c
2 +++ b/drivers/net/wireless/ath/ath9k/hw.c
3 @@ -914,6 +914,13 @@ static void ath9k_hw_init_interrupt_mask
7 +static void ath9k_hw_set_sifs_time(struct ath_hw *ah, u32 us)
9 + u32 val = ath9k_hw_mac_to_clks(ah, us - 2);
10 + val = min(val, (u32) 0xFFFF);
11 + REG_WRITE(ah, AR_D_GBL_IFS_SIFS, val);
14 static void ath9k_hw_setslottime(struct ath_hw *ah, u32 us)
16 u32 val = ath9k_hw_mac_to_clks(ah, us);
17 @@ -951,25 +958,60 @@ static bool ath9k_hw_set_global_txtimeou
19 void ath9k_hw_init_global_settings(struct ath_hw *ah)
21 - struct ieee80211_conf *conf = &ath9k_hw_common(ah)->hw->conf;
22 + struct ath_common *common = ath9k_hw_common(ah);
23 + struct ieee80211_conf *conf = &common->hw->conf;
24 + const struct ath9k_channel *chan = ah->curchan;
28 + int rx_lat = 0, tx_lat = 0, eifs = 0;
31 ath_dbg(ath9k_hw_common(ah), ATH_DBG_RESET, "ah->misc_mode 0x%x\n",
37 if (ah->misc_mode != 0)
38 REG_SET_BIT(ah, AR_PCU_MISC, ah->misc_mode);
40 - if (conf->channel && conf->channel->band == IEEE80211_BAND_5GHZ)
47 + if (IS_CHAN_HALF_RATE(chan)) {
51 + if (IS_CHAN_A_FAST_CLOCK(ah, chan))
56 + } else if (IS_CHAN_QUARTER_RATE(chan)) {
60 + if (IS_CHAN_A_FAST_CLOCK(ah, chan))
66 + eifs = REG_READ(ah, AR_D_GBL_IFS_EIFS);
67 + reg = REG_READ(ah, AR_USEC);
68 + rx_lat = MS(reg, AR_USEC_RX_LAT);
69 + tx_lat = MS(reg, AR_USEC_TX_LAT);
71 + slottime = ah->slottime;
72 + if (IS_CHAN_5GHZ(chan))
78 /* As defined by IEEE 802.11-2007 17.3.8.6 */
79 - slottime = ah->slottime + 3 * ah->coverage_class;
80 - acktimeout = slottime + sifstime;
81 + acktimeout = slottime + sifstime + 3 * ah->coverage_class;
84 * Workaround for early ACK timeouts, add an offset to match the
85 @@ -981,11 +1023,20 @@ void ath9k_hw_init_global_settings(struc
86 if (conf->channel && conf->channel->band == IEEE80211_BAND_2GHZ)
87 acktimeout += 64 - sifstime - ah->slottime;
89 - ath9k_hw_setslottime(ah, ah->slottime);
90 + ath9k_hw_set_sifs_time(ah, sifstime);
91 + ath9k_hw_setslottime(ah, slottime);
92 ath9k_hw_set_ack_timeout(ah, acktimeout);
93 ath9k_hw_set_cts_timeout(ah, acktimeout);
94 if (ah->globaltxtimeout != (u32) -1)
95 ath9k_hw_set_global_txtimeout(ah, ah->globaltxtimeout);
97 + REG_WRITE(ah, AR_D_GBL_IFS_EIFS, ath9k_hw_mac_to_clks(ah, eifs));
98 + REG_RMW(ah, AR_USEC,
99 + (common->clockrate - 1) |
100 + SM(rx_lat, AR_USEC_RX_LAT) |
101 + SM(tx_lat, AR_USEC_TX_LAT),
102 + AR_USEC_TX_LAT | AR_USEC_RX_LAT | AR_USEC_USEC);
105 EXPORT_SYMBOL(ath9k_hw_init_global_settings);