[package] base-files: attempt bring up related wifi devices when calling ifup
[openwrt.git] / package / mac80211 / patches / 545-ath9k_timing_settings.patch
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
4 }
5 }
6
7 +static void ath9k_hw_set_sifs_time(struct ath_hw *ah, u32 us)
8 +{
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);
12 +}
13 +
14 static void ath9k_hw_setslottime(struct ath_hw *ah, u32 us)
15 {
16 u32 val = ath9k_hw_mac_to_clks(ah, us);
17 @@ -951,25 +958,60 @@ static bool ath9k_hw_set_global_txtimeou
18
19 void ath9k_hw_init_global_settings(struct ath_hw *ah)
20 {
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;
25 int acktimeout;
26 int slottime;
27 int sifstime;
28 + int rx_lat = 0, tx_lat = 0, eifs = 0;
29 + u32 reg;
30
31 ath_dbg(ath9k_hw_common(ah), ATH_DBG_RESET, "ah->misc_mode 0x%x\n",
32 ah->misc_mode);
33
34 + if (!chan)
35 + return;
36 +
37 if (ah->misc_mode != 0)
38 REG_SET_BIT(ah, AR_PCU_MISC, ah->misc_mode);
39
40 - if (conf->channel && conf->channel->band == IEEE80211_BAND_5GHZ)
41 - sifstime = 16;
42 - else
43 - sifstime = 10;
44 + rx_lat = 37;
45 + tx_lat = 54;
46 +
47 + if (IS_CHAN_HALF_RATE(chan)) {
48 + eifs = 175;
49 + rx_lat *= 2;
50 + tx_lat *= 2;
51 + if (IS_CHAN_A_FAST_CLOCK(ah, chan))
52 + tx_lat += 11;
53 +
54 + slottime = 13;
55 + sifstime = 32;
56 + } else if (IS_CHAN_QUARTER_RATE(chan)) {
57 + eifs = 340;
58 + rx_lat *= 4;
59 + tx_lat *= 4;
60 + if (IS_CHAN_A_FAST_CLOCK(ah, chan))
61 + tx_lat += 22;
62 +
63 + slottime = 21;
64 + sifstime = 64;
65 + } else {
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);
70 +
71 + slottime = ah->slottime;
72 + if (IS_CHAN_5GHZ(chan))
73 + sifstime = 16;
74 + else
75 + sifstime = 10;
76 + }
77
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;
82
83 /*
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;
88
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);
96 +
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);
103 +
104 }
105 EXPORT_SYMBOL(ath9k_hw_init_global_settings);
106
This page took 0.042974 seconds and 5 git commands to generate.