7fd622546f37ac97da3013b8bbdd13e9e44fe70b
[openwrt.git] / package / kernel / mac80211 / patches / 300-pending_work.patch
1 --- a/drivers/net/wireless/ath/ath10k/mac.c
2 +++ b/drivers/net/wireless/ath/ath10k/mac.c
3 @@ -1351,12 +1351,12 @@ static int ath10k_update_channel_list(st
4                         ch->allow_vht = true;
5  
6                         ch->allow_ibss =
7 -                               !(channel->flags & IEEE80211_CHAN_NO_IBSS);
8 +                               !(channel->flags & IEEE80211_CHAN_NO_IR);
9  
10                         ch->ht40plus =
11                                 !(channel->flags & IEEE80211_CHAN_NO_HT40PLUS);
12  
13 -                       passive = channel->flags & IEEE80211_CHAN_PASSIVE_SCAN;
14 +                       passive = channel->flags & IEEE80211_CHAN_NO_IR;
15                         ch->passive = passive;
16  
17                         ch->freq = channel->center_freq;
18 --- a/drivers/net/wireless/ath/ath9k/Kconfig
19 +++ b/drivers/net/wireless/ath/ath9k/Kconfig
20 @@ -90,7 +90,7 @@ config ATH9K_DFS_CERTIFIED
21  
22  config ATH9K_TX99
23         bool "Atheros ath9k TX99 testing support"
24 -       depends on CFG80211_CERTIFICATION_ONUS
25 +       depends on ATH9K_DEBUGFS && CFG80211_CERTIFICATION_ONUS
26         default n
27         ---help---
28           Say N. This should only be enabled on systems undergoing
29 @@ -108,6 +108,14 @@ config ATH9K_TX99
30           be evaluated to meet the RF exposure limits set forth in the
31           governmental SAR regulations.
32  
33 +config ATH9K_WOW
34 +       bool "Wake on Wireless LAN support (EXPERIMENTAL)"
35 +       depends on ATH9K && PM
36 +       default n
37 +       ---help---
38 +         This option enables Wake on Wireless LAN support for certain cards.
39 +         Currently, AR9462 is supported.
40 +
41  config ATH9K_LEGACY_RATE_CONTROL
42         bool "Atheros ath9k rate control"
43         depends on ATH9K
44 --- a/drivers/net/wireless/ath/ath9k/Makefile
45 +++ b/drivers/net/wireless/ath/ath9k/Makefile
46 @@ -13,9 +13,9 @@ ath9k-$(CPTCFG_ATH9K_PCI) += pci.o
47  ath9k-$(CPTCFG_ATH9K_AHB) += ahb.o
48  ath9k-$(CPTCFG_ATH9K_DEBUGFS) += debug.o
49  ath9k-$(CPTCFG_ATH9K_DFS_DEBUGFS) += dfs_debug.o
50 -ath9k-$(CPTCFG_ATH9K_DFS_CERTIFIED) += \
51 -               dfs.o
52 -ath9k-$(CONFIG_PM_SLEEP) += wow.o
53 +ath9k-$(CPTCFG_ATH9K_DFS_CERTIFIED) += dfs.o
54 +ath9k-$(CPTCFG_ATH9K_TX99) += tx99.o
55 +ath9k-$(CPTCFG_ATH9K_WOW) += wow.o
56  
57  obj-$(CPTCFG_ATH9K) += ath9k.o
58  
59 @@ -41,6 +41,8 @@ ath9k_hw-y:=  \
60                 ar9003_eeprom.o \
61                 ar9003_paprd.o
62  
63 +ath9k_hw-$(CPTCFG_ATH9K_WOW) += ar9003_wow.o
64 +
65  ath9k_hw-$(CPTCFG_ATH9K_BTCOEX_SUPPORT) += btcoex.o \
66                                            ar9003_mci.o
67  obj-$(CPTCFG_ATH9K_HW) += ath9k_hw.o
68 --- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c
69 +++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
70 @@ -17,6 +17,7 @@
71  #include "hw.h"
72  #include "ar9003_mac.h"
73  #include "ar9003_2p2_initvals.h"
74 +#include "ar9003_buffalo_initvals.h"
75  #include "ar9485_initvals.h"
76  #include "ar9340_initvals.h"
77  #include "ar9330_1p1_initvals.h"
78 @@ -26,6 +27,7 @@
79  #include "ar9462_2p0_initvals.h"
80  #include "ar9462_2p1_initvals.h"
81  #include "ar9565_1p0_initvals.h"
82 +#include "ar9565_1p1_initvals.h"
83  
84  /* General hardware code for the AR9003 hadware family */
85  
86 @@ -148,7 +150,11 @@ static void ar9003_hw_init_mode_regs(str
87                                 ar9340Modes_high_ob_db_tx_gain_table_1p0);
88  
89                 INIT_INI_ARRAY(&ah->iniModesFastClock,
90 -                               ar9340Modes_fast_clock_1p0);
91 +                              ar9340Modes_fast_clock_1p0);
92 +               INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
93 +                              ar9340_1p0_baseband_core_txfir_coeff_japan_2484);
94 +               INIT_INI_ARRAY(&ah->ini_dfs,
95 +                              ar9340_1p0_baseband_postamble_dfs_channel);
96  
97                 if (!ah->is_clk_25mhz)
98                         INIT_INI_ARRAY(&ah->iniAdditional,
99 @@ -187,17 +193,17 @@ static void ar9003_hw_init_mode_regs(str
100                 INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
101                                ar9485_1_1_baseband_core_txfir_coeff_japan_2484);
102  
103 -               /* Load PCIE SERDES settings from INI */
104 -
105 -               /* Awake Setting */
106 -
107 -               INIT_INI_ARRAY(&ah->iniPcieSerdes,
108 -                               ar9485_1_1_pcie_phy_clkreq_disable_L1);
109 -
110 -               /* Sleep Setting */
111 -
112 -               INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
113 -                               ar9485_1_1_pcie_phy_clkreq_disable_L1);
114 +               if (ah->config.no_pll_pwrsave) {
115 +                       INIT_INI_ARRAY(&ah->iniPcieSerdes,
116 +                                      ar9485_1_1_pcie_phy_clkreq_disable_L1);
117 +                       INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
118 +                                      ar9485_1_1_pcie_phy_clkreq_disable_L1);
119 +               } else {
120 +                       INIT_INI_ARRAY(&ah->iniPcieSerdes,
121 +                                      ar9485_1_1_pll_on_cdr_on_clkreq_disable_L1);
122 +                       INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
123 +                                      ar9485_1_1_pll_on_cdr_on_clkreq_disable_L1);
124 +               }
125         } else if (AR_SREV_9462_21(ah)) {
126                 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
127                                ar9462_2p1_mac_core);
128 @@ -223,6 +229,10 @@ static void ar9003_hw_init_mode_regs(str
129                                ar9462_2p1_modes_fast_clock);
130                 INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
131                                ar9462_2p1_baseband_core_txfir_coeff_japan_2484);
132 +               INIT_INI_ARRAY(&ah->iniPcieSerdes,
133 +                              ar9462_2p1_pciephy_clkreq_disable_L1);
134 +               INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
135 +                              ar9462_2p1_pciephy_clkreq_disable_L1);
136         } else if (AR_SREV_9462_20(ah)) {
137  
138                 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE], ar9462_2p0_mac_core);
139 @@ -247,18 +257,18 @@ static void ar9003_hw_init_mode_regs(str
140                                 ar9462_2p0_soc_postamble);
141  
142                 INIT_INI_ARRAY(&ah->iniModesRxGain,
143 -                               ar9462_common_rx_gain_table_2p0);
144 +                               ar9462_2p0_common_rx_gain);
145  
146                 /* Awake -> Sleep Setting */
147                 INIT_INI_ARRAY(&ah->iniPcieSerdes,
148 -                              ar9462_pciephy_clkreq_disable_L1_2p0);
149 +                              ar9462_2p0_pciephy_clkreq_disable_L1);
150                 /* Sleep -> Awake Setting */
151                 INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
152 -                              ar9462_pciephy_clkreq_disable_L1_2p0);
153 +                              ar9462_2p0_pciephy_clkreq_disable_L1);
154  
155                 /* Fast clock modal settings */
156                 INIT_INI_ARRAY(&ah->iniModesFastClock,
157 -                               ar9462_modes_fast_clock_2p0);
158 +                               ar9462_2p0_modes_fast_clock);
159  
160                 INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
161                                ar9462_2p0_baseband_core_txfir_coeff_japan_2484);
162 @@ -330,7 +340,46 @@ static void ar9003_hw_init_mode_regs(str
163                                 ar9580_1p0_low_ob_db_tx_gain_table);
164  
165                 INIT_INI_ARRAY(&ah->iniModesFastClock,
166 -                               ar9580_1p0_modes_fast_clock);
167 +                              ar9580_1p0_modes_fast_clock);
168 +               INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
169 +                              ar9580_1p0_baseband_core_txfir_coeff_japan_2484);
170 +               INIT_INI_ARRAY(&ah->ini_dfs,
171 +                              ar9580_1p0_baseband_postamble_dfs_channel);
172 +       } else if (AR_SREV_9565_11_OR_LATER(ah)) {
173 +               INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
174 +                              ar9565_1p1_mac_core);
175 +               INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
176 +                              ar9565_1p1_mac_postamble);
177 +
178 +               INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
179 +                              ar9565_1p1_baseband_core);
180 +               INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
181 +                              ar9565_1p1_baseband_postamble);
182 +
183 +               INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
184 +                              ar9565_1p1_radio_core);
185 +               INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
186 +                              ar9565_1p1_radio_postamble);
187 +
188 +               INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
189 +                              ar9565_1p1_soc_preamble);
190 +               INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
191 +                              ar9565_1p1_soc_postamble);
192 +
193 +               INIT_INI_ARRAY(&ah->iniModesRxGain,
194 +                              ar9565_1p1_Common_rx_gain_table);
195 +               INIT_INI_ARRAY(&ah->iniModesTxGain,
196 +                              ar9565_1p1_Modes_lowest_ob_db_tx_gain_table);
197 +
198 +               INIT_INI_ARRAY(&ah->iniPcieSerdes,
199 +                              ar9565_1p1_pciephy_clkreq_disable_L1);
200 +               INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
201 +                              ar9565_1p1_pciephy_clkreq_disable_L1);
202 +
203 +               INIT_INI_ARRAY(&ah->iniModesFastClock,
204 +                               ar9565_1p1_modes_fast_clock);
205 +               INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
206 +                              ar9565_1p1_baseband_core_txfir_coeff_japan_2484);
207         } else if (AR_SREV_9565(ah)) {
208                 INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
209                                ar9565_1p0_mac_core);
210 @@ -411,7 +460,11 @@ static void ar9003_hw_init_mode_regs(str
211  
212                 /* Fast clock modal settings */
213                 INIT_INI_ARRAY(&ah->iniModesFastClock,
214 -                               ar9300Modes_fast_clock_2p2);
215 +                              ar9300Modes_fast_clock_2p2);
216 +               INIT_INI_ARRAY(&ah->iniCckfirJapan2484,
217 +                              ar9300_2p2_baseband_core_txfir_coeff_japan_2484);
218 +               INIT_INI_ARRAY(&ah->ini_dfs,
219 +                              ar9300_2p2_baseband_postamble_dfs_channel);
220         }
221  }
222  
223 @@ -440,7 +493,10 @@ static void ar9003_tx_gain_table_mode0(s
224                         ar9462_2p1_modes_low_ob_db_tx_gain);
225         else if (AR_SREV_9462_20(ah))
226                 INIT_INI_ARRAY(&ah->iniModesTxGain,
227 -                       ar9462_modes_low_ob_db_tx_gain_table_2p0);
228 +                       ar9462_2p0_modes_low_ob_db_tx_gain);
229 +       else if (AR_SREV_9565_11(ah))
230 +               INIT_INI_ARRAY(&ah->iniModesTxGain,
231 +                              ar9565_1p1_modes_low_ob_db_tx_gain_table);
232         else if (AR_SREV_9565(ah))
233                 INIT_INI_ARRAY(&ah->iniModesTxGain,
234                                ar9565_1p0_modes_low_ob_db_tx_gain_table);
235 @@ -474,7 +530,10 @@ static void ar9003_tx_gain_table_mode1(s
236                         ar9462_2p1_modes_high_ob_db_tx_gain);
237         else if (AR_SREV_9462_20(ah))
238                 INIT_INI_ARRAY(&ah->iniModesTxGain,
239 -                       ar9462_modes_high_ob_db_tx_gain_table_2p0);
240 +                       ar9462_2p0_modes_high_ob_db_tx_gain);
241 +       else if (AR_SREV_9565_11(ah))
242 +               INIT_INI_ARRAY(&ah->iniModesTxGain,
243 +                              ar9565_1p1_modes_high_ob_db_tx_gain_table);
244         else if (AR_SREV_9565(ah))
245                 INIT_INI_ARRAY(&ah->iniModesTxGain,
246                                ar9565_1p0_modes_high_ob_db_tx_gain_table);
247 @@ -500,6 +559,9 @@ static void ar9003_tx_gain_table_mode2(s
248         else if (AR_SREV_9580(ah))
249                 INIT_INI_ARRAY(&ah->iniModesTxGain,
250                         ar9580_1p0_low_ob_db_tx_gain_table);
251 +       else if (AR_SREV_9565_11(ah))
252 +               INIT_INI_ARRAY(&ah->iniModesTxGain,
253 +                              ar9565_1p1_modes_low_ob_db_tx_gain_table);
254         else if (AR_SREV_9565(ah))
255                 INIT_INI_ARRAY(&ah->iniModesTxGain,
256                                ar9565_1p0_modes_low_ob_db_tx_gain_table);
257 @@ -525,12 +587,20 @@ static void ar9003_tx_gain_table_mode3(s
258         else if (AR_SREV_9580(ah))
259                 INIT_INI_ARRAY(&ah->iniModesTxGain,
260                         ar9580_1p0_high_power_tx_gain_table);
261 +       else if (AR_SREV_9565_11(ah))
262 +               INIT_INI_ARRAY(&ah->iniModesTxGain,
263 +                              ar9565_1p1_modes_high_power_tx_gain_table);
264         else if (AR_SREV_9565(ah))
265                 INIT_INI_ARRAY(&ah->iniModesTxGain,
266                                ar9565_1p0_modes_high_power_tx_gain_table);
267 -       else
268 -               INIT_INI_ARRAY(&ah->iniModesTxGain,
269 -                       ar9300Modes_high_power_tx_gain_table_2p2);
270 +       else {
271 +               if (ah->config.tx_gain_buffalo)
272 +                       INIT_INI_ARRAY(&ah->iniModesTxGain,
273 +                                      ar9300Modes_high_power_tx_gain_table_buffalo);
274 +               else
275 +                       INIT_INI_ARRAY(&ah->iniModesTxGain,
276 +                                      ar9300Modes_high_power_tx_gain_table_2p2);
277 +       }
278  }
279  
280  static void ar9003_tx_gain_table_mode4(struct ath_hw *ah)
281 @@ -546,7 +616,7 @@ static void ar9003_tx_gain_table_mode4(s
282                        ar9462_2p1_modes_mix_ob_db_tx_gain);
283         else if (AR_SREV_9462_20(ah))
284                 INIT_INI_ARRAY(&ah->iniModesTxGain,
285 -                      ar9462_modes_mix_ob_db_tx_gain_table_2p0);
286 +                      ar9462_2p0_modes_mix_ob_db_tx_gain);
287         else
288                 INIT_INI_ARRAY(&ah->iniModesTxGain,
289                         ar9300Modes_mixed_ob_db_tx_gain_table_2p2);
290 @@ -581,6 +651,13 @@ static void ar9003_tx_gain_table_mode6(s
291                         ar9580_1p0_type6_tx_gain_table);
292  }
293  
294 +static void ar9003_tx_gain_table_mode7(struct ath_hw *ah)
295 +{
296 +       if (AR_SREV_9340(ah))
297 +               INIT_INI_ARRAY(&ah->iniModesTxGain,
298 +                              ar9340_cus227_tx_gain_table_1p0);
299 +}
300 +
301  typedef void (*ath_txgain_tab)(struct ath_hw *ah);
302  
303  static void ar9003_tx_gain_table_apply(struct ath_hw *ah)
304 @@ -593,6 +670,7 @@ static void ar9003_tx_gain_table_apply(s
305                 ar9003_tx_gain_table_mode4,
306                 ar9003_tx_gain_table_mode5,
307                 ar9003_tx_gain_table_mode6,
308 +               ar9003_tx_gain_table_mode7,
309         };
310         int idx = ar9003_hw_get_tx_gain_idx(ah);
311  
312 @@ -629,7 +707,10 @@ static void ar9003_rx_gain_table_mode0(s
313                                 ar9462_2p1_common_rx_gain);
314         else if (AR_SREV_9462_20(ah))
315                 INIT_INI_ARRAY(&ah->iniModesRxGain,
316 -                               ar9462_common_rx_gain_table_2p0);
317 +                               ar9462_2p0_common_rx_gain);
318 +       else if (AR_SREV_9565_11(ah))
319 +               INIT_INI_ARRAY(&ah->iniModesRxGain,
320 +                              ar9565_1p1_Common_rx_gain_table);
321         else if (AR_SREV_9565(ah))
322                 INIT_INI_ARRAY(&ah->iniModesRxGain,
323                                ar9565_1p0_Common_rx_gain_table);
324 @@ -657,7 +738,7 @@ static void ar9003_rx_gain_table_mode1(s
325                         ar9462_2p1_common_wo_xlna_rx_gain);
326         else if (AR_SREV_9462_20(ah))
327                 INIT_INI_ARRAY(&ah->iniModesRxGain,
328 -                       ar9462_common_wo_xlna_rx_gain_table_2p0);
329 +                       ar9462_2p0_common_wo_xlna_rx_gain);
330         else if (AR_SREV_9550(ah)) {
331                 INIT_INI_ARRAY(&ah->iniModesRxGain,
332                         ar955x_1p0_common_wo_xlna_rx_gain_table);
333 @@ -666,6 +747,9 @@ static void ar9003_rx_gain_table_mode1(s
334         } else if (AR_SREV_9580(ah))
335                 INIT_INI_ARRAY(&ah->iniModesRxGain,
336                         ar9580_1p0_wo_xlna_rx_gain_table);
337 +       else if (AR_SREV_9565_11(ah))
338 +               INIT_INI_ARRAY(&ah->iniModesRxGain,
339 +                              ar9565_1p1_common_wo_xlna_rx_gain_table);
340         else if (AR_SREV_9565(ah))
341                 INIT_INI_ARRAY(&ah->iniModesRxGain,
342                                ar9565_1p0_common_wo_xlna_rx_gain_table);
343 @@ -687,7 +771,7 @@ static void ar9003_rx_gain_table_mode2(s
344                                ar9462_2p1_baseband_postamble_5g_xlna);
345         } else if (AR_SREV_9462_20(ah)) {
346                 INIT_INI_ARRAY(&ah->iniModesRxGain,
347 -                              ar9462_common_mixed_rx_gain_table_2p0);
348 +                              ar9462_2p0_common_mixed_rx_gain);
349                 INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_core,
350                                ar9462_2p0_baseband_core_mix_rxgain);
351                 INIT_INI_ARRAY(&ah->ini_modes_rxgain_bb_postamble,
352 @@ -701,12 +785,12 @@ static void ar9003_rx_gain_table_mode3(s
353  {
354         if (AR_SREV_9462_21(ah)) {
355                 INIT_INI_ARRAY(&ah->iniModesRxGain,
356 -                              ar9462_2p1_common_5g_xlna_only_rx_gain);
357 +                              ar9462_2p1_common_5g_xlna_only_rxgain);
358                 INIT_INI_ARRAY(&ah->ini_modes_rxgain_5g_xlna,
359                                ar9462_2p1_baseband_postamble_5g_xlna);
360         } else if (AR_SREV_9462_20(ah)) {
361                 INIT_INI_ARRAY(&ah->iniModesRxGain,
362 -                              ar9462_2p0_5g_xlna_only_rxgain);
363 +                              ar9462_2p0_common_5g_xlna_only_rxgain);
364                 INIT_INI_ARRAY(&ah->ini_modes_rxgain_5g_xlna,
365                                ar9462_2p0_baseband_postamble_5g_xlna);
366         }
367 @@ -750,6 +834,9 @@ static void ar9003_hw_init_mode_gain_reg
368  static void ar9003_hw_configpcipowersave(struct ath_hw *ah,
369                                          bool power_off)
370  {
371 +       unsigned int i;
372 +       struct ar5416IniArray *array;
373 +
374         /*
375          * Increase L1 Entry Latency. Some WB222 boards don't have
376          * this change in eeprom/OTP.
377 @@ -775,18 +862,13 @@ static void ar9003_hw_configpcipowersave
378          * Configire PCIE after Ini init. SERDES values now come from ini file
379          * This enables PCIe low power mode.
380          */
381 -       if (ah->config.pcieSerDesWrite) {
382 -               unsigned int i;
383 -               struct ar5416IniArray *array;
384 -
385 -               array = power_off ? &ah->iniPcieSerdes :
386 -                                   &ah->iniPcieSerdesLowPower;
387 -
388 -               for (i = 0; i < array->ia_rows; i++) {
389 -                       REG_WRITE(ah,
390 -                                 INI_RA(array, i, 0),
391 -                                 INI_RA(array, i, 1));
392 -               }
393 +       array = power_off ? &ah->iniPcieSerdes :
394 +               &ah->iniPcieSerdesLowPower;
395 +
396 +       for (i = 0; i < array->ia_rows; i++) {
397 +               REG_WRITE(ah,
398 +                         INI_RA(array, i, 0),
399 +                         INI_RA(array, i, 1));
400         }
401  }
402  
403 --- a/drivers/net/wireless/ath/ath9k/ar9340_initvals.h
404 +++ b/drivers/net/wireless/ath/ath9k/ar9340_initvals.h
405 @@ -18,6 +18,20 @@
406  #ifndef INITVALS_9340_H
407  #define INITVALS_9340_H
408  
409 +#define ar9340_1p0_mac_postamble ar9300_2p2_mac_postamble
410 +
411 +#define ar9340_1p0_soc_postamble ar9300_2p2_soc_postamble
412 +
413 +#define ar9340Modes_fast_clock_1p0 ar9300Modes_fast_clock_2p2
414 +
415 +#define ar9340Common_rx_gain_table_1p0 ar9300Common_rx_gain_table_2p2
416 +
417 +#define ar9340Common_wo_xlna_rx_gain_table_1p0 ar9300Common_wo_xlna_rx_gain_table_2p2
418 +
419 +#define ar9340_1p0_baseband_core_txfir_coeff_japan_2484 ar9300_2p2_baseband_core_txfir_coeff_japan_2484
420 +
421 +#define ar9340_1p0_baseband_postamble_dfs_channel ar9300_2p2_baseband_postamble_dfs_channel
422 +
423  static const u32 ar9340_1p0_radio_postamble[][5] = {
424         /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
425         {0x000160ac, 0xa4646800, 0xa4646800, 0xa4646800, 0xa4646800},
426 @@ -100,8 +114,6 @@ static const u32 ar9340Modes_lowest_ob_d
427         {0x00016448, 0x24925266, 0x24925266, 0x24925266, 0x24925266},
428  };
429  
430 -#define ar9340Modes_fast_clock_1p0 ar9300Modes_fast_clock_2p2
431 -
432  static const u32 ar9340_1p0_radio_core[][2] = {
433         /* Addr      allmodes  */
434         {0x00016000, 0x36db6db6},
435 @@ -215,16 +227,12 @@ static const u32 ar9340_1p0_radio_core_4
436         {0x0000824c, 0x0001e800},
437  };
438  
439 -#define ar9340_1p0_mac_postamble ar9300_2p2_mac_postamble
440 -
441 -#define ar9340_1p0_soc_postamble ar9300_2p2_soc_postamble
442 -
443  static const u32 ar9340_1p0_baseband_postamble[][5] = {
444         /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
445         {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8011, 0xd00a8011},
446         {0x00009820, 0x206a022e, 0x206a022e, 0x206a022e, 0x206a022e},
447         {0x00009824, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0},
448 -       {0x00009828, 0x06903081, 0x06903081, 0x06903881, 0x06903881},
449 +       {0x00009828, 0x06903081, 0x06903081, 0x09103881, 0x09103881},
450         {0x0000982c, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4},
451         {0x00009830, 0x0000059c, 0x0000059c, 0x0000119c, 0x0000119c},
452         {0x00009c00, 0x000000c4, 0x000000c4, 0x000000c4, 0x000000c4},
453 @@ -340,9 +348,9 @@ static const u32 ar9340_1p0_baseband_cor
454         {0x0000a370, 0x00000000},
455         {0x0000a390, 0x00000001},
456         {0x0000a394, 0x00000444},
457 -       {0x0000a398, 0x001f0e0f},
458 -       {0x0000a39c, 0x0075393f},
459 -       {0x0000a3a0, 0xb79f6427},
460 +       {0x0000a398, 0x00000000},
461 +       {0x0000a39c, 0x210d0401},
462 +       {0x0000a3a0, 0xab9a7144},
463         {0x0000a3a4, 0x00000000},
464         {0x0000a3a8, 0xaaaaaaaa},
465         {0x0000a3ac, 0x3c466478},
466 @@ -714,266 +722,6 @@ static const u32 ar9340Modes_ub124_tx_ga
467         {0x0000b2e8, 0xfffe0000, 0xfffe0000, 0xfffc0000, 0xfffc0000},
468  };
469  
470 -static const u32 ar9340Common_rx_gain_table_1p0[][2] = {
471 -       /* Addr      allmodes  */
472 -       {0x0000a000, 0x00010000},
473 -       {0x0000a004, 0x00030002},
474 -       {0x0000a008, 0x00050004},
475 -       {0x0000a00c, 0x00810080},
476 -       {0x0000a010, 0x00830082},
477 -       {0x0000a014, 0x01810180},
478 -       {0x0000a018, 0x01830182},
479 -       {0x0000a01c, 0x01850184},
480 -       {0x0000a020, 0x01890188},
481 -       {0x0000a024, 0x018b018a},
482 -       {0x0000a028, 0x018d018c},
483 -       {0x0000a02c, 0x01910190},
484 -       {0x0000a030, 0x01930192},
485 -       {0x0000a034, 0x01950194},
486 -       {0x0000a038, 0x038a0196},
487 -       {0x0000a03c, 0x038c038b},
488 -       {0x0000a040, 0x0390038d},
489 -       {0x0000a044, 0x03920391},
490 -       {0x0000a048, 0x03940393},
491 -       {0x0000a04c, 0x03960395},
492 -       {0x0000a050, 0x00000000},
493 -       {0x0000a054, 0x00000000},
494 -       {0x0000a058, 0x00000000},
495 -       {0x0000a05c, 0x00000000},
496 -       {0x0000a060, 0x00000000},
497 -       {0x0000a064, 0x00000000},
498 -       {0x0000a068, 0x00000000},
499 -       {0x0000a06c, 0x00000000},
500 -       {0x0000a070, 0x00000000},
501 -       {0x0000a074, 0x00000000},
502 -       {0x0000a078, 0x00000000},
503 -       {0x0000a07c, 0x00000000},
504 -       {0x0000a080, 0x22222229},
505 -       {0x0000a084, 0x1d1d1d1d},
506 -       {0x0000a088, 0x1d1d1d1d},
507 -       {0x0000a08c, 0x1d1d1d1d},
508 -       {0x0000a090, 0x171d1d1d},
509 -       {0x0000a094, 0x11111717},
510 -       {0x0000a098, 0x00030311},
511 -       {0x0000a09c, 0x00000000},
512 -       {0x0000a0a0, 0x00000000},
513 -       {0x0000a0a4, 0x00000000},
514 -       {0x0000a0a8, 0x00000000},
515 -       {0x0000a0ac, 0x00000000},
516 -       {0x0000a0b0, 0x00000000},
517 -       {0x0000a0b4, 0x00000000},
518 -       {0x0000a0b8, 0x00000000},
519 -       {0x0000a0bc, 0x00000000},
520 -       {0x0000a0c0, 0x001f0000},
521 -       {0x0000a0c4, 0x01000101},
522 -       {0x0000a0c8, 0x011e011f},
523 -       {0x0000a0cc, 0x011c011d},
524 -       {0x0000a0d0, 0x02030204},
525 -       {0x0000a0d4, 0x02010202},
526 -       {0x0000a0d8, 0x021f0200},
527 -       {0x0000a0dc, 0x0302021e},
528 -       {0x0000a0e0, 0x03000301},
529 -       {0x0000a0e4, 0x031e031f},
530 -       {0x0000a0e8, 0x0402031d},
531 -       {0x0000a0ec, 0x04000401},
532 -       {0x0000a0f0, 0x041e041f},
533 -       {0x0000a0f4, 0x0502041d},
534 -       {0x0000a0f8, 0x05000501},
535 -       {0x0000a0fc, 0x051e051f},
536 -       {0x0000a100, 0x06010602},
537 -       {0x0000a104, 0x061f0600},
538 -       {0x0000a108, 0x061d061e},
539 -       {0x0000a10c, 0x07020703},
540 -       {0x0000a110, 0x07000701},
541 -       {0x0000a114, 0x00000000},
542 -       {0x0000a118, 0x00000000},
543 -       {0x0000a11c, 0x00000000},
544 -       {0x0000a120, 0x00000000},
545 -       {0x0000a124, 0x00000000},
546 -       {0x0000a128, 0x00000000},
547 -       {0x0000a12c, 0x00000000},
548 -       {0x0000a130, 0x00000000},
549 -       {0x0000a134, 0x00000000},
550 -       {0x0000a138, 0x00000000},
551 -       {0x0000a13c, 0x00000000},
552 -       {0x0000a140, 0x001f0000},
553 -       {0x0000a144, 0x01000101},
554 -       {0x0000a148, 0x011e011f},
555 -       {0x0000a14c, 0x011c011d},
556 -       {0x0000a150, 0x02030204},
557 -       {0x0000a154, 0x02010202},
558 -       {0x0000a158, 0x021f0200},
559 -       {0x0000a15c, 0x0302021e},
560 -       {0x0000a160, 0x03000301},
561 -       {0x0000a164, 0x031e031f},
562 -       {0x0000a168, 0x0402031d},
563 -       {0x0000a16c, 0x04000401},
564 -       {0x0000a170, 0x041e041f},
565 -       {0x0000a174, 0x0502041d},
566 -       {0x0000a178, 0x05000501},
567 -       {0x0000a17c, 0x051e051f},
568 -       {0x0000a180, 0x06010602},
569 -       {0x0000a184, 0x061f0600},
570 -       {0x0000a188, 0x061d061e},
571 -       {0x0000a18c, 0x07020703},
572 -       {0x0000a190, 0x07000701},
573 -       {0x0000a194, 0x00000000},
574 -       {0x0000a198, 0x00000000},
575 -       {0x0000a19c, 0x00000000},
576 -       {0x0000a1a0, 0x00000000},
577 -       {0x0000a1a4, 0x00000000},
578 -       {0x0000a1a8, 0x00000000},
579 -       {0x0000a1ac, 0x00000000},
580 -       {0x0000a1b0, 0x00000000},
581 -       {0x0000a1b4, 0x00000000},
582 -       {0x0000a1b8, 0x00000000},
583 -       {0x0000a1bc, 0x00000000},
584 -       {0x0000a1c0, 0x00000000},
585 -       {0x0000a1c4, 0x00000000},
586 -       {0x0000a1c8, 0x00000000},
587 -       {0x0000a1cc, 0x00000000},
588 -       {0x0000a1d0, 0x00000000},
589 -       {0x0000a1d4, 0x00000000},
590 -       {0x0000a1d8, 0x00000000},
591 -       {0x0000a1dc, 0x00000000},
592 -       {0x0000a1e0, 0x00000000},
593 -       {0x0000a1e4, 0x00000000},
594 -       {0x0000a1e8, 0x00000000},
595 -       {0x0000a1ec, 0x00000000},
596 -       {0x0000a1f0, 0x00000396},
597 -       {0x0000a1f4, 0x00000396},
598 -       {0x0000a1f8, 0x00000396},
599 -       {0x0000a1fc, 0x00000196},
600 -       {0x0000b000, 0x00010000},
601 -       {0x0000b004, 0x00030002},
602 -       {0x0000b008, 0x00050004},
603 -       {0x0000b00c, 0x00810080},
604 -       {0x0000b010, 0x00830082},
605 -       {0x0000b014, 0x01810180},
606 -       {0x0000b018, 0x01830182},
607 -       {0x0000b01c, 0x01850184},
608 -       {0x0000b020, 0x02810280},
609 -       {0x0000b024, 0x02830282},
610 -       {0x0000b028, 0x02850284},
611 -       {0x0000b02c, 0x02890288},
612 -       {0x0000b030, 0x028b028a},
613 -       {0x0000b034, 0x0388028c},
614 -       {0x0000b038, 0x038a0389},
615 -       {0x0000b03c, 0x038c038b},
616 -       {0x0000b040, 0x0390038d},
617 -       {0x0000b044, 0x03920391},
618 -       {0x0000b048, 0x03940393},
619 -       {0x0000b04c, 0x03960395},
620 -       {0x0000b050, 0x00000000},
621 -       {0x0000b054, 0x00000000},
622 -       {0x0000b058, 0x00000000},
623 -       {0x0000b05c, 0x00000000},
624 -       {0x0000b060, 0x00000000},
625 -       {0x0000b064, 0x00000000},
626 -       {0x0000b068, 0x00000000},
627 -       {0x0000b06c, 0x00000000},
628 -       {0x0000b070, 0x00000000},
629 -       {0x0000b074, 0x00000000},
630 -       {0x0000b078, 0x00000000},
631 -       {0x0000b07c, 0x00000000},
632 -       {0x0000b080, 0x23232323},
633 -       {0x0000b084, 0x21232323},
634 -       {0x0000b088, 0x19191c1e},
635 -       {0x0000b08c, 0x12141417},
636 -       {0x0000b090, 0x07070e0e},
637 -       {0x0000b094, 0x03030305},
638 -       {0x0000b098, 0x00000003},
639 -       {0x0000b09c, 0x00000000},
640 -       {0x0000b0a0, 0x00000000},
641 -       {0x0000b0a4, 0x00000000},
642 -       {0x0000b0a8, 0x00000000},
643 -       {0x0000b0ac, 0x00000000},
644 -       {0x0000b0b0, 0x00000000},
645 -       {0x0000b0b4, 0x00000000},
646 -       {0x0000b0b8, 0x00000000},
647 -       {0x0000b0bc, 0x00000000},
648 -       {0x0000b0c0, 0x003f0020},
649 -       {0x0000b0c4, 0x00400041},
650 -       {0x0000b0c8, 0x0140005f},
651 -       {0x0000b0cc, 0x0160015f},
652 -       {0x0000b0d0, 0x017e017f},
653 -       {0x0000b0d4, 0x02410242},
654 -       {0x0000b0d8, 0x025f0240},
655 -       {0x0000b0dc, 0x027f0260},
656 -       {0x0000b0e0, 0x0341027e},
657 -       {0x0000b0e4, 0x035f0340},
658 -       {0x0000b0e8, 0x037f0360},
659 -       {0x0000b0ec, 0x04400441},
660 -       {0x0000b0f0, 0x0460045f},
661 -       {0x0000b0f4, 0x0541047f},
662 -       {0x0000b0f8, 0x055f0540},
663 -       {0x0000b0fc, 0x057f0560},
664 -       {0x0000b100, 0x06400641},
665 -       {0x0000b104, 0x0660065f},
666 -       {0x0000b108, 0x067e067f},
667 -       {0x0000b10c, 0x07410742},
668 -       {0x0000b110, 0x075f0740},
669 -       {0x0000b114, 0x077f0760},
670 -       {0x0000b118, 0x07800781},
671 -       {0x0000b11c, 0x07a0079f},
672 -       {0x0000b120, 0x07c107bf},
673 -       {0x0000b124, 0x000007c0},
674 -       {0x0000b128, 0x00000000},
675 -       {0x0000b12c, 0x00000000},
676 -       {0x0000b130, 0x00000000},
677 -       {0x0000b134, 0x00000000},
678 -       {0x0000b138, 0x00000000},
679 -       {0x0000b13c, 0x00000000},
680 -       {0x0000b140, 0x003f0020},
681 -       {0x0000b144, 0x00400041},
682 -       {0x0000b148, 0x0140005f},
683 -       {0x0000b14c, 0x0160015f},
684 -       {0x0000b150, 0x017e017f},
685 -       {0x0000b154, 0x02410242},
686 -       {0x0000b158, 0x025f0240},
687 -       {0x0000b15c, 0x027f0260},
688 -       {0x0000b160, 0x0341027e},
689 -       {0x0000b164, 0x035f0340},
690 -       {0x0000b168, 0x037f0360},
691 -       {0x0000b16c, 0x04400441},
692 -       {0x0000b170, 0x0460045f},
693 -       {0x0000b174, 0x0541047f},
694 -       {0x0000b178, 0x055f0540},
695 -       {0x0000b17c, 0x057f0560},
696 -       {0x0000b180, 0x06400641},
697 -       {0x0000b184, 0x0660065f},
698 -       {0x0000b188, 0x067e067f},
699 -       {0x0000b18c, 0x07410742},
700 -       {0x0000b190, 0x075f0740},
701 -       {0x0000b194, 0x077f0760},
702 -       {0x0000b198, 0x07800781},
703 -       {0x0000b19c, 0x07a0079f},
704 -       {0x0000b1a0, 0x07c107bf},
705 -       {0x0000b1a4, 0x000007c0},
706 -       {0x0000b1a8, 0x00000000},
707 -       {0x0000b1ac, 0x00000000},
708 -       {0x0000b1b0, 0x00000000},
709 -       {0x0000b1b4, 0x00000000},
710 -       {0x0000b1b8, 0x00000000},
711 -       {0x0000b1bc, 0x00000000},
712 -       {0x0000b1c0, 0x00000000},
713 -       {0x0000b1c4, 0x00000000},
714 -       {0x0000b1c8, 0x00000000},
715 -       {0x0000b1cc, 0x00000000},
716 -       {0x0000b1d0, 0x00000000},
717 -       {0x0000b1d4, 0x00000000},
718 -       {0x0000b1d8, 0x00000000},
719 -       {0x0000b1dc, 0x00000000},
720 -       {0x0000b1e0, 0x00000000},
721 -       {0x0000b1e4, 0x00000000},
722 -       {0x0000b1e8, 0x00000000},
723 -       {0x0000b1ec, 0x00000000},
724 -       {0x0000b1f0, 0x00000396},
725 -       {0x0000b1f4, 0x00000396},
726 -       {0x0000b1f8, 0x00000396},
727 -       {0x0000b1fc, 0x00000196},
728 -};
729 -
730  static const u32 ar9340Modes_low_ob_db_tx_gain_table_1p0[][5] = {
731         /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
732         {0x0000a2dc, 0x0380c7fc, 0x0380c7fc, 0x03aaa352, 0x03aaa352},
733 @@ -1437,8 +1185,6 @@ static const u32 ar9340_1p0_mac_core[][2
734         {0x000083d0, 0x000101ff},
735  };
736  
737 -#define ar9340Common_wo_xlna_rx_gain_table_1p0 ar9300Common_wo_xlna_rx_gain_table_2p2
738 -
739  static const u32 ar9340_1p0_soc_preamble[][2] = {
740         /* Addr      allmodes  */
741         {0x00007008, 0x00000000},
742 @@ -1447,4 +1193,106 @@ static const u32 ar9340_1p0_soc_preamble
743         {0x00007038, 0x000004c2},
744  };
745  
746 +static const u32 ar9340_cus227_tx_gain_table_1p0[][5] = {
747 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
748 +       {0x0000a2dc, 0x0380c7fc, 0x0380c7fc, 0x03aaa352, 0x03aaa352},
749 +       {0x0000a2e0, 0x0000f800, 0x0000f800, 0x03ccc584, 0x03ccc584},
750 +       {0x0000a2e4, 0x03ff0000, 0x03ff0000, 0x03f0f800, 0x03f0f800},
751 +       {0x0000a2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
752 +       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
753 +       {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
754 +       {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002},
755 +       {0x0000a508, 0x0a000020, 0x0a000020, 0x08000004, 0x08000004},
756 +       {0x0000a50c, 0x10000023, 0x10000023, 0x0b000200, 0x0b000200},
757 +       {0x0000a510, 0x16000220, 0x16000220, 0x0f000202, 0x0f000202},
758 +       {0x0000a514, 0x1c000223, 0x1c000223, 0x11000400, 0x11000400},
759 +       {0x0000a518, 0x21002220, 0x21002220, 0x15000402, 0x15000402},
760 +       {0x0000a51c, 0x27002223, 0x27002223, 0x19000404, 0x19000404},
761 +       {0x0000a520, 0x2c022220, 0x2c022220, 0x1b000603, 0x1b000603},
762 +       {0x0000a524, 0x30022222, 0x30022222, 0x1f000a02, 0x1f000a02},
763 +       {0x0000a528, 0x35022225, 0x35022225, 0x23000a04, 0x23000a04},
764 +       {0x0000a52c, 0x3b02222a, 0x3b02222a, 0x26000a20, 0x26000a20},
765 +       {0x0000a530, 0x3f02222c, 0x3f02222c, 0x2a000e20, 0x2a000e20},
766 +       {0x0000a534, 0x4202242a, 0x4202242a, 0x2e000e22, 0x2e000e22},
767 +       {0x0000a538, 0x4702244a, 0x4702244a, 0x31000e24, 0x31000e24},
768 +       {0x0000a53c, 0x4b02244c, 0x4b02244c, 0x34001640, 0x34001640},
769 +       {0x0000a540, 0x4e02246c, 0x4e02246c, 0x38001660, 0x38001660},
770 +       {0x0000a544, 0x5302266c, 0x5302266c, 0x3b001861, 0x3b001861},
771 +       {0x0000a548, 0x5702286c, 0x5702286c, 0x3e001a81, 0x3e001a81},
772 +       {0x0000a54c, 0x5c02486b, 0x5c02486b, 0x42001a83, 0x42001a83},
773 +       {0x0000a550, 0x61024a6c, 0x61024a6c, 0x44001c84, 0x44001c84},
774 +       {0x0000a554, 0x66026a6c, 0x66026a6c, 0x48001ce3, 0x48001ce3},
775 +       {0x0000a558, 0x6b026e6c, 0x6b026e6c, 0x4c001ce5, 0x4c001ce5},
776 +       {0x0000a55c, 0x7002708c, 0x7002708c, 0x50001ce9, 0x50001ce9},
777 +       {0x0000a560, 0x7302b08a, 0x7302b08a, 0x54001ceb, 0x54001ceb},
778 +       {0x0000a564, 0x7702b08c, 0x7702b08c, 0x56001eec, 0x56001eec},
779 +       {0x0000a568, 0x7702b08c, 0x7702b08c, 0x56001eec, 0x56001eec},
780 +       {0x0000a56c, 0x7702b08c, 0x7702b08c, 0x56001eec, 0x56001eec},
781 +       {0x0000a570, 0x7702b08c, 0x7702b08c, 0x56001eec, 0x56001eec},
782 +       {0x0000a574, 0x7702b08c, 0x7702b08c, 0x56001eec, 0x56001eec},
783 +       {0x0000a578, 0x7702b08c, 0x7702b08c, 0x56001eec, 0x56001eec},
784 +       {0x0000a57c, 0x7702b08c, 0x7702b08c, 0x56001eec, 0x56001eec},
785 +       {0x0000a580, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
786 +       {0x0000a584, 0x06800003, 0x06800003, 0x04800002, 0x04800002},
787 +       {0x0000a588, 0x0a800020, 0x0a800020, 0x08800004, 0x08800004},
788 +       {0x0000a58c, 0x10800023, 0x10800023, 0x0b800200, 0x0b800200},
789 +       {0x0000a590, 0x16800220, 0x16800220, 0x0f800202, 0x0f800202},
790 +       {0x0000a594, 0x1c800223, 0x1c800223, 0x11800400, 0x11800400},
791 +       {0x0000a598, 0x21820220, 0x21820220, 0x15800402, 0x15800402},
792 +       {0x0000a59c, 0x27820223, 0x27820223, 0x19800404, 0x19800404},
793 +       {0x0000a5a0, 0x2b822220, 0x2b822220, 0x1b800603, 0x1b800603},
794 +       {0x0000a5a4, 0x2f822222, 0x2f822222, 0x1f800a02, 0x1f800a02},
795 +       {0x0000a5a8, 0x34822225, 0x34822225, 0x23800a04, 0x23800a04},
796 +       {0x0000a5ac, 0x3a82222a, 0x3a82222a, 0x26800a20, 0x26800a20},
797 +       {0x0000a5b0, 0x3e82222c, 0x3e82222c, 0x2a800e20, 0x2a800e20},
798 +       {0x0000a5b4, 0x4282242a, 0x4282242a, 0x2e800e22, 0x2e800e22},
799 +       {0x0000a5b8, 0x4782244a, 0x4782244a, 0x31800e24, 0x31800e24},
800 +       {0x0000a5bc, 0x4b82244c, 0x4b82244c, 0x34801640, 0x34801640},
801 +       {0x0000a5c0, 0x4e82246c, 0x4e82246c, 0x38801660, 0x38801660},
802 +       {0x0000a5c4, 0x5382266c, 0x5382266c, 0x3b801861, 0x3b801861},
803 +       {0x0000a5c8, 0x5782286c, 0x5782286c, 0x3e801a81, 0x3e801a81},
804 +       {0x0000a5cc, 0x5c84286b, 0x5c84286b, 0x42801a83, 0x42801a83},
805 +       {0x0000a5d0, 0x61842a6c, 0x61842a6c, 0x44801c84, 0x44801c84},
806 +       {0x0000a5d4, 0x66862a6c, 0x66862a6c, 0x48801ce3, 0x48801ce3},
807 +       {0x0000a5d8, 0x6b862e6c, 0x6b862e6c, 0x4c801ce5, 0x4c801ce5},
808 +       {0x0000a5dc, 0x7086308c, 0x7086308c, 0x50801ce9, 0x50801ce9},
809 +       {0x0000a5e0, 0x738a308a, 0x738a308a, 0x54801ceb, 0x54801ceb},
810 +       {0x0000a5e4, 0x778a308c, 0x778a308c, 0x56801eec, 0x56801eec},
811 +       {0x0000a5e8, 0x778a308c, 0x778a308c, 0x56801eec, 0x56801eec},
812 +       {0x0000a5ec, 0x778a308c, 0x778a308c, 0x56801eec, 0x56801eec},
813 +       {0x0000a5f0, 0x778a308c, 0x778a308c, 0x56801eec, 0x56801eec},
814 +       {0x0000a5f4, 0x778a308c, 0x778a308c, 0x56801eec, 0x56801eec},
815 +       {0x0000a5f8, 0x778a308c, 0x778a308c, 0x56801eec, 0x56801eec},
816 +       {0x0000a5fc, 0x778a308c, 0x778a308c, 0x56801eec, 0x56801eec},
817 +       {0x0000a600, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
818 +       {0x0000a604, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
819 +       {0x0000a608, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
820 +       {0x0000a60c, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
821 +       {0x0000a610, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
822 +       {0x0000a614, 0x01404000, 0x01404000, 0x01404000, 0x01404000},
823 +       {0x0000a618, 0x01404501, 0x01404501, 0x01404501, 0x01404501},
824 +       {0x0000a61c, 0x02008802, 0x02008802, 0x02008501, 0x02008501},
825 +       {0x0000a620, 0x0300cc03, 0x0300cc03, 0x0280ca03, 0x0280ca03},
826 +       {0x0000a624, 0x0300cc03, 0x0300cc03, 0x03010c04, 0x03010c04},
827 +       {0x0000a628, 0x0300cc03, 0x0300cc03, 0x04014c04, 0x04014c04},
828 +       {0x0000a62c, 0x03810c03, 0x03810c03, 0x04015005, 0x04015005},
829 +       {0x0000a630, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005},
830 +       {0x0000a634, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005},
831 +       {0x0000a638, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005},
832 +       {0x0000a63c, 0x03810e04, 0x03810e04, 0x04015005, 0x04015005},
833 +       {0x0000b2dc, 0x0380c7fc, 0x0380c7fc, 0x03aaa352, 0x03aaa352},
834 +       {0x0000b2e0, 0x0000f800, 0x0000f800, 0x03ccc584, 0x03ccc584},
835 +       {0x0000b2e4, 0x03ff0000, 0x03ff0000, 0x03f0f800, 0x03f0f800},
836 +       {0x0000b2e8, 0x00000000, 0x00000000, 0x03ff0000, 0x03ff0000},
837 +       {0x00016044, 0x056db2db, 0x056db2db, 0x03b6d2e4, 0x03b6d2e4},
838 +       {0x00016048, 0x24925666, 0x24925666, 0x8e481266, 0x8e481266},
839 +       {0x00016280, 0x01000015, 0x01000015, 0x01001015, 0x01001015},
840 +       {0x00016288, 0x30318000, 0x30318000, 0x00318000, 0x00318000},
841 +       {0x00016444, 0x056db2db, 0x056db2db, 0x03b6d2e4, 0x03b6d2e4},
842 +       {0x00016448, 0x24925666, 0x24925666, 0x8e481266, 0x8e481266},
843 +       {0x0000a3a4, 0x00000011, 0x00000011, 0x00000011, 0x00000011},
844 +       {0x0000a3a8, 0x3c3c3c3c, 0x3c3c3c3c, 0x3c3c3c3c, 0x3c3c3c3c},
845 +       {0x0000a3ac, 0x30303030, 0x30303030, 0x30303030, 0x30303030},
846 +};
847 +
848  #endif /* INITVALS_9340_H */
849 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
850 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
851 @@ -459,6 +459,7 @@ void ath_check_ani(struct ath_softc *sc)
852  int ath_update_survey_stats(struct ath_softc *sc);
853  void ath_update_survey_nf(struct ath_softc *sc, int channel);
854  void ath9k_queue_reset(struct ath_softc *sc, enum ath_reset_type type);
855 +void ath_ps_full_sleep(unsigned long data);
856  
857  /**********/
858  /* BTCOEX */
859 @@ -570,6 +571,34 @@ static inline void ath_fill_led_pin(stru
860  }
861  #endif
862  
863 +/************************/
864 +/* Wake on Wireless LAN */
865 +/************************/
866 +
867 +#ifdef CONFIG_ATH9K_WOW
868 +void ath9k_init_wow(struct ieee80211_hw *hw);
869 +int ath9k_suspend(struct ieee80211_hw *hw,
870 +                 struct cfg80211_wowlan *wowlan);
871 +int ath9k_resume(struct ieee80211_hw *hw);
872 +void ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled);
873 +#else
874 +static inline void ath9k_init_wow(struct ieee80211_hw *hw)
875 +{
876 +}
877 +static inline int ath9k_suspend(struct ieee80211_hw *hw,
878 +                               struct cfg80211_wowlan *wowlan)
879 +{
880 +       return 0;
881 +}
882 +static inline int ath9k_resume(struct ieee80211_hw *hw)
883 +{
884 +       return 0;
885 +}
886 +static inline void ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled)
887 +{
888 +}
889 +#endif /* CONFIG_ATH9K_WOW */
890 +
891  /*******************************/
892  /* Antenna diversity/combining */
893  /*******************************/
894 @@ -632,15 +661,16 @@ void ath_ant_comb_scan(struct ath_softc 
895  /* Main driver core */
896  /********************/
897  
898 -#define ATH9K_PCI_CUS198      0x0001
899 -#define ATH9K_PCI_CUS230      0x0002
900 -#define ATH9K_PCI_CUS217      0x0004
901 -#define ATH9K_PCI_CUS252      0x0008
902 -#define ATH9K_PCI_WOW         0x0010
903 -#define ATH9K_PCI_BT_ANT_DIV  0x0020
904 -#define ATH9K_PCI_D3_L1_WAR   0x0040
905 -#define ATH9K_PCI_AR9565_1ANT 0x0080
906 -#define ATH9K_PCI_AR9565_2ANT 0x0100
907 +#define ATH9K_PCI_CUS198          0x0001
908 +#define ATH9K_PCI_CUS230          0x0002
909 +#define ATH9K_PCI_CUS217          0x0004
910 +#define ATH9K_PCI_CUS252          0x0008
911 +#define ATH9K_PCI_WOW             0x0010
912 +#define ATH9K_PCI_BT_ANT_DIV      0x0020
913 +#define ATH9K_PCI_D3_L1_WAR       0x0040
914 +#define ATH9K_PCI_AR9565_1ANT     0x0080
915 +#define ATH9K_PCI_AR9565_2ANT     0x0100
916 +#define ATH9K_PCI_NO_PLL_PWRSAVE  0x0200
917  
918  /*
919   * Default cache line size, in bytes.
920 @@ -723,6 +753,7 @@ struct ath_softc {
921         struct work_struct hw_check_work;
922         struct work_struct hw_reset_work;
923         struct completion paprd_complete;
924 +       wait_queue_head_t tx_wait;
925  
926         unsigned int hw_busy_count;
927         unsigned long sc_flags;
928 @@ -759,6 +790,7 @@ struct ath_softc {
929         struct delayed_work tx_complete_work;
930         struct delayed_work hw_pll_work;
931         struct timer_list rx_poll_timer;
932 +       struct timer_list sleep_timer;
933  
934  #ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT
935         struct ath_btcoex btcoex;
936 @@ -783,7 +815,7 @@ struct ath_softc {
937         bool tx99_state;
938         s16 tx99_power;
939  
940 -#ifdef CONFIG_PM_SLEEP
941 +#ifdef CONFIG_ATH9K_WOW
942         atomic_t wow_got_bmiss_intr;
943         atomic_t wow_sleep_proc_intr; /* in the middle of WoW sleep ? */
944         u32 wow_intr_before_sleep;
945 @@ -946,10 +978,25 @@ struct fft_sample_ht20_40 {
946         u8 data[SPECTRAL_HT20_40_NUM_BINS];
947  } __packed;
948  
949 -int ath9k_tx99_init(struct ath_softc *sc);
950 -void ath9k_tx99_deinit(struct ath_softc *sc);
951 +/********/
952 +/* TX99 */
953 +/********/
954 +
955 +#ifdef CONFIG_ATH9K_TX99
956 +void ath9k_tx99_init_debug(struct ath_softc *sc);
957  int ath9k_tx99_send(struct ath_softc *sc, struct sk_buff *skb,
958                     struct ath_tx_control *txctl);
959 +#else
960 +static inline void ath9k_tx99_init_debug(struct ath_softc *sc)
961 +{
962 +}
963 +static inline int ath9k_tx99_send(struct ath_softc *sc,
964 +                                 struct sk_buff *skb,
965 +                                 struct ath_tx_control *txctl)
966 +{
967 +       return 0;
968 +}
969 +#endif /* CONFIG_ATH9K_TX99 */
970  
971  void ath9k_tasklet(unsigned long data);
972  int ath_cabq_update(struct ath_softc *);
973 @@ -966,6 +1013,9 @@ extern bool is_ath9k_unloaded;
974  
975  u8 ath9k_parse_mpdudensity(u8 mpdudensity);
976  irqreturn_t ath_isr(int irq, void *dev);
977 +int ath_reset(struct ath_softc *sc);
978 +void ath_cancel_work(struct ath_softc *sc);
979 +void ath_restart_work(struct ath_softc *sc);
980  int ath9k_init_device(u16 devid, struct ath_softc *sc,
981                     const struct ath_bus_ops *bus_ops);
982  void ath9k_deinit_device(struct ath_softc *sc);
983 --- a/drivers/net/wireless/ath/ath9k/debug.c
984 +++ b/drivers/net/wireless/ath/ath9k/debug.c
985 @@ -1782,111 +1782,6 @@ void ath9k_deinit_debug(struct ath_softc
986         }
987  }
988  
989 -static ssize_t read_file_tx99(struct file *file, char __user *user_buf,
990 -                             size_t count, loff_t *ppos)
991 -{
992 -       struct ath_softc *sc = file->private_data;
993 -       char buf[3];
994 -       unsigned int len;
995 -
996 -       len = sprintf(buf, "%d\n", sc->tx99_state);
997 -       return simple_read_from_buffer(user_buf, count, ppos, buf, len);
998 -}
999 -
1000 -static ssize_t write_file_tx99(struct file *file, const char __user *user_buf,
1001 -                              size_t count, loff_t *ppos)
1002 -{
1003 -       struct ath_softc *sc = file->private_data;
1004 -       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1005 -       char buf[32];
1006 -       bool start;
1007 -       ssize_t len;
1008 -       int r;
1009 -
1010 -       if (sc->nvifs > 1)
1011 -               return -EOPNOTSUPP;
1012 -
1013 -       len = min(count, sizeof(buf) - 1);
1014 -       if (copy_from_user(buf, user_buf, len))
1015 -               return -EFAULT;
1016 -
1017 -       if (strtobool(buf, &start))
1018 -               return -EINVAL;
1019 -
1020 -       if (start == sc->tx99_state) {
1021 -               if (!start)
1022 -                       return count;
1023 -               ath_dbg(common, XMIT, "Resetting TX99\n");
1024 -               ath9k_tx99_deinit(sc);
1025 -       }
1026 -
1027 -       if (!start) {
1028 -               ath9k_tx99_deinit(sc);
1029 -               return count;
1030 -       }
1031 -
1032 -       r = ath9k_tx99_init(sc);
1033 -       if (r)
1034 -               return r;
1035 -
1036 -       return count;
1037 -}
1038 -
1039 -static const struct file_operations fops_tx99 = {
1040 -       .read = read_file_tx99,
1041 -       .write = write_file_tx99,
1042 -       .open = simple_open,
1043 -       .owner = THIS_MODULE,
1044 -       .llseek = default_llseek,
1045 -};
1046 -
1047 -static ssize_t read_file_tx99_power(struct file *file,
1048 -                                   char __user *user_buf,
1049 -                                   size_t count, loff_t *ppos)
1050 -{
1051 -       struct ath_softc *sc = file->private_data;
1052 -       char buf[32];
1053 -       unsigned int len;
1054 -
1055 -       len = sprintf(buf, "%d (%d dBm)\n",
1056 -                     sc->tx99_power,
1057 -                     sc->tx99_power / 2);
1058 -
1059 -       return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1060 -}
1061 -
1062 -static ssize_t write_file_tx99_power(struct file *file,
1063 -                                    const char __user *user_buf,
1064 -                                    size_t count, loff_t *ppos)
1065 -{
1066 -       struct ath_softc *sc = file->private_data;
1067 -       int r;
1068 -       u8 tx_power;
1069 -
1070 -       r = kstrtou8_from_user(user_buf, count, 0, &tx_power);
1071 -       if (r)
1072 -               return r;
1073 -
1074 -       if (tx_power > MAX_RATE_POWER)
1075 -               return -EINVAL;
1076 -
1077 -       sc->tx99_power = tx_power;
1078 -
1079 -       ath9k_ps_wakeup(sc);
1080 -       ath9k_hw_tx99_set_txpower(sc->sc_ah, sc->tx99_power);
1081 -       ath9k_ps_restore(sc);
1082 -
1083 -       return count;
1084 -}
1085 -
1086 -static const struct file_operations fops_tx99_power = {
1087 -       .read = read_file_tx99_power,
1088 -       .write = write_file_tx99_power,
1089 -       .open = simple_open,
1090 -       .owner = THIS_MODULE,
1091 -       .llseek = default_llseek,
1092 -};
1093 -
1094  int ath9k_init_debug(struct ath_hw *ah)
1095  {
1096         struct ath_common *common = ath9k_hw_common(ah);
1097 @@ -1903,6 +1798,7 @@ int ath9k_init_debug(struct ath_hw *ah)
1098  #endif
1099  
1100         ath9k_dfs_init_debug(sc);
1101 +       ath9k_tx99_init_debug(sc);
1102  
1103         debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy, sc,
1104                             &fops_dma);
1105 @@ -1978,15 +1874,6 @@ int ath9k_init_debug(struct ath_hw *ah)
1106         debugfs_create_file("btcoex", S_IRUSR, sc->debug.debugfs_phy, sc,
1107                             &fops_btcoex);
1108  #endif
1109 -       if (config_enabled(CPTCFG_ATH9K_TX99) &&
1110 -           AR_SREV_9300_20_OR_LATER(ah)) {
1111 -               debugfs_create_file("tx99", S_IRUSR | S_IWUSR,
1112 -                                   sc->debug.debugfs_phy, sc,
1113 -                                   &fops_tx99);
1114 -               debugfs_create_file("tx99_power", S_IRUSR | S_IWUSR,
1115 -                                   sc->debug.debugfs_phy, sc,
1116 -                                   &fops_tx99_power);
1117 -       }
1118  
1119         return 0;
1120  }
1121 --- a/drivers/net/wireless/ath/ath9k/hw.c
1122 +++ b/drivers/net/wireless/ath/ath9k/hw.c
1123 @@ -17,6 +17,7 @@
1124  #include <linux/io.h>
1125  #include <linux/slab.h>
1126  #include <linux/module.h>
1127 +#include <linux/time.h>
1128  #include <asm/unaligned.h>
1129  
1130  #include "hw.h"
1131 @@ -454,7 +455,6 @@ static void ath9k_hw_init_config(struct 
1132         }
1133  
1134         ah->config.rx_intr_mitigation = true;
1135 -       ah->config.pcieSerDesWrite = true;
1136  
1137         /*
1138          * We need this for PCI devices only (Cardbus, PCI, miniPCI)
1139 @@ -549,11 +549,11 @@ static int ath9k_hw_post_init(struct ath
1140          * EEPROM needs to be initialized before we do this.
1141          * This is required for regulatory compliance.
1142          */
1143 -       if (AR_SREV_9462(ah) || AR_SREV_9565(ah)) {
1144 +       if (AR_SREV_9300_20_OR_LATER(ah)) {
1145                 u16 regdmn = ah->eep_ops->get_eeprom(ah, EEP_REG_0);
1146                 if ((regdmn & 0xF0) == CTL_FCC) {
1147 -                       ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9462_FCC_2GHZ;
1148 -                       ah->nf_5g.max = AR_PHY_CCA_MAX_GOOD_VAL_9462_FCC_5GHZ;
1149 +                       ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9300_FCC_2GHZ;
1150 +                       ah->nf_5g.max = AR_PHY_CCA_MAX_GOOD_VAL_9300_FCC_5GHZ;
1151                 }
1152         }
1153  
1154 @@ -1502,8 +1502,9 @@ static bool ath9k_hw_channel_change(stru
1155         int r;
1156  
1157         if (pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH) {
1158 -               band_switch = IS_CHAN_5GHZ(ah->curchan) != IS_CHAN_5GHZ(chan);
1159 -               mode_diff = (chan->channelFlags != ah->curchan->channelFlags);
1160 +               u32 flags_diff = chan->channelFlags ^ ah->curchan->channelFlags;
1161 +               band_switch = !!(flags_diff & CHANNEL_5GHZ);
1162 +               mode_diff = !!(flags_diff & ~CHANNEL_HT);
1163         }
1164  
1165         for (qnum = 0; qnum < AR_NUM_QCU; qnum++) {
1166 @@ -1815,7 +1816,7 @@ static int ath9k_hw_do_fastcc(struct ath
1167          * If cross-band fcc is not supoprted, bail out if channelFlags differ.
1168          */
1169         if (!(pCap->hw_caps & ATH9K_HW_CAP_FCC_BAND_SWITCH) &&
1170 -           chan->channelFlags != ah->curchan->channelFlags)
1171 +           ((chan->channelFlags ^ ah->curchan->channelFlags) & ~CHANNEL_HT))
1172                 goto fail;
1173  
1174         if (!ath9k_hw_check_alive(ah))
1175 @@ -1856,10 +1857,12 @@ int ath9k_hw_reset(struct ath_hw *ah, st
1176                    struct ath9k_hw_cal_data *caldata, bool fastcc)
1177  {
1178         struct ath_common *common = ath9k_hw_common(ah);
1179 +       struct timespec ts;
1180         u32 saveLedState;
1181         u32 saveDefAntenna;
1182         u32 macStaId1;
1183         u64 tsf = 0;
1184 +       s64 usec = 0;
1185         int r;
1186         bool start_mci_reset = false;
1187         bool save_fullsleep = ah->chip_fullsleep;
1188 @@ -1902,10 +1905,10 @@ int ath9k_hw_reset(struct ath_hw *ah, st
1189  
1190         macStaId1 = REG_READ(ah, AR_STA_ID1) & AR_STA_ID1_BASE_RATE_11B;
1191  
1192 -       /* For chips on which RTC reset is done, save TSF before it gets cleared */
1193 -       if (AR_SREV_9100(ah) ||
1194 -           (AR_SREV_9280(ah) && ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL)))
1195 -               tsf = ath9k_hw_gettsf64(ah);
1196 +       /* Save TSF before chip reset, a cold reset clears it */
1197 +       tsf = ath9k_hw_gettsf64(ah);
1198 +       getrawmonotonic(&ts);
1199 +       usec = ts.tv_sec * 1000 + ts.tv_nsec / 1000;
1200  
1201         saveLedState = REG_READ(ah, AR_CFG_LED) &
1202                 (AR_CFG_LED_ASSOC_CTL | AR_CFG_LED_MODE_SEL |
1203 @@ -1938,8 +1941,9 @@ int ath9k_hw_reset(struct ath_hw *ah, st
1204         }
1205  
1206         /* Restore TSF */
1207 -       if (tsf)
1208 -               ath9k_hw_settsf64(ah, tsf);
1209 +       getrawmonotonic(&ts);
1210 +       usec = ts.tv_sec * 1000 + ts.tv_nsec / 1000 - usec;
1211 +       ath9k_hw_settsf64(ah, tsf + usec);
1212  
1213         if (AR_SREV_9280_20_OR_LATER(ah))
1214                 REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, AR_GPIO_JTAG_DISABLE);
1215 --- a/drivers/net/wireless/ath/ath9k/hw.h
1216 +++ b/drivers/net/wireless/ath/ath9k/hw.h
1217 @@ -283,7 +283,6 @@ struct ath9k_ops_config {
1218         int additional_swba_backoff;
1219         int ack_6mb;
1220         u32 cwm_ignore_extcca;
1221 -       bool pcieSerDesWrite;
1222         u8 pcie_clock_req;
1223         u32 pcie_waen;
1224         u8 analog_shiftreg;
1225 @@ -316,6 +315,8 @@ struct ath9k_ops_config {
1226         u32 ant_ctrl_comm2g_switch_enable;
1227         bool xatten_margin_cfg;
1228         bool alt_mingainidx;
1229 +       bool no_pll_pwrsave;
1230 +       bool tx_gain_buffalo;
1231  };
1232  
1233  enum ath9k_int {
1234 @@ -864,6 +865,7 @@ struct ath_hw {
1235         u32 gpio_mask;
1236         u32 gpio_val;
1237  
1238 +       struct ar5416IniArray ini_dfs;
1239         struct ar5416IniArray iniModes;
1240         struct ar5416IniArray iniCommon;
1241         struct ar5416IniArray iniBB_RfGain;
1242 @@ -920,7 +922,7 @@ struct ath_hw {
1243         /* Enterprise mode cap */
1244         u32 ent_mode;
1245  
1246 -#ifdef CONFIG_PM_SLEEP
1247 +#ifdef CONFIG_ATH9K_WOW
1248         u32 wow_event_mask;
1249  #endif
1250         bool is_clk_25mhz;
1251 @@ -1126,7 +1128,7 @@ ath9k_hw_get_btcoex_scheme(struct ath_hw
1252  #endif /* CPTCFG_ATH9K_BTCOEX_SUPPORT */
1253  
1254  
1255 -#ifdef CONFIG_PM_SLEEP
1256 +#ifdef CONFIG_ATH9K_WOW
1257  const char *ath9k_hw_wow_event_to_string(u32 wow_event);
1258  void ath9k_hw_wow_apply_pattern(struct ath_hw *ah, u8 *user_pattern,
1259                                 u8 *user_mask, int pattern_count,
1260 --- a/drivers/net/wireless/ath/ath9k/init.c
1261 +++ b/drivers/net/wireless/ath/ath9k/init.c
1262 @@ -554,7 +554,7 @@ static void ath9k_init_misc(struct ath_s
1263         sc->spec_config.fft_period = 0xF;
1264  }
1265  
1266 -static void ath9k_init_platform(struct ath_softc *sc)
1267 +static void ath9k_init_pcoem_platform(struct ath_softc *sc)
1268  {
1269         struct ath_hw *ah = sc->sc_ah;
1270         struct ath9k_hw_capabilities *pCap = &ah->caps;
1271 @@ -609,6 +609,11 @@ static void ath9k_init_platform(struct a
1272                 ah->config.pcie_waen = 0x0040473b;
1273                 ath_info(common, "Enable WAR for ASPM D3/L1\n");
1274         }
1275 +
1276 +       if (sc->driver_data & ATH9K_PCI_NO_PLL_PWRSAVE) {
1277 +               ah->config.no_pll_pwrsave = true;
1278 +               ath_info(common, "Disable PLL PowerSave\n");
1279 +       }
1280  }
1281  
1282  static void ath9k_eeprom_request_cb(const struct firmware *eeprom_blob,
1283 @@ -656,6 +661,27 @@ static void ath9k_eeprom_release(struct 
1284         release_firmware(sc->sc_ah->eeprom_blob);
1285  }
1286  
1287 +static int ath9k_init_soc_platform(struct ath_softc *sc)
1288 +{
1289 +       struct ath9k_platform_data *pdata = sc->dev->platform_data;
1290 +       struct ath_hw *ah = sc->sc_ah;
1291 +       int ret = 0;
1292 +
1293 +       if (!pdata)
1294 +               return 0;
1295 +
1296 +       if (pdata->eeprom_name) {
1297 +               ret = ath9k_eeprom_request(sc, pdata->eeprom_name);
1298 +               if (ret)
1299 +                       return ret;
1300 +       }
1301 +
1302 +       if (pdata->tx_gain_buffalo)
1303 +               ah->config.tx_gain_buffalo = true;
1304 +
1305 +       return ret;
1306 +}
1307 +
1308  static int ath9k_init_softc(u16 devid, struct ath_softc *sc,
1309                             const struct ath_bus_ops *bus_ops)
1310  {
1311 @@ -683,6 +709,7 @@ static int ath9k_init_softc(u16 devid, s
1312         common = ath9k_hw_common(ah);
1313         sc->dfs_detector = dfs_pattern_detector_init(common, NL80211_DFS_UNSET);
1314         sc->tx99_power = MAX_RATE_POWER + 1;
1315 +       init_waitqueue_head(&sc->tx_wait);
1316  
1317         if (!pdata) {
1318                 ah->ah_flags |= AH_USE_EEPROM;
1319 @@ -708,7 +735,11 @@ static int ath9k_init_softc(u16 devid, s
1320         /*
1321          * Platform quirks.
1322          */
1323 -       ath9k_init_platform(sc);
1324 +       ath9k_init_pcoem_platform(sc);
1325 +
1326 +       ret = ath9k_init_soc_platform(sc);
1327 +       if (ret)
1328 +               return ret;
1329  
1330         /*
1331          * Enable WLAN/BT RX Antenna diversity only when:
1332 @@ -722,7 +753,6 @@ static int ath9k_init_softc(u16 devid, s
1333                 common->bt_ant_diversity = 1;
1334  
1335         spin_lock_init(&common->cc_lock);
1336 -
1337         spin_lock_init(&sc->sc_serial_rw);
1338         spin_lock_init(&sc->sc_pm_lock);
1339         mutex_init(&sc->mutex);
1340 @@ -730,6 +760,7 @@ static int ath9k_init_softc(u16 devid, s
1341         tasklet_init(&sc->bcon_tasklet, ath9k_beacon_tasklet,
1342                      (unsigned long)sc);
1343  
1344 +       setup_timer(&sc->sleep_timer, ath_ps_full_sleep, (unsigned long)sc);
1345         INIT_WORK(&sc->hw_reset_work, ath_reset_work);
1346         INIT_WORK(&sc->hw_check_work, ath_hw_check);
1347         INIT_WORK(&sc->paprd_work, ath_paprd_calibrate);
1348 @@ -743,12 +774,6 @@ static int ath9k_init_softc(u16 devid, s
1349         ath_read_cachesize(common, &csz);
1350         common->cachelsz = csz << 2; /* convert to bytes */
1351  
1352 -       if (pdata && pdata->eeprom_name) {
1353 -               ret = ath9k_eeprom_request(sc, pdata->eeprom_name);
1354 -               if (ret)
1355 -                       return ret;
1356 -       }
1357 -
1358         /* Initializes the hardware for all supported chipsets */
1359         ret = ath9k_hw_init(ah);
1360         if (ret)
1361 @@ -845,7 +870,8 @@ static const struct ieee80211_iface_limi
1362  };
1363  
1364  static const struct ieee80211_iface_limit if_dfs_limits[] = {
1365 -       { .max = 1,     .types = BIT(NL80211_IFTYPE_AP) },
1366 +       { .max = 1,     .types = BIT(NL80211_IFTYPE_AP) |
1367 +                                BIT(NL80211_IFTYPE_ADHOC) },
1368  };
1369  
1370  static const struct ieee80211_iface_combination if_comb[] = {
1371 @@ -862,20 +888,11 @@ static const struct ieee80211_iface_comb
1372                 .max_interfaces = 1,
1373                 .num_different_channels = 1,
1374                 .beacon_int_infra_match = true,
1375 -               .radar_detect_widths =  BIT(NL80211_CHAN_NO_HT) |
1376 -                                       BIT(NL80211_CHAN_HT20),
1377 +               .radar_detect_widths =  BIT(NL80211_CHAN_WIDTH_20_NOHT) |
1378 +                                       BIT(NL80211_CHAN_WIDTH_20),
1379         }
1380  };
1381  
1382 -#ifdef CONFIG_PM
1383 -static const struct wiphy_wowlan_support ath9k_wowlan_support = {
1384 -       .flags = WIPHY_WOWLAN_MAGIC_PKT | WIPHY_WOWLAN_DISCONNECT,
1385 -       .n_patterns = MAX_NUM_USER_PATTERN,
1386 -       .pattern_min_len = 1,
1387 -       .pattern_max_len = MAX_PATTERN_SIZE,
1388 -};
1389 -#endif
1390 -
1391  void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
1392  {
1393         struct ath_hw *ah = sc->sc_ah;
1394 @@ -925,16 +942,6 @@ void ath9k_set_hw_capab(struct ath_softc
1395         hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_5_10_MHZ;
1396         hw->wiphy->flags |= WIPHY_FLAG_HAS_CHANNEL_SWITCH;
1397  
1398 -#ifdef CONFIG_PM_SLEEP
1399 -       if ((ah->caps.hw_caps & ATH9K_HW_WOW_DEVICE_CAPABLE) &&
1400 -           (sc->driver_data & ATH9K_PCI_WOW) &&
1401 -           device_can_wakeup(sc->dev))
1402 -               hw->wiphy->wowlan = &ath9k_wowlan_support;
1403 -
1404 -       atomic_set(&sc->wow_sleep_proc_intr, -1);
1405 -       atomic_set(&sc->wow_got_bmiss_intr, -1);
1406 -#endif
1407 -
1408         hw->queues = 4;
1409         hw->max_rates = 4;
1410         hw->channel_change_time = 5000;
1411 @@ -960,6 +967,7 @@ void ath9k_set_hw_capab(struct ath_softc
1412                 hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
1413                         &sc->sbands[IEEE80211_BAND_5GHZ];
1414  
1415 +       ath9k_init_wow(hw);
1416         ath9k_reload_chainmask_settings(sc);
1417  
1418         SET_IEEE80211_PERM_ADDR(hw, common->macaddr);
1419 @@ -1058,6 +1066,7 @@ static void ath9k_deinit_softc(struct at
1420                 if (ATH_TXQ_SETUP(sc, i))
1421                         ath_tx_cleanupq(sc, &sc->tx.txq[i]);
1422  
1423 +       del_timer_sync(&sc->sleep_timer);
1424         ath9k_hw_deinit(sc->sc_ah);
1425         if (sc->dfs_detector != NULL)
1426                 sc->dfs_detector->exit(sc->dfs_detector);
1427 --- a/drivers/net/wireless/ath/ath9k/main.c
1428 +++ b/drivers/net/wireless/ath/ath9k/main.c
1429 @@ -82,6 +82,22 @@ static bool ath9k_setpower(struct ath_so
1430         return ret;
1431  }
1432  
1433 +void ath_ps_full_sleep(unsigned long data)
1434 +{
1435 +       struct ath_softc *sc = (struct ath_softc *) data;
1436 +       struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1437 +       bool reset;
1438 +
1439 +       spin_lock(&common->cc_lock);
1440 +       ath_hw_cycle_counters_update(common);
1441 +       spin_unlock(&common->cc_lock);
1442 +
1443 +       ath9k_hw_setrxabort(sc->sc_ah, 1);
1444 +       ath9k_hw_stopdmarecv(sc->sc_ah, &reset);
1445 +
1446 +       ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_FULL_SLEEP);
1447 +}
1448 +
1449  void ath9k_ps_wakeup(struct ath_softc *sc)
1450  {
1451         struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1452 @@ -92,6 +108,7 @@ void ath9k_ps_wakeup(struct ath_softc *s
1453         if (++sc->ps_usecount != 1)
1454                 goto unlock;
1455  
1456 +       del_timer_sync(&sc->sleep_timer);
1457         power_mode = sc->sc_ah->power_mode;
1458         ath9k_hw_setpower(sc->sc_ah, ATH9K_PM_AWAKE);
1459  
1460 @@ -117,17 +134,17 @@ void ath9k_ps_restore(struct ath_softc *
1461         struct ath_common *common = ath9k_hw_common(sc->sc_ah);
1462         enum ath9k_power_mode mode;
1463         unsigned long flags;
1464 -       bool reset;
1465  
1466         spin_lock_irqsave(&sc->sc_pm_lock, flags);
1467         if (--sc->ps_usecount != 0)
1468                 goto unlock;
1469  
1470         if (sc->ps_idle) {
1471 -               ath9k_hw_setrxabort(sc->sc_ah, 1);
1472 -               ath9k_hw_stopdmarecv(sc->sc_ah, &reset);
1473 -               mode = ATH9K_PM_FULL_SLEEP;
1474 -       } else if (sc->ps_enabled &&
1475 +               mod_timer(&sc->sleep_timer, jiffies + HZ / 10);
1476 +               goto unlock;
1477 +       }
1478 +
1479 +       if (sc->ps_enabled &&
1480                    !(sc->ps_flags & (PS_WAIT_FOR_BEACON |
1481                                      PS_WAIT_FOR_CAB |
1482                                      PS_WAIT_FOR_PSPOLL_DATA |
1483 @@ -163,13 +180,13 @@ static void __ath_cancel_work(struct ath
1484  #endif
1485  }
1486  
1487 -static void ath_cancel_work(struct ath_softc *sc)
1488 +void ath_cancel_work(struct ath_softc *sc)
1489  {
1490         __ath_cancel_work(sc);
1491         cancel_work_sync(&sc->hw_reset_work);
1492  }
1493  
1494 -static void ath_restart_work(struct ath_softc *sc)
1495 +void ath_restart_work(struct ath_softc *sc)
1496  {
1497         ieee80211_queue_delayed_work(sc->hw, &sc->tx_complete_work, 0);
1498  
1499 @@ -487,6 +504,8 @@ void ath9k_tasklet(unsigned long data)
1500                         ath_tx_edma_tasklet(sc);
1501                 else
1502                         ath_tx_tasklet(sc);
1503 +
1504 +               wake_up(&sc->tx_wait);
1505         }
1506  
1507         ath9k_btcoex_handle_interrupt(sc, status);
1508 @@ -579,7 +598,8 @@ irqreturn_t ath_isr(int irq, void *dev)
1509  
1510                 goto chip_reset;
1511         }
1512 -#ifdef CONFIG_PM_SLEEP
1513 +
1514 +#ifdef CONFIG_ATH9K_WOW
1515         if (status & ATH9K_INT_BMISS) {
1516                 if (atomic_read(&sc->wow_sleep_proc_intr) == 0) {
1517                         ath_dbg(common, ANY, "during WoW we got a BMISS\n");
1518 @@ -588,6 +608,8 @@ irqreturn_t ath_isr(int irq, void *dev)
1519                 }
1520         }
1521  #endif
1522 +
1523 +
1524         if (status & ATH9K_INT_SWBA)
1525                 tasklet_schedule(&sc->bcon_tasklet);
1526  
1527 @@ -627,7 +649,7 @@ chip_reset:
1528  #undef SCHED_INTR
1529  }
1530  
1531 -static int ath_reset(struct ath_softc *sc)
1532 +int ath_reset(struct ath_softc *sc)
1533  {
1534         int r;
1535  
1536 @@ -1817,13 +1839,31 @@ static void ath9k_set_coverage_class(str
1537         mutex_unlock(&sc->mutex);
1538  }
1539  
1540 +static bool ath9k_has_tx_pending(struct ath_softc *sc)
1541 +{
1542 +       int i, npend;
1543 +
1544 +       for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
1545 +               if (!ATH_TXQ_SETUP(sc, i))
1546 +                       continue;
1547 +
1548 +               if (!sc->tx.txq[i].axq_depth)
1549 +                       continue;
1550 +
1551 +               npend = ath9k_has_pending_frames(sc, &sc->tx.txq[i]);
1552 +               if (npend)
1553 +                       break;
1554 +       }
1555 +
1556 +       return !!npend;
1557 +}
1558 +
1559  static void ath9k_flush(struct ieee80211_hw *hw, u32 queues, bool drop)
1560  {
1561         struct ath_softc *sc = hw->priv;
1562         struct ath_hw *ah = sc->sc_ah;
1563         struct ath_common *common = ath9k_hw_common(ah);
1564 -       int timeout = 200; /* ms */
1565 -       int i, j;
1566 +       int timeout = HZ / 5; /* 200 ms */
1567         bool drain_txq;
1568  
1569         mutex_lock(&sc->mutex);
1570 @@ -1841,25 +1881,9 @@ static void ath9k_flush(struct ieee80211
1571                 return;
1572         }
1573  
1574 -       for (j = 0; j < timeout; j++) {
1575 -               bool npend = false;
1576 -
1577 -               if (j)
1578 -                       usleep_range(1000, 2000);
1579 -
1580 -               for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) {
1581 -                       if (!ATH_TXQ_SETUP(sc, i))
1582 -                               continue;
1583 -
1584 -                       npend = ath9k_has_pending_frames(sc, &sc->tx.txq[i]);
1585 -
1586 -                       if (npend)
1587 -                               break;
1588 -               }
1589 -
1590 -               if (!npend)
1591 -                   break;
1592 -       }
1593 +       if (wait_event_timeout(sc->tx_wait, !ath9k_has_tx_pending(sc),
1594 +                              timeout) > 0)
1595 +               drop = false;
1596  
1597         if (drop) {
1598                 ath9k_ps_wakeup(sc);
1599 @@ -2021,333 +2045,6 @@ static int ath9k_get_antenna(struct ieee
1600         return 0;
1601  }
1602  
1603 -#ifdef CONFIG_PM_SLEEP
1604 -
1605 -static void ath9k_wow_map_triggers(struct ath_softc *sc,
1606 -                                  struct cfg80211_wowlan *wowlan,
1607 -                                  u32 *wow_triggers)
1608 -{
1609 -       if (wowlan->disconnect)
1610 -               *wow_triggers |= AH_WOW_LINK_CHANGE |
1611 -                                AH_WOW_BEACON_MISS;
1612 -       if (wowlan->magic_pkt)
1613 -               *wow_triggers |= AH_WOW_MAGIC_PATTERN_EN;
1614 -
1615 -       if (wowlan->n_patterns)
1616 -               *wow_triggers |= AH_WOW_USER_PATTERN_EN;
1617 -
1618 -       sc->wow_enabled = *wow_triggers;
1619 -
1620 -}
1621 -
1622 -static void ath9k_wow_add_disassoc_deauth_pattern(struct ath_softc *sc)
1623 -{
1624 -       struct ath_hw *ah = sc->sc_ah;
1625 -       struct ath_common *common = ath9k_hw_common(ah);
1626 -       int pattern_count = 0;
1627 -       int i, byte_cnt;
1628 -       u8 dis_deauth_pattern[MAX_PATTERN_SIZE];
1629 -       u8 dis_deauth_mask[MAX_PATTERN_SIZE];
1630 -
1631 -       memset(dis_deauth_pattern, 0, MAX_PATTERN_SIZE);
1632 -       memset(dis_deauth_mask, 0, MAX_PATTERN_SIZE);
1633 -
1634 -       /*
1635 -        * Create Dissassociate / Deauthenticate packet filter
1636 -        *
1637 -        *     2 bytes        2 byte    6 bytes   6 bytes  6 bytes
1638 -        *  +--------------+----------+---------+--------+--------+----
1639 -        *  + Frame Control+ Duration +   DA    +  SA    +  BSSID +
1640 -        *  +--------------+----------+---------+--------+--------+----
1641 -        *
1642 -        * The above is the management frame format for disassociate/
1643 -        * deauthenticate pattern, from this we need to match the first byte
1644 -        * of 'Frame Control' and DA, SA, and BSSID fields
1645 -        * (skipping 2nd byte of FC and Duration feild.
1646 -        *
1647 -        * Disassociate pattern
1648 -        * --------------------
1649 -        * Frame control = 00 00 1010
1650 -        * DA, SA, BSSID = x:x:x:x:x:x
1651 -        * Pattern will be A0000000 | x:x:x:x:x:x | x:x:x:x:x:x
1652 -        *                          | x:x:x:x:x:x  -- 22 bytes
1653 -        *
1654 -        * Deauthenticate pattern
1655 -        * ----------------------
1656 -        * Frame control = 00 00 1100
1657 -        * DA, SA, BSSID = x:x:x:x:x:x
1658 -        * Pattern will be C0000000 | x:x:x:x:x:x | x:x:x:x:x:x
1659 -        *                          | x:x:x:x:x:x  -- 22 bytes
1660 -        */
1661 -
1662 -       /* Create Disassociate Pattern first */
1663 -
1664 -       byte_cnt = 0;
1665 -
1666 -       /* Fill out the mask with all FF's */
1667 -
1668 -       for (i = 0; i < MAX_PATTERN_MASK_SIZE; i++)
1669 -               dis_deauth_mask[i] = 0xff;
1670 -
1671 -       /* copy the first byte of frame control field */
1672 -       dis_deauth_pattern[byte_cnt] = 0xa0;
1673 -       byte_cnt++;
1674 -
1675 -       /* skip 2nd byte of frame control and Duration field */
1676 -       byte_cnt += 3;
1677 -
1678 -       /*
1679 -        * need not match the destination mac address, it can be a broadcast
1680 -        * mac address or an unicast to this station
1681 -        */
1682 -       byte_cnt += 6;
1683 -
1684 -       /* copy the source mac address */
1685 -       memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN);
1686 -
1687 -       byte_cnt += 6;
1688 -
1689 -       /* copy the bssid, its same as the source mac address */
1690 -
1691 -       memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN);
1692 -
1693 -       /* Create Disassociate pattern mask */
1694 -
1695 -       dis_deauth_mask[0] = 0xfe;
1696 -       dis_deauth_mask[1] = 0x03;
1697 -       dis_deauth_mask[2] = 0xc0;
1698 -
1699 -       ath_dbg(common, WOW, "Adding disassoc/deauth patterns for WoW\n");
1700 -
1701 -       ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask,
1702 -                                  pattern_count, byte_cnt);
1703 -
1704 -       pattern_count++;
1705 -       /*
1706 -        * for de-authenticate pattern, only the first byte of the frame
1707 -        * control field gets changed from 0xA0 to 0xC0
1708 -        */
1709 -       dis_deauth_pattern[0] = 0xC0;
1710 -
1711 -       ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask,
1712 -                                  pattern_count, byte_cnt);
1713 -
1714 -}
1715 -
1716 -static void ath9k_wow_add_pattern(struct ath_softc *sc,
1717 -                                 struct cfg80211_wowlan *wowlan)
1718 -{
1719 -       struct ath_hw *ah = sc->sc_ah;
1720 -       struct ath9k_wow_pattern *wow_pattern = NULL;
1721 -       struct cfg80211_pkt_pattern *patterns = wowlan->patterns;
1722 -       int mask_len;
1723 -       s8 i = 0;
1724 -
1725 -       if (!wowlan->n_patterns)
1726 -               return;
1727 -
1728 -       /*
1729 -        * Add the new user configured patterns
1730 -        */
1731 -       for (i = 0; i < wowlan->n_patterns; i++) {
1732 -
1733 -               wow_pattern = kzalloc(sizeof(*wow_pattern), GFP_KERNEL);
1734 -
1735 -               if (!wow_pattern)
1736 -                       return;
1737 -
1738 -               /*
1739 -                * TODO: convert the generic user space pattern to
1740 -                * appropriate chip specific/802.11 pattern.
1741 -                */
1742 -
1743 -               mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8);
1744 -               memset(wow_pattern->pattern_bytes, 0, MAX_PATTERN_SIZE);
1745 -               memset(wow_pattern->mask_bytes, 0, MAX_PATTERN_SIZE);
1746 -               memcpy(wow_pattern->pattern_bytes, patterns[i].pattern,
1747 -                      patterns[i].pattern_len);
1748 -               memcpy(wow_pattern->mask_bytes, patterns[i].mask, mask_len);
1749 -               wow_pattern->pattern_len = patterns[i].pattern_len;
1750 -
1751 -               /*
1752 -                * just need to take care of deauth and disssoc pattern,
1753 -                * make sure we don't overwrite them.
1754 -                */
1755 -
1756 -               ath9k_hw_wow_apply_pattern(ah, wow_pattern->pattern_bytes,
1757 -                                          wow_pattern->mask_bytes,
1758 -                                          i + 2,
1759 -                                          wow_pattern->pattern_len);
1760 -               kfree(wow_pattern);
1761 -
1762 -       }
1763 -
1764 -}
1765 -
1766 -static int ath9k_suspend(struct ieee80211_hw *hw,
1767 -                        struct cfg80211_wowlan *wowlan)
1768 -{
1769 -       struct ath_softc *sc = hw->priv;
1770 -       struct ath_hw *ah = sc->sc_ah;
1771 -       struct ath_common *common = ath9k_hw_common(ah);
1772 -       u32 wow_triggers_enabled = 0;
1773 -       int ret = 0;
1774 -
1775 -       mutex_lock(&sc->mutex);
1776 -
1777 -       ath_cancel_work(sc);
1778 -       ath_stop_ani(sc);
1779 -       del_timer_sync(&sc->rx_poll_timer);
1780 -
1781 -       if (test_bit(SC_OP_INVALID, &sc->sc_flags)) {
1782 -               ath_dbg(common, ANY, "Device not present\n");
1783 -               ret = -EINVAL;
1784 -               goto fail_wow;
1785 -       }
1786 -
1787 -       if (WARN_ON(!wowlan)) {
1788 -               ath_dbg(common, WOW, "None of the WoW triggers enabled\n");
1789 -               ret = -EINVAL;
1790 -               goto fail_wow;
1791 -       }
1792 -
1793 -       if (!device_can_wakeup(sc->dev)) {
1794 -               ath_dbg(common, WOW, "device_can_wakeup failed, WoW is not enabled\n");
1795 -               ret = 1;
1796 -               goto fail_wow;
1797 -       }
1798 -
1799 -       /*
1800 -        * none of the sta vifs are associated
1801 -        * and we are not currently handling multivif
1802 -        * cases, for instance we have to seperately
1803 -        * configure 'keep alive frame' for each
1804 -        * STA.
1805 -        */
1806 -
1807 -       if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) {
1808 -               ath_dbg(common, WOW, "None of the STA vifs are associated\n");
1809 -               ret = 1;
1810 -               goto fail_wow;
1811 -       }
1812 -
1813 -       if (sc->nvifs > 1) {
1814 -               ath_dbg(common, WOW, "WoW for multivif is not yet supported\n");
1815 -               ret = 1;
1816 -               goto fail_wow;
1817 -       }
1818 -
1819 -       ath9k_wow_map_triggers(sc, wowlan, &wow_triggers_enabled);
1820 -
1821 -       ath_dbg(common, WOW, "WoW triggers enabled 0x%x\n",
1822 -               wow_triggers_enabled);
1823 -
1824 -       ath9k_ps_wakeup(sc);
1825 -
1826 -       ath9k_stop_btcoex(sc);
1827 -
1828 -       /*
1829 -        * Enable wake up on recieving disassoc/deauth
1830 -        * frame by default.
1831 -        */
1832 -       ath9k_wow_add_disassoc_deauth_pattern(sc);
1833 -
1834 -       if (wow_triggers_enabled & AH_WOW_USER_PATTERN_EN)
1835 -               ath9k_wow_add_pattern(sc, wowlan);
1836 -
1837 -       spin_lock_bh(&sc->sc_pcu_lock);
1838 -       /*
1839 -        * To avoid false wake, we enable beacon miss interrupt only
1840 -        * when we go to sleep. We save the current interrupt mask
1841 -        * so we can restore it after the system wakes up
1842 -        */
1843 -       sc->wow_intr_before_sleep = ah->imask;
1844 -       ah->imask &= ~ATH9K_INT_GLOBAL;
1845 -       ath9k_hw_disable_interrupts(ah);
1846 -       ah->imask = ATH9K_INT_BMISS | ATH9K_INT_GLOBAL;
1847 -       ath9k_hw_set_interrupts(ah);
1848 -       ath9k_hw_enable_interrupts(ah);
1849 -
1850 -       spin_unlock_bh(&sc->sc_pcu_lock);
1851 -
1852 -       /*
1853 -        * we can now sync irq and kill any running tasklets, since we already
1854 -        * disabled interrupts and not holding a spin lock
1855 -        */
1856 -       synchronize_irq(sc->irq);
1857 -       tasklet_kill(&sc->intr_tq);
1858 -
1859 -       ath9k_hw_wow_enable(ah, wow_triggers_enabled);
1860 -
1861 -       ath9k_ps_restore(sc);
1862 -       ath_dbg(common, ANY, "WoW enabled in ath9k\n");
1863 -       atomic_inc(&sc->wow_sleep_proc_intr);
1864 -
1865 -fail_wow:
1866 -       mutex_unlock(&sc->mutex);
1867 -       return ret;
1868 -}
1869 -
1870 -static int ath9k_resume(struct ieee80211_hw *hw)
1871 -{
1872 -       struct ath_softc *sc = hw->priv;
1873 -       struct ath_hw *ah = sc->sc_ah;
1874 -       struct ath_common *common = ath9k_hw_common(ah);
1875 -       u32 wow_status;
1876 -
1877 -       mutex_lock(&sc->mutex);
1878 -
1879 -       ath9k_ps_wakeup(sc);
1880 -
1881 -       spin_lock_bh(&sc->sc_pcu_lock);
1882 -
1883 -       ath9k_hw_disable_interrupts(ah);
1884 -       ah->imask = sc->wow_intr_before_sleep;
1885 -       ath9k_hw_set_interrupts(ah);
1886 -       ath9k_hw_enable_interrupts(ah);
1887 -
1888 -       spin_unlock_bh(&sc->sc_pcu_lock);
1889 -
1890 -       wow_status = ath9k_hw_wow_wakeup(ah);
1891 -
1892 -       if (atomic_read(&sc->wow_got_bmiss_intr) == 0) {
1893 -               /*
1894 -                * some devices may not pick beacon miss
1895 -                * as the reason they woke up so we add
1896 -                * that here for that shortcoming.
1897 -                */
1898 -               wow_status |= AH_WOW_BEACON_MISS;
1899 -               atomic_dec(&sc->wow_got_bmiss_intr);
1900 -               ath_dbg(common, ANY, "Beacon miss interrupt picked up during WoW sleep\n");
1901 -       }
1902 -
1903 -       atomic_dec(&sc->wow_sleep_proc_intr);
1904 -
1905 -       if (wow_status) {
1906 -               ath_dbg(common, ANY, "Waking up due to WoW triggers %s with WoW status = %x\n",
1907 -                       ath9k_hw_wow_event_to_string(wow_status), wow_status);
1908 -       }
1909 -
1910 -       ath_restart_work(sc);
1911 -       ath9k_start_btcoex(sc);
1912 -
1913 -       ath9k_ps_restore(sc);
1914 -       mutex_unlock(&sc->mutex);
1915 -
1916 -       return 0;
1917 -}
1918 -
1919 -static void ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled)
1920 -{
1921 -       struct ath_softc *sc = hw->priv;
1922 -
1923 -       mutex_lock(&sc->mutex);
1924 -       device_init_wakeup(sc->dev, 1);
1925 -       device_set_wakeup_enable(sc->dev, enabled);
1926 -       mutex_unlock(&sc->mutex);
1927 -}
1928 -
1929 -#endif
1930  static void ath9k_sw_scan_start(struct ieee80211_hw *hw)
1931  {
1932         struct ath_softc *sc = hw->priv;
1933 @@ -2373,134 +2070,6 @@ static void ath9k_channel_switch_beacon(
1934         sc->csa_vif = vif;
1935  }
1936  
1937 -static void ath9k_tx99_stop(struct ath_softc *sc)
1938 -{
1939 -       struct ath_hw *ah = sc->sc_ah;
1940 -       struct ath_common *common = ath9k_hw_common(ah);
1941 -
1942 -       ath_drain_all_txq(sc);
1943 -       ath_startrecv(sc);
1944 -
1945 -       ath9k_hw_set_interrupts(ah);
1946 -       ath9k_hw_enable_interrupts(ah);
1947 -
1948 -       ieee80211_wake_queues(sc->hw);
1949 -
1950 -       kfree_skb(sc->tx99_skb);
1951 -       sc->tx99_skb = NULL;
1952 -       sc->tx99_state = false;
1953 -
1954 -       ath9k_hw_tx99_stop(sc->sc_ah);
1955 -       ath_dbg(common, XMIT, "TX99 stopped\n");
1956 -}
1957 -
1958 -static struct sk_buff *ath9k_build_tx99_skb(struct ath_softc *sc)
1959 -{
1960 -       static u8 PN9Data[] = {0xff, 0x87, 0xb8, 0x59, 0xb7, 0xa1, 0xcc, 0x24,
1961 -                              0x57, 0x5e, 0x4b, 0x9c, 0x0e, 0xe9, 0xea, 0x50,
1962 -                              0x2a, 0xbe, 0xb4, 0x1b, 0xb6, 0xb0, 0x5d, 0xf1,
1963 -                              0xe6, 0x9a, 0xe3, 0x45, 0xfd, 0x2c, 0x53, 0x18,
1964 -                              0x0c, 0xca, 0xc9, 0xfb, 0x49, 0x37, 0xe5, 0xa8,
1965 -                              0x51, 0x3b, 0x2f, 0x61, 0xaa, 0x72, 0x18, 0x84,
1966 -                              0x02, 0x23, 0x23, 0xab, 0x63, 0x89, 0x51, 0xb3,
1967 -                              0xe7, 0x8b, 0x72, 0x90, 0x4c, 0xe8, 0xfb, 0xc0};
1968 -       u32 len = 1200;
1969 -       struct ieee80211_hw *hw = sc->hw;
1970 -       struct ieee80211_hdr *hdr;
1971 -       struct ieee80211_tx_info *tx_info;
1972 -       struct sk_buff *skb;
1973 -
1974 -       skb = alloc_skb(len, GFP_KERNEL);
1975 -       if (!skb)
1976 -               return NULL;
1977 -
1978 -       skb_put(skb, len);
1979 -
1980 -       memset(skb->data, 0, len);
1981 -
1982 -       hdr = (struct ieee80211_hdr *)skb->data;
1983 -       hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA);
1984 -       hdr->duration_id = 0;
1985 -
1986 -       memcpy(hdr->addr1, hw->wiphy->perm_addr, ETH_ALEN);
1987 -       memcpy(hdr->addr2, hw->wiphy->perm_addr, ETH_ALEN);
1988 -       memcpy(hdr->addr3, hw->wiphy->perm_addr, ETH_ALEN);
1989 -
1990 -       hdr->seq_ctrl |= cpu_to_le16(sc->tx.seq_no);
1991 -
1992 -       tx_info = IEEE80211_SKB_CB(skb);
1993 -       memset(tx_info, 0, sizeof(*tx_info));
1994 -       tx_info->band = hw->conf.chandef.chan->band;
1995 -       tx_info->flags = IEEE80211_TX_CTL_NO_ACK;
1996 -       tx_info->control.vif = sc->tx99_vif;
1997 -
1998 -       memcpy(skb->data + sizeof(*hdr), PN9Data, sizeof(PN9Data));
1999 -
2000 -       return skb;
2001 -}
2002 -
2003 -void ath9k_tx99_deinit(struct ath_softc *sc)
2004 -{
2005 -       ath_reset(sc);
2006 -
2007 -       ath9k_ps_wakeup(sc);
2008 -       ath9k_tx99_stop(sc);
2009 -       ath9k_ps_restore(sc);
2010 -}
2011 -
2012 -int ath9k_tx99_init(struct ath_softc *sc)
2013 -{
2014 -       struct ieee80211_hw *hw = sc->hw;
2015 -       struct ath_hw *ah = sc->sc_ah;
2016 -       struct ath_common *common = ath9k_hw_common(ah);
2017 -       struct ath_tx_control txctl;
2018 -       int r;
2019 -
2020 -       if (sc->sc_flags & SC_OP_INVALID) {
2021 -               ath_err(common,
2022 -                       "driver is in invalid state unable to use TX99");
2023 -               return -EINVAL;
2024 -       }
2025 -
2026 -       sc->tx99_skb = ath9k_build_tx99_skb(sc);
2027 -       if (!sc->tx99_skb)
2028 -               return -ENOMEM;
2029 -
2030 -       memset(&txctl, 0, sizeof(txctl));
2031 -       txctl.txq = sc->tx.txq_map[IEEE80211_AC_VO];
2032 -
2033 -       ath_reset(sc);
2034 -
2035 -       ath9k_ps_wakeup(sc);
2036 -
2037 -       ath9k_hw_disable_interrupts(ah);
2038 -       atomic_set(&ah->intr_ref_cnt, -1);
2039 -       ath_drain_all_txq(sc);
2040 -       ath_stoprecv(sc);
2041 -
2042 -       sc->tx99_state = true;
2043 -
2044 -       ieee80211_stop_queues(hw);
2045 -
2046 -       if (sc->tx99_power == MAX_RATE_POWER + 1)
2047 -               sc->tx99_power = MAX_RATE_POWER;
2048 -
2049 -       ath9k_hw_tx99_set_txpower(ah, sc->tx99_power);
2050 -       r = ath9k_tx99_send(sc, sc->tx99_skb, &txctl);
2051 -       if (r) {
2052 -               ath_dbg(common, XMIT, "Failed to xmit TX99 skb\n");
2053 -               return r;
2054 -       }
2055 -
2056 -       ath_dbg(common, XMIT, "TX99 xmit started using %d ( %ddBm)\n",
2057 -               sc->tx99_power,
2058 -               sc->tx99_power / 2);
2059 -
2060 -       /* We leave the harware awake as it will be chugging on */
2061 -
2062 -       return 0;
2063 -}
2064 -
2065  struct ieee80211_ops ath9k_ops = {
2066         .tx                 = ath9k_tx,
2067         .start              = ath9k_start,
2068 @@ -2531,7 +2100,7 @@ struct ieee80211_ops ath9k_ops = {
2069         .set_antenna        = ath9k_set_antenna,
2070         .get_antenna        = ath9k_get_antenna,
2071  
2072 -#ifdef CONFIG_PM_SLEEP
2073 +#ifdef CONFIG_ATH9K_WOW
2074         .suspend            = ath9k_suspend,
2075         .resume             = ath9k_resume,
2076         .set_wakeup         = ath9k_set_wakeup,
2077 --- a/drivers/net/wireless/ath/ath9k/wow.c
2078 +++ b/drivers/net/wireless/ath/ath9k/wow.c
2079 @@ -1,5 +1,5 @@
2080  /*
2081 - * Copyright (c) 2012 Qualcomm Atheros, Inc.
2082 + * Copyright (c) 2013 Qualcomm Atheros, Inc.
2083   *
2084   * Permission to use, copy, modify, and/or distribute this software for any
2085   * purpose with or without fee is hereby granted, provided that the above
2086 @@ -14,409 +14,348 @@
2087   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2088   */
2089  
2090 -#include <linux/export.h>
2091  #include "ath9k.h"
2092 -#include "reg.h"
2093 -#include "hw-ops.h"
2094  
2095 -const char *ath9k_hw_wow_event_to_string(u32 wow_event)
2096 +static const struct wiphy_wowlan_support ath9k_wowlan_support = {
2097 +       .flags = WIPHY_WOWLAN_MAGIC_PKT | WIPHY_WOWLAN_DISCONNECT,
2098 +       .n_patterns = MAX_NUM_USER_PATTERN,
2099 +       .pattern_min_len = 1,
2100 +       .pattern_max_len = MAX_PATTERN_SIZE,
2101 +};
2102 +
2103 +static void ath9k_wow_map_triggers(struct ath_softc *sc,
2104 +                                  struct cfg80211_wowlan *wowlan,
2105 +                                  u32 *wow_triggers)
2106  {
2107 -       if (wow_event & AH_WOW_MAGIC_PATTERN_EN)
2108 -               return "Magic pattern";
2109 -       if (wow_event & AH_WOW_USER_PATTERN_EN)
2110 -               return "User pattern";
2111 -       if (wow_event & AH_WOW_LINK_CHANGE)
2112 -               return "Link change";
2113 -       if (wow_event & AH_WOW_BEACON_MISS)
2114 -               return "Beacon miss";
2115 +       if (wowlan->disconnect)
2116 +               *wow_triggers |= AH_WOW_LINK_CHANGE |
2117 +                                AH_WOW_BEACON_MISS;
2118 +       if (wowlan->magic_pkt)
2119 +               *wow_triggers |= AH_WOW_MAGIC_PATTERN_EN;
2120 +
2121 +       if (wowlan->n_patterns)
2122 +               *wow_triggers |= AH_WOW_USER_PATTERN_EN;
2123 +
2124 +       sc->wow_enabled = *wow_triggers;
2125  
2126 -       return  "unknown reason";
2127  }
2128 -EXPORT_SYMBOL(ath9k_hw_wow_event_to_string);
2129  
2130 -static void ath9k_hw_set_powermode_wow_sleep(struct ath_hw *ah)
2131 +static void ath9k_wow_add_disassoc_deauth_pattern(struct ath_softc *sc)
2132  {
2133 +       struct ath_hw *ah = sc->sc_ah;
2134         struct ath_common *common = ath9k_hw_common(ah);
2135 +       int pattern_count = 0;
2136 +       int i, byte_cnt;
2137 +       u8 dis_deauth_pattern[MAX_PATTERN_SIZE];
2138 +       u8 dis_deauth_mask[MAX_PATTERN_SIZE];
2139  
2140 -       REG_SET_BIT(ah, AR_STA_ID1, AR_STA_ID1_PWR_SAV);
2141 +       memset(dis_deauth_pattern, 0, MAX_PATTERN_SIZE);
2142 +       memset(dis_deauth_mask, 0, MAX_PATTERN_SIZE);
2143  
2144 -       /* set rx disable bit */
2145 -       REG_WRITE(ah, AR_CR, AR_CR_RXD);
2146 +       /*
2147 +        * Create Dissassociate / Deauthenticate packet filter
2148 +        *
2149 +        *     2 bytes        2 byte    6 bytes   6 bytes  6 bytes
2150 +        *  +--------------+----------+---------+--------+--------+----
2151 +        *  + Frame Control+ Duration +   DA    +  SA    +  BSSID +
2152 +        *  +--------------+----------+---------+--------+--------+----
2153 +        *
2154 +        * The above is the management frame format for disassociate/
2155 +        * deauthenticate pattern, from this we need to match the first byte
2156 +        * of 'Frame Control' and DA, SA, and BSSID fields
2157 +        * (skipping 2nd byte of FC and Duration feild.
2158 +        *
2159 +        * Disassociate pattern
2160 +        * --------------------
2161 +        * Frame control = 00 00 1010
2162 +        * DA, SA, BSSID = x:x:x:x:x:x
2163 +        * Pattern will be A0000000 | x:x:x:x:x:x | x:x:x:x:x:x
2164 +        *                          | x:x:x:x:x:x  -- 22 bytes
2165 +        *
2166 +        * Deauthenticate pattern
2167 +        * ----------------------
2168 +        * Frame control = 00 00 1100
2169 +        * DA, SA, BSSID = x:x:x:x:x:x
2170 +        * Pattern will be C0000000 | x:x:x:x:x:x | x:x:x:x:x:x
2171 +        *                          | x:x:x:x:x:x  -- 22 bytes
2172 +        */
2173  
2174 -       if (!ath9k_hw_wait(ah, AR_CR, AR_CR_RXE, 0, AH_WAIT_TIMEOUT)) {
2175 -               ath_err(common, "Failed to stop Rx DMA in 10ms AR_CR=0x%08x AR_DIAG_SW=0x%08x\n",
2176 -                       REG_READ(ah, AR_CR), REG_READ(ah, AR_DIAG_SW));
2177 -               return;
2178 -       }
2179 +       /* Create Disassociate Pattern first */
2180  
2181 -       REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_ON_INT);
2182 -}
2183 +       byte_cnt = 0;
2184  
2185 -static void ath9k_wow_create_keep_alive_pattern(struct ath_hw *ah)
2186 -{
2187 -       struct ath_common *common = ath9k_hw_common(ah);
2188 -       u8 sta_mac_addr[ETH_ALEN], ap_mac_addr[ETH_ALEN];
2189 -       u32 ctl[13] = {0};
2190 -       u32 data_word[KAL_NUM_DATA_WORDS];
2191 -       u8 i;
2192 -       u32 wow_ka_data_word0;
2193 -
2194 -       memcpy(sta_mac_addr, common->macaddr, ETH_ALEN);
2195 -       memcpy(ap_mac_addr, common->curbssid, ETH_ALEN);
2196 -
2197 -       /* set the transmit buffer */
2198 -       ctl[0] = (KAL_FRAME_LEN | (MAX_RATE_POWER << 16));
2199 -       ctl[1] = 0;
2200 -       ctl[3] = 0xb;   /* OFDM_6M hardware value for this rate */
2201 -       ctl[4] = 0;
2202 -       ctl[7] = (ah->txchainmask) << 2;
2203 -       ctl[2] = 0xf << 16; /* tx_tries 0 */
2204 -
2205 -       for (i = 0; i < KAL_NUM_DESC_WORDS; i++)
2206 -               REG_WRITE(ah, (AR_WOW_KA_DESC_WORD2 + i * 4), ctl[i]);
2207 -
2208 -       REG_WRITE(ah, (AR_WOW_KA_DESC_WORD2 + i * 4), ctl[i]);
2209 -
2210 -       data_word[0] = (KAL_FRAME_TYPE << 2) | (KAL_FRAME_SUB_TYPE << 4) |
2211 -                      (KAL_TO_DS << 8) | (KAL_DURATION_ID << 16);
2212 -       data_word[1] = (ap_mac_addr[3] << 24) | (ap_mac_addr[2] << 16) |
2213 -                      (ap_mac_addr[1] << 8) | (ap_mac_addr[0]);
2214 -       data_word[2] = (sta_mac_addr[1] << 24) | (sta_mac_addr[0] << 16) |
2215 -                      (ap_mac_addr[5] << 8) | (ap_mac_addr[4]);
2216 -       data_word[3] = (sta_mac_addr[5] << 24) | (sta_mac_addr[4] << 16) |
2217 -                      (sta_mac_addr[3] << 8) | (sta_mac_addr[2]);
2218 -       data_word[4] = (ap_mac_addr[3] << 24) | (ap_mac_addr[2] << 16) |
2219 -                      (ap_mac_addr[1] << 8) | (ap_mac_addr[0]);
2220 -       data_word[5] = (ap_mac_addr[5] << 8) | (ap_mac_addr[4]);
2221 -
2222 -       if (AR_SREV_9462_20(ah)) {
2223 -               /* AR9462 2.0 has an extra descriptor word (time based
2224 -                * discard) compared to other chips */
2225 -               REG_WRITE(ah, (AR_WOW_KA_DESC_WORD2 + (12 * 4)), 0);
2226 -               wow_ka_data_word0 = AR_WOW_TXBUF(13);
2227 -       } else {
2228 -               wow_ka_data_word0 = AR_WOW_TXBUF(12);
2229 -       }
2230 +       /* Fill out the mask with all FF's */
2231  
2232 -       for (i = 0; i < KAL_NUM_DATA_WORDS; i++)
2233 -               REG_WRITE(ah, (wow_ka_data_word0 + i*4), data_word[i]);
2234 +       for (i = 0; i < MAX_PATTERN_MASK_SIZE; i++)
2235 +               dis_deauth_mask[i] = 0xff;
2236  
2237 -}
2238 +       /* copy the first byte of frame control field */
2239 +       dis_deauth_pattern[byte_cnt] = 0xa0;
2240 +       byte_cnt++;
2241  
2242 -void ath9k_hw_wow_apply_pattern(struct ath_hw *ah, u8 *user_pattern,
2243 -                               u8 *user_mask, int pattern_count,
2244 -                               int pattern_len)
2245 -{
2246 -       int i;
2247 -       u32 pattern_val, mask_val;
2248 -       u32 set, clr;
2249 +       /* skip 2nd byte of frame control and Duration field */
2250 +       byte_cnt += 3;
2251  
2252 -       /* FIXME: should check count by querying the hardware capability */
2253 -       if (pattern_count >= MAX_NUM_PATTERN)
2254 -               return;
2255 +       /*
2256 +        * need not match the destination mac address, it can be a broadcast
2257 +        * mac address or an unicast to this station
2258 +        */
2259 +       byte_cnt += 6;
2260  
2261 -       REG_SET_BIT(ah, AR_WOW_PATTERN, BIT(pattern_count));
2262 +       /* copy the source mac address */
2263 +       memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN);
2264  
2265 -       /* set the registers for pattern */
2266 -       for (i = 0; i < MAX_PATTERN_SIZE; i += 4) {
2267 -               memcpy(&pattern_val, user_pattern, 4);
2268 -               REG_WRITE(ah, (AR_WOW_TB_PATTERN(pattern_count) + i),
2269 -                         pattern_val);
2270 -               user_pattern += 4;
2271 -       }
2272 +       byte_cnt += 6;
2273  
2274 -       /* set the registers for mask */
2275 -       for (i = 0; i < MAX_PATTERN_MASK_SIZE; i += 4) {
2276 -               memcpy(&mask_val, user_mask, 4);
2277 -               REG_WRITE(ah, (AR_WOW_TB_MASK(pattern_count) + i), mask_val);
2278 -               user_mask += 4;
2279 -       }
2280 +       /* copy the bssid, its same as the source mac address */
2281  
2282 -       /* set the pattern length to be matched
2283 -        *
2284 -        * AR_WOW_LENGTH1_REG1
2285 -        * bit 31:24 pattern 0 length
2286 -        * bit 23:16 pattern 1 length
2287 -        * bit 15:8 pattern 2 length
2288 -        * bit 7:0 pattern 3 length
2289 -        *
2290 -        * AR_WOW_LENGTH1_REG2
2291 -        * bit 31:24 pattern 4 length
2292 -        * bit 23:16 pattern 5 length
2293 -        * bit 15:8 pattern 6 length
2294 -        * bit 7:0 pattern 7 length
2295 -        *
2296 -        * the below logic writes out the new
2297 -        * pattern length for the corresponding
2298 -        * pattern_count, while masking out the
2299 -        * other fields
2300 -        */
2301 +       memcpy((dis_deauth_pattern + byte_cnt), common->curbssid, ETH_ALEN);
2302  
2303 -       ah->wow_event_mask |= BIT(pattern_count + AR_WOW_PAT_FOUND_SHIFT);
2304 +       /* Create Disassociate pattern mask */
2305  
2306 -       if (pattern_count < 4) {
2307 -               /* Pattern 0-3 uses AR_WOW_LENGTH1 register */
2308 -               set = (pattern_len & AR_WOW_LENGTH_MAX) <<
2309 -                      AR_WOW_LEN1_SHIFT(pattern_count);
2310 -               clr = AR_WOW_LENGTH1_MASK(pattern_count);
2311 -               REG_RMW(ah, AR_WOW_LENGTH1, set, clr);
2312 -       } else {
2313 -               /* Pattern 4-7 uses AR_WOW_LENGTH2 register */
2314 -               set = (pattern_len & AR_WOW_LENGTH_MAX) <<
2315 -                      AR_WOW_LEN2_SHIFT(pattern_count);
2316 -               clr = AR_WOW_LENGTH2_MASK(pattern_count);
2317 -               REG_RMW(ah, AR_WOW_LENGTH2, set, clr);
2318 -       }
2319 +       dis_deauth_mask[0] = 0xfe;
2320 +       dis_deauth_mask[1] = 0x03;
2321 +       dis_deauth_mask[2] = 0xc0;
2322  
2323 -}
2324 -EXPORT_SYMBOL(ath9k_hw_wow_apply_pattern);
2325 +       ath_dbg(common, WOW, "Adding disassoc/deauth patterns for WoW\n");
2326  
2327 -u32 ath9k_hw_wow_wakeup(struct ath_hw *ah)
2328 -{
2329 -       u32 wow_status = 0;
2330 -       u32 val = 0, rval;
2331 +       ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask,
2332 +                                  pattern_count, byte_cnt);
2333  
2334 +       pattern_count++;
2335         /*
2336 -        * read the WoW status register to know
2337 -        * the wakeup reason
2338 +        * for de-authenticate pattern, only the first byte of the frame
2339 +        * control field gets changed from 0xA0 to 0xC0
2340          */
2341 -       rval = REG_READ(ah, AR_WOW_PATTERN);
2342 -       val = AR_WOW_STATUS(rval);
2343 +       dis_deauth_pattern[0] = 0xC0;
2344  
2345 -       /*
2346 -        * mask only the WoW events that we have enabled. Sometimes
2347 -        * we have spurious WoW events from the AR_WOW_PATTERN
2348 -        * register. This mask will clean it up.
2349 -        */
2350 +       ath9k_hw_wow_apply_pattern(ah, dis_deauth_pattern, dis_deauth_mask,
2351 +                                  pattern_count, byte_cnt);
2352  
2353 -       val &= ah->wow_event_mask;
2354 +}
2355  
2356 -       if (val) {
2357 -               if (val & AR_WOW_MAGIC_PAT_FOUND)
2358 -                       wow_status |= AH_WOW_MAGIC_PATTERN_EN;
2359 -               if (AR_WOW_PATTERN_FOUND(val))
2360 -                       wow_status |= AH_WOW_USER_PATTERN_EN;
2361 -               if (val & AR_WOW_KEEP_ALIVE_FAIL)
2362 -                       wow_status |= AH_WOW_LINK_CHANGE;
2363 -               if (val & AR_WOW_BEACON_FAIL)
2364 -                       wow_status |= AH_WOW_BEACON_MISS;
2365 -       }
2366 +static void ath9k_wow_add_pattern(struct ath_softc *sc,
2367 +                                 struct cfg80211_wowlan *wowlan)
2368 +{
2369 +       struct ath_hw *ah = sc->sc_ah;
2370 +       struct ath9k_wow_pattern *wow_pattern = NULL;
2371 +       struct cfg80211_pkt_pattern *patterns = wowlan->patterns;
2372 +       int mask_len;
2373 +       s8 i = 0;
2374 +
2375 +       if (!wowlan->n_patterns)
2376 +               return;
2377  
2378         /*
2379 -        * set and clear WOW_PME_CLEAR registers for the chip to
2380 -        * generate next wow signal.
2381 -        * disable D3 before accessing other registers ?
2382 +        * Add the new user configured patterns
2383          */
2384 +       for (i = 0; i < wowlan->n_patterns; i++) {
2385  
2386 -       /* do we need to check the bit value 0x01000000 (7-10) ?? */
2387 -       REG_RMW(ah, AR_PCIE_PM_CTRL, AR_PMCTRL_WOW_PME_CLR,
2388 -               AR_PMCTRL_PWR_STATE_D1D3);
2389 +               wow_pattern = kzalloc(sizeof(*wow_pattern), GFP_KERNEL);
2390  
2391 -       /*
2392 -        * clear all events
2393 -        */
2394 -       REG_WRITE(ah, AR_WOW_PATTERN,
2395 -                 AR_WOW_CLEAR_EVENTS(REG_READ(ah, AR_WOW_PATTERN)));
2396 +               if (!wow_pattern)
2397 +                       return;
2398  
2399 -       /*
2400 -        * restore the beacon threshold to init value
2401 -        */
2402 -       REG_WRITE(ah, AR_RSSI_THR, INIT_RSSI_THR);
2403 +               /*
2404 +                * TODO: convert the generic user space pattern to
2405 +                * appropriate chip specific/802.11 pattern.
2406 +                */
2407  
2408 -       /*
2409 -        * Restore the way the PCI-E reset, Power-On-Reset, external
2410 -        * PCIE_POR_SHORT pins are tied to its original value.
2411 -        * Previously just before WoW sleep, we untie the PCI-E
2412 -        * reset to our Chip's Power On Reset so that any PCI-E
2413 -        * reset from the bus will not reset our chip
2414 -        */
2415 -       if (ah->is_pciexpress)
2416 -               ath9k_hw_configpcipowersave(ah, false);
2417 +               mask_len = DIV_ROUND_UP(wowlan->patterns[i].pattern_len, 8);
2418 +               memset(wow_pattern->pattern_bytes, 0, MAX_PATTERN_SIZE);
2419 +               memset(wow_pattern->mask_bytes, 0, MAX_PATTERN_SIZE);
2420 +               memcpy(wow_pattern->pattern_bytes, patterns[i].pattern,
2421 +                      patterns[i].pattern_len);
2422 +               memcpy(wow_pattern->mask_bytes, patterns[i].mask, mask_len);
2423 +               wow_pattern->pattern_len = patterns[i].pattern_len;
2424 +
2425 +               /*
2426 +                * just need to take care of deauth and disssoc pattern,
2427 +                * make sure we don't overwrite them.
2428 +                */
2429 +
2430 +               ath9k_hw_wow_apply_pattern(ah, wow_pattern->pattern_bytes,
2431 +                                          wow_pattern->mask_bytes,
2432 +                                          i + 2,
2433 +                                          wow_pattern->pattern_len);
2434 +               kfree(wow_pattern);
2435  
2436 -       ah->wow_event_mask = 0;
2437 +       }
2438  
2439 -       return wow_status;
2440  }
2441 -EXPORT_SYMBOL(ath9k_hw_wow_wakeup);
2442  
2443 -void ath9k_hw_wow_enable(struct ath_hw *ah, u32 pattern_enable)
2444 +int ath9k_suspend(struct ieee80211_hw *hw,
2445 +                 struct cfg80211_wowlan *wowlan)
2446  {
2447 -       u32 wow_event_mask;
2448 -       u32 set, clr;
2449 +       struct ath_softc *sc = hw->priv;
2450 +       struct ath_hw *ah = sc->sc_ah;
2451 +       struct ath_common *common = ath9k_hw_common(ah);
2452 +       u32 wow_triggers_enabled = 0;
2453 +       int ret = 0;
2454  
2455 -       /*
2456 -        * wow_event_mask is a mask to the AR_WOW_PATTERN register to
2457 -        * indicate which WoW events we have enabled. The WoW events
2458 -        * are from the 'pattern_enable' in this function and
2459 -        * 'pattern_count' of ath9k_hw_wow_apply_pattern()
2460 -        */
2461 -       wow_event_mask = ah->wow_event_mask;
2462 +       mutex_lock(&sc->mutex);
2463  
2464 -       /*
2465 -        * Untie Power-on-Reset from the PCI-E-Reset. When we are in
2466 -        * WOW sleep, we do want the Reset from the PCI-E to disturb
2467 -        * our hw state
2468 -        */
2469 -       if (ah->is_pciexpress) {
2470 -               /*
2471 -                * we need to untie the internal POR (power-on-reset)
2472 -                * to the external PCI-E reset. We also need to tie
2473 -                * the PCI-E Phy reset to the PCI-E reset.
2474 -                */
2475 -               set = AR_WA_RESET_EN | AR_WA_POR_SHORT;
2476 -               clr = AR_WA_UNTIE_RESET_EN | AR_WA_D3_L1_DISABLE;
2477 -               REG_RMW(ah, AR_WA, set, clr);
2478 +       ath_cancel_work(sc);
2479 +       ath_stop_ani(sc);
2480 +       del_timer_sync(&sc->rx_poll_timer);
2481 +
2482 +       if (test_bit(SC_OP_INVALID, &sc->sc_flags)) {
2483 +               ath_dbg(common, ANY, "Device not present\n");
2484 +               ret = -EINVAL;
2485 +               goto fail_wow;
2486         }
2487  
2488 -       /*
2489 -        * set the power states appropriately and enable PME
2490 -        */
2491 -       set = AR_PMCTRL_HOST_PME_EN | AR_PMCTRL_PWR_PM_CTRL_ENA |
2492 -             AR_PMCTRL_AUX_PWR_DET | AR_PMCTRL_WOW_PME_CLR;
2493 +       if (WARN_ON(!wowlan)) {
2494 +               ath_dbg(common, WOW, "None of the WoW triggers enabled\n");
2495 +               ret = -EINVAL;
2496 +               goto fail_wow;
2497 +       }
2498  
2499 -       /*
2500 -        * set and clear WOW_PME_CLEAR registers for the chip
2501 -        * to generate next wow signal.
2502 -        */
2503 -       REG_SET_BIT(ah, AR_PCIE_PM_CTRL, set);
2504 -       clr = AR_PMCTRL_WOW_PME_CLR;
2505 -       REG_CLR_BIT(ah, AR_PCIE_PM_CTRL, clr);
2506 +       if (!device_can_wakeup(sc->dev)) {
2507 +               ath_dbg(common, WOW, "device_can_wakeup failed, WoW is not enabled\n");
2508 +               ret = 1;
2509 +               goto fail_wow;
2510 +       }
2511  
2512         /*
2513 -        * Setup for:
2514 -        *      - beacon misses
2515 -        *      - magic pattern
2516 -        *      - keep alive timeout
2517 -        *      - pattern matching
2518 +        * none of the sta vifs are associated
2519 +        * and we are not currently handling multivif
2520 +        * cases, for instance we have to seperately
2521 +        * configure 'keep alive frame' for each
2522 +        * STA.
2523          */
2524  
2525 -       /*
2526 -        * Program default values for pattern backoff, aifs/slot/KAL count,
2527 -        * beacon miss timeout, KAL timeout, etc.
2528 -        */
2529 -       set = AR_WOW_BACK_OFF_SHIFT(AR_WOW_PAT_BACKOFF);
2530 -       REG_SET_BIT(ah, AR_WOW_PATTERN, set);
2531 +       if (!test_bit(SC_OP_PRIM_STA_VIF, &sc->sc_flags)) {
2532 +               ath_dbg(common, WOW, "None of the STA vifs are associated\n");
2533 +               ret = 1;
2534 +               goto fail_wow;
2535 +       }
2536 +
2537 +       if (sc->nvifs > 1) {
2538 +               ath_dbg(common, WOW, "WoW for multivif is not yet supported\n");
2539 +               ret = 1;
2540 +               goto fail_wow;
2541 +       }
2542  
2543 -       set = AR_WOW_AIFS_CNT(AR_WOW_CNT_AIFS_CNT) |
2544 -             AR_WOW_SLOT_CNT(AR_WOW_CNT_SLOT_CNT) |
2545 -             AR_WOW_KEEP_ALIVE_CNT(AR_WOW_CNT_KA_CNT);
2546 -       REG_SET_BIT(ah, AR_WOW_COUNT, set);
2547 -
2548 -       if (pattern_enable & AH_WOW_BEACON_MISS)
2549 -               set = AR_WOW_BEACON_TIMO;
2550 -       /* We are not using beacon miss, program a large value */
2551 -       else
2552 -               set = AR_WOW_BEACON_TIMO_MAX;
2553 +       ath9k_wow_map_triggers(sc, wowlan, &wow_triggers_enabled);
2554  
2555 -       REG_WRITE(ah, AR_WOW_BCN_TIMO, set);
2556 +       ath_dbg(common, WOW, "WoW triggers enabled 0x%x\n",
2557 +               wow_triggers_enabled);
2558  
2559 -       /*
2560 -        * Keep alive timo in ms except AR9280
2561 -        */
2562 -       if (!pattern_enable)
2563 -               set = AR_WOW_KEEP_ALIVE_NEVER;
2564 -       else
2565 -               set = KAL_TIMEOUT * 32;
2566 +       ath9k_ps_wakeup(sc);
2567  
2568 -       REG_WRITE(ah, AR_WOW_KEEP_ALIVE_TIMO, set);
2569 +       ath9k_stop_btcoex(sc);
2570  
2571         /*
2572 -        * Keep alive delay in us. based on 'power on clock',
2573 -        * therefore in usec
2574 +        * Enable wake up on recieving disassoc/deauth
2575 +        * frame by default.
2576          */
2577 -       set = KAL_DELAY * 1000;
2578 -       REG_WRITE(ah, AR_WOW_KEEP_ALIVE_DELAY, set);
2579 +       ath9k_wow_add_disassoc_deauth_pattern(sc);
2580  
2581 -       /*
2582 -        * Create keep alive pattern to respond to beacons
2583 -        */
2584 -       ath9k_wow_create_keep_alive_pattern(ah);
2585 +       if (wow_triggers_enabled & AH_WOW_USER_PATTERN_EN)
2586 +               ath9k_wow_add_pattern(sc, wowlan);
2587  
2588 +       spin_lock_bh(&sc->sc_pcu_lock);
2589         /*
2590 -        * Configure MAC WoW Registers
2591 +        * To avoid false wake, we enable beacon miss interrupt only
2592 +        * when we go to sleep. We save the current interrupt mask
2593 +        * so we can restore it after the system wakes up
2594          */
2595 -       set = 0;
2596 -       /* Send keep alive timeouts anyway */
2597 -       clr = AR_WOW_KEEP_ALIVE_AUTO_DIS;
2598 -
2599 -       if (pattern_enable & AH_WOW_LINK_CHANGE)
2600 -               wow_event_mask |= AR_WOW_KEEP_ALIVE_FAIL;
2601 -       else
2602 -               set = AR_WOW_KEEP_ALIVE_FAIL_DIS;
2603 +       sc->wow_intr_before_sleep = ah->imask;
2604 +       ah->imask &= ~ATH9K_INT_GLOBAL;
2605 +       ath9k_hw_disable_interrupts(ah);
2606 +       ah->imask = ATH9K_INT_BMISS | ATH9K_INT_GLOBAL;
2607 +       ath9k_hw_set_interrupts(ah);
2608 +       ath9k_hw_enable_interrupts(ah);
2609  
2610 -       set = AR_WOW_KEEP_ALIVE_FAIL_DIS;
2611 -       REG_RMW(ah, AR_WOW_KEEP_ALIVE, set, clr);
2612 +       spin_unlock_bh(&sc->sc_pcu_lock);
2613  
2614         /*
2615 -        * we are relying on a bmiss failure. ensure we have
2616 -        * enough threshold to prevent false positives
2617 +        * we can now sync irq and kill any running tasklets, since we already
2618 +        * disabled interrupts and not holding a spin lock
2619          */
2620 -       REG_RMW_FIELD(ah, AR_RSSI_THR, AR_RSSI_THR_BM_THR,
2621 -                     AR_WOW_BMISSTHRESHOLD);
2622 +       synchronize_irq(sc->irq);
2623 +       tasklet_kill(&sc->intr_tq);
2624 +
2625 +       ath9k_hw_wow_enable(ah, wow_triggers_enabled);
2626  
2627 -       set = 0;
2628 -       clr = 0;
2629 +       ath9k_ps_restore(sc);
2630 +       ath_dbg(common, ANY, "WoW enabled in ath9k\n");
2631 +       atomic_inc(&sc->wow_sleep_proc_intr);
2632  
2633 -       if (pattern_enable & AH_WOW_BEACON_MISS) {
2634 -               set = AR_WOW_BEACON_FAIL_EN;
2635 -               wow_event_mask |= AR_WOW_BEACON_FAIL;
2636 -       } else {
2637 -               clr = AR_WOW_BEACON_FAIL_EN;
2638 +fail_wow:
2639 +       mutex_unlock(&sc->mutex);
2640 +       return ret;
2641 +}
2642 +
2643 +int ath9k_resume(struct ieee80211_hw *hw)
2644 +{
2645 +       struct ath_softc *sc = hw->priv;
2646 +       struct ath_hw *ah = sc->sc_ah;
2647 +       struct ath_common *common = ath9k_hw_common(ah);
2648 +       u32 wow_status;
2649 +
2650 +       mutex_lock(&sc->mutex);
2651 +
2652 +       ath9k_ps_wakeup(sc);
2653 +
2654 +       spin_lock_bh(&sc->sc_pcu_lock);
2655 +
2656 +       ath9k_hw_disable_interrupts(ah);
2657 +       ah->imask = sc->wow_intr_before_sleep;
2658 +       ath9k_hw_set_interrupts(ah);
2659 +       ath9k_hw_enable_interrupts(ah);
2660 +
2661 +       spin_unlock_bh(&sc->sc_pcu_lock);
2662 +
2663 +       wow_status = ath9k_hw_wow_wakeup(ah);
2664 +
2665 +       if (atomic_read(&sc->wow_got_bmiss_intr) == 0) {
2666 +               /*
2667 +                * some devices may not pick beacon miss
2668 +                * as the reason they woke up so we add
2669 +                * that here for that shortcoming.
2670 +                */
2671 +               wow_status |= AH_WOW_BEACON_MISS;
2672 +               atomic_dec(&sc->wow_got_bmiss_intr);
2673 +               ath_dbg(common, ANY, "Beacon miss interrupt picked up during WoW sleep\n");
2674         }
2675  
2676 -       REG_RMW(ah, AR_WOW_BCN_EN, set, clr);
2677 +       atomic_dec(&sc->wow_sleep_proc_intr);
2678  
2679 -       set = 0;
2680 -       clr = 0;
2681 -       /*
2682 -        * Enable the magic packet registers
2683 -        */
2684 -       if (pattern_enable & AH_WOW_MAGIC_PATTERN_EN) {
2685 -               set = AR_WOW_MAGIC_EN;
2686 -               wow_event_mask |= AR_WOW_MAGIC_PAT_FOUND;
2687 -       } else {
2688 -               clr = AR_WOW_MAGIC_EN;
2689 +       if (wow_status) {
2690 +               ath_dbg(common, ANY, "Waking up due to WoW triggers %s with WoW status = %x\n",
2691 +                       ath9k_hw_wow_event_to_string(wow_status), wow_status);
2692         }
2693 -       set |= AR_WOW_MAC_INTR_EN;
2694 -       REG_RMW(ah, AR_WOW_PATTERN, set, clr);
2695  
2696 -       REG_WRITE(ah, AR_WOW_PATTERN_MATCH_LT_256B,
2697 -                 AR_WOW_PATTERN_SUPPORTED);
2698 +       ath_restart_work(sc);
2699 +       ath9k_start_btcoex(sc);
2700  
2701 -       /*
2702 -        * Set the power states appropriately and enable PME
2703 -        */
2704 -       clr = 0;
2705 -       set = AR_PMCTRL_PWR_STATE_D1D3 | AR_PMCTRL_HOST_PME_EN |
2706 -             AR_PMCTRL_PWR_PM_CTRL_ENA;
2707 +       ath9k_ps_restore(sc);
2708 +       mutex_unlock(&sc->mutex);
2709  
2710 -       clr = AR_PCIE_PM_CTRL_ENA;
2711 -       REG_RMW(ah, AR_PCIE_PM_CTRL, set, clr);
2712 +       return 0;
2713 +}
2714  
2715 -       /*
2716 -        * this is needed to prevent the chip waking up
2717 -        * the host within 3-4 seconds with certain
2718 -        * platform/BIOS. The fix is to enable
2719 -        * D1 & D3 to match original definition and
2720 -        * also match the OTP value. Anyway this
2721 -        * is more related to SW WOW.
2722 -        */
2723 -       clr = AR_PMCTRL_PWR_STATE_D1D3;
2724 -       REG_CLR_BIT(ah, AR_PCIE_PM_CTRL, clr);
2725 +void ath9k_set_wakeup(struct ieee80211_hw *hw, bool enabled)
2726 +{
2727 +       struct ath_softc *sc = hw->priv;
2728  
2729 -       set = AR_PMCTRL_PWR_STATE_D1D3_REAL;
2730 -       REG_SET_BIT(ah, AR_PCIE_PM_CTRL, set);
2731 +       mutex_lock(&sc->mutex);
2732 +       device_init_wakeup(sc->dev, 1);
2733 +       device_set_wakeup_enable(sc->dev, enabled);
2734 +       mutex_unlock(&sc->mutex);
2735 +}
2736  
2737 -       REG_CLR_BIT(ah, AR_STA_ID1, AR_STA_ID1_PRESERVE_SEQNUM);
2738 +void ath9k_init_wow(struct ieee80211_hw *hw)
2739 +{
2740 +       struct ath_softc *sc = hw->priv;
2741  
2742 -       /* to bring down WOW power low margin */
2743 -       set = BIT(13);
2744 -       REG_SET_BIT(ah, AR_PCIE_PHY_REG3, set);
2745 -       /* HW WoW */
2746 -       clr = BIT(5);
2747 -       REG_CLR_BIT(ah, AR_PCU_MISC_MODE3, clr);
2748 +       if ((sc->sc_ah->caps.hw_caps & ATH9K_HW_WOW_DEVICE_CAPABLE) &&
2749 +           (sc->driver_data & ATH9K_PCI_WOW) &&
2750 +           device_can_wakeup(sc->dev))
2751 +               hw->wiphy->wowlan = &ath9k_wowlan_support;
2752  
2753 -       ath9k_hw_set_powermode_wow_sleep(ah);
2754 -       ah->wow_event_mask = wow_event_mask;
2755 +       atomic_set(&sc->wow_sleep_proc_intr, -1);
2756 +       atomic_set(&sc->wow_got_bmiss_intr, -1);
2757  }
2758 -EXPORT_SYMBOL(ath9k_hw_wow_enable);
2759 --- a/drivers/net/wireless/ath/ath9k/xmit.c
2760 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
2761 @@ -1276,6 +1276,10 @@ static void ath_tx_fill_desc(struct ath_
2762                                 if (!rts_thresh || (len > rts_thresh))
2763                                         rts = true;
2764                         }
2765 +
2766 +                       if (!aggr)
2767 +                               len = fi->framelen;
2768 +
2769                         ath_buf_set_rate(sc, bf, &info, len, rts);
2770                 }
2771  
2772 @@ -1786,6 +1790,9 @@ bool ath_drain_all_txq(struct ath_softc 
2773                 if (!ATH_TXQ_SETUP(sc, i))
2774                         continue;
2775  
2776 +               if (!sc->tx.txq[i].axq_depth)
2777 +                       continue;
2778 +
2779                 if (ath9k_hw_numtxpending(ah, sc->tx.txq[i].axq_qnum))
2780                         npend |= BIT(i);
2781         }
2782 @@ -2749,6 +2756,8 @@ void ath_tx_node_cleanup(struct ath_soft
2783         }
2784  }
2785  
2786 +#ifdef CONFIG_ATH9K_TX99
2787 +
2788  int ath9k_tx99_send(struct ath_softc *sc, struct sk_buff *skb,
2789                     struct ath_tx_control *txctl)
2790  {
2791 @@ -2791,3 +2800,5 @@ int ath9k_tx99_send(struct ath_softc *sc
2792  
2793         return 0;
2794  }
2795 +
2796 +#endif /* CONFIG_ATH9K_TX99 */
2797 --- a/drivers/net/wireless/ath/regd.c
2798 +++ b/drivers/net/wireless/ath/regd.c
2799 @@ -37,17 +37,17 @@ static int __ath_regd_init(struct ath_re
2800  
2801  /* We enable active scan on these a case by case basis by regulatory domain */
2802  #define ATH9K_2GHZ_CH12_13     REG_RULE(2467-10, 2472+10, 40, 0, 20,\
2803 -                                       NL80211_RRF_PASSIVE_SCAN)
2804 +                                       NL80211_RRF_NO_IR)
2805  #define ATH9K_2GHZ_CH14                REG_RULE(2484-10, 2484+10, 40, 0, 20,\
2806 -                               NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_OFDM)
2807 +                               NL80211_RRF_NO_IR | NL80211_RRF_NO_OFDM)
2808  
2809  /* We allow IBSS on these on a case by case basis by regulatory domain */
2810  #define ATH9K_5GHZ_5150_5350   REG_RULE(5150-10, 5350+10, 80, 0, 30,\
2811 -                               NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
2812 +                               NL80211_RRF_NO_IR)
2813  #define ATH9K_5GHZ_5470_5850   REG_RULE(5470-10, 5850+10, 80, 0, 30,\
2814 -                               NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
2815 +                               NL80211_RRF_NO_IR)
2816  #define ATH9K_5GHZ_5725_5850   REG_RULE(5725-10, 5850+10, 80, 0, 30,\
2817 -                               NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS)
2818 +                               NL80211_RRF_NO_IR)
2819  
2820  #define ATH9K_2GHZ_ALL         ATH9K_2GHZ_CH01_11, \
2821                                 ATH9K_2GHZ_CH12_13, \
2822 @@ -224,17 +224,16 @@ ath_reg_apply_beaconing_flags(struct wip
2823                                  * regulatory_hint().
2824                                  */
2825                                 if (!(reg_rule->flags &
2826 -                                   NL80211_RRF_NO_IBSS))
2827 +                                   NL80211_RRF_NO_IR))
2828                                         ch->flags &=
2829 -                                         ~IEEE80211_CHAN_NO_IBSS;
2830 +                                         ~IEEE80211_CHAN_NO_IR;
2831                                 if (!(reg_rule->flags &
2832 -                                   NL80211_RRF_PASSIVE_SCAN))
2833 +                                   NL80211_RRF_NO_IR))
2834                                         ch->flags &=
2835 -                                         ~IEEE80211_CHAN_PASSIVE_SCAN;
2836 +                                         ~IEEE80211_CHAN_NO_IR;
2837                         } else {
2838                                 if (ch->beacon_found)
2839 -                                       ch->flags &= ~(IEEE80211_CHAN_NO_IBSS |
2840 -                                         IEEE80211_CHAN_PASSIVE_SCAN);
2841 +                                       ch->flags &= ~IEEE80211_CHAN_NO_IR;
2842                         }
2843                 }
2844         }
2845 @@ -260,11 +259,11 @@ ath_reg_apply_active_scan_flags(struct w
2846          */
2847         if (initiator != NL80211_REGDOM_SET_BY_COUNTRY_IE) {
2848                 ch = &sband->channels[11]; /* CH 12 */
2849 -               if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2850 -                       ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2851 +               if (ch->flags & IEEE80211_CHAN_NO_IR)
2852 +                       ch->flags &= ~IEEE80211_CHAN_NO_IR;
2853                 ch = &sband->channels[12]; /* CH 13 */
2854 -               if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2855 -                       ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2856 +               if (ch->flags & IEEE80211_CHAN_NO_IR)
2857 +                       ch->flags &= ~IEEE80211_CHAN_NO_IR;
2858                 return;
2859         }
2860  
2861 @@ -278,17 +277,17 @@ ath_reg_apply_active_scan_flags(struct w
2862         ch = &sband->channels[11]; /* CH 12 */
2863         reg_rule = freq_reg_info(wiphy, ch->center_freq);
2864         if (!IS_ERR(reg_rule)) {
2865 -               if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
2866 -                       if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2867 -                               ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2868 +               if (!(reg_rule->flags & NL80211_RRF_NO_IR))
2869 +                       if (ch->flags & IEEE80211_CHAN_NO_IR)
2870 +                               ch->flags &= ~IEEE80211_CHAN_NO_IR;
2871         }
2872  
2873         ch = &sband->channels[12]; /* CH 13 */
2874         reg_rule = freq_reg_info(wiphy, ch->center_freq);
2875         if (!IS_ERR(reg_rule)) {
2876 -               if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN))
2877 -                       if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
2878 -                               ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
2879 +               if (!(reg_rule->flags & NL80211_RRF_NO_IR))
2880 +                       if (ch->flags & IEEE80211_CHAN_NO_IR)
2881 +                               ch->flags &= ~IEEE80211_CHAN_NO_IR;
2882         }
2883  }
2884  
2885 @@ -320,8 +319,8 @@ static void ath_reg_apply_radar_flags(st
2886                  */
2887                 if (!(ch->flags & IEEE80211_CHAN_DISABLED))
2888                         ch->flags |= IEEE80211_CHAN_RADAR |
2889 -                                    IEEE80211_CHAN_NO_IBSS |
2890 -                                    IEEE80211_CHAN_PASSIVE_SCAN;
2891 +                                    IEEE80211_CHAN_NO_IR |
2892 +                                    IEEE80211_CHAN_NO_IR;
2893         }
2894  }
2895  
2896 --- a/drivers/net/wireless/brcm80211/brcmfmac/p2p.c
2897 +++ b/drivers/net/wireless/brcm80211/brcmfmac/p2p.c
2898 @@ -812,7 +812,7 @@ static s32 brcmf_p2p_run_escan(struct br
2899                         struct ieee80211_channel *chan = request->channels[i];
2900  
2901                         if (chan->flags & (IEEE80211_CHAN_RADAR |
2902 -                                          IEEE80211_CHAN_PASSIVE_SCAN))
2903 +                                          IEEE80211_CHAN_NO_IR))
2904                                 continue;
2905  
2906                         chanspecs[i] = channel_to_chanspec(&p2p->cfg->d11inf,
2907 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
2908 +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c
2909 @@ -202,9 +202,9 @@ static struct ieee80211_supported_band _
2910  
2911  /* This is to override regulatory domains defined in cfg80211 module (reg.c)
2912   * By default world regulatory domain defined in reg.c puts the flags
2913 - * NL80211_RRF_PASSIVE_SCAN and NL80211_RRF_NO_IBSS for 5GHz channels (for
2914 - * 36..48 and 149..165). With respect to these flags, wpa_supplicant doesn't
2915 - * start p2p operations on 5GHz channels. All the changes in world regulatory
2916 + * NL80211_RRF_NO_IR for 5GHz channels (for * 36..48 and 149..165).
2917 + * With respect to these flags, wpa_supplicant doesn't * start p2p
2918 + * operations on 5GHz channels. All the changes in world regulatory
2919   * domain are to be done here.
2920   */
2921  static const struct ieee80211_regdomain brcmf_regdom = {
2922 @@ -5197,10 +5197,10 @@ static s32 brcmf_construct_reginfo(struc
2923                                         if (channel & WL_CHAN_RADAR)
2924                                                 band_chan_arr[index].flags |=
2925                                                         (IEEE80211_CHAN_RADAR |
2926 -                                                       IEEE80211_CHAN_NO_IBSS);
2927 +                                                       IEEE80211_CHAN_NO_IR);
2928                                         if (channel & WL_CHAN_PASSIVE)
2929                                                 band_chan_arr[index].flags |=
2930 -                                                   IEEE80211_CHAN_PASSIVE_SCAN;
2931 +                                                   IEEE80211_CHAN_NO_IR;
2932                                 }
2933                         }
2934                         if (!update)
2935 --- a/drivers/net/wireless/brcm80211/brcmsmac/channel.c
2936 +++ b/drivers/net/wireless/brcm80211/brcmsmac/channel.c
2937 @@ -59,23 +59,20 @@
2938  
2939  #define BRCM_2GHZ_2412_2462    REG_RULE(2412-10, 2462+10, 40, 0, 19, 0)
2940  #define BRCM_2GHZ_2467_2472    REG_RULE(2467-10, 2472+10, 20, 0, 19, \
2941 -                                        NL80211_RRF_PASSIVE_SCAN | \
2942 -                                        NL80211_RRF_NO_IBSS)
2943 +                                        NL80211_RRF_NO_IR)
2944  
2945  #define BRCM_5GHZ_5180_5240    REG_RULE(5180-10, 5240+10, 40, 0, 21, \
2946 -                                        NL80211_RRF_PASSIVE_SCAN | \
2947 -                                        NL80211_RRF_NO_IBSS)
2948 +                                        NL80211_RRF_NO_IR)
2949  #define BRCM_5GHZ_5260_5320    REG_RULE(5260-10, 5320+10, 40, 0, 21, \
2950 -                                        NL80211_RRF_PASSIVE_SCAN | \
2951 +                                        NL80211_RRF_NO_IR | \
2952                                          NL80211_RRF_DFS | \
2953 -                                        NL80211_RRF_NO_IBSS)
2954 +                                        NL80211_RRF_NO_IR)
2955  #define BRCM_5GHZ_5500_5700    REG_RULE(5500-10, 5700+10, 40, 0, 21, \
2956 -                                        NL80211_RRF_PASSIVE_SCAN | \
2957 +                                        NL80211_RRF_NO_IR | \
2958                                          NL80211_RRF_DFS | \
2959 -                                        NL80211_RRF_NO_IBSS)
2960 +                                        NL80211_RRF_NO_IR)
2961  #define BRCM_5GHZ_5745_5825    REG_RULE(5745-10, 5825+10, 40, 0, 21, \
2962 -                                        NL80211_RRF_PASSIVE_SCAN | \
2963 -                                        NL80211_RRF_NO_IBSS)
2964 +                                        NL80211_RRF_NO_IR)
2965  
2966  static const struct ieee80211_regdomain brcms_regdom_x2 = {
2967         .n_reg_rules = 6,
2968 @@ -395,7 +392,7 @@ brcms_c_channel_set_chanspec(struct brcm
2969                 brcms_c_set_gmode(wlc, wlc->protection->gmode_user, false);
2970  
2971         brcms_b_set_chanspec(wlc->hw, chanspec,
2972 -                             !!(ch->flags & IEEE80211_CHAN_PASSIVE_SCAN),
2973 +                             !!(ch->flags & IEEE80211_CHAN_NO_IR),
2974                               &txpwr);
2975  }
2976  
2977 @@ -657,8 +654,8 @@ static void brcms_reg_apply_radar_flags(
2978                  */
2979                 if (!(ch->flags & IEEE80211_CHAN_DISABLED))
2980                         ch->flags |= IEEE80211_CHAN_RADAR |
2981 -                                    IEEE80211_CHAN_NO_IBSS |
2982 -                                    IEEE80211_CHAN_PASSIVE_SCAN;
2983 +                                    IEEE80211_CHAN_NO_IR |
2984 +                                    IEEE80211_CHAN_NO_IR;
2985         }
2986  }
2987  
2988 @@ -688,14 +685,13 @@ brcms_reg_apply_beaconing_flags(struct w
2989                                 if (IS_ERR(rule))
2990                                         continue;
2991  
2992 -                               if (!(rule->flags & NL80211_RRF_NO_IBSS))
2993 -                                       ch->flags &= ~IEEE80211_CHAN_NO_IBSS;
2994 -                               if (!(rule->flags & NL80211_RRF_PASSIVE_SCAN))
2995 +                               if (!(rule->flags & NL80211_RRF_NO_IR))
2996 +                                       ch->flags &= ~IEEE80211_CHAN_NO_IR;
2997 +                               if (!(rule->flags & NL80211_RRF_NO_IR))
2998                                         ch->flags &=
2999 -                                               ~IEEE80211_CHAN_PASSIVE_SCAN;
3000 +                                               ~IEEE80211_CHAN_NO_IR;
3001                         } else if (ch->beacon_found) {
3002 -                               ch->flags &= ~(IEEE80211_CHAN_NO_IBSS |
3003 -                                              IEEE80211_CHAN_PASSIVE_SCAN);
3004 +                               ch->flags &= ~IEEE80211_CHAN_NO_IR;
3005                         }
3006                 }
3007         }
3008 --- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
3009 +++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
3010 @@ -125,13 +125,13 @@ static struct ieee80211_channel brcms_2g
3011         CHAN2GHZ(10, 2457, IEEE80211_CHAN_NO_HT40PLUS),
3012         CHAN2GHZ(11, 2462, IEEE80211_CHAN_NO_HT40PLUS),
3013         CHAN2GHZ(12, 2467,
3014 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS |
3015 +                IEEE80211_CHAN_NO_IR |
3016                  IEEE80211_CHAN_NO_HT40PLUS),
3017         CHAN2GHZ(13, 2472,
3018 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS |
3019 +                IEEE80211_CHAN_NO_IR |
3020                  IEEE80211_CHAN_NO_HT40PLUS),
3021         CHAN2GHZ(14, 2484,
3022 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_IBSS |
3023 +                IEEE80211_CHAN_NO_IR |
3024                  IEEE80211_CHAN_NO_HT40PLUS | IEEE80211_CHAN_NO_HT40MINUS |
3025                  IEEE80211_CHAN_NO_OFDM)
3026  };
3027 @@ -144,51 +144,51 @@ static struct ieee80211_channel brcms_5g
3028         CHAN5GHZ(48, IEEE80211_CHAN_NO_HT40PLUS),
3029         /* UNII-2 */
3030         CHAN5GHZ(52,
3031 -                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
3032 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
3033 +                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
3034 +                IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
3035         CHAN5GHZ(56,
3036 -                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
3037 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
3038 +                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
3039 +                IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
3040         CHAN5GHZ(60,
3041 -                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
3042 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
3043 +                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
3044 +                IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
3045         CHAN5GHZ(64,
3046 -                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
3047 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
3048 +                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
3049 +                IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
3050         /* MID */
3051         CHAN5GHZ(100,
3052 -                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
3053 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
3054 +                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
3055 +                IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
3056         CHAN5GHZ(104,
3057 -                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
3058 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
3059 +                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
3060 +                IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
3061         CHAN5GHZ(108,
3062 -                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
3063 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
3064 +                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
3065 +                IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
3066         CHAN5GHZ(112,
3067 -                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
3068 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
3069 +                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
3070 +                IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
3071         CHAN5GHZ(116,
3072 -                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
3073 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
3074 +                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
3075 +                IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
3076         CHAN5GHZ(120,
3077 -                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
3078 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
3079 +                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
3080 +                IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
3081         CHAN5GHZ(124,
3082 -                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
3083 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
3084 +                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
3085 +                IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
3086         CHAN5GHZ(128,
3087 -                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
3088 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
3089 +                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
3090 +                IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
3091         CHAN5GHZ(132,
3092 -                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
3093 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40MINUS),
3094 +                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
3095 +                IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40MINUS),
3096         CHAN5GHZ(136,
3097 -                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
3098 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS),
3099 +                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
3100 +                IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS),
3101         CHAN5GHZ(140,
3102 -                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IBSS |
3103 -                IEEE80211_CHAN_PASSIVE_SCAN | IEEE80211_CHAN_NO_HT40PLUS |
3104 +                IEEE80211_CHAN_RADAR | IEEE80211_CHAN_NO_IR |
3105 +                IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_NO_HT40PLUS |
3106                  IEEE80211_CHAN_NO_HT40MINUS),
3107         /* UNII-3 */
3108         CHAN5GHZ(149, IEEE80211_CHAN_NO_HT40MINUS),
3109 --- a/drivers/net/wireless/cw1200/scan.c
3110 +++ b/drivers/net/wireless/cw1200/scan.c
3111 @@ -197,9 +197,9 @@ void cw1200_scan_work(struct work_struct
3112                         if ((*it)->band != first->band)
3113                                 break;
3114                         if (((*it)->flags ^ first->flags) &
3115 -                                       IEEE80211_CHAN_PASSIVE_SCAN)
3116 +                                       IEEE80211_CHAN_NO_IR)
3117                                 break;
3118 -                       if (!(first->flags & IEEE80211_CHAN_PASSIVE_SCAN) &&
3119 +                       if (!(first->flags & IEEE80211_CHAN_NO_IR) &&
3120                             (*it)->max_power != first->max_power)
3121                                 break;
3122                 }
3123 @@ -210,7 +210,7 @@ void cw1200_scan_work(struct work_struct
3124                 else
3125                         scan.max_tx_rate = WSM_TRANSMIT_RATE_1;
3126                 scan.num_probes =
3127 -                       (first->flags & IEEE80211_CHAN_PASSIVE_SCAN) ? 0 : 2;
3128 +                       (first->flags & IEEE80211_CHAN_NO_IR) ? 0 : 2;
3129                 scan.num_ssids = priv->scan.n_ssids;
3130                 scan.ssids = &priv->scan.ssids[0];
3131                 scan.num_channels = it - priv->scan.curr;
3132 @@ -233,7 +233,7 @@ void cw1200_scan_work(struct work_struct
3133                 }
3134                 for (i = 0; i < scan.num_channels; ++i) {
3135                         scan.ch[i].number = priv->scan.curr[i]->hw_value;
3136 -                       if (priv->scan.curr[i]->flags & IEEE80211_CHAN_PASSIVE_SCAN) {
3137 +                       if (priv->scan.curr[i]->flags & IEEE80211_CHAN_NO_IR) {
3138                                 scan.ch[i].min_chan_time = 50;
3139                                 scan.ch[i].max_chan_time = 100;
3140                         } else {
3141 @@ -241,7 +241,7 @@ void cw1200_scan_work(struct work_struct
3142                                 scan.ch[i].max_chan_time = 25;
3143                         }
3144                 }
3145 -               if (!(first->flags & IEEE80211_CHAN_PASSIVE_SCAN) &&
3146 +               if (!(first->flags & IEEE80211_CHAN_NO_IR) &&
3147                     priv->scan.output_power != first->max_power) {
3148                         priv->scan.output_power = first->max_power;
3149                         wsm_set_output_power(priv,
3150 --- a/drivers/net/wireless/ipw2x00/ipw2100.c
3151 +++ b/drivers/net/wireless/ipw2x00/ipw2100.c
3152 @@ -1934,10 +1934,10 @@ static int ipw2100_wdev_init(struct net_
3153                         bg_band->channels[i].max_power = geo->bg[i].max_power;
3154                         if (geo->bg[i].flags & LIBIPW_CH_PASSIVE_ONLY)
3155                                 bg_band->channels[i].flags |=
3156 -                                       IEEE80211_CHAN_PASSIVE_SCAN;
3157 +                                       IEEE80211_CHAN_NO_IR;
3158                         if (geo->bg[i].flags & LIBIPW_CH_NO_IBSS)
3159                                 bg_band->channels[i].flags |=
3160 -                                       IEEE80211_CHAN_NO_IBSS;
3161 +                                       IEEE80211_CHAN_NO_IR;
3162                         if (geo->bg[i].flags & LIBIPW_CH_RADAR_DETECT)
3163                                 bg_band->channels[i].flags |=
3164                                         IEEE80211_CHAN_RADAR;
3165 --- a/drivers/net/wireless/ipw2x00/ipw2200.c
3166 +++ b/drivers/net/wireless/ipw2x00/ipw2200.c
3167 @@ -11472,10 +11472,10 @@ static int ipw_wdev_init(struct net_devi
3168                         bg_band->channels[i].max_power = geo->bg[i].max_power;
3169                         if (geo->bg[i].flags & LIBIPW_CH_PASSIVE_ONLY)
3170                                 bg_band->channels[i].flags |=
3171 -                                       IEEE80211_CHAN_PASSIVE_SCAN;
3172 +                                       IEEE80211_CHAN_NO_IR;
3173                         if (geo->bg[i].flags & LIBIPW_CH_NO_IBSS)
3174                                 bg_band->channels[i].flags |=
3175 -                                       IEEE80211_CHAN_NO_IBSS;
3176 +                                       IEEE80211_CHAN_NO_IR;
3177                         if (geo->bg[i].flags & LIBIPW_CH_RADAR_DETECT)
3178                                 bg_band->channels[i].flags |=
3179                                         IEEE80211_CHAN_RADAR;
3180 @@ -11511,10 +11511,10 @@ static int ipw_wdev_init(struct net_devi
3181                         a_band->channels[i].max_power = geo->a[i].max_power;
3182                         if (geo->a[i].flags & LIBIPW_CH_PASSIVE_ONLY)
3183                                 a_band->channels[i].flags |=
3184 -                                       IEEE80211_CHAN_PASSIVE_SCAN;
3185 +                                       IEEE80211_CHAN_NO_IR;
3186                         if (geo->a[i].flags & LIBIPW_CH_NO_IBSS)
3187                                 a_band->channels[i].flags |=
3188 -                                       IEEE80211_CHAN_NO_IBSS;
3189 +                                       IEEE80211_CHAN_NO_IR;
3190                         if (geo->a[i].flags & LIBIPW_CH_RADAR_DETECT)
3191                                 a_band->channels[i].flags |=
3192                                         IEEE80211_CHAN_RADAR;
3193 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
3194 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
3195 @@ -1595,7 +1595,7 @@ il3945_get_channels_for_scan(struct il_p
3196                  *  and use long active_dwell time.
3197                  */
3198                 if (!is_active || il_is_channel_passive(ch_info) ||
3199 -                   (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) {
3200 +                   (chan->flags & IEEE80211_CHAN_NO_IR)) {
3201                         scan_ch->type = 0;      /* passive */
3202                         if (IL_UCODE_API(il->ucode_ver) == 1)
3203                                 scan_ch->active_dwell =
3204 --- a/drivers/net/wireless/iwlegacy/4965-mac.c
3205 +++ b/drivers/net/wireless/iwlegacy/4965-mac.c
3206 @@ -805,7 +805,7 @@ il4965_get_channels_for_scan(struct il_p
3207                 }
3208  
3209                 if (!is_active || il_is_channel_passive(ch_info) ||
3210 -                   (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN))
3211 +                   (chan->flags & IEEE80211_CHAN_NO_IR))
3212                         scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
3213                 else
3214                         scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE;
3215 --- a/drivers/net/wireless/iwlegacy/common.c
3216 +++ b/drivers/net/wireless/iwlegacy/common.c
3217 @@ -3447,10 +3447,10 @@ il_init_geos(struct il_priv *il)
3218  
3219                 if (il_is_channel_valid(ch)) {
3220                         if (!(ch->flags & EEPROM_CHANNEL_IBSS))
3221 -                               geo_ch->flags |= IEEE80211_CHAN_NO_IBSS;
3222 +                               geo_ch->flags |= IEEE80211_CHAN_NO_IR;
3223  
3224                         if (!(ch->flags & EEPROM_CHANNEL_ACTIVE))
3225 -                               geo_ch->flags |= IEEE80211_CHAN_PASSIVE_SCAN;
3226 +                               geo_ch->flags |= IEEE80211_CHAN_NO_IR;
3227  
3228                         if (ch->flags & EEPROM_CHANNEL_RADAR)
3229                                 geo_ch->flags |= IEEE80211_CHAN_RADAR;
3230 --- a/drivers/net/wireless/iwlegacy/debug.c
3231 +++ b/drivers/net/wireless/iwlegacy/debug.c
3232 @@ -567,12 +567,12 @@ il_dbgfs_channels_read(struct file *file
3233                                       flags & IEEE80211_CHAN_RADAR ?
3234                                       " (IEEE 802.11h required)" : "",
3235                                       ((channels[i].
3236 -                                       flags & IEEE80211_CHAN_NO_IBSS) ||
3237 +                                       flags & IEEE80211_CHAN_NO_IR) ||
3238                                        (channels[i].
3239                                         flags & IEEE80211_CHAN_RADAR)) ? "" :
3240                                       ", IBSS",
3241                                       channels[i].
3242 -                                     flags & IEEE80211_CHAN_PASSIVE_SCAN ?
3243 +                                     flags & IEEE80211_CHAN_NO_IR ?
3244                                       "passive only" : "active/passive");
3245         }
3246         supp_band = il_get_hw_mode(il, IEEE80211_BAND_5GHZ);
3247 @@ -594,12 +594,12 @@ il_dbgfs_channels_read(struct file *file
3248                                       flags & IEEE80211_CHAN_RADAR ?
3249                                       " (IEEE 802.11h required)" : "",
3250                                       ((channels[i].
3251 -                                       flags & IEEE80211_CHAN_NO_IBSS) ||
3252 +                                       flags & IEEE80211_CHAN_NO_IR) ||
3253                                        (channels[i].
3254                                         flags & IEEE80211_CHAN_RADAR)) ? "" :
3255                                       ", IBSS",
3256                                       channels[i].
3257 -                                     flags & IEEE80211_CHAN_PASSIVE_SCAN ?
3258 +                                     flags & IEEE80211_CHAN_NO_IR ?
3259                                       "passive only" : "active/passive");
3260         }
3261         ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
3262 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
3263 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
3264 @@ -352,12 +352,12 @@ static ssize_t iwl_dbgfs_channels_read(s
3265                                         channels[i].max_power,
3266                                         channels[i].flags & IEEE80211_CHAN_RADAR ?
3267                                         " (IEEE 802.11h required)" : "",
3268 -                                       ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
3269 +                                       ((channels[i].flags & IEEE80211_CHAN_NO_IR)
3270                                         || (channels[i].flags &
3271                                         IEEE80211_CHAN_RADAR)) ? "" :
3272                                         ", IBSS",
3273                                         channels[i].flags &
3274 -                                       IEEE80211_CHAN_PASSIVE_SCAN ?
3275 +                                       IEEE80211_CHAN_NO_IR ?
3276                                         "passive only" : "active/passive");
3277         }
3278         supp_band = iwl_get_hw_mode(priv, IEEE80211_BAND_5GHZ);
3279 @@ -375,12 +375,12 @@ static ssize_t iwl_dbgfs_channels_read(s
3280                                         channels[i].max_power,
3281                                         channels[i].flags & IEEE80211_CHAN_RADAR ?
3282                                         " (IEEE 802.11h required)" : "",
3283 -                                       ((channels[i].flags & IEEE80211_CHAN_NO_IBSS)
3284 +                                       ((channels[i].flags & IEEE80211_CHAN_NO_IR)
3285                                         || (channels[i].flags &
3286                                         IEEE80211_CHAN_RADAR)) ? "" :
3287                                         ", IBSS",
3288                                         channels[i].flags &
3289 -                                       IEEE80211_CHAN_PASSIVE_SCAN ?
3290 +                                       IEEE80211_CHAN_NO_IR ?
3291                                         "passive only" : "active/passive");
3292         }
3293         ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
3294 --- a/drivers/net/wireless/iwlwifi/dvm/scan.c
3295 +++ b/drivers/net/wireless/iwlwifi/dvm/scan.c
3296 @@ -544,7 +544,7 @@ static int iwl_get_channels_for_scan(str
3297                 channel = chan->hw_value;
3298                 scan_ch->channel = cpu_to_le16(channel);
3299  
3300 -               if (!is_active || (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN))
3301 +               if (!is_active || (chan->flags & IEEE80211_CHAN_NO_IR))
3302                         scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE;
3303                 else
3304                         scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE;
3305 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c
3306 +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c
3307 @@ -614,10 +614,10 @@ static int iwl_init_channel_map(struct d
3308                         channel->flags = IEEE80211_CHAN_NO_HT40;
3309  
3310                         if (!(eeprom_ch->flags & EEPROM_CHANNEL_IBSS))
3311 -                               channel->flags |= IEEE80211_CHAN_NO_IBSS;
3312 +                               channel->flags |= IEEE80211_CHAN_NO_IR;
3313  
3314                         if (!(eeprom_ch->flags & EEPROM_CHANNEL_ACTIVE))
3315 -                               channel->flags |= IEEE80211_CHAN_PASSIVE_SCAN;
3316 +                               channel->flags |= IEEE80211_CHAN_NO_IR;
3317  
3318                         if (eeprom_ch->flags & EEPROM_CHANNEL_RADAR)
3319                                 channel->flags |= IEEE80211_CHAN_RADAR;
3320 --- a/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c
3321 +++ b/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c
3322 @@ -223,10 +223,10 @@ static int iwl_init_channel_map(struct d
3323                         channel->flags |= IEEE80211_CHAN_NO_160MHZ;
3324  
3325                 if (!(ch_flags & NVM_CHANNEL_IBSS))
3326 -                       channel->flags |= IEEE80211_CHAN_NO_IBSS;
3327 +                       channel->flags |= IEEE80211_CHAN_NO_IR;
3328  
3329                 if (!(ch_flags & NVM_CHANNEL_ACTIVE))
3330 -                       channel->flags |= IEEE80211_CHAN_PASSIVE_SCAN;
3331 +                       channel->flags |= IEEE80211_CHAN_NO_IR;
3332  
3333                 if (ch_flags & NVM_CHANNEL_RADAR)
3334                         channel->flags |= IEEE80211_CHAN_RADAR;
3335 --- a/drivers/net/wireless/iwlwifi/mvm/scan.c
3336 +++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
3337 @@ -192,7 +192,7 @@ static void iwl_mvm_scan_fill_channels(s
3338         for (i = 0; i < cmd->channel_count; i++) {
3339                 chan->channel = cpu_to_le16(req->channels[i]->hw_value);
3340                 chan->type = cpu_to_le32(type);
3341 -               if (req->channels[i]->flags & IEEE80211_CHAN_PASSIVE_SCAN)
3342 +               if (req->channels[i]->flags & IEEE80211_CHAN_NO_IR)
3343                         chan->type &= cpu_to_le32(~SCAN_CHANNEL_TYPE_ACTIVE);
3344                 chan->active_dwell = cpu_to_le16(active_dwell);
3345                 chan->passive_dwell = cpu_to_le16(passive_dwell);
3346 @@ -642,7 +642,7 @@ static void iwl_build_channel_cfg(struct
3347                 channels->iter_count[index] = cpu_to_le16(1);
3348                 channels->iter_interval[index] = 0;
3349  
3350 -               if (!(s_band->channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN))
3351 +               if (!(s_band->channels[i].flags & IEEE80211_CHAN_NO_IR))
3352                         channels->type[index] |=
3353                                 cpu_to_le32(IWL_SCAN_OFFLOAD_CHANNEL_ACTIVE);
3354  
3355 --- a/drivers/net/wireless/mac80211_hwsim.c
3356 +++ b/drivers/net/wireless/mac80211_hwsim.c
3357 @@ -159,7 +159,7 @@ static const struct ieee80211_regdomain 
3358         .reg_rules = {
3359                 REG_RULE(2412-10, 2462+10, 40, 0, 20, 0),
3360                 REG_RULE(5725-10, 5850+10, 40, 0, 30,
3361 -                       NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS),
3362 +                        NL80211_RRF_NO_IR),
3363         }
3364  };
3365  
3366 @@ -1485,7 +1485,7 @@ static void hw_scan_work(struct work_str
3367                     req->channels[hwsim->scan_chan_idx]->center_freq);
3368  
3369         hwsim->tmp_chan = req->channels[hwsim->scan_chan_idx];
3370 -       if (hwsim->tmp_chan->flags & IEEE80211_CHAN_PASSIVE_SCAN ||
3371 +       if (hwsim->tmp_chan->flags & IEEE80211_CHAN_NO_IR ||
3372             !req->n_ssids) {
3373                 dwell = 120;
3374         } else {
3375 --- a/drivers/net/wireless/mwifiex/cfg80211.c
3376 +++ b/drivers/net/wireless/mwifiex/cfg80211.c
3377 @@ -50,24 +50,24 @@ static const struct ieee80211_regdomain 
3378                 REG_RULE(2412-10, 2462+10, 40, 3, 20, 0),
3379                 /* Channel 12 - 13 */
3380                 REG_RULE(2467-10, 2472+10, 20, 3, 20,
3381 -                        NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS),
3382 +                        NL80211_RRF_NO_IR),
3383                 /* Channel 14 */
3384                 REG_RULE(2484-10, 2484+10, 20, 3, 20,
3385 -                        NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS |
3386 +                        NL80211_RRF_NO_IR |
3387                          NL80211_RRF_NO_OFDM),
3388                 /* Channel 36 - 48 */
3389                 REG_RULE(5180-10, 5240+10, 40, 3, 20,
3390 -                        NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS),
3391 +                        NL80211_RRF_NO_IR),
3392                 /* Channel 149 - 165 */
3393                 REG_RULE(5745-10, 5825+10, 40, 3, 20,
3394 -                        NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS),
3395 +                        NL80211_RRF_NO_IR),
3396                 /* Channel 52 - 64 */
3397                 REG_RULE(5260-10, 5320+10, 40, 3, 30,
3398 -                        NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS |
3399 +                        NL80211_RRF_NO_IR |
3400                          NL80211_RRF_DFS),
3401                 /* Channel 100 - 140 */
3402                 REG_RULE(5500-10, 5700+10, 40, 3, 30,
3403 -                        NL80211_RRF_PASSIVE_SCAN | NL80211_RRF_NO_IBSS |
3404 +                        NL80211_RRF_NO_IR |
3405                          NL80211_RRF_DFS),
3406         }
3407  };
3408 @@ -1968,7 +1968,7 @@ mwifiex_cfg80211_scan(struct wiphy *wiph
3409                 user_scan_cfg->chan_list[i].chan_number = chan->hw_value;
3410                 user_scan_cfg->chan_list[i].radio_type = chan->band;
3411  
3412 -               if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)
3413 +               if (chan->flags & IEEE80211_CHAN_NO_IR)
3414                         user_scan_cfg->chan_list[i].scan_type =
3415                                                 MWIFIEX_SCAN_TYPE_PASSIVE;
3416                 else
3417 --- a/drivers/net/wireless/mwifiex/scan.c
3418 +++ b/drivers/net/wireless/mwifiex/scan.c
3419 @@ -515,14 +515,14 @@ mwifiex_scan_create_channel_list(struct 
3420                                 scan_chan_list[chan_idx].max_scan_time =
3421                                         cpu_to_le16((u16) user_scan_in->
3422                                         chan_list[0].scan_time);
3423 -                       else if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
3424 +                       else if (ch->flags & IEEE80211_CHAN_NO_IR)
3425                                 scan_chan_list[chan_idx].max_scan_time =
3426                                         cpu_to_le16(adapter->passive_scan_time);
3427                         else
3428                                 scan_chan_list[chan_idx].max_scan_time =
3429                                         cpu_to_le16(adapter->active_scan_time);
3430  
3431 -                       if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN)
3432 +                       if (ch->flags & IEEE80211_CHAN_NO_IR)
3433                                 scan_chan_list[chan_idx].chan_scan_mode_bitmap
3434                                         |= MWIFIEX_PASSIVE_SCAN;
3435                         else
3436 --- a/drivers/net/wireless/rt2x00/rt2x00lib.h
3437 +++ b/drivers/net/wireless/rt2x00/rt2x00lib.h
3438 @@ -146,7 +146,7 @@ void rt2x00queue_remove_l2pad(struct sk_
3439   * @local: frame is not from mac80211
3440   */
3441  int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
3442 -                              bool local);
3443 +                              struct ieee80211_sta *sta, bool local);
3444  
3445  /**
3446   * rt2x00queue_update_beacon - Send new beacon from mac80211
3447 --- a/drivers/net/wireless/rt2x00/rt2x00mac.c
3448 +++ b/drivers/net/wireless/rt2x00/rt2x00mac.c
3449 @@ -90,7 +90,7 @@ static int rt2x00mac_tx_rts_cts(struct r
3450                                   frag_skb->data, data_length, tx_info,
3451                                   (struct ieee80211_rts *)(skb->data));
3452  
3453 -       retval = rt2x00queue_write_tx_frame(queue, skb, true);
3454 +       retval = rt2x00queue_write_tx_frame(queue, skb, NULL, true);
3455         if (retval) {
3456                 dev_kfree_skb_any(skb);
3457                 rt2x00_warn(rt2x00dev, "Failed to send RTS/CTS frame\n");
3458 @@ -151,7 +151,7 @@ void rt2x00mac_tx(struct ieee80211_hw *h
3459                         goto exit_fail;
3460         }
3461  
3462 -       if (unlikely(rt2x00queue_write_tx_frame(queue, skb, false)))
3463 +       if (unlikely(rt2x00queue_write_tx_frame(queue, skb, control->sta, false)))
3464                 goto exit_fail;
3465  
3466         /*
3467 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
3468 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
3469 @@ -635,7 +635,7 @@ static void rt2x00queue_bar_check(struct
3470  }
3471  
3472  int rt2x00queue_write_tx_frame(struct data_queue *queue, struct sk_buff *skb,
3473 -                              bool local)
3474 +                              struct ieee80211_sta *sta, bool local)
3475  {
3476         struct ieee80211_tx_info *tx_info;
3477         struct queue_entry *entry;
3478 @@ -649,7 +649,7 @@ int rt2x00queue_write_tx_frame(struct da
3479          * after that we are free to use the skb->cb array
3480          * for our information.
3481          */
3482 -       rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc, NULL);
3483 +       rt2x00queue_create_tx_descriptor(queue->rt2x00dev, skb, &txdesc, sta);
3484  
3485         /*
3486          * All information is retrieved from the skb->cb array,
3487 --- a/drivers/net/wireless/rtl818x/rtl8187/dev.c
3488 +++ b/drivers/net/wireless/rtl818x/rtl8187/dev.c
3489 @@ -416,7 +416,7 @@ static int rtl8187_init_urbs(struct ieee
3490         struct rtl8187_rx_info *info;
3491         int ret = 0;
3492  
3493 -       while (skb_queue_len(&priv->rx_queue) < 16) {
3494 +       while (skb_queue_len(&priv->rx_queue) < 32) {
3495                 skb = __dev_alloc_skb(RTL8187_MAX_RX, GFP_KERNEL);
3496                 if (!skb) {
3497                         ret = -ENOMEM;
3498 --- a/drivers/net/wireless/rtlwifi/base.c
3499 +++ b/drivers/net/wireless/rtlwifi/base.c
3500 @@ -1078,8 +1078,8 @@ u8 rtl_is_special_data(struct ieee80211_
3501  
3502         ip = (struct iphdr *)((u8 *) skb->data + mac_hdr_len&nbs