rb532: fix a module dependency issue
[librecmc/librecmc.git] / package / mac80211 / patches / 500-pending_work.patch
1 --- a/drivers/net/wireless/ath/ath9k/Kconfig
2 +++ b/drivers/net/wireless/ath/ath9k/Kconfig
3 @@ -32,6 +32,13 @@ config ATH9K_DEBUGFS
4  
5           Also required for changing debug message flags at run time.
6  
7 +config ATH9K_PKTLOG
8 +       bool "ath9k packet logging support"
9 +       depends on ATH9K_DEBUGFS
10 +       ---help---
11 +       Say Y to dump frame information during tx/rx, rate information
12 +       and ani state.
13 +
14  config ATH9K_HTC
15         tristate "Atheros HTC based wireless cards support"
16         depends on USB && MAC80211
17 @@ -53,3 +60,4 @@ config ATH9K_HTC_DEBUGFS
18         depends on ATH9K_HTC && DEBUG_FS
19         ---help---
20           Say Y, if you need access to ath9k_htc's statistics.
21 +
22 --- a/drivers/net/wireless/ath/ath9k/Makefile
23 +++ b/drivers/net/wireless/ath/ath9k/Makefile
24 @@ -10,6 +10,7 @@ ath9k-y +=    beacon.o \
25  ath9k-$(CONFIG_PCI) += pci.o
26  ath9k-$(CONFIG_ATHEROS_AR71XX) += ahb.o
27  ath9k-$(CONFIG_ATH9K_DEBUGFS) += debug.o
28 +ath9k-$(CONFIG_ATH9K_PKTLOG) += pktlog.o
29  
30  obj-$(CONFIG_ATH9K) += ath9k.o
31  
32 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
33 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
34 @@ -215,7 +215,8 @@ static void ar9002_hw_fill_txdesc(struct
35  }
36  
37  static int ar9002_hw_proc_txdesc(struct ath_hw *ah, void *ds,
38 -                                struct ath_tx_status *ts)
39 +                                struct ath_tx_status *ts,
40 +                                void *txs_desc)
41  {
42         struct ar5416_desc *ads = AR5416DESC(ds);
43  
44 --- /dev/null
45 +++ b/drivers/net/wireless/ath/ath9k/ar9003_2p0_initvals.h
46 @@ -0,0 +1,1784 @@
47 +/*
48 + * Copyright (c) 2010 Atheros Communications Inc.
49 + *
50 + * Permission to use, copy, modify, and/or distribute this software for any
51 + * purpose with or without fee is hereby granted, provided that the above
52 + * copyright notice and this permission notice appear in all copies.
53 + *
54 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
55 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
56 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
57 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
58 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
59 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
60 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
61 + */
62 +
63 +#ifndef INITVALS_9003_2P0_H
64 +#define INITVALS_9003_2P0_H
65 +
66 +/* AR9003 2.0 */
67 +
68 +static const u32 ar9300_2p0_radio_postamble[][5] = {
69 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
70 +       {0x0001609c, 0x0dd08f29, 0x0dd08f29, 0x0b283f31, 0x0b283f31},
71 +       {0x000160ac, 0xa4653c00, 0xa4653c00, 0x24652800, 0x24652800},
72 +       {0x000160b0, 0x03284f3e, 0x03284f3e, 0x05d08f20, 0x05d08f20},
73 +       {0x0001610c, 0x08000000, 0x00000000, 0x00000000, 0x00000000},
74 +       {0x00016140, 0x10804008, 0x10804008, 0x50804008, 0x50804008},
75 +       {0x0001650c, 0x08000000, 0x00000000, 0x00000000, 0x00000000},
76 +       {0x00016540, 0x10804008, 0x10804008, 0x50804008, 0x50804008},
77 +       {0x0001690c, 0x08000000, 0x00000000, 0x00000000, 0x00000000},
78 +       {0x00016940, 0x10804008, 0x10804008, 0x50804008, 0x50804008},
79 +};
80 +
81 +static const u32 ar9300Modes_lowest_ob_db_tx_gain_table_2p0[][5] = {
82 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
83 +       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
84 +       {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
85 +       {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002},
86 +       {0x0000a508, 0x0a000020, 0x0a000020, 0x08000004, 0x08000004},
87 +       {0x0000a50c, 0x10000023, 0x10000023, 0x0b000200, 0x0b000200},
88 +       {0x0000a510, 0x16000220, 0x16000220, 0x0f000202, 0x0f000202},
89 +       {0x0000a514, 0x1c000223, 0x1c000223, 0x12000400, 0x12000400},
90 +       {0x0000a518, 0x21020220, 0x21020220, 0x16000402, 0x16000402},
91 +       {0x0000a51c, 0x27020223, 0x27020223, 0x19000404, 0x19000404},
92 +       {0x0000a520, 0x2b022220, 0x2b022220, 0x1c000603, 0x1c000603},
93 +       {0x0000a524, 0x2f022222, 0x2f022222, 0x21000a02, 0x21000a02},
94 +       {0x0000a528, 0x34022225, 0x34022225, 0x25000a04, 0x25000a04},
95 +       {0x0000a52c, 0x3a02222a, 0x3a02222a, 0x28000a20, 0x28000a20},
96 +       {0x0000a530, 0x3e02222c, 0x3e02222c, 0x2c000e20, 0x2c000e20},
97 +       {0x0000a534, 0x4202242a, 0x4202242a, 0x30000e22, 0x30000e22},
98 +       {0x0000a538, 0x4702244a, 0x4702244a, 0x34000e24, 0x34000e24},
99 +       {0x0000a53c, 0x4b02244c, 0x4b02244c, 0x38001640, 0x38001640},
100 +       {0x0000a540, 0x4e02246c, 0x4e02246c, 0x3c001660, 0x3c001660},
101 +       {0x0000a544, 0x5302266c, 0x5302266c, 0x3f001861, 0x3f001861},
102 +       {0x0000a548, 0x5702286c, 0x5702286c, 0x43001a81, 0x43001a81},
103 +       {0x0000a54c, 0x5c04286b, 0x5c04286b, 0x47001a83, 0x47001a83},
104 +       {0x0000a550, 0x61042a6c, 0x61042a6c, 0x4a001c84, 0x4a001c84},
105 +       {0x0000a554, 0x66062a6c, 0x66062a6c, 0x4e001ce3, 0x4e001ce3},
106 +       {0x0000a558, 0x6b062e6c, 0x6b062e6c, 0x52001ce5, 0x52001ce5},
107 +       {0x0000a55c, 0x7006308c, 0x7006308c, 0x56001ce9, 0x56001ce9},
108 +       {0x0000a560, 0x730a308a, 0x730a308a, 0x5a001ceb, 0x5a001ceb},
109 +       {0x0000a564, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
110 +       {0x0000a568, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
111 +       {0x0000a56c, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
112 +       {0x0000a570, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
113 +       {0x0000a574, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
114 +       {0x0000a578, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
115 +       {0x0000a57c, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
116 +       {0x0000a580, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
117 +       {0x0000a584, 0x06800003, 0x06800003, 0x04800002, 0x04800002},
118 +       {0x0000a588, 0x0a800020, 0x0a800020, 0x08800004, 0x08800004},
119 +       {0x0000a58c, 0x10800023, 0x10800023, 0x0b800200, 0x0b800200},
120 +       {0x0000a590, 0x16800220, 0x16800220, 0x0f800202, 0x0f800202},
121 +       {0x0000a594, 0x1c800223, 0x1c800223, 0x12800400, 0x12800400},
122 +       {0x0000a598, 0x21820220, 0x21820220, 0x16800402, 0x16800402},
123 +       {0x0000a59c, 0x27820223, 0x27820223, 0x19800404, 0x19800404},
124 +       {0x0000a5a0, 0x2b822220, 0x2b822220, 0x1c800603, 0x1c800603},
125 +       {0x0000a5a4, 0x2f822222, 0x2f822222, 0x21800a02, 0x21800a02},
126 +       {0x0000a5a8, 0x34822225, 0x34822225, 0x25800a04, 0x25800a04},
127 +       {0x0000a5ac, 0x3a82222a, 0x3a82222a, 0x28800a20, 0x28800a20},
128 +       {0x0000a5b0, 0x3e82222c, 0x3e82222c, 0x2c800e20, 0x2c800e20},
129 +       {0x0000a5b4, 0x4282242a, 0x4282242a, 0x30800e22, 0x30800e22},
130 +       {0x0000a5b8, 0x4782244a, 0x4782244a, 0x34800e24, 0x34800e24},
131 +       {0x0000a5bc, 0x4b82244c, 0x4b82244c, 0x38801640, 0x38801640},
132 +       {0x0000a5c0, 0x4e82246c, 0x4e82246c, 0x3c801660, 0x3c801660},
133 +       {0x0000a5c4, 0x5382266c, 0x5382266c, 0x3f801861, 0x3f801861},
134 +       {0x0000a5c8, 0x5782286c, 0x5782286c, 0x43801a81, 0x43801a81},
135 +       {0x0000a5cc, 0x5c84286b, 0x5c84286b, 0x47801a83, 0x47801a83},
136 +       {0x0000a5d0, 0x61842a6c, 0x61842a6c, 0x4a801c84, 0x4a801c84},
137 +       {0x0000a5d4, 0x66862a6c, 0x66862a6c, 0x4e801ce3, 0x4e801ce3},
138 +       {0x0000a5d8, 0x6b862e6c, 0x6b862e6c, 0x52801ce5, 0x52801ce5},
139 +       {0x0000a5dc, 0x7086308c, 0x7086308c, 0x56801ce9, 0x56801ce9},
140 +       {0x0000a5e0, 0x738a308a, 0x738a308a, 0x5a801ceb, 0x5a801ceb},
141 +       {0x0000a5e4, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
142 +       {0x0000a5e8, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
143 +       {0x0000a5ec, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
144 +       {0x0000a5f0, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
145 +       {0x0000a5f4, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
146 +       {0x0000a5f8, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
147 +       {0x0000a5fc, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
148 +       {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
149 +       {0x00016048, 0x62480001, 0x62480001, 0x62480001, 0x62480001},
150 +       {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
151 +       {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
152 +       {0x00016448, 0x62480001, 0x62480001, 0x62480001, 0x62480001},
153 +       {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
154 +       {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
155 +       {0x00016848, 0x62480001, 0x62480001, 0x62480001, 0x62480001},
156 +       {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
157 +};
158 +
159 +static const u32 ar9300Modes_fast_clock_2p0[][3] = {
160 +       /* Addr      5G_HT20     5G_HT40   */
161 +       {0x00001030, 0x00000268, 0x000004d0},
162 +       {0x00001070, 0x0000018c, 0x00000318},
163 +       {0x000010b0, 0x00000fd0, 0x00001fa0},
164 +       {0x00008014, 0x044c044c, 0x08980898},
165 +       {0x0000801c, 0x148ec02b, 0x148ec057},
166 +       {0x00008318, 0x000044c0, 0x00008980},
167 +       {0x00009e00, 0x03721821, 0x03721821},
168 +       {0x0000a230, 0x0000000b, 0x00000016},
169 +       {0x0000a254, 0x00000898, 0x00001130},
170 +};
171 +
172 +static const u32 ar9300_2p0_radio_core[][2] = {
173 +       /* Addr      allmodes  */
174 +       {0x00016000, 0x36db6db6},
175 +       {0x00016004, 0x6db6db40},
176 +       {0x00016008, 0x73f00000},
177 +       {0x0001600c, 0x00000000},
178 +       {0x00016040, 0x7f80fff8},
179 +       {0x0001604c, 0x76d005b5},
180 +       {0x00016050, 0x556cf031},
181 +       {0x00016054, 0x13449440},
182 +       {0x00016058, 0x0c51c92c},
183 +       {0x0001605c, 0x3db7fffc},
184 +       {0x00016060, 0xfffffffc},
185 +       {0x00016064, 0x000f0278},
186 +       {0x0001606c, 0x6db60000},
187 +       {0x00016080, 0x00000000},
188 +       {0x00016084, 0x0e48048c},
189 +       {0x00016088, 0x54214514},
190 +       {0x0001608c, 0x119f481e},
191 +       {0x00016090, 0x24926490},
192 +       {0x00016098, 0xd2888888},
193 +       {0x000160a0, 0x0a108ffe},
194 +       {0x000160a4, 0x812fc370},
195 +       {0x000160a8, 0x423c8000},
196 +       {0x000160b4, 0x92480080},
197 +       {0x000160c0, 0x00adb6d0},
198 +       {0x000160c4, 0x6db6db60},
199 +       {0x000160c8, 0x6db6db6c},
200 +       {0x000160cc, 0x01e6c000},
201 +       {0x00016100, 0x3fffbe01},
202 +       {0x00016104, 0xfff80000},
203 +       {0x00016108, 0x00080010},
204 +       {0x00016144, 0x02084080},
205 +       {0x00016148, 0x00000000},
206 +       {0x00016280, 0x058a0001},
207 +       {0x00016284, 0x3d840208},
208 +       {0x00016288, 0x05a20408},
209 +       {0x0001628c, 0x00038c07},
210 +       {0x00016290, 0x40000004},
211 +       {0x00016294, 0x458aa14f},
212 +       {0x00016380, 0x00000000},
213 +       {0x00016384, 0x00000000},
214 +       {0x00016388, 0x00800700},
215 +       {0x0001638c, 0x00800700},
216 +       {0x00016390, 0x00800700},
217 +       {0x00016394, 0x00000000},
218 +       {0x00016398, 0x00000000},
219 +       {0x0001639c, 0x00000000},
220 +       {0x000163a0, 0x00000001},
221 +       {0x000163a4, 0x00000001},
222 +       {0x000163a8, 0x00000000},
223 +       {0x000163ac, 0x00000000},
224 +       {0x000163b0, 0x00000000},
225 +       {0x000163b4, 0x00000000},
226 +       {0x000163b8, 0x00000000},
227 +       {0x000163bc, 0x00000000},
228 +       {0x000163c0, 0x000000a0},
229 +       {0x000163c4, 0x000c0000},
230 +       {0x000163c8, 0x14021402},
231 +       {0x000163cc, 0x00001402},
232 +       {0x000163d0, 0x00000000},
233 +       {0x000163d4, 0x00000000},
234 +       {0x00016400, 0x36db6db6},
235 +       {0x00016404, 0x6db6db40},
236 +       {0x00016408, 0x73f00000},
237 +       {0x0001640c, 0x00000000},
238 +       {0x00016440, 0x7f80fff8},
239 +       {0x0001644c, 0x76d005b5},
240 +       {0x00016450, 0x556cf031},
241 +       {0x00016454, 0x13449440},
242 +       {0x00016458, 0x0c51c92c},
243 +       {0x0001645c, 0x3db7fffc},
244 +       {0x00016460, 0xfffffffc},
245 +       {0x00016464, 0x000f0278},
246 +       {0x0001646c, 0x6db60000},
247 +       {0x00016500, 0x3fffbe01},
248 +       {0x00016504, 0xfff80000},
249 +       {0x00016508, 0x00080010},
250 +       {0x00016544, 0x02084080},
251 +       {0x00016548, 0x00000000},
252 +       {0x00016780, 0x00000000},
253 +       {0x00016784, 0x00000000},
254 +       {0x00016788, 0x00800700},
255 +       {0x0001678c, 0x00800700},
256 +       {0x00016790, 0x00800700},
257 +       {0x00016794, 0x00000000},
258 +       {0x00016798, 0x00000000},
259 +       {0x0001679c, 0x00000000},
260 +       {0x000167a0, 0x00000001},
261 +       {0x000167a4, 0x00000001},
262 +       {0x000167a8, 0x00000000},
263 +       {0x000167ac, 0x00000000},
264 +       {0x000167b0, 0x00000000},
265 +       {0x000167b4, 0x00000000},
266 +       {0x000167b8, 0x00000000},
267 +       {0x000167bc, 0x00000000},
268 +       {0x000167c0, 0x000000a0},
269 +       {0x000167c4, 0x000c0000},
270 +       {0x000167c8, 0x14021402},
271 +       {0x000167cc, 0x00001402},
272 +       {0x000167d0, 0x00000000},
273 +       {0x000167d4, 0x00000000},
274 +       {0x00016800, 0x36db6db6},
275 +       {0x00016804, 0x6db6db40},
276 +       {0x00016808, 0x73f00000},
277 +       {0x0001680c, 0x00000000},
278 +       {0x00016840, 0x7f80fff8},
279 +       {0x0001684c, 0x76d005b5},
280 +       {0x00016850, 0x556cf031},
281 +       {0x00016854, 0x13449440},
282 +       {0x00016858, 0x0c51c92c},
283 +       {0x0001685c, 0x3db7fffc},
284 +       {0x00016860, 0xfffffffc},
285 +       {0x00016864, 0x000f0278},
286 +       {0x0001686c, 0x6db60000},
287 +       {0x00016900, 0x3fffbe01},
288 +       {0x00016904, 0xfff80000},
289 +       {0x00016908, 0x00080010},
290 +       {0x00016944, 0x02084080},
291 +       {0x00016948, 0x00000000},
292 +       {0x00016b80, 0x00000000},
293 +       {0x00016b84, 0x00000000},
294 +       {0x00016b88, 0x00800700},
295 +       {0x00016b8c, 0x00800700},
296 +       {0x00016b90, 0x00800700},
297 +       {0x00016b94, 0x00000000},
298 +       {0x00016b98, 0x00000000},
299 +       {0x00016b9c, 0x00000000},
300 +       {0x00016ba0, 0x00000001},
301 +       {0x00016ba4, 0x00000001},
302 +       {0x00016ba8, 0x00000000},
303 +       {0x00016bac, 0x00000000},
304 +       {0x00016bb0, 0x00000000},
305 +       {0x00016bb4, 0x00000000},
306 +       {0x00016bb8, 0x00000000},
307 +       {0x00016bbc, 0x00000000},
308 +       {0x00016bc0, 0x000000a0},
309 +       {0x00016bc4, 0x000c0000},
310 +       {0x00016bc8, 0x14021402},
311 +       {0x00016bcc, 0x00001402},
312 +       {0x00016bd0, 0x00000000},
313 +       {0x00016bd4, 0x00000000},
314 +};
315 +
316 +static const u32 ar9300Common_rx_gain_table_merlin_2p0[][2] = {
317 +       /* Addr      allmodes  */
318 +       {0x0000a000, 0x02000101},
319 +       {0x0000a004, 0x02000102},
320 +       {0x0000a008, 0x02000103},
321 +       {0x0000a00c, 0x02000104},
322 +       {0x0000a010, 0x02000200},
323 +       {0x0000a014, 0x02000201},
324 +       {0x0000a018, 0x02000202},
325 +       {0x0000a01c, 0x02000203},
326 +       {0x0000a020, 0x02000204},
327 +       {0x0000a024, 0x02000205},
328 +       {0x0000a028, 0x02000208},
329 +       {0x0000a02c, 0x02000302},
330 +       {0x0000a030, 0x02000303},
331 +       {0x0000a034, 0x02000304},
332 +       {0x0000a038, 0x02000400},
333 +       {0x0000a03c, 0x02010300},
334 +       {0x0000a040, 0x02010301},
335 +       {0x0000a044, 0x02010302},
336 +       {0x0000a048, 0x02000500},
337 +       {0x0000a04c, 0x02010400},
338 +       {0x0000a050, 0x02020300},
339 +       {0x0000a054, 0x02020301},
340 +       {0x0000a058, 0x02020302},
341 +       {0x0000a05c, 0x02020303},
342 +       {0x0000a060, 0x02020400},
343 +       {0x0000a064, 0x02030300},
344 +       {0x0000a068, 0x02030301},
345 +       {0x0000a06c, 0x02030302},
346 +       {0x0000a070, 0x02030303},
347 +       {0x0000a074, 0x02030400},
348 +       {0x0000a078, 0x02040300},
349 +       {0x0000a07c, 0x02040301},
350 +       {0x0000a080, 0x02040302},
351 +       {0x0000a084, 0x02040303},
352 +       {0x0000a088, 0x02030500},
353 +       {0x0000a08c, 0x02040400},
354 +       {0x0000a090, 0x02050203},
355 +       {0x0000a094, 0x02050204},
356 +       {0x0000a098, 0x02050205},
357 +       {0x0000a09c, 0x02040500},
358 +       {0x0000a0a0, 0x02050301},
359 +       {0x0000a0a4, 0x02050302},
360 +       {0x0000a0a8, 0x02050303},
361 +       {0x0000a0ac, 0x02050400},
362 +       {0x0000a0b0, 0x02050401},
363 +       {0x0000a0b4, 0x02050402},
364 +       {0x0000a0b8, 0x02050403},
365 +       {0x0000a0bc, 0x02050500},
366 +       {0x0000a0c0, 0x02050501},
367 +       {0x0000a0c4, 0x02050502},
368 +       {0x0000a0c8, 0x02050503},
369 +       {0x0000a0cc, 0x02050504},
370 +       {0x0000a0d0, 0x02050600},
371 +       {0x0000a0d4, 0x02050601},
372 +       {0x0000a0d8, 0x02050602},
373 +       {0x0000a0dc, 0x02050603},
374 +       {0x0000a0e0, 0x02050604},
375 +       {0x0000a0e4, 0x02050700},
376 +       {0x0000a0e8, 0x02050701},
377 +       {0x0000a0ec, 0x02050702},
378 +       {0x0000a0f0, 0x02050703},
379 +       {0x0000a0f4, 0x02050704},
380 +       {0x0000a0f8, 0x02050705},
381 +       {0x0000a0fc, 0x02050708},
382 +       {0x0000a100, 0x02050709},
383 +       {0x0000a104, 0x0205070a},
384 +       {0x0000a108, 0x0205070b},
385 +       {0x0000a10c, 0x0205070c},
386 +       {0x0000a110, 0x0205070d},
387 +       {0x0000a114, 0x02050710},
388 +       {0x0000a118, 0x02050711},
389 +       {0x0000a11c, 0x02050712},
390 +       {0x0000a120, 0x02050713},
391 +       {0x0000a124, 0x02050714},
392 +       {0x0000a128, 0x02050715},
393 +       {0x0000a12c, 0x02050730},
394 +       {0x0000a130, 0x02050731},
395 +       {0x0000a134, 0x02050732},
396 +       {0x0000a138, 0x02050733},
397 +       {0x0000a13c, 0x02050734},
398 +       {0x0000a140, 0x02050735},
399 +       {0x0000a144, 0x02050750},
400 +       {0x0000a148, 0x02050751},
401 +       {0x0000a14c, 0x02050752},
402 +       {0x0000a150, 0x02050753},
403 +       {0x0000a154, 0x02050754},
404 +       {0x0000a158, 0x02050755},
405 +       {0x0000a15c, 0x02050770},
406 +       {0x0000a160, 0x02050771},
407 +       {0x0000a164, 0x02050772},
408 +       {0x0000a168, 0x02050773},
409 +       {0x0000a16c, 0x02050774},
410 +       {0x0000a170, 0x02050775},
411 +       {0x0000a174, 0x00000776},
412 +       {0x0000a178, 0x00000776},
413 +       {0x0000a17c, 0x00000776},
414 +       {0x0000a180, 0x00000776},
415 +       {0x0000a184, 0x00000776},
416 +       {0x0000a188, 0x00000776},
417 +       {0x0000a18c, 0x00000776},
418 +       {0x0000a190, 0x00000776},
419 +       {0x0000a194, 0x00000776},
420 +       {0x0000a198, 0x00000776},
421 +       {0x0000a19c, 0x00000776},
422 +       {0x0000a1a0, 0x00000776},
423 +       {0x0000a1a4, 0x00000776},
424 +       {0x0000a1a8, 0x00000776},
425 +       {0x0000a1ac, 0x00000776},
426 +       {0x0000a1b0, 0x00000776},
427 +       {0x0000a1b4, 0x00000776},
428 +       {0x0000a1b8, 0x00000776},
429 +       {0x0000a1bc, 0x00000776},
430 +       {0x0000a1c0, 0x00000776},
431 +       {0x0000a1c4, 0x00000776},
432 +       {0x0000a1c8, 0x00000776},
433 +       {0x0000a1cc, 0x00000776},
434 +       {0x0000a1d0, 0x00000776},
435 +       {0x0000a1d4, 0x00000776},
436 +       {0x0000a1d8, 0x00000776},
437 +       {0x0000a1dc, 0x00000776},
438 +       {0x0000a1e0, 0x00000776},
439 +       {0x0000a1e4, 0x00000776},
440 +       {0x0000a1e8, 0x00000776},
441 +       {0x0000a1ec, 0x00000776},
442 +       {0x0000a1f0, 0x00000776},
443 +       {0x0000a1f4, 0x00000776},
444 +       {0x0000a1f8, 0x00000776},
445 +       {0x0000a1fc, 0x00000776},
446 +       {0x0000b000, 0x02000101},
447 +       {0x0000b004, 0x02000102},
448 +       {0x0000b008, 0x02000103},
449 +       {0x0000b00c, 0x02000104},
450 +       {0x0000b010, 0x02000200},
451 +       {0x0000b014, 0x02000201},
452 +       {0x0000b018, 0x02000202},
453 +       {0x0000b01c, 0x02000203},
454 +       {0x0000b020, 0x02000204},
455 +       {0x0000b024, 0x02000205},
456 +       {0x0000b028, 0x02000208},
457 +       {0x0000b02c, 0x02000302},
458 +       {0x0000b030, 0x02000303},
459 +       {0x0000b034, 0x02000304},
460 +       {0x0000b038, 0x02000400},
461 +       {0x0000b03c, 0x02010300},
462 +       {0x0000b040, 0x02010301},
463 +       {0x0000b044, 0x02010302},
464 +       {0x0000b048, 0x02000500},
465 +       {0x0000b04c, 0x02010400},
466 +       {0x0000b050, 0x02020300},
467 +       {0x0000b054, 0x02020301},
468 +       {0x0000b058, 0x02020302},
469 +       {0x0000b05c, 0x02020303},
470 +       {0x0000b060, 0x02020400},
471 +       {0x0000b064, 0x02030300},
472 +       {0x0000b068, 0x02030301},
473 +       {0x0000b06c, 0x02030302},
474 +       {0x0000b070, 0x02030303},
475 +       {0x0000b074, 0x02030400},
476 +       {0x0000b078, 0x02040300},
477 +       {0x0000b07c, 0x02040301},
478 +       {0x0000b080, 0x02040302},
479 +       {0x0000b084, 0x02040303},
480 +       {0x0000b088, 0x02030500},
481 +       {0x0000b08c, 0x02040400},
482 +       {0x0000b090, 0x02050203},
483 +       {0x0000b094, 0x02050204},
484 +       {0x0000b098, 0x02050205},
485 +       {0x0000b09c, 0x02040500},
486 +       {0x0000b0a0, 0x02050301},
487 +       {0x0000b0a4, 0x02050302},
488 +       {0x0000b0a8, 0x02050303},
489 +       {0x0000b0ac, 0x02050400},
490 +       {0x0000b0b0, 0x02050401},
491 +       {0x0000b0b4, 0x02050402},
492 +       {0x0000b0b8, 0x02050403},
493 +       {0x0000b0bc, 0x02050500},
494 +       {0x0000b0c0, 0x02050501},
495 +       {0x0000b0c4, 0x02050502},
496 +       {0x0000b0c8, 0x02050503},
497 +       {0x0000b0cc, 0x02050504},
498 +       {0x0000b0d0, 0x02050600},
499 +       {0x0000b0d4, 0x02050601},
500 +       {0x0000b0d8, 0x02050602},
501 +       {0x0000b0dc, 0x02050603},
502 +       {0x0000b0e0, 0x02050604},
503 +       {0x0000b0e4, 0x02050700},
504 +       {0x0000b0e8, 0x02050701},
505 +       {0x0000b0ec, 0x02050702},
506 +       {0x0000b0f0, 0x02050703},
507 +       {0x0000b0f4, 0x02050704},
508 +       {0x0000b0f8, 0x02050705},
509 +       {0x0000b0fc, 0x02050708},
510 +       {0x0000b100, 0x02050709},
511 +       {0x0000b104, 0x0205070a},
512 +       {0x0000b108, 0x0205070b},
513 +       {0x0000b10c, 0x0205070c},
514 +       {0x0000b110, 0x0205070d},
515 +       {0x0000b114, 0x02050710},
516 +       {0x0000b118, 0x02050711},
517 +       {0x0000b11c, 0x02050712},
518 +       {0x0000b120, 0x02050713},
519 +       {0x0000b124, 0x02050714},
520 +       {0x0000b128, 0x02050715},
521 +       {0x0000b12c, 0x02050730},
522 +       {0x0000b130, 0x02050731},
523 +       {0x0000b134, 0x02050732},
524 +       {0x0000b138, 0x02050733},
525 +       {0x0000b13c, 0x02050734},
526 +       {0x0000b140, 0x02050735},
527 +       {0x0000b144, 0x02050750},
528 +       {0x0000b148, 0x02050751},
529 +       {0x0000b14c, 0x02050752},
530 +       {0x0000b150, 0x02050753},
531 +       {0x0000b154, 0x02050754},
532 +       {0x0000b158, 0x02050755},
533 +       {0x0000b15c, 0x02050770},
534 +       {0x0000b160, 0x02050771},
535 +       {0x0000b164, 0x02050772},
536 +       {0x0000b168, 0x02050773},
537 +       {0x0000b16c, 0x02050774},
538 +       {0x0000b170, 0x02050775},
539 +       {0x0000b174, 0x00000776},
540 +       {0x0000b178, 0x00000776},
541 +       {0x0000b17c, 0x00000776},
542 +       {0x0000b180, 0x00000776},
543 +       {0x0000b184, 0x00000776},
544 +       {0x0000b188, 0x00000776},
545 +       {0x0000b18c, 0x00000776},
546 +       {0x0000b190, 0x00000776},
547 +       {0x0000b194, 0x00000776},
548 +       {0x0000b198, 0x00000776},
549 +       {0x0000b19c, 0x00000776},
550 +       {0x0000b1a0, 0x00000776},
551 +       {0x0000b1a4, 0x00000776},
552 +       {0x0000b1a8, 0x00000776},
553 +       {0x0000b1ac, 0x00000776},
554 +       {0x0000b1b0, 0x00000776},
555 +       {0x0000b1b4, 0x00000776},
556 +       {0x0000b1b8, 0x00000776},
557 +       {0x0000b1bc, 0x00000776},
558 +       {0x0000b1c0, 0x00000776},
559 +       {0x0000b1c4, 0x00000776},
560 +       {0x0000b1c8, 0x00000776},
561 +       {0x0000b1cc, 0x00000776},
562 +       {0x0000b1d0, 0x00000776},
563 +       {0x0000b1d4, 0x00000776},
564 +       {0x0000b1d8, 0x00000776},
565 +       {0x0000b1dc, 0x00000776},
566 +       {0x0000b1e0, 0x00000776},
567 +       {0x0000b1e4, 0x00000776},
568 +       {0x0000b1e8, 0x00000776},
569 +       {0x0000b1ec, 0x00000776},
570 +       {0x0000b1f0, 0x00000776},
571 +       {0x0000b1f4, 0x00000776},
572 +       {0x0000b1f8, 0x00000776},
573 +       {0x0000b1fc, 0x00000776},
574 +};
575 +
576 +static const u32 ar9300_2p0_mac_postamble[][5] = {
577 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
578 +       {0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160},
579 +       {0x00001070, 0x00000168, 0x000002d0, 0x00000318, 0x0000018c},
580 +       {0x000010b0, 0x00000e60, 0x00001cc0, 0x00007c70, 0x00003e38},
581 +       {0x00008014, 0x03e803e8, 0x07d007d0, 0x10801600, 0x08400b00},
582 +       {0x0000801c, 0x128d8027, 0x128d804f, 0x12e00057, 0x12e0002b},
583 +       {0x00008120, 0x08f04800, 0x08f04800, 0x08f04810, 0x08f04810},
584 +       {0x000081d0, 0x00003210, 0x00003210, 0x0000320a, 0x0000320a},
585 +       {0x00008318, 0x00003e80, 0x00007d00, 0x00006880, 0x00003440},
586 +};
587 +
588 +static const u32 ar9300_2p0_soc_postamble[][5] = {
589 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
590 +       {0x00007010, 0x00000023, 0x00000023, 0x00000023, 0x00000023},
591 +};
592 +
593 +static const u32 ar9200_merlin_2p0_radio_core[][2] = {
594 +       /* Addr      allmodes  */
595 +       {0x00007800, 0x00040000},
596 +       {0x00007804, 0xdb005012},
597 +       {0x00007808, 0x04924914},
598 +       {0x0000780c, 0x21084210},
599 +       {0x00007810, 0x6d801300},
600 +       {0x00007814, 0x0019beff},
601 +       {0x00007818, 0x07e41000},
602 +       {0x0000781c, 0x00392000},
603 +       {0x00007820, 0x92592480},
604 +       {0x00007824, 0x00040000},
605 +       {0x00007828, 0xdb005012},
606 +       {0x0000782c, 0x04924914},
607 +       {0x00007830, 0x21084210},
608 +       {0x00007834, 0x6d801300},
609 +       {0x00007838, 0x0019beff},
610 +       {0x0000783c, 0x07e40000},
611 +       {0x00007840, 0x00392000},
612 +       {0x00007844, 0x92592480},
613 +       {0x00007848, 0x00100000},
614 +       {0x0000784c, 0x773f0567},
615 +       {0x00007850, 0x54214514},
616 +       {0x00007854, 0x12035828},
617 +       {0x00007858, 0x92592692},
618 +       {0x0000785c, 0x00000000},
619 +       {0x00007860, 0x56400000},
620 +       {0x00007864, 0x0a8e370e},
621 +       {0x00007868, 0xc0102850},
622 +       {0x0000786c, 0x812d4000},
623 +       {0x00007870, 0x807ec400},
624 +       {0x00007874, 0x001b6db0},
625 +       {0x00007878, 0x00376b63},
626 +       {0x0000787c, 0x06db6db6},
627 +       {0x00007880, 0x006d8000},
628 +       {0x00007884, 0xffeffffe},
629 +       {0x00007888, 0xffeffffe},
630 +       {0x0000788c, 0x00010000},
631 +       {0x00007890, 0x02060aeb},
632 +       {0x00007894, 0x5a108000},
633 +};
634 +
635 +static const u32 ar9300_2p0_baseband_postamble[][5] = {
636 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
637 +       {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8011, 0xd00a8011},
638 +       {0x00009820, 0x206a022e, 0x206a022e, 0x206a012e, 0x206a012e},
639 +       {0x00009824, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0},
640 +       {0x00009828, 0x06903081, 0x06903081, 0x06903881, 0x06903881},
641 +       {0x0000982c, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4},
642 +       {0x00009830, 0x0000059c, 0x0000059c, 0x0000119c, 0x0000119c},
643 +       {0x00009c00, 0x00000044, 0x000000c4, 0x000000c4, 0x00000044},
644 +       {0x00009e00, 0x0372161e, 0x0372161e, 0x037216a0, 0x037216a0},
645 +       {0x00009e04, 0x00802020, 0x00802020, 0x00802020, 0x00802020},
646 +       {0x00009e0c, 0x6c4000e2, 0x6d4000e2, 0x6d4000e2, 0x6c4000e2},
647 +       {0x00009e10, 0x7ec88d2e, 0x7ec88d2e, 0x7ec84d2e, 0x7ec84d2e},
648 +       {0x00009e14, 0x31395d5e, 0x3139605e, 0x3139605e, 0x31395d5e},
649 +       {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
650 +       {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c},
651 +       {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce},
652 +       {0x00009e2c, 0x0000001c, 0x0000001c, 0x00000021, 0x00000021},
653 +       {0x00009e44, 0x02321e27, 0x02321e27, 0x02291e27, 0x02291e27},
654 +       {0x00009e48, 0x5030201a, 0x5030201a, 0x50302012, 0x50302012},
655 +       {0x00009fc8, 0x0003f000, 0x0003f000, 0x0001a000, 0x0001a000},
656 +       {0x0000a204, 0x000037c0, 0x000037c4, 0x000037c4, 0x000037c0},
657 +       {0x0000a208, 0x00000104, 0x00000104, 0x00000004, 0x00000004},
658 +       {0x0000a230, 0x0000000a, 0x00000014, 0x00000016, 0x0000000b},
659 +       {0x0000a238, 0xffb81018, 0xffb81018, 0xffb81018, 0xffb81018},
660 +       {0x0000a250, 0x00000000, 0x00000000, 0x00000210, 0x00000108},
661 +       {0x0000a254, 0x000007d0, 0x00000fa0, 0x00001130, 0x00000898},
662 +       {0x0000a258, 0x02020002, 0x02020002, 0x02020002, 0x02020002},
663 +       {0x0000a25c, 0x01000e0e, 0x01000e0e, 0x01000e0e, 0x01000e0e},
664 +       {0x0000a260, 0x0a021501, 0x0a021501, 0x3a021501, 0x3a021501},
665 +       {0x0000a264, 0x00000e0e, 0x00000e0e, 0x00000e0e, 0x00000e0e},
666 +       {0x0000a280, 0x00000007, 0x00000007, 0x0000000b, 0x0000000b},
667 +       {0x0000a284, 0x00000000, 0x00000000, 0x00000150, 0x00000150},
668 +       {0x0000a288, 0x00000110, 0x00000110, 0x00000110, 0x00000110},
669 +       {0x0000a28c, 0x00022222, 0x00022222, 0x00022222, 0x00022222},
670 +       {0x0000a2c4, 0x00158d18, 0x00158d18, 0x00158d18, 0x00158d18},
671 +       {0x0000a2d0, 0x00071981, 0x00071981, 0x00071981, 0x00071982},
672 +       {0x0000a2d8, 0xf999a83a, 0xf999a83a, 0xf999a83a, 0xf999a83a},
673 +       {0x0000a358, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
674 +       {0x0000a830, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
675 +       {0x0000ae04, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
676 +       {0x0000ae18, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
677 +       {0x0000ae1c, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
678 +       {0x0000ae20, 0x000001b5, 0x000001b5, 0x000001ce, 0x000001ce},
679 +       {0x0000b284, 0x00000000, 0x00000000, 0x00000150, 0x00000150},
680 +       {0x0000b830, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
681 +       {0x0000be04, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
682 +       {0x0000be18, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
683 +       {0x0000be1c, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
684 +       {0x0000be20, 0x000001b5, 0x000001b5, 0x000001ce, 0x000001ce},
685 +       {0x0000c284, 0x00000000, 0x00000000, 0x00000150, 0x00000150},
686 +};
687 +
688 +static const u32 ar9300_2p0_baseband_core[][2] = {
689 +       /* Addr      allmodes  */
690 +       {0x00009800, 0xafe68e30},
691 +       {0x00009804, 0xfd14e000},
692 +       {0x00009808, 0x9c0a9f6b},
693 +       {0x0000980c, 0x04900000},
694 +       {0x00009814, 0x9280c00a},
695 +       {0x00009818, 0x00000000},
696 +       {0x0000981c, 0x00020028},
697 +       {0x00009834, 0x5f3ca3de},
698 +       {0x00009838, 0x0108ecff},
699 +       {0x0000983c, 0x14750600},
700 +       {0x00009880, 0x201fff00},
701 +       {0x00009884, 0x00001042},
702 +       {0x000098a4, 0x00200400},
703 +       {0x000098b0, 0x52440bbe},
704 +       {0x000098d0, 0x004b6a8e},
705 +       {0x000098d4, 0x00000820},
706 +       {0x000098dc, 0x00000000},
707 +       {0x000098f0, 0x00000000},
708 +       {0x000098f4, 0x00000000},
709 +       {0x00009c04, 0xff55ff55},
710 +       {0x00009c08, 0x0320ff55},
711 +       {0x00009c0c, 0x00000000},
712 +       {0x00009c10, 0x00000000},
713 +       {0x00009c14, 0x00046384},
714 +       {0x00009c18, 0x05b6b440},
715 +       {0x00009c1c, 0x00b6b440},
716 +       {0x00009d00, 0xc080a333},
717 +       {0x00009d04, 0x40206c10},
718 +       {0x00009d08, 0x009c4060},
719 +       {0x00009d0c, 0x9883800a},
720 +       {0x00009d10, 0x01834061},
721 +       {0x00009d14, 0x00c0040b},
722 +       {0x00009d18, 0x00000000},
723 +       {0x00009e08, 0x0038230c},
724 +       {0x00009e24, 0x990bb515},
725 +       {0x00009e28, 0x0c6f0000},
726 +       {0x00009e30, 0x06336f77},
727 +       {0x00009e34, 0x6af6532f},
728 +       {0x00009e38, 0x0cc80c00},
729 +       {0x00009e3c, 0xcf946222},
730 +       {0x00009e40, 0x0d261820},
731 +       {0x00009e4c, 0x00001004},
732 +       {0x00009e50, 0x00ff03f1},
733 +       {0x00009e54, 0x00000000},
734 +       {0x00009fc0, 0x803e4788},
735 +       {0x00009fc4, 0x0001efb5},
736 +       {0x00009fcc, 0x40000014},
737 +       {0x00009fd0, 0x01193b93},
738 +       {0x0000a20c, 0x00000000},
739 +       {0x0000a220, 0x00000000},
740 +       {0x0000a224, 0x00000000},
741 +       {0x0000a228, 0x10002310},
742 +       {0x0000a22c, 0x01036a1e},
743 +       {0x0000a234, 0x10000fff},
744 +       {0x0000a23c, 0x00000000},
745 +       {0x0000a244, 0x0c000000},
746 +       {0x0000a2a0, 0x00000001},
747 +       {0x0000a2c0, 0x00000001},
748 +       {0x0000a2c8, 0x00000000},
749 +       {0x0000a2cc, 0x18c43433},
750 +       {0x0000a2d4, 0x00000000},
751 +       {0x0000a2dc, 0x00000000},
752 +       {0x0000a2e0, 0x00000000},
753 +       {0x0000a2e4, 0x00000000},
754 +       {0x0000a2e8, 0x00000000},
755 +       {0x0000a2ec, 0x00000000},
756 +       {0x0000a2f0, 0x00000000},
757 +       {0x0000a2f4, 0x00000000},
758 +       {0x0000a2f8, 0x00000000},
759 +       {0x0000a344, 0x00000000},
760 +       {0x0000a34c, 0x00000000},
761 +       {0x0000a350, 0x0000a000},
762 +       {0x0000a364, 0x00000000},
763 +       {0x0000a370, 0x00000000},
764 +       {0x0000a390, 0x00000001},
765 +       {0x0000a394, 0x00000444},
766 +       {0x0000a398, 0x001f0e0f},
767 +       {0x0000a39c, 0x0075393f},
768 +       {0x0000a3a0, 0xb79f6427},
769 +       {0x0000a3a4, 0x00000000},
770 +       {0x0000a3a8, 0xaaaaaaaa},
771 +       {0x0000a3ac, 0x3c466478},
772 +       {0x0000a3c0, 0x20202020},
773 +       {0x0000a3c4, 0x22222220},
774 +       {0x0000a3c8, 0x20200020},
775 +       {0x0000a3cc, 0x20202020},
776 +       {0x0000a3d0, 0x20202020},
777 +       {0x0000a3d4, 0x20202020},
778 +       {0x0000a3d8, 0x20202020},
779 +       {0x0000a3dc, 0x20202020},
780 +       {0x0000a3e0, 0x20202020},
781 +       {0x0000a3e4, 0x20202020},
782 +       {0x0000a3e8, 0x20202020},
783 +       {0x0000a3ec, 0x20202020},
784 +       {0x0000a3f0, 0x00000000},
785 +       {0x0000a3f4, 0x00000246},
786 +       {0x0000a3f8, 0x0cdbd380},
787 +       {0x0000a3fc, 0x000f0f01},
788 +       {0x0000a400, 0x8fa91f01},
789 +       {0x0000a404, 0x00000000},
790 +       {0x0000a408, 0x0e79e5c6},
791 +       {0x0000a40c, 0x00820820},
792 +       {0x0000a414, 0x1ce739ce},
793 +       {0x0000a418, 0x2d001dce},
794 +       {0x0000a41c, 0x1ce739ce},
795 +       {0x0000a420, 0x000001ce},
796 +       {0x0000a424, 0x1ce739ce},
797 +       {0x0000a428, 0x000001ce},
798 +       {0x0000a42c, 0x1ce739ce},
799 +       {0x0000a430, 0x1ce739ce},
800 +       {0x0000a434, 0x00000000},
801 +       {0x0000a438, 0x00001801},
802 +       {0x0000a43c, 0x00000000},
803 +       {0x0000a440, 0x00000000},
804 +       {0x0000a444, 0x00000000},
805 +       {0x0000a448, 0x04000080},
806 +       {0x0000a44c, 0x00000001},
807 +       {0x0000a450, 0x00010000},
808 +       {0x0000a458, 0x00000000},
809 +       {0x0000a600, 0x00000000},
810 +       {0x0000a604, 0x00000000},
811 +       {0x0000a608, 0x00000000},
812 +       {0x0000a60c, 0x00000000},
813 +       {0x0000a610, 0x00000000},
814 +       {0x0000a614, 0x00000000},
815 +       {0x0000a618, 0x00000000},
816 +       {0x0000a61c, 0x00000000},
817 +       {0x0000a620, 0x00000000},
818 +       {0x0000a624, 0x00000000},
819 +       {0x0000a628, 0x00000000},
820 +       {0x0000a62c, 0x00000000},
821 +       {0x0000a630, 0x00000000},
822 +       {0x0000a634, 0x00000000},
823 +       {0x0000a638, 0x00000000},
824 +       {0x0000a63c, 0x00000000},
825 +       {0x0000a640, 0x00000000},
826 +       {0x0000a644, 0x3fad9d74},
827 +       {0x0000a648, 0x0048060a},
828 +       {0x0000a64c, 0x00000637},
829 +       {0x0000a670, 0x03020100},
830 +       {0x0000a674, 0x09080504},
831 +       {0x0000a678, 0x0d0c0b0a},
832 +       {0x0000a67c, 0x13121110},
833 +       {0x0000a680, 0x31301514},
834 +       {0x0000a684, 0x35343332},
835 +       {0x0000a688, 0x00000036},
836 +       {0x0000a690, 0x00000838},
837 +       {0x0000a7c0, 0x00000000},
838 +       {0x0000a7c4, 0xfffffffc},
839 +       {0x0000a7c8, 0x00000000},
840 +       {0x0000a7cc, 0x00000000},
841 +       {0x0000a7d0, 0x00000000},
842 +       {0x0000a7d4, 0x00000004},
843 +       {0x0000a7dc, 0x00000001},
844 +       {0x0000a8d0, 0x004b6a8e},
845 +       {0x0000a8d4, 0x00000820},
846 +       {0x0000a8dc, 0x00000000},
847 +       {0x0000a8f0, 0x00000000},
848 +       {0x0000a8f4, 0x00000000},
849 +       {0x0000b2d0, 0x00000080},
850 +       {0x0000b2d4, 0x00000000},
851 +       {0x0000b2dc, 0x00000000},
852 +       {0x0000b2e0, 0x00000000},
853 +       {0x0000b2e4, 0x00000000},
854 +       {0x0000b2e8, 0x00000000},
855 +       {0x0000b2ec, 0x00000000},
856 +       {0x0000b2f0, 0x00000000},
857 +       {0x0000b2f4, 0x00000000},
858 +       {0x0000b2f8, 0x00000000},
859 +       {0x0000b408, 0x0e79e5c0},
860 +       {0x0000b40c, 0x00820820},
861 +       {0x0000b420, 0x00000000},
862 +       {0x0000b8d0, 0x004b6a8e},
863 +       {0x0000b8d4, 0x00000820},
864 +       {0x0000b8dc, 0x00000000},
865 +       {0x0000b8f0, 0x00000000},
866 +       {0x0000b8f4, 0x00000000},
867 +       {0x0000c2d0, 0x00000080},
868 +       {0x0000c2d4, 0x00000000},
869 +       {0x0000c2dc, 0x00000000},
870 +       {0x0000c2e0, 0x00000000},
871 +       {0x0000c2e4, 0x00000000},
872 +       {0x0000c2e8, 0x00000000},
873 +       {0x0000c2ec, 0x00000000},
874 +       {0x0000c2f0, 0x00000000},
875 +       {0x0000c2f4, 0x00000000},
876 +       {0x0000c2f8, 0x00000000},
877 +       {0x0000c408, 0x0e79e5c0},
878 +       {0x0000c40c, 0x00820820},
879 +       {0x0000c420, 0x00000000},
880 +};
881 +
882 +static const u32 ar9300Modes_high_power_tx_gain_table_2p0[][5] = {
883 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
884 +       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
885 +       {0x0000a500, 0x00002220, 0x00002220, 0x00000000, 0x00000000},
886 +       {0x0000a504, 0x06002223, 0x06002223, 0x04000002, 0x04000002},
887 +       {0x0000a508, 0x0a022220, 0x0a022220, 0x08000004, 0x08000004},
888 +       {0x0000a50c, 0x0f022223, 0x0f022223, 0x0b000200, 0x0b000200},
889 +       {0x0000a510, 0x14022620, 0x14022620, 0x0f000202, 0x0f000202},
890 +       {0x0000a514, 0x18022622, 0x18022622, 0x11000400, 0x11000400},
891 +       {0x0000a518, 0x1b022822, 0x1b022822, 0x15000402, 0x15000402},
892 +       {0x0000a51c, 0x20022842, 0x20022842, 0x19000404, 0x19000404},
893 +       {0x0000a520, 0x22022c41, 0x22022c41, 0x1b000603, 0x1b000603},
894 +       {0x0000a524, 0x28023042, 0x28023042, 0x1f000a02, 0x1f000a02},
895 +       {0x0000a528, 0x2c023044, 0x2c023044, 0x23000a04, 0x23000a04},
896 +       {0x0000a52c, 0x2f023644, 0x2f023644, 0x26000a20, 0x26000a20},
897 +       {0x0000a530, 0x34025643, 0x34025643, 0x2a000e20, 0x2a000e20},
898 +       {0x0000a534, 0x38025a44, 0x38025a44, 0x2e000e22, 0x2e000e22},
899 +       {0x0000a538, 0x3b025e45, 0x3b025e45, 0x31000e24, 0x31000e24},
900 +       {0x0000a53c, 0x41025e4a, 0x41025e4a, 0x34001640, 0x34001640},
901 +       {0x0000a540, 0x48025e6c, 0x48025e6c, 0x38001660, 0x38001660},
902 +       {0x0000a544, 0x4e025e8e, 0x4e025e8e, 0x3b001861, 0x3b001861},
903 +       {0x0000a548, 0x53025eb2, 0x53025eb2, 0x3e001a81, 0x3e001a81},
904 +       {0x0000a54c, 0x59025eb5, 0x59025eb5, 0x42001a83, 0x42001a83},
905 +       {0x0000a550, 0x5f025ef6, 0x5f025ef6, 0x44001c84, 0x44001c84},
906 +       {0x0000a554, 0x62025f56, 0x62025f56, 0x48001ce3, 0x48001ce3},
907 +       {0x0000a558, 0x66027f56, 0x66027f56, 0x4c001ce5, 0x4c001ce5},
908 +       {0x0000a55c, 0x6a029f56, 0x6a029f56, 0x50001ce9, 0x50001ce9},
909 +       {0x0000a560, 0x70049f56, 0x70049f56, 0x54001ceb, 0x54001ceb},
910 +       {0x0000a564, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
911 +       {0x0000a568, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
912 +       {0x0000a56c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
913 +       {0x0000a570, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
914 +       {0x0000a574, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
915 +       {0x0000a578, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
916 +       {0x0000a57c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
917 +       {0x0000a580, 0x00802220, 0x00802220, 0x00800000, 0x00800000},
918 +       {0x0000a584, 0x06802223, 0x06802223, 0x04800002, 0x04800002},
919 +       {0x0000a588, 0x0a822220, 0x0a822220, 0x08800004, 0x08800004},
920 +       {0x0000a58c, 0x0f822223, 0x0f822223, 0x0b800200, 0x0b800200},
921 +       {0x0000a590, 0x14822620, 0x14822620, 0x0f800202, 0x0f800202},
922 +       {0x0000a594, 0x18822622, 0x18822622, 0x11800400, 0x11800400},
923 +       {0x0000a598, 0x1b822822, 0x1b822822, 0x15800402, 0x15800402},
924 +       {0x0000a59c, 0x20822842, 0x20822842, 0x19800404, 0x19800404},
925 +       {0x0000a5a0, 0x22822c41, 0x22822c41, 0x1b800603, 0x1b800603},
926 +       {0x0000a5a4, 0x28823042, 0x28823042, 0x1f800a02, 0x1f800a02},
927 +       {0x0000a5a8, 0x2c823044, 0x2c823044, 0x23800a04, 0x23800a04},
928 +       {0x0000a5ac, 0x2f823644, 0x2f823644, 0x26800a20, 0x26800a20},
929 +       {0x0000a5b0, 0x34825643, 0x34825643, 0x2a800e20, 0x2a800e20},
930 +       {0x0000a5b4, 0x38825a44, 0x38825a44, 0x2e800e22, 0x2e800e22},
931 +       {0x0000a5b8, 0x3b825e45, 0x3b825e45, 0x31800e24, 0x31800e24},
932 +       {0x0000a5bc, 0x41825e4a, 0x41825e4a, 0x34801640, 0x34801640},
933 +       {0x0000a5c0, 0x48825e6c, 0x48825e6c, 0x38801660, 0x38801660},
934 +       {0x0000a5c4, 0x4e825e8e, 0x4e825e8e, 0x3b801861, 0x3b801861},
935 +       {0x0000a5c8, 0x53825eb2, 0x53825eb2, 0x3e801a81, 0x3e801a81},
936 +       {0x0000a5cc, 0x59825eb5, 0x59825eb5, 0x42801a83, 0x42801a83},
937 +       {0x0000a5d0, 0x5f825ef6, 0x5f825ef6, 0x44801c84, 0x44801c84},
938 +       {0x0000a5d4, 0x62825f56, 0x62825f56, 0x48801ce3, 0x48801ce3},
939 +       {0x0000a5d8, 0x66827f56, 0x66827f56, 0x4c801ce5, 0x4c801ce5},
940 +       {0x0000a5dc, 0x6a829f56, 0x6a829f56, 0x50801ce9, 0x50801ce9},
941 +       {0x0000a5e0, 0x70849f56, 0x70849f56, 0x54801ceb, 0x54801ceb},
942 +       {0x0000a5e4, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
943 +       {0x0000a5e8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
944 +       {0x0000a5ec, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
945 +       {0x0000a5f0, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
946 +       {0x0000a5f4, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
947 +       {0x0000a5f8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
948 +       {0x0000a5fc, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
949 +       {0x00016044, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6},
950 +       {0x00016048, 0xae480001, 0xae480001, 0xae480001, 0xae480001},
951 +       {0x00016068, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c},
952 +       {0x00016444, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6},
953 +       {0x00016448, 0xae480001, 0xae480001, 0xae480001, 0xae480001},
954 +       {0x00016468, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c},
955 +       {0x00016844, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6},
956 +       {0x00016848, 0xae480001, 0xae480001, 0xae480001, 0xae480001},
957 +       {0x00016868, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c},
958 +};
959 +
960 +static const u32 ar9300Modes_high_ob_db_tx_gain_table_2p0[][5] = {
961 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
962 +       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
963 +       {0x0000a500, 0x00002220, 0x00002220, 0x00000000, 0x00000000},
964 +       {0x0000a504, 0x06002223, 0x06002223, 0x04000002, 0x04000002},
965 +       {0x0000a508, 0x0a022220, 0x0a022220, 0x08000004, 0x08000004},
966 +       {0x0000a50c, 0x0f022223, 0x0f022223, 0x0b000200, 0x0b000200},
967 +       {0x0000a510, 0x14022620, 0x14022620, 0x0f000202, 0x0f000202},
968 +       {0x0000a514, 0x18022622, 0x18022622, 0x11000400, 0x11000400},
969 +       {0x0000a518, 0x1b022822, 0x1b022822, 0x15000402, 0x15000402},
970 +       {0x0000a51c, 0x20022842, 0x20022842, 0x19000404, 0x19000404},
971 +       {0x0000a520, 0x22022c41, 0x22022c41, 0x1b000603, 0x1b000603},
972 +       {0x0000a524, 0x28023042, 0x28023042, 0x1f000a02, 0x1f000a02},
973 +       {0x0000a528, 0x2c023044, 0x2c023044, 0x23000a04, 0x23000a04},
974 +       {0x0000a52c, 0x2f023644, 0x2f023644, 0x26000a20, 0x26000a20},
975 +       {0x0000a530, 0x34025643, 0x34025643, 0x2a000e20, 0x2a000e20},
976 +       {0x0000a534, 0x38025a44, 0x38025a44, 0x2e000e22, 0x2e000e22},
977 +       {0x0000a538, 0x3b025e45, 0x3b025e45, 0x31000e24, 0x31000e24},
978 +       {0x0000a53c, 0x41025e4a, 0x41025e4a, 0x34001640, 0x34001640},
979 +       {0x0000a540, 0x48025e6c, 0x48025e6c, 0x38001660, 0x38001660},
980 +       {0x0000a544, 0x4e025e8e, 0x4e025e8e, 0x3b001861, 0x3b001861},
981 +       {0x0000a548, 0x53025eb2, 0x53025eb2, 0x3e001a81, 0x3e001a81},
982 +       {0x0000a54c, 0x59025eb5, 0x59025eb5, 0x42001a83, 0x42001a83},
983 +       {0x0000a550, 0x5f025ef6, 0x5f025ef6, 0x44001c84, 0x44001c84},
984 +       {0x0000a554, 0x62025f56, 0x62025f56, 0x48001ce3, 0x48001ce3},
985 +       {0x0000a558, 0x66027f56, 0x66027f56, 0x4c001ce5, 0x4c001ce5},
986 +       {0x0000a55c, 0x6a029f56, 0x6a029f56, 0x50001ce9, 0x50001ce9},
987 +       {0x0000a560, 0x70049f56, 0x70049f56, 0x54001ceb, 0x54001ceb},
988 +       {0x0000a564, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
989 +       {0x0000a568, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
990 +       {0x0000a56c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
991 +       {0x0000a570, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
992 +       {0x0000a574, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
993 +       {0x0000a578, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
994 +       {0x0000a57c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
995 +       {0x0000a580, 0x00802220, 0x00802220, 0x00800000, 0x00800000},
996 +       {0x0000a584, 0x06802223, 0x06802223, 0x04800002, 0x04800002},
997 +       {0x0000a588, 0x0a822220, 0x0a822220, 0x08800004, 0x08800004},
998 +       {0x0000a58c, 0x0f822223, 0x0f822223, 0x0b800200, 0x0b800200},
999 +       {0x0000a590, 0x14822620, 0x14822620, 0x0f800202, 0x0f800202},
1000 +       {0x0000a594, 0x18822622, 0x18822622, 0x11800400, 0x11800400},
1001 +       {0x0000a598, 0x1b822822, 0x1b822822, 0x15800402, 0x15800402},
1002 +       {0x0000a59c, 0x20822842, 0x20822842, 0x19800404, 0x19800404},
1003 +       {0x0000a5a0, 0x22822c41, 0x22822c41, 0x1b800603, 0x1b800603},
1004 +       {0x0000a5a4, 0x28823042, 0x28823042, 0x1f800a02, 0x1f800a02},
1005 +       {0x0000a5a8, 0x2c823044, 0x2c823044, 0x23800a04, 0x23800a04},
1006 +       {0x0000a5ac, 0x2f823644, 0x2f823644, 0x26800a20, 0x26800a20},
1007 +       {0x0000a5b0, 0x34825643, 0x34825643, 0x2a800e20, 0x2a800e20},
1008 +       {0x0000a5b4, 0x38825a44, 0x38825a44, 0x2e800e22, 0x2e800e22},
1009 +       {0x0000a5b8, 0x3b825e45, 0x3b825e45, 0x31800e24, 0x31800e24},
1010 +       {0x0000a5bc, 0x41825e4a, 0x41825e4a, 0x34801640, 0x34801640},
1011 +       {0x0000a5c0, 0x48825e6c, 0x48825e6c, 0x38801660, 0x38801660},
1012 +       {0x0000a5c4, 0x4e825e8e, 0x4e825e8e, 0x3b801861, 0x3b801861},
1013 +       {0x0000a5c8, 0x53825eb2, 0x53825eb2, 0x3e801a81, 0x3e801a81},
1014 +       {0x0000a5cc, 0x59825eb5, 0x59825eb5, 0x42801a83, 0x42801a83},
1015 +       {0x0000a5d0, 0x5f825ef6, 0x5f825ef6, 0x44801c84, 0x44801c84},
1016 +       {0x0000a5d4, 0x62825f56, 0x62825f56, 0x48801ce3, 0x48801ce3},
1017 +       {0x0000a5d8, 0x66827f56, 0x66827f56, 0x4c801ce5, 0x4c801ce5},
1018 +       {0x0000a5dc, 0x6a829f56, 0x6a829f56, 0x50801ce9, 0x50801ce9},
1019 +       {0x0000a5e0, 0x70849f56, 0x70849f56, 0x54801ceb, 0x54801ceb},
1020 +       {0x0000a5e4, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
1021 +       {0x0000a5e8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
1022 +       {0x0000a5ec, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
1023 +       {0x0000a5f0, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
1024 +       {0x0000a5f4, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
1025 +       {0x0000a5f8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
1026 +       {0x0000a5fc, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
1027 +       {0x00016044, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4},
1028 +       {0x00016048, 0x8e480001, 0x8e480001, 0x8e480001, 0x8e480001},
1029 +       {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1030 +       {0x00016444, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4},
1031 +       {0x00016448, 0x8e480001, 0x8e480001, 0x8e480001, 0x8e480001},
1032 +       {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1033 +       {0x00016844, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4},
1034 +       {0x00016848, 0x8e480001, 0x8e480001, 0x8e480001, 0x8e480001},
1035 +       {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1036 +};
1037 +
1038 +static const u32 ar9300Common_rx_gain_table_2p0[][2] = {
1039 +       /* Addr      allmodes  */
1040 +       {0x0000a000, 0x00010000},
1041 +       {0x0000a004, 0x00030002},
1042 +       {0x0000a008, 0x00050004},
1043 +       {0x0000a00c, 0x00810080},
1044 +       {0x0000a010, 0x00830082},
1045 +       {0x0000a014, 0x01810180},
1046 +       {0x0000a018, 0x01830182},
1047 +       {0x0000a01c, 0x01850184},
1048 +       {0x0000a020, 0x01890188},
1049 +       {0x0000a024, 0x018b018a},
1050 +       {0x0000a028, 0x018d018c},
1051 +       {0x0000a02c, 0x01910190},
1052 +       {0x0000a030, 0x01930192},
1053 +       {0x0000a034, 0x01950194},
1054 +       {0x0000a038, 0x038a0196},
1055 +       {0x0000a03c, 0x038c038b},
1056 +       {0x0000a040, 0x0390038d},
1057 +       {0x0000a044, 0x03920391},
1058 +       {0x0000a048, 0x03940393},
1059 +       {0x0000a04c, 0x03960395},
1060 +       {0x0000a050, 0x00000000},
1061 +       {0x0000a054, 0x00000000},
1062 +       {0x0000a058, 0x00000000},
1063 +       {0x0000a05c, 0x00000000},
1064 +       {0x0000a060, 0x00000000},
1065 +       {0x0000a064, 0x00000000},
1066 +       {0x0000a068, 0x00000000},
1067 +       {0x0000a06c, 0x00000000},
1068 +       {0x0000a070, 0x00000000},
1069 +       {0x0000a074, 0x00000000},
1070 +       {0x0000a078, 0x00000000},
1071 +       {0x0000a07c, 0x00000000},
1072 +       {0x0000a080, 0x22222229},
1073 +       {0x0000a084, 0x1d1d1d1d},
1074 +       {0x0000a088, 0x1d1d1d1d},
1075 +       {0x0000a08c, 0x1d1d1d1d},
1076 +       {0x0000a090, 0x171d1d1d},
1077 +       {0x0000a094, 0x11111717},
1078 +       {0x0000a098, 0x00030311},
1079 +       {0x0000a09c, 0x00000000},
1080 +       {0x0000a0a0, 0x00000000},
1081 +       {0x0000a0a4, 0x00000000},
1082 +       {0x0000a0a8, 0x00000000},
1083 +       {0x0000a0ac, 0x00000000},
1084 +       {0x0000a0b0, 0x00000000},
1085 +       {0x0000a0b4, 0x00000000},
1086 +       {0x0000a0b8, 0x00000000},
1087 +       {0x0000a0bc, 0x00000000},
1088 +       {0x0000a0c0, 0x001f0000},
1089 +       {0x0000a0c4, 0x01000101},
1090 +       {0x0000a0c8, 0x011e011f},
1091 +       {0x0000a0cc, 0x011c011d},
1092 +       {0x0000a0d0, 0x02030204},
1093 +       {0x0000a0d4, 0x02010202},
1094 +       {0x0000a0d8, 0x021f0200},
1095 +       {0x0000a0dc, 0x0302021e},
1096 +       {0x0000a0e0, 0x03000301},
1097 +       {0x0000a0e4, 0x031e031f},
1098 +       {0x0000a0e8, 0x0402031d},
1099 +       {0x0000a0ec, 0x04000401},
1100 +       {0x0000a0f0, 0x041e041f},
1101 +       {0x0000a0f4, 0x0502041d},
1102 +       {0x0000a0f8, 0x05000501},
1103 +       {0x0000a0fc, 0x051e051f},
1104 +       {0x0000a100, 0x06010602},
1105 +       {0x0000a104, 0x061f0600},
1106 +       {0x0000a108, 0x061d061e},
1107 +       {0x0000a10c, 0x07020703},
1108 +       {0x0000a110, 0x07000701},
1109 +       {0x0000a114, 0x00000000},
1110 +       {0x0000a118, 0x00000000},
1111 +       {0x0000a11c, 0x00000000},
1112 +       {0x0000a120, 0x00000000},
1113 +       {0x0000a124, 0x00000000},
1114 +       {0x0000a128, 0x00000000},
1115 +       {0x0000a12c, 0x00000000},
1116 +       {0x0000a130, 0x00000000},
1117 +       {0x0000a134, 0x00000000},
1118 +       {0x0000a138, 0x00000000},
1119 +       {0x0000a13c, 0x00000000},
1120 +       {0x0000a140, 0x001f0000},
1121 +       {0x0000a144, 0x01000101},
1122 +       {0x0000a148, 0x011e011f},
1123 +       {0x0000a14c, 0x011c011d},
1124 +       {0x0000a150, 0x02030204},
1125 +       {0x0000a154, 0x02010202},
1126 +       {0x0000a158, 0x021f0200},
1127 +       {0x0000a15c, 0x0302021e},
1128 +       {0x0000a160, 0x03000301},
1129 +       {0x0000a164, 0x031e031f},
1130 +       {0x0000a168, 0x0402031d},
1131 +       {0x0000a16c, 0x04000401},
1132 +       {0x0000a170, 0x041e041f},
1133 +       {0x0000a174, 0x0502041d},
1134 +       {0x0000a178, 0x05000501},
1135 +       {0x0000a17c, 0x051e051f},
1136 +       {0x0000a180, 0x06010602},
1137 +       {0x0000a184, 0x061f0600},
1138 +       {0x0000a188, 0x061d061e},
1139 +       {0x0000a18c, 0x07020703},
1140 +       {0x0000a190, 0x07000701},
1141 +       {0x0000a194, 0x00000000},
1142 +       {0x0000a198, 0x00000000},
1143 +       {0x0000a19c, 0x00000000},
1144 +       {0x0000a1a0, 0x00000000},
1145 +       {0x0000a1a4, 0x00000000},
1146 +       {0x0000a1a8, 0x00000000},
1147 +       {0x0000a1ac, 0x00000000},
1148 +       {0x0000a1b0, 0x00000000},
1149 +       {0x0000a1b4, 0x00000000},
1150 +       {0x0000a1b8, 0x00000000},
1151 +       {0x0000a1bc, 0x00000000},
1152 +       {0x0000a1c0, 0x00000000},
1153 +       {0x0000a1c4, 0x00000000},
1154 +       {0x0000a1c8, 0x00000000},
1155 +       {0x0000a1cc, 0x00000000},
1156 +       {0x0000a1d0, 0x00000000},
1157 +       {0x0000a1d4, 0x00000000},
1158 +       {0x0000a1d8, 0x00000000},
1159 +       {0x0000a1dc, 0x00000000},
1160 +       {0x0000a1e0, 0x00000000},
1161 +       {0x0000a1e4, 0x00000000},
1162 +       {0x0000a1e8, 0x00000000},
1163 +       {0x0000a1ec, 0x00000000},
1164 +       {0x0000a1f0, 0x00000396},
1165 +       {0x0000a1f4, 0x00000396},
1166 +       {0x0000a1f8, 0x00000396},
1167 +       {0x0000a1fc, 0x00000196},
1168 +       {0x0000b000, 0x00010000},
1169 +       {0x0000b004, 0x00030002},
1170 +       {0x0000b008, 0x00050004},
1171 +       {0x0000b00c, 0x00810080},
1172 +       {0x0000b010, 0x00830082},
1173 +       {0x0000b014, 0x01810180},
1174 +       {0x0000b018, 0x01830182},
1175 +       {0x0000b01c, 0x01850184},
1176 +       {0x0000b020, 0x02810280},
1177 +       {0x0000b024, 0x02830282},
1178 +       {0x0000b028, 0x02850284},
1179 +       {0x0000b02c, 0x02890288},
1180 +       {0x0000b030, 0x028b028a},
1181 +       {0x0000b034, 0x0388028c},
1182 +       {0x0000b038, 0x038a0389},
1183 +       {0x0000b03c, 0x038c038b},
1184 +       {0x0000b040, 0x0390038d},
1185 +       {0x0000b044, 0x03920391},
1186 +       {0x0000b048, 0x03940393},
1187 +       {0x0000b04c, 0x03960395},
1188 +       {0x0000b050, 0x00000000},
1189 +       {0x0000b054, 0x00000000},
1190 +       {0x0000b058, 0x00000000},
1191 +       {0x0000b05c, 0x00000000},
1192 +       {0x0000b060, 0x00000000},
1193 +       {0x0000b064, 0x00000000},
1194 +       {0x0000b068, 0x00000000},
1195 +       {0x0000b06c, 0x00000000},
1196 +       {0x0000b070, 0x00000000},
1197 +       {0x0000b074, 0x00000000},
1198 +       {0x0000b078, 0x00000000},
1199 +       {0x0000b07c, 0x00000000},
1200 +       {0x0000b080, 0x32323232},
1201 +       {0x0000b084, 0x2f2f3232},
1202 +       {0x0000b088, 0x23282a2d},
1203 +       {0x0000b08c, 0x1c1e2123},
1204 +       {0x0000b090, 0x14171919},
1205 +       {0x0000b094, 0x0e0e1214},
1206 +       {0x0000b098, 0x03050707},
1207 +       {0x0000b09c, 0x00030303},
1208 +       {0x0000b0a0, 0x00000000},
1209 +       {0x0000b0a4, 0x00000000},
1210 +       {0x0000b0a8, 0x00000000},
1211 +       {0x0000b0ac, 0x00000000},
1212 +       {0x0000b0b0, 0x00000000},
1213 +       {0x0000b0b4, 0x00000000},
1214 +       {0x0000b0b8, 0x00000000},
1215 +       {0x0000b0bc, 0x00000000},
1216 +       {0x0000b0c0, 0x003f0020},
1217 +       {0x0000b0c4, 0x00400041},
1218 +       {0x0000b0c8, 0x0140005f},
1219 +       {0x0000b0cc, 0x0160015f},
1220 +       {0x0000b0d0, 0x017e017f},
1221 +       {0x0000b0d4, 0x02410242},
1222 +       {0x0000b0d8, 0x025f0240},
1223 +       {0x0000b0dc, 0x027f0260},
1224 +       {0x0000b0e0, 0x0341027e},
1225 +       {0x0000b0e4, 0x035f0340},
1226 +       {0x0000b0e8, 0x037f0360},
1227 +       {0x0000b0ec, 0x04400441},
1228 +       {0x0000b0f0, 0x0460045f},
1229 +       {0x0000b0f4, 0x0541047f},
1230 +       {0x0000b0f8, 0x055f0540},
1231 +       {0x0000b0fc, 0x057f0560},
1232 +       {0x0000b100, 0x06400641},
1233 +       {0x0000b104, 0x0660065f},
1234 +       {0x0000b108, 0x067e067f},
1235 +       {0x0000b10c, 0x07410742},
1236 +       {0x0000b110, 0x075f0740},
1237 +       {0x0000b114, 0x077f0760},
1238 +       {0x0000b118, 0x07800781},
1239 +       {0x0000b11c, 0x07a0079f},
1240 +       {0x0000b120, 0x07c107bf},
1241 +       {0x0000b124, 0x000007c0},
1242 +       {0x0000b128, 0x00000000},
1243 +       {0x0000b12c, 0x00000000},
1244 +       {0x0000b130, 0x00000000},
1245 +       {0x0000b134, 0x00000000},
1246 +       {0x0000b138, 0x00000000},
1247 +       {0x0000b13c, 0x00000000},
1248 +       {0x0000b140, 0x003f0020},
1249 +       {0x0000b144, 0x00400041},
1250 +       {0x0000b148, 0x0140005f},
1251 +       {0x0000b14c, 0x0160015f},
1252 +       {0x0000b150, 0x017e017f},
1253 +       {0x0000b154, 0x02410242},
1254 +       {0x0000b158, 0x025f0240},
1255 +       {0x0000b15c, 0x027f0260},
1256 +       {0x0000b160, 0x0341027e},
1257 +       {0x0000b164, 0x035f0340},
1258 +       {0x0000b168, 0x037f0360},
1259 +       {0x0000b16c, 0x04400441},
1260 +       {0x0000b170, 0x0460045f},
1261 +       {0x0000b174, 0x0541047f},
1262 +       {0x0000b178, 0x055f0540},
1263 +       {0x0000b17c, 0x057f0560},
1264 +       {0x0000b180, 0x06400641},
1265 +       {0x0000b184, 0x0660065f},
1266 +       {0x0000b188, 0x067e067f},
1267 +       {0x0000b18c, 0x07410742},
1268 +       {0x0000b190, 0x075f0740},
1269 +       {0x0000b194, 0x077f0760},
1270 +       {0x0000b198, 0x07800781},
1271 +       {0x0000b19c, 0x07a0079f},
1272 +       {0x0000b1a0, 0x07c107bf},
1273 +       {0x0000b1a4, 0x000007c0},
1274 +       {0x0000b1a8, 0x00000000},
1275 +       {0x0000b1ac, 0x00000000},
1276 +       {0x0000b1b0, 0x00000000},
1277 +       {0x0000b1b4, 0x00000000},
1278 +       {0x0000b1b8, 0x00000000},
1279 +       {0x0000b1bc, 0x00000000},
1280 +       {0x0000b1c0, 0x00000000},
1281 +       {0x0000b1c4, 0x00000000},
1282 +       {0x0000b1c8, 0x00000000},
1283 +       {0x0000b1cc, 0x00000000},
1284 +       {0x0000b1d0, 0x00000000},
1285 +       {0x0000b1d4, 0x00000000},
1286 +       {0x0000b1d8, 0x00000000},
1287 +       {0x0000b1dc, 0x00000000},
1288 +       {0x0000b1e0, 0x00000000},
1289 +       {0x0000b1e4, 0x00000000},
1290 +       {0x0000b1e8, 0x00000000},
1291 +       {0x0000b1ec, 0x00000000},
1292 +       {0x0000b1f0, 0x00000396},
1293 +       {0x0000b1f4, 0x00000396},
1294 +       {0x0000b1f8, 0x00000396},
1295 +       {0x0000b1fc, 0x00000196},
1296 +};
1297 +
1298 +static const u32 ar9300Modes_low_ob_db_tx_gain_table_2p0[][5] = {
1299 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
1300 +       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
1301 +       {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1302 +       {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002},
1303 +       {0x0000a508, 0x0a000020, 0x0a000020, 0x08000004, 0x08000004},
1304 +       {0x0000a50c, 0x10000023, 0x10000023, 0x0b000200, 0x0b000200},
1305 +       {0x0000a510, 0x16000220, 0x16000220, 0x0f000202, 0x0f000202},
1306 +       {0x0000a514, 0x1c000223, 0x1c000223, 0x12000400, 0x12000400},
1307 +       {0x0000a518, 0x21020220, 0x21020220, 0x16000402, 0x16000402},
1308 +       {0x0000a51c, 0x27020223, 0x27020223, 0x19000404, 0x19000404},
1309 +       {0x0000a520, 0x2b022220, 0x2b022220, 0x1c000603, 0x1c000603},
1310 +       {0x0000a524, 0x2f022222, 0x2f022222, 0x21000a02, 0x21000a02},
1311 +       {0x0000a528, 0x34022225, 0x34022225, 0x25000a04, 0x25000a04},
1312 +       {0x0000a52c, 0x3a02222a, 0x3a02222a, 0x28000a20, 0x28000a20},
1313 +       {0x0000a530, 0x3e02222c, 0x3e02222c, 0x2c000e20, 0x2c000e20},
1314 +       {0x0000a534, 0x4202242a, 0x4202242a, 0x30000e22, 0x30000e22},
1315 +       {0x0000a538, 0x4702244a, 0x4702244a, 0x34000e24, 0x34000e24},
1316 +       {0x0000a53c, 0x4b02244c, 0x4b02244c, 0x38001640, 0x38001640},
1317 +       {0x0000a540, 0x4e02246c, 0x4e02246c, 0x3c001660, 0x3c001660},
1318 +       {0x0000a544, 0x5302266c, 0x5302266c, 0x3f001861, 0x3f001861},
1319 +       {0x0000a548, 0x5702286c, 0x5702286c, 0x43001a81, 0x43001a81},
1320 +       {0x0000a54c, 0x5c04286b, 0x5c04286b, 0x47001a83, 0x47001a83},
1321 +       {0x0000a550, 0x61042a6c, 0x61042a6c, 0x4a001c84, 0x4a001c84},
1322 +       {0x0000a554, 0x66062a6c, 0x66062a6c, 0x4e001ce3, 0x4e001ce3},
1323 +       {0x0000a558, 0x6b062e6c, 0x6b062e6c, 0x52001ce5, 0x52001ce5},
1324 +       {0x0000a55c, 0x7006308c, 0x7006308c, 0x56001ce9, 0x56001ce9},
1325 +       {0x0000a560, 0x730a308a, 0x730a308a, 0x5a001ceb, 0x5a001ceb},
1326 +       {0x0000a564, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
1327 +       {0x0000a568, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
1328 +       {0x0000a56c, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
1329 +       {0x0000a570, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
1330 +       {0x0000a574, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
1331 +       {0x0000a578, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
1332 +       {0x0000a57c, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
1333 +       {0x0000a580, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
1334 +       {0x0000a584, 0x06800003, 0x06800003, 0x04800002, 0x04800002},
1335 +       {0x0000a588, 0x0a800020, 0x0a800020, 0x08800004, 0x08800004},
1336 +       {0x0000a58c, 0x10800023, 0x10800023, 0x0b800200, 0x0b800200},
1337 +       {0x0000a590, 0x16800220, 0x16800220, 0x0f800202, 0x0f800202},
1338 +       {0x0000a594, 0x1c800223, 0x1c800223, 0x12800400, 0x12800400},
1339 +       {0x0000a598, 0x21820220, 0x21820220, 0x16800402, 0x16800402},
1340 +       {0x0000a59c, 0x27820223, 0x27820223, 0x19800404, 0x19800404},
1341 +       {0x0000a5a0, 0x2b822220, 0x2b822220, 0x1c800603, 0x1c800603},
1342 +       {0x0000a5a4, 0x2f822222, 0x2f822222, 0x21800a02, 0x21800a02},
1343 +       {0x0000a5a8, 0x34822225, 0x34822225, 0x25800a04, 0x25800a04},
1344 +       {0x0000a5ac, 0x3a82222a, 0x3a82222a, 0x28800a20, 0x28800a20},
1345 +       {0x0000a5b0, 0x3e82222c, 0x3e82222c, 0x2c800e20, 0x2c800e20},
1346 +       {0x0000a5b4, 0x4282242a, 0x4282242a, 0x30800e22, 0x30800e22},
1347 +       {0x0000a5b8, 0x4782244a, 0x4782244a, 0x34800e24, 0x34800e24},
1348 +       {0x0000a5bc, 0x4b82244c, 0x4b82244c, 0x38801640, 0x38801640},
1349 +       {0x0000a5c0, 0x4e82246c, 0x4e82246c, 0x3c801660, 0x3c801660},
1350 +       {0x0000a5c4, 0x5382266c, 0x5382266c, 0x3f801861, 0x3f801861},
1351 +       {0x0000a5c8, 0x5782286c, 0x5782286c, 0x43801a81, 0x43801a81},
1352 +       {0x0000a5cc, 0x5c84286b, 0x5c84286b, 0x47801a83, 0x47801a83},
1353 +       {0x0000a5d0, 0x61842a6c, 0x61842a6c, 0x4a801c84, 0x4a801c84},
1354 +       {0x0000a5d4, 0x66862a6c, 0x66862a6c, 0x4e801ce3, 0x4e801ce3},
1355 +       {0x0000a5d8, 0x6b862e6c, 0x6b862e6c, 0x52801ce5, 0x52801ce5},
1356 +       {0x0000a5dc, 0x7086308c, 0x7086308c, 0x56801ce9, 0x56801ce9},
1357 +       {0x0000a5e0, 0x738a308a, 0x738a308a, 0x5a801ceb, 0x5a801ceb},
1358 +       {0x0000a5e4, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
1359 +       {0x0000a5e8, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
1360 +       {0x0000a5ec, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
1361 +       {0x0000a5f0, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
1362 +       {0x0000a5f4, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
1363 +       {0x0000a5f8, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
1364 +       {0x0000a5fc, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
1365 +       {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1366 +       {0x00016048, 0x64000001, 0x64000001, 0x64000001, 0x64000001},
1367 +       {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1368 +       {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1369 +       {0x00016448, 0x64000001, 0x64000001, 0x64000001, 0x64000001},
1370 +       {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1371 +       {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1372 +       {0x00016848, 0x64000001, 0x64000001, 0x64000001, 0x64000001},
1373 +       {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1374 +};
1375 +
1376 +static const u32 ar9300_2p0_mac_core[][2] = {
1377 +       /* Addr      allmodes  */
1378 +       {0x00000008, 0x00000000},
1379 +       {0x00000030, 0x00020085},
1380 +       {0x00000034, 0x00000005},
1381 +       {0x00000040, 0x00000000},
1382 +       {0x00000044, 0x00000000},
1383 +       {0x00000048, 0x00000008},
1384 +       {0x0000004c, 0x00000010},
1385 +       {0x00000050, 0x00000000},
1386 +       {0x00001040, 0x002ffc0f},
1387 +       {0x00001044, 0x002ffc0f},
1388 +       {0x00001048, 0x002ffc0f},
1389 +       {0x0000104c, 0x002ffc0f},
1390 +       {0x00001050, 0x002ffc0f},
1391 +       {0x00001054, 0x002ffc0f},
1392 +       {0x00001058, 0x002ffc0f},
1393 +       {0x0000105c, 0x002ffc0f},
1394 +       {0x00001060, 0x002ffc0f},
1395 +       {0x00001064, 0x002ffc0f},
1396 +       {0x000010f0, 0x00000100},
1397 +       {0x00001270, 0x00000000},
1398 +       {0x000012b0, 0x00000000},
1399 +       {0x000012f0, 0x00000000},
1400 +       {0x0000143c, 0x00000000},
1401 +       {0x0000147c, 0x00000000},
1402 +       {0x00008000, 0x00000000},
1403 +       {0x00008004, 0x00000000},
1404 +       {0x00008008, 0x00000000},
1405 +       {0x0000800c, 0x00000000},
1406 +       {0x00008018, 0x00000000},
1407 +       {0x00008020, 0x00000000},
1408 +       {0x00008038, 0x00000000},
1409 +       {0x0000803c, 0x00000000},
1410 +       {0x00008040, 0x00000000},
1411 +       {0x00008044, 0x00000000},
1412 +       {0x00008048, 0x00000000},
1413 +       {0x0000804c, 0xffffffff},
1414 +       {0x00008054, 0x00000000},
1415 +       {0x00008058, 0x00000000},
1416 +       {0x0000805c, 0x000fc78f},
1417 +       {0x00008060, 0x0000000f},
1418 +       {0x00008064, 0x00000000},
1419 +       {0x00008070, 0x00000310},
1420 +       {0x00008074, 0x00000020},
1421 +       {0x00008078, 0x00000000},
1422 +       {0x0000809c, 0x0000000f},
1423 +       {0x000080a0, 0x00000000},
1424 +       {0x000080a4, 0x02ff0000},
1425 +       {0x000080a8, 0x0e070605},
1426 +       {0x000080ac, 0x0000000d},
1427 +       {0x000080b0, 0x00000000},
1428 +       {0x000080b4, 0x00000000},
1429 +       {0x000080b8, 0x00000000},
1430 +       {0x000080bc, 0x00000000},
1431 +       {0x000080c0, 0x2a800000},
1432 +       {0x000080c4, 0x06900168},
1433 +       {0x000080c8, 0x13881c20},
1434 +       {0x000080cc, 0x01f40000},
1435 +       {0x000080d0, 0x00252500},
1436 +       {0x000080d4, 0x00a00000},
1437 +       {0x000080d8, 0x00400000},
1438 +       {0x000080dc, 0x00000000},
1439 +       {0x000080e0, 0xffffffff},
1440 +       {0x000080e4, 0x0000ffff},
1441 +       {0x000080e8, 0x3f3f3f3f},
1442 +       {0x000080ec, 0x00000000},
1443 +       {0x000080f0, 0x00000000},
1444 +       {0x000080f4, 0x00000000},
1445 +       {0x000080fc, 0x00020000},
1446 +       {0x00008100, 0x00000000},
1447 +       {0x00008108, 0x00000052},
1448 +       {0x0000810c, 0x00000000},
1449 +       {0x00008110, 0x00000000},
1450 +       {0x00008114, 0x000007ff},
1451 +       {0x00008118, 0x000000aa},
1452 +       {0x0000811c, 0x00003210},
1453 +       {0x00008124, 0x00000000},
1454 +       {0x00008128, 0x00000000},
1455 +       {0x0000812c, 0x00000000},
1456 +       {0x00008130, 0x00000000},
1457 +       {0x00008134, 0x00000000},
1458 +       {0x00008138, 0x00000000},
1459 +       {0x0000813c, 0x0000ffff},
1460 +       {0x00008144, 0xffffffff},
1461 +       {0x00008168, 0x00000000},
1462 +       {0x0000816c, 0x00000000},
1463 +       {0x00008170, 0x18486200},
1464 +       {0x00008174, 0x33332210},
1465 +       {0x00008178, 0x00000000},
1466 +       {0x0000817c, 0x00020000},
1467 +       {0x000081c0, 0x00000000},
1468 +       {0x000081c4, 0x33332210},
1469 +       {0x000081c8, 0x00000000},
1470 +       {0x000081cc, 0x00000000},
1471 +       {0x000081d4, 0x00000000},
1472 +       {0x000081ec, 0x00000000},
1473 +       {0x000081f0, 0x00000000},
1474 +       {0x000081f4, 0x00000000},
1475 +       {0x000081f8, 0x00000000},
1476 +       {0x000081fc, 0x00000000},
1477 +       {0x00008240, 0x00100000},
1478 +       {0x00008244, 0x0010f424},
1479 +       {0x00008248, 0x00000800},
1480 +       {0x0000824c, 0x0001e848},
1481 +       {0x00008250, 0x00000000},
1482 +       {0x00008254, 0x00000000},
1483 +       {0x00008258, 0x00000000},
1484 +       {0x0000825c, 0x40000000},
1485 +       {0x00008260, 0x00080922},
1486 +       {0x00008264, 0x98a00010},
1487 +       {0x00008268, 0xffffffff},
1488 +       {0x0000826c, 0x0000ffff},
1489 +       {0x00008270, 0x00000000},
1490 +       {0x00008274, 0x40000000},
1491 +       {0x00008278, 0x003e4180},
1492 +       {0x0000827c, 0x00000004},
1493 +       {0x00008284, 0x0000002c},
1494 +       {0x00008288, 0x0000002c},
1495 +       {0x0000828c, 0x000000ff},
1496 +       {0x00008294, 0x00000000},
1497 +       {0x00008298, 0x00000000},
1498 +       {0x0000829c, 0x00000000},
1499 +       {0x00008300, 0x00000140},
1500 +       {0x00008314, 0x00000000},
1501 +       {0x0000831c, 0x0000010d},
1502 +       {0x00008328, 0x00000000},
1503 +       {0x0000832c, 0x00000007},
1504 +       {0x00008330, 0x00000302},
1505 +       {0x00008334, 0x00000700},
1506 +       {0x00008338, 0x00ff0000},
1507 +       {0x0000833c, 0x02400000},
1508 +       {0x00008340, 0x000107ff},
1509 +       {0x00008344, 0xaa48105b},
1510 +       {0x00008348, 0x008f0000},
1511 +       {0x0000835c, 0x00000000},
1512 +       {0x00008360, 0xffffffff},
1513 +       {0x00008364, 0xffffffff},
1514 +       {0x00008368, 0x00000000},
1515 +       {0x00008370, 0x00000000},
1516 +       {0x00008374, 0x000000ff},
1517 +       {0x00008378, 0x00000000},
1518 +       {0x0000837c, 0x00000000},
1519 +       {0x00008380, 0xffffffff},
1520 +       {0x00008384, 0xffffffff},
1521 +       {0x00008390, 0xffffffff},
1522 +       {0x00008394, 0xffffffff},
1523 +       {0x00008398, 0x00000000},
1524 +       {0x0000839c, 0x00000000},
1525 +       {0x000083a0, 0x00000000},
1526 +       {0x000083a4, 0x0000fa14},
1527 +       {0x000083a8, 0x000f0c00},
1528 +       {0x000083ac, 0x33332210},
1529 +       {0x000083b0, 0x33332210},
1530 +       {0x000083b4, 0x33332210},
1531 +       {0x000083b8, 0x33332210},
1532 +       {0x000083bc, 0x00000000},
1533 +       {0x000083c0, 0x00000000},
1534 +       {0x000083c4, 0x00000000},
1535 +       {0x000083c8, 0x00000000},
1536 +       {0x000083cc, 0x00000200},
1537 +       {0x000083d0, 0x000301ff},
1538 +};
1539 +
1540 +static const u32 ar9300Common_wo_xlna_rx_gain_table_2p0[][2] = {
1541 +       /* Addr      allmodes  */
1542 +       {0x0000a000, 0x00010000},
1543 +       {0x0000a004, 0x00030002},
1544 +       {0x0000a008, 0x00050004},
1545 +       {0x0000a00c, 0x00810080},
1546 +       {0x0000a010, 0x00830082},
1547 +       {0x0000a014, 0x01810180},
1548 +       {0x0000a018, 0x01830182},
1549 +       {0x0000a01c, 0x01850184},
1550 +       {0x0000a020, 0x01890188},
1551 +       {0x0000a024, 0x018b018a},
1552 +       {0x0000a028, 0x018d018c},
1553 +       {0x0000a02c, 0x03820190},
1554 +       {0x0000a030, 0x03840383},
1555 +       {0x0000a034, 0x03880385},
1556 +       {0x0000a038, 0x038a0389},
1557 +       {0x0000a03c, 0x038c038b},
1558 +       {0x0000a040, 0x0390038d},
1559 +       {0x0000a044, 0x03920391},
1560 +       {0x0000a048, 0x03940393},
1561 +       {0x0000a04c, 0x03960395},
1562 +       {0x0000a050, 0x00000000},
1563 +       {0x0000a054, 0x00000000},
1564 +       {0x0000a058, 0x00000000},
1565 +       {0x0000a05c, 0x00000000},
1566 +       {0x0000a060, 0x00000000},
1567 +       {0x0000a064, 0x00000000},
1568 +       {0x0000a068, 0x00000000},
1569 +       {0x0000a06c, 0x00000000},
1570 +       {0x0000a070, 0x00000000},
1571 +       {0x0000a074, 0x00000000},
1572 +       {0x0000a078, 0x00000000},
1573 +       {0x0000a07c, 0x00000000},
1574 +       {0x0000a080, 0x29292929},
1575 +       {0x0000a084, 0x29292929},
1576 +       {0x0000a088, 0x29292929},
1577 +       {0x0000a08c, 0x29292929},
1578 +       {0x0000a090, 0x22292929},
1579 +       {0x0000a094, 0x1d1d2222},
1580 +       {0x0000a098, 0x0c111117},
1581 +       {0x0000a09c, 0x00030303},
1582 +       {0x0000a0a0, 0x00000000},
1583 +       {0x0000a0a4, 0x00000000},
1584 +       {0x0000a0a8, 0x00000000},
1585 +       {0x0000a0ac, 0x00000000},
1586 +       {0x0000a0b0, 0x00000000},
1587 +       {0x0000a0b4, 0x00000000},
1588 +       {0x0000a0b8, 0x00000000},
1589 +       {0x0000a0bc, 0x00000000},
1590 +       {0x0000a0c0, 0x001f0000},
1591 +       {0x0000a0c4, 0x01000101},
1592 +       {0x0000a0c8, 0x011e011f},
1593 +       {0x0000a0cc, 0x011c011d},
1594 +       {0x0000a0d0, 0x02030204},
1595 +       {0x0000a0d4, 0x02010202},
1596 +       {0x0000a0d8, 0x021f0200},
1597 +       {0x0000a0dc, 0x0302021e},
1598 +       {0x0000a0e0, 0x03000301},
1599 +       {0x0000a0e4, 0x031e031f},
1600 +       {0x0000a0e8, 0x0402031d},
1601 +       {0x0000a0ec, 0x04000401},
1602 +       {0x0000a0f0, 0x041e041f},
1603 +       {0x0000a0f4, 0x0502041d},
1604 +       {0x0000a0f8, 0x05000501},
1605 +       {0x0000a0fc, 0x051e051f},
1606 +       {0x0000a100, 0x06010602},
1607 +       {0x0000a104, 0x061f0600},
1608 +       {0x0000a108, 0x061d061e},
1609 +       {0x0000a10c, 0x07020703},
1610 +       {0x0000a110, 0x07000701},
1611 +       {0x0000a114, 0x00000000},
1612 +       {0x0000a118, 0x00000000},
1613 +       {0x0000a11c, 0x00000000},
1614 +       {0x0000a120, 0x00000000},
1615 +       {0x0000a124, 0x00000000},
1616 +       {0x0000a128, 0x00000000},
1617 +       {0x0000a12c, 0x00000000},
1618 +       {0x0000a130, 0x00000000},
1619 +       {0x0000a134, 0x00000000},
1620 +       {0x0000a138, 0x00000000},
1621 +       {0x0000a13c, 0x00000000},
1622 +       {0x0000a140, 0x001f0000},
1623 +       {0x0000a144, 0x01000101},
1624 +       {0x0000a148, 0x011e011f},
1625 +       {0x0000a14c, 0x011c011d},
1626 +       {0x0000a150, 0x02030204},
1627 +       {0x0000a154, 0x02010202},
1628 +       {0x0000a158, 0x021f0200},
1629 +       {0x0000a15c, 0x0302021e},
1630 +       {0x0000a160, 0x03000301},
1631 +       {0x0000a164, 0x031e031f},
1632 +       {0x0000a168, 0x0402031d},
1633 +       {0x0000a16c, 0x04000401},
1634 +       {0x0000a170, 0x041e041f},
1635 +       {0x0000a174, 0x0502041d},
1636 +       {0x0000a178, 0x05000501},
1637 +       {0x0000a17c, 0x051e051f},
1638 +       {0x0000a180, 0x06010602},
1639 +       {0x0000a184, 0x061f0600},
1640 +       {0x0000a188, 0x061d061e},
1641 +       {0x0000a18c, 0x07020703},
1642 +       {0x0000a190, 0x07000701},
1643 +       {0x0000a194, 0x00000000},
1644 +       {0x0000a198, 0x00000000},
1645 +       {0x0000a19c, 0x00000000},
1646 +       {0x0000a1a0, 0x00000000},
1647 +       {0x0000a1a4, 0x00000000},
1648 +       {0x0000a1a8, 0x00000000},
1649 +       {0x0000a1ac, 0x00000000},
1650 +       {0x0000a1b0, 0x00000000},
1651 +       {0x0000a1b4, 0x00000000},
1652 +       {0x0000a1b8, 0x00000000},
1653 +       {0x0000a1bc, 0x00000000},
1654 +       {0x0000a1c0, 0x00000000},
1655 +       {0x0000a1c4, 0x00000000},
1656 +       {0x0000a1c8, 0x00000000},
1657 +       {0x0000a1cc, 0x00000000},
1658 +       {0x0000a1d0, 0x00000000},
1659 +       {0x0000a1d4, 0x00000000},
1660 +       {0x0000a1d8, 0x00000000},
1661 +       {0x0000a1dc, 0x00000000},
1662 +       {0x0000a1e0, 0x00000000},
1663 +       {0x0000a1e4, 0x00000000},
1664 +       {0x0000a1e8, 0x00000000},
1665 +       {0x0000a1ec, 0x00000000},
1666 +       {0x0000a1f0, 0x00000396},
1667 +       {0x0000a1f4, 0x00000396},
1668 +       {0x0000a1f8, 0x00000396},
1669 +       {0x0000a1fc, 0x00000196},
1670 +       {0x0000b000, 0x00010000},
1671 +       {0x0000b004, 0x00030002},
1672 +       {0x0000b008, 0x00050004},
1673 +       {0x0000b00c, 0x00810080},
1674 +       {0x0000b010, 0x00830082},
1675 +       {0x0000b014, 0x01810180},
1676 +       {0x0000b018, 0x01830182},
1677 +       {0x0000b01c, 0x01850184},
1678 +       {0x0000b020, 0x02810280},
1679 +       {0x0000b024, 0x02830282},
1680 +       {0x0000b028, 0x02850284},
1681 +       {0x0000b02c, 0x02890288},
1682 +       {0x0000b030, 0x028b028a},
1683 +       {0x0000b034, 0x0388028c},
1684 +       {0x0000b038, 0x038a0389},
1685 +       {0x0000b03c, 0x038c038b},
1686 +       {0x0000b040, 0x0390038d},
1687 +       {0x0000b044, 0x03920391},
1688 +       {0x0000b048, 0x03940393},
1689 +       {0x0000b04c, 0x03960395},
1690 +       {0x0000b050, 0x00000000},
1691 +       {0x0000b054, 0x00000000},
1692 +       {0x0000b058, 0x00000000},
1693 +       {0x0000b05c, 0x00000000},
1694 +       {0x0000b060, 0x00000000},
1695 +       {0x0000b064, 0x00000000},
1696 +       {0x0000b068, 0x00000000},
1697 +       {0x0000b06c, 0x00000000},
1698 +       {0x0000b070, 0x00000000},
1699 +       {0x0000b074, 0x00000000},
1700 +       {0x0000b078, 0x00000000},
1701 +       {0x0000b07c, 0x00000000},
1702 +       {0x0000b080, 0x32323232},
1703 +       {0x0000b084, 0x2f2f3232},
1704 +       {0x0000b088, 0x23282a2d},
1705 +       {0x0000b08c, 0x1c1e2123},
1706 +       {0x0000b090, 0x14171919},
1707 +       {0x0000b094, 0x0e0e1214},
1708 +       {0x0000b098, 0x03050707},
1709 +       {0x0000b09c, 0x00030303},
1710 +       {0x0000b0a0, 0x00000000},
1711 +       {0x0000b0a4, 0x00000000},
1712 +       {0x0000b0a8, 0x00000000},
1713 +       {0x0000b0ac, 0x00000000},
1714 +       {0x0000b0b0, 0x00000000},
1715 +       {0x0000b0b4, 0x00000000},
1716 +       {0x0000b0b8, 0x00000000},
1717 +       {0x0000b0bc, 0x00000000},
1718 +       {0x0000b0c0, 0x003f0020},
1719 +       {0x0000b0c4, 0x00400041},
1720 +       {0x0000b0c8, 0x0140005f},
1721 +       {0x0000b0cc, 0x0160015f},
1722 +       {0x0000b0d0, 0x017e017f},
1723 +       {0x0000b0d4, 0x02410242},
1724 +       {0x0000b0d8, 0x025f0240},
1725 +       {0x0000b0dc, 0x027f0260},
1726 +       {0x0000b0e0, 0x0341027e},
1727 +       {0x0000b0e4, 0x035f0340},
1728 +       {0x0000b0e8, 0x037f0360},
1729 +       {0x0000b0ec, 0x04400441},
1730 +       {0x0000b0f0, 0x0460045f},
1731 +       {0x0000b0f4, 0x0541047f},
1732 +       {0x0000b0f8, 0x055f0540},
1733 +       {0x0000b0fc, 0x057f0560},
1734 +       {0x0000b100, 0x06400641},
1735 +       {0x0000b104, 0x0660065f},
1736 +       {0x0000b108, 0x067e067f},
1737 +       {0x0000b10c, 0x07410742},
1738 +       {0x0000b110, 0x075f0740},
1739 +       {0x0000b114, 0x077f0760},
1740 +       {0x0000b118, 0x07800781},
1741 +       {0x0000b11c, 0x07a0079f},
1742 +       {0x0000b120, 0x07c107bf},
1743 +       {0x0000b124, 0x000007c0},
1744 +       {0x0000b128, 0x00000000},
1745 +       {0x0000b12c, 0x00000000},
1746 +       {0x0000b130, 0x00000000},
1747 +       {0x0000b134, 0x00000000},
1748 +       {0x0000b138, 0x00000000},
1749 +       {0x0000b13c, 0x00000000},
1750 +       {0x0000b140, 0x003f0020},
1751 +       {0x0000b144, 0x00400041},
1752 +       {0x0000b148, 0x0140005f},
1753 +       {0x0000b14c, 0x0160015f},
1754 +       {0x0000b150, 0x017e017f},
1755 +       {0x0000b154, 0x02410242},
1756 +       {0x0000b158, 0x025f0240},
1757 +       {0x0000b15c, 0x027f0260},
1758 +       {0x0000b160, 0x0341027e},
1759 +       {0x0000b164, 0x035f0340},
1760 +       {0x0000b168, 0x037f0360},
1761 +       {0x0000b16c, 0x04400441},
1762 +       {0x0000b170, 0x0460045f},
1763 +       {0x0000b174, 0x0541047f},
1764 +       {0x0000b178, 0x055f0540},
1765 +       {0x0000b17c, 0x057f0560},
1766 +       {0x0000b180, 0x06400641},
1767 +       {0x0000b184, 0x0660065f},
1768 +       {0x0000b188, 0x067e067f},
1769 +       {0x0000b18c, 0x07410742},
1770 +       {0x0000b190, 0x075f0740},
1771 +       {0x0000b194, 0x077f0760},
1772 +       {0x0000b198, 0x07800781},
1773 +       {0x0000b19c, 0x07a0079f},
1774 +       {0x0000b1a0, 0x07c107bf},
1775 +       {0x0000b1a4, 0x000007c0},
1776 +       {0x0000b1a8, 0x00000000},
1777 +       {0x0000b1ac, 0x00000000},
1778 +       {0x0000b1b0, 0x00000000},
1779 +       {0x0000b1b4, 0x00000000},
1780 +       {0x0000b1b8, 0x00000000},
1781 +       {0x0000b1bc, 0x00000000},
1782 +       {0x0000b1c0, 0x00000000},
1783 +       {0x0000b1c4, 0x00000000},
1784 +       {0x0000b1c8, 0x00000000},
1785 +       {0x0000b1cc, 0x00000000},
1786 +       {0x0000b1d0, 0x00000000},
1787 +       {0x0000b1d4, 0x00000000},
1788 +       {0x0000b1d8, 0x00000000},
1789 +       {0x0000b1dc, 0x00000000},
1790 +       {0x0000b1e0, 0x00000000},
1791 +       {0x0000b1e4, 0x00000000},
1792 +       {0x0000b1e8, 0x00000000},
1793 +       {0x0000b1ec, 0x00000000},
1794 +       {0x0000b1f0, 0x00000396},
1795 +       {0x0000b1f4, 0x00000396},
1796 +       {0x0000b1f8, 0x00000396},
1797 +       {0x0000b1fc, 0x00000196},
1798 +};
1799 +
1800 +static const u32 ar9300_2p0_soc_preamble[][2] = {
1801 +       /* Addr      allmodes  */
1802 +       {0x000040a4, 0x00a0c1c9},
1803 +       {0x00007008, 0x00000000},
1804 +       {0x00007020, 0x00000000},
1805 +       {0x00007034, 0x00000002},
1806 +       {0x00007038, 0x000004c2},
1807 +};
1808 +
1809 +static const u32 ar9300PciePhy_pll_on_clkreq_disable_L1_2p0[][2] = {
1810 +       /* Addr      allmodes  */
1811 +       {0x00004040, 0x08212e5e},
1812 +       {0x00004040, 0x0008003b},
1813 +       {0x00004044, 0x00000000},
1814 +};
1815 +
1816 +static const u32 ar9300PciePhy_clkreq_enable_L1_2p0[][2] = {
1817 +       /* Addr      allmodes  */
1818 +       {0x00004040, 0x08253e5e},
1819 +       {0x00004040, 0x0008003b},
1820 +       {0x00004044, 0x00000000},
1821 +};
1822 +
1823 +static const u32 ar9300PciePhy_clkreq_disable_L1_2p0[][2] = {
1824 +       /* Addr      allmodes  */
1825 +       {0x00004040, 0x08213e5e},
1826 +       {0x00004040, 0x0008003b},
1827 +       {0x00004044, 0x00000000},
1828 +};
1829 +
1830 +#endif /* INITVALS_9003_2P0_H */
1831 --- /dev/null
1832 +++ b/drivers/net/wireless/ath/ath9k/ar9003_2p2_initvals.h
1833 @@ -0,0 +1,1785 @@
1834 +/*
1835 + * Copyright (c) 2010 Atheros Communications Inc.
1836 + *
1837 + * Permission to use, copy, modify, and/or distribute this software for any
1838 + * purpose with or without fee is hereby granted, provided that the above
1839 + * copyright notice and this permission notice appear in all copies.
1840 + *
1841 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1842 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1843 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1844 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1845 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1846 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1847 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1848 + */
1849 +
1850 +#ifndef INITVALS_9003_2P2_H
1851 +#define INITVALS_9003_2P2_H
1852 +
1853 +/* AR9003 2.2 */
1854 +
1855 +static const u32 ar9300_2p2_radio_postamble[][5] = {
1856 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
1857 +       {0x0001609c, 0x0dd08f29, 0x0dd08f29, 0x0b283f31, 0x0b283f31},
1858 +       {0x000160ac, 0xa4653c00, 0xa4653c00, 0x24652800, 0x24652800},
1859 +       {0x000160b0, 0x03284f3e, 0x03284f3e, 0x05d08f20, 0x05d08f20},
1860 +       {0x0001610c, 0x08000000, 0x00000000, 0x00000000, 0x00000000},
1861 +       {0x00016140, 0x10804008, 0x10804008, 0x50804008, 0x50804008},
1862 +       {0x0001650c, 0x08000000, 0x00000000, 0x00000000, 0x00000000},
1863 +       {0x00016540, 0x10804008, 0x10804008, 0x50804008, 0x50804008},
1864 +       {0x0001690c, 0x08000000, 0x00000000, 0x00000000, 0x00000000},
1865 +       {0x00016940, 0x10804008, 0x10804008, 0x50804008, 0x50804008},
1866 +};
1867 +
1868 +static const u32 ar9300Modes_lowest_ob_db_tx_gain_table_2p2[][5] = {
1869 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
1870 +       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
1871 +       {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
1872 +       {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002},
1873 +       {0x0000a508, 0x0a000020, 0x0a000020, 0x08000004, 0x08000004},
1874 +       {0x0000a50c, 0x10000023, 0x10000023, 0x0b000200, 0x0b000200},
1875 +       {0x0000a510, 0x16000220, 0x16000220, 0x0f000202, 0x0f000202},
1876 +       {0x0000a514, 0x1c000223, 0x1c000223, 0x12000400, 0x12000400},
1877 +       {0x0000a518, 0x21002220, 0x21002220, 0x16000402, 0x16000402},
1878 +       {0x0000a51c, 0x27002223, 0x27002223, 0x19000404, 0x19000404},
1879 +       {0x0000a520, 0x2b022220, 0x2b022220, 0x1c000603, 0x1c000603},
1880 +       {0x0000a524, 0x2f022222, 0x2f022222, 0x21000a02, 0x21000a02},
1881 +       {0x0000a528, 0x34022225, 0x34022225, 0x25000a04, 0x25000a04},
1882 +       {0x0000a52c, 0x3a02222a, 0x3a02222a, 0x28000a20, 0x28000a20},
1883 +       {0x0000a530, 0x3e02222c, 0x3e02222c, 0x2c000e20, 0x2c000e20},
1884 +       {0x0000a534, 0x4202242a, 0x4202242a, 0x30000e22, 0x30000e22},
1885 +       {0x0000a538, 0x4702244a, 0x4702244a, 0x34000e24, 0x34000e24},
1886 +       {0x0000a53c, 0x4b02244c, 0x4b02244c, 0x38001640, 0x38001640},
1887 +       {0x0000a540, 0x4e02246c, 0x4e02246c, 0x3c001660, 0x3c001660},
1888 +       {0x0000a544, 0x5302266c, 0x5302266c, 0x3f001861, 0x3f001861},
1889 +       {0x0000a548, 0x5702286c, 0x5702286c, 0x43001a81, 0x43001a81},
1890 +       {0x0000a54c, 0x5c02486b, 0x5c02486b, 0x47001a83, 0x47001a83},
1891 +       {0x0000a550, 0x61024a6c, 0x61024a6c, 0x4a001c84, 0x4a001c84},
1892 +       {0x0000a554, 0x66026a6c, 0x66026a6c, 0x4e001ce3, 0x4e001ce3},
1893 +       {0x0000a558, 0x6b026e6c, 0x6b026e6c, 0x52001ce5, 0x52001ce5},
1894 +       {0x0000a55c, 0x7002708c, 0x7002708c, 0x56001ce9, 0x56001ce9},
1895 +       {0x0000a560, 0x7302b08a, 0x7302b08a, 0x5a001ceb, 0x5a001ceb},
1896 +       {0x0000a564, 0x7702b08c, 0x7702b08c, 0x5d001eec, 0x5d001eec},
1897 +       {0x0000a568, 0x7702b08c, 0x7702b08c, 0x5d001eec, 0x5d001eec},
1898 +       {0x0000a56c, 0x7702b08c, 0x7702b08c, 0x5d001eec, 0x5d001eec},
1899 +       {0x0000a570, 0x7702b08c, 0x7702b08c, 0x5d001eec, 0x5d001eec},
1900 +       {0x0000a574, 0x7702b08c, 0x7702b08c, 0x5d001eec, 0x5d001eec},
1901 +       {0x0000a578, 0x7702b08c, 0x7702b08c, 0x5d001eec, 0x5d001eec},
1902 +       {0x0000a57c, 0x7702b08c, 0x7702b08c, 0x5d001eec, 0x5d001eec},
1903 +       {0x0000a580, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
1904 +       {0x0000a584, 0x06800003, 0x06800003, 0x04800002, 0x04800002},
1905 +       {0x0000a588, 0x0a800020, 0x0a800020, 0x08800004, 0x08800004},
1906 +       {0x0000a58c, 0x10800023, 0x10800023, 0x0b800200, 0x0b800200},
1907 +       {0x0000a590, 0x16800220, 0x16800220, 0x0f800202, 0x0f800202},
1908 +       {0x0000a594, 0x1c800223, 0x1c800223, 0x12800400, 0x12800400},
1909 +       {0x0000a598, 0x21802220, 0x21802220, 0x16800402, 0x16800402},
1910 +       {0x0000a59c, 0x27802223, 0x27802223, 0x19800404, 0x19800404},
1911 +       {0x0000a5a0, 0x2b822220, 0x2b822220, 0x1c800603, 0x1c800603},
1912 +       {0x0000a5a4, 0x2f822222, 0x2f822222, 0x21800a02, 0x21800a02},
1913 +       {0x0000a5a8, 0x34822225, 0x34822225, 0x25800a04, 0x25800a04},
1914 +       {0x0000a5ac, 0x3a82222a, 0x3a82222a, 0x28800a20, 0x28800a20},
1915 +       {0x0000a5b0, 0x3e82222c, 0x3e82222c, 0x2c800e20, 0x2c800e20},
1916 +       {0x0000a5b4, 0x4282242a, 0x4282242a, 0x30800e22, 0x30800e22},
1917 +       {0x0000a5b8, 0x4782244a, 0x4782244a, 0x34800e24, 0x34800e24},
1918 +       {0x0000a5bc, 0x4b82244c, 0x4b82244c, 0x38801640, 0x38801640},
1919 +       {0x0000a5c0, 0x4e82246c, 0x4e82246c, 0x3c801660, 0x3c801660},
1920 +       {0x0000a5c4, 0x5382266c, 0x5382266c, 0x3f801861, 0x3f801861},
1921 +       {0x0000a5c8, 0x5782286c, 0x5782286c, 0x43801a81, 0x43801a81},
1922 +       {0x0000a5cc, 0x5c82486b, 0x5c82486b, 0x47801a83, 0x47801a83},
1923 +       {0x0000a5d0, 0x61824a6c, 0x61824a6c, 0x4a801c84, 0x4a801c84},
1924 +       {0x0000a5d4, 0x66826a6c, 0x66826a6c, 0x4e801ce3, 0x4e801ce3},
1925 +       {0x0000a5d8, 0x6b826e6c, 0x6b826e6c, 0x52801ce5, 0x52801ce5},
1926 +       {0x0000a5dc, 0x7082708c, 0x7082708c, 0x56801ce9, 0x56801ce9},
1927 +       {0x0000a5e0, 0x7382b08a, 0x7382b08a, 0x5a801ceb, 0x5a801ceb},
1928 +       {0x0000a5e4, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
1929 +       {0x0000a5e8, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
1930 +       {0x0000a5ec, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
1931 +       {0x0000a5f0, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
1932 +       {0x0000a5f4, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
1933 +       {0x0000a5f8, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
1934 +       {0x0000a5fc, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
1935 +       {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1936 +       {0x00016048, 0x62480001, 0x62480001, 0x62480001, 0x62480001},
1937 +       {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1938 +       {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1939 +       {0x00016448, 0x62480001, 0x62480001, 0x62480001, 0x62480001},
1940 +       {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1941 +       {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1942 +       {0x00016848, 0x62480001, 0x62480001, 0x62480001, 0x62480001},
1943 +       {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1944 +};
1945 +
1946 +static const u32 ar9300Modes_fast_clock_2p2[][3] = {
1947 +       /* Addr      5G_HT20     5G_HT40   */
1948 +       {0x00001030, 0x00000268, 0x000004d0},
1949 +       {0x00001070, 0x0000018c, 0x00000318},
1950 +       {0x000010b0, 0x00000fd0, 0x00001fa0},
1951 +       {0x00008014, 0x044c044c, 0x08980898},
1952 +       {0x0000801c, 0x148ec02b, 0x148ec057},
1953 +       {0x00008318, 0x000044c0, 0x00008980},
1954 +       {0x00009e00, 0x03721821, 0x03721821},
1955 +       {0x0000a230, 0x0000000b, 0x00000016},
1956 +       {0x0000a254, 0x00000898, 0x00001130},
1957 +};
1958 +
1959 +static const u32 ar9300_2p2_radio_core[][2] = {
1960 +       /* Addr      allmodes  */
1961 +       {0x00016000, 0x36db6db6},
1962 +       {0x00016004, 0x6db6db40},
1963 +       {0x00016008, 0x73f00000},
1964 +       {0x0001600c, 0x00000000},
1965 +       {0x00016040, 0x7f80fff8},
1966 +       {0x0001604c, 0x76d005b5},
1967 +       {0x00016050, 0x556cf031},
1968 +       {0x00016054, 0x13449440},
1969 +       {0x00016058, 0x0c51c92c},
1970 +       {0x0001605c, 0x3db7fffc},
1971 +       {0x00016060, 0xfffffffc},
1972 +       {0x00016064, 0x000f0278},
1973 +       {0x0001606c, 0x6db60000},
1974 +       {0x00016080, 0x00000000},
1975 +       {0x00016084, 0x0e48048c},
1976 +       {0x00016088, 0x54214514},
1977 +       {0x0001608c, 0x119f481e},
1978 +       {0x00016090, 0x24926490},
1979 +       {0x00016098, 0xd2888888},
1980 +       {0x000160a0, 0x0a108ffe},
1981 +       {0x000160a4, 0x812fc370},
1982 +       {0x000160a8, 0x423c8000},
1983 +       {0x000160b4, 0x92480080},
1984 +       {0x000160c0, 0x00adb6d0},
1985 +       {0x000160c4, 0x6db6db60},
1986 +       {0x000160c8, 0x6db6db6c},
1987 +       {0x000160cc, 0x01e6c000},
1988 +       {0x00016100, 0x3fffbe01},
1989 +       {0x00016104, 0xfff80000},
1990 +       {0x00016108, 0x00080010},
1991 +       {0x00016144, 0x02084080},
1992 +       {0x00016148, 0x00000000},
1993 +       {0x00016280, 0x058a0001},
1994 +       {0x00016284, 0x3d840208},
1995 +       {0x00016288, 0x05a20408},
1996 +       {0x0001628c, 0x00038c07},
1997 +       {0x00016290, 0x00000004},
1998 +       {0x00016294, 0x458aa14f},
1999 +       {0x00016380, 0x00000000},
2000 +       {0x00016384, 0x00000000},
2001 +       {0x00016388, 0x00800700},
2002 +       {0x0001638c, 0x00800700},
2003 +       {0x00016390, 0x00800700},
2004 +       {0x00016394, 0x00000000},
2005 +       {0x00016398, 0x00000000},
2006 +       {0x0001639c, 0x00000000},
2007 +       {0x000163a0, 0x00000001},
2008 +       {0x000163a4, 0x00000001},
2009 +       {0x000163a8, 0x00000000},
2010 +       {0x000163ac, 0x00000000},
2011 +       {0x000163b0, 0x00000000},
2012 +       {0x000163b4, 0x00000000},
2013 +       {0x000163b8, 0x00000000},
2014 +       {0x000163bc, 0x00000000},
2015 +       {0x000163c0, 0x000000a0},
2016 +       {0x000163c4, 0x000c0000},
2017 +       {0x000163c8, 0x14021402},
2018 +       {0x000163cc, 0x00001402},
2019 +       {0x000163d0, 0x00000000},
2020 +       {0x000163d4, 0x00000000},
2021 +       {0x00016400, 0x36db6db6},
2022 +       {0x00016404, 0x6db6db40},
2023 +       {0x00016408, 0x73f00000},
2024 +       {0x0001640c, 0x00000000},
2025 +       {0x00016440, 0x7f80fff8},
2026 +       {0x0001644c, 0x76d005b5},
2027 +       {0x00016450, 0x556cf031},
2028 +       {0x00016454, 0x13449440},
2029 +       {0x00016458, 0x0c51c92c},
2030 +       {0x0001645c, 0x3db7fffc},
2031 +       {0x00016460, 0xfffffffc},
2032 +       {0x00016464, 0x000f0278},
2033 +       {0x0001646c, 0x6db60000},
2034 +       {0x00016500, 0x3fffbe01},
2035 +       {0x00016504, 0xfff80000},
2036 +       {0x00016508, 0x00080010},
2037 +       {0x00016544, 0x02084080},
2038 +       {0x00016548, 0x00000000},
2039 +       {0x00016780, 0x00000000},
2040 +       {0x00016784, 0x00000000},
2041 +       {0x00016788, 0x00800700},
2042 +       {0x0001678c, 0x00800700},
2043 +       {0x00016790, 0x00800700},
2044 +       {0x00016794, 0x00000000},
2045 +       {0x00016798, 0x00000000},
2046 +       {0x0001679c, 0x00000000},
2047 +       {0x000167a0, 0x00000001},
2048 +       {0x000167a4, 0x00000001},
2049 +       {0x000167a8, 0x00000000},
2050 +       {0x000167ac, 0x00000000},
2051 +       {0x000167b0, 0x00000000},
2052 +       {0x000167b4, 0x00000000},
2053 +       {0x000167b8, 0x00000000},
2054 +       {0x000167bc, 0x00000000},
2055 +       {0x000167c0, 0x000000a0},
2056 +       {0x000167c4, 0x000c0000},
2057 +       {0x000167c8, 0x14021402},
2058 +       {0x000167cc, 0x00001402},
2059 +       {0x000167d0, 0x00000000},
2060 +       {0x000167d4, 0x00000000},
2061 +       {0x00016800, 0x36db6db6},
2062 +       {0x00016804, 0x6db6db40},
2063 +       {0x00016808, 0x73f00000},
2064 +       {0x0001680c, 0x00000000},
2065 +       {0x00016840, 0x7f80fff8},
2066 +       {0x0001684c, 0x76d005b5},
2067 +       {0x00016850, 0x556cf031},
2068 +       {0x00016854, 0x13449440},
2069 +       {0x00016858, 0x0c51c92c},
2070 +       {0x0001685c, 0x3db7fffc},
2071 +       {0x00016860, 0xfffffffc},
2072 +       {0x00016864, 0x000f0278},
2073 +       {0x0001686c, 0x6db60000},
2074 +       {0x00016900, 0x3fffbe01},
2075 +       {0x00016904, 0xfff80000},
2076 +       {0x00016908, 0x00080010},
2077 +       {0x00016944, 0x02084080},
2078 +       {0x00016948, 0x00000000},
2079 +       {0x00016b80, 0x00000000},
2080 +       {0x00016b84, 0x00000000},
2081 +       {0x00016b88, 0x00800700},
2082 +       {0x00016b8c, 0x00800700},
2083 +       {0x00016b90, 0x00800700},
2084 +       {0x00016b94, 0x00000000},
2085 +       {0x00016b98, 0x00000000},
2086 +       {0x00016b9c, 0x00000000},
2087 +       {0x00016ba0, 0x00000001},
2088 +       {0x00016ba4, 0x00000001},
2089 +       {0x00016ba8, 0x00000000},
2090 +       {0x00016bac, 0x00000000},
2091 +       {0x00016bb0, 0x00000000},
2092 +       {0x00016bb4, 0x00000000},
2093 +       {0x00016bb8, 0x00000000},
2094 +       {0x00016bbc, 0x00000000},
2095 +       {0x00016bc0, 0x000000a0},
2096 +       {0x00016bc4, 0x000c0000},
2097 +       {0x00016bc8, 0x14021402},
2098 +       {0x00016bcc, 0x00001402},
2099 +       {0x00016bd0, 0x00000000},
2100 +       {0x00016bd4, 0x00000000},
2101 +};
2102 +
2103 +static const u32 ar9300Common_rx_gain_table_merlin_2p2[][2] = {
2104 +       /* Addr      allmodes  */
2105 +       {0x0000a000, 0x02000101},
2106 +       {0x0000a004, 0x02000102},
2107 +       {0x0000a008, 0x02000103},
2108 +       {0x0000a00c, 0x02000104},
2109 +       {0x0000a010, 0x02000200},
2110 +       {0x0000a014, 0x02000201},
2111 +       {0x0000a018, 0x02000202},
2112 +       {0x0000a01c, 0x02000203},
2113 +       {0x0000a020, 0x02000204},
2114 +       {0x0000a024, 0x02000205},
2115 +       {0x0000a028, 0x02000208},
2116 +       {0x0000a02c, 0x02000302},
2117 +       {0x0000a030, 0x02000303},
2118 +       {0x0000a034, 0x02000304},
2119 +       {0x0000a038, 0x02000400},
2120 +       {0x0000a03c, 0x02010300},
2121 +       {0x0000a040, 0x02010301},
2122 +       {0x0000a044, 0x02010302},
2123 +       {0x0000a048, 0x02000500},
2124 +       {0x0000a04c, 0x02010400},
2125 +       {0x0000a050, 0x02020300},
2126 +       {0x0000a054, 0x02020301},
2127 +       {0x0000a058, 0x02020302},
2128 +       {0x0000a05c, 0x02020303},
2129 +       {0x0000a060, 0x02020400},
2130 +       {0x0000a064, 0x02030300},
2131 +       {0x0000a068, 0x02030301},
2132 +       {0x0000a06c, 0x02030302},
2133 +       {0x0000a070, 0x02030303},
2134 +       {0x0000a074, 0x02030400},
2135 +       {0x0000a078, 0x02040300},
2136 +       {0x0000a07c, 0x02040301},
2137 +       {0x0000a080, 0x02040302},
2138 +       {0x0000a084, 0x02040303},
2139 +       {0x0000a088, 0x02030500},
2140 +       {0x0000a08c, 0x02040400},
2141 +       {0x0000a090, 0x02050203},
2142 +       {0x0000a094, 0x02050204},
2143 +       {0x0000a098, 0x02050205},
2144 +       {0x0000a09c, 0x02040500},
2145 +       {0x0000a0a0, 0x02050301},
2146 +       {0x0000a0a4, 0x02050302},
2147 +       {0x0000a0a8, 0x02050303},
2148 +       {0x0000a0ac, 0x02050400},
2149 +       {0x0000a0b0, 0x02050401},
2150 +       {0x0000a0b4, 0x02050402},
2151 +       {0x0000a0b8, 0x02050403},
2152 +       {0x0000a0bc, 0x02050500},
2153 +       {0x0000a0c0, 0x02050501},
2154 +       {0x0000a0c4, 0x02050502},
2155 +       {0x0000a0c8, 0x02050503},
2156 +       {0x0000a0cc, 0x02050504},
2157 +       {0x0000a0d0, 0x02050600},
2158 +       {0x0000a0d4, 0x02050601},
2159 +       {0x0000a0d8, 0x02050602},
2160 +       {0x0000a0dc, 0x02050603},
2161 +       {0x0000a0e0, 0x02050604},
2162 +       {0x0000a0e4, 0x02050700},
2163 +       {0x0000a0e8, 0x02050701},
2164 +       {0x0000a0ec, 0x02050702},
2165 +       {0x0000a0f0, 0x02050703},
2166 +       {0x0000a0f4, 0x02050704},
2167 +       {0x0000a0f8, 0x02050705},
2168 +       {0x0000a0fc, 0x02050708},
2169 +       {0x0000a100, 0x02050709},
2170 +       {0x0000a104, 0x0205070a},
2171 +       {0x0000a108, 0x0205070b},
2172 +       {0x0000a10c, 0x0205070c},
2173 +       {0x0000a110, 0x0205070d},
2174 +       {0x0000a114, 0x02050710},
2175 +       {0x0000a118, 0x02050711},
2176 +       {0x0000a11c, 0x02050712},
2177 +       {0x0000a120, 0x02050713},
2178 +       {0x0000a124, 0x02050714},
2179 +       {0x0000a128, 0x02050715},
2180 +       {0x0000a12c, 0x02050730},
2181 +       {0x0000a130, 0x02050731},
2182 +       {0x0000a134, 0x02050732},
2183 +       {0x0000a138, 0x02050733},
2184 +       {0x0000a13c, 0x02050734},
2185 +       {0x0000a140, 0x02050735},
2186 +       {0x0000a144, 0x02050750},
2187 +       {0x0000a148, 0x02050751},
2188 +       {0x0000a14c, 0x02050752},
2189 +       {0x0000a150, 0x02050753},
2190 +       {0x0000a154, 0x02050754},
2191 +       {0x0000a158, 0x02050755},
2192 +       {0x0000a15c, 0x02050770},
2193 +       {0x0000a160, 0x02050771},
2194 +       {0x0000a164, 0x02050772},
2195 +       {0x0000a168, 0x02050773},
2196 +       {0x0000a16c, 0x02050774},
2197 +       {0x0000a170, 0x02050775},
2198 +       {0x0000a174, 0x00000776},
2199 +       {0x0000a178, 0x00000776},
2200 +       {0x0000a17c, 0x00000776},
2201 +       {0x0000a180, 0x00000776},
2202 +       {0x0000a184, 0x00000776},
2203 +       {0x0000a188, 0x00000776},
2204 +       {0x0000a18c, 0x00000776},
2205 +       {0x0000a190, 0x00000776},
2206 +       {0x0000a194, 0x00000776},
2207 +       {0x0000a198, 0x00000776},
2208 +       {0x0000a19c, 0x00000776},
2209 +       {0x0000a1a0, 0x00000776},
2210 +       {0x0000a1a4, 0x00000776},
2211 +       {0x0000a1a8, 0x00000776},
2212 +       {0x0000a1ac, 0x00000776},
2213 +       {0x0000a1b0, 0x00000776},
2214 +       {0x0000a1b4, 0x00000776},
2215 +       {0x0000a1b8, 0x00000776},
2216 +       {0x0000a1bc, 0x00000776},
2217 +       {0x0000a1c0, 0x00000776},
2218 +       {0x0000a1c4, 0x00000776},
2219 +       {0x0000a1c8, 0x00000776},
2220 +       {0x0000a1cc, 0x00000776},
2221 +       {0x0000a1d0, 0x00000776},
2222 +       {0x0000a1d4, 0x00000776},
2223 +       {0x0000a1d8, 0x00000776},
2224 +       {0x0000a1dc, 0x00000776},
2225 +       {0x0000a1e0, 0x00000776},
2226 +       {0x0000a1e4, 0x00000776},
2227 +       {0x0000a1e8, 0x00000776},
2228 +       {0x0000a1ec, 0x00000776},
2229 +       {0x0000a1f0, 0x00000776},
2230 +       {0x0000a1f4, 0x00000776},
2231 +       {0x0000a1f8, 0x00000776},
2232 +       {0x0000a1fc, 0x00000776},
2233 +       {0x0000b000, 0x02000101},
2234 +       {0x0000b004, 0x02000102},
2235 +       {0x0000b008, 0x02000103},
2236 +       {0x0000b00c, 0x02000104},
2237 +       {0x0000b010, 0x02000200},
2238 +       {0x0000b014, 0x02000201},
2239 +       {0x0000b018, 0x02000202},
2240 +       {0x0000b01c, 0x02000203},
2241 +       {0x0000b020, 0x02000204},
2242 +       {0x0000b024, 0x02000205},
2243 +       {0x0000b028, 0x02000208},
2244 +       {0x0000b02c, 0x02000302},
2245 +       {0x0000b030, 0x02000303},
2246 +       {0x0000b034, 0x02000304},
2247 +       {0x0000b038, 0x02000400},
2248 +       {0x0000b03c, 0x02010300},
2249 +       {0x0000b040, 0x02010301},
2250 +       {0x0000b044, 0x02010302},
2251 +       {0x0000b048, 0x02000500},
2252 +       {0x0000b04c, 0x02010400},
2253 +       {0x0000b050, 0x02020300},
2254 +       {0x0000b054, 0x02020301},
2255 +       {0x0000b058, 0x02020302},
2256 +       {0x0000b05c, 0x02020303},
2257 +       {0x0000b060, 0x02020400},
2258 +       {0x0000b064, 0x02030300},
2259 +       {0x0000b068, 0x02030301},
2260 +       {0x0000b06c, 0x02030302},
2261 +       {0x0000b070, 0x02030303},
2262 +       {0x0000b074, 0x02030400},
2263 +       {0x0000b078, 0x02040300},
2264 +       {0x0000b07c, 0x02040301},
2265 +       {0x0000b080, 0x02040302},
2266 +       {0x0000b084, 0x02040303},
2267 +       {0x0000b088, 0x02030500},
2268 +       {0x0000b08c, 0x02040400},
2269 +       {0x0000b090, 0x02050203},
2270 +       {0x0000b094, 0x02050204},
2271 +       {0x0000b098, 0x02050205},
2272 +       {0x0000b09c, 0x02040500},
2273 +       {0x0000b0a0, 0x02050301},
2274 +       {0x0000b0a4, 0x02050302},
2275 +       {0x0000b0a8, 0x02050303},
2276 +       {0x0000b0ac, 0x02050400},
2277 +       {0x0000b0b0, 0x02050401},
2278 +       {0x0000b0b4, 0x02050402},
2279 +       {0x0000b0b8, 0x02050403},
2280 +       {0x0000b0bc, 0x02050500},
2281 +       {0x0000b0c0, 0x02050501},
2282 +       {0x0000b0c4, 0x02050502},
2283 +       {0x0000b0c8, 0x02050503},
2284 +       {0x0000b0cc, 0x02050504},
2285 +       {0x0000b0d0, 0x02050600},
2286 +       {0x0000b0d4, 0x02050601},
2287 +       {0x0000b0d8, 0x02050602},
2288 +       {0x0000b0dc, 0x02050603},
2289 +       {0x0000b0e0, 0x02050604},
2290 +       {0x0000b0e4, 0x02050700},
2291 +       {0x0000b0e8, 0x02050701},
2292 +       {0x0000b0ec, 0x02050702},
2293 +       {0x0000b0f0, 0x02050703},
2294 +       {0x0000b0f4, 0x02050704},
2295 +       {0x0000b0f8, 0x02050705},
2296 +       {0x0000b0fc, 0x02050708},
2297 +       {0x0000b100, 0x02050709},
2298 +       {0x0000b104, 0x0205070a},
2299 +       {0x0000b108, 0x0205070b},
2300 +       {0x0000b10c, 0x0205070c},
2301 +       {0x0000b110, 0x0205070d},
2302 +       {0x0000b114, 0x02050710},
2303 +       {0x0000b118, 0x02050711},
2304 +       {0x0000b11c, 0x02050712},
2305 +       {0x0000b120, 0x02050713},
2306 +       {0x0000b124, 0x02050714},
2307 +       {0x0000b128, 0x02050715},
2308 +       {0x0000b12c, 0x02050730},
2309 +       {0x0000b130, 0x02050731},
2310 +       {0x0000b134, 0x02050732},
2311 +       {0x0000b138, 0x02050733},
2312 +       {0x0000b13c, 0x02050734},
2313 +       {0x0000b140, 0x02050735},
2314 +       {0x0000b144, 0x02050750},
2315 +       {0x0000b148, 0x02050751},
2316 +       {0x0000b14c, 0x02050752},
2317 +       {0x0000b150, 0x02050753},
2318 +       {0x0000b154, 0x02050754},
2319 +       {0x0000b158, 0x02050755},
2320 +       {0x0000b15c, 0x02050770},
2321 +       {0x0000b160, 0x02050771},
2322 +       {0x0000b164, 0x02050772},
2323 +       {0x0000b168, 0x02050773},
2324 +       {0x0000b16c, 0x02050774},
2325 +       {0x0000b170, 0x02050775},
2326 +       {0x0000b174, 0x00000776},
2327 +       {0x0000b178, 0x00000776},
2328 +       {0x0000b17c, 0x00000776},
2329 +       {0x0000b180, 0x00000776},
2330 +       {0x0000b184, 0x00000776},
2331 +       {0x0000b188, 0x00000776},
2332 +       {0x0000b18c, 0x00000776},
2333 +       {0x0000b190, 0x00000776},
2334 +       {0x0000b194, 0x00000776},
2335 +       {0x0000b198, 0x00000776},
2336 +       {0x0000b19c, 0x00000776},
2337 +       {0x0000b1a0, 0x00000776},
2338 +       {0x0000b1a4, 0x00000776},
2339 +       {0x0000b1a8, 0x00000776},
2340 +       {0x0000b1ac, 0x00000776},
2341 +       {0x0000b1b0, 0x00000776},
2342 +       {0x0000b1b4, 0x00000776},
2343 +       {0x0000b1b8, 0x00000776},
2344 +       {0x0000b1bc, 0x00000776},
2345 +       {0x0000b1c0, 0x00000776},
2346 +       {0x0000b1c4, 0x00000776},
2347 +       {0x0000b1c8, 0x00000776},
2348 +       {0x0000b1cc, 0x00000776},
2349 +       {0x0000b1d0, 0x00000776},
2350 +       {0x0000b1d4, 0x00000776},
2351 +       {0x0000b1d8, 0x00000776},
2352 +       {0x0000b1dc, 0x00000776},
2353 +       {0x0000b1e0, 0x00000776},
2354 +       {0x0000b1e4, 0x00000776},
2355 +       {0x0000b1e8, 0x00000776},
2356 +       {0x0000b1ec, 0x00000776},
2357 +       {0x0000b1f0, 0x00000776},
2358 +       {0x0000b1f4, 0x00000776},
2359 +       {0x0000b1f8, 0x00000776},
2360 +       {0x0000b1fc, 0x00000776},
2361 +};
2362 +
2363 +static const u32 ar9300_2p2_mac_postamble[][5] = {
2364 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
2365 +       {0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160},
2366 +       {0x00001070, 0x00000168, 0x000002d0, 0x00000318, 0x0000018c},
2367 +       {0x000010b0, 0x00000e60, 0x00001cc0, 0x00007c70, 0x00003e38},
2368 +       {0x00008014, 0x03e803e8, 0x07d007d0, 0x10801600, 0x08400b00},
2369 +       {0x0000801c, 0x128d8027, 0x128d804f, 0x12e00057, 0x12e0002b},
2370 +       {0x00008120, 0x08f04800, 0x08f04800, 0x08f04810, 0x08f04810},
2371 +       {0x000081d0, 0x00003210, 0x00003210, 0x0000320a, 0x0000320a},
2372 +       {0x00008318, 0x00003e80, 0x00007d00, 0x00006880, 0x00003440},
2373 +};
2374 +
2375 +static const u32 ar9300_2p2_soc_postamble[][5] = {
2376 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
2377 +       {0x00007010, 0x00000023, 0x00000023, 0x00000023, 0x00000023},
2378 +};
2379 +
2380 +static const u32 ar9200_merlin_2p2_radio_core[][2] = {
2381 +       /* Addr      allmodes  */
2382 +       {0x00007800, 0x00040000},
2383 +       {0x00007804, 0xdb005012},
2384 +       {0x00007808, 0x04924914},
2385 +       {0x0000780c, 0x21084210},
2386 +       {0x00007810, 0x6d801300},
2387 +       {0x00007814, 0x0019beff},
2388 +       {0x00007818, 0x07e41000},
2389 +       {0x0000781c, 0x00392000},
2390 +       {0x00007820, 0x92592480},
2391 +       {0x00007824, 0x00040000},
2392 +       {0x00007828, 0xdb005012},
2393 +       {0x0000782c, 0x04924914},
2394 +       {0x00007830, 0x21084210},
2395 +       {0x00007834, 0x6d801300},
2396 +       {0x00007838, 0x0019beff},
2397 +       {0x0000783c, 0x07e40000},
2398 +       {0x00007840, 0x00392000},
2399 +       {0x00007844, 0x92592480},
2400 +       {0x00007848, 0x00100000},
2401 +       {0x0000784c, 0x773f0567},
2402 +       {0x00007850, 0x54214514},
2403 +       {0x00007854, 0x12035828},
2404 +       {0x00007858, 0x92592692},
2405 +       {0x0000785c, 0x00000000},
2406 +       {0x00007860, 0x56400000},
2407 +       {0x00007864, 0x0a8e370e},
2408 +       {0x00007868, 0xc0102850},
2409 +       {0x0000786c, 0x812d4000},
2410 +       {0x00007870, 0x807ec400},
2411 +       {0x00007874, 0x001b6db0},
2412 +       {0x00007878, 0x00376b63},
2413 +       {0x0000787c, 0x06db6db6},
2414 +       {0x00007880, 0x006d8000},
2415 +       {0x00007884, 0xffeffffe},
2416 +       {0x00007888, 0xffeffffe},
2417 +       {0x0000788c, 0x00010000},
2418 +       {0x00007890, 0x02060aeb},
2419 +       {0x00007894, 0x5a108000},
2420 +};
2421 +
2422 +static const u32 ar9300_2p2_baseband_postamble[][5] = {
2423 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
2424 +       {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8011, 0xd00a8011},
2425 +       {0x00009820, 0x206a022e, 0x206a022e, 0x206a012e, 0x206a012e},
2426 +       {0x00009824, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0},
2427 +       {0x00009828, 0x06903081, 0x06903081, 0x06903881, 0x06903881},
2428 +       {0x0000982c, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4},
2429 +       {0x00009830, 0x0000059c, 0x0000059c, 0x0000119c, 0x0000119c},
2430 +       {0x00009c00, 0x000000c4, 0x000000c4, 0x000000c4, 0x000000c4},
2431 +       {0x00009e00, 0x0372161e, 0x0372161e, 0x037216a0, 0x037216a0},
2432 +       {0x00009e04, 0x00802020, 0x00802020, 0x00802020, 0x00802020},
2433 +       {0x00009e0c, 0x6c4000e2, 0x6d4000e2, 0x6d4000e2, 0x6c4000e2},
2434 +       {0x00009e10, 0x7ec88d2e, 0x7ec88d2e, 0x7ec84d2e, 0x7ec84d2e},
2435 +       {0x00009e14, 0x31395d5e, 0x3139605e, 0x3139605e, 0x31395d5e},
2436 +       {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
2437 +       {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c},
2438 +       {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce},
2439 +       {0x00009e2c, 0x0000001c, 0x0000001c, 0x00000021, 0x00000021},
2440 +       {0x00009e44, 0x02321e27, 0x02321e27, 0x02291e27, 0x02291e27},
2441 +       {0x00009e48, 0x5030201a, 0x5030201a, 0x50302012, 0x50302012},
2442 +       {0x00009fc8, 0x0003f000, 0x0003f000, 0x0001a000, 0x0001a000},
2443 +       {0x0000a204, 0x000037c0, 0x000037c4, 0x000037c4, 0x000037c0},
2444 +       {0x0000a208, 0x00000104, 0x00000104, 0x00000004, 0x00000004},
2445 +       {0x0000a230, 0x0000000a, 0x00000014, 0x00000016, 0x0000000b},
2446 +       {0x0000a234, 0x00000fff, 0x10000fff, 0x10000fff, 0x00000fff},
2447 +       {0x0000a238, 0xffb81018, 0xffb81018, 0xffb81018, 0xffb81018},
2448 +       {0x0000a250, 0x00000000, 0x00000000, 0x00000210, 0x00000108},
2449 +       {0x0000a254, 0x000007d0, 0x00000fa0, 0x00001130, 0x00000898},
2450 +       {0x0000a258, 0x02020002, 0x02020002, 0x02020002, 0x02020002},
2451 +       {0x0000a25c, 0x01000e0e, 0x01000e0e, 0x01000e0e, 0x01000e0e},
2452 +       {0x0000a260, 0x0a021501, 0x0a021501, 0x3a021501, 0x3a021501},
2453 +       {0x0000a264, 0x00000e0e, 0x00000e0e, 0x00000e0e, 0x00000e0e},
2454 +       {0x0000a280, 0x00000007, 0x00000007, 0x0000000b, 0x0000000b},
2455 +       {0x0000a284, 0x00000000, 0x00000000, 0x00000150, 0x00000150},
2456 +       {0x0000a288, 0x00000110, 0x00000110, 0x00000110, 0x00000110},
2457 +       {0x0000a28c, 0x00022222, 0x00022222, 0x00022222, 0x00022222},
2458 +       {0x0000a2c4, 0x00158d18, 0x00158d18, 0x00158d18, 0x00158d18},
2459 +       {0x0000a2d0, 0x00071981, 0x00071981, 0x00071981, 0x00071982},
2460 +       {0x0000a2d8, 0xf999a83a, 0xf999a83a, 0xf999a83a, 0xf999a83a},
2461 +       {0x0000a358, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
2462 +       {0x0000a830, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
2463 +       {0x0000ae04, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
2464 +       {0x0000ae18, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
2465 +       {0x0000ae1c, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
2466 +       {0x0000ae20, 0x000001b5, 0x000001b5, 0x000001ce, 0x000001ce},
2467 +       {0x0000b284, 0x00000000, 0x00000000, 0x00000150, 0x00000150},
2468 +       {0x0000b830, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
2469 +       {0x0000be04, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
2470 +       {0x0000be18, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
2471 +       {0x0000be1c, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
2472 +       {0x0000be20, 0x000001b5, 0x000001b5, 0x000001ce, 0x000001ce},
2473 +       {0x0000c284, 0x00000000, 0x00000000, 0x00000150, 0x00000150},
2474 +};
2475 +
2476 +static const u32 ar9300_2p2_baseband_core[][2] = {
2477 +       /* Addr      allmodes  */
2478 +       {0x00009800, 0xafe68e30},
2479 +       {0x00009804, 0xfd14e000},
2480 +       {0x00009808, 0x9c0a9f6b},
2481 +       {0x0000980c, 0x04900000},
2482 +       {0x00009814, 0x9280c00a},
2483 +       {0x00009818, 0x00000000},
2484 +       {0x0000981c, 0x00020028},
2485 +       {0x00009834, 0x5f3ca3de},
2486 +       {0x00009838, 0x0108ecff},
2487 +       {0x0000983c, 0x14750600},
2488 +       {0x00009880, 0x201fff00},
2489 +       {0x00009884, 0x00001042},
2490 +       {0x000098a4, 0x00200400},
2491 +       {0x000098b0, 0x52440bbe},
2492 +       {0x000098d0, 0x004b6a8e},
2493 +       {0x000098d4, 0x00000820},
2494 +       {0x000098dc, 0x00000000},
2495 +       {0x000098f0, 0x00000000},
2496 +       {0x000098f4, 0x00000000},
2497 +       {0x00009c04, 0xff55ff55},
2498 +       {0x00009c08, 0x0320ff55},
2499 +       {0x00009c0c, 0x00000000},
2500 +       {0x00009c10, 0x00000000},
2501 +       {0x00009c14, 0x00046384},
2502 +       {0x00009c18, 0x05b6b440},
2503 +       {0x00009c1c, 0x00b6b440},
2504 +       {0x00009d00, 0xc080a333},
2505 +       {0x00009d04, 0x40206c10},
2506 +       {0x00009d08, 0x009c4060},
2507 +       {0x00009d0c, 0x9883800a},
2508 +       {0x00009d10, 0x01834061},
2509 +       {0x00009d14, 0x00c0040b},
2510 +       {0x00009d18, 0x00000000},
2511 +       {0x00009e08, 0x0038230c},
2512 +       {0x00009e24, 0x990bb515},
2513 +       {0x00009e28, 0x0c6f0000},
2514 +       {0x00009e30, 0x06336f77},
2515 +       {0x00009e34, 0x6af6532f},
2516 +       {0x00009e38, 0x0cc80c00},
2517 +       {0x00009e3c, 0xcf946222},
2518 +       {0x00009e40, 0x0d261820},
2519 +       {0x00009e4c, 0x00001004},
2520 +       {0x00009e50, 0x00ff03f1},
2521 +       {0x00009e54, 0x00000000},
2522 +       {0x00009fc0, 0x803e4788},
2523 +       {0x00009fc4, 0x0001efb5},
2524 +       {0x00009fcc, 0x40000014},
2525 +       {0x00009fd0, 0x01193b93},
2526 +       {0x0000a20c, 0x00000000},
2527 +       {0x0000a220, 0x00000000},
2528 +       {0x0000a224, 0x00000000},
2529 +       {0x0000a228, 0x10002310},
2530 +       {0x0000a22c, 0x01036a1e},
2531 +       {0x0000a23c, 0x00000000},
2532 +       {0x0000a244, 0x0c000000},
2533 +       {0x0000a2a0, 0x00000001},
2534 +       {0x0000a2c0, 0x00000001},
2535 +       {0x0000a2c8, 0x00000000},
2536 +       {0x0000a2cc, 0x18c43433},
2537 +       {0x0000a2d4, 0x00000000},
2538 +       {0x0000a2dc, 0x00000000},
2539 +       {0x0000a2e0, 0x00000000},
2540 +       {0x0000a2e4, 0x00000000},
2541 +       {0x0000a2e8, 0x00000000},
2542 +       {0x0000a2ec, 0x00000000},
2543 +       {0x0000a2f0, 0x00000000},
2544 +       {0x0000a2f4, 0x00000000},
2545 +       {0x0000a2f8, 0x00000000},
2546 +       {0x0000a344, 0x00000000},
2547 +       {0x0000a34c, 0x00000000},
2548 +       {0x0000a350, 0x0000a000},
2549 +       {0x0000a364, 0x00000000},
2550 +       {0x0000a370, 0x00000000},
2551 +       {0x0000a390, 0x00000001},
2552 +       {0x0000a394, 0x00000444},
2553 +       {0x0000a398, 0x001f0e0f},
2554 +       {0x0000a39c, 0x0075393f},
2555 +       {0x0000a3a0, 0xb79f6427},
2556 +       {0x0000a3a4, 0x00000000},
2557 +       {0x0000a3a8, 0xaaaaaaaa},
2558 +       {0x0000a3ac, 0x3c466478},
2559 +       {0x0000a3c0, 0x20202020},
2560 +       {0x0000a3c4, 0x22222220},
2561 +       {0x0000a3c8, 0x20200020},
2562 +       {0x0000a3cc, 0x20202020},
2563 +       {0x0000a3d0, 0x20202020},
2564 +       {0x0000a3d4, 0x20202020},
2565 +       {0x0000a3d8, 0x20202020},
2566 +       {0x0000a3dc, 0x20202020},
2567 +       {0x0000a3e0, 0x20202020},
2568 +       {0x0000a3e4, 0x20202020},
2569 +       {0x0000a3e8, 0x20202020},
2570 +       {0x0000a3ec, 0x20202020},
2571 +       {0x0000a3f0, 0x00000000},
2572 +       {0x0000a3f4, 0x00000246},
2573 +       {0x0000a3f8, 0x0cdbd380},
2574 +       {0x0000a3fc, 0x000f0f01},
2575 +       {0x0000a400, 0x8fa91f01},
2576 +       {0x0000a404, 0x00000000},
2577 +       {0x0000a408, 0x0e79e5c6},
2578 +       {0x0000a40c, 0x00820820},
2579 +       {0x0000a414, 0x1ce739ce},
2580 +       {0x0000a418, 0x2d001dce},
2581 +       {0x0000a41c, 0x1ce739ce},
2582 +       {0x0000a420, 0x000001ce},
2583 +       {0x0000a424, 0x1ce739ce},
2584 +       {0x0000a428, 0x000001ce},
2585 +       {0x0000a42c, 0x1ce739ce},
2586 +       {0x0000a430, 0x1ce739ce},
2587 +       {0x0000a434, 0x00000000},
2588 +       {0x0000a438, 0x00001801},
2589 +       {0x0000a43c, 0x00000000},
2590 +       {0x0000a440, 0x00000000},
2591 +       {0x0000a444, 0x00000000},
2592 +       {0x0000a448, 0x06000080},
2593 +       {0x0000a44c, 0x00000001},
2594 +       {0x0000a450, 0x00010000},
2595 +       {0x0000a458, 0x00000000},
2596 +       {0x0000a600, 0x00000000},
2597 +       {0x0000a604, 0x00000000},
2598 +       {0x0000a608, 0x00000000},
2599 +       {0x0000a60c, 0x00000000},
2600 +       {0x0000a610, 0x00000000},
2601 +       {0x0000a614, 0x00000000},
2602 +       {0x0000a618, 0x00000000},
2603 +       {0x0000a61c, 0x00000000},
2604 +       {0x0000a620, 0x00000000},
2605 +       {0x0000a624, 0x00000000},
2606 +       {0x0000a628, 0x00000000},
2607 +       {0x0000a62c, 0x00000000},
2608 +       {0x0000a630, 0x00000000},
2609 +       {0x0000a634, 0x00000000},
2610 +       {0x0000a638, 0x00000000},
2611 +       {0x0000a63c, 0x00000000},
2612 +       {0x0000a640, 0x00000000},
2613 +       {0x0000a644, 0x3fad9d74},
2614 +       {0x0000a648, 0x0048060a},
2615 +       {0x0000a64c, 0x00000637},
2616 +       {0x0000a670, 0x03020100},
2617 +       {0x0000a674, 0x09080504},
2618 +       {0x0000a678, 0x0d0c0b0a},
2619 +       {0x0000a67c, 0x13121110},
2620 +       {0x0000a680, 0x31301514},
2621 +       {0x0000a684, 0x35343332},
2622 +       {0x0000a688, 0x00000036},
2623 +       {0x0000a690, 0x00000838},
2624 +       {0x0000a7c0, 0x00000000},
2625 +       {0x0000a7c4, 0xfffffffc},
2626 +       {0x0000a7c8, 0x00000000},
2627 +       {0x0000a7cc, 0x00000000},
2628 +       {0x0000a7d0, 0x00000000},
2629 +       {0x0000a7d4, 0x00000004},
2630 +       {0x0000a7dc, 0x00000001},
2631 +       {0x0000a8d0, 0x004b6a8e},
2632 +       {0x0000a8d4, 0x00000820},
2633 +       {0x0000a8dc, 0x00000000},
2634 +       {0x0000a8f0, 0x00000000},
2635 +       {0x0000a8f4, 0x00000000},
2636 +       {0x0000b2d0, 0x00000080},
2637 +       {0x0000b2d4, 0x00000000},
2638 +       {0x0000b2dc, 0x00000000},
2639 +       {0x0000b2e0, 0x00000000},
2640 +       {0x0000b2e4, 0x00000000},
2641 +       {0x0000b2e8, 0x00000000},
2642 +       {0x0000b2ec, 0x00000000},
2643 +       {0x0000b2f0, 0x00000000},
2644 +       {0x0000b2f4, 0x00000000},
2645 +       {0x0000b2f8, 0x00000000},
2646 +       {0x0000b408, 0x0e79e5c0},
2647 +       {0x0000b40c, 0x00820820},
2648 +       {0x0000b420, 0x00000000},
2649 +       {0x0000b8d0, 0x004b6a8e},
2650 +       {0x0000b8d4, 0x00000820},
2651 +       {0x0000b8dc, 0x00000000},
2652 +       {0x0000b8f0, 0x00000000},
2653 +       {0x0000b8f4, 0x00000000},
2654 +       {0x0000c2d0, 0x00000080},
2655 +       {0x0000c2d4, 0x00000000},
2656 +       {0x0000c2dc, 0x00000000},
2657 +       {0x0000c2e0, 0x00000000},
2658 +       {0x0000c2e4, 0x00000000},
2659 +       {0x0000c2e8, 0x00000000},
2660 +       {0x0000c2ec, 0x00000000},
2661 +       {0x0000c2f0, 0x00000000},
2662 +       {0x0000c2f4, 0x00000000},
2663 +       {0x0000c2f8, 0x00000000},
2664 +       {0x0000c408, 0x0e79e5c0},
2665 +       {0x0000c40c, 0x00820820},
2666 +       {0x0000c420, 0x00000000},
2667 +};
2668 +
2669 +static const u32 ar9300Modes_high_power_tx_gain_table_2p2[][5] = {
2670 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
2671 +       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
2672 +       {0x0000a500, 0x00002220, 0x00002220, 0x00000000, 0x00000000},
2673 +       {0x0000a504, 0x06002223, 0x06002223, 0x04000002, 0x04000002},
2674 +       {0x0000a508, 0x0a022220, 0x0a022220, 0x08000004, 0x08000004},
2675 +       {0x0000a50c, 0x0f022223, 0x0f022223, 0x0b000200, 0x0b000200},
2676 +       {0x0000a510, 0x14022620, 0x14022620, 0x0f000202, 0x0f000202},
2677 +       {0x0000a514, 0x18022622, 0x18022622, 0x11000400, 0x11000400},
2678 +       {0x0000a518, 0x1b022822, 0x1b022822, 0x15000402, 0x15000402},
2679 +       {0x0000a51c, 0x20022842, 0x20022842, 0x19000404, 0x19000404},
2680 +       {0x0000a520, 0x22022c41, 0x22022c41, 0x1b000603, 0x1b000603},
2681 +       {0x0000a524, 0x28023042, 0x28023042, 0x1f000a02, 0x1f000a02},
2682 +       {0x0000a528, 0x2c023044, 0x2c023044, 0x23000a04, 0x23000a04},
2683 +       {0x0000a52c, 0x2f023644, 0x2f023644, 0x26000a20, 0x26000a20},
2684 +       {0x0000a530, 0x34025643, 0x34025643, 0x2a000e20, 0x2a000e20},
2685 +       {0x0000a534, 0x38025a44, 0x38025a44, 0x2e000e22, 0x2e000e22},
2686 +       {0x0000a538, 0x3b025e45, 0x3b025e45, 0x31000e24, 0x31000e24},
2687 +       {0x0000a53c, 0x41025e4a, 0x41025e4a, 0x34001640, 0x34001640},
2688 +       {0x0000a540, 0x48025e6c, 0x48025e6c, 0x38001660, 0x38001660},
2689 +       {0x0000a544, 0x4e025e8e, 0x4e025e8e, 0x3b001861, 0x3b001861},
2690 +       {0x0000a548, 0x53025eb2, 0x53025eb2, 0x3e001a81, 0x3e001a81},
2691 +       {0x0000a54c, 0x59025eb5, 0x59025eb5, 0x42001a83, 0x42001a83},
2692 +       {0x0000a550, 0x5f025ef6, 0x5f025ef6, 0x44001c84, 0x44001c84},
2693 +       {0x0000a554, 0x62025f56, 0x62025f56, 0x48001ce3, 0x48001ce3},
2694 +       {0x0000a558, 0x66027f56, 0x66027f56, 0x4c001ce5, 0x4c001ce5},
2695 +       {0x0000a55c, 0x6a029f56, 0x6a029f56, 0x50001ce9, 0x50001ce9},
2696 +       {0x0000a560, 0x70049f56, 0x70049f56, 0x54001ceb, 0x54001ceb},
2697 +       {0x0000a564, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
2698 +       {0x0000a568, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
2699 +       {0x0000a56c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
2700 +       {0x0000a570, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
2701 +       {0x0000a574, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
2702 +       {0x0000a578, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
2703 +       {0x0000a57c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
2704 +       {0x0000a580, 0x00802220, 0x00802220, 0x00800000, 0x00800000},
2705 +       {0x0000a584, 0x06802223, 0x06802223, 0x04800002, 0x04800002},
2706 +       {0x0000a588, 0x0a822220, 0x0a822220, 0x08800004, 0x08800004},
2707 +       {0x0000a58c, 0x0f822223, 0x0f822223, 0x0b800200, 0x0b800200},
2708 +       {0x0000a590, 0x14822620, 0x14822620, 0x0f800202, 0x0f800202},
2709 +       {0x0000a594, 0x18822622, 0x18822622, 0x11800400, 0x11800400},
2710 +       {0x0000a598, 0x1b822822, 0x1b822822, 0x15800402, 0x15800402},
2711 +       {0x0000a59c, 0x20822842, 0x20822842, 0x19800404, 0x19800404},
2712 +       {0x0000a5a0, 0x22822c41, 0x22822c41, 0x1b800603, 0x1b800603},
2713 +       {0x0000a5a4, 0x28823042, 0x28823042, 0x1f800a02, 0x1f800a02},
2714 +       {0x0000a5a8, 0x2c823044, 0x2c823044, 0x23800a04, 0x23800a04},
2715 +       {0x0000a5ac, 0x2f823644, 0x2f823644, 0x26800a20, 0x26800a20},
2716 +       {0x0000a5b0, 0x34825643, 0x34825643, 0x2a800e20, 0x2a800e20},
2717 +       {0x0000a5b4, 0x38825a44, 0x38825a44, 0x2e800e22, 0x2e800e22},
2718 +       {0x0000a5b8, 0x3b825e45, 0x3b825e45, 0x31800e24, 0x31800e24},
2719 +       {0x0000a5bc, 0x41825e4a, 0x41825e4a, 0x34801640, 0x34801640},
2720 +       {0x0000a5c0, 0x48825e6c, 0x48825e6c, 0x38801660, 0x38801660},
2721 +       {0x0000a5c4, 0x4e825e8e, 0x4e825e8e, 0x3b801861, 0x3b801861},
2722 +       {0x0000a5c8, 0x53825eb2, 0x53825eb2, 0x3e801a81, 0x3e801a81},
2723 +       {0x0000a5cc, 0x59825eb5, 0x59825eb5, 0x42801a83, 0x42801a83},
2724 +       {0x0000a5d0, 0x5f825ef6, 0x5f825ef6, 0x44801c84, 0x44801c84},
2725 +       {0x0000a5d4, 0x62825f56, 0x62825f56, 0x48801ce3, 0x48801ce3},
2726 +       {0x0000a5d8, 0x66827f56, 0x66827f56, 0x4c801ce5, 0x4c801ce5},
2727 +       {0x0000a5dc, 0x6a829f56, 0x6a829f56, 0x50801ce9, 0x50801ce9},
2728 +       {0x0000a5e0, 0x70849f56, 0x70849f56, 0x54801ceb, 0x54801ceb},
2729 +       {0x0000a5e4, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
2730 +       {0x0000a5e8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
2731 +       {0x0000a5ec, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
2732 +       {0x0000a5f0, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
2733 +       {0x0000a5f4, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
2734 +       {0x0000a5f8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
2735 +       {0x0000a5fc, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
2736 +       {0x00016044, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6},
2737 +       {0x00016048, 0xae480001, 0xae480001, 0xae480001, 0xae480001},
2738 +       {0x00016068, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c},
2739 +       {0x00016444, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6},
2740 +       {0x00016448, 0xae480001, 0xae480001, 0xae480001, 0xae480001},
2741 +       {0x00016468, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c},
2742 +       {0x00016844, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6},
2743 +       {0x00016848, 0xae480001, 0xae480001, 0xae480001, 0xae480001},
2744 +       {0x00016868, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c},
2745 +};
2746 +
2747 +static const u32 ar9300Modes_high_ob_db_tx_gain_table_2p2[][5] = {
2748 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
2749 +       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
2750 +       {0x0000a500, 0x00002220, 0x00002220, 0x00000000, 0x00000000},
2751 +       {0x0000a504, 0x06002223, 0x06002223, 0x04000002, 0x04000002},
2752 +       {0x0000a508, 0x0a022220, 0x0a022220, 0x08000004, 0x08000004},
2753 +       {0x0000a50c, 0x0f022223, 0x0f022223, 0x0b000200, 0x0b000200},
2754 +       {0x0000a510, 0x14022620, 0x14022620, 0x0f000202, 0x0f000202},
2755 +       {0x0000a514, 0x18022622, 0x18022622, 0x11000400, 0x11000400},
2756 +       {0x0000a518, 0x1b022822, 0x1b022822, 0x15000402, 0x15000402},
2757 +       {0x0000a51c, 0x20022842, 0x20022842, 0x19000404, 0x19000404},
2758 +       {0x0000a520, 0x22022c41, 0x22022c41, 0x1b000603, 0x1b000603},
2759 +       {0x0000a524, 0x28023042, 0x28023042, 0x1f000a02, 0x1f000a02},
2760 +       {0x0000a528, 0x2c023044, 0x2c023044, 0x23000a04, 0x23000a04},
2761 +       {0x0000a52c, 0x2f023644, 0x2f023644, 0x26000a20, 0x26000a20},
2762 +       {0x0000a530, 0x34025643, 0x34025643, 0x2a000e20, 0x2a000e20},
2763 +       {0x0000a534, 0x38025a44, 0x38025a44, 0x2e000e22, 0x2e000e22},
2764 +       {0x0000a538, 0x3b025e45, 0x3b025e45, 0x31000e24, 0x31000e24},
2765 +       {0x0000a53c, 0x41025e4a, 0x41025e4a, 0x34001640, 0x34001640},
2766 +       {0x0000a540, 0x48025e6c, 0x48025e6c, 0x38001660, 0x38001660},
2767 +       {0x0000a544, 0x4e025e8e, 0x4e025e8e, 0x3b001861, 0x3b001861},
2768 +       {0x0000a548, 0x53025eb2, 0x53025eb2, 0x3e001a81, 0x3e001a81},
2769 +       {0x0000a54c, 0x59025eb5, 0x59025eb5, 0x42001a83, 0x42001a83},
2770 +       {0x0000a550, 0x5f025ef6, 0x5f025ef6, 0x44001c84, 0x44001c84},
2771 +       {0x0000a554, 0x62025f56, 0x62025f56, 0x48001ce3, 0x48001ce3},
2772 +       {0x0000a558, 0x66027f56, 0x66027f56, 0x4c001ce5, 0x4c001ce5},
2773 +       {0x0000a55c, 0x6a029f56, 0x6a029f56, 0x50001ce9, 0x50001ce9},
2774 +       {0x0000a560, 0x70049f56, 0x70049f56, 0x54001ceb, 0x54001ceb},
2775 +       {0x0000a564, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
2776 +       {0x0000a568, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
2777 +       {0x0000a56c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
2778 +       {0x0000a570, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
2779 +       {0x0000a574, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
2780 +       {0x0000a578, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
2781 +       {0x0000a57c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
2782 +       {0x0000a580, 0x00802220, 0x00802220, 0x00800000, 0x00800000},
2783 +       {0x0000a584, 0x06802223, 0x06802223, 0x04800002, 0x04800002},
2784 +       {0x0000a588, 0x0a822220, 0x0a822220, 0x08800004, 0x08800004},
2785 +       {0x0000a58c, 0x0f822223, 0x0f822223, 0x0b800200, 0x0b800200},
2786 +       {0x0000a590, 0x14822620, 0x14822620, 0x0f800202, 0x0f800202},
2787 +       {0x0000a594, 0x18822622, 0x18822622, 0x11800400, 0x11800400},
2788 +       {0x0000a598, 0x1b822822, 0x1b822822, 0x15800402, 0x15800402},
2789 +       {0x0000a59c, 0x20822842, 0x20822842, 0x19800404, 0x19800404},
2790 +       {0x0000a5a0, 0x22822c41, 0x22822c41, 0x1b800603, 0x1b800603},
2791 +       {0x0000a5a4, 0x28823042, 0x28823042, 0x1f800a02, 0x1f800a02},
2792 +       {0x0000a5a8, 0x2c823044, 0x2c823044, 0x23800a04, 0x23800a04},
2793 +       {0x0000a5ac, 0x2f823644, 0x2f823644, 0x26800a20, 0x26800a20},
2794 +       {0x0000a5b0, 0x34825643, 0x34825643, 0x2a800e20, 0x2a800e20},
2795 +       {0x0000a5b4, 0x38825a44, 0x38825a44, 0x2e800e22, 0x2e800e22},
2796 +       {0x0000a5b8, 0x3b825e45, 0x3b825e45, 0x31800e24, 0x31800e24},
2797 +       {0x0000a5bc, 0x41825e4a, 0x41825e4a, 0x34801640, 0x34801640},
2798 +       {0x0000a5c0, 0x48825e6c, 0x48825e6c, 0x38801660, 0x38801660},
2799 +       {0x0000a5c4, 0x4e825e8e, 0x4e825e8e, 0x3b801861, 0x3b801861},
2800 +       {0x0000a5c8, 0x53825eb2, 0x53825eb2, 0x3e801a81, 0x3e801a81},
2801 +       {0x0000a5cc, 0x59825eb5, 0x59825eb5, 0x42801a83, 0x42801a83},
2802 +       {0x0000a5d0, 0x5f825ef6, 0x5f825ef6, 0x44801c84, 0x44801c84},
2803 +       {0x0000a5d4, 0x62825f56, 0x62825f56, 0x48801ce3, 0x48801ce3},
2804 +       {0x0000a5d8, 0x66827f56, 0x66827f56, 0x4c801ce5, 0x4c801ce5},
2805 +       {0x0000a5dc, 0x6a829f56, 0x6a829f56, 0x50801ce9, 0x50801ce9},
2806 +       {0x0000a5e0, 0x70849f56, 0x70849f56, 0x54801ceb, 0x54801ceb},
2807 +       {0x0000a5e4, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
2808 +       {0x0000a5e8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
2809 +       {0x0000a5ec, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
2810 +       {0x0000a5f0, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
2811 +       {0x0000a5f4, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
2812 +       {0x0000a5f8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
2813 +       {0x0000a5fc, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
2814 +       {0x00016044, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4},
2815 +       {0x00016048, 0x8e480001, 0x8e480001, 0x8e480001, 0x8e480001},
2816 +       {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
2817 +       {0x00016444, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4},
2818 +       {0x00016448, 0x8e480001, 0x8e480001, 0x8e480001, 0x8e480001},
2819 +       {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
2820 +       {0x00016844, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4},
2821 +       {0x00016848, 0x8e480001, 0x8e480001, 0x8e480001, 0x8e480001},
2822 +       {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
2823 +};
2824 +
2825 +static const u32 ar9300Common_rx_gain_table_2p2[][2] = {
2826 +       /* Addr      allmodes  */
2827 +       {0x0000a000, 0x00010000},
2828 +       {0x0000a004, 0x00030002},
2829 +       {0x0000a008, 0x00050004},
2830 +       {0x0000a00c, 0x00810080},
2831 +       {0x0000a010, 0x00830082},
2832 +       {0x0000a014, 0x01810180},
2833 +       {0x0000a018, 0x01830182},
2834 +       {0x0000a01c, 0x01850184},
2835 +       {0x0000a020, 0x01890188},
2836 +       {0x0000a024, 0x018b018a},
2837 +       {0x0000a028, 0x018d018c},
2838 +       {0x0000a02c, 0x01910190},
2839 +       {0x0000a030, 0x01930192},
2840 +       {0x0000a034, 0x01950194},
2841 +       {0x0000a038, 0x038a0196},
2842 +       {0x0000a03c, 0x038c038b},
2843 +       {0x0000a040, 0x0390038d},
2844 +       {0x0000a044, 0x03920391},
2845 +       {0x0000a048, 0x03940393},
2846 +       {0x0000a04c, 0x03960395},
2847 +       {0x0000a050, 0x00000000},
2848 +       {0x0000a054, 0x00000000},
2849 +       {0x0000a058, 0x00000000},
2850 +       {0x0000a05c, 0x00000000},
2851 +       {0x0000a060, 0x00000000},
2852 +       {0x0000a064, 0x00000000},
2853 +       {0x0000a068, 0x00000000},
2854 +       {0x0000a06c, 0x00000000},
2855 +       {0x0000a070, 0x00000000},
2856 +       {0x0000a074, 0x00000000},
2857 +       {0x0000a078, 0x00000000},
2858 +       {0x0000a07c, 0x00000000},
2859 +       {0x0000a080, 0x22222229},
2860 +       {0x0000a084, 0x1d1d1d1d},
2861 +       {0x0000a088, 0x1d1d1d1d},
2862 +       {0x0000a08c, 0x1d1d1d1d},
2863 +       {0x0000a090, 0x171d1d1d},
2864 +       {0x0000a094, 0x11111717},
2865 +       {0x0000a098, 0x00030311},
2866 +       {0x0000a09c, 0x00000000},
2867 +       {0x0000a0a0, 0x00000000},
2868 +       {0x0000a0a4, 0x00000000},
2869 +       {0x0000a0a8, 0x00000000},
2870 +       {0x0000a0ac, 0x00000000},
2871 +       {0x0000a0b0, 0x00000000},
2872 +       {0x0000a0b4, 0x00000000},
2873 +       {0x0000a0b8, 0x00000000},
2874 +       {0x0000a0bc, 0x00000000},
2875 +       {0x0000a0c0, 0x001f0000},
2876 +       {0x0000a0c4, 0x01000101},
2877 +       {0x0000a0c8, 0x011e011f},
2878 +       {0x0000a0cc, 0x011c011d},
2879 +       {0x0000a0d0, 0x02030204},
2880 +       {0x0000a0d4, 0x02010202},
2881 +       {0x0000a0d8, 0x021f0200},
2882 +       {0x0000a0dc, 0x0302021e},
2883 +       {0x0000a0e0, 0x03000301},
2884 +       {0x0000a0e4, 0x031e031f},
2885 +       {0x0000a0e8, 0x0402031d},
2886 +       {0x0000a0ec, 0x04000401},
2887 +       {0x0000a0f0, 0x041e041f},
2888 +       {0x0000a0f4, 0x0502041d},
2889 +       {0x0000a0f8, 0x05000501},
2890 +       {0x0000a0fc, 0x051e051f},
2891 +       {0x0000a100, 0x06010602},
2892 +       {0x0000a104, 0x061f0600},
2893 +       {0x0000a108, 0x061d061e},
2894 +       {0x0000a10c, 0x07020703},
2895 +       {0x0000a110, 0x07000701},
2896 +       {0x0000a114, 0x00000000},
2897 +       {0x0000a118, 0x00000000},
2898 +       {0x0000a11c, 0x00000000},
2899 +       {0x0000a120, 0x00000000},
2900 +       {0x0000a124, 0x00000000},
2901 +       {0x0000a128, 0x00000000},
2902 +       {0x0000a12c, 0x00000000},
2903 +       {0x0000a130, 0x00000000},
2904 +       {0x0000a134, 0x00000000},
2905 +       {0x0000a138, 0x00000000},
2906 +       {0x0000a13c, 0x00000000},
2907 +       {0x0000a140, 0x001f0000},
2908 +       {0x0000a144, 0x01000101},
2909 +       {0x0000a148, 0x011e011f},
2910 +       {0x0000a14c, 0x011c011d},
2911 +       {0x0000a150, 0x02030204},
2912 +       {0x0000a154, 0x02010202},
2913 +       {0x0000a158, 0x021f0200},
2914 +       {0x0000a15c, 0x0302021e},
2915 +       {0x0000a160, 0x03000301},
2916 +       {0x0000a164, 0x031e031f},
2917 +       {0x0000a168, 0x0402031d},
2918 +       {0x0000a16c, 0x04000401},
2919 +       {0x0000a170, 0x041e041f},
2920 +       {0x0000a174, 0x0502041d},
2921 +       {0x0000a178, 0x05000501},
2922 +       {0x0000a17c, 0x051e051f},
2923 +       {0x0000a180, 0x06010602},
2924 +       {0x0000a184, 0x061f0600},
2925 +       {0x0000a188, 0x061d061e},
2926 +       {0x0000a18c, 0x07020703},
2927 +       {0x0000a190, 0x07000701},
2928 +       {0x0000a194, 0x00000000},
2929 +       {0x0000a198, 0x00000000},
2930 +       {0x0000a19c, 0x00000000},
2931 +       {0x0000a1a0, 0x00000000},
2932 +       {0x0000a1a4, 0x00000000},
2933 +       {0x0000a1a8, 0x00000000},
2934 +       {0x0000a1ac, 0x00000000},
2935 +       {0x0000a1b0, 0x00000000},
2936 +       {0x0000a1b4, 0x00000000},
2937 +       {0x0000a1b8, 0x00000000},
2938 +       {0x0000a1bc, 0x00000000},
2939 +       {0x0000a1c0, 0x00000000},
2940 +       {0x0000a1c4, 0x00000000},
2941 +       {0x0000a1c8, 0x00000000},
2942 +       {0x0000a1cc, 0x00000000},
2943 +       {0x0000a1d0, 0x00000000},
2944 +       {0x0000a1d4, 0x00000000},
2945 +       {0x0000a1d8, 0x00000000},
2946 +       {0x0000a1dc, 0x00000000},
2947 +       {0x0000a1e0, 0x00000000},
2948 +       {0x0000a1e4, 0x00000000},
2949 +       {0x0000a1e8, 0x00000000},
2950 +       {0x0000a1ec, 0x00000000},
2951 +       {0x0000a1f0, 0x00000396},
2952 +       {0x0000a1f4, 0x00000396},
2953 +       {0x0000a1f8, 0x00000396},
2954 +       {0x0000a1fc, 0x00000196},
2955 +       {0x0000b000, 0x00010000},
2956 +       {0x0000b004, 0x00030002},
2957 +       {0x0000b008, 0x00050004},
2958 +       {0x0000b00c, 0x00810080},
2959 +       {0x0000b010, 0x00830082},
2960 +       {0x0000b014, 0x01810180},
2961 +       {0x0000b018, 0x01830182},
2962 +       {0x0000b01c, 0x01850184},
2963 +       {0x0000b020, 0x02810280},
2964 +       {0x0000b024, 0x02830282},
2965 +       {0x0000b028, 0x02850284},
2966 +       {0x0000b02c, 0x02890288},
2967 +       {0x0000b030, 0x028b028a},
2968 +       {0x0000b034, 0x0388028c},
2969 +       {0x0000b038, 0x038a0389},
2970 +       {0x0000b03c, 0x038c038b},
2971 +       {0x0000b040, 0x0390038d},
2972 +       {0x0000b044, 0x03920391},
2973 +       {0x0000b048, 0x03940393},
2974 +       {0x0000b04c, 0x03960395},
2975 +       {0x0000b050, 0x00000000},
2976 +       {0x0000b054, 0x00000000},
2977 +       {0x0000b058, 0x00000000},
2978 +       {0x0000b05c, 0x00000000},
2979 +       {0x0000b060, 0x00000000},
2980 +       {0x0000b064, 0x00000000},
2981 +       {0x0000b068, 0x00000000},
2982 +       {0x0000b06c, 0x00000000},
2983 +       {0x0000b070, 0x00000000},
2984 +       {0x0000b074, 0x00000000},
2985 +       {0x0000b078, 0x00000000},
2986 +       {0x0000b07c, 0x00000000},
2987 +       {0x0000b080, 0x32323232},
2988 +       {0x0000b084, 0x2f2f3232},
2989 +       {0x0000b088, 0x23282a2d},
2990 +       {0x0000b08c, 0x1c1e2123},
2991 +       {0x0000b090, 0x14171919},
2992 +       {0x0000b094, 0x0e0e1214},
2993 +       {0x0000b098, 0x03050707},
2994 +       {0x0000b09c, 0x00030303},
2995 +       {0x0000b0a0, 0x00000000},
2996 +       {0x0000b0a4, 0x00000000},
2997 +       {0x0000b0a8, 0x00000000},
2998 +       {0x0000b0ac, 0x00000000},
2999 +       {0x0000b0b0, 0x00000000},
3000 +       {0x0000b0b4, 0x00000000},
3001 +       {0x0000b0b8, 0x00000000},
3002 +       {0x0000b0bc, 0x00000000},
3003 +       {0x0000b0c0, 0x003f0020},
3004 +       {0x0000b0c4, 0x00400041},
3005 +       {0x0000b0c8, 0x0140005f},
3006 +       {0x0000b0cc, 0x0160015f},
3007 +       {0x0000b0d0, 0x017e017f},
3008 +       {0x0000b0d4, 0x02410242},
3009 +       {0x0000b0d8, 0x025f0240},
3010 +       {0x0000b0dc, 0x027f0260},
3011 +       {0x0000b0e0, 0x0341027e},
3012 +       {0x0000b0e4, 0x035f0340},
3013 +       {0x0000b0e8, 0x037f0360},
3014 +       {0x0000b0ec, 0x04400441},
3015 +       {0x0000b0f0, 0x0460045f},
3016 +       {0x0000b0f4, 0x0541047f},
3017 +       {0x0000b0f8, 0x055f0540},
3018 +       {0x0000b0fc, 0x057f0560},
3019 +       {0x0000b100, 0x06400641},
3020 +       {0x0000b104, 0x0660065f},
3021 +       {0x0000b108, 0x067e067f},
3022 +       {0x0000b10c, 0x07410742},
3023 +       {0x0000b110, 0x075f0740},
3024 +       {0x0000b114, 0x077f0760},
3025 +       {0x0000b118, 0x07800781},
3026 +       {0x0000b11c, 0x07a0079f},
3027 +       {0x0000b120, 0x07c107bf},
3028 +       {0x0000b124, 0x000007c0},
3029 +       {0x0000b128, 0x00000000},
3030 +       {0x0000b12c, 0x00000000},
3031 +       {0x0000b130, 0x00000000},
3032 +       {0x0000b134, 0x00000000},
3033 +       {0x0000b138, 0x00000000},
3034 +       {0x0000b13c, 0x00000000},
3035 +       {0x0000b140, 0x003f0020},
3036 +       {0x0000b144, 0x00400041},
3037 +       {0x0000b148, 0x0140005f},
3038 +       {0x0000b14c, 0x0160015f},
3039 +       {0x0000b150, 0x017e017f},
3040 +       {0x0000b154, 0x02410242},
3041 +       {0x0000b158, 0x025f0240},
3042 +       {0x0000b15c, 0x027f0260},
3043 +       {0x0000b160, 0x0341027e},
3044 +       {0x0000b164, 0x035f0340},
3045 +       {0x0000b168, 0x037f0360},
3046 +       {0x0000b16c, 0x04400441},
3047 +       {0x0000b170, 0x0460045f},
3048 +       {0x0000b174, 0x0541047f},
3049 +       {0x0000b178, 0x055f0540},
3050 +       {0x0000b17c, 0x057f0560},
3051 +       {0x0000b180, 0x06400641},
3052 +       {0x0000b184, 0x0660065f},
3053 +       {0x0000b188, 0x067e067f},
3054 +       {0x0000b18c, 0x07410742},
3055 +       {0x0000b190, 0x075f0740},
3056 +       {0x0000b194, 0x077f0760},
3057 +       {0x0000b198, 0x07800781},
3058 +       {0x0000b19c, 0x07a0079f},
3059 +       {0x0000b1a0, 0x07c107bf},
3060 +       {0x0000b1a4, 0x000007c0},
3061 +       {0x0000b1a8, 0x00000000},
3062 +       {0x0000b1ac, 0x00000000},
3063 +       {0x0000b1b0, 0x00000000},
3064 +       {0x0000b1b4, 0x00000000},
3065 +       {0x0000b1b8, 0x00000000},
3066 +       {0x0000b1bc, 0x00000000},
3067 +       {0x0000b1c0, 0x00000000},
3068 +       {0x0000b1c4, 0x00000000},
3069 +       {0x0000b1c8, 0x00000000},
3070 +       {0x0000b1cc, 0x00000000},
3071 +       {0x0000b1d0, 0x00000000},
3072 +       {0x0000b1d4, 0x00000000},
3073 +       {0x0000b1d8, 0x00000000},
3074 +       {0x0000b1dc, 0x00000000},
3075 +       {0x0000b1e0, 0x00000000},
3076 +       {0x0000b1e4, 0x00000000},
3077 +       {0x0000b1e8, 0x00000000},
3078 +       {0x0000b1ec, 0x00000000},
3079 +       {0x0000b1f0, 0x00000396},
3080 +       {0x0000b1f4, 0x00000396},
3081 +       {0x0000b1f8, 0x00000396},
3082 +       {0x0000b1fc, 0x00000196},
3083 +};
3084 +
3085 +static const u32 ar9300Modes_low_ob_db_tx_gain_table_2p2[][5] = {
3086 +       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
3087 +       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
3088 +       {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
3089 +       {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002},
3090 +       {0x0000a508, 0x0a000020, 0x0a000020, 0x08000004, 0x08000004},
3091 +       {0x0000a50c, 0x10000023, 0x10000023, 0x0b000200, 0x0b000200},
3092 +       {0x0000a510, 0x16000220, 0x16000220, 0x0f000202, 0x0f000202},
3093 +       {0x0000a514, 0x1c000223, 0x1c000223, 0x12000400, 0x12000400},
3094 +       {0x0000a518, 0x21002220, 0x21002220, 0x16000402, 0x16000402},
3095 +       {0x0000a51c, 0x27002223, 0x27002223, 0x19000404, 0x19000404},
3096 +       {0x0000a520, 0x2b022220, 0x2b022220, 0x1c000603, 0x1c000603},
3097 +       {0x0000a524, 0x2f022222, 0x2f022222, 0x21000a02, 0x21000a02},
3098 +       {0x0000a528, 0x34022225, 0x34022225, 0x25000a04, 0x25000a04},
3099 +       {0x0000a52c, 0x3a02222a, 0x3a02222a, 0x28000a20, 0x28000a20},
3100 +       {0x0000a530, 0x3e02222c, 0x3e02222c, 0x2c000e20, 0x2c000e20},
3101 +       {0x0000a534, 0x4202242a, 0x4202242a, 0x30000e22, 0x30000e22},
3102 +       {0x0000a538, 0x4702244a, 0x4702244a, 0x34000e24, 0x34000e24},
3103 +       {0x0000a53c, 0x4b02244c, 0x4b02244c, 0x38001640, 0x38001640},
3104 +       {0x0000a540, 0x4e02246c, 0x4e02246c, 0x3c001660, 0x3c001660},
3105 +       {0x0000a544, 0x5302266c, 0x5302266c, 0x3f001861, 0x3f001861},
3106 +       {0x0000a548, 0x5702286c, 0x5702286c, 0x43001a81, 0x43001a81},
3107 +       {0x0000a54c, 0x5c02486b, 0x5c02486b, 0x47001a83, 0x47001a83},
3108 +       {0x0000a550, 0x61024a6c, 0x61024a6c, 0x4a001c84, 0x4a001c84},
3109 +       {0x0000a554, 0x66026a6c, 0x66026a6c, 0x4e001ce3, 0x4e001ce3},
3110 +       {0x0000a558, 0x6b026e6c, 0x6b026e6c, 0x52001ce5, 0x52001ce5},
3111 +       {0x0000a55c, 0x7002708c, 0x7002708c, 0x56001ce9, 0x56001ce9},
3112 +       {0x0000a560, 0x7302b08a, 0x7302b08a, 0x5a001ceb, 0x5a001ceb},
3113 +       {0x0000a564, 0x7702b08c, 0x7702b08c, 0x5d001eec, 0x5d001eec},
3114 +       {0x0000a568, 0x7702b08c, 0x7702b08c, 0x5d001eec, 0x5d001eec},
3115 +       {0x0000a56c, 0x7702b08c, 0x7702b08c, 0x5d001eec, 0x5d001eec},
3116 +       {0x0000a570, 0x7702b08c, 0x7702b08c, 0x5d001eec, 0x5d001eec},
3117 +       {0x0000a574, 0x7702b08c, 0x7702b08c, 0x5d001eec, 0x5d001eec},
3118 +       {0x0000a578, 0x7702b08c, 0x7702b08c, 0x5d001eec, 0x5d001eec},
3119 +       {0x0000a57c, 0x7702b08c, 0x7702b08c, 0x5d001eec, 0x5d001eec},
3120 +       {0x0000a580, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
3121 +       {0x0000a584, 0x06800003, 0x06800003, 0x04800002, 0x04800002},
3122 +       {0x0000a588, 0x0a800020, 0x0a800020, 0x08800004, 0x08800004},
3123 +       {0x0000a58c, 0x10800023, 0x10800023, 0x0b800200, 0x0b800200},
3124 +       {0x0000a590, 0x16800220, 0x16800220, 0x0f800202, 0x0f800202},
3125 +       {0x0000a594, 0x1c800223, 0x1c800223, 0x12800400, 0x12800400},
3126 +       {0x0000a598, 0x21802220, 0x21802220, 0x16800402, 0x16800402},
3127 +       {0x0000a59c, 0x27802223, 0x27802223, 0x19800404, 0x19800404},
3128 +       {0x0000a5a0, 0x2b822220, 0x2b822220, 0x1c800603, 0x1c800603},
3129 +       {0x0000a5a4, 0x2f822222, 0x2f822222, 0x21800a02, 0x21800a02},
3130 +       {0x0000a5a8, 0x34822225, 0x34822225, 0x25800a04, 0x25800a04},
3131 +       {0x0000a5ac, 0x3a82222a, 0x3a82222a, 0x28800a20, 0x28800a20},
3132 +       {0x0000a5b0, 0x3e82222c, 0x3e82222c, 0x2c800e20, 0x2c800e20},
3133 +       {0x0000a5b4, 0x4282242a, 0x4282242a, 0x30800e22, 0x30800e22},
3134 +       {0x0000a5b8, 0x4782244a, 0x4782244a, 0x34800e24, 0x34800e24},
3135 +       {0x0000a5bc, 0x4b82244c, 0x4b82244c, 0x38801640, 0x38801640},
3136 +       {0x0000a5c0, 0x4e82246c, 0x4e82246c, 0x3c801660, 0x3c801660},
3137 +       {0x0000a5c4, 0x5382266c, 0x5382266c, 0x3f801861, 0x3f801861},
3138 +       {0x0000a5c8, 0x5782286c, 0x5782286c, 0x43801a81, 0x43801a81},
3139 +       {0x0000a5cc, 0x5c82486b, 0x5c82486b, 0x47801a83, 0x47801a83},
3140 +       {0x0000a5d0, 0x61824a6c, 0x61824a6c, 0x4a801c84, 0x4a801c84},
3141 +       {0x0000a5d4, 0x66826a6c, 0x66826a6c, 0x4e801ce3, 0x4e801ce3},
3142 +       {0x0000a5d8, 0x6b826e6c, 0x6b826e6c, 0x52801ce5, 0x52801ce5},
3143 +       {0x0000a5dc, 0x7082708c, 0x7082708c, 0x56801ce9, 0x56801ce9},
3144 +       {0x0000a5e0, 0x7382b08a, 0x7382b08a, 0x5a801ceb, 0x5a801ceb},
3145 +       {0x0000a5e4, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
3146 +       {0x0000a5e8, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
3147 +       {0x0000a5ec, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
3148 +       {0x0000a5f0, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
3149 +       {0x0000a5f4, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
3150 +       {0x0000a5f8, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
3151 +       {0x0000a5fc, 0x7782b08c, 0x7782b08c, 0x5d801eec, 0x5d801eec},
3152 +       {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
3153 +       {0x00016048, 0x66480001, 0x66480001, 0x66480001, 0x66480001},
3154 +       {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
3155 +       {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
3156 +       {0x00016448, 0x66480001, 0x66480001, 0x66480001, 0x66480001},
3157 +       {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
3158 +       {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
3159 +       {0x00016848, 0x66480001, 0x66480001, 0x66480001, 0x66480001},
3160 +       {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
3161 +};
3162 +
3163 +static const u32 ar9300_2p2_mac_core[][2] = {
3164 +       /* Addr      allmodes  */
3165 +       {0x00000008, 0x00000000},
3166 +       {0x00000030, 0x00020085},
3167 +       {0x00000034, 0x00000005},
3168 +       {0x00000040, 0x00000000},
3169 +       {0x00000044, 0x00000000},
3170 +       {0x00000048, 0x00000008},
3171 +       {0x0000004c, 0x00000010},
3172 +       {0x00000050, 0x00000000},
3173 +       {0x00001040, 0x002ffc0f},
3174 +       {0x00001044, 0x002ffc0f},
3175 +       {0x00001048, 0x002ffc0f},
3176 +       {0x0000104c, 0x002ffc0f},
3177 +       {0x00001050, 0x002ffc0f},
3178 +       {0x00001054, 0x002ffc0f},
3179 +       {0x00001058, 0x002ffc0f},
3180 +       {0x0000105c, 0x002ffc0f},
3181 +       {0x00001060, 0x002ffc0f},
3182 +       {0x00001064, 0x002ffc0f},
3183 +       {0x000010f0, 0x00000100},
3184 +       {0x00001270, 0x00000000},
3185 +       {0x000012b0, 0x00000000},
3186 +       {0x000012f0, 0x00000000},
3187 +       {0x0000143c, 0x00000000},
3188 +       {0x0000147c, 0x00000000},
3189 +       {0x00008000, 0x00000000},
3190 +       {0x00008004, 0x00000000},
3191 +       {0x00008008, 0x00000000},
3192 +       {0x0000800c, 0x00000000},
3193 +       {0x00008018, 0x00000000},
3194 +       {0x00008020, 0x00000000},
3195 +       {0x00008038, 0x00000000},
3196 +       {0x0000803c, 0x00000000},
3197 +       {0x00008040, 0x00000000},
3198 +       {0x00008044, 0x00000000},
3199 +       {0x00008048, 0x00000000},
3200 +       {0x0000804c, 0xffffffff},
3201 +       {0x00008054, 0x00000000},
3202 +       {0x00008058, 0x00000000},
3203 +       {0x0000805c, 0x000fc78f},
3204 +       {0x00008060, 0x0000000f},
3205 +       {0x00008064, 0x00000000},
3206 +       {0x00008070, 0x00000310},
3207 +       {0x00008074, 0x00000020},
3208 +       {0x00008078, 0x00000000},
3209 +       {0x0000809c, 0x0000000f},
3210 +       {0x000080a0, 0x00000000},
3211 +       {0x000080a4, 0x02ff0000},
3212 +       {0x000080a8, 0x0e070605},
3213 +       {0x000080ac, 0x0000000d},
3214 +       {0x000080b0, 0x00000000},
3215 +       {0x000080b4, 0x00000000},
3216 +       {0x000080b8, 0x00000000},
3217 +       {0x000080bc, 0x00000000},
3218 +       {0x000080c0, 0x2a800000},
3219 +       {0x000080c4, 0x06900168},
3220 +       {0x000080c8, 0x13881c20},
3221 +       {0x000080cc, 0x01f40000},
3222 +       {0x000080d0, 0x00252500},
3223 +       {0x000080d4, 0x00a00000},
3224 +       {0x000080d8, 0x00400000},
3225 +       {0x000080dc, 0x00000000},
3226 +       {0x000080e0, 0xffffffff},
3227 +       {0x000080e4, 0x0000ffff},
3228 +       {0x000080e8, 0x3f3f3f3f},
3229 +       {0x000080ec, 0x00000000},
3230 +       {0x000080f0, 0x00000000},
3231 +       {0x000080f4, 0x00000000},
3232 +       {0x000080fc, 0x00020000},
3233 +       {0x00008100, 0x00000000},
3234 +       {0x00008108, 0x00000052},
3235 +       {0x0000810c, 0x00000000},
3236 +       {0x00008110, 0x00000000},
3237 +       {0x00008114, 0x000007ff},
3238 +       {0x00008118, 0x000000aa},
3239 +       {0x0000811c, 0x00003210},
3240 +       {0x00008124, 0x00000000},
3241 +       {0x00008128, 0x00000000},
3242 +       {0x0000812c, 0x00000000},
3243 +       {0x00008130, 0x00000000},
3244 +       {0x00008134, 0x00000000},
3245 +       {0x00008138, 0x00000000},
3246 +       {0x0000813c, 0x0000ffff},
3247 +       {0x00008144, 0xffffffff},
3248 +       {0x00008168, 0x00000000},
3249 +       {0x0000816c, 0x00000000},
3250 +       {0x00008170, 0x18486200},
3251 +       {0x00008174, 0x33332210},
3252 +       {0x00008178, 0x00000000},
3253 +       {0x0000817c, 0x00020000},
3254 +       {0x000081c0, 0x00000000},
3255 +       {0x000081c4, 0x33332210},
3256 +       {0x000081c8, 0x00000000},
3257 +       {0x000081cc, 0x00000000},
3258 +       {0x000081d4, 0x00000000},
3259 +       {0x000081ec, 0x00000000},
3260 +       {0x000081f0, 0x00000000},
3261 +       {0x000081f4, 0x00000000},
3262 +       {0x000081f8, 0x00000000},
3263 +       {0x000081fc, 0x00000000},
3264 +       {0x00008240, 0x00100000},
3265 +       {0x00008244, 0x0010f424},
3266 +       {0x00008248, 0x00000800},
3267 +       {0x0000824c, 0x0001e848},
3268 +       {0x00008250, 0x00000000},
3269 +       {0x00008254, 0x00000000},
3270 +       {0x00008258, 0x00000000},
3271 +       {0x0000825c, 0x40000000},
3272 +       {0x00008260, 0x00080922},
3273 +       {0x00008264, 0x9bc00010},
3274 +       {0x00008268, 0xffffffff},
3275 +       {0x0000826c, 0x0000ffff},
3276 +       {0x00008270, 0x00000000},
3277 +       {0x00008274, 0x40000000},
3278 +       {0x00008278, 0x003e4180},
3279 +       {0x0000827c, 0x00000004},
3280 +       {0x00008284, 0x0000002c},
3281 +       {0x00008288, 0x0000002c},
3282 +       {0x0000828c, 0x000000ff},
3283 +       {0x00008294, 0x00000000},
3284 +       {0x00008298, 0x00000000},
3285 +       {0x0000829c, 0x00000000},
3286 +       {0x00008300, 0x00000140},
3287 +       {0x00008314, 0x00000000},
3288 +       {0x0000831c, 0x0000010d},
3289 +       {0x00008328, 0x00000000},
3290 +       {0x0000832c, 0x00000007},
3291 +       {0x00008330, 0x00000302},
3292 +       {0x00008334, 0x00000700},
3293 +       {0x00008338, 0x00ff0000},
3294 +       {0x0000833c, 0x02400000},
3295 +       {0x00008340, 0x000107ff},
3296 +       {0x00008344, 0xaa48105b},
3297 +       {0x00008348, 0x008f0000},
3298 +       {0x0000835c, 0x00000000},
3299 +       {0x00008360, 0xffffffff},
3300 +       {0x00008364, 0xffffffff},
3301 +       {0x00008368, 0x00000000},
3302 +       {0x00008370, 0x00000000},
3303 +       {0x00008374, 0x000000ff},
3304 +       {0x00008378, 0x00000000},
3305 +       {0x0000837c, 0x00000000},
3306 +       {0x00008380, 0xffffffff},
3307 +       {0x00008384, 0xffffffff},
3308 +       {0x00008390, 0xffffffff},
3309 +       {0x00008394, 0xffffffff},
3310 +       {0x00008398, 0x00000000},
3311 +       {0x0000839c, 0x00000000},
3312 +       {0x000083a0, 0x00000000},
3313 +       {0x000083a4, 0x0000fa14},
3314 +       {0x000083a8, 0x000f0c00},
3315 +       {0x000083ac, 0x33332210},
3316 +       {0x000083b0, 0x33332210},
3317 +       {0x000083b4, 0x33332210},
3318 +       {0x000083b8, 0x33332210},
3319 +       {0x000083bc, 0x00000000},
3320 +       {0x000083c0, 0x00000000},
3321 +       {0x000083c4, 0x00000000},
3322 +       {0x000083c8, 0x00000000},
3323 +       {0x000083cc, 0x00000200},
3324 +       {0x000083d0, 0x000301ff},
3325 +};
3326 +
3327 +static const u32 ar9300Common_wo_xlna_rx_gain_table_2p2[][2] = {
3328 +       /* Addr      allmodes  */
3329 +       {0x0000a000, 0x00010000},
3330 +       {0x0000a004, 0x00030002},
3331 +       {0x0000a008, 0x00050004},
3332 +       {0x0000a00c, 0x00810080},
3333 +       {0x0000a010, 0x00830082},
3334 +       {0x0000a014, 0x01810180},
3335 +       {0x0000a018, 0x01830182},
3336 +       {0x0000a01c, 0x01850184},
3337 +       {0x0000a020, 0x01890188},
3338 +       {0x0000a024, 0x018b018a},
3339 +       {0x0000a028, 0x018d018c},
3340 +       {0x0000a02c, 0x03820190},
3341 +       {0x0000a030, 0x03840383},
3342 +       {0x0000a034, 0x03880385},
3343 +       {0x0000a038, 0x038a0389},
3344 +       {0x0000a03c, 0x038c038b},
3345 +       {0x0000a040, 0x0390038d},
3346 +       {0x0000a044, 0x03920391},
3347 +       {0x0000a048, 0x03940393},
3348 +       {0x0000a04c, 0x03960395},
3349 +       {0x0000a050, 0x00000000},
3350 +       {0x0000a054, 0x00000000},
3351 +       {0x0000a058, 0x00000000},
3352 +       {0x0000a05c, 0x00000000},
3353 +       {0x0000a060, 0x00000000},
3354 +       {0x0000a064, 0x00000000},
3355 +       {0x0000a068, 0x00000000},
3356 +       {0x0000a06c, 0x00000000},
3357 +       {0x0000a070, 0x00000000},
3358 +       {0x0000a074, 0x00000000},
3359 +       {0x0000a078, 0x00000000},
3360 +       {0x0000a07c, 0x00000000},
3361 +       {0x0000a080, 0x29292929},
3362 +       {0x0000a084, 0x29292929},
3363 +       {0x0000a088, 0x29292929},
3364 +       {0x0000a08c, 0x29292929},
3365 +       {0x0000a090, 0x22292929},
3366 +       {0x0000a094, 0x1d1d2222},
3367 +       {0x0000a098, 0x0c111117},
3368 +       {0x0000a09c, 0x00030303},
3369 +       {0x0000a0a0, 0x00000000},
3370 +       {0x0000a0a4, 0x00000000},
3371 +       {0x0000a0a8, 0x00000000},
3372 +       {0x0000a0ac, 0x00000000},
3373 +       {0x0000a0b0, 0x00000000},
3374 +       {0x0000a0b4, 0x00000000},
3375 +       {0x0000a0b8, 0x00000000},
3376 +       {0x0000a0bc, 0x00000000},
3377 +       {0x0000a0c0, 0x001f0000},
3378 +       {0x0000a0c4, 0x01000101},
3379 +       {0x0000a0c8, 0x011e011f},
3380 +       {0x0000a0cc, 0x011c011d},
3381 +       {0x0000a0d0, 0x02030204},
3382 +       {0x0000a0d4, 0x02010202},
3383 +       {0x0000a0d8, 0x021f0200},
3384 +       {0x0000a0dc, 0x0302021e},
3385 +       {0x0000a0e0, 0x03000301},
3386 +       {0x0000a0e4, 0x031e031f},
3387 +       {0x0000a0e8, 0x0402031d},
3388 +       {0x0000a0ec, 0x04000401},
3389 +       {0x0000a0f0, 0x041e041f},
3390 +       {0x0000a0f4, 0x0502041d},
3391 +       {0x0000a0f8, 0x05000501},
3392 +       {0x0000a0fc, 0x051e051f},
3393 +       {0x0000a100, 0x06010602},
3394 +       {0x0000a104, 0x061f0600},
3395 +       {0x0000a108, 0x061d061e},
3396 +       {0x0000a10c, 0x07020703},
3397 +       {0x0000a110, 0x07000701},
3398 +       {0x0000a114, 0x00000000},
3399 +       {0x0000a118, 0x00000000},
3400 +       {0x0000a11c, 0x00000000},
3401 +       {0x0000a120, 0x00000000},
3402 +       {0x0000a124, 0x00000000},
3403 +       {0x0000a128, 0x00000000},
3404 +       {0x0000a12c, 0x00000000},
3405 +       {0x0000a130, 0x00000000},
3406 +       {0x0000a134, 0x00000000},
3407 +       {0x0000a138, 0x00000000},
3408 +       {0x0000a13c, 0x00000000},
3409 +       {0x0000a140, 0x001f0000},
3410 +       {0x0000a144, 0x01000101},
3411 +       {0x0000a148, 0x011e011f},
3412 +       {0x0000a14c, 0x011c011d},
3413 +       {0x0000a150, 0x02030204},
3414 +       {0x0000a154, 0x02010202},
3415 +       {0x0000a158, 0x021f0200},
3416 +       {0x0000a15c, 0x0302021e},
3417 +       {0x0000a160, 0x03000301},
3418 +       {0x0000a164, 0x031e031f},
3419 +       {0x0000a168, 0x0402031d},
3420 +       {0x0000a16c, 0x04000401},
3421 +       {0x0000a170, 0x041e041f},
3422 +       {0x0000a174, 0x0502041d},
3423 +       {0x0000a178, 0x05000501},
3424 +       {0x0000a17c, 0x051e051f},
3425 +       {0x0000a180, 0x06010602},
3426 +       {0x0000a184, 0x061f0600},
3427 +       {0x0000a188, 0x061d061e},
3428 +       {0x0000a18c, 0x07020703},
3429 +       {0x0000a190, 0x07000701},
3430 +       {0x0000a194, 0x00000000},
3431 +       {0x0000a198, 0x00000000},
3432 +       {0x0000a19c, 0x00000000},
3433 +       {0x0000a1a0, 0x00000000},
3434 +       {0x0000a1a4, 0x00000000},
3435 +       {0x0000a1a8, 0x00000000},
3436 +       {0x0000a1ac, 0x00000000},
3437 +       {0x0000a1b0, 0x00000000},
3438 +       {0x0000a1b4, 0x00000000},
3439 +       {0x0000a1b8, 0x00000000},
3440 +       {0x0000a1bc, 0x00000000},
3441 +       {0x0000a1c0, 0x00000000},
3442 +       {0x0000a1c4, 0x00000000},
3443 +       {0x0000a1c8, 0x00000000},
3444 +       {0x0000a1cc, 0x00000000},
3445 +       {0x0000a1d0, 0x00000000},
3446 +       {0x0000a1d4, 0x00000000},
3447 +       {0x0000a1d8, 0x00000000},
3448 +       {0x0000a1dc, 0x00000000},
3449 +       {0x0000a1e0, 0x00000000},
3450 +       {0x0000a1e4, 0x00000000},
3451 +       {0x0000a1e8, 0x00000000},
3452 +       {0x0000a1ec, 0x00000000},
3453 +       {0x0000a1f0, 0x00000396},
3454 +       {0x0000a1f4, 0x00000396},
3455 +       {0x0000a1f8, 0x00000396},
3456 +       {0x0000a1fc, 0x00000196},
3457 +       {0x0000b000, 0x00010000},
3458 +       {0x0000b004, 0x00030002},
3459 +       {0x0000b008, 0x00050004},
3460 +       {0x0000b00c, 0x00810080},
3461 +       {0x0000b010, 0x00830082},
3462 +       {0x0000b014, 0x01810180},
3463 +       {0x0000b018, 0x01830182},
3464 +       {0x0000b01c, 0x01850184},
3465 +       {0x0000b020, 0x02810280},
3466 +       {0x0000b024, 0x02830282},
3467 +       {0x0000b028, 0x02850284},
3468 +       {0x0000b02c, 0x02890288},
3469 +       {0x0000b030, 0x028b028a},
3470 +       {0x0000b034, 0x0388028c},
3471 +       {0x0000b038, 0x038a0389},
3472 +       {0x0000b03c, 0x038c038b},
3473 +       {0x0000b040, 0x0390038d},
3474 +       {0x0000b044, 0x03920391},
3475 +       {0x0000b048, 0x03940393},
3476 +       {0x0000b04c, 0x03960395},
3477 +       {0x0000b050, 0x00000000},
3478 +       {0x0000b054, 0x00000000},
3479 +       {0x0000b058, 0x00000000},
3480 +       {0x0000b05c, 0x00000000},
3481 +       {0x0000b060, 0x00000000},
3482 +       {0x0000b064, 0x00000000},
3483 +       {0x0000b068, 0x00000000},
3484 +       {0x0000b06c, 0x00000000},
3485 +       {0x0000b070, 0x00000000},
3486 +       {0x0000b074, 0x00000000},
3487 +       {0x0000b078, 0x00000000},
3488 +       {0x0000b07c, 0x00000000},
3489 +       {0x0000b080, 0x32323232},
3490 +       {0x0000b084, 0x2f2f3232},
3491 +       {0x0000b088, 0x23282a2d},
3492 +       {0x0000b08c, 0x1c1e2123},
3493 +       {0x0000b090, 0x14171919},
3494 +       {0x0000b094, 0x0e0e1214},
3495 +       {0x0000b098, 0x03050707},
3496 +       {0x0000b09c, 0x00030303},
3497 +       {0x0000b0a0, 0x00000000},
3498 +       {0x0000b0a4, 0x00000000},
3499 +       {0x0000b0a8, 0x00000000},
3500 +       {0x0000b0ac, 0x00000000},
3501 +       {0x0000b0b0, 0x00000000},
3502 +       {0x0000b0b4, 0x00000000},
3503 +       {0x0000b0b8, 0x00000000},
3504 +       {0x0000b0bc, 0x00000000},
3505 +       {0x0000b0c0, 0x003f0020},
3506 +       {0x0000b0c4, 0x00400041},
3507 +       {0x0000b0c8, 0x0140005f},
3508 +       {0x0000b0cc, 0x0160015f},
3509 +       {0x0000b0d0, 0x017e017f},
3510 +       {0x0000b0d4, 0x02410242},
3511 +       {0x0000b0d8, 0x025f0240},
3512 +       {0x0000b0dc, 0x027f0260},
3513 +       {0x0000b0e0, 0x0341027e},
3514 +       {0x0000b0e4, 0x035f0340},
3515 +       {0x0000b0e8, 0x037f0360},
3516 +       {0x0000b0ec, 0x04400441},
3517 +       {0x0000b0f0, 0x0460045f},
3518 +       {0x0000b0f4, 0x0541047f},
3519 +       {0x0000b0f8, 0x055f0540},
3520 +       {0x0000b0fc, 0x057f0560},
3521 +       {0x0000b100, 0x06400641},
3522 +       {0x0000b104, 0x0660065f},
3523 +       {0x0000b108, 0x067e067f},
3524 +       {0x0000b10c, 0x07410742},
3525 +       {0x0000b110, 0x075f0740},
3526 +       {0x0000b114, 0x077f0760},
3527 +       {0x0000b118, 0x07800781},
3528 +       {0x0000b11c, 0x07a0079f},
3529 +       {0x0000b120, 0x07c107bf},
3530 +       {0x0000b124, 0x000007c0},
3531 +       {0x0000b128, 0x00000000},
3532 +       {0x0000b12c, 0x00000000},
3533 +       {0x0000b130, 0x00000000},
3534 +       {0x0000b134, 0x00000000},
3535 +       {0x0000b138, 0x00000000},
3536 +       {0x0000b13c, 0x00000000},
3537 +       {0x0000b140, 0x003f0020},
3538 +       {0x0000b144, 0x00400041},
3539 +       {0x0000b148, 0x0140005f},
3540 +       {0x0000b14c, 0x0160015f},
3541 +       {0x0000b150, 0x017e017f},
3542 +       {0x0000b154, 0x02410242},
3543 +       {0x0000b158, 0x025f0240},
3544 +       {0x0000b15c, 0x027f0260},
3545 +       {0x0000b160, 0x0341027e},
3546 +       {0x0000b164, 0x035f0340},
3547 +       {0x0000b168, 0x037f0360},
3548 +       {0x0000b16c, 0x04400441},
3549 +       {0x0000b170, 0x0460045f},
3550 +       {0x0000b174, 0x0541047f},
3551 +       {0x0000b178, 0x055f0540},
3552 +       {0x0000b17c, 0x057f0560},
3553 +       {0x0000b180, 0x06400641},
3554 +       {0x0000b184, 0x0660065f},
3555 +       {0x0000b188, 0x067e067f},
3556 +       {0x0000b18c, 0x07410742},
3557 +       {0x0000b190, 0x075f0740},
3558 +       {0x0000b194, 0x077f0760},
3559 +       {0x0000b198, 0x07800781},
3560 +       {0x0000b19c, 0x07a0079f},
3561 +       {0x0000b1a0, 0x07c107bf},
3562 +       {0x0000b1a4, 0x000007c0},
3563 +       {0x0000b1a8, 0x00000000},
3564 +       {0x0000b1ac, 0x00000000},
3565 +       {0x0000b1b0, 0x00000000},
3566 +       {0x0000b1b4, 0x00000000},
3567 +       {0x0000b1b8, 0x00000000},
3568 +       {0x0000b1bc, 0x00000000},
3569 +       {0x0000b1c0, 0x00000000},
3570 +       {0x0000b1c4, 0x00000000},
3571 +       {0x0000b1c8, 0x00000000},
3572 +       {0x0000b1cc, 0x00000000},
3573 +       {0x0000b1d0, 0x00000000},
3574 +       {0x0000b1d4, 0x00000000},
3575 +       {0x0000b1d8, 0x00000000},
3576 +       {0x0000b1dc, 0x00000000},
3577 +       {0x0000b1e0, 0x00000000},
3578 +       {0x0000b1e4, 0x00000000},
3579 +       {0x0000b1e8, 0x00000000},
3580 +       {0x0000b1ec, 0x00000000},
3581 +       {0x0000b1f0, 0x00000396},
3582 +       {0x0000b1f4, 0x00000396},
3583 +       {0x0000b1f8, 0x00000396},
3584 +       {0x0000b1fc, 0x00000196},
3585 +};
3586 +
3587 +static const u32 ar9300_2p2_soc_preamble[][2] = {
3588 +       /* Addr      allmodes  */
3589 +       {0x000040a4, 0x00a0c1c9},
3590 +       {0x00007008, 0x00000000},
3591 +       {0x00007020, 0x00000000},
3592 +       {0x00007034, 0x00000002},
3593 +       {0x00007038, 0x000004c2},
3594 +       {0x00007048, 0x00000008},
3595 +};
3596 +
3597 +static const u32 ar9300PciePhy_pll_on_clkreq_disable_L1_2p2[][2] = {
3598 +       /* Addr      allmodes  */
3599 +       {0x00004040, 0x08212e5e},
3600 +       {0x00004040, 0x0008003b},
3601 +       {0x00004044, 0x00000000},
3602 +};
3603 +
3604 +static const u32 ar9300PciePhy_clkreq_enable_L1_2p2[][2] = {
3605 +       /* Addr      allmodes  */
3606 +       {0x00004040, 0x08253e5e},
3607 +       {0x00004040, 0x0008003b},
3608 +       {0x00004044, 0x00000000},
3609 +};
3610 +
3611 +static const u32 ar9300PciePhy_clkreq_disable_L1_2p2[][2] = {
3612 +       /* Addr      allmodes  */
3613 +       {0x00004040, 0x08213e5e},
3614 +       {0x00004040, 0x0008003b},
3615 +       {0x00004044, 0x00000000},
3616 +};
3617 +
3618 +#endif /* INITVALS_9003_2P2_H */
3619 --- a/drivers/net/wireless/ath/ath9k/ar9003_calib.c
3620 +++ b/drivers/net/wireless/ath/ath9k/ar9003_calib.c
3621 @@ -739,6 +739,12 @@ static bool ar9003_hw_init_cal(struct at
3622          */
3623         ar9003_hw_set_chain_masks(ah, 0x7, 0x7);
3624  
3625 +       /* Do Tx IQ Calibration */
3626 +       ar9003_hw_tx_iq_cal(ah);
3627 +       REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS);
3628 +       udelay(5);
3629 +       REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
3630 +
3631         /* Calibrate the AGC */
3632         REG_WRITE(ah, AR_PHY_AGC_CONTROL,
3633                   REG_READ(ah, AR_PHY_AGC_CONTROL) |
3634 @@ -753,10 +759,6 @@ static bool ar9003_hw_init_cal(struct at
3635                 return false;
3636         }
3637  
3638 -       /* Do Tx IQ Calibration */
3639 -       if (ah->config.tx_iq_calibration)
3640 -               ar9003_hw_tx_iq_cal(ah);
3641 -
3642         /* Revert chainmasks to their original values before NF cal */
3643         ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask);
3644  
3645 --- a/drivers/net/wireless/ath/ath9k/ar9003_hw.c
3646 +++ b/drivers/net/wireless/ath/ath9k/ar9003_hw.c
3647 @@ -16,7 +16,8 @@
3648  
3649  #include "hw.h"
3650  #include "ar9003_mac.h"
3651 -#include "ar9003_initvals.h"
3652 +#include "ar9003_2p0_initvals.h"
3653 +#include "ar9003_2p2_initvals.h"
3654  
3655  /* General hardware code for the AR9003 hadware family */
3656  
3657 @@ -31,12 +32,8 @@ static bool ar9003_hw_macversion_support
3658         return false;
3659  }
3660  
3661 -/* AR9003 2.0 - new INI format (pre, core, post arrays per subsystem) */
3662 -/*
3663 - * XXX: move TX/RX gain INI to its own init_mode_gain_regs after
3664 - * ensuring it does not affect hardware bring up
3665 - */
3666 -static void ar9003_hw_init_mode_regs(struct ath_hw *ah)
3667 +/* AR9003 2.0 */
3668 +static void ar9003_2p0_hw_init_mode_regs(struct ath_hw *ah)
3669  {
3670         /* mac */
3671         INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
3672 @@ -106,27 +103,128 @@ static void ar9003_hw_init_mode_regs(str
3673                        3);
3674  }
3675  
3676 +/* AR9003 2.2 */
3677 +static void ar9003_2p2_hw_init_mode_regs(struct ath_hw *ah)
3678 +{
3679 +       /* mac */
3680 +       INIT_INI_ARRAY(&ah->iniMac[ATH_INI_PRE], NULL, 0, 0);
3681 +       INIT_INI_ARRAY(&ah->iniMac[ATH_INI_CORE],
3682 +                      ar9300_2p2_mac_core,
3683 +                      ARRAY_SIZE(ar9300_2p2_mac_core), 2);
3684 +       INIT_INI_ARRAY(&ah->iniMac[ATH_INI_POST],
3685 +                      ar9300_2p2_mac_postamble,
3686 +                      ARRAY_SIZE(ar9300_2p2_mac_postamble), 5);
3687 +
3688 +       /* bb */
3689 +       INIT_INI_ARRAY(&ah->iniBB[ATH_INI_PRE], NULL, 0, 0);
3690 +       INIT_INI_ARRAY(&ah->iniBB[ATH_INI_CORE],
3691 +                      ar9300_2p2_baseband_core,
3692 +                      ARRAY_SIZE(ar9300_2p2_baseband_core), 2);
3693 +       INIT_INI_ARRAY(&ah->iniBB[ATH_INI_POST],
3694 +                      ar9300_2p2_baseband_postamble,
3695 +                      ARRAY_SIZE(ar9300_2p2_baseband_postamble), 5);
3696 +
3697 +       /* radio */
3698 +       INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_PRE], NULL, 0, 0);
3699 +       INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_CORE],
3700 +                      ar9300_2p2_radio_core,
3701 +                      ARRAY_SIZE(ar9300_2p2_radio_core), 2);
3702 +       INIT_INI_ARRAY(&ah->iniRadio[ATH_INI_POST],
3703 +                      ar9300_2p2_radio_postamble,
3704 +                      ARRAY_SIZE(ar9300_2p2_radio_postamble), 5);
3705 +
3706 +       /* soc */
3707 +       INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_PRE],
3708 +                      ar9300_2p2_soc_preamble,
3709 +                      ARRAY_SIZE(ar9300_2p2_soc_preamble), 2);
3710 +       INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_CORE], NULL, 0, 0);
3711 +       INIT_INI_ARRAY(&ah->iniSOC[ATH_INI_POST],
3712 +                      ar9300_2p2_soc_postamble,
3713 +                      ARRAY_SIZE(ar9300_2p2_soc_postamble), 5);
3714 +
3715 +       /* rx/tx gain */
3716 +       INIT_INI_ARRAY(&ah->iniModesRxGain,
3717 +                      ar9300Common_rx_gain_table_2p2,
3718 +                      ARRAY_SIZE(ar9300Common_rx_gain_table_2p2), 2);
3719 +       INIT_INI_ARRAY(&ah->iniModesTxGain,
3720 +                      ar9300Modes_lowest_ob_db_tx_gain_table_2p2,
3721 +                      ARRAY_SIZE(ar9300Modes_lowest_ob_db_tx_gain_table_2p2),
3722 +                      5);
3723 +
3724 +       /* Load PCIE SERDES settings from INI */
3725 +
3726 +       /* Awake Setting */
3727 +
3728 +       INIT_INI_ARRAY(&ah->iniPcieSerdes,
3729 +                      ar9300PciePhy_pll_on_clkreq_disable_L1_2p2,
3730 +                      ARRAY_SIZE(ar9300PciePhy_pll_on_clkreq_disable_L1_2p2),
3731 +                      2);
3732 +
3733 +       /* Sleep Setting */
3734 +
3735 +       INIT_INI_ARRAY(&ah->iniPcieSerdesLowPower,
3736 +                      ar9300PciePhy_clkreq_enable_L1_2p2,
3737 +                      ARRAY_SIZE(ar9300PciePhy_clkreq_enable_L1_2p2),
3738 +                      2);
3739 +
3740 +       /* Fast clock modal settings */
3741 +       INIT_INI_ARRAY(&ah->iniModesAdditional,
3742 +                      ar9300Modes_fast_clock_2p2,
3743 +                      ARRAY_SIZE(ar9300Modes_fast_clock_2p2),
3744 +                      3);
3745 +}
3746 +
3747 +/*
3748 + * The AR9003 family uses a new INI format (pre, core, post
3749 + * arrays per subsystem).
3750 + */
3751 +static void ar9003_hw_init_mode_regs(struct ath_hw *ah)
3752 +{
3753 +       if (AR_SREV_9300_20(ah))
3754 +               ar9003_2p0_hw_init_mode_regs(ah);
3755 +       else
3756 +               ar9003_2p2_hw_init_mode_regs(ah);
3757 +}
3758 +
3759  static void ar9003_tx_gain_table_apply(struct ath_hw *ah)
3760  {
3761         switch (ar9003_hw_get_tx_gain_idx(ah)) {
3762         case 0:
3763         default:
3764 -               INIT_INI_ARRAY(&ah->iniModesTxGain,
3765 -                              ar9300Modes_lowest_ob_db_tx_gain_table_2p0,
3766 -                              ARRAY_SIZE(ar9300Modes_lowest_ob_db_tx_gain_table_2p0),
3767 -                              5);
3768 +               if (AR_SREV_9300_20(ah))
3769 +                       INIT_INI_ARRAY(&ah->iniModesTxGain,
3770 +                                      ar9300Modes_lowest_ob_db_tx_gain_table_2p0,
3771 +                                      ARRAY_SIZE(ar9300Modes_lowest_ob_db_tx_gain_table_2p0),
3772 +                                      5);
3773 +               else
3774 +                       INIT_INI_ARRAY(&ah->iniModesTxGain,
3775 +                                      ar9300Modes_lowest_ob_db_tx_gain_table_2p2,
3776 +                                      ARRAY_SIZE(ar9300Modes_lowest_ob_db_tx_gain_table_2p2),
3777 +                                      5);
3778                 break;
3779         case 1:
3780 -               INIT_INI_ARRAY(&ah->iniModesTxGain,
3781 -                              ar9300Modes_high_ob_db_tx_gain_table_2p0,
3782 -                              ARRAY_SIZE(ar9300Modes_high_ob_db_tx_gain_table_2p0),
3783 -                              5);
3784 +               if (AR_SREV_9300_20(ah))
3785 +                       INIT_INI_ARRAY(&ah->iniModesTxGain,
3786 +                                      ar9300Modes_high_ob_db_tx_gain_table_2p0,
3787 +                                      ARRAY_SIZE(ar9300Modes_high_ob_db_tx_gain_table_2p0),
3788 +                                      5);
3789 +               else
3790 +                       INIT_INI_ARRAY(&ah->iniModesTxGain,
3791 +                                      ar9300Modes_high_ob_db_tx_gain_table_2p2,
3792 +                                      ARRAY_SIZE(ar9300Modes_high_ob_db_tx_gain_table_2p2),
3793 +                                      5);
3794                 break;
3795         case 2:
3796 -               INIT_INI_ARRAY(&ah->iniModesTxGain,
3797 -                              ar9300Modes_low_ob_db_tx_gain_table_2p0,
3798 -                              ARRAY_SIZE(ar9300Modes_low_ob_db_tx_gain_table_2p0),
3799 -                              5);
3800 +               if (AR_SREV_9300_20(ah))
3801 +                       INIT_INI_ARRAY(&ah->iniModesTxGain,
3802 +                                      ar9300Modes_low_ob_db_tx_gain_table_2p0,
3803 +                                      ARRAY_SIZE(ar9300Modes_low_ob_db_tx_gain_table_2p0),
3804 +                                      5);
3805 +               else
3806 +                       INIT_INI_ARRAY(&ah->iniModesTxGain,
3807 +                                      ar9300Modes_low_ob_db_tx_gain_table_2p2,
3808 +                                      ARRAY_SIZE(ar9300Modes_low_ob_db_tx_gain_table_2p2),
3809 +                                      5);
3810                 break;
3811         }
3812  }
3813 @@ -136,15 +234,28 @@ static void ar9003_rx_gain_table_apply(s
3814         switch (ar9003_hw_get_rx_gain_idx(ah)) {
3815         case 0:
3816         default:
3817 -               INIT_INI_ARRAY(&ah->iniModesRxGain, ar9300Common_rx_gain_table_2p0,
3818 -                              ARRAY_SIZE(ar9300Common_rx_gain_table_2p0),
3819 -                              2);
3820 +               if (AR_SREV_9300_20(ah))
3821 +                       INIT_INI_ARRAY(&ah->iniModesRxGain,
3822 +                                      ar9300Common_rx_gain_table_2p0,
3823 +                                      ARRAY_SIZE(ar9300Common_rx_gain_table_2p0),
3824 +                                      2);
3825 +               else
3826 +                       INIT_INI_ARRAY(&ah->iniModesRxGain,
3827 +                                      ar9300Common_rx_gain_table_2p2,
3828 +                                      ARRAY_SIZE(ar9300Common_rx_gain_table_2p2),
3829 +                                      2);
3830                 break;
3831         case 1:
3832 -               INIT_INI_ARRAY(&ah->iniModesRxGain,
3833 -                              ar9300Common_wo_xlna_rx_gain_table_2p0,
3834 -                              ARRAY_SIZE(ar9300Common_wo_xlna_rx_gain_table_2p0),
3835 -                              2);
3836 +               if (AR_SREV_9300_20(ah))
3837 +                       INIT_INI_ARRAY(&ah->iniModesRxGain,
3838 +                                      ar9300Common_wo_xlna_rx_gain_table_2p0,
3839 +                                      ARRAY_SIZE(ar9300Common_wo_xlna_rx_gain_table_2p0),
3840 +                                      2);
3841 +               else
3842 +                       INIT_INI_ARRAY(&ah->iniModesRxGain,
3843 +                                      ar9300Common_wo_xlna_rx_gain_table_2p2,
3844 +                                      ARRAY_SIZE(ar9300Common_wo_xlna_rx_gain_table_2p2),
3845 +                                      2);
3846                 break;
3847         }
3848  }
3849 --- a/drivers/net/wireless/ath/ath9k/ar9003_initvals.h
3850 +++ /dev/null
3851 @@ -1,1784 +0,0 @@
3852 -/*
3853 - * Copyright (c) 2010 Atheros Communications Inc.
3854 - *
3855 - * Permission to use, copy, modify, and/or distribute this software for any
3856 - * purpose with or without fee is hereby granted, provided that the above
3857 - * copyright notice and this permission notice appear in all copies.
3858 - *
3859 - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
3860 - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
3861 - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
3862 - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
3863 - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
3864 - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
3865 - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
3866 - */
3867 -
3868 -#ifndef INITVALS_9003_H
3869 -#define INITVALS_9003_H
3870 -
3871 -/* AR9003 2.0 */
3872 -
3873 -static const u32 ar9300_2p0_radio_postamble[][5] = {
3874 -       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
3875 -       {0x0001609c, 0x0dd08f29, 0x0dd08f29, 0x0b283f31, 0x0b283f31},
3876 -       {0x000160ac, 0xa4653c00, 0xa4653c00, 0x24652800, 0x24652800},
3877 -       {0x000160b0, 0x03284f3e, 0x03284f3e, 0x05d08f20, 0x05d08f20},
3878 -       {0x0001610c, 0x08000000, 0x00000000, 0x00000000, 0x00000000},
3879 -       {0x00016140, 0x10804008, 0x10804008, 0x50804008, 0x50804008},
3880 -       {0x0001650c, 0x08000000, 0x00000000, 0x00000000, 0x00000000},
3881 -       {0x00016540, 0x10804008, 0x10804008, 0x50804008, 0x50804008},
3882 -       {0x0001690c, 0x08000000, 0x00000000, 0x00000000, 0x00000000},
3883 -       {0x00016940, 0x10804008, 0x10804008, 0x50804008, 0x50804008},
3884 -};
3885 -
3886 -static const u32 ar9300Modes_lowest_ob_db_tx_gain_table_2p0[][5] = {
3887 -       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
3888 -       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
3889 -       {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
3890 -       {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002},
3891 -       {0x0000a508, 0x0a000020, 0x0a000020, 0x08000004, 0x08000004},
3892 -       {0x0000a50c, 0x10000023, 0x10000023, 0x0b000200, 0x0b000200},
3893 -       {0x0000a510, 0x16000220, 0x16000220, 0x0f000202, 0x0f000202},
3894 -       {0x0000a514, 0x1c000223, 0x1c000223, 0x12000400, 0x12000400},
3895 -       {0x0000a518, 0x21020220, 0x21020220, 0x16000402, 0x16000402},
3896 -       {0x0000a51c, 0x27020223, 0x27020223, 0x19000404, 0x19000404},
3897 -       {0x0000a520, 0x2b022220, 0x2b022220, 0x1c000603, 0x1c000603},
3898 -       {0x0000a524, 0x2f022222, 0x2f022222, 0x21000a02, 0x21000a02},
3899 -       {0x0000a528, 0x34022225, 0x34022225, 0x25000a04, 0x25000a04},
3900 -       {0x0000a52c, 0x3a02222a, 0x3a02222a, 0x28000a20, 0x28000a20},
3901 -       {0x0000a530, 0x3e02222c, 0x3e02222c, 0x2c000e20, 0x2c000e20},
3902 -       {0x0000a534, 0x4202242a, 0x4202242a, 0x30000e22, 0x30000e22},
3903 -       {0x0000a538, 0x4702244a, 0x4702244a, 0x34000e24, 0x34000e24},
3904 -       {0x0000a53c, 0x4b02244c, 0x4b02244c, 0x38001640, 0x38001640},
3905 -       {0x0000a540, 0x4e02246c, 0x4e02246c, 0x3c001660, 0x3c001660},
3906 -       {0x0000a544, 0x5302266c, 0x5302266c, 0x3f001861, 0x3f001861},
3907 -       {0x0000a548, 0x5702286c, 0x5702286c, 0x43001a81, 0x43001a81},
3908 -       {0x0000a54c, 0x5c04286b, 0x5c04286b, 0x47001a83, 0x47001a83},
3909 -       {0x0000a550, 0x61042a6c, 0x61042a6c, 0x4a001c84, 0x4a001c84},
3910 -       {0x0000a554, 0x66062a6c, 0x66062a6c, 0x4e001ce3, 0x4e001ce3},
3911 -       {0x0000a558, 0x6b062e6c, 0x6b062e6c, 0x52001ce5, 0x52001ce5},
3912 -       {0x0000a55c, 0x7006308c, 0x7006308c, 0x56001ce9, 0x56001ce9},
3913 -       {0x0000a560, 0x730a308a, 0x730a308a, 0x5a001ceb, 0x5a001ceb},
3914 -       {0x0000a564, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
3915 -       {0x0000a568, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
3916 -       {0x0000a56c, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
3917 -       {0x0000a570, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
3918 -       {0x0000a574, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
3919 -       {0x0000a578, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
3920 -       {0x0000a57c, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
3921 -       {0x0000a580, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
3922 -       {0x0000a584, 0x06800003, 0x06800003, 0x04800002, 0x04800002},
3923 -       {0x0000a588, 0x0a800020, 0x0a800020, 0x08800004, 0x08800004},
3924 -       {0x0000a58c, 0x10800023, 0x10800023, 0x0b800200, 0x0b800200},
3925 -       {0x0000a590, 0x16800220, 0x16800220, 0x0f800202, 0x0f800202},
3926 -       {0x0000a594, 0x1c800223, 0x1c800223, 0x12800400, 0x12800400},
3927 -       {0x0000a598, 0x21820220, 0x21820220, 0x16800402, 0x16800402},
3928 -       {0x0000a59c, 0x27820223, 0x27820223, 0x19800404, 0x19800404},
3929 -       {0x0000a5a0, 0x2b822220, 0x2b822220, 0x1c800603, 0x1c800603},
3930 -       {0x0000a5a4, 0x2f822222, 0x2f822222, 0x21800a02, 0x21800a02},
3931 -       {0x0000a5a8, 0x34822225, 0x34822225, 0x25800a04, 0x25800a04},
3932 -       {0x0000a5ac, 0x3a82222a, 0x3a82222a, 0x28800a20, 0x28800a20},
3933 -       {0x0000a5b0, 0x3e82222c, 0x3e82222c, 0x2c800e20, 0x2c800e20},
3934 -       {0x0000a5b4, 0x4282242a, 0x4282242a, 0x30800e22, 0x30800e22},
3935 -       {0x0000a5b8, 0x4782244a, 0x4782244a, 0x34800e24, 0x34800e24},
3936 -       {0x0000a5bc, 0x4b82244c, 0x4b82244c, 0x38801640, 0x38801640},
3937 -       {0x0000a5c0, 0x4e82246c, 0x4e82246c, 0x3c801660, 0x3c801660},
3938 -       {0x0000a5c4, 0x5382266c, 0x5382266c, 0x3f801861, 0x3f801861},
3939 -       {0x0000a5c8, 0x5782286c, 0x5782286c, 0x43801a81, 0x43801a81},
3940 -       {0x0000a5cc, 0x5c84286b, 0x5c84286b, 0x47801a83, 0x47801a83},
3941 -       {0x0000a5d0, 0x61842a6c, 0x61842a6c, 0x4a801c84, 0x4a801c84},
3942 -       {0x0000a5d4, 0x66862a6c, 0x66862a6c, 0x4e801ce3, 0x4e801ce3},
3943 -       {0x0000a5d8, 0x6b862e6c, 0x6b862e6c, 0x52801ce5, 0x52801ce5},
3944 -       {0x0000a5dc, 0x7086308c, 0x7086308c, 0x56801ce9, 0x56801ce9},
3945 -       {0x0000a5e0, 0x738a308a, 0x738a308a, 0x5a801ceb, 0x5a801ceb},
3946 -       {0x0000a5e4, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
3947 -       {0x0000a5e8, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
3948 -       {0x0000a5ec, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
3949 -       {0x0000a5f0, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
3950 -       {0x0000a5f4, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
3951 -       {0x0000a5f8, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
3952 -       {0x0000a5fc, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
3953 -       {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
3954 -       {0x00016048, 0x62480001, 0x62480001, 0x62480001, 0x62480001},
3955 -       {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
3956 -       {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
3957 -       {0x00016448, 0x62480001, 0x62480001, 0x62480001, 0x62480001},
3958 -       {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
3959 -       {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
3960 -       {0x00016848, 0x62480001, 0x62480001, 0x62480001, 0x62480001},
3961 -       {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
3962 -};
3963 -
3964 -static const u32 ar9300Modes_fast_clock_2p0[][3] = {
3965 -       /* Addr      5G_HT20     5G_HT40   */
3966 -       {0x00001030, 0x00000268, 0x000004d0},
3967 -       {0x00001070, 0x0000018c, 0x00000318},
3968 -       {0x000010b0, 0x00000fd0, 0x00001fa0},
3969 -       {0x00008014, 0x044c044c, 0x08980898},
3970 -       {0x0000801c, 0x148ec02b, 0x148ec057},
3971 -       {0x00008318, 0x000044c0, 0x00008980},
3972 -       {0x00009e00, 0x03721821, 0x03721821},
3973 -       {0x0000a230, 0x0000000b, 0x00000016},
3974 -       {0x0000a254, 0x00000898, 0x00001130},
3975 -};
3976 -
3977 -static const u32 ar9300_2p0_radio_core[][2] = {
3978 -       /* Addr      allmodes  */
3979 -       {0x00016000, 0x36db6db6},
3980 -       {0x00016004, 0x6db6db40},
3981 -       {0x00016008, 0x73f00000},
3982 -       {0x0001600c, 0x00000000},
3983 -       {0x00016040, 0x7f80fff8},
3984 -       {0x0001604c, 0x76d005b5},
3985 -       {0x00016050, 0x556cf031},
3986 -       {0x00016054, 0x13449440},
3987 -       {0x00016058, 0x0c51c92c},
3988 -       {0x0001605c, 0x3db7fffc},
3989 -       {0x00016060, 0xfffffffc},
3990 -       {0x00016064, 0x000f0278},
3991 -       {0x0001606c, 0x6db60000},
3992 -       {0x00016080, 0x00000000},
3993 -       {0x00016084, 0x0e48048c},
3994 -       {0x00016088, 0x54214514},
3995 -       {0x0001608c, 0x119f481e},
3996 -       {0x00016090, 0x24926490},
3997 -       {0x00016098, 0xd2888888},
3998 -       {0x000160a0, 0x0a108ffe},
3999 -       {0x000160a4, 0x812fc370},
4000 -       {0x000160a8, 0x423c8000},
4001 -       {0x000160b4, 0x92480080},
4002 -       {0x000160c0, 0x00adb6d0},
4003 -       {0x000160c4, 0x6db6db60},
4004 -       {0x000160c8, 0x6db6db6c},
4005 -       {0x000160cc, 0x01e6c000},
4006 -       {0x00016100, 0x3fffbe01},
4007 -       {0x00016104, 0xfff80000},
4008 -       {0x00016108, 0x00080010},
4009 -       {0x00016144, 0x02084080},
4010 -       {0x00016148, 0x00000000},
4011 -       {0x00016280, 0x058a0001},
4012 -       {0x00016284, 0x3d840208},
4013 -       {0x00016288, 0x05a20408},
4014 -       {0x0001628c, 0x00038c07},
4015 -       {0x00016290, 0x40000004},
4016 -       {0x00016294, 0x458aa14f},
4017 -       {0x00016380, 0x00000000},
4018 -       {0x00016384, 0x00000000},
4019 -       {0x00016388, 0x00800700},
4020 -       {0x0001638c, 0x00800700},
4021 -       {0x00016390, 0x00800700},
4022 -       {0x00016394, 0x00000000},
4023 -       {0x00016398, 0x00000000},
4024 -       {0x0001639c, 0x00000000},
4025 -       {0x000163a0, 0x00000001},
4026 -       {0x000163a4, 0x00000001},
4027 -       {0x000163a8, 0x00000000},
4028 -       {0x000163ac, 0x00000000},
4029 -       {0x000163b0, 0x00000000},
4030 -       {0x000163b4, 0x00000000},
4031 -       {0x000163b8, 0x00000000},
4032 -       {0x000163bc, 0x00000000},
4033 -       {0x000163c0, 0x000000a0},
4034 -       {0x000163c4, 0x000c0000},
4035 -       {0x000163c8, 0x14021402},
4036 -       {0x000163cc, 0x00001402},
4037 -       {0x000163d0, 0x00000000},
4038 -       {0x000163d4, 0x00000000},
4039 -       {0x00016400, 0x36db6db6},
4040 -       {0x00016404, 0x6db6db40},
4041 -       {0x00016408, 0x73f00000},
4042 -       {0x0001640c, 0x00000000},
4043 -       {0x00016440, 0x7f80fff8},
4044 -       {0x0001644c, 0x76d005b5},
4045 -       {0x00016450, 0x556cf031},
4046 -       {0x00016454, 0x13449440},
4047 -       {0x00016458, 0x0c51c92c},
4048 -       {0x0001645c, 0x3db7fffc},
4049 -       {0x00016460, 0xfffffffc},
4050 -       {0x00016464, 0x000f0278},
4051 -       {0x0001646c, 0x6db60000},
4052 -       {0x00016500, 0x3fffbe01},
4053 -       {0x00016504, 0xfff80000},
4054 -       {0x00016508, 0x00080010},
4055 -       {0x00016544, 0x02084080},
4056 -       {0x00016548, 0x00000000},
4057 -       {0x00016780, 0x00000000},
4058 -       {0x00016784, 0x00000000},
4059 -       {0x00016788, 0x00800700},
4060 -       {0x0001678c, 0x00800700},
4061 -       {0x00016790, 0x00800700},
4062 -       {0x00016794, 0x00000000},
4063 -       {0x00016798, 0x00000000},
4064 -       {0x0001679c, 0x00000000},
4065 -       {0x000167a0, 0x00000001},
4066 -       {0x000167a4, 0x00000001},
4067 -       {0x000167a8, 0x00000000},
4068 -       {0x000167ac, 0x00000000},
4069 -       {0x000167b0, 0x00000000},
4070 -       {0x000167b4, 0x00000000},
4071 -       {0x000167b8, 0x00000000},
4072 -       {0x000167bc, 0x00000000},
4073 -       {0x000167c0, 0x000000a0},
4074 -       {0x000167c4, 0x000c0000},
4075 -       {0x000167c8, 0x14021402},
4076 -       {0x000167cc, 0x00001402},
4077 -       {0x000167d0, 0x00000000},
4078 -       {0x000167d4, 0x00000000},
4079 -       {0x00016800, 0x36db6db6},
4080 -       {0x00016804, 0x6db6db40},
4081 -       {0x00016808, 0x73f00000},
4082 -       {0x0001680c, 0x00000000},
4083 -       {0x00016840, 0x7f80fff8},
4084 -       {0x0001684c, 0x76d005b5},
4085 -       {0x00016850, 0x556cf031},
4086 -       {0x00016854, 0x13449440},
4087 -       {0x00016858, 0x0c51c92c},
4088 -       {0x0001685c, 0x3db7fffc},
4089 -       {0x00016860, 0xfffffffc},
4090 -       {0x00016864, 0x000f0278},
4091 -       {0x0001686c, 0x6db60000},
4092 -       {0x00016900, 0x3fffbe01},
4093 -       {0x00016904, 0xfff80000},
4094 -       {0x00016908, 0x00080010},
4095 -       {0x00016944, 0x02084080},
4096 -       {0x00016948, 0x00000000},
4097 -       {0x00016b80, 0x00000000},
4098 -       {0x00016b84, 0x00000000},
4099 -       {0x00016b88, 0x00800700},
4100 -       {0x00016b8c, 0x00800700},
4101 -       {0x00016b90, 0x00800700},
4102 -       {0x00016b94, 0x00000000},
4103 -       {0x00016b98, 0x00000000},
4104 -       {0x00016b9c, 0x00000000},
4105 -       {0x00016ba0, 0x00000001},
4106 -       {0x00016ba4, 0x00000001},
4107 -       {0x00016ba8, 0x00000000},
4108 -       {0x00016bac, 0x00000000},
4109 -       {0x00016bb0, 0x00000000},
4110 -       {0x00016bb4, 0x00000000},
4111 -       {0x00016bb8, 0x00000000},
4112 -       {0x00016bbc, 0x00000000},
4113 -       {0x00016bc0, 0x000000a0},
4114 -       {0x00016bc4, 0x000c0000},
4115 -       {0x00016bc8, 0x14021402},
4116 -       {0x00016bcc, 0x00001402},
4117 -       {0x00016bd0, 0x00000000},
4118 -       {0x00016bd4, 0x00000000},
4119 -};
4120 -
4121 -static const u32 ar9300Common_rx_gain_table_merlin_2p0[][2] = {
4122 -       /* Addr      allmodes  */
4123 -       {0x0000a000, 0x02000101},
4124 -       {0x0000a004, 0x02000102},
4125 -       {0x0000a008, 0x02000103},
4126 -       {0x0000a00c, 0x02000104},
4127 -       {0x0000a010, 0x02000200},
4128 -       {0x0000a014, 0x02000201},
4129 -       {0x0000a018, 0x02000202},
4130 -       {0x0000a01c, 0x02000203},
4131 -       {0x0000a020, 0x02000204},
4132 -       {0x0000a024, 0x02000205},
4133 -       {0x0000a028, 0x02000208},
4134 -       {0x0000a02c, 0x02000302},
4135 -       {0x0000a030, 0x02000303},
4136 -       {0x0000a034, 0x02000304},
4137 -       {0x0000a038, 0x02000400},
4138 -       {0x0000a03c, 0x02010300},
4139 -       {0x0000a040, 0x02010301},
4140 -       {0x0000a044, 0x02010302},
4141 -       {0x0000a048, 0x02000500},
4142 -       {0x0000a04c, 0x02010400},
4143 -       {0x0000a050, 0x02020300},
4144 -       {0x0000a054, 0x02020301},
4145 -       {0x0000a058, 0x02020302},
4146 -       {0x0000a05c, 0x02020303},
4147 -       {0x0000a060, 0x02020400},
4148 -       {0x0000a064, 0x02030300},
4149 -       {0x0000a068, 0x02030301},
4150 -       {0x0000a06c, 0x02030302},
4151 -       {0x0000a070, 0x02030303},
4152 -       {0x0000a074, 0x02030400},
4153 -       {0x0000a078, 0x02040300},
4154 -       {0x0000a07c, 0x02040301},
4155 -       {0x0000a080, 0x02040302},
4156 -       {0x0000a084, 0x02040303},
4157 -       {0x0000a088, 0x02030500},
4158 -       {0x0000a08c, 0x02040400},
4159 -       {0x0000a090, 0x02050203},
4160 -       {0x0000a094, 0x02050204},
4161 -       {0x0000a098, 0x02050205},
4162 -       {0x0000a09c, 0x02040500},
4163 -       {0x0000a0a0, 0x02050301},
4164 -       {0x0000a0a4, 0x02050302},
4165 -       {0x0000a0a8, 0x02050303},
4166 -       {0x0000a0ac, 0x02050400},
4167 -       {0x0000a0b0, 0x02050401},
4168 -       {0x0000a0b4, 0x02050402},
4169 -       {0x0000a0b8, 0x02050403},
4170 -       {0x0000a0bc, 0x02050500},
4171 -       {0x0000a0c0, 0x02050501},
4172 -       {0x0000a0c4, 0x02050502},
4173 -       {0x0000a0c8, 0x02050503},
4174 -       {0x0000a0cc, 0x02050504},
4175 -       {0x0000a0d0, 0x02050600},
4176 -       {0x0000a0d4, 0x02050601},
4177 -       {0x0000a0d8, 0x02050602},
4178 -       {0x0000a0dc, 0x02050603},
4179 -       {0x0000a0e0, 0x02050604},
4180 -       {0x0000a0e4, 0x02050700},
4181 -       {0x0000a0e8, 0x02050701},
4182 -       {0x0000a0ec, 0x02050702},
4183 -       {0x0000a0f0, 0x02050703},
4184 -       {0x0000a0f4, 0x02050704},
4185 -       {0x0000a0f8, 0x02050705},
4186 -       {0x0000a0fc, 0x02050708},
4187 -       {0x0000a100, 0x02050709},
4188 -       {0x0000a104, 0x0205070a},
4189 -       {0x0000a108, 0x0205070b},
4190 -       {0x0000a10c, 0x0205070c},
4191 -       {0x0000a110, 0x0205070d},
4192 -       {0x0000a114, 0x02050710},
4193 -       {0x0000a118, 0x02050711},
4194 -       {0x0000a11c, 0x02050712},
4195 -       {0x0000a120, 0x02050713},
4196 -       {0x0000a124, 0x02050714},
4197 -       {0x0000a128, 0x02050715},
4198 -       {0x0000a12c, 0x02050730},
4199 -       {0x0000a130, 0x02050731},
4200 -       {0x0000a134, 0x02050732},
4201 -       {0x0000a138, 0x02050733},
4202 -       {0x0000a13c, 0x02050734},
4203 -       {0x0000a140, 0x02050735},
4204 -       {0x0000a144, 0x02050750},
4205 -       {0x0000a148, 0x02050751},
4206 -       {0x0000a14c, 0x02050752},
4207 -       {0x0000a150, 0x02050753},
4208 -       {0x0000a154, 0x02050754},
4209 -       {0x0000a158, 0x02050755},
4210 -       {0x0000a15c, 0x02050770},
4211 -       {0x0000a160, 0x02050771},
4212 -       {0x0000a164, 0x02050772},
4213 -       {0x0000a168, 0x02050773},
4214 -       {0x0000a16c, 0x02050774},
4215 -       {0x0000a170, 0x02050775},
4216 -       {0x0000a174, 0x00000776},
4217 -       {0x0000a178, 0x00000776},
4218 -       {0x0000a17c, 0x00000776},
4219 -       {0x0000a180, 0x00000776},
4220 -       {0x0000a184, 0x00000776},
4221 -       {0x0000a188, 0x00000776},
4222 -       {0x0000a18c, 0x00000776},
4223 -       {0x0000a190, 0x00000776},
4224 -       {0x0000a194, 0x00000776},
4225 -       {0x0000a198, 0x00000776},
4226 -       {0x0000a19c, 0x00000776},
4227 -       {0x0000a1a0, 0x00000776},
4228 -       {0x0000a1a4, 0x00000776},
4229 -       {0x0000a1a8, 0x00000776},
4230 -       {0x0000a1ac, 0x00000776},
4231 -       {0x0000a1b0, 0x00000776},
4232 -       {0x0000a1b4, 0x00000776},
4233 -       {0x0000a1b8, 0x00000776},
4234 -       {0x0000a1bc, 0x00000776},
4235 -       {0x0000a1c0, 0x00000776},
4236 -       {0x0000a1c4, 0x00000776},
4237 -       {0x0000a1c8, 0x00000776},
4238 -       {0x0000a1cc, 0x00000776},
4239 -       {0x0000a1d0, 0x00000776},
4240 -       {0x0000a1d4, 0x00000776},
4241 -       {0x0000a1d8, 0x00000776},
4242 -       {0x0000a1dc, 0x00000776},
4243 -       {0x0000a1e0, 0x00000776},
4244 -       {0x0000a1e4, 0x00000776},
4245 -       {0x0000a1e8, 0x00000776},
4246 -       {0x0000a1ec, 0x00000776},
4247 -       {0x0000a1f0, 0x00000776},
4248 -       {0x0000a1f4, 0x00000776},
4249 -       {0x0000a1f8, 0x00000776},
4250 -       {0x0000a1fc, 0x00000776},
4251 -       {0x0000b000, 0x02000101},
4252 -       {0x0000b004, 0x02000102},
4253 -       {0x0000b008, 0x02000103},
4254 -       {0x0000b00c, 0x02000104},
4255 -       {0x0000b010, 0x02000200},
4256 -       {0x0000b014, 0x02000201},
4257 -       {0x0000b018, 0x02000202},
4258 -       {0x0000b01c, 0x02000203},
4259 -       {0x0000b020, 0x02000204},
4260 -       {0x0000b024, 0x02000205},
4261 -       {0x0000b028, 0x02000208},
4262 -       {0x0000b02c, 0x02000302},
4263 -       {0x0000b030, 0x02000303},
4264 -       {0x0000b034, 0x02000304},
4265 -       {0x0000b038, 0x02000400},
4266 -       {0x0000b03c, 0x02010300},
4267 -       {0x0000b040, 0x02010301},
4268 -       {0x0000b044, 0x02010302},
4269 -       {0x0000b048, 0x02000500},
4270 -       {0x0000b04c, 0x02010400},
4271 -       {0x0000b050, 0x02020300},
4272 -       {0x0000b054, 0x02020301},
4273 -       {0x0000b058, 0x02020302},
4274 -       {0x0000b05c, 0x02020303},
4275 -       {0x0000b060, 0x02020400},
4276 -       {0x0000b064, 0x02030300},
4277 -       {0x0000b068, 0x02030301},
4278 -       {0x0000b06c, 0x02030302},
4279 -       {0x0000b070, 0x02030303},
4280 -       {0x0000b074, 0x02030400},
4281 -       {0x0000b078, 0x02040300},
4282 -       {0x0000b07c, 0x02040301},
4283 -       {0x0000b080, 0x02040302},
4284 -       {0x0000b084, 0x02040303},
4285 -       {0x0000b088, 0x02030500},
4286 -       {0x0000b08c, 0x02040400},
4287 -       {0x0000b090, 0x02050203},
4288 -       {0x0000b094, 0x02050204},
4289 -       {0x0000b098, 0x02050205},
4290 -       {0x0000b09c, 0x02040500},
4291 -       {0x0000b0a0, 0x02050301},
4292 -       {0x0000b0a4, 0x02050302},
4293 -       {0x0000b0a8, 0x02050303},
4294 -       {0x0000b0ac, 0x02050400},
4295 -       {0x0000b0b0, 0x02050401},
4296 -       {0x0000b0b4, 0x02050402},
4297 -       {0x0000b0b8, 0x02050403},
4298 -       {0x0000b0bc, 0x02050500},
4299 -       {0x0000b0c0, 0x02050501},
4300 -       {0x0000b0c4, 0x02050502},
4301 -       {0x0000b0c8, 0x02050503},
4302 -       {0x0000b0cc, 0x02050504},
4303 -       {0x0000b0d0, 0x02050600},
4304 -       {0x0000b0d4, 0x02050601},
4305 -       {0x0000b0d8, 0x02050602},
4306 -       {0x0000b0dc, 0x02050603},
4307 -       {0x0000b0e0, 0x02050604},
4308 -       {0x0000b0e4, 0x02050700},
4309 -       {0x0000b0e8, 0x02050701},
4310 -       {0x0000b0ec, 0x02050702},
4311 -       {0x0000b0f0, 0x02050703},
4312 -       {0x0000b0f4, 0x02050704},
4313 -       {0x0000b0f8, 0x02050705},
4314 -       {0x0000b0fc, 0x02050708},
4315 -       {0x0000b100, 0x02050709},
4316 -       {0x0000b104, 0x0205070a},
4317 -       {0x0000b108, 0x0205070b},
4318 -       {0x0000b10c, 0x0205070c},
4319 -       {0x0000b110, 0x0205070d},
4320 -       {0x0000b114, 0x02050710},
4321 -       {0x0000b118, 0x02050711},
4322 -       {0x0000b11c, 0x02050712},
4323 -       {0x0000b120, 0x02050713},
4324 -       {0x0000b124, 0x02050714},
4325 -       {0x0000b128, 0x02050715},
4326 -       {0x0000b12c, 0x02050730},
4327 -       {0x0000b130, 0x02050731},
4328 -       {0x0000b134, 0x02050732},
4329 -       {0x0000b138, 0x02050733},
4330 -       {0x0000b13c, 0x02050734},
4331 -       {0x0000b140, 0x02050735},
4332 -       {0x0000b144, 0x02050750},
4333 -       {0x0000b148, 0x02050751},
4334 -       {0x0000b14c, 0x02050752},
4335 -       {0x0000b150, 0x02050753},
4336 -       {0x0000b154, 0x02050754},
4337 -       {0x0000b158, 0x02050755},
4338 -       {0x0000b15c, 0x02050770},
4339 -       {0x0000b160, 0x02050771},
4340 -       {0x0000b164, 0x02050772},
4341 -       {0x0000b168, 0x02050773},
4342 -       {0x0000b16c, 0x02050774},
4343 -       {0x0000b170, 0x02050775},
4344 -       {0x0000b174, 0x00000776},
4345 -       {0x0000b178, 0x00000776},
4346 -       {0x0000b17c, 0x00000776},
4347 -       {0x0000b180, 0x00000776},
4348 -       {0x0000b184, 0x00000776},
4349 -       {0x0000b188, 0x00000776},
4350 -       {0x0000b18c, 0x00000776},
4351 -       {0x0000b190, 0x00000776},
4352 -       {0x0000b194, 0x00000776},
4353 -       {0x0000b198, 0x00000776},
4354 -       {0x0000b19c, 0x00000776},
4355 -       {0x0000b1a0, 0x00000776},
4356 -       {0x0000b1a4, 0x00000776},
4357 -       {0x0000b1a8, 0x00000776},
4358 -       {0x0000b1ac, 0x00000776},
4359 -       {0x0000b1b0, 0x00000776},
4360 -       {0x0000b1b4, 0x00000776},
4361 -       {0x0000b1b8, 0x00000776},
4362 -       {0x0000b1bc, 0x00000776},
4363 -       {0x0000b1c0, 0x00000776},
4364 -       {0x0000b1c4, 0x00000776},
4365 -       {0x0000b1c8, 0x00000776},
4366 -       {0x0000b1cc, 0x00000776},
4367 -       {0x0000b1d0, 0x00000776},
4368 -       {0x0000b1d4, 0x00000776},
4369 -       {0x0000b1d8, 0x00000776},
4370 -       {0x0000b1dc, 0x00000776},
4371 -       {0x0000b1e0, 0x00000776},
4372 -       {0x0000b1e4, 0x00000776},
4373 -       {0x0000b1e8, 0x00000776},
4374 -       {0x0000b1ec, 0x00000776},
4375 -       {0x0000b1f0, 0x00000776},
4376 -       {0x0000b1f4, 0x00000776},
4377 -       {0x0000b1f8, 0x00000776},
4378 -       {0x0000b1fc, 0x00000776},
4379 -};
4380 -
4381 -static const u32 ar9300_2p0_mac_postamble[][5] = {
4382 -       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
4383 -       {0x00001030, 0x00000230, 0x00000460, 0x000002c0, 0x00000160},
4384 -       {0x00001070, 0x00000168, 0x000002d0, 0x00000318, 0x0000018c},
4385 -       {0x000010b0, 0x00000e60, 0x00001cc0, 0x00007c70, 0x00003e38},
4386 -       {0x00008014, 0x03e803e8, 0x07d007d0, 0x10801600, 0x08400b00},
4387 -       {0x0000801c, 0x128d8027, 0x128d804f, 0x12e00057, 0x12e0002b},
4388 -       {0x00008120, 0x08f04800, 0x08f04800, 0x08f04810, 0x08f04810},
4389 -       {0x000081d0, 0x00003210, 0x00003210, 0x0000320a, 0x0000320a},
4390 -       {0x00008318, 0x00003e80, 0x00007d00, 0x00006880, 0x00003440},
4391 -};
4392 -
4393 -static const u32 ar9300_2p0_soc_postamble[][5] = {
4394 -       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
4395 -       {0x00007010, 0x00000023, 0x00000023, 0x00000023, 0x00000023},
4396 -};
4397 -
4398 -static const u32 ar9200_merlin_2p0_radio_core[][2] = {
4399 -       /* Addr      allmodes  */
4400 -       {0x00007800, 0x00040000},
4401 -       {0x00007804, 0xdb005012},
4402 -       {0x00007808, 0x04924914},
4403 -       {0x0000780c, 0x21084210},
4404 -       {0x00007810, 0x6d801300},
4405 -       {0x00007814, 0x0019beff},
4406 -       {0x00007818, 0x07e41000},
4407 -       {0x0000781c, 0x00392000},
4408 -       {0x00007820, 0x92592480},
4409 -       {0x00007824, 0x00040000},
4410 -       {0x00007828, 0xdb005012},
4411 -       {0x0000782c, 0x04924914},
4412 -       {0x00007830, 0x21084210},
4413 -       {0x00007834, 0x6d801300},
4414 -       {0x00007838, 0x0019beff},
4415 -       {0x0000783c, 0x07e40000},
4416 -       {0x00007840, 0x00392000},
4417 -       {0x00007844, 0x92592480},
4418 -       {0x00007848, 0x00100000},
4419 -       {0x0000784c, 0x773f0567},
4420 -       {0x00007850, 0x54214514},
4421 -       {0x00007854, 0x12035828},
4422 -       {0x00007858, 0x92592692},
4423 -       {0x0000785c, 0x00000000},
4424 -       {0x00007860, 0x56400000},
4425 -       {0x00007864, 0x0a8e370e},
4426 -       {0x00007868, 0xc0102850},
4427 -       {0x0000786c, 0x812d4000},
4428 -       {0x00007870, 0x807ec400},
4429 -       {0x00007874, 0x001b6db0},
4430 -       {0x00007878, 0x00376b63},
4431 -       {0x0000787c, 0x06db6db6},
4432 -       {0x00007880, 0x006d8000},
4433 -       {0x00007884, 0xffeffffe},
4434 -       {0x00007888, 0xffeffffe},
4435 -       {0x0000788c, 0x00010000},
4436 -       {0x00007890, 0x02060aeb},
4437 -       {0x00007894, 0x5a108000},
4438 -};
4439 -
4440 -static const u32 ar9300_2p0_baseband_postamble[][5] = {
4441 -       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
4442 -       {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8011, 0xd00a8011},
4443 -       {0x00009820, 0x206a022e, 0x206a022e, 0x206a012e, 0x206a012e},
4444 -       {0x00009824, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0},
4445 -       {0x00009828, 0x06903081, 0x06903081, 0x06903881, 0x06903881},
4446 -       {0x0000982c, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4},
4447 -       {0x00009830, 0x0000059c, 0x0000059c, 0x0000119c, 0x0000119c},
4448 -       {0x00009c00, 0x00000044, 0x000000c4, 0x000000c4, 0x00000044},
4449 -       {0x00009e00, 0x0372161e, 0x0372161e, 0x037216a0, 0x037216a0},
4450 -       {0x00009e04, 0x00802020, 0x00802020, 0x00802020, 0x00802020},
4451 -       {0x00009e0c, 0x6c4000e2, 0x6d4000e2, 0x6d4000e2, 0x6c4000e2},
4452 -       {0x00009e10, 0x7ec88d2e, 0x7ec88d2e, 0x7ec84d2e, 0x7ec84d2e},
4453 -       {0x00009e14, 0x31395d5e, 0x3139605e, 0x3139605e, 0x31395d5e},
4454 -       {0x00009e18, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
4455 -       {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c},
4456 -       {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce},
4457 -       {0x00009e2c, 0x0000001c, 0x0000001c, 0x00000021, 0x00000021},
4458 -       {0x00009e44, 0x02321e27, 0x02321e27, 0x02291e27, 0x02291e27},
4459 -       {0x00009e48, 0x5030201a, 0x5030201a, 0x50302012, 0x50302012},
4460 -       {0x00009fc8, 0x0003f000, 0x0003f000, 0x0001a000, 0x0001a000},
4461 -       {0x0000a204, 0x000037c0, 0x000037c4, 0x000037c4, 0x000037c0},
4462 -       {0x0000a208, 0x00000104, 0x00000104, 0x00000004, 0x00000004},
4463 -       {0x0000a230, 0x0000000a, 0x00000014, 0x00000016, 0x0000000b},
4464 -       {0x0000a238, 0xffb81018, 0xffb81018, 0xffb81018, 0xffb81018},
4465 -       {0x0000a250, 0x00000000, 0x00000000, 0x00000210, 0x00000108},
4466 -       {0x0000a254, 0x000007d0, 0x00000fa0, 0x00001130, 0x00000898},
4467 -       {0x0000a258, 0x02020002, 0x02020002, 0x02020002, 0x02020002},
4468 -       {0x0000a25c, 0x01000e0e, 0x01000e0e, 0x01000e0e, 0x01000e0e},
4469 -       {0x0000a260, 0x0a021501, 0x0a021501, 0x3a021501, 0x3a021501},
4470 -       {0x0000a264, 0x00000e0e, 0x00000e0e, 0x00000e0e, 0x00000e0e},
4471 -       {0x0000a280, 0x00000007, 0x00000007, 0x0000000b, 0x0000000b},
4472 -       {0x0000a284, 0x00000000, 0x00000000, 0x00000150, 0x00000150},
4473 -       {0x0000a288, 0x00000110, 0x00000110, 0x00000110, 0x00000110},
4474 -       {0x0000a28c, 0x00022222, 0x00022222, 0x00022222, 0x00022222},
4475 -       {0x0000a2c4, 0x00158d18, 0x00158d18, 0x00158d18, 0x00158d18},
4476 -       {0x0000a2d0, 0x00071981, 0x00071981, 0x00071981, 0x00071982},
4477 -       {0x0000a2d8, 0xf999a83a, 0xf999a83a, 0xf999a83a, 0xf999a83a},
4478 -       {0x0000a358, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
4479 -       {0x0000a830, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
4480 -       {0x0000ae04, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
4481 -       {0x0000ae18, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
4482 -       {0x0000ae1c, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
4483 -       {0x0000ae20, 0x000001b5, 0x000001b5, 0x000001ce, 0x000001ce},
4484 -       {0x0000b284, 0x00000000, 0x00000000, 0x00000150, 0x00000150},
4485 -       {0x0000b830, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
4486 -       {0x0000be04, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
4487 -       {0x0000be18, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
4488 -       {0x0000be1c, 0x0000019c, 0x0000019c, 0x0000019c, 0x0000019c},
4489 -       {0x0000be20, 0x000001b5, 0x000001b5, 0x000001ce, 0x000001ce},
4490 -       {0x0000c284, 0x00000000, 0x00000000, 0x00000150, 0x00000150},
4491 -};
4492 -
4493 -static const u32 ar9300_2p0_baseband_core[][2] = {
4494 -       /* Addr      allmodes  */
4495 -       {0x00009800, 0xafe68e30},
4496 -       {0x00009804, 0xfd14e000},
4497 -       {0x00009808, 0x9c0a9f6b},
4498 -       {0x0000980c, 0x04900000},
4499 -       {0x00009814, 0x9280c00a},
4500 -       {0x00009818, 0x00000000},
4501 -       {0x0000981c, 0x00020028},
4502 -       {0x00009834, 0x5f3ca3de},
4503 -       {0x00009838, 0x0108ecff},
4504 -       {0x0000983c, 0x14750600},
4505 -       {0x00009880, 0x201fff00},
4506 -       {0x00009884, 0x00001042},
4507 -       {0x000098a4, 0x00200400},
4508 -       {0x000098b0, 0x52440bbe},
4509 -       {0x000098d0, 0x004b6a8e},
4510 -       {0x000098d4, 0x00000820},
4511 -       {0x000098dc, 0x00000000},
4512 -       {0x000098f0, 0x00000000},
4513 -       {0x000098f4, 0x00000000},
4514 -       {0x00009c04, 0xff55ff55},
4515 -       {0x00009c08, 0x0320ff55},
4516 -       {0x00009c0c, 0x00000000},
4517 -       {0x00009c10, 0x00000000},
4518 -       {0x00009c14, 0x00046384},
4519 -       {0x00009c18, 0x05b6b440},
4520 -       {0x00009c1c, 0x00b6b440},
4521 -       {0x00009d00, 0xc080a333},
4522 -       {0x00009d04, 0x40206c10},
4523 -       {0x00009d08, 0x009c4060},
4524 -       {0x00009d0c, 0x9883800a},
4525 -       {0x00009d10, 0x01834061},
4526 -       {0x00009d14, 0x00c0040b},
4527 -       {0x00009d18, 0x00000000},
4528 -       {0x00009e08, 0x0038230c},
4529 -       {0x00009e24, 0x990bb515},
4530 -       {0x00009e28, 0x0c6f0000},
4531 -       {0x00009e30, 0x06336f77},
4532 -       {0x00009e34, 0x6af6532f},
4533 -       {0x00009e38, 0x0cc80c00},
4534 -       {0x00009e3c, 0xcf946222},
4535 -       {0x00009e40, 0x0d261820},
4536 -       {0x00009e4c, 0x00001004},
4537 -       {0x00009e50, 0x00ff03f1},
4538 -       {0x00009e54, 0x00000000},
4539 -       {0x00009fc0, 0x803e4788},
4540 -       {0x00009fc4, 0x0001efb5},
4541 -       {0x00009fcc, 0x40000014},
4542 -       {0x00009fd0, 0x01193b93},
4543 -       {0x0000a20c, 0x00000000},
4544 -       {0x0000a220, 0x00000000},
4545 -       {0x0000a224, 0x00000000},
4546 -       {0x0000a228, 0x10002310},
4547 -       {0x0000a22c, 0x01036a1e},
4548 -       {0x0000a234, 0x10000fff},
4549 -       {0x0000a23c, 0x00000000},
4550 -       {0x0000a244, 0x0c000000},
4551 -       {0x0000a2a0, 0x00000001},
4552 -       {0x0000a2c0, 0x00000001},
4553 -       {0x0000a2c8, 0x00000000},
4554 -       {0x0000a2cc, 0x18c43433},
4555 -       {0x0000a2d4, 0x00000000},
4556 -       {0x0000a2dc, 0x00000000},
4557 -       {0x0000a2e0, 0x00000000},
4558 -       {0x0000a2e4, 0x00000000},
4559 -       {0x0000a2e8, 0x00000000},
4560 -       {0x0000a2ec, 0x00000000},
4561 -       {0x0000a2f0, 0x00000000},
4562 -       {0x0000a2f4, 0x00000000},
4563 -       {0x0000a2f8, 0x00000000},
4564 -       {0x0000a344, 0x00000000},
4565 -       {0x0000a34c, 0x00000000},
4566 -       {0x0000a350, 0x0000a000},
4567 -       {0x0000a364, 0x00000000},
4568 -       {0x0000a370, 0x00000000},
4569 -       {0x0000a390, 0x00000001},
4570 -       {0x0000a394, 0x00000444},
4571 -       {0x0000a398, 0x001f0e0f},
4572 -       {0x0000a39c, 0x0075393f},
4573 -       {0x0000a3a0, 0xb79f6427},
4574 -       {0x0000a3a4, 0x00000000},
4575 -       {0x0000a3a8, 0xaaaaaaaa},
4576 -       {0x0000a3ac, 0x3c466478},
4577 -       {0x0000a3c0, 0x20202020},
4578 -       {0x0000a3c4, 0x22222220},
4579 -       {0x0000a3c8, 0x20200020},
4580 -       {0x0000a3cc, 0x20202020},
4581 -       {0x0000a3d0, 0x20202020},
4582 -       {0x0000a3d4, 0x20202020},
4583 -       {0x0000a3d8, 0x20202020},
4584 -       {0x0000a3dc, 0x20202020},
4585 -       {0x0000a3e0, 0x20202020},
4586 -       {0x0000a3e4, 0x20202020},
4587 -       {0x0000a3e8, 0x20202020},
4588 -       {0x0000a3ec, 0x20202020},
4589 -       {0x0000a3f0, 0x00000000},
4590 -       {0x0000a3f4, 0x00000246},
4591 -       {0x0000a3f8, 0x0cdbd380},
4592 -       {0x0000a3fc, 0x000f0f01},
4593 -       {0x0000a400, 0x8fa91f01},
4594 -       {0x0000a404, 0x00000000},
4595 -       {0x0000a408, 0x0e79e5c6},
4596 -       {0x0000a40c, 0x00820820},
4597 -       {0x0000a414, 0x1ce739ce},
4598 -       {0x0000a418, 0x2d001dce},
4599 -       {0x0000a41c, 0x1ce739ce},
4600 -       {0x0000a420, 0x000001ce},
4601 -       {0x0000a424, 0x1ce739ce},
4602 -       {0x0000a428, 0x000001ce},
4603 -       {0x0000a42c, 0x1ce739ce},
4604 -       {0x0000a430, 0x1ce739ce},
4605 -       {0x0000a434, 0x00000000},
4606 -       {0x0000a438, 0x00001801},
4607 -       {0x0000a43c, 0x00000000},
4608 -       {0x0000a440, 0x00000000},
4609 -       {0x0000a444, 0x00000000},
4610 -       {0x0000a448, 0x04000080},
4611 -       {0x0000a44c, 0x00000001},
4612 -       {0x0000a450, 0x00010000},
4613 -       {0x0000a458, 0x00000000},
4614 -       {0x0000a600, 0x00000000},
4615 -       {0x0000a604, 0x00000000},
4616 -       {0x0000a608, 0x00000000},
4617 -       {0x0000a60c, 0x00000000},
4618 -       {0x0000a610, 0x00000000},
4619 -       {0x0000a614, 0x00000000},
4620 -       {0x0000a618, 0x00000000},
4621 -       {0x0000a61c, 0x00000000},
4622 -       {0x0000a620, 0x00000000},
4623 -       {0x0000a624, 0x00000000},
4624 -       {0x0000a628, 0x00000000},
4625 -       {0x0000a62c, 0x00000000},
4626 -       {0x0000a630, 0x00000000},
4627 -       {0x0000a634, 0x00000000},
4628 -       {0x0000a638, 0x00000000},
4629 -       {0x0000a63c, 0x00000000},
4630 -       {0x0000a640, 0x00000000},
4631 -       {0x0000a644, 0x3fad9d74},
4632 -       {0x0000a648, 0x0048060a},
4633 -       {0x0000a64c, 0x00000637},
4634 -       {0x0000a670, 0x03020100},
4635 -       {0x0000a674, 0x09080504},
4636 -       {0x0000a678, 0x0d0c0b0a},
4637 -       {0x0000a67c, 0x13121110},
4638 -       {0x0000a680, 0x31301514},
4639 -       {0x0000a684, 0x35343332},
4640 -       {0x0000a688, 0x00000036},
4641 -       {0x0000a690, 0x00000838},
4642 -       {0x0000a7c0, 0x00000000},
4643 -       {0x0000a7c4, 0xfffffffc},
4644 -       {0x0000a7c8, 0x00000000},
4645 -       {0x0000a7cc, 0x00000000},
4646 -       {0x0000a7d0, 0x00000000},
4647 -       {0x0000a7d4, 0x00000004},
4648 -       {0x0000a7dc, 0x00000001},
4649 -       {0x0000a8d0, 0x004b6a8e},
4650 -       {0x0000a8d4, 0x00000820},
4651 -       {0x0000a8dc, 0x00000000},
4652 -       {0x0000a8f0, 0x00000000},
4653 -       {0x0000a8f4, 0x00000000},
4654 -       {0x0000b2d0, 0x00000080},
4655 -       {0x0000b2d4, 0x00000000},
4656 -       {0x0000b2dc, 0x00000000},
4657 -       {0x0000b2e0, 0x00000000},
4658 -       {0x0000b2e4, 0x00000000},
4659 -       {0x0000b2e8, 0x00000000},
4660 -       {0x0000b2ec, 0x00000000},
4661 -       {0x0000b2f0, 0x00000000},
4662 -       {0x0000b2f4, 0x00000000},
4663 -       {0x0000b2f8, 0x00000000},
4664 -       {0x0000b408, 0x0e79e5c0},
4665 -       {0x0000b40c, 0x00820820},
4666 -       {0x0000b420, 0x00000000},
4667 -       {0x0000b8d0, 0x004b6a8e},
4668 -       {0x0000b8d4, 0x00000820},
4669 -       {0x0000b8dc, 0x00000000},
4670 -       {0x0000b8f0, 0x00000000},
4671 -       {0x0000b8f4, 0x00000000},
4672 -       {0x0000c2d0, 0x00000080},
4673 -       {0x0000c2d4, 0x00000000},
4674 -       {0x0000c2dc, 0x00000000},
4675 -       {0x0000c2e0, 0x00000000},
4676 -       {0x0000c2e4, 0x00000000},
4677 -       {0x0000c2e8, 0x00000000},
4678 -       {0x0000c2ec, 0x00000000},
4679 -       {0x0000c2f0, 0x00000000},
4680 -       {0x0000c2f4, 0x00000000},
4681 -       {0x0000c2f8, 0x00000000},
4682 -       {0x0000c408, 0x0e79e5c0},
4683 -       {0x0000c40c, 0x00820820},
4684 -       {0x0000c420, 0x00000000},
4685 -};
4686 -
4687 -static const u32 ar9300Modes_high_power_tx_gain_table_2p0[][5] = {
4688 -       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
4689 -       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
4690 -       {0x0000a500, 0x00002220, 0x00002220, 0x00000000, 0x00000000},
4691 -       {0x0000a504, 0x06002223, 0x06002223, 0x04000002, 0x04000002},
4692 -       {0x0000a508, 0x0a022220, 0x0a022220, 0x08000004, 0x08000004},
4693 -       {0x0000a50c, 0x0f022223, 0x0f022223, 0x0b000200, 0x0b000200},
4694 -       {0x0000a510, 0x14022620, 0x14022620, 0x0f000202, 0x0f000202},
4695 -       {0x0000a514, 0x18022622, 0x18022622, 0x11000400, 0x11000400},
4696 -       {0x0000a518, 0x1b022822, 0x1b022822, 0x15000402, 0x15000402},
4697 -       {0x0000a51c, 0x20022842, 0x20022842, 0x19000404, 0x19000404},
4698 -       {0x0000a520, 0x22022c41, 0x22022c41, 0x1b000603, 0x1b000603},
4699 -       {0x0000a524, 0x28023042, 0x28023042, 0x1f000a02, 0x1f000a02},
4700 -       {0x0000a528, 0x2c023044, 0x2c023044, 0x23000a04, 0x23000a04},
4701 -       {0x0000a52c, 0x2f023644, 0x2f023644, 0x26000a20, 0x26000a20},
4702 -       {0x0000a530, 0x34025643, 0x34025643, 0x2a000e20, 0x2a000e20},
4703 -       {0x0000a534, 0x38025a44, 0x38025a44, 0x2e000e22, 0x2e000e22},
4704 -       {0x0000a538, 0x3b025e45, 0x3b025e45, 0x31000e24, 0x31000e24},
4705 -       {0x0000a53c, 0x41025e4a, 0x41025e4a, 0x34001640, 0x34001640},
4706 -       {0x0000a540, 0x48025e6c, 0x48025e6c, 0x38001660, 0x38001660},
4707 -       {0x0000a544, 0x4e025e8e, 0x4e025e8e, 0x3b001861, 0x3b001861},
4708 -       {0x0000a548, 0x53025eb2, 0x53025eb2, 0x3e001a81, 0x3e001a81},
4709 -       {0x0000a54c, 0x59025eb5, 0x59025eb5, 0x42001a83, 0x42001a83},
4710 -       {0x0000a550, 0x5f025ef6, 0x5f025ef6, 0x44001c84, 0x44001c84},
4711 -       {0x0000a554, 0x62025f56, 0x62025f56, 0x48001ce3, 0x48001ce3},
4712 -       {0x0000a558, 0x66027f56, 0x66027f56, 0x4c001ce5, 0x4c001ce5},
4713 -       {0x0000a55c, 0x6a029f56, 0x6a029f56, 0x50001ce9, 0x50001ce9},
4714 -       {0x0000a560, 0x70049f56, 0x70049f56, 0x54001ceb, 0x54001ceb},
4715 -       {0x0000a564, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
4716 -       {0x0000a568, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
4717 -       {0x0000a56c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
4718 -       {0x0000a570, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
4719 -       {0x0000a574, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
4720 -       {0x0000a578, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
4721 -       {0x0000a57c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
4722 -       {0x0000a580, 0x00802220, 0x00802220, 0x00800000, 0x00800000},
4723 -       {0x0000a584, 0x06802223, 0x06802223, 0x04800002, 0x04800002},
4724 -       {0x0000a588, 0x0a822220, 0x0a822220, 0x08800004, 0x08800004},
4725 -       {0x0000a58c, 0x0f822223, 0x0f822223, 0x0b800200, 0x0b800200},
4726 -       {0x0000a590, 0x14822620, 0x14822620, 0x0f800202, 0x0f800202},
4727 -       {0x0000a594, 0x18822622, 0x18822622, 0x11800400, 0x11800400},
4728 -       {0x0000a598, 0x1b822822, 0x1b822822, 0x15800402, 0x15800402},
4729 -       {0x0000a59c, 0x20822842, 0x20822842, 0x19800404, 0x19800404},
4730 -       {0x0000a5a0, 0x22822c41, 0x22822c41, 0x1b800603, 0x1b800603},
4731 -       {0x0000a5a4, 0x28823042, 0x28823042, 0x1f800a02, 0x1f800a02},
4732 -       {0x0000a5a8, 0x2c823044, 0x2c823044, 0x23800a04, 0x23800a04},
4733 -       {0x0000a5ac, 0x2f823644, 0x2f823644, 0x26800a20, 0x26800a20},
4734 -       {0x0000a5b0, 0x34825643, 0x34825643, 0x2a800e20, 0x2a800e20},
4735 -       {0x0000a5b4, 0x38825a44, 0x38825a44, 0x2e800e22, 0x2e800e22},
4736 -       {0x0000a5b8, 0x3b825e45, 0x3b825e45, 0x31800e24, 0x31800e24},
4737 -       {0x0000a5bc, 0x41825e4a, 0x41825e4a, 0x34801640, 0x34801640},
4738 -       {0x0000a5c0, 0x48825e6c, 0x48825e6c, 0x38801660, 0x38801660},
4739 -       {0x0000a5c4, 0x4e825e8e, 0x4e825e8e, 0x3b801861, 0x3b801861},
4740 -       {0x0000a5c8, 0x53825eb2, 0x53825eb2, 0x3e801a81, 0x3e801a81},
4741 -       {0x0000a5cc, 0x59825eb5, 0x59825eb5, 0x42801a83, 0x42801a83},
4742 -       {0x0000a5d0, 0x5f825ef6, 0x5f825ef6, 0x44801c84, 0x44801c84},
4743 -       {0x0000a5d4, 0x62825f56, 0x62825f56, 0x48801ce3, 0x48801ce3},
4744 -       {0x0000a5d8, 0x66827f56, 0x66827f56, 0x4c801ce5, 0x4c801ce5},
4745 -       {0x0000a5dc, 0x6a829f56, 0x6a829f56, 0x50801ce9, 0x50801ce9},
4746 -       {0x0000a5e0, 0x70849f56, 0x70849f56, 0x54801ceb, 0x54801ceb},
4747 -       {0x0000a5e4, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
4748 -       {0x0000a5e8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
4749 -       {0x0000a5ec, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
4750 -       {0x0000a5f0, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
4751 -       {0x0000a5f4, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
4752 -       {0x0000a5f8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
4753 -       {0x0000a5fc, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
4754 -       {0x00016044, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6},
4755 -       {0x00016048, 0xae480001, 0xae480001, 0xae480001, 0xae480001},
4756 -       {0x00016068, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c},
4757 -       {0x00016444, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6},
4758 -       {0x00016448, 0xae480001, 0xae480001, 0xae480001, 0xae480001},
4759 -       {0x00016468, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c},
4760 -       {0x00016844, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6},
4761 -       {0x00016848, 0xae480001, 0xae480001, 0xae480001, 0xae480001},
4762 -       {0x00016868, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c},
4763 -};
4764 -
4765 -static const u32 ar9300Modes_high_ob_db_tx_gain_table_2p0[][5] = {
4766 -       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
4767 -       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
4768 -       {0x0000a500, 0x00002220, 0x00002220, 0x00000000, 0x00000000},
4769 -       {0x0000a504, 0x06002223, 0x06002223, 0x04000002, 0x04000002},
4770 -       {0x0000a508, 0x0a022220, 0x0a022220, 0x08000004, 0x08000004},
4771 -       {0x0000a50c, 0x0f022223, 0x0f022223, 0x0b000200, 0x0b000200},
4772 -       {0x0000a510, 0x14022620, 0x14022620, 0x0f000202, 0x0f000202},
4773 -       {0x0000a514, 0x18022622, 0x18022622, 0x11000400, 0x11000400},
4774 -       {0x0000a518, 0x1b022822, 0x1b022822, 0x15000402, 0x15000402},
4775 -       {0x0000a51c, 0x20022842, 0x20022842, 0x19000404, 0x19000404},
4776 -       {0x0000a520, 0x22022c41, 0x22022c41, 0x1b000603, 0x1b000603},
4777 -       {0x0000a524, 0x28023042, 0x28023042, 0x1f000a02, 0x1f000a02},
4778 -       {0x0000a528, 0x2c023044, 0x2c023044, 0x23000a04, 0x23000a04},
4779 -       {0x0000a52c, 0x2f023644, 0x2f023644, 0x26000a20, 0x26000a20},
4780 -       {0x0000a530, 0x34025643, 0x34025643, 0x2a000e20, 0x2a000e20},
4781 -       {0x0000a534, 0x38025a44, 0x38025a44, 0x2e000e22, 0x2e000e22},
4782 -       {0x0000a538, 0x3b025e45, 0x3b025e45, 0x31000e24, 0x31000e24},
4783 -       {0x0000a53c, 0x41025e4a, 0x41025e4a, 0x34001640, 0x34001640},
4784 -       {0x0000a540, 0x48025e6c, 0x48025e6c, 0x38001660, 0x38001660},
4785 -       {0x0000a544, 0x4e025e8e, 0x4e025e8e, 0x3b001861, 0x3b001861},
4786 -       {0x0000a548, 0x53025eb2, 0x53025eb2, 0x3e001a81, 0x3e001a81},
4787 -       {0x0000a54c, 0x59025eb5, 0x59025eb5, 0x42001a83, 0x42001a83},
4788 -       {0x0000a550, 0x5f025ef6, 0x5f025ef6, 0x44001c84, 0x44001c84},
4789 -       {0x0000a554, 0x62025f56, 0x62025f56, 0x48001ce3, 0x48001ce3},
4790 -       {0x0000a558, 0x66027f56, 0x66027f56, 0x4c001ce5, 0x4c001ce5},
4791 -       {0x0000a55c, 0x6a029f56, 0x6a029f56, 0x50001ce9, 0x50001ce9},
4792 -       {0x0000a560, 0x70049f56, 0x70049f56, 0x54001ceb, 0x54001ceb},
4793 -       {0x0000a564, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
4794 -       {0x0000a568, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
4795 -       {0x0000a56c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
4796 -       {0x0000a570, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
4797 -       {0x0000a574, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
4798 -       {0x0000a578, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
4799 -       {0x0000a57c, 0x7504ff56, 0x7504ff56, 0x56001eec, 0x56001eec},
4800 -       {0x0000a580, 0x00802220, 0x00802220, 0x00800000, 0x00800000},
4801 -       {0x0000a584, 0x06802223, 0x06802223, 0x04800002, 0x04800002},
4802 -       {0x0000a588, 0x0a822220, 0x0a822220, 0x08800004, 0x08800004},
4803 -       {0x0000a58c, 0x0f822223, 0x0f822223, 0x0b800200, 0x0b800200},
4804 -       {0x0000a590, 0x14822620, 0x14822620, 0x0f800202, 0x0f800202},
4805 -       {0x0000a594, 0x18822622, 0x18822622, 0x11800400, 0x11800400},
4806 -       {0x0000a598, 0x1b822822, 0x1b822822, 0x15800402, 0x15800402},
4807 -       {0x0000a59c, 0x20822842, 0x20822842, 0x19800404, 0x19800404},
4808 -       {0x0000a5a0, 0x22822c41, 0x22822c41, 0x1b800603, 0x1b800603},
4809 -       {0x0000a5a4, 0x28823042, 0x28823042, 0x1f800a02, 0x1f800a02},
4810 -       {0x0000a5a8, 0x2c823044, 0x2c823044, 0x23800a04, 0x23800a04},
4811 -       {0x0000a5ac, 0x2f823644, 0x2f823644, 0x26800a20, 0x26800a20},
4812 -       {0x0000a5b0, 0x34825643, 0x34825643, 0x2a800e20, 0x2a800e20},
4813 -       {0x0000a5b4, 0x38825a44, 0x38825a44, 0x2e800e22, 0x2e800e22},
4814 -       {0x0000a5b8, 0x3b825e45, 0x3b825e45, 0x31800e24, 0x31800e24},
4815 -       {0x0000a5bc, 0x41825e4a, 0x41825e4a, 0x34801640, 0x34801640},
4816 -       {0x0000a5c0, 0x48825e6c, 0x48825e6c, 0x38801660, 0x38801660},
4817 -       {0x0000a5c4, 0x4e825e8e, 0x4e825e8e, 0x3b801861, 0x3b801861},
4818 -       {0x0000a5c8, 0x53825eb2, 0x53825eb2, 0x3e801a81, 0x3e801a81},
4819 -       {0x0000a5cc, 0x59825eb5, 0x59825eb5, 0x42801a83, 0x42801a83},
4820 -       {0x0000a5d0, 0x5f825ef6, 0x5f825ef6, 0x44801c84, 0x44801c84},
4821 -       {0x0000a5d4, 0x62825f56, 0x62825f56, 0x48801ce3, 0x48801ce3},
4822 -       {0x0000a5d8, 0x66827f56, 0x66827f56, 0x4c801ce5, 0x4c801ce5},
4823 -       {0x0000a5dc, 0x6a829f56, 0x6a829f56, 0x50801ce9, 0x50801ce9},
4824 -       {0x0000a5e0, 0x70849f56, 0x70849f56, 0x54801ceb, 0x54801ceb},
4825 -       {0x0000a5e4, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
4826 -       {0x0000a5e8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
4827 -       {0x0000a5ec, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
4828 -       {0x0000a5f0, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
4829 -       {0x0000a5f4, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
4830 -       {0x0000a5f8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
4831 -       {0x0000a5fc, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
4832 -       {0x00016044, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4},
4833 -       {0x00016048, 0x8e480001, 0x8e480001, 0x8e480001, 0x8e480001},
4834 -       {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
4835 -       {0x00016444, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4},
4836 -       {0x00016448, 0x8e480001, 0x8e480001, 0x8e480001, 0x8e480001},
4837 -       {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
4838 -       {0x00016844, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4},
4839 -       {0x00016848, 0x8e480001, 0x8e480001, 0x8e480001, 0x8e480001},
4840 -       {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
4841 -};
4842 -
4843 -static const u32 ar9300Common_rx_gain_table_2p0[][2] = {
4844 -       /* Addr      allmodes  */
4845 -       {0x0000a000, 0x00010000},
4846 -       {0x0000a004, 0x00030002},
4847 -       {0x0000a008, 0x00050004},
4848 -       {0x0000a00c, 0x00810080},
4849 -       {0x0000a010, 0x00830082},
4850 -       {0x0000a014, 0x01810180},
4851 -       {0x0000a018, 0x01830182},
4852 -       {0x0000a01c, 0x01850184},
4853 -       {0x0000a020, 0x01890188},
4854 -       {0x0000a024, 0x018b018a},
4855 -       {0x0000a028, 0x018d018c},
4856 -       {0x0000a02c, 0x01910190},
4857 -       {0x0000a030, 0x01930192},
4858 -       {0x0000a034, 0x01950194},
4859 -       {0x0000a038, 0x038a0196},
4860 -       {0x0000a03c, 0x038c038b},
4861 -       {0x0000a040, 0x0390038d},
4862 -       {0x0000a044, 0x03920391},
4863 -       {0x0000a048, 0x03940393},
4864 -       {0x0000a04c, 0x03960395},
4865 -       {0x0000a050, 0x00000000},
4866 -       {0x0000a054, 0x00000000},
4867 -       {0x0000a058, 0x00000000},
4868 -       {0x0000a05c, 0x00000000},
4869 -       {0x0000a060, 0x00000000},
4870 -       {0x0000a064, 0x00000000},
4871 -       {0x0000a068, 0x00000000},
4872 -       {0x0000a06c, 0x00000000},
4873 -       {0x0000a070, 0x00000000},
4874 -       {0x0000a074, 0x00000000},
4875 -       {0x0000a078, 0x00000000},
4876 -       {0x0000a07c, 0x00000000},
4877 -       {0x0000a080, 0x22222229},
4878 -       {0x0000a084, 0x1d1d1d1d},
4879 -       {0x0000a088, 0x1d1d1d1d},
4880 -       {0x0000a08c, 0x1d1d1d1d},
4881 -       {0x0000a090, 0x171d1d1d},
4882 -       {0x0000a094, 0x11111717},
4883 -       {0x0000a098, 0x00030311},
4884 -       {0x0000a09c, 0x00000000},
4885 -       {0x0000a0a0, 0x00000000},
4886 -       {0x0000a0a4, 0x00000000},
4887 -       {0x0000a0a8, 0x00000000},
4888 -       {0x0000a0ac, 0x00000000},
4889 -       {0x0000a0b0, 0x00000000},
4890 -       {0x0000a0b4, 0x00000000},
4891 -       {0x0000a0b8, 0x00000000},
4892 -       {0x0000a0bc, 0x00000000},
4893 -       {0x0000a0c0, 0x001f0000},
4894 -       {0x0000a0c4, 0x01000101},
4895 -       {0x0000a0c8, 0x011e011f},
4896 -       {0x0000a0cc, 0x011c011d},
4897 -       {0x0000a0d0, 0x02030204},
4898 -       {0x0000a0d4, 0x02010202},
4899 -       {0x0000a0d8, 0x021f0200},
4900 -       {0x0000a0dc, 0x0302021e},
4901 -       {0x0000a0e0, 0x03000301},
4902 -       {0x0000a0e4, 0x031e031f},
4903 -       {0x0000a0e8, 0x0402031d},
4904 -       {0x0000a0ec, 0x04000401},
4905 -       {0x0000a0f0, 0x041e041f},
4906 -       {0x0000a0f4, 0x0502041d},
4907 -       {0x0000a0f8, 0x05000501},
4908 -       {0x0000a0fc, 0x051e051f},
4909 -       {0x0000a100, 0x06010602},
4910 -       {0x0000a104, 0x061f0600},
4911 -       {0x0000a108, 0x061d061e},
4912 -       {0x0000a10c, 0x07020703},
4913 -       {0x0000a110, 0x07000701},
4914 -       {0x0000a114, 0x00000000},
4915 -       {0x0000a118, 0x00000000},
4916 -       {0x0000a11c, 0x00000000},
4917 -       {0x0000a120, 0x00000000},
4918 -       {0x0000a124, 0x00000000},
4919 -       {0x0000a128, 0x00000000},
4920 -       {0x0000a12c, 0x00000000},
4921 -       {0x0000a130, 0x00000000},
4922 -       {0x0000a134, 0x00000000},
4923 -       {0x0000a138, 0x00000000},
4924 -       {0x0000a13c, 0x00000000},
4925 -       {0x0000a140, 0x001f0000},
4926 -       {0x0000a144, 0x01000101},
4927 -       {0x0000a148, 0x011e011f},
4928 -       {0x0000a14c, 0x011c011d},
4929 -       {0x0000a150, 0x02030204},
4930 -       {0x0000a154, 0x02010202},
4931 -       {0x0000a158, 0x021f0200},
4932 -       {0x0000a15c, 0x0302021e},
4933 -       {0x0000a160, 0x03000301},
4934 -       {0x0000a164, 0x031e031f},
4935 -       {0x0000a168, 0x0402031d},
4936 -       {0x0000a16c, 0x04000401},
4937 -       {0x0000a170, 0x041e041f},
4938 -       {0x0000a174, 0x0502041d},
4939 -       {0x0000a178, 0x05000501},
4940 -       {0x0000a17c, 0x051e051f},
4941 -       {0x0000a180, 0x06010602},
4942 -       {0x0000a184, 0x061f0600},
4943 -       {0x0000a188, 0x061d061e},
4944 -       {0x0000a18c, 0x07020703},
4945 -       {0x0000a190, 0x07000701},
4946 -       {0x0000a194, 0x00000000},
4947 -       {0x0000a198, 0x00000000},
4948 -       {0x0000a19c, 0x00000000},
4949 -       {0x0000a1a0, 0x00000000},
4950 -       {0x0000a1a4, 0x00000000},
4951 -       {0x0000a1a8, 0x00000000},
4952 -       {0x0000a1ac, 0x00000000},
4953 -       {0x0000a1b0, 0x00000000},
4954 -       {0x0000a1b4, 0x00000000},
4955 -       {0x0000a1b8, 0x00000000},
4956 -       {0x0000a1bc, 0x00000000},
4957 -       {0x0000a1c0, 0x00000000},
4958 -       {0x0000a1c4, 0x00000000},
4959 -       {0x0000a1c8, 0x00000000},
4960 -       {0x0000a1cc, 0x00000000},
4961 -       {0x0000a1d0, 0x00000000},
4962 -       {0x0000a1d4, 0x00000000},
4963 -       {0x0000a1d8, 0x00000000},
4964 -       {0x0000a1dc, 0x00000000},
4965 -       {0x0000a1e0, 0x00000000},
4966 -       {0x0000a1e4, 0x00000000},
4967 -       {0x0000a1e8, 0x00000000},
4968 -       {0x0000a1ec, 0x00000000},
4969 -       {0x0000a1f0, 0x00000396},
4970 -       {0x0000a1f4, 0x00000396},
4971 -       {0x0000a1f8, 0x00000396},
4972 -       {0x0000a1fc, 0x00000196},
4973 -       {0x0000b000, 0x00010000},
4974 -       {0x0000b004, 0x00030002},
4975 -       {0x0000b008, 0x00050004},
4976 -       {0x0000b00c, 0x00810080},
4977 -       {0x0000b010, 0x00830082},
4978 -       {0x0000b014, 0x01810180},
4979 -       {0x0000b018, 0x01830182},
4980 -       {0x0000b01c, 0x01850184},
4981 -       {0x0000b020, 0x02810280},
4982 -       {0x0000b024, 0x02830282},
4983 -       {0x0000b028, 0x02850284},
4984 -       {0x0000b02c, 0x02890288},
4985 -       {0x0000b030, 0x028b028a},
4986 -       {0x0000b034, 0x0388028c},
4987 -       {0x0000b038, 0x038a0389},
4988 -       {0x0000b03c, 0x038c038b},
4989 -       {0x0000b040, 0x0390038d},
4990 -       {0x0000b044, 0x03920391},
4991 -       {0x0000b048, 0x03940393},
4992 -       {0x0000b04c, 0x03960395},
4993 -       {0x0000b050, 0x00000000},
4994 -       {0x0000b054, 0x00000000},
4995 -       {0x0000b058, 0x00000000},
4996 -       {0x0000b05c, 0x00000000},
4997 -       {0x0000b060, 0x00000000},
4998 -       {0x0000b064, 0x00000000},
4999 -       {0x0000b068, 0x00000000},
5000 -       {0x0000b06c, 0x00000000},
5001 -       {0x0000b070, 0x00000000},
5002 -       {0x0000b074, 0x00000000},
5003 -       {0x0000b078, 0x00000000},
5004 -       {0x0000b07c, 0x00000000},
5005 -       {0x0000b080, 0x32323232},
5006 -       {0x0000b084, 0x2f2f3232},
5007 -       {0x0000b088, 0x23282a2d},
5008 -       {0x0000b08c, 0x1c1e2123},
5009 -       {0x0000b090, 0x14171919},
5010 -       {0x0000b094, 0x0e0e1214},
5011 -       {0x0000b098, 0x03050707},
5012 -       {0x0000b09c, 0x00030303},
5013 -       {0x0000b0a0, 0x00000000},
5014 -       {0x0000b0a4, 0x00000000},
5015 -       {0x0000b0a8, 0x00000000},
5016 -       {0x0000b0ac, 0x00000000},
5017 -       {0x0000b0b0, 0x00000000},
5018 -       {0x0000b0b4, 0x00000000},
5019 -       {0x0000b0b8, 0x00000000},
5020 -       {0x0000b0bc, 0x00000000},
5021 -       {0x0000b0c0, 0x003f0020},
5022 -       {0x0000b0c4, 0x00400041},
5023 -       {0x0000b0c8, 0x0140005f},
5024 -       {0x0000b0cc, 0x0160015f},
5025 -       {0x0000b0d0, 0x017e017f},
5026 -       {0x0000b0d4, 0x02410242},
5027 -       {0x0000b0d8, 0x025f0240},
5028 -       {0x0000b0dc, 0x027f0260},
5029 -       {0x0000b0e0, 0x0341027e},
5030 -       {0x0000b0e4, 0x035f0340},
5031 -       {0x0000b0e8, 0x037f0360},
5032 -       {0x0000b0ec, 0x04400441},
5033 -       {0x0000b0f0, 0x0460045f},
5034 -       {0x0000b0f4, 0x0541047f},
5035 -       {0x0000b0f8, 0x055f0540},
5036 -       {0x0000b0fc, 0x057f0560},
5037 -       {0x0000b100, 0x06400641},
5038 -       {0x0000b104, 0x0660065f},
5039 -       {0x0000b108, 0x067e067f},
5040 -       {0x0000b10c, 0x07410742},
5041 -       {0x0000b110, 0x075f0740},
5042 -       {0x0000b114, 0x077f0760},
5043 -       {0x0000b118, 0x07800781},
5044 -       {0x0000b11c, 0x07a0079f},
5045 -       {0x0000b120, 0x07c107bf},
5046 -       {0x0000b124, 0x000007c0},
5047 -       {0x0000b128, 0x00000000},
5048 -       {0x0000b12c, 0x00000000},
5049 -       {0x0000b130, 0x00000000},
5050 -       {0x0000b134, 0x00000000},
5051 -       {0x0000b138, 0x00000000},
5052 -       {0x0000b13c, 0x00000000},
5053 -       {0x0000b140, 0x003f0020},
5054 -       {0x0000b144, 0x00400041},
5055 -       {0x0000b148, 0x0140005f},
5056 -       {0x0000b14c, 0x0160015f},
5057 -       {0x0000b150, 0x017e017f},
5058 -       {0x0000b154, 0x02410242},
5059 -       {0x0000b158, 0x025f0240},
5060 -       {0x0000b15c, 0x027f0260},
5061 -       {0x0000b160, 0x0341027e},
5062 -       {0x0000b164, 0x035f0340},
5063 -       {0x0000b168, 0x037f0360},
5064 -       {0x0000b16c, 0x04400441},
5065 -       {0x0000b170, 0x0460045f},
5066 -       {0x0000b174, 0x0541047f},
5067 -       {0x0000b178, 0x055f0540},
5068 -       {0x0000b17c, 0x057f0560},
5069 -       {0x0000b180, 0x06400641},
5070 -       {0x0000b184, 0x0660065f},
5071 -       {0x0000b188, 0x067e067f},
5072 -       {0x0000b18c, 0x07410742},
5073 -       {0x0000b190, 0x075f0740},
5074 -       {0x0000b194, 0x077f0760},
5075 -       {0x0000b198, 0x07800781},
5076 -       {0x0000b19c, 0x07a0079f},
5077 -       {0x0000b1a0, 0x07c107bf},
5078 -       {0x0000b1a4, 0x000007c0},
5079 -       {0x0000b1a8, 0x00000000},
5080 -       {0x0000b1ac, 0x00000000},
5081 -       {0x0000b1b0, 0x00000000},
5082 -       {0x0000b1b4, 0x00000000},
5083 -       {0x0000b1b8, 0x00000000},
5084 -       {0x0000b1bc, 0x00000000},
5085 -       {0x0000b1c0, 0x00000000},
5086 -       {0x0000b1c4, 0x00000000},
5087 -       {0x0000b1c8, 0x00000000},
5088 -       {0x0000b1cc, 0x00000000},
5089 -       {0x0000b1d0, 0x00000000},
5090 -       {0x0000b1d4, 0x00000000},
5091 -       {0x0000b1d8, 0x00000000},
5092 -       {0x0000b1dc, 0x00000000},
5093 -       {0x0000b1e0, 0x00000000},
5094 -       {0x0000b1e4, 0x00000000},
5095 -       {0x0000b1e8, 0x00000000},
5096 -       {0x0000b1ec, 0x00000000},
5097 -       {0x0000b1f0, 0x00000396},
5098 -       {0x0000b1f4, 0x00000396},
5099 -       {0x0000b1f8, 0x00000396},
5100 -       {0x0000b1fc, 0x00000196},
5101 -};
5102 -
5103 -static const u32 ar9300Modes_low_ob_db_tx_gain_table_2p0[][5] = {
5104 -       /* Addr      5G_HT20     5G_HT40     2G_HT40     2G_HT20   */
5105 -       {0x0000a410, 0x000050d9, 0x000050d9, 0x000050d9, 0x000050d9},
5106 -       {0x0000a500, 0x00000000, 0x00000000, 0x00000000, 0x00000000},
5107 -       {0x0000a504, 0x06000003, 0x06000003, 0x04000002, 0x04000002},
5108 -       {0x0000a508, 0x0a000020, 0x0a000020, 0x08000004, 0x08000004},
5109 -       {0x0000a50c, 0x10000023, 0x10000023, 0x0b000200, 0x0b000200},
5110 -       {0x0000a510, 0x16000220, 0x16000220, 0x0f000202, 0x0f000202},
5111 -       {0x0000a514, 0x1c000223, 0x1c000223, 0x12000400, 0x12000400},
5112 -       {0x0000a518, 0x21020220, 0x21020220, 0x16000402, 0x16000402},
5113 -       {0x0000a51c, 0x27020223, 0x27020223, 0x19000404, 0x19000404},
5114 -       {0x0000a520, 0x2b022220, 0x2b022220, 0x1c000603, 0x1c000603},
5115 -       {0x0000a524, 0x2f022222, 0x2f022222, 0x21000a02, 0x21000a02},
5116 -       {0x0000a528, 0x34022225, 0x34022225, 0x25000a04, 0x25000a04},
5117 -       {0x0000a52c, 0x3a02222a, 0x3a02222a, 0x28000a20, 0x28000a20},
5118 -       {0x0000a530, 0x3e02222c, 0x3e02222c, 0x2c000e20, 0x2c000e20},
5119 -       {0x0000a534, 0x4202242a, 0x4202242a, 0x30000e22, 0x30000e22},
5120 -       {0x0000a538, 0x4702244a, 0x4702244a, 0x34000e24, 0x34000e24},
5121 -       {0x0000a53c, 0x4b02244c, 0x4b02244c, 0x38001640, 0x38001640},
5122 -       {0x0000a540, 0x4e02246c, 0x4e02246c, 0x3c001660, 0x3c001660},
5123 -       {0x0000a544, 0x5302266c, 0x5302266c, 0x3f001861, 0x3f001861},
5124 -       {0x0000a548, 0x5702286c, 0x5702286c, 0x43001a81, 0x43001a81},
5125 -       {0x0000a54c, 0x5c04286b, 0x5c04286b, 0x47001a83, 0x47001a83},
5126 -       {0x0000a550, 0x61042a6c, 0x61042a6c, 0x4a001c84, 0x4a001c84},
5127 -       {0x0000a554, 0x66062a6c, 0x66062a6c, 0x4e001ce3, 0x4e001ce3},
5128 -       {0x0000a558, 0x6b062e6c, 0x6b062e6c, 0x52001ce5, 0x52001ce5},
5129 -       {0x0000a55c, 0x7006308c, 0x7006308c, 0x56001ce9, 0x56001ce9},
5130 -       {0x0000a560, 0x730a308a, 0x730a308a, 0x5a001ceb, 0x5a001ceb},
5131 -       {0x0000a564, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
5132 -       {0x0000a568, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
5133 -       {0x0000a56c, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
5134 -       {0x0000a570, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
5135 -       {0x0000a574, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
5136 -       {0x0000a578, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
5137 -       {0x0000a57c, 0x770a308c, 0x770a308c, 0x5d001eec, 0x5d001eec},
5138 -       {0x0000a580, 0x00800000, 0x00800000, 0x00800000, 0x00800000},
5139 -       {0x0000a584, 0x06800003, 0x06800003, 0x04800002, 0x04800002},
5140 -       {0x0000a588, 0x0a800020, 0x0a800020, 0x08800004, 0x08800004},
5141 -       {0x0000a58c, 0x10800023, 0x10800023, 0x0b800200, 0x0b800200},
5142 -       {0x0000a590, 0x16800220, 0x16800220, 0x0f800202, 0x0f800202},
5143 -       {0x0000a594, 0x1c800223, 0x1c800223, 0x12800400, 0x12800400},
5144 -       {0x0000a598, 0x21820220, 0x21820220, 0x16800402, 0x16800402},
5145 -       {0x0000a59c, 0x27820223, 0x27820223, 0x19800404, 0x19800404},
5146 -       {0x0000a5a0, 0x2b822220, 0x2b822220, 0x1c800603, 0x1c800603},
5147 -       {0x0000a5a4, 0x2f822222, 0x2f822222, 0x21800a02, 0x21800a02},
5148 -       {0x0000a5a8, 0x34822225, 0x34822225, 0x25800a04, 0x25800a04},
5149 -       {0x0000a5ac, 0x3a82222a, 0x3a82222a, 0x28800a20, 0x28800a20},
5150 -       {0x0000a5b0, 0x3e82222c, 0x3e82222c, 0x2c800e20, 0x2c800e20},
5151 -       {0x0000a5b4, 0x4282242a, 0x4282242a, 0x30800e22, 0x30800e22},
5152 -       {0x0000a5b8, 0x4782244a, 0x4782244a, 0x34800e24, 0x34800e24},
5153 -       {0x0000a5bc, 0x4b82244c, 0x4b82244c, 0x38801640, 0x38801640},
5154 -       {0x0000a5c0, 0x4e82246c, 0x4e82246c, 0x3c801660, 0x3c801660},
5155 -       {0x0000a5c4, 0x5382266c, 0x5382266c, 0x3f801861, 0x3f801861},
5156 -       {0x0000a5c8, 0x5782286c, 0x5782286c, 0x43801a81, 0x43801a81},
5157 -       {0x0000a5cc, 0x5c84286b, 0x5c84286b, 0x47801a83, 0x47801a83},
5158 -       {0x0000a5d0, 0x61842a6c, 0x61842a6c, 0x4a801c84, 0x4a801c84},
5159 -       {0x0000a5d4, 0x66862a6c, 0x66862a6c, 0x4e801ce3, 0x4e801ce3},
5160 -       {0x0000a5d8, 0x6b862e6c, 0x6b862e6c, 0x52801ce5, 0x52801ce5},
5161 -       {0x0000a5dc, 0x7086308c, 0x7086308c, 0x56801ce9, 0x56801ce9},
5162 -       {0x0000a5e0, 0x738a308a, 0x738a308a, 0x5a801ceb, 0x5a801ceb},
5163 -       {0x0000a5e4, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
5164 -       {0x0000a5e8, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
5165 -       {0x0000a5ec, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
5166 -       {0x0000a5f0, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
5167 -       {0x0000a5f4, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
5168 -       {0x0000a5f8, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
5169 -       {0x0000a5fc, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
5170 -       {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
5171 -       {0x00016048, 0x64000001, 0x64000001, 0x64000001, 0x64000001},
5172 -       {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
5173 -       {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
5174 -       {0x00016448, 0x64000001, 0x64000001, 0x64000001, 0x64000001},
5175 -       {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
5176 -       {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
5177 -       {0x00016848, 0x64000001, 0x64000001, 0x64000001, 0x64000001},
5178 -       {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
5179 -};
5180 -
5181 -static const u32 ar9300_2p0_mac_core[][2] = {
5182 -       /* Addr      allmodes  */
5183 -       {0x00000008, 0x00000000},
5184 -       {0x00000030, 0x00020085},
5185 -       {0x00000034, 0x00000005},
5186 -       {0x00000040, 0x00000000},
5187 -       {0x00000044, 0x00000000},
5188 -       {0x00000048, 0x00000008},
5189 -       {0x0000004c, 0x00000010},
5190 -       {0x00000050, 0x00000000},
5191 -       {0x00001040, 0x002ffc0f},
5192 -       {0x00001044, 0x002ffc0f},
5193 -       {0x00001048, 0x002ffc0f},
5194 -       {0x0000104c, 0x002ffc0f},
5195 -       {0x00001050, 0x002ffc0f},
5196 -       {0x00001054, 0x002ffc0f},
5197 -       {0x00001058, 0x002ffc0f},
5198 -       {0x0000105c, 0x002ffc0f},
5199 -       {0x00001060, 0x002ffc0f},
5200 -       {0x00001064, 0x002ffc0f},
5201 -       {0x000010f0, 0x00000100},
5202 -       {0x00001270, 0x00000000},
5203 -       {0x000012b0, 0x00000000},
5204 -       {0x000012f0, 0x00000000},
5205 -       {0x0000143c, 0x00000000},
5206 -       {0x0000147c, 0x00000000},
5207 -       {0x00008000, 0x00000000},
5208 -       {0x00008004, 0x00000000},
5209 -       {0x00008008, 0x00000000},
5210 -       {0x0000800c, 0x00000000},
5211 -       {0x00008018, 0x00000000},
5212 -       {0x00008020, 0x00000000},
5213 -       {0x00008038, 0x00000000},
5214 -       {0x0000803c, 0x00000000},
5215 -       {0x00008040, 0x00000000},
5216 -       {0x00008044, 0x00000000},
5217 -       {0x00008048, 0x00000000},
5218 -       {0x0000804c, 0xffffffff},
5219 -       {0x00008054, 0x00000000},
5220 -       {0x00008058, 0x00000000},
5221 -       {0x0000805c, 0x000fc78f},
5222 -       {0x00008060, 0x0000000f},
5223 -       {0x00008064, 0x00000000},
5224 -       {0x00008070, 0x00000310},
5225 -       {0x00008074, 0x00000020},
5226 -       {0x00008078, 0x00000000},
5227 -       {0x0000809c, 0x0000000f},
5228 -       {0x000080a0, 0x00000000},
5229 -       {0x000080a4, 0x02ff0000},
5230 -       {0x000080a8, 0x0e070605},
5231 -       {0x000080ac, 0x0000000d},
5232 -       {0x000080b0, 0x00000000},
5233 -       {0x000080b4, 0x00000000},
5234 -       {0x000080b8, 0x00000000},
5235 -       {0x000080bc, 0x00000000},
5236 -       {0x000080c0, 0x2a800000},
5237 -       {0x000080c4, 0x06900168},
5238 -       {0x000080c8, 0x13881c20},
5239 -       {0x000080cc, 0x01f40000},
5240 -       {0x000080d0, 0x00252500},
5241 -       {0x000080d4, 0x00a00000},
5242 -       {0x000080d8, 0x00400000},
5243 -       {0x000080dc, 0x00000000},
5244 -       {0x000080e0, 0xffffffff},
5245 -       {0x000080e4, 0x0000ffff},
5246 -       {0x000080e8, 0x3f3f3f3f},
5247 -       {0x000080ec, 0x00000000},
5248 -       {0x000080f0, 0x00000000},
5249 -       {0x000080f4, 0x00000000},
5250 -       {0x000080fc, 0x00020000},
5251 -       {0x00008100, 0x00000000},
5252 -       {0x00008108, 0x00000052},
5253 -       {0x0000810c, 0x00000000},
5254 -       {0x00008110, 0x00000000},
5255 -       {0x00008114, 0x000007ff},
5256 -       {0x00008118, 0x000000aa},
5257 -       {0x0000811c, 0x00003210},
5258 -       {0x00008124, 0x00000000},
5259 -       {0x00008128, 0x00000000},
5260 -       {0x0000812c, 0x00000000},
5261 -       {0x00008130, 0x00000000},
5262 -       {0x00008134, 0x00000000},
5263 -       {0x00008138, 0x00000000},
5264 -       {0x0000813c, 0x0000ffff},
5265 -       {0x00008144, 0xffffffff},
5266 -       {0x00008168, 0x00000000},
5267 -       {0x0000816c, 0x00000000},
5268 -       {0x00008170, 0x18486200},
5269 -       {0x00008174, 0x33332210},
5270 -       {0x00008178, 0x00000000},
5271 -       {0x0000817c, 0x00020000},
5272 -       {0x000081c0, 0x00000000},
5273 -       {0x000081c4, 0x33332210},
5274 -       {0x000081c8, 0x00000000},
5275 -       {0x000081cc, 0x00000000},
5276 -       {0x000081d4, 0x00000000},
5277 -       {0x000081ec, 0x00000000},
5278 -       {0x000081f0, 0x00000000},
5279 -       {0x000081f4, 0x00000000},
5280 -       {0x000081f8, 0x00000000},
5281 -       {0x000081fc, 0x00000000},
5282 -       {0x00008240, 0x00100000},
5283 -       {0x00008244, 0x0010f424},
5284 -       {0x00008248, 0x00000800},
5285 -       {0x0000824c, 0x0001e848},
5286 -       {0x00008250, 0x00000000},
5287 -       {0x00008254, 0x00000000},
5288 -       {0x00008258, 0x00000000},
5289 -       {0x0000825c, 0x40000000},
5290 -       {0x00008260, 0x00080922},
5291 -       {0x00008264, 0x98a00010},
5292 -       {0x00008268, 0xffffffff},
5293 -       {0x0000826c, 0x0000ffff},
5294 -       {0x00008270, 0x00000000},
5295 -       {0x00008274, 0x40000000},
5296 -       {0x00008278, 0x003e4180},
5297 -       {0x0000827c, 0x00000004},
5298 -       {0x00008284, 0x0000002c},
5299 -       {0x00008288, 0x0000002c},
5300 -       {0x0000828c, 0x000000ff},
5301 -       {0x00008294, 0x00000000},
5302 -       {0x00008298, 0x00000000},
5303 -       {0x0000829c, 0x00000000},
5304 -       {0x00008300, 0x00000140},
5305 -       {0x00008314, 0x00000000},
5306 -       {0x0000831c, 0x0000010d},
5307 -       {0x00008328, 0x00000000},
5308 -       {0x0000832c, 0x00000007},
5309 -       {0x00008330, 0x00000302},
5310 -       {0x00008334, 0x00000700},
5311 -       {0x00008338, 0x00ff0000},
5312 -       {0x0000833c, 0x02400000},
5313 -       {0x00008340, 0x000107ff},
5314 -       {0x00008344, 0xaa48105b},
5315 -       {0x00008348, 0x008f0000},
5316 -       {0x0000835c, 0x00000000},
5317 -       {0x00008360, 0xffffffff},
5318 -       {0x00008364, 0xffffffff},
5319 -       {0x00008368, 0x00000000},
5320 -       {0x00008370, 0x00000000},
5321 -       {0x00008374, 0x000000ff},
5322 -       {0x00008378, 0x00000000},
5323 -       {0x0000837c, 0x00000000},
5324 -       {0x00008380, 0xffffffff},
5325 -       {0x00008384, 0xffffffff},
5326 -       {0x00008390, 0xffffffff},
5327 -       {0x00008394, 0xffffffff},
5328 -       {0x00008398, 0x00000000},
5329 -       {0x0000839c, 0x00000000},
5330 -       {0x000083a0, 0x00000000},
5331 -       {0x000083a4, 0x0000fa14},
5332 -       {0x000083a8, 0x000f0c00},
5333 -       {0x000083ac, 0x33332210},
5334 -       {0x000083b0, 0x33332210},
5335 -       {0x000083b4, 0x33332210},
5336 -       {0x000083b8, 0x33332210},
5337 -       {0x000083bc, 0x00000000},
5338 -       {0x000083c0, 0x00000000},
5339 -       {0x000083c4, 0x00000000},
5340 -       {0x000083c8, 0x00000000},
5341 -       {0x000083cc, 0x00000200},
5342 -       {0x000083d0, 0x000301ff},
5343 -};
5344 -
5345 -static const u32 ar9300Common_wo_xlna_rx_gain_table_2p0[][2] = {
5346 -       /* Addr      allmodes  */
5347 -       {0x0000a000, 0x00010000},
5348 -       {0x0000a004, 0x00030002},
5349 -       {0x0000a008, 0x00050004},
5350 -       {0x0000a00c, 0x00810080},
5351 -       {0x0000a010, 0x00830082},
5352 -       {0x0000a014, 0x01810180},
5353 -       {0x0000a018, 0x01830182},
5354 -       {0x0000a01c, 0x01850184},
5355 -       {0x0000a020, 0x01890188},
5356 -       {0x0000a024, 0x018b018a},
5357 -       {0x0000a028, 0x018d018c},
5358 -       {0x0000a02c, 0x03820190},
5359 -       {0x0000a030, 0x03840383},
5360 -       {0x0000a034, 0x03880385},
5361 -       {0x0000a038, 0x038a0389},
5362 -       {0x0000a03c, 0x038c038b},
5363 -       {0x0000a040, 0x0390038d},
5364 -       {0x0000a044, 0x03920391},
5365 -       {0x0000a048, 0x03940393},
5366 -       {0x0000a04c, 0x03960395},
5367 -       {0x0000a050, 0x00000000},
5368 -       {0x0000a054, 0x00000000},
5369 -       {0x0000a058, 0x00000000},
5370 -       {0x0000a05c, 0x00000000},
5371 -       {0x0000a060, 0x00000000},
5372 -       {0x0000a064, 0x00000000},
5373 -       {0x0000a068, 0x00000000},
5374 -       {0x0000a06c, 0x00000000},
5375 -       {0x0000a070, 0x00000000},
5376 -       {0x0000a074, 0x00000000},
5377 -       {0x0000a078, 0x00000000},
5378 -       {0x0000a07c, 0x00000000},
5379 -       {0x0000a080, 0x29292929},
5380 -       {0x0000a084, 0x29292929},
5381 -       {0x0000a088, 0x29292929},
5382 -       {0x0000a08c, 0x29292929},
5383 -       {0x0000a090, 0x22292929},
5384 -       {0x0000a094, 0x1d1d2222},
5385 -       {0x0000a098, 0x0c111117},
5386 -       {0x0000a09c, 0x00030303},
5387 -       {0x0000a0a0, 0x00000000},
5388 -       {0x0000a0a4, 0x00000000},
5389 -       {0x0000a0a8, 0x00000000},
5390 -       {0x0000a0ac, 0x00000000},
5391 -       {0x0000a0b0, 0x00000000},
5392 -       {0x0000a0b4, 0x00000000},
5393 -       {0x0000a0b8, 0x00000000},
5394 -       {0x0000a0bc, 0x00000000},
5395 -       {0x0000a0c0, 0x001f0000},
5396 -       {0x0000a0c4, 0x01000101},
5397 -       {0x0000a0c8, 0x011e011f},
5398 -       {0x0000a0cc, 0x011c011d},
5399 -       {0x0000a0d0, 0x02030204},
5400 -       {0x0000a0d4, 0x02010202},
5401 -       {0x0000a0d8, 0x021f0200},
5402 -       {0x0000a0dc, 0x0302021e},
5403 -       {0x0000a0e0, 0x03000301},
5404 -       {0x0000a0e4, 0x031e031f},
5405 -       {0x0000a0e8, 0x0402031d},
5406 -       {0x0000a0ec, 0x04000401},
5407 -       {0x0000a0f0, 0x041e041f},
5408 -       {0x0000a0f4, 0x0502041d},
5409 -       {0x0000a0f8, 0x05000501},
5410 -       {0x0000a0fc, 0x051e051f},
5411 -       {0x0000a100, 0x06010602},
5412 -       {0x0000a104, 0x061f0600},
5413 -       {0x0000a108, 0x061d061e},
5414 -       {0x0000a10c, 0x07020703},
5415 -       {0x0000a110, 0x07000701},
5416 -       {0x0000a114, 0x00000000},
5417 -       {0x0000a118, 0x00000000},
5418 -       {0x0000a11c, 0x00000000},
5419 -       {0x0000a120, 0x00000000},
5420 -       {0x0000a124, 0x00000000},
5421 -       {0x0000a128, 0x00000000},
5422 -       {0x0000a12c, 0x00000000},
5423 -       {0x0000a130, 0x00000000},
5424 -       {0x0000a134, 0x00000000},
5425 -       {0x0000a138, 0x00000000},
5426 -       {0x0000a13c, 0x00000000},
5427 -       {0x0000a140, 0x001f0000},
5428 -       {0x0000a144, 0x01000101},
5429 -       {0x0000a148, 0x011e011f},
5430 -       {0x0000a14c, 0x011c011d},
5431 -       {0x0000a150, 0x02030204},
5432 -       {0x0000a154, 0x02010202},
5433 -       {0x0000a158, 0x021f0200},
5434 -       {0x0000a15c, 0x0302021e},
5435 -       {0x0000a160, 0x03000301},
5436 -       {0x0000a164, 0x031e031f},
5437 -       {0x0000a168, 0x0402031d},
5438 -       {0x0000a16c, 0x04000401},
5439 -       {0x0000a170, 0x041e041f},
5440 -       {0x0000a174, 0x0502041d},
5441 -       {0x0000a178, 0x05000501},
5442 -       {0x0000a17c, 0x051e051f},
5443 -       {0x0000a180, 0x06010602},
5444 -       {0x0000a184, 0x061f0600},
5445 -       {0x0000a188, 0x061d061e},
5446 -       {0x0000a18c, 0x07020703},
5447 -       {0x0000a190, 0x07000701},
5448 -       {0x0000a194, 0x00000000},
5449 -       {0x0000a198, 0x00000000},
5450 -       {0x0000a19c, 0x00000000},
5451 -       {0x0000a1a0, 0x00000000},
5452 -       {0x0000a1a4, 0x00000000},
5453 -       {0x0000a1a8, 0x00000000},
5454 -       {0x0000a1ac, 0x00000000},
5455 -       {0x0000a1b0, 0x00000000},
5456 -       {0x0000a1b4, 0x00000000},
5457 -       {0x0000a1b8, 0x00000000},
5458 -       {0x0000a1bc, 0x00000000},
5459 -       {0x0000a1c0, 0x00000000},
5460 -       {0x0000a1c4, 0x00000000},
5461 -       {0x0000a1c8, 0x00000000},
5462 -       {0x0000a1cc, 0x00000000},
5463 -       {0x0000a1d0, 0x00000000},
5464 -       {0x0000a1d4, 0x00000000},
5465 -       {0x0000a1d8, 0x00000000},
5466 -       {0x0000a1dc, 0x00000000},
5467 -       {0x0000a1e0, 0x00000000},
5468 -       {0x0000a1e4, 0x00000000},
5469 -       {0x0000a1e8, 0x00000000},
5470 -       {0x0000a1ec, 0x00000000},
5471 -       {0x0000a1f0, 0x00000396},
5472 -       {0x0000a1f4, 0x00000396},
5473 -       {0x0000a1f8, 0x00000396},
5474 -       {0x0000a1fc, 0x00000196},
5475 -       {0x0000b000, 0x00010000},
5476 -       {0x0000b004, 0x00030002},
5477 -       {0x0000b008, 0x00050004},
5478 -       {0x0000b00c, 0x00810080},
5479 -       {0x0000b010, 0x00830082},
5480 -       {0x0000b014, 0x01810180},
5481 -       {0x0000b018, 0x01830182},
5482 -       {0x0000b01c, 0x01850184},
5483 -       {0x0000b020, 0x02810280},
5484 -       {0x0000b024, 0x02830282},
5485 -       {0x0000b028, 0x02850284},
5486 -       {0x0000b02c, 0x02890288},
5487 -       {0x0000b030, 0x028b028a},
5488 -       {0x0000b034, 0x0388028c},
5489 -       {0x0000b038, 0x038a0389},
5490 -       {0x0000b03c, 0x038c038b},
5491 -       {0x0000b040, 0x0390038d},
5492 -       {0x0000b044, 0x03920391},
5493 -       {0x0000b048, 0x03940393},
5494 -       {0x0000b04c, 0x03960395},
5495 -       {0x0000b050, 0x00000000},
5496 -       {0x0000b054, 0x00000000},
5497 -       {0x0000b058, 0x00000000},
5498 -       {0x0000b05c, 0x00000000},
5499 -       {0x0000b060, 0x00000000},
5500 -       {0x0000b064, 0x00000000},
5501 -       {0x0000b068, 0x00000000},
5502 -       {0x0000b06c, 0x00000000},
5503 -       {0x0000b070, 0x00000000},
5504 -       {0x0000b074, 0x00000000},
5505 -       {0x0000b078, 0x00000000},
5506 -       {0x0000b07c, 0x00000000},
5507 -       {0x0000b080, 0x32323232},
5508 -       {0x0000b084, 0x2f2f3232},
5509 -       {0x0000b088, 0x23282a2d},
5510 -       {0x0000b08c, 0x1c1e2123},
5511 -       {0x0000b090, 0x14171919},
5512 -       {0x0000b094, 0x0e0e1214},
5513 -       {0x0000b098, 0x03050707},
5514 -       {0x0000b09c, 0x00030303},
5515 -       {0x0000b0a0, 0x00000000},
5516 -       {0x0000b0a4, 0x00000000},
5517 -       {0x0000b0a8, 0x00000000},
5518 -       {0x0000b0ac, 0x00000000},
5519 -       {0x0000b0b0, 0x00000000},
5520 -       {0x0000b0b4, 0x00000000},
5521 -       {0x0000b0b8, 0x00000000},
5522 -       {0x0000b0bc, 0x00000000},
5523 -       {0x0000b0c0, 0x003f0020},
5524 -       {0x0000b0c4, 0x00400041},
5525 -       {0x0000b0c8, 0x0140005f},
5526 -       {0x0000b0cc, 0x0160015f},
5527 -       {0x0000b0d0, 0x017e017f},
5528 -       {0x0000b0d4, 0x02410242},
5529 -       {0x0000b0d8, 0x025f0240},
5530 -       {0x0000b0dc, 0x027f0260},
5531 -       {0x0000b0e0, 0x0341027e},
5532 -       {0x0000b0e4, 0x035f0340},
5533 -       {0x0000b0e8, 0x037f0360},
5534 -       {0x0000b0ec, 0x04400441},
5535 -       {0x0000b0f0, 0x0460045f},
5536 -       {0x0000b0f4, 0x0541047f},
5537 -       {0x0000b0f8, 0x055f0540},
5538 -       {0x0000b0fc, 0x057f0560},
5539 -       {0x0000b100, 0x06400641},
5540 -       {0x0000b104, 0x0660065f},
5541 -       {0x0000b108, 0x067e067f},
5542 -       {0x0000b10c, 0x07410742},
5543 -       {0x0000b110, 0x075f0740},
5544 -       {0x0000b114, 0x077f0760},
5545 -       {0x0000b118, 0x07800781},
5546 -       {0x0000b11c, 0x07a0079f},
5547 -       {0x0000b120, 0x07c107bf},
5548 -       {0x0000b124, 0x000007c0},
5549 -       {0x0000b128, 0x00000000},
5550 -       {0x0000b12c, 0x00000000},
5551 -       {0x0000b130, 0x00000000},
5552 -       {0x0000b134, 0x00000000},
5553 -       {0x0000b138, 0x00000000},
5554 -       {0x0000b13c, 0x00000000},
5555 -       {0x0000b140, 0x003f0020},
5556 -       {0x0000b144, 0x00400041},
5557 -       {0x0000b148, 0x0140005f},
5558 -       {0x0000b14c, 0x0160015f},
5559 -       {0x0000b150, 0x017e017f},
5560 -       {0x0000b154, 0x02410242},
5561 -       {0x0000b158, 0x025f0240},
5562 -       {0x0000b15c, 0x027f0260},
5563 -       {0x0000b160, 0x0341027e},
5564 -       {0x0000b164, 0x035f0340},
5565 -       {0x0000b168, 0x037f0360},
5566 -       {0x0000b16c, 0x04400441},
5567 -       {0x0000b170, 0x0460045f},
5568 -       {0x0000b174, 0x0541047f},
5569 -       {0x0000b178, 0x055f0540},
5570 -       {0x0000b17c, 0x057f0560},
5571 -       {0x0000b180, 0x06400641},
5572 -       {0x0000b184, 0x0660065f},
5573 -       {0x0000b188, 0x067e067f},
5574 -       {0x0000b18c, 0x07410742},
5575 -       {0x0000b190, 0x075f0740},
5576 -       {0x0000b194, 0x077f0760},
5577 -       {0x0000b198, 0x07800781},
5578 -       {0x0000b19c, 0x07a0079f},
5579 -       {0x0000b1a0, 0x07c107bf},
5580 -       {0x0000b1a4, 0x000007c0},
5581 -       {0x0000b1a8, 0x00000000},
5582 -       {0x0000b1ac, 0x00000000},
5583 -       {0x0000b1b0, 0x00000000},
5584 -       {0x0000b1b4, 0x00000000},
5585 -       {0x0000b1b8, 0x00000000},
5586 -       {0x0000b1bc, 0x00000000},
5587 -       {0x0000b1c0, 0x00000000},
5588 -       {0x0000b1c4, 0x00000000},
5589 -       {0x0000b1c8, 0x00000000},
5590 -       {0x0000b1cc, 0x00000000},
5591 -       {0x0000b1d0, 0x00000000},
5592 -       {0x0000b1d4, 0x00000000},
5593 -       {0x0000b1d8, 0x00000000},
5594 -       {0x0000b1dc, 0x00000000},
5595 -       {0x0000b1e0, 0x00000000},
5596 -       {0x0000b1e4, 0x00000000},
5597 -       {0x0000b1e8, 0x00000000},
5598 -       {0x0000b1ec, 0x00000000},
5599 -       {0x0000b1f0, 0x00000396},
5600 -       {0x0000b1f4, 0x00000396},
5601 -       {0x0000b1f8, 0x00000396},
5602 -       {0x0000b1fc, 0x00000196},
5603 -};
5604 -
5605 -static const u32 ar9300_2p0_soc_preamble[][2] = {
5606 -       /* Addr      allmodes  */
5607 -       {0x000040a4, 0x00a0c1c9},
5608 -       {0x00007008, 0x00000000},
5609 -       {0x00007020, 0x00000000},
5610 -       {0x00007034, 0x00000002},
5611 -       {0x00007038, 0x000004c2},
5612 -};
5613 -
5614 -static const u32 ar9300PciePhy_pll_on_clkreq_disable_L1_2p0[][2] = {
5615 -       /* Addr      allmodes  */
5616 -       {0x00004040, 0x08212e5e},
5617 -       {0x00004040, 0x0008003b},
5618 -       {0x00004044, 0x00000000},
5619 -};
5620 -
5621 -static const u32 ar9300PciePhy_clkreq_enable_L1_2p0[][2] = {
5622 -       /* Addr      allmodes  */
5623 -       {0x00004040, 0x08253e5e},
5624 -       {0x00004040, 0x0008003b},
5625 -       {0x00004044, 0x00000000},
5626 -};
5627 -
5628 -static const u32 ar9300PciePhy_clkreq_disable_L1_2p0[][2] = {
5629 -       /* Addr      allmodes  */
5630 -       {0x00004040, 0x08213e5e},
5631 -       {0x00004040, 0x0008003b},
5632 -       {0x00004044, 0x00000000},
5633 -};
5634 -
5635 -#endif /* INITVALS_9003_H */
5636 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
5637 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
5638 @@ -90,6 +90,8 @@ static bool ar9003_hw_get_isr(struct ath
5639                                   MAP_ISR_S2_CST);
5640                         mask2 |= ((isr2 & AR_ISR_S2_TSFOOR) >>
5641                                   MAP_ISR_S2_TSFOOR);
5642 +                       mask2 |= ((isr2 & AR_ISR_S2_BB_WATCHDOG) >>
5643 +                                 MAP_ISR_S2_BB_WATCHDOG);
5644  
5645                         if (!(pCap->hw_caps & ATH9K_HW_CAP_RAC_SUPPORTED)) {
5646                                 REG_WRITE(ah, AR_ISR_S2, isr2);
5647 @@ -167,6 +169,9 @@ static bool ar9003_hw_get_isr(struct ath
5648  
5649                         (void) REG_READ(ah, AR_ISR);
5650                 }
5651 +
5652 +               if (*masked & ATH9K_INT_BB_WATCHDOG)
5653 +                       ar9003_hw_bb_watchdog_read(ah);
5654         }
5655  
5656         if (sync_cause) {
5657 @@ -229,7 +234,8 @@ static void ar9003_hw_fill_txdesc(struct
5658  }
5659  
5660  static int ar9003_hw_proc_txdesc(struct ath_hw *ah, void *ds,
5661 -                                struct ath_tx_status *ts)
5662 +                                struct ath_tx_status *ts,
5663 +                                void *txs_desc)
5664  {
5665         struct ar9003_txs *ads;
5666  
5667 @@ -300,6 +306,7 @@ static int ar9003_hw_proc_txdesc(struct 
5668  
5669         ts->tid = MS(ads->status8, AR_TxTid);
5670  
5671 +       memcpy(txs_desc, ads, sizeof(*ads));
5672         memset(ads, 0, sizeof(*ads));
5673  
5674         return 0;
5675 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.h
5676 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.h
5677 @@ -47,6 +47,7 @@
5678  #define MAP_ISR_S2_DTIMSYNC     7
5679  #define MAP_ISR_S2_DTIM         7
5680  #define MAP_ISR_S2_TSFOOR       4
5681 +#define MAP_ISR_S2_BB_WATCHDOG  6
5682  
5683  #define AR9003TXC_CONST(_ds) ((const struct ar9003_txc *) _ds)
5684  
5685 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.c
5686 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.c
5687 @@ -1132,3 +1132,122 @@ void ar9003_hw_attach_phy_ops(struct ath
5688         priv_ops->do_getnf = ar9003_hw_do_getnf;
5689         priv_ops->loadnf = ar9003_hw_loadnf;
5690  }
5691 +
5692 +void ar9003_hw_bb_watchdog_config(struct ath_hw *ah)
5693 +{
5694 +       struct ath_common *common = ath9k_hw_common(ah);
5695 +       u32 idle_tmo_ms = ah->bb_watchdog_timeout_ms;
5696 +       u32 val, idle_count;
5697 +
5698 +       if (!idle_tmo_ms) {
5699 +               /* disable IRQ, disable chip-reset for BB panic */
5700 +               REG_WRITE(ah, AR_PHY_WATCHDOG_CTL_2,
5701 +                         REG_READ(ah, AR_PHY_WATCHDOG_CTL_2) &
5702 +                         ~(AR_PHY_WATCHDOG_RST_ENABLE |
5703 +                           AR_PHY_WATCHDOG_IRQ_ENABLE));
5704 +
5705 +               /* disable watchdog in non-IDLE mode, disable in IDLE mode */
5706 +               REG_WRITE(ah, AR_PHY_WATCHDOG_CTL_1,
5707 +                         REG_READ(ah, AR_PHY_WATCHDOG_CTL_1) &
5708 +                         ~(AR_PHY_WATCHDOG_NON_IDLE_ENABLE |
5709 +                           AR_PHY_WATCHDOG_IDLE_ENABLE));
5710 +
5711 +               ath_print(common, ATH_DBG_RESET, "Disabled BB Watchdog\n");
5712 +               return;
5713 +       }
5714 +
5715 +       /* enable IRQ, disable chip-reset for BB watchdog */
5716 +       val = REG_READ(ah, AR_PHY_WATCHDOG_CTL_2) & AR_PHY_WATCHDOG_CNTL2_MASK;
5717 +       REG_WRITE(ah, AR_PHY_WATCHDOG_CTL_2,
5718 +                 (val | AR_PHY_WATCHDOG_IRQ_ENABLE) &
5719 +                 ~AR_PHY_WATCHDOG_RST_ENABLE);
5720 +
5721 +       /* bound limit to 10 secs */
5722 +       if (idle_tmo_ms > 10000)
5723 +               idle_tmo_ms = 10000;
5724 +
5725 +       /*
5726 +        * The time unit for watchdog event is 2^15 44/88MHz cycles.
5727 +        *
5728 +        * For HT20 we have a time unit of 2^15/44 MHz = .74 ms per tick
5729 +        * For HT40 we have a time unit of 2^15/88 MHz = .37 ms per tick
5730 +        *
5731 +        * Given we use fast clock now in 5 GHz, these time units should
5732 +        * be common for both 2 GHz and 5 GHz.
5733 +        */
5734 +       idle_count = (100 * idle_tmo_ms) / 74;
5735 +       if (ah->curchan && IS_CHAN_HT40(ah->curchan))
5736 +               idle_count = (100 * idle_tmo_ms) / 37;
5737 +
5738 +       /*
5739 +        * enable watchdog in non-IDLE mode, disable in IDLE mode,
5740 +        * set idle time-out.
5741 +        */
5742 +       REG_WRITE(ah, AR_PHY_WATCHDOG_CTL_1,
5743 +                 AR_PHY_WATCHDOG_NON_IDLE_ENABLE |
5744 +                 AR_PHY_WATCHDOG_IDLE_MASK |
5745 +                 (AR_PHY_WATCHDOG_NON_IDLE_MASK & (idle_count << 2)));
5746 +
5747 +       ath_print(common, ATH_DBG_RESET,
5748 +                 "Enabled BB Watchdog timeout (%u ms)\n",
5749 +                 idle_tmo_ms);
5750 +}
5751 +
5752 +void ar9003_hw_bb_watchdog_read(struct ath_hw *ah)
5753 +{
5754 +       /*
5755 +        * we want to avoid printing in ISR context so we save the
5756 +        * watchdog status to be printed later in bottom half context.
5757 +        */
5758 +       ah->bb_watchdog_last_status = REG_READ(ah, AR_PHY_WATCHDOG_STATUS);
5759 +
5760 +       /*
5761 +        * the watchdog timer should reset on status read but to be sure
5762 +        * sure we write 0 to the watchdog status bit.
5763 +        */
5764 +       REG_WRITE(ah, AR_PHY_WATCHDOG_STATUS,
5765 +                 ah->bb_watchdog_last_status & ~AR_PHY_WATCHDOG_STATUS_CLR);
5766 +}
5767 +
5768 +void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah)
5769 +{
5770 +       struct ath_common *common = ath9k_hw_common(ah);
5771 +       u32 rxc_pcnt = 0, rxf_pcnt = 0, txf_pcnt = 0, status;
5772 +
5773 +       if (likely(!(common->debug_mask & ATH_DBG_RESET)))
5774 +               return;
5775 +
5776 +       status = ah->bb_watchdog_last_status;
5777 +       ath_print(common, ATH_DBG_RESET,
5778 +                 "\n==== BB update: BB status=0x%08x ====\n", status);
5779 +       ath_print(common, ATH_DBG_RESET,
5780 +                 "** BB state: wd=%u det=%u rdar=%u rOFDM=%d "
5781 +                 "rCCK=%u tOFDM=%u tCCK=%u agc=%u src=%u **\n",
5782 +                 MS(status, AR_PHY_WATCHDOG_INFO),
5783 +                 MS(status, AR_PHY_WATCHDOG_DET_HANG),
5784 +                 MS(status, AR_PHY_WATCHDOG_RADAR_SM),
5785 +                 MS(status, AR_PHY_WATCHDOG_RX_OFDM_SM),
5786 +                 MS(status, AR_PHY_WATCHDOG_RX_CCK_SM),
5787 +                 MS(status, AR_PHY_WATCHDOG_TX_OFDM_SM),
5788 +                 MS(status, AR_PHY_WATCHDOG_TX_CCK_SM),
5789 +                 MS(status, AR_PHY_WATCHDOG_AGC_SM),
5790 +                 MS(status,AR_PHY_WATCHDOG_SRCH_SM));
5791 +
5792 +       ath_print(common, ATH_DBG_RESET,
5793 +                 "** BB WD cntl: cntl1=0x%08x cntl2=0x%08x **\n",
5794 +                 REG_READ(ah, AR_PHY_WATCHDOG_CTL_1),
5795 +                 REG_READ(ah, AR_PHY_WATCHDOG_CTL_2));
5796 +       ath_print(common, ATH_DBG_RESET,
5797 +                 "** BB mode: BB_gen_controls=0x%08x **\n",
5798 +                 REG_READ(ah, AR_PHY_GEN_CTRL));
5799 +
5800 +       if (ath9k_hw_GetMibCycleCountsPct(ah, &rxc_pcnt, &rxf_pcnt, &txf_pcnt))
5801 +               ath_print(common, ATH_DBG_RESET,
5802 +                         "** BB busy times: rx_clear=%d%%, "
5803 +                         "rx_frame=%d%%, tx_frame=%d%% **\n",
5804 +                         rxc_pcnt, rxf_pcnt, txf_pcnt);
5805 +
5806 +       ath_print(common, ATH_DBG_RESET,
5807 +                 "==== BB update: done ====\n\n");
5808 +}
5809 +EXPORT_SYMBOL(ar9003_hw_bb_watchdog_dbg_info);
5810 --- a/drivers/net/wireless/ath/ath9k/ar9003_phy.h
5811 +++ b/drivers/net/wireless/ath/ath9k/ar9003_phy.h
5812 @@ -483,10 +483,10 @@
5813  #define AR_PHY_TX_IQCAL_STATUS_B0   (AR_SM_BASE + 0x48c)
5814  #define AR_PHY_TX_IQCAL_CORR_COEFF_01_B0    (AR_SM_BASE + 0x450)
5815  
5816 -#define AR_PHY_PANIC_WD_STATUS      (AR_SM_BASE + 0x5c0)
5817 -#define AR_PHY_PANIC_WD_CTL_1       (AR_SM_BASE + 0x5c4)
5818 -#define AR_PHY_PANIC_WD_CTL_2       (AR_SM_BASE + 0x5c8)
5819 -#define AR_PHY_BT_CTL               (AR_SM_BASE + 0x5cc)
5820 +#define AR_PHY_WATCHDOG_STATUS      (AR_SM_BASE + 0x5c0)
5821 +#define AR_PHY_WATCHDOG_CTL_1       (AR_SM_BASE + 0x5c4)
5822 +#define AR_PHY_WATCHDOG_CTL_2       (AR_SM_BASE + 0x5c8)
5823 +#define AR_PHY_WATCHDOG_CTL         (AR_SM_BASE + 0x5cc)
5824  #define AR_PHY_ONLY_WARMRESET       (AR_SM_BASE + 0x5d0)
5825  #define AR_PHY_ONLY_CTL             (AR_SM_BASE + 0x5d4)
5826  #define AR_PHY_ECO_CTRL             (AR_SM_BASE + 0x5dc)
5827 @@ -812,35 +812,35 @@
5828  #define AR_PHY_CAL_MEAS_2_9300_10(_i) (AR_PHY_IQ_ADC_MEAS_2_B0_9300_10 + (AR_PHY_CHAIN_OFFSET * (_i)))
5829  #define AR_PHY_CAL_MEAS_3_9300_10(_i) (AR_PHY_IQ_ADC_MEAS_3_B0_9300_10 + (AR_PHY_CHAIN_OFFSET * (_i)))
5830  
5831 -#define AR_PHY_BB_PANIC_NON_IDLE_ENABLE 0x00000001
5832 -#define AR_PHY_BB_PANIC_IDLE_ENABLE     0x00000002
5833 -#define AR_PHY_BB_PANIC_IDLE_MASK       0xFFFF0000
5834 -#define AR_PHY_BB_PANIC_NON_IDLE_MASK   0x0000FFFC
5835 -
5836 -#define AR_PHY_BB_PANIC_RST_ENABLE      0x00000002
5837 -#define AR_PHY_BB_PANIC_IRQ_ENABLE      0x00000004
5838 -#define AR_PHY_BB_PANIC_CNTL2_MASK      0xFFFFFFF9
5839 -
5840 -#define AR_PHY_BB_WD_STATUS             0x00000007
5841 -#define AR_PHY_BB_WD_STATUS_S           0
5842 -#define AR_PHY_BB_WD_DET_HANG           0x00000008
5843 -#define AR_PHY_BB_WD_DET_HANG_S         3
5844 -#define AR_PHY_BB_WD_RADAR_SM           0x000000F0
5845 -#define AR_PHY_BB_WD_RADAR_SM_S         4
5846 -#define AR_PHY_BB_WD_RX_OFDM_SM         0x00000F00
5847 -#define AR_PHY_BB_WD_RX_OFDM_SM_S       8
5848 -#define AR_PHY_BB_WD_RX_CCK_SM          0x0000F000
5849 -#define AR_PHY_BB_WD_RX_CCK_SM_S        12
5850 -#define AR_PHY_BB_WD_TX_OFDM_SM         0x000F0000
5851 -#define AR_PHY_BB_WD_TX_OFDM_SM_S       16
5852 -#define AR_PHY_BB_WD_TX_CCK_SM          0x00F00000
5853 -#define AR_PHY_BB_WD_TX_CCK_SM_S        20
5854 -#define AR_PHY_BB_WD_AGC_SM             0x0F000000
5855 -#define AR_PHY_BB_WD_AGC_SM_S           24
5856 -#define AR_PHY_BB_WD_SRCH_SM            0xF0000000
5857 -#define AR_PHY_BB_WD_SRCH_SM_S          28
5858 +#define AR_PHY_WATCHDOG_NON_IDLE_ENABLE    0x00000001
5859 +#define AR_PHY_WATCHDOG_IDLE_ENABLE        0x00000002
5860 +#define AR_PHY_WATCHDOG_IDLE_MASK          0xFFFF0000
5861 +#define AR_PHY_WATCHDOG_NON_IDLE_MASK      0x0000FFFC
5862 +
5863 +#define AR_PHY_WATCHDOG_RST_ENABLE         0x00000002
5864 +#define AR_PHY_WATCHDOG_IRQ_ENABLE         0x00000004
5865 +#define AR_PHY_WATCHDOG_CNTL2_MASK         0xFFFFFFF9
5866 +
5867 +#define AR_PHY_WATCHDOG_INFO               0x00000007
5868 +#define AR_PHY_WATCHDOG_INFO_S             0
5869 +#define AR_PHY_WATCHDOG_DET_HANG           0x00000008
5870 +#define AR_PHY_WATCHDOG_DET_HANG_S         3
5871 +#define AR_PHY_WATCHDOG_RADAR_SM           0x000000F0
5872 +#define AR_PHY_WATCHDOG_RADAR_SM_S         4
5873 +#define AR_PHY_WATCHDOG_RX_OFDM_SM         0x00000F00
5874 +#define AR_PHY_WATCHDOG_RX_OFDM_SM_S       8
5875 +#define AR_PHY_WATCHDOG_RX_CCK_SM          0x0000F000
5876 +#define AR_PHY_WATCHDOG_RX_CCK_SM_S        12
5877 +#define AR_PHY_WATCHDOG_TX_OFDM_SM         0x000F0000
5878 +#define AR_PHY_WATCHDOG_TX_OFDM_SM_S       16
5879 +#define AR_PHY_WATCHDOG_TX_CCK_SM          0x00F00000
5880 +#define AR_PHY_WATCHDOG_TX_CCK_SM_S        20
5881 +#define AR_PHY_WATCHDOG_AGC_SM             0x0F000000
5882 +#define AR_PHY_WATCHDOG_AGC_SM_S           24
5883 +#define AR_PHY_WATCHDOG_SRCH_SM            0xF0000000
5884 +#define AR_PHY_WATCHDOG_SRCH_SM_S          28
5885  
5886 -#define AR_PHY_BB_WD_STATUS_CLR         0x00000008
5887 +#define AR_PHY_WATCHDOG_STATUS_CLR         0x00000008
5888  
5889  void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx);
5890  
5891 --- a/drivers/net/wireless/ath/ath9k/ath9k.h
5892 +++ b/drivers/net/wireless/ath/ath9k/ath9k.h
5893 @@ -23,6 +23,7 @@
5894  
5895  #include "debug.h"
5896  #include "common.h"
5897 +#include "pktlog.h"
5898  
5899  /*
5900   * Header for the ath9k.ko driver core *only* -- hw code nor any other driver
5901 @@ -206,6 +207,69 @@ struct ath_txq {
5902         u8 txq_tailidx;
5903  };
5904  
5905 +struct ath_atx_ac {
5906 +       int sched;
5907 +       int qnum;
5908 +       struct list_head list;
5909 +       struct list_head tid_q;
5910 +};
5911 +
5912 +struct ath_buf_state {
5913 +       int bfs_nframes;
5914 +       u16 bfs_al;
5915 +       u16 bfs_frmlen;
5916 +       int bfs_seqno;
5917 +       int bfs_tidno;
5918 +       int bfs_retries;
5919 +       u8 bf_type;
5920 +       u32 bfs_keyix;
5921 +       enum ath9k_key_type bfs_keytype;
5922 +};
5923 +
5924 +struct ath_buf {
5925 +       struct list_head list;
5926 +       struct ath_buf *bf_lastbf;      /* last buf of this unit (a frame or
5927 +                                          an aggregate) */
5928 +       struct ath_buf *bf_next;        /* next subframe in the aggregate */
5929 +       struct sk_buff *bf_mpdu;        /* enclosing frame structure */
5930 +       void *bf_desc;                  /* virtual addr of desc */
5931 +       dma_addr_t bf_daddr;            /* physical addr of desc */
5932 +       dma_addr_t bf_buf_addr;         /* physical addr of data buffer */
5933 +       bool bf_stale;
5934 +       bool bf_isnullfunc;
5935 +       bool bf_tx_aborted;
5936 +       u16 bf_flags;
5937 +       struct ath_buf_state bf_state;
5938 +       dma_addr_t bf_dmacontext;
5939 +       struct ath_wiphy *aphy;
5940 +};
5941 +
5942 +struct ath_atx_tid {
5943 +       struct list_head list;
5944 +       struct list_head buf_q;
5945 +       struct ath_node *an;
5946 +       struct ath_atx_ac *ac;
5947 +       struct ath_buf *tx_buf[ATH_TID_MAX_BUFS];
5948 +       u16 seq_start;
5949 +       u16 seq_next;
5950 +       u16 baw_size;
5951 +       int tidno;
5952 +       int baw_head;   /* first un-acked tx buffer */
5953 +       int baw_tail;   /* next unused tx buffer slot */
5954 +       int sched;
5955 +       int paused;
5956 +       u8 state;
5957 +};
5958 +
5959 +struct ath_node {
5960 +       struct ath_common *common;
5961 +       struct ath_atx_tid tid[WME_NUM_TID];
5962 +       struct ath_atx_ac ac[WME_NUM_AC];
5963 +       u16 maxampdu;
5964 +       u8 mpdudensity;
5965 +       int last_rssi;
5966 +};
5967 +
5968  #define AGGR_CLEANUP         BIT(1)
5969  #define AGGR_ADDBA_COMPLETE  BIT(2)
5970  #define AGGR_ADDBA_PROGRESS  BIT(3)
5971 @@ -446,6 +510,7 @@ void ath_deinit_leds(struct ath_softc *s
5972  #define SC_OP_TSF_RESET              BIT(11)
5973  #define SC_OP_BT_PRIORITY_DETECTED   BIT(12)
5974  #define SC_OP_BT_SCAN               BIT(13)
5975 +#define SC_OP_PKTLOGGING            BIT(14)
5976  
5977  /* Powersave flags */
5978  #define PS_WAIT_FOR_BEACON        BIT(0)
5979 @@ -523,6 +588,10 @@ struct ath_softc {
5980  #ifdef CONFIG_ATH9K_DEBUGFS
5981         struct ath9k_debug debug;
5982  #endif
5983 +#ifdef CONFIG_ATH9K_PKTLOG
5984 +       struct ath_pktlog_debugfs pktlog;
5985 +#endif
5986 +       bool is_pkt_logging;
5987         struct ath_beacon_config cur_beacon_conf;
5988         struct delayed_work tx_complete_work;
5989         struct ath_btcoex btcoex;
5990 --- a/drivers/net/wireless/ath/ath9k/beacon.c
5991 +++ b/drivers/net/wireless/ath/ath9k/beacon.c
5992 @@ -76,22 +76,13 @@ static void ath_beacon_setup(struct ath_
5993         ds = bf->bf_desc;
5994         flags = ATH9K_TXDESC_NOACK;
5995  
5996 -       if (((sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC) ||
5997 -            (sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT)) &&
5998 -           (ah->caps.hw_caps & ATH9K_HW_CAP_VEOL)) {
5999 -               ds->ds_link = bf->bf_daddr; /* self-linked */
6000 -               flags |= ATH9K_TXDESC_VEOL;
6001 -               /* Let hardware handle antenna switching. */
6002 -               antenna = 0;
6003 -       } else {
6004 -               ds->ds_link = 0;
6005 -               /*
6006 -                * Switch antenna every beacon.
6007 -                * Should only switch every beacon period, not for every SWBA
6008 -                * XXX assumes two antennae
6009 -                */
6010 -               antenna = ((sc->beacon.ast_be_xmit / sc->nbcnvifs) & 1 ? 2 : 1);
6011 -       }
6012 +       ds->ds_link = 0;
6013 +       /*
6014 +        * Switch antenna every beacon.
6015 +        * Should only switch every beacon period, not for every SWBA
6016 +        * XXX assumes two antennae
6017 +        */
6018 +       antenna = ((sc->beacon.ast_be_xmit / sc->nbcnvifs) & 1 ? 2 : 1);
6019  
6020         sband = &sc->sbands[common->hw->conf.channel->band];
6021         rate = sband->bitrates[rateidx].hw_value;
6022 @@ -215,36 +206,6 @@ static struct ath_buf *ath_beacon_genera
6023         return bf;
6024  }
6025  
6026 -/*
6027 - * Startup beacon transmission for adhoc mode when they are sent entirely
6028 - * by the hardware using the self-linked descriptor + veol trick.
6029 -*/
6030 -static void ath_beacon_start_adhoc(struct ath_softc *sc,
6031 -                                  struct ieee80211_vif *vif)
6032 -{
6033 -       struct ath_hw *ah = sc->sc_ah;
6034 -       struct ath_common *common = ath9k_hw_common(ah);
6035 -       struct ath_buf *bf;
6036 -       struct ath_vif *avp;
6037 -       struct sk_buff *skb;
6038 -
6039 -       avp = (void *)vif->drv_priv;
6040 -
6041 -       if (avp->av_bcbuf == NULL)
6042 -               return;
6043 -
6044 -       bf = avp->av_bcbuf;
6045 -       skb = bf->bf_mpdu;
6046 -
6047 -       ath_beacon_setup(sc, avp, bf, 0);
6048 -
6049 -       /* NB: caller is known to have already stopped tx dma */
6050 -       ath9k_hw_puttxbuf(ah, sc->beacon.beaconq, bf->bf_daddr);
6051 -       ath9k_hw_txstart(ah, sc->beacon.beaconq);
6052 -       ath_print(common, ATH_DBG_BEACON, "TXDP%u = %llx (%p)\n",
6053 -                 sc->beacon.beaconq, ito64(bf->bf_daddr), bf->bf_desc);
6054 -}
6055 -
6056  int ath_beacon_alloc(struct ath_wiphy *aphy, struct ieee80211_vif *vif)
6057  {
6058         struct ath_softc *sc = aphy->sc;
6059 @@ -265,7 +226,8 @@ int ath_beacon_alloc(struct ath_wiphy *a
6060                 list_del(&avp->av_bcbuf->list);
6061  
6062                 if (sc->sc_ah->opmode == NL80211_IFTYPE_AP ||
6063 -                   !(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_VEOL)) {
6064 +                   sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC ||
6065 +                   sc->sc_ah->opmode == NL80211_IFTYPE_MESH_POINT) {
6066                         int slot;
6067                         /*
6068                          * Assign the vif to a beacon xmit slot. As
6069 @@ -274,17 +236,11 @@ int ath_beacon_alloc(struct ath_wiphy *a
6070                         avp->av_bslot = 0;
6071                         for (slot = 0; slot < ATH_BCBUF; slot++)
6072                                 if (sc->beacon.bslot[slot] == NULL) {
6073 -                                       /*
6074 -                                        * XXX hack, space out slots to better
6075 -                                        * deal with misses
6076 -                                        */
6077 -                                       if (slot+1 < ATH_BCBUF &&
6078 -                                           sc->beacon.bslot[slot+1] == NULL) {
6079 -                                               avp->av_bslot = slot+1;
6080 -                                               break;
6081 -                                       }
6082                                         avp->av_bslot = slot;
6083 +
6084                                         /* NB: keep looking for a double slot */
6085 +                                       if (slot == 0 || !sc->beacon.bslot[slot-1])
6086 +                                               break;
6087                                 }
6088                         BUG_ON(sc->beacon.bslot[avp->av_bslot] != NULL);
6089                         sc->beacon.bslot[avp->av_bslot] = vif;
6090 @@ -721,8 +677,7 @@ static void ath_beacon_config_adhoc(stru
6091          * self-linked tx descriptor and let the hardware deal with things.
6092          */
6093         intval |= ATH9K_BEACON_ENA;
6094 -       if (!(ah->caps.hw_caps & ATH9K_HW_CAP_VEOL))
6095 -               ah->imask |= ATH9K_INT_SWBA;
6096 +       ah->imask |= ATH9K_INT_SWBA;
6097  
6098         ath_beaconq_config(sc);
6099  
6100 @@ -732,10 +687,6 @@ static void ath_beacon_config_adhoc(stru
6101         ath9k_beacon_init(sc, nexttbtt, intval);
6102         sc->beacon.bmisscnt = 0;
6103         ath9k_hw_set_interrupts(ah, ah->imask);
6104 -
6105 -       /* FIXME: Handle properly when vif is NULL */
6106 -       if (vif && ah->caps.hw_caps & ATH9K_HW_CAP_VEOL)
6107 -               ath_beacon_start_adhoc(sc, vif);
6108  }
6109  
6110  void ath_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif)
6111 --- a/drivers/net/wireless/ath/ath9k/common.c
6112 +++ b/drivers/net/wireless/ath/ath9k/common.c
6113 @@ -27,270 +27,6 @@ MODULE_AUTHOR("Atheros Communications");
6114  MODULE_DESCRIPTION("Shared library for Atheros wireless 802.11n LAN cards.");
6115  MODULE_LICENSE("Dual BSD/GPL");
6116  
6117 -/* Common RX processing */
6118 -
6119 -/* Assumes you've already done the endian to CPU conversion */
6120 -static bool ath9k_rx_accept(struct ath_common *common,
6121 -                           struct sk_buff *skb,
6122 -                           struct ieee80211_rx_status *rxs,
6123 -                           struct ath_rx_status *rx_stats,
6124 -                           bool *decrypt_error)
6125 -{
6126 -       struct ath_hw *ah = common->ah;
6127 -       struct ieee80211_hdr *hdr;
6128 -       __le16 fc;
6129 -
6130 -       hdr = (struct ieee80211_hdr *) skb->data;
6131 -       fc = hdr->frame_control;
6132 -
6133 -       if (!rx_stats->rs_datalen)
6134 -               return false;
6135 -        /*
6136 -         * rs_status follows rs_datalen so if rs_datalen is too large
6137 -         * we can take a hint that hardware corrupted it, so ignore
6138 -         * those frames.
6139 -         */
6140 -       if (rx_stats->rs_datalen > common->rx_bufsize)
6141 -               return false;
6142 -
6143 -       /*
6144 -        * rs_more indicates chained descriptors which can be used
6145 -        * to link buffers together for a sort of scatter-gather
6146 -        * operation.
6147 -        * reject the frame, we don't support scatter-gather yet and
6148 -        * the frame is probably corrupt anyway
6149 -        */
6150 -       if (rx_stats->rs_more)
6151 -               return false;
6152 -
6153 -       /*
6154 -        * The rx_stats->rs_status will not be set until the end of the
6155 -        * chained descriptors so it can be ignored if rs_more is set. The
6156 -        * rs_more will be false at the last element of the chained
6157 -        * descriptors.
6158 -        */
6159 -       if (rx_stats->rs_status != 0) {
6160 -               if (rx_stats->rs_status & ATH9K_RXERR_CRC)
6161 -                       rxs->flag |= RX_FLAG_FAILED_FCS_CRC;
6162 -               if (rx_stats->rs_status & ATH9K_RXERR_PHY)
6163 -                       return false;
6164 -
6165 -               if (rx_stats->rs_status & ATH9K_RXERR_DECRYPT) {
6166 -                       *decrypt_error = true;
6167 -               } else if (rx_stats->rs_status & ATH9K_RXERR_MIC) {
6168 -                       if (ieee80211_is_ctl(fc))
6169 -                               /*
6170 -                                * Sometimes, we get invalid
6171 -                                * MIC failures on valid control frames.
6172 -                                * Remove these mic errors.
6173 -                                */
6174 -                               rx_stats->rs_status &= ~ATH9K_RXERR_MIC;
6175 -                       else
6176 -                               rxs->flag |= RX_FLAG_MMIC_ERROR;
6177 -               }
6178 -               /*
6179 -                * Reject error frames with the exception of
6180 -                * decryption and MIC failures. For monitor mode,
6181 -                * we also ignore the CRC error.
6182 -                */
6183 -               if (ah->opmode == NL80211_IFTYPE_MONITOR) {
6184 -                       if (rx_stats->rs_status &
6185 -                           ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC |
6186 -                             ATH9K_RXERR_CRC))
6187 -                               return false;
6188 -               } else {
6189 -                       if (rx_stats->rs_status &
6190 -                           ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC)) {
6191 -                               return false;
6192 -                       }
6193 -               }
6194 -       }
6195 -       return true;
6196 -}
6197 -
6198 -static int ath9k_process_rate(struct ath_common *common,
6199 -                             struct ieee80211_hw *hw,
6200 -                             struct ath_rx_status *rx_stats,
6201 -                             struct ieee80211_rx_status *rxs,
6202 -                             struct sk_buff *skb)
6203 -{
6204 -       struct ieee80211_supported_band *sband;
6205 -       enum ieee80211_band band;
6206 -       unsigned int i = 0;
6207 -
6208 -       band = hw->conf.channel->band;
6209 -       sband = hw->wiphy->bands[band];
6210 -
6211 -       if (rx_stats->rs_rate & 0x80) {
6212 -               /* HT rate */
6213 -               rxs->flag |= RX_FLAG_HT;
6214 -               if (rx_stats->rs_flags & ATH9K_RX_2040)
6215 -                       rxs->flag |= RX_FLAG_40MHZ;
6216 -               if (rx_stats->rs_flags & ATH9K_RX_GI)
6217 -                       rxs->flag |= RX_FLAG_SHORT_GI;
6218 -               rxs->rate_idx = rx_stats->rs_rate & 0x7f;
6219 -               return 0;
6220 -       }
6221 -
6222 -       for (i = 0; i < sband->n_bitrates; i++) {
6223 -               if (sband->bitrates[i].hw_value == rx_stats->rs_rate) {
6224 -                       rxs->rate_idx = i;
6225 -                       return 0;
6226 -               }
6227 -               if (sband->bitrates[i].hw_value_short == rx_stats->rs_rate) {
6228 -                       rxs->flag |= RX_FLAG_SHORTPRE;
6229 -                       rxs->rate_idx = i;
6230 -                       return 0;
6231 -               }
6232 -       }
6233 -
6234 -       /*
6235 -        * No valid hardware bitrate found -- we should not get here
6236 -        * because hardware has already validated this frame as OK.
6237 -        */
6238 -       ath_print(common, ATH_DBG_XMIT, "unsupported hw bitrate detected "
6239 -                 "0x%02x using 1 Mbit\n", rx_stats->rs_rate);
6240 -       if ((common->debug_mask & ATH_DBG_XMIT))
6241 -               print_hex_dump_bytes("", DUMP_PREFIX_NONE, skb->data, skb->len);
6242 -
6243 -       return -EINVAL;
6244 -}
6245 -
6246 -static void ath9k_process_rssi(struct ath_common *common,
6247 -                              struct ieee80211_hw *hw,
6248 -                              struct sk_buff *skb,
6249 -                              struct ath_rx_status *rx_stats)
6250 -{
6251 -       struct ath_hw *ah = common->ah;
6252 -       struct ieee80211_sta *sta;
6253 -       struct ieee80211_hdr *hdr;
6254 -       struct ath_node *an;
6255 -       int last_rssi = ATH_RSSI_DUMMY_MARKER;
6256 -       __le16 fc;
6257 -
6258 -       hdr = (struct ieee80211_hdr *)skb->data;
6259 -       fc = hdr->frame_control;
6260 -
6261 -       rcu_read_lock();
6262 -       /*
6263 -        * XXX: use ieee80211_find_sta! This requires quite a bit of work
6264 -        * under the current ath9k virtual wiphy implementation as we have
6265 -        * no way of tying a vif to wiphy. Typically vifs are attached to
6266 -        * at least one sdata of a wiphy on mac80211 but with ath9k virtual
6267 -        * wiphy you'd have to iterate over every wiphy and each sdata.
6268 -        */
6269 -       sta = ieee80211_find_sta_by_hw(hw, hdr->addr2);
6270 -       if (sta) {
6271 -               an = (struct ath_node *) sta->drv_priv;
6272 -               if (rx_stats->rs_rssi != ATH9K_RSSI_BAD &&
6273 -                  !rx_stats->rs_moreaggr)
6274 -                       ATH_RSSI_LPF(an->last_rssi, rx_stats->rs_rssi);
6275 -               last_rssi = an->last_rssi;
6276 -       }
6277 -       rcu_read_unlock();
6278 -
6279 -       if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
6280 -               rx_stats->rs_rssi = ATH_EP_RND(last_rssi,
6281 -                                             ATH_RSSI_EP_MULTIPLIER);
6282 -       if (rx_stats->rs_rssi < 0)
6283 -               rx_stats->rs_rssi = 0;
6284 -
6285 -       /* Update Beacon RSSI, this is used by ANI. */
6286 -       if (ieee80211_is_beacon(fc))
6287 -               ah->stats.avgbrssi = rx_stats->rs_rssi;
6288 -}
6289 -
6290 -/*
6291 - * For Decrypt or Demic errors, we only mark packet status here and always push
6292 - * up the frame up to let mac80211 handle the actual error case, be it no
6293 - * decryption key or real decryption error. This let us keep statistics there.
6294 - */
6295 -int ath9k_cmn_rx_skb_preprocess(struct ath_common *common,
6296 -                               struct ieee80211_hw *hw,
6297 -                               struct sk_buff *skb,
6298 -                               struct ath_rx_status *rx_stats,
6299 -                               struct ieee80211_rx_status *rx_status,
6300 -                               bool *decrypt_error)
6301 -{
6302 -       struct ath_hw *ah = common->ah;
6303 -
6304 -       memset(rx_status, 0, sizeof(struct ieee80211_rx_status));
6305 -
6306 -       /*
6307 -        * everything but the rate is checked here, the rate check is done
6308 -        * separately to avoid doing two lookups for a rate for each frame.
6309 -        */
6310 -       if (!ath9k_rx_accept(common, skb, rx_status, rx_stats, decrypt_error))
6311 -               return -EINVAL;
6312 -
6313 -       ath9k_process_rssi(common, hw, skb, rx_stats);
6314 -
6315 -       if (ath9k_process_rate(common, hw, rx_stats, rx_status, skb))
6316 -               return -EINVAL;
6317 -
6318 -       rx_status->mactime = ath9k_hw_extend_tsf(ah, rx_stats->rs_tstamp);
6319 -       rx_status->band = hw->conf.channel->band;
6320 -       rx_status->freq = hw->conf.channel->center_freq;
6321 -       rx_status->signal = ATH_DEFAULT_NOISE_FLOOR + rx_stats->rs_rssi;
6322 -       rx_status->antenna = rx_stats->rs_antenna;
6323 -       rx_status->flag |= RX_FLAG_TSFT;
6324 -
6325 -       return 0;
6326 -}
6327 -EXPORT_SYMBOL(ath9k_cmn_rx_skb_preprocess);
6328 -
6329 -void ath9k_cmn_rx_skb_postprocess(struct ath_common *common,
6330 -                                 struct sk_buff *skb,
6331 -                                 struct ath_rx_status *rx_stats,
6332 -                                 struct ieee80211_rx_status *rxs,
6333 -                                 bool decrypt_error)
6334 -{
6335 -       struct ath_hw *ah = common->ah;
6336 -       struct ieee80211_hdr *hdr;
6337 -       int hdrlen, padpos, padsize;
6338 -       u8 keyix;
6339 -       __le16 fc;
6340 -
6341 -       /* see if any padding is done by the hw and remove it */
6342 -       hdr = (struct ieee80211_hdr *) skb->data;
6343 -       hdrlen = ieee80211_get_hdrlen_from_skb(skb);
6344 -       fc = hdr->frame_control;
6345 -       padpos = ath9k_cmn_padpos(hdr->frame_control);
6346 -
6347 -       /* The MAC header is padded to have 32-bit boundary if the
6348 -        * packet payload is non-zero. The general calculation for
6349 -        * padsize would take into account odd header lengths:
6350 -        * padsize = (4 - padpos % 4) % 4; However, since only
6351 -        * even-length headers are used, padding can only be 0 or 2
6352 -        * bytes and we can optimize this a bit. In addition, we must
6353 -        * not try to remove padding from short control frames that do
6354 -        * not have payload. */
6355 -       padsize = padpos & 3;
6356 -       if (padsize && skb->len>=padpos+padsize+FCS_LEN) {
6357 -               memmove(skb->data + padsize, skb->data, padpos);
6358 -               skb_pull(skb, padsize);
6359 -       }
6360 -
6361 -       keyix = rx_stats->rs_keyix;
6362 -
6363 -       if (!(keyix == ATH9K_RXKEYIX_INVALID) && !decrypt_error &&
6364 -           ieee80211_has_protected(fc)) {
6365 -               rxs->flag |= RX_FLAG_DECRYPTED;
6366 -       } else if (ieee80211_has_protected(fc)
6367 -                  && !decrypt_error && skb->len >= hdrlen + 4) {
6368 -               keyix = skb->data[hdrlen + 3] >> 6;
6369 -
6370 -               if (test_bit(keyix, common->keymap))
6371 -                       rxs->flag |= RX_FLAG_DECRYPTED;
6372 -       }
6373 -       if (ah->sw_mgmt_crypto &&
6374 -           (rxs->flag & RX_FLAG_DECRYPTED) &&
6375 -           ieee80211_is_mgmt(fc))
6376 -               /* Use software decrypt for management frames. */
6377 -               rxs->flag &= ~RX_FLAG_DECRYPTED;
6378 -}
6379 -EXPORT_SYMBOL(ath9k_cmn_rx_skb_postprocess);
6380 -
6381  int ath9k_cmn_padpos(__le16 frame_control)
6382  {
6383         int padpos = 24;
6384 --- a/drivers/net/wireless/ath/ath9k/common.h
6385 +++ b/drivers/net/wireless/ath/ath9k/common.h
6386 @@ -52,82 +52,6 @@
6387  #define ATH_EP_RND(x, mul)                                             \
6388         ((((x)%(mul)) >= ((mul)/2)) ? ((x) + ((mul) - 1)) / (mul) : (x)/(mul))
6389  
6390 -struct ath_atx_ac {
6391 -       int sched;
6392 -       int qnum;
6393 -       struct list_head list;
6394 -       struct list_head tid_q;
6395 -};
6396 -
6397 -struct ath_buf_state {
6398 -       int bfs_nframes;
6399 -       u16 bfs_al;
6400 -       u16 bfs_frmlen;
6401 -       int bfs_seqno;
6402 -       int bfs_tidno;
6403 -       int bfs_retries;
6404 -       u8 bf_type;
6405 -       u32 bfs_keyix;
6406 -       enum ath9k_key_type bfs_keytype;
6407 -};
6408 -
6409 -struct ath_buf {
6410 -       struct list_head list;
6411 -       struct ath_buf *bf_lastbf;      /* last buf of this unit (a frame or
6412 -                                          an aggregate) */
6413 -       struct ath_buf *bf_next;        /* next subframe in the aggregate */
6414 -       struct sk_buff *bf_mpdu;        /* enclosing frame structure */
6415 -       void *bf_desc;                  /* virtual addr of desc */
6416 -       dma_addr_t bf_daddr;            /* physical addr of desc */
6417 -       dma_addr_t bf_buf_addr;         /* physical addr of data buffer */
6418 -       bool bf_stale;
6419 -       bool bf_isnullfunc;
6420 -       bool bf_tx_aborted;
6421 -       u16 bf_flags;
6422 -       struct ath_buf_state bf_state;
6423 -       dma_addr_t bf_dmacontext;
6424 -       struct ath_wiphy *aphy;
6425 -};
6426 -
6427 -struct ath_atx_tid {
6428 -       struct list_head list;
6429 -       struct list_head buf_q;
6430 -       struct ath_node *an;
6431 -       struct ath_atx_ac *ac;
6432 -       struct ath_buf *tx_buf[ATH_TID_MAX_BUFS];
6433 -       u16 seq_start;
6434 -       u16 seq_next;
6435 -       u16 baw_size;
6436 -       int tidno;
6437 -       int baw_head;   /* first un-acked tx buffer */
6438 -       int baw_tail;   /* next unused tx buffer slot */
6439 -       int sched;
6440 -       int paused;
6441 -       u8 state;
6442 -};
6443 -
6444 -struct ath_node {
6445 -       struct ath_common *common;
6446 -       struct ath_atx_tid tid[WME_NUM_TID];
6447 -       struct ath_atx_ac ac[WME_NUM_AC];
6448 -       u16 maxampdu;
6449 -       u8 mpdudensity;
6450 -       int last_rssi;
6451 -};
6452 -
6453 -int ath9k_cmn_rx_skb_preprocess(struct ath_common *common,
6454 -                               struct ieee80211_hw *hw,
6455 -                               struct sk_buff *skb,
6456 -                               struct ath_rx_status *rx_stats,
6457 -                               struct ieee80211_rx_status *rx_status,
6458 -                               bool *decrypt_error);
6459 -
6460 -void ath9k_cmn_rx_skb_postprocess(struct ath_common *common,
6461 -                                 struct sk_buff *skb,
6462 -                                 struct ath_rx_status *rx_stats,
6463 -                                 struct ieee80211_rx_status *rxs,
6464 -                                 bool decrypt_error);
6465 -
6466  int ath9k_cmn_padpos(__le16 frame_control);
6467  int ath9k_cmn_get_hw_crypto_keytype(struct sk_buff *skb);
6468  void ath9k_cmn_update_ichannel(struct ieee80211_hw *hw,
6469 --- a/drivers/net/wireless/ath/ath9k/debug.c
6470 +++ b/drivers/net/wireless/ath/ath9k/debug.c
6471 @@ -15,6 +15,7 @@
6472   */
6473  
6474  #include <linux/slab.h>
6475 +#include <linux/vmalloc.h>
6476  #include <asm/unaligned.h>
6477  
6478  #include "ath9k.h"
6479 @@ -32,6 +33,19 @@ static int ath9k_debugfs_open(struct ino
6480         return 0;
6481  }
6482  
6483 +static ssize_t ath9k_debugfs_read_buf(struct file *file, char __user *user_buf,
6484 +                                     size_t count, loff_t *ppos)
6485 +{
6486 +       u8 *buf = file->private_data;
6487 +       return simple_read_from_buffer(user_buf, count, ppos, buf, strlen(buf));
6488 +}
6489 +
6490 +static int ath9k_debugfs_release_buf (struct inode *inode, struct file *file)
6491 +{
6492 +       vfree(file->private_data);
6493 +       return 0;
6494 +}
6495 +
6496  #ifdef CONFIG_ATH_DEBUG
6497  
6498  static ssize_t read_file_debug(struct file *file, char __user *user_buf,
6499 @@ -269,6 +283,8 @@ void ath_debug_stat_interrupt(struct ath
6500                         sc->debug.stats.istats.rxlp++;
6501                 if (status & ATH9K_INT_RXHP)
6502                         sc->debug.stats.istats.rxhp++;
6503 +               if (status & ATH9K_INT_BB_WATCHDOG)
6504 +                       sc->debug.stats.istats.bb_watchdog++;
6505         } else {
6506                 if (status & ATH9K_INT_RX)
6507                         sc->debug.stats.istats.rxok++;
6508 @@ -319,6 +335,9 @@ static ssize_t read_file_interrupt(struc
6509                         "%8s: %10u\n", "RXLP", sc->debug.stats.istats.rxlp);
6510                 len += snprintf(buf + len, sizeof(buf) - len,
6511                         "%8s: %10u\n", "RXHP", sc->debug.stats.istats.rxhp);
6512 +               len += snprintf(buf + len, sizeof(buf) - len,
6513 +                       "%8s: %10u\n", "WATCHDOG",
6514 +                       sc->debug.stats.istats.bb_watchdog);
6515         } else {
6516                 len += snprintf(buf + len, sizeof(buf) - len,
6517                         "%8s: %10u\n", "RX", sc->debug.stats.istats.rxok);
6518 @@ -871,7 +890,38 @@ static ssize_t write_file_regval(struct 
6519  static const struct file_operations fops_regval = {
6520         .read = read_file_regval,
6521         .write = write_file_regval,
6522 -       .open = ath9k_debugfs_open,
6523 +};
6524 +
6525 +#define REGDUMP_LINE_SIZE      20
6526 +#define REGDUMP_NUM_REGS       (0x16bd4 / 4 + 1)
6527 +#define REGDUMP_DATA_LEN       (REGDUMP_NUM_REGS * REGDUMP_LINE_SIZE + 1)
6528 +
6529 +static int open_file_regdump(struct inode *inode, struct file *file)
6530 +{
6531 +       struct ath_softc *sc = inode->i_private;
6532 +       unsigned int len = 0;
6533 +       u8 *buf;
6534 +       int i;
6535 +
6536 +       buf = vmalloc(REGDUMP_DATA_LEN);
6537 +       if (!buf)
6538 +               return -ENOMEM;
6539 +
6540 +       ath9k_ps_wakeup(sc);
6541 +       for (i = 0; i < REGDUMP_NUM_REGS; i++)
6542 +               len += scnprintf(buf + len, REGDUMP_DATA_LEN - len,
6543 +                       "0x%06x 0x%08x\n", i << 2, REG_READ(sc->sc_ah, i << 2));
6544 +       ath9k_ps_restore(sc);
6545 +
6546 +       file->private_data = buf;
6547 +
6548 +       return 0;
6549 +}
6550 +
6551 +static const struct file_operations fops_regdump = {
6552 +       .open = open_file_regdump,
6553 +       .read = ath9k_debugfs_read_buf,
6554 +       .release = ath9k_debugfs_release_buf,
6555         .owner = THIS_MODULE
6556  };
6557  
6558 @@ -935,6 +985,16 @@ int ath9k_init_debug(struct ath_hw *ah)
6559                 goto err;
6560  
6561         sc->debug.regidx = 0;
6562 +
6563 +       if (!debugfs_create_file("regdump", S_IRUSR, sc->debug.debugfs_phy,
6564 +                       sc, &fops_regdump))
6565 +               goto err;
6566 +
6567 +#ifdef CONFIG_ATH9K_PKTLOG
6568 +       if (ath9k_init_pktlog(sc) != 0)
6569 +               goto err;
6570 +#endif
6571 +
6572         return 0;
6573  err:
6574         ath9k_exit_debug(ah);
6575 @@ -946,6 +1006,10 @@ void ath9k_exit_debug(struct ath_hw *ah)
6576         struct ath_common *common = ath9k_hw_common(ah);
6577         struct ath_softc *sc = (struct ath_softc *) common->priv;
6578  
6579 +#ifdef CONFIG_ATH9K_PKTLOG
6580 +       ath9k_deinit_pktlog(sc);
6581 +#endif
6582 +       debugfs_remove(sc->debug.debugfs_regdump);
6583         debugfs_remove_recursive(sc->debug.debugfs_phy);
6584  }
6585  
6586 --- a/drivers/net/wireless/ath/ath9k/debug.h
6587 +++ b/drivers/net/wireless/ath/ath9k/debug.h
6588 @@ -53,6 +53,7 @@ struct ath_buf;
6589   * @cabend: RX End of CAB traffic
6590   * @dtimsync: DTIM sync lossage
6591   * @dtim: RX Beacon with DTIM
6592 + * @bb_watchdog: Baseband watchdog
6593   */
6594  struct ath_interrupt_stats {
6595         u32 total;
6596 @@ -76,6 +77,7 @@ struct ath_interrupt_stats {
6597         u32 cabend;
6598         u32 dtimsync;
6599         u32 dtim;
6600 +       u32 bb_watchdog;
6601  };
6602  
6603  struct ath_rc_stats {
6604 @@ -154,6 +156,14 @@ struct ath_stats {
6605  struct ath9k_debug {
6606         struct dentry *debugfs_phy;
6607         u32 regidx;
6608 +       struct dentry *debugfs_debug;
6609 +       struct dentry *debugfs_dma;
6610 +       struct dentry *debugfs_interrupt;
6611 +       struct dentry *debugfs_rcstat;
6612 +       struct dentry *debugfs_wiphy;
6613 +       struct dentry *debugfs_xmit;
6614 +       struct dentry *debugfs_recv;
6615 +       struct dentry *debugfs_regdump;
6616         struct ath_stats stats;
6617  };
6618  
6619 --- a/drivers/net/wireless/ath/ath9k/hw-ops.h
6620 +++ b/drivers/net/wireless/ath/ath9k/hw-ops.h
6621 @@ -67,9 +67,10 @@ static inline void ath9k_hw_filltxdesc(s
6622  }
6623  
6624  static inline int ath9k_hw_txprocdesc(struct ath_hw *ah, void *ds,
6625 -                                     struct ath_tx_status *ts)
6626 +                                     struct ath_tx_status *ts,
6627 +                                     void *txs_desc)
6628  {
6629 -       return ath9k_hw_ops(ah)->proc_txdesc(ah, ds, ts);
6630 +       return ath9k_hw_ops(ah)->proc_txdesc(ah, ds, ts, txs_desc);
6631  }
6632  
6633  static inline void ath9k_hw_set11n_txdesc(struct ath_hw *ah, void *ds,
6634 --- a/drivers/net/wireless/ath/ath9k/hw.c
6635 +++ b/drivers/net/wireless/ath/ath9k/hw.c
6636 @@ -395,12 +395,6 @@ static void ath9k_hw_init_config(struct 
6637         ah->config.rx_intr_mitigation = true;
6638  
6639         /*
6640 -        * Tx IQ Calibration (ah->config.tx_iq_calibration) is only
6641 -        * used by AR9003, but it is showing reliability issues.
6642 -        * It will take a while to fix so this is currently disabled.
6643 -        */
6644 -
6645 -       /*
6646          * We need this for PCI devices only (Cardbus, PCI, miniPCI)
6647          * _and_ if on non-uniprocessor systems (Multiprocessor/HT).
6648          * This means we use it for all AR5416 devices, and the few
6649 @@ -639,6 +633,7 @@ static int __ath9k_hw_init(struct ath_hw
6650                 ar9003_hw_set_nf_limits(ah);
6651  
6652         ath9k_init_nfcal_hist_buffer(ah);
6653 +       ah->bb_watchdog_timeout_ms = 25;
6654  
6655         common->state = ATH_HW_INITIALIZED;
6656  
6657 @@ -1453,6 +1448,7 @@ int ath9k_hw_reset(struct ath_hw *ah, st
6658         if (AR_SREV_9300_20_OR_LATER(ah)) {
6659                 ath9k_hw_loadnf(ah, curchan);
6660                 ath9k_hw_start_nfcal(ah);
6661 +               ar9003_hw_bb_watchdog_config(ah);
6662         }
6663  
6664         return 0;
6665 @@ -2177,7 +2173,7 @@ int ath9k_hw_fill_cap_info(struct ath_hw
6666                 pCap->hw_caps |= ATH9K_HW_CAP_RFSILENT;
6667         }
6668  #endif
6669 -       if (AR_SREV_9271(ah))
6670 +       if (AR_SREV_9271(ah) || AR_SREV_9300_20_OR_LATER(ah))
6671                 pCap->hw_caps |= ATH9K_HW_CAP_AUTOSLEEP;
6672         else
6673                 pCap->hw_caps &= ~ATH9K_HW_CAP_AUTOSLEEP;
6674 @@ -2244,6 +2240,9 @@ int ath9k_hw_fill_cap_info(struct ath_hw
6675         if (AR_SREV_9300_20_OR_LATER(ah))
6676                 pCap->hw_caps |= ATH9K_HW_CAP_RAC_SUPPORTED;
6677  
6678 +       if (AR_SREV_9287_10_OR_LATER(ah))
6679 +               pCap->hw_caps |= ATH9K_HW_CAP_SGI_20;
6680 +
6681         return 0;
6682  }
6683  
6684 @@ -2478,7 +2477,7 @@ void ath9k_hw_setrxfilter(struct ath_hw 
6685                 phybits |= AR_PHY_ERR_RADAR;
6686         if (bits & ATH9K_RX_FILTER_PHYERR)
6687                 phybits |= AR_PHY_ERR_OFDM_TIMING | AR_PHY_ERR_CCK_TIMING;
6688 -       REG_WRITE(ah, AR_PHY_ERR, phybits);
6689 +       REG_WRITE(ah, AR_PHY_ERR, 0xffffffff);
6690  
6691         if (phybits)
6692                 REG_WRITE(ah, AR_RXCFG,
6693 --- a/drivers/net/wireless/ath/ath9k/hw.h
6694 +++ b/drivers/net/wireless/ath/ath9k/hw.h
6695 @@ -199,6 +199,7 @@ enum ath9k_hw_caps {
6696         ATH9K_HW_CAP_RAC_SUPPORTED              = BIT(18),
6697         ATH9K_HW_CAP_LDPC                       = BIT(19),
6698         ATH9K_HW_CAP_FASTCLOCK                  = BIT(20),
6699 +       ATH9K_HW_CAP_SGI_20                     = BIT(21),
6700  };
6701  
6702  enum ath9k_capability_type {
6703 @@ -262,7 +263,6 @@ struct ath9k_ops_config {
6704  #define AR_BASE_FREQ_5GHZ      4900
6705  #define AR_SPUR_FEEQ_BOUND_HT40 19
6706  #define AR_SPUR_FEEQ_BOUND_HT20 10
6707 -       bool tx_iq_calibration; /* Only available for >= AR9003 */
6708         int spurmode;
6709         u16 spurchans[AR_EEPROM_MODAL_SPURS][2];
6710         u8 max_txtrig_level;
6711 @@ -279,6 +279,7 @@ enum ath9k_int {
6712         ATH9K_INT_TX = 0x00000040,
6713         ATH9K_INT_TXDESC = 0x00000080,
6714         ATH9K_INT_TIM_TIMER = 0x00000100,
6715 +       ATH9K_INT_BB_WATCHDOG = 0x00000400,
6716         ATH9K_INT_TXURN = 0x00000800,
6717         ATH9K_INT_MIB = 0x00001000,
6718         ATH9K_INT_RXPHY = 0x00004000,
6719 @@ -581,7 +582,7 @@ struct ath_hw_ops {
6720                             const void *ds0, dma_addr_t buf_addr,
6721                             unsigned int qcu);
6722         int (*proc_txdesc)(struct ath_hw *ah, void *ds,
6723 -                          struct ath_tx_status *ts);
6724 +                          struct ath_tx_status *ts, void* txs_desc);
6725         void (*set11n_txdesc)(struct ath_hw *ah, void *ds,
6726                               u32 pktLen, enum ath9k_pkt_type type,
6727                               u32 txPower, u32 keyIx,
6728 @@ -789,6 +790,11 @@ struct ath_hw {
6729         u32 ts_paddr_end;
6730         u16 ts_tail;
6731         u8 ts_size;
6732 +
6733 +       u32 bb_watchdog_last_status;
6734 +       u32 bb_watchdog_timeout_ms; /* in ms, 0 to disable */
6735 +
6736 +       bool is_pkt_logging;
6737  };
6738  
6739  static inline struct ath_common *ath9k_hw_common(struct ath_hw *ah)
6740 @@ -910,10 +916,13 @@ void ar9002_hw_enable_async_fifo(struct 
6741  void ar9002_hw_enable_wep_aggregation(struct ath_hw *ah);
6742  
6743  /*
6744 - * Code specifric to AR9003, we stuff these here to avoid callbacks
6745 + * Code specific to AR9003, we stuff these here to avoid callbacks
6746   * for older families
6747   */
6748  void ar9003_hw_set_nf_limits(struct ath_hw *ah);
6749 +void ar9003_hw_bb_watchdog_config(struct ath_hw *ah);
6750 +void ar9003_hw_bb_watchdog_read(struct ath_hw *ah);
6751 +void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah);
6752  
6753  /* Hardware family op attach helpers */
6754  void ar5008_hw_attach_phy_ops(struct ath_hw *ah);
6755 --- a/drivers/net/wireless/ath/ath9k/init.c
6756 +++ b/drivers/net/wireless/ath/ath9k/init.c
6757 @@ -209,6 +209,9 @@ static void setup_ht_cap(struct ath_soft
6758         if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_LDPC)
6759                 ht_info->cap |= IEEE80211_HT_CAP_LDPC_CODING;
6760  
6761 +       if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_SGI_20)
6762 +               ht_info->cap |= IEEE80211_HT_CAP_SGI_20;
6763 +
6764         ht_info->ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K;
6765         ht_info->ampdu_density = IEEE80211_HT_MPDU_DENSITY_8;
6766  
6767 --- a/drivers/net/wireless/ath/ath9k/main.c
6768 +++ b/drivers/net/wireless/ath/ath9k/main.c
6769 @@ -521,6 +521,12 @@ irqreturn_t ath_isr(int irq, void *dev)
6770             !(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)))
6771                 goto chip_reset;
6772  
6773 +       if ((ah->caps.hw_caps & ATH9K_HW_CAP_EDMA) &&
6774 +           (status & ATH9K_INT_BB_WATCHDOG)) {
6775 +               ar9003_hw_bb_watchdog_dbg_info(ah);
6776 +               goto chip_reset;
6777 +       }
6778 +
6779         if (status & ATH9K_INT_SWBA)
6780                 tasklet_schedule(&sc->bcon_tasklet);
6781  
6782 @@ -1196,7 +1202,9 @@ static int ath9k_start(struct ieee80211_
6783                     ATH9K_INT_GLOBAL;
6784  
6785         if (ah->caps.hw_caps & ATH9K_HW_CAP_EDMA)
6786 -               ah->imask |= ATH9K_INT_RXHP | ATH9K_INT_RXLP;
6787 +               ah->imask |= ATH9K_INT_RXHP |
6788 +                            ATH9K_INT_RXLP |
6789 +                            ATH9K_INT_BB_WATCHDOG;
6790         else
6791                 ah->imask |= ATH9K_INT_RX;
6792  
6793 @@ -1275,7 +1283,8 @@ static int ath9k_tx(struct ieee80211_hw 
6794                  * completed and if needed, also for RX of buffered frames.
6795                  */
6796                 ath9k_ps_wakeup(sc);
6797 -               ath9k_hw_setrxabort(sc->sc_ah, 0);
6798 +               if (!(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_AUTOSLEEP))
6799 +                       ath9k_hw_setrxabort(sc->sc_ah, 0);
6800                 if (ieee80211_is_pspoll(hdr->frame_control)) {
6801                         ath_print(common, ATH_DBG_PS,
6802                                   "Sending PS-Poll to pick a buffered frame\n");
6803 @@ -1539,8 +1548,8 @@ void ath9k_enable_ps(struct ath_softc *s
6804                         ah->imask |= ATH9K_INT_TIM_TIMER;
6805                         ath9k_hw_set_interrupts(ah, ah->imask);
6806                 }
6807 +               ath9k_hw_setrxabort(ah, 1);
6808         }
6809 -       ath9k_hw_setrxabort(ah, 1);
6810  }
6811  
6812  static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
6813 --- a/drivers/net/wireless/ath/ath9k/pci.c
6814 +++ b/drivers/net/wireless/ath/ath9k/pci.c
6815 @@ -29,6 +29,7 @@ static DEFINE_PCI_DEVICE_TABLE(ath_pci_i
6816         { PCI_VDEVICE(ATHEROS, 0x002C) }, /* PCI-E 802.11n bonded out */
6817         { PCI_VDEVICE(ATHEROS, 0x002D) }, /* PCI   */
6818         { PCI_VDEVICE(ATHEROS, 0x002E) }, /* PCI-E */
6819 +       { PCI_VDEVICE(ATHEROS, 0x0030) }, /* PCI-E  AR9300 */
6820         { 0 }
6821  };
6822  
6823 --- /dev/null
6824 +++ b/drivers/net/wireless/ath/ath9k/pktlog.c
6825 @@ -0,0 +1,783 @@
6826 +
6827 +#include <linux/vmalloc.h>
6828 +#include <linux/highmem.h>
6829 +#include "ath9k.h"
6830 +
6831 +static int ath9k_debugfs_open(struct inode *inode, struct file *file)
6832 +{
6833 +       file->private_data = inode->i_private;
6834 +       return 0;
6835 +}
6836 +
6837 +static struct page *pktlog_virt_to_logical(void *addr)
6838 +{
6839 +       struct page *page;
6840 +       unsigned long vpage = 0UL;
6841 +
6842 +       page = vmalloc_to_page(addr);
6843 +       if (page) {
6844 +               vpage = (unsigned long) page_address(page);
6845 +               vpage |= ((unsigned long) addr & (PAGE_SIZE - 1));
6846 +       }
6847 +       return virt_to_page((void *) vpage);
6848 +}
6849 +
6850 +static void ath_pktlog_release(struct ath_pktlog *pktlog)
6851 +{
6852 +       unsigned long page_cnt, vaddr;
6853 +       struct page *page;
6854 +
6855 +       page_cnt =
6856 +               ((sizeof(*(pktlog->pktlog_buf)) +
6857 +               pktlog->pktlog_buf_size) / PAGE_SIZE) + 1;
6858 +
6859 +       for (vaddr = (unsigned long) (pktlog->pktlog_buf); vaddr <
6860 +                       (unsigned long) (pktlog->pktlog_buf) +
6861 +                       (page_cnt * PAGE_SIZE);
6862 +                       vaddr += PAGE_SIZE) {
6863 +               page = pktlog_virt_to_logical((void *) vaddr);
6864 +               clear_bit(PG_reserved, &page->flags);
6865 +       }
6866 +
6867 +       vfree(pktlog->pktlog_buf);
6868 +       pktlog->pktlog_buf = NULL;
6869 +}
6870 +
6871 +static int ath_alloc_pktlog_buf(struct ath_softc *sc)
6872 +{
6873 +       u32 page_cnt;
6874 +       unsigned long vaddr;
6875 +       struct page *page;
6876 +       struct ath_pktlog *pktlog = &sc->pktlog.pktlog;
6877 +
6878 +       if (pktlog->pktlog_buf_size == 0)
6879 +               return -EINVAL;
6880 +
6881 +       page_cnt = (sizeof(*(pktlog->pktlog_buf)) +
6882 +                   pktlog->pktlog_buf_size) / PAGE_SIZE;
6883 +
6884 +       pktlog->pktlog_buf =  vmalloc((page_cnt + 2) * PAGE_SIZE);
6885 +       if (pktlog->pktlog_buf == NULL) {
6886 +               printk(KERN_ERR "Failed to allocate memory  for pktlog");
6887 +               return -ENOMEM;
6888 +       }
6889 +
6890 +       pktlog->pktlog_buf = (struct ath_pktlog_buf *)
6891 +                                    (((unsigned long)
6892 +                                     (pktlog->pktlog_buf)
6893 +                                    + PAGE_SIZE - 1) & PAGE_MASK);
6894 +
6895 +       for (vaddr = (unsigned long) (pktlog->pktlog_buf);
6896 +                     vaddr < ((unsigned long) (pktlog->pktlog_buf)
6897 +                     + (page_cnt * PAGE_SIZE)); vaddr += PAGE_SIZE) {
6898 +               page = pktlog_virt_to_logical((void *)vaddr);
6899 +               set_bit(PG_reserved, &page->flags);
6900 +       }
6901 +
6902 +       return 0;
6903 +}
6904 +
6905 +static void ath_init_pktlog_buf(struct ath_pktlog *pktlog)
6906 +{
6907 +       pktlog->pktlog_buf->bufhdr.magic_num = PKTLOG_MAGIC_NUM;
6908 +       pktlog->pktlog_buf->bufhdr.version = CUR_PKTLOG_VER;
6909 +       pktlog->pktlog_buf->rd_offset = -1;
6910 +       pktlog->pktlog_buf->wr_offset = 0;
6911 +       if (pktlog->pktlog_filter == 0)
6912 +               pktlog->pktlog_filter = ATH_PKTLOG_FILTER_DEFAULT;
6913 +}
6914 +
6915 +static char *ath_pktlog_getbuf(struct ath_pktlog *pl_info,
6916 +                              u16 log_type, size_t log_size,
6917 +                              u32 flags)
6918 +{
6919 +       struct ath_pktlog_buf *log_buf;
6920 +       struct ath_pktlog_hdr *log_hdr;
6921 +       int32_t cur_wr_offset, buf_size;
6922 +       char *log_ptr;
6923 +
6924 +       log_buf = pl_info->pktlog_buf;
6925 +       buf_size = pl_info->pktlog_buf_size;
6926 +
6927 +       spin_lock_bh(&pl_info->pktlog_lock);
6928 +       cur_wr_offset = log_buf->wr_offset;
6929 +       /* Move read offset to the next entry if there is a buffer overlap */
6930 +       if (log_buf->rd_offset >= 0) {
6931 +               if ((cur_wr_offset <= log_buf->rd_offset)
6932 +                               && (cur_wr_offset +
6933 +                               sizeof(struct ath_pktlog_hdr)) >
6934 +                               log_buf->rd_offset)
6935 +                       PKTLOG_MOV_RD_IDX(log_buf->rd_offset, log_buf,
6936 +                                         buf_size);
6937 +       } else {
6938 +               log_buf->rd_offset = cur_wr_offset;
6939 +       }
6940 +
6941 +       log_hdr =
6942 +               (struct ath_pktlog_hdr *) (log_buf->log_data + cur_wr_offset);
6943 +       log_hdr->log_type = log_type;
6944 +       log_hdr->flags = flags;
6945 +       log_hdr->timestamp = jiffies;
6946 +       log_hdr->size = (u16) log_size;
6947 +
6948 +       cur_wr_offset += sizeof(*log_hdr);
6949 +
6950 +       if ((buf_size - cur_wr_offset) < log_size) {
6951 +               while ((cur_wr_offset <= log_buf->rd_offset)
6952 +                               && (log_buf->rd_offset < buf_size))
6953 +                       PKTLOG_MOV_RD_IDX(log_buf->rd_offset, log_buf,
6954 +                                         buf_size);
6955 +               cur_wr_offset = 0;
6956 +       }
6957 +
6958 +       while ((cur_wr_offset <= log_buf->rd_offset)
6959 +                       && (cur_wr_offset + log_size) > log_buf->rd_offset)
6960 +               PKTLOG_MOV_RD_IDX(log_buf->rd_offset, log_buf, buf_size);
6961 +
6962 +       log_ptr = &(log_buf->log_data[cur_wr_offset]);
6963 +
6964 +       cur_wr_offset += log_hdr->size;
6965 +
6966 +       log_buf->wr_offset =
6967 +               ((buf_size - cur_wr_offset) >=
6968 +                sizeof(struct ath_pktlog_hdr)) ? cur_wr_offset : 0;
6969 +       spin_unlock_bh(&pl_info->pktlog_lock);
6970 +
6971 +       return log_ptr;
6972 +}
6973 +
6974 +static void ath9k_hw_get_descinfo(struct ath_hw *ah, struct ath_desc_info *desc_info)
6975 +{
6976 +       desc_info->txctl_numwords = TXCTL_NUMWORDS(ah);
6977 +       desc_info->txctl_offset = TXCTL_OFFSET(ah);
6978 +       desc_info->txstatus_numwords = TXSTATUS_NUMWORDS(ah);
6979 +       desc_info->txstatus_offset = TXSTATUS_OFFSET(ah);
6980 +
6981 +       desc_info->rxctl_numwords = RXCTL_NUMWORDS(ah);
6982 +       desc_info->rxctl_offset = RXCTL_OFFSET(ah);
6983 +       desc_info->rxstatus_numwords = RXSTATUS_NUMWORDS(ah);
6984 +       desc_info->rxstatus_offset = RXSTATUS_OFFSET(ah);
6985 +}
6986 +
6987 +static int  pktlog_pgfault(struct vm_area_struct *vma, struct vm_fault *vmf)
6988 +{
6989 +       unsigned long address = (unsigned long) vmf->virtual_address;
6990 +
6991 +       if (address == 0UL)
6992 +               return VM_FAULT_NOPAGE;
6993 +
6994 +       if (vmf->pgoff > vma->vm_end)
6995 +               return VM_FAULT_SIGBUS;
6996 +
6997 +       get_page(virt_to_page(address));
6998 +       vmf->page = virt_to_page(address);
6999 +       return VM_FAULT_MINOR;
7000 +}
7001 +
7002 +static struct vm_operations_struct pktlog_vmops = {
7003 +       .fault = pktlog_pgfault
7004 +};
7005 +
7006 +static int ath_pktlog_mmap(struct file *file, struct vm_area_struct *vma)
7007 +{
7008 +       struct ath_softc *sc = file->private_data;
7009 +
7010 +       /* entire buffer should be mapped */
7011 +       if (vma->vm_pgoff != 0)
7012 +               return -EINVAL;
7013 +
7014 +       if (!sc->pktlog.pktlog.pktlog_buf) {
7015 +               printk(KERN_ERR "Can't allocate pktlog buf");
7016 +               return -ENOMEM;
7017 +       }
7018 +
7019 +       vma->vm_flags |= VM_LOCKED;
7020 +       vma->vm_ops = &pktlog_vmops;
7021 +
7022 +       return 0;
7023 +}
7024 +
7025 +static ssize_t ath_pktlog_read(struct file *file, char __user *userbuf,
7026 +                              size_t count, loff_t *ppos)
7027 +{
7028 +       size_t bufhdr_size;
7029 +       size_t nbytes = 0, ret_val = 0;
7030 +       int rem_len;
7031 +       int start_offset, end_offset;
7032 +       int fold_offset, ppos_data, cur_rd_offset;
7033 +       struct ath_softc *sc = file->private_data;
7034 +       struct ath_pktlog *pktlog_info = &sc->pktlog.pktlog;
7035 +       struct ath_pktlog_buf *log_buf = pktlog_info->pktlog_buf;
7036 +
7037 +       if (log_buf == NULL)
7038 +               return 0;
7039 +
7040 +       bufhdr_size = sizeof(log_buf->bufhdr);
7041 +
7042 +       /* copy valid log entries from circular buffer into user space */
7043 +       rem_len = count;
7044 +
7045 +       nbytes = 0;
7046 +
7047 +       if (*ppos < bufhdr_size) {
7048 +               nbytes = min((int) (bufhdr_size -  *ppos), rem_len);
7049 +               if (copy_to_user(userbuf,
7050 +                   ((char *) &log_buf->bufhdr) + *ppos, nbytes))
7051 +                       return -EFAULT;
7052 +               rem_len -= nbytes;
7053 +               ret_val += nbytes;
7054 +       }
7055 +
7056 +       start_offset = log_buf->rd_offset;
7057 +
7058 +       if ((rem_len == 0) || (start_offset < 0))
7059 +               goto read_done;
7060 +
7061 +       fold_offset = -1;
7062 +       cur_rd_offset = start_offset;
7063 +
7064 +       /* Find the last offset and fold-offset if the buffer is folded */
7065 +       do {
7066 +               struct ath_pktlog_hdr *log_hdr;
7067 +               int log_data_offset;
7068 +
7069 +               log_hdr =
7070 +                       (struct ath_pktlog_hdr *) (log_buf->log_data +
7071 +                                                       cur_rd_offset);
7072 +
7073 +               log_data_offset = cur_rd_offset + sizeof(struct ath_pktlog_hdr);
7074 +
7075 +               if ((fold_offset == -1)
7076 +                               && ((pktlog_info->pktlog_buf_size -
7077 +                                   log_data_offset) <= log_hdr->size))
7078 +                       fold_offset = log_data_offset - 1;
7079 +
7080 +               PKTLOG_MOV_RD_IDX(cur_rd_offset, log_buf,
7081 +                                 pktlog_info->pktlog_buf_size);
7082 +
7083 +               if ((fold_offset == -1) && (cur_rd_offset == 0)
7084 +                               && (cur_rd_offset != log_buf->wr_offset))
7085 +                       fold_offset = log_data_offset + log_hdr->size - 1;
7086 +
7087 +               end_offset = log_data_offset + log_hdr->size - 1;
7088 +       } while (cur_rd_offset != log_buf->wr_offset);
7089 +
7090 +       ppos_data = *ppos + ret_val - bufhdr_size + start_offset;
7091 +
7092 +       if (fold_offset == -1) {
7093 +               if (ppos_data > end_offset)
7094 +                       goto read_done;
7095 +
7096 +               nbytes = min(rem_len, end_offset - ppos_data + 1);
7097 +               if (copy_to_user(userbuf + ret_val,
7098 +                                log_buf->log_data + ppos_data, nbytes))
7099 +                       return -EFAULT;
7100 +               ret_val += nbytes;
7101 +               rem_len -= nbytes;
7102 +       } else {
7103 +               if (ppos_data <= fold_offset) {
7104 +                       nbytes = min(rem_len, fold_offset - ppos_data + 1);
7105 +                       if (copy_to_user(userbuf + ret_val,
7106 +                                               log_buf->log_data + ppos_data,
7107 +                                               nbytes))
7108 +                               return -EFAULT;
7109 +                       ret_val += nbytes;
7110 +                       rem_len -= nbytes;
7111 +               }
7112 +
7113 +               if (rem_len == 0)
7114 +                       goto read_done;
7115 +
7116 +               ppos_data =
7117 +                       *ppos + ret_val - (bufhdr_size +
7118 +                                       (fold_offset - start_offset + 1));
7119 +
7120 +               if (ppos_data <= end_offset) {
7121 +                       nbytes = min(rem_len, end_offset - ppos_data + 1);
7122 +                       if (copy_to_user(userbuf + ret_val, log_buf->log_data
7123 +                                        + ppos_data,
7124 +                                        nbytes))
7125 +                               return -EFAULT;
7126 +                       ret_val += nbytes;
7127 +                       rem_len -= nbytes;
7128 +               }
7129 +       }
7130 +
7131 +read_done:
7132 +               *ppos += ret_val;
7133 +
7134 +               return ret_val;
7135 +}
7136 +
7137 +static const struct file_operations fops_pktlog_dump = {
7138 +       .read = ath_pktlog_read,
7139 +       .mmap = ath_pktlog_mmap,
7140 +       .open = ath9k_debugfs_open
7141 +};
7142 +
7143 +static ssize_t write_pktlog_start(struct file *file, const char __user *ubuf,
7144 +                                  size_t count, loff_t *ppos)
7145 +{
7146 +       struct ath_softc *sc = file->private_data;
7147 +       struct ath_pktlog *pktlog = &sc->pktlog.pktlog;
7148 +       char buf[32];
7149 +       int buf_size;
7150 +       int start_pktlog, err;
7151 +
7152 +       buf_size = min(count, sizeof(buf) - 1);
7153 +       if (copy_from_user(buf, ubuf, buf_size))
7154 +               return -EFAULT;
7155 +
7156 +       sscanf(buf, "%d", &start_pktlog);
7157 +       if (start_pktlog) {
7158 +               if (pktlog->pktlog_buf != NULL)
7159 +                       ath_pktlog_release(pktlog);
7160 +
7161 +               err = ath_alloc_pktlog_buf(sc);
7162 +               if (err != 0)
7163 +                       return err;
7164 +
7165 +               ath_init_pktlog_buf(pktlog);
7166 +               pktlog->pktlog_buf->rd_offset = -1;
7167 +               pktlog->pktlog_buf->wr_offset = 0;
7168 +               sc->is_pkt_logging = 1;
7169 +       } else {
7170 +               sc->is_pkt_logging = 0;
7171 +       }
7172 +
7173 +       sc->sc_ah->is_pkt_logging = sc->is_pkt_logging;
7174 +       return count;
7175 +}
7176 +
7177 +static ssize_t read_pktlog_start(struct file *file, char __user *ubuf,
7178 +                                 size_t count, loff_t *ppos)
7179 +{
7180 +       char buf[32];
7181 +       struct ath_softc *sc = file->private_data;
7182 +       int len = 0;
7183 +
7184 +       len = scnprintf(buf, sizeof(buf) - len, "%d", sc->is_pkt_logging);
7185 +       return simple_read_from_buffer(ubuf, count, ppos, buf, len);
7186 +}
7187 +
7188 +static const struct file_operations fops_pktlog_start = {
7189 +       .read = read_pktlog_start,
7190 +       .write = write_pktlog_start,
7191 +       .open = ath9k_debugfs_open
7192 +};
7193 +
7194 +static ssize_t pktlog_size_write(struct file *file, const char __user *ubuf,
7195 +                                size_t count, loff_t *ppos)
7196 +{
7197 +       struct ath_softc *sc = file->private_data;
7198 +       char buf[32];
7199 +       u32 pktlog_size;
7200 +       int buf_size;
7201 +
7202 +       buf_size = min(count, sizeof(buf) - 1);
7203 +       if (copy_from_user(buf, ubuf, buf_size))
7204 +               return -EFAULT;
7205 +
7206 +       sscanf(buf, "%d", &pktlog_size);
7207 +
7208 +       if (pktlog_size == sc->pktlog.pktlog.pktlog_buf_size)
7209 +               return count;
7210 +
7211 +       if (sc->is_pkt_logging) {
7212 +               printk(KERN_DEBUG "Stop packet logging before"
7213 +                       " changing the pktlog size \n");
7214 +               return -EINVAL;
7215 +       }
7216 +
7217 +       sc->pktlog.pktlog.pktlog_buf_size = pktlog_size;
7218 +
7219 +       return count;
7220 +}
7221 +
7222 +static ssize_t pktlog_size_read(struct file *file, char __user *ubuf,
7223 +                               size_t count, loff_t *ppos)
7224 +{
7225 +       char buf[32];
7226 +       struct ath_softc *sc = file->private_data;
7227 +       int len = 0;
7228 +
7229 +       len = scnprintf(buf, sizeof(buf) - len, "%ul",
7230 +                           sc->pktlog.pktlog.pktlog_buf_size);
7231 +       return simple_read_from_buffer(ubuf, count, ppos, buf, len);
7232 +}
7233 +
7234 +static const struct file_operations fops_pktlog_size = {
7235 +       .read = pktlog_size_read,
7236 +       .write = pktlog_size_write,
7237 +       .open = ath9k_debugfs_open
7238 +};
7239 +
7240 +static ssize_t pktlog_filter_write(struct file *file, const char __user *ubuf,
7241 +                                  size_t count, loff_t *ppos)
7242 +{
7243 +       char buf[32];
7244 +       struct ath_softc *sc = file->private_data;
7245 +       u32 filter;
7246 +       int buf_count;
7247 +
7248 +       buf_count = min(count, sizeof(buf) - 1);
7249 +       if (copy_from_user(buf, ubuf, buf_count))
7250 +               return -EFAULT;
7251 +
7252 +       if (sscanf(buf, "%x", &filter))
7253 +               sc->pktlog.pktlog.pktlog_filter = filter;
7254 +       else
7255 +               sc->pktlog.pktlog.pktlog_filter = 0;
7256 +
7257 +       return count;
7258 +}
7259 +
7260 +static ssize_t  pktlog_filter_read(struct file *file, char __user *ubuf,
7261 +                                  size_t count, loff_t *ppos)
7262 +{
7263 +       char buf[32];
7264 +       struct ath_softc *sc = file->private_data;
7265 +       int len = 0;
7266 +
7267 +       len = scnprintf(buf, sizeof(buf) - len, "%ul",
7268 +                           sc->pktlog.pktlog.pktlog_filter);
7269 +
7270 +       return simple_read_from_buffer(ubuf, count, ppos, buf, len);
7271 +}
7272 +
7273 +static const struct file_operations fops_pktlog_filter = {
7274 +       .read = pktlog_filter_read,
7275 +       .write = pktlog_filter_write,
7276 +       .open = ath9k_debugfs_open
7277 +};
7278 +
7279 +void ath_pktlog_txctl(struct ath_softc *sc, struct ath_buf *bf)
7280 +{
7281 +       struct ath_pktlog_txctl *tx_log;
7282 +       struct ath_pktlog *pl_info;
7283 +       struct ieee80211_hdr *hdr;
7284 +       struct ath_desc_info desc_info;
7285 +       int i;
7286 +       u32 *ds_words, flags = 0;
7287 +
7288 +       pl_info = &sc->pktlog.pktlog;
7289 +
7290 +       if ((pl_info->pktlog_filter & ATH_PKTLOG_TX) == 0 ||
7291 +           bf->bf_mpdu == NULL || !sc->is_pkt_logging)
7292 +               return;
7293 +
7294 +       flags |= (((sc->sc_ah->hw_version.macRev <<
7295 +                       PHFLAGS_MACREV_SFT) & PHFLAGS_MACREV_MASK) |
7296 +                       ((sc->sc_ah->hw_version.macVersion << PHFLAGS_MACVERSION_SFT)
7297 +                       & PHFLAGS_MACVERSION_MASK));
7298 +
7299 +       tx_log = (struct ath_pktlog_txctl *)ath_pktlog_getbuf(pl_info,
7300 +                       PKTLOG_TYPE_TXCTL, sizeof(*tx_log), flags);
7301 +
7302 +       memset(tx_log, 0, sizeof(*tx_log));
7303 +
7304 +       hdr = (struct ieee80211_hdr *) bf->bf_mpdu->data;
7305 +       tx_log->framectrl = hdr->frame_control;
7306 +       tx_log->seqctrl   = hdr->seq_ctrl;
7307 +
7308 +       if (ieee80211_has_tods(tx_log->framectrl)) {
7309 +               tx_log->bssid_tail = (hdr->addr1[ETH_ALEN - 2] << 8) |
7310 +                                    (hdr->addr1[ETH_ALEN - 1]);
7311 +               tx_log->sa_tail    = (hdr->addr2[ETH_ALEN - 2] << 8) |
7312 +                                    (hdr->addr2[ETH_ALEN - 1]);
7313 +               tx_log->da_tail    = (hdr->addr3[ETH_ALEN - 2] << 8) |
7314 +                                    (hdr->addr3[ETH_ALEN - 1]);
7315 +       } else if (ieee80211_has_fromds(tx_log->framectrl)) {
7316 +               tx_log->bssid_tail = (hdr->addr2[ETH_ALEN - 2] << 8) |
7317 +                                    (hdr->addr2[ETH_ALEN - 1]);
7318 +               tx_log->sa_tail    = (hdr->addr3[ETH_ALEN - 2] << 8) |
7319 +                                    (hdr->addr3[ETH_ALEN - 1]);
7320 +               tx_log->da_tail    = (hdr->addr1[ETH_ALEN - 2] << 8) |
7321 +                                    (hdr->addr1[ETH_ALEN - 1]);
7322 +       } else {
7323 +               tx_log->bssid_tail = (hdr->addr3[ETH_ALEN - 2] << 8) |
7324 +                                    (hdr->addr3[ETH_ALEN - 1]);
7325 +               tx_log->sa_tail    = (hdr->addr2[ETH_ALEN - 2] << 8) |
7326 +                                    (hdr->addr2[ETH_ALEN - 1]);
7327 +               tx_log->da_tail    = (hdr->addr1[ETH_ALEN - 2] << 8) |
7328 +                                    (hdr->addr1[ETH_ALEN - 1]);
7329 +       }
7330 +
7331 +       ath9k_hw_get_descinfo(sc->sc_ah, &desc_info);
7332 +
7333 +       ds_words = (u32 *)(bf->bf_desc) + desc_info.txctl_offset;
7334 +       for (i = 0; i < desc_info.txctl_numwords; i++)
7335 +               tx_log->txdesc_ctl[i] = ds_words[i];
7336 +}
7337 +
7338 +void ath_pktlog_txstatus(struct ath_softc *sc, void *ds)
7339 +{
7340 +       struct ath_pktlog_txstatus *tx_log;
7341 +       struct ath_pktlog *pl_info;
7342 +       struct ath_desc_info desc_info;
7343 +       int i;
7344 +       u32 *ds_words, flags = 0;
7345 +
7346 +       pl_info = &sc->pktlog.pktlog;
7347 +
7348 +       if ((pl_info->pktlog_filter & ATH_PKTLOG_TX) == 0 ||
7349 +           !sc->is_pkt_logging)
7350 +               return;
7351 +
7352 +       flags |= (((sc->sc_ah->hw_version.macRev <<
7353 +                 PHFLAGS_MACREV_SFT) & PHFLAGS_MACREV_MASK) |
7354 +                 ((sc->sc_ah->hw_version.macVersion << PHFLAGS_MACVERSION_SFT)
7355 +                 & PHFLAGS_MACVERSION_MASK));
7356 +       tx_log = (struct ath_pktlog_txstatus *)ath_pktlog_getbuf(pl_info,
7357 +                       PKTLOG_TYPE_TXSTATUS, sizeof(*tx_log), flags);
7358 +
7359 +       memset(tx_log, 0, sizeof(*tx_log));
7360 +
7361 +       ath9k_hw_get_descinfo(sc->sc_ah, &desc_info);
7362 +
7363 +       ds_words = (u32 *)(ds) + desc_info.txstatus_offset;
7364 +
7365 +       for (i = 0; i < desc_info.txstatus_numwords; i++)
7366 +               tx_log->txdesc_status[i] = ds_words[i];
7367 +}
7368 +
7369 +void ath_pktlog_rx(struct ath_softc *sc, void *desc, struct sk_buff *skb)
7370 +{
7371 +       struct ath_pktlog_rx *rx_log;
7372 +       struct ath_pktlog *pl_info;
7373 +       struct ieee80211_hdr *hdr;
7374 +       struct ath_desc_info desc_info;
7375 +       int i;
7376 +       u32 *ds_words, flags = 0;
7377 +
7378 +       pl_info = &sc->pktlog.pktlog;
7379 +
7380 +       if ((pl_info->pktlog_filter & ATH_PKTLOG_RX) == 0 ||
7381 +           !sc->is_pkt_logging)
7382 +               return;
7383 +
7384 +       flags |= (((sc->sc_ah->hw_version.macRev <<
7385 +                 PHFLAGS_MACREV_SFT) & PHFLAGS_MACREV_MASK) |
7386 +                 ((sc->sc_ah->hw_version.macVersion <<
7387 +                PHFLAGS_MACVERSION_SFT) & PHFLAGS_MACVERSION_MASK));
7388 +
7389 +       rx_log = (struct ath_pktlog_rx *)ath_pktlog_getbuf(pl_info, PKTLOG_TYPE_RX,
7390 +                       sizeof(*rx_log), flags);
7391 +
7392 +       memset(rx_log, 0, sizeof(*rx_log));
7393 +
7394 +       if (skb->len > sizeof(struct ieee80211_hdr)) {
7395 +               hdr = (struct ieee80211_hdr *) skb->data;
7396 +               rx_log->framectrl = hdr->frame_control;
7397 +               rx_log->seqctrl   = hdr->seq_ctrl;
7398 +
7399 +               if (ieee80211_has_tods(rx_log->framectrl)) {
7400 +                       rx_log->bssid_tail = (hdr->addr1[ETH_ALEN - 2] << 8) |
7401 +                                            (hdr->addr1[ETH_ALEN - 1]);
7402 +                       rx_log->sa_tail    = (hdr->addr2[ETH_ALEN - 2] << 8) |
7403 +                                            (hdr->addr2[ETH_ALEN - 1]);
7404 +                       rx_log->da_tail    = (hdr->addr3[ETH_ALEN - 2] << 8) |
7405 +                                            (hdr->addr3[ETH_ALEN - 1]);
7406 +               } else if (ieee80211_has_fromds(rx_log->framectrl)) {
7407 +                       rx_log->bssid_tail = (hdr->addr2[ETH_ALEN - 2] << 8) |
7408 +                                            (hdr->addr2[ETH_ALEN - 1]);
7409 +                       rx_log->sa_tail    = (hdr->addr3[ETH_ALEN - 2] << 8) |
7410 +                                            (hdr->addr3[ETH_ALEN - 1]);
7411 +                       rx_log->da_tail    = (hdr->addr1[ETH_ALEN - 2] << 8) |
7412 +                                            (hdr->addr1[ETH_ALEN - 1]);
7413 +               } else {
7414 +                       rx_log->bssid_tail = (hdr->addr3[ETH_ALEN - 2] << 8) |
7415 +                                            (hdr->addr3[ETH_ALEN - 1]);
7416 +                       rx_log->sa_tail    = (hdr->addr2[ETH_ALEN - 2] << 8) |
7417 +                                            (hdr->addr2[ETH_ALEN - 1]);
7418 +                       rx_log->da_tail    = (hdr->addr1[ETH_ALEN - 2] << 8) |
7419 +                                            (hdr->addr1[ETH_ALEN - 1]);
7420 +               }
7421 +       } else {
7422 +               hdr = (struct ieee80211_hdr *) skb->data;
7423 +
7424 +               if (ieee80211_is_ctl(hdr->frame_control)) {
7425 +                       rx_log->framectrl = hdr->frame_control;
7426 +                       rx_log->da_tail = (hdr->addr1[ETH_ALEN - 2] << 8) |
7427 +                                            (hdr->addr1[ETH_ALEN - 1]);
7428 +                       if (skb->len < sizeof(struct ieee80211_rts)) {
7429 +                               rx_log->sa_tail = 0;
7430 +                       } else {
7431 +                               rx_log->sa_tail = (hdr->addr2[ETH_ALEN - 2]
7432 +                                                 << 8) |
7433 +                                                 (hdr->addr2[ETH_ALEN - 1]);
7434 +                       }
7435 +               } else {
7436 +                       rx_log->framectrl = 0xFFFF;
7437 +                       rx_log->da_tail = 0;
7438 +                       rx_log->sa_tail = 0;
7439 +               }
7440 +
7441 +               rx_log->seqctrl   = 0;
7442 +               rx_log->bssid_tail = 0;
7443 +       }
7444 +
7445 +       ath9k_hw_get_descinfo(sc->sc_ah, &desc_info);
7446 +
7447 +       ds_words = (u32 *)(desc) + desc_info.rxstatus_offset;
7448 +
7449 +       for (i = 0; i < desc_info.rxstatus_numwords; i++)
7450 +               rx_log->rxdesc_status[i] = ds_words[i];
7451 +}
7452 +
7453 +void ath9k_pktlog_rc(struct ath_softc *sc, struct ath_rate_priv *ath_rc_priv,
7454 +                    int8_t ratecode, u8 rate, int8_t is_probing, u16 ac)
7455 +{
7456 +       struct ath_pktlog_rcfind *rcf_log;
7457 +       struct ath_pktlog *pl_info;
7458 +       u32 flags = 0;
7459 +
7460 +       pl_info = &sc->pktlog.pktlog;
7461 +
7462 +       if ((pl_info->pktlog_filter & ATH_PKTLOG_RCFIND) == 0 ||
7463 +           !sc->is_pkt_logging)
7464 +               return;
7465 +
7466 +       flags |= (((sc->sc_ah->hw_version.macRev <<
7467 +                PHFLAGS_MACREV_SFT) & PHFLAGS_MACREV_MASK) |
7468 +                ((sc->sc_ah->hw_version.macVersion <<
7469 +                PHFLAGS_MACVERSION_SFT) & PHFLAGS_MACVERSION_MASK));
7470 +       rcf_log = (struct ath_pktlog_rcfind *)ath_pktlog_getbuf(pl_info,
7471 +                 PKTLOG_TYPE_RCFIND, sizeof(*rcf_log), flags);
7472 +
7473 +       rcf_log->rate = rate;
7474 +       rcf_log->rateCode = ratecode;
7475 +       rcf_log->rcProbeRate = is_probing ? ath_rc_priv->probe_rate : 0;
7476 +       rcf_log->isProbing = is_probing;
7477 +       rcf_log->ac = ac;
7478 +       rcf_log->rcRateMax = ath_rc_priv->rate_max_phy;
7479 +       rcf_log->rcRateTableSize = ath_rc_priv->rate_table_size;
7480 +}
7481 +
7482 +void ath9k_pktlog_rcupdate(struct ath_softc *sc, struct ath_rate_priv *ath_rc_priv, u8 tx_rate,
7483 +                          u8 rate_code, u8 xretries, u8 retries, int8_t rssi, u16 ac)
7484 +{
7485 +       struct ath_pktlog_rcupdate *rcu_log;
7486 +       struct ath_pktlog *pl_info;
7487 +       int i;
7488 +       u32 flags = 0;
7489 +
7490 +       pl_info = &sc->pktlog.pktlog;
7491 +
7492 +       if ((pl_info->pktlog_filter & ATH_PKTLOG_RCUPDATE) == 0 ||
7493 +           !sc->is_pkt_logging)
7494 +               return;
7495 +
7496 +       flags |= (((sc->sc_ah->hw_version.macRev <<
7497 +                PHFLAGS_MACREV_SFT) & PHFLAGS_MACREV_MASK) |
7498 +                ((sc->sc_ah->hw_version.macVersion <<
7499 +                PHFLAGS_MACVERSION_SFT) & PHFLAGS_MACVERSION_MASK));
7500 +       rcu_log = (struct ath_pktlog_rcupdate *)ath_pktlog_getbuf(pl_info,
7501 +                                               PKTLOG_TYPE_RCUPDATE,
7502 +                                               sizeof(*rcu_log), flags);
7503 +
7504 +       memset(rcu_log, 0, sizeof(*rcu_log));
7505 +
7506 +       rcu_log->txRate = tx_rate;
7507 +       rcu_log->rateCode = rate_code;
7508 +       rcu_log->Xretries = xretries;
7509 +       rcu_log->retries = retries;
7510 +       rcu_log->rssiAck = rssi;
7511 +       rcu_log->ac = ac;
7512 +       rcu_log->rcProbeRate = ath_rc_priv->probe_rate;
7513 +       rcu_log->rcRateMax = ath_rc_priv->rate_max_phy;
7514 +
7515 +       for (i = 0; i < RATE_TABLE_SIZE; i++) {
7516 +               rcu_log->rcPer[i] = ath_rc_priv->per[i];
7517 +       }
7518 +}
7519 +
7520 +void ath9k_pktlog_txcomplete(struct ath_softc *sc, struct list_head *bf_head,
7521 +                            struct ath_buf *bf, struct ath_buf *bf_last)
7522 +{
7523 +       struct log_tx ;
7524 +       struct ath_buf *tbf;
7525 +
7526 +       list_for_each_entry(tbf, bf_head, list)
7527 +               ath_pktlog_txctl(sc, tbf);
7528 +
7529 +       if (bf->bf_next == NULL && bf_last->bf_stale)
7530 +               ath_pktlog_txctl(sc, bf_last);
7531 +}
7532 +
7533 +void ath9k_pktlog_txctrl(struct ath_softc *sc, struct list_head *bf_head, struct ath_buf *lastbf)
7534 +{
7535 +       struct log_tx ;
7536 +       struct ath_buf *tbf;
7537 +
7538 +       list_for_each_entry(tbf, bf_head, list)
7539 +               ath_pktlog_txctl(sc, tbf);
7540 +
7541 +       /* log the last descriptor. */
7542 +       ath_pktlog_txctl(sc, lastbf);
7543 +}
7544 +
7545 +static void pktlog_init(struct ath_softc *sc)
7546 +{
7547 +       spin_lock_init(&sc->pktlog.pktlog.pktlog_lock);
7548 +       sc->pktlog.pktlog.pktlog_buf_size = ATH_DEBUGFS_PKTLOG_SIZE_DEFAULT;
7549 +       sc->pktlog.pktlog.pktlog_buf = NULL;
7550 +       sc->pktlog.pktlog.pktlog_filter = 0;
7551 +}
7552 +
7553 +int ath9k_init_pktlog(struct ath_softc *sc)
7554 +{
7555 +       sc->pktlog.debugfs_pktlog = debugfs_create_dir("pktlog",
7556 +                       sc->debug.debugfs_phy);
7557 +       if (!sc->pktlog.debugfs_pktlog)
7558 +               goto err;
7559 +
7560 +       sc->pktlog.pktlog_start = debugfs_create_file("pktlog_start",
7561 +                       S_IRUGO | S_IWUSR,
7562 +                       sc->pktlog.debugfs_pktlog,
7563 +                       sc, &fops_pktlog_start);
7564 +       if (!sc->pktlog.pktlog_start)
7565 +               goto err;
7566 +
7567 +       sc->pktlog.pktlog_size = debugfs_create_file("pktlog_size",
7568 +                       S_IRUGO | S_IWUSR,
7569 +                       sc->pktlog.debugfs_pktlog,
7570 +                       sc, &fops_pktlog_size);
7571 +       if (!sc->pktlog.pktlog_size)
7572 +               goto err;
7573 +
7574 +       sc->pktlog.pktlog_filter = debugfs_create_file("pktlog_filter",
7575 +                       S_IRUGO | S_IWUSR,
7576 +                       sc->pktlog.debugfs_pktlog,
7577 +                       sc, &fops_pktlog_filter);
7578 +       if (!sc->pktlog.pktlog_filter)
7579 +               goto err;
7580 +
7581 +       sc->pktlog.pktlog_dump = debugfs_create_file("pktlog_dump",
7582 +                       S_IRUGO,
7583 +                       sc->pktlog.debugfs_pktlog,
7584 +                       sc, &fops_pktlog_dump);
7585 +       if (!sc->pktlog.pktlog_dump)
7586 +               goto err;
7587 +
7588 +       pktlog_init(sc);
7589 +
7590 +       return 0;
7591 +
7592 +err:
7593 +       return -ENOMEM;
7594 +}
7595 +
7596 +void ath9k_deinit_pktlog(struct ath_softc *sc)
7597 +{
7598 +       struct ath_pktlog *pktlog = &sc->pktlog.pktlog;
7599 +
7600 +       if (pktlog->pktlog_buf != NULL)
7601 +               ath_pktlog_release(pktlog);
7602 +
7603 +       debugfs_remove(sc->pktlog.pktlog_start);
7604 +       debugfs_remove(sc->pktlog.pktlog_size);
7605 +       debugfs_remove(sc->pktlog.pktlog_filter);
7606 +       debugfs_remove(sc->pktlog.pktlog_dump);
7607 +       debugfs_remove(sc->pktlog.debugfs_pktlog);
7608 +}
7609 --- /dev/null
7610 +++ b/drivers/net/wireless/ath/ath9k/pktlog.h
7611 @@ -0,0 +1,235 @@
7612 +#ifndef PKTLOG_H
7613 +#define PKTLOG_H
7614 +
7615 +#ifdef CONFIG_ATH9K_PKTLOG
7616 +#define CUR_PKTLOG_VER          10010  /* Packet log version */
7617 +#define PKTLOG_MAGIC_NUM        7735225
7618 +#define ATH_PKTLOG_TX          0x000000001
7619 +#define ATH_PKTLOG_RX          0x000000002
7620 +#define ATH_PKTLOG_RCFIND      0x000000004
7621 +#define ATH_PKTLOG_RCUPDATE    0x000000008
7622 +
7623 +#define ATH_DEBUGFS_PKTLOG_SIZE_DEFAULT (1024 * 1024)
7624 +#define ATH_PKTLOG_FILTER_DEFAULT (ATH_PKTLOG_TX | ATH_PKTLOG_RX |     \
7625 +               ATH_PKTLOG_RCFIND | ATH_PKTLOG_RCUPDATE)
7626 +
7627 +#define PHFLAGS_MACVERSION_MASK 0x00ff0000
7628 +#define PHFLAGS_MACVERSION_SFT  16
7629 +#define PHFLAGS_MACREV_MASK 0xff0  /* MAC revision */
7630 +#define PHFLAGS_MACREV_SFT  4
7631 +
7632 +struct ath_pktlog_hdr {
7633 +       u32 flags;
7634 +       u16 log_type; /* Type of log information foll this header */
7635 +       int16_t size; /* Size of variable length log information in bytes */
7636 +       u32 timestamp;
7637 +}  __packed;
7638 +
7639 +/* Types of packet log events */
7640 +#define PKTLOG_TYPE_TXCTL    0
7641 +#define PKTLOG_TYPE_TXSTATUS 1
7642 +#define PKTLOG_TYPE_RX       2
7643 +#define PKTLOG_TYPE_RCFIND   3
7644 +#define PKTLOG_TYPE_RCUPDATE 4
7645 +
7646 +#define PKTLOG_MAX_TXCTL_WORDS 12
7647 +#define PKTLOG_MAX_TXSTATUS_WORDS 10
7648 +#define PKTLOG_MAX_PROTO_WORDS  16
7649 +
7650 +struct ath_pktlog_txctl {
7651 +       __le16 framectrl;       /* frame control field from header */
7652 +       __le16 seqctrl;         /* frame control field from header */
7653 +       u16 bssid_tail;      /* last two octets of bssid */
7654 +       u16 sa_tail;         /* last two octets of SA */
7655 +       u16 da_tail;         /* last two octets of DA */
7656 +       u16 resvd;
7657 +       u32 txdesc_ctl[PKTLOG_MAX_TXCTL_WORDS];     /* Tx descriptor words */
7658 +       unsigned long proto_hdr;   /* protocol header (variable length!) */
7659 +       int32_t misc[0]; /* Can be used for HT specific or other misc info */
7660 +}  __packed;
7661 +
7662 +struct ath_pktlog_txstatus {
7663 +       /* Tx descriptor status words */
7664 +       u32 txdesc_status[PKTLOG_MAX_TXSTATUS_WORDS];
7665 +       int32_t misc[0]; /* Can be used for HT specific or other misc info */
7666 +}  __packed;
7667 +
7668 +#define PKTLOG_MAX_RXSTATUS_WORDS 11
7669 +
7670 +struct ath_pktlog_rx {
7671 +       u16 framectrl;       /* frame control field from header */
7672 +       u16 seqctrl;         /* sequence control field */
7673 +       u16 bssid_tail;      /* last two octets of bssid */
7674 +       u16 sa_tail;         /* last two octets of SA */
7675 +       u16 da_tail;         /* last two octets of DA */
7676 +       u16 resvd;
7677 +       u32 rxdesc_status[PKTLOG_MAX_RXSTATUS_WORDS];  /* Rx descriptor words */
7678 +       unsigned long proto_hdr;   /* protocol header (variable length!) */
7679 +       int32_t misc[0];    /* Can be used for HT specific or other misc info */
7680 +}  __packed;
7681 +
7682 +struct ath_pktlog_rcfind {
7683 +       u8 rate;
7684 +       u8 rateCode;
7685 +       s8 rcRssiLast;
7686 +       s8 rcRssiLastPrev;
7687 +       s8 rcRssiLastPrev2;
7688 +       s8 rssiReduce;
7689 +       u8 rcProbeRate;
7690 +       s8 isProbing;
7691 +       s8 primeInUse;
7692 +       s8 currentPrimeState;
7693 +       u8 rcRateTableSize;
7694 +       u8 rcRateMax;
7695 +       u8 ac;
7696 +       int32_t misc[0]; /* Can be used for HT specific or other misc info */
7697 +}  __packed;
7698 +
7699 +struct ath_pktlog_rcupdate {
7700 +       u8 txRate;
7701 +       u8 rateCode;
7702 +       s8 rssiAck;
7703 +       u8 Xretries;
7704 +       u8 retries;
7705 +       s8 rcRssiLast;
7706 +       s8 rcRssiLastLkup;
7707 +       s8 rcRssiLastPrev;
7708 +       s8 rcRssiLastPrev2;
7709 +       u8 rcProbeRate;
7710 +       u8 rcRateMax;
7711 +       s8 useTurboPrime;
7712 +       s8 currentBoostState;
7713 +       u8 rcHwMaxRetryRate;
7714 +       u8 ac;
7715 +       u8 resvd[2];
7716 +       s8 rcRssiThres[RATE_TABLE_SIZE];
7717 +       u8 rcPer[RATE_TABLE_SIZE];
7718 +       u8 resv2[RATE_TABLE_SIZE + 5];
7719 +       int32_t misc[0]; /* Can be used for HT specific or other misc info */
7720 +};
7721 +
7722 +#define TXCTL_OFFSET(ah)      (AR_SREV_9300_20_OR_LATER(ah) ? 11 : 2)
7723 +#define TXCTL_NUMWORDS(ah)    (AR_SREV_5416_20_OR_LATER(ah) ? 12 : 8)
7724 +#define TXSTATUS_OFFSET(ah)   (AR_SREV_9300_20_OR_LATER(ah) ? 2 : 14)
7725 +#define TXSTATUS_NUMWORDS(ah) (AR_SREV_9300_20_OR_LATER(ah) ? 7 : 10)
7726 +
7727 +#define RXCTL_OFFSET(ah)      (AR_SREV_9300_20_OR_LATER(ah) ? 0 : 3)
7728 +#define RXCTL_NUMWORDS(ah)    (AR_SREV_9300_20_OR_LATER(ah) ? 0 : 1)
7729 +#define RXSTATUS_OFFSET(ah)   (AR_SREV_9300_20_OR_LATER(ah) ? 1 : 4)
7730 +#define RXSTATUS_NUMWORDS(ah) (AR_SREV_9300_20_OR_LATER(ah) ? 11 : 9)
7731 +
7732 +struct ath_desc_info {
7733 +       u8 txctl_offset;
7734 +       u8 txctl_numwords;
7735 +       u8 txstatus_offset;
7736 +       u8 txstatus_numwords;
7737 +       u8 rxctl_offset;
7738 +       u8 rxctl_numwords;
7739 +       u8 rxstatus_offset;
7740 +       u8 rxstatus_numwords;
7741 +};
7742 +
7743 +#define PKTLOG_MOV_RD_IDX(_rd_offset, _log_buf, _log_size)  \
7744 +       do { \
7745 +               if ((_rd_offset + sizeof(struct ath_pktlog_hdr) + \
7746 +                   ((struct ath_pktlog_hdr *)((_log_buf)->log_data + \
7747 +                           (_rd_offset)))->size) <= _log_size) { \
7748 +                       _rd_offset = ((_rd_offset) + \
7749 +                                       sizeof(struct ath_pktlog_hdr) + \
7750 +                                       ((struct ath_pktlog_hdr *) \
7751 +                                        ((_log_buf)->log_data + \
7752 +                                         (_rd_offset)))->size); \
7753 +               } else { \
7754 +                       _rd_offset = ((struct ath_pktlog_hdr *) \
7755 +                                       ((_log_buf)->log_data +  \
7756 +                                        (_rd_offset)))->size;  \
7757 +               } \
7758 +               (_rd_offset) = (((_log_size) - (_rd_offset)) >= \
7759 +                               sizeof(struct ath_pktlog_hdr)) ? \
7760 +               _rd_offset : 0; \
7761 +       } while (0);
7762 +
7763 +struct ath_pktlog_bufhdr {
7764 +       u32 magic_num;  /* Used by post processing scripts */
7765 +       u32 version;    /* Set to CUR_PKTLOG_VER */
7766 +};
7767 +
7768 +struct ath_pktlog_buf {
7769 +       struct ath_pktlog_bufhdr bufhdr;
7770 +       int32_t rd_offset;
7771 +       int32_t wr_offset;
7772 +       char log_data[0];
7773 +};
7774 +
7775 +struct ath_pktlog {
7776 +       struct ath_pktlog_buf *pktlog_buf;
7777 +       u32 pktlog_filter;
7778 +       u32 pktlog_buf_size;           /* Size of buffer in bytes */
7779 +       spinlock_t pktlog_lock;
7780 +};
7781 +
7782 +struct ath_pktlog_debugfs {
7783 +       struct dentry *debugfs_pktlog;
7784 +       struct dentry *pktlog_enable;
7785 +       struct dentry *pktlog_start;
7786 +       struct dentry *pktlog_filter;
7787 +       struct dentry *pktlog_size;
7788 +       struct dentry *pktlog_dump;
7789 +       struct ath_pktlog pktlog;
7790 +};
7791 +
7792 +void ath_pktlog_txctl(struct ath_softc *sc, struct ath_buf *bf);
7793 +void ath_pktlog_txstatus(struct ath_softc *sc, void *ds);
7794 +void ath_pktlog_rx(struct ath_softc *sc, void *ds, struct sk_buff *skb);
7795 +void ath9k_pktlog_rc(struct ath_softc *sc, struct ath_rate_priv *ath_rc_priv,
7796 +               int8_t ratecode, u8 rate, int8_t is_probing, u16 ac);
7797 +void ath9k_pktlog_rcupdate(struct ath_softc *sc,
7798 +                          struct ath_rate_priv *ath_rc_priv, u8 tx_rate,
7799 +                          u8 rate_code, u8 xretries, u8 retries, int8_t rssi,
7800 +                          u16 ac);
7801 +void ath9k_pktlog_txcomplete(struct ath_softc *sc ,struct list_head *bf_head,
7802 +                            struct ath_buf *bf, struct ath_buf *bf_last);
7803 +void ath9k_pktlog_txctrl(struct ath_softc *sc, struct list_head *bf_head,
7804 +                        struct ath_buf *lastbf);
7805 +int ath9k_init_pktlog(struct ath_softc *sc);
7806 +void ath9k_deinit_pktlog(struct ath_softc *sc);
7807 +#else /* CONFIG_ATH9K_PKTLOG */
7808 +static inline void ath_pktlog_txstatus(struct ath_softc *sc, void *ds)
7809 +{
7810 +}
7811 +
7812 +static inline void ath_pktlog_rx(struct ath_softc *sc, void *ds,
7813 +                                struct sk_buff *skb)
7814 +{
7815 +}
7816 +
7817 +static inline void ath9k_pktlog_rc(struct ath_softc *sc,
7818 +                                  struct ath_rate_priv *ath_rc_priv,
7819 +                                  int8_t ratecode, u8 rate,
7820 +                                  int8_t is_probing, u16 ac)
7821 +{
7822 +}
7823 +
7824 +static inline void ath9k_pktlog_rcupdate(struct ath_softc *sc,
7825 +                                        struct ath_rate_priv *ath_rc_priv,
7826 +                                        u8 tx_rate, u8 rate_code,
7827 +                                        u8 xretries, u8 retries,
7828 +                                        int8_t rssi, u16 ac)
7829 +{
7830 +}
7831 +
7832 +static inline void ath9k_pktlog_txcomplete(struct ath_softc *sc,
7833 +                                          struct list_head *bf_head,
7834 +                                          struct ath_buf *bf,
7835 +                                          struct ath_buf *bf_last)
7836 +{
7837 +}
7838 +
7839 +static inline void ath9k_pktlog_txctrl(struct ath_softc *sc,
7840 +                                      struct list_head *bf_head,
7841 +                                      struct ath_buf *lastbf)
7842 +{
7843 +}
7844 +#endif /* CONFIG_ATH9K_PKTLOG */
7845 +
7846 +#endif
7847 --- a/drivers/net/wireless/ath/ath9k/rc.c
7848 +++ b/drivers/net/wireless/ath/ath9k/rc.c
7849 @@ -40,73 +40,75 @@ static const struct ath_rate_table ar541
7850                 { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */
7851                         29300, 7, 108, 4, 7, 7, 7, 7 },
7852                 { VALID_2040, VALID_2040, WLAN_RC_PHY_HT_20_SS, 6500, /* 6.5 Mb */
7853 -                       6400, 0, 0, 0, 8, 24, 8, 24 },
7854 +                       6400, 0, 0, 0, 8, 25, 8, 25 },
7855                 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 13000, /* 13 Mb */
7856 -                       12700, 1, 1, 2, 9, 25, 9, 25 },
7857 +                       12700, 1, 1, 2, 9, 26, 9, 26 },
7858                 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 19500, /* 19.5 Mb */
7859 -                       18800, 2, 2, 2, 10, 26, 10, 26 },
7860 +                       18800, 2, 2, 2, 10, 27, 10, 27 },
7861                 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 26000, /* 26 Mb */
7862 -                       25000, 3, 3, 4, 11, 27, 11, 27 },
7863 +                       25000, 3, 3, 4, 11, 28, 11, 28 },
7864                 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 39000, /* 39 Mb */
7865 -                       36700, 4, 4, 4, 12, 28, 12, 28 },
7866 +                       36700, 4, 4, 4, 12, 29, 12, 29 },
7867                 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 52000, /* 52 Mb */
7868 -                       48100, 5, 5, 4, 13, 29, 13, 29 },
7869 +                       48100, 5, 5, 4, 13, 30, 13, 30 },
7870                 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 58500, /* 58.5 Mb */
7871 -                       53500, 6, 6, 4, 14, 30, 14, 30 },
7872 +                       53500, 6, 6, 4, 14, 31, 14, 31 },
7873                 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 65000, /* 65 Mb */
7874 -                       59000, 7, 7, 4, 15, 31, 15, 32 },
7875 +                       59000, 7, 7, 4, 15, 32, 15, 33 },
7876                 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 13000, /* 13 Mb */
7877 -                       12700, 8, 8, 3, 16, 33, 16, 33 },
7878 +                       12700, 8, 8, 3, 16, 34, 16, 34 },
7879                 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 26000, /* 26 Mb */
7880 -                       24800, 9, 9, 2, 17, 34, 17, 34 },
7881 +                       24800, 9, 9, 2, 17, 35, 17, 35 },
7882                 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 39000, /* 39 Mb */
7883 -                       36600, 10, 10, 2, 18, 35, 18, 35 },
7884 +                       36600, 10, 10, 2, 18, 36, 18, 36 },
7885                 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 52000, /* 52 Mb */
7886 -                       48100, 11, 11, 4, 19, 36, 19, 36 },
7887 +                       48100, 11, 11, 4, 19, 37, 19, 37 },
7888                 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 78000, /* 78 Mb */
7889 -                       69500, 12, 12, 4, 20, 37, 20, 37 },
7890 +                       69500, 12, 12, 4, 20, 38, 20, 38 },
7891                 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 104000, /* 104 Mb */
7892 -                       89500, 13, 13, 4, 21, 38, 21, 38 },
7893 +                       89500, 13, 13, 4, 21, 39, 21, 39 },
7894                 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 117000, /* 117 Mb */
7895 -                       98900, 14, 14, 4, 22, 39, 22, 39 },
7896 +                       98900, 14, 14, 4, 22, 40, 22, 40 },
7897                 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 130000, /* 130 Mb */
7898 -                       108300, 15, 15, 4, 23, 40, 23, 41 },
7899 +                       108300, 15, 15, 4, 23, 41, 24, 42 },
7900 +               { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS_HGI, 144400, /* 144.4 Mb */
7901 +                       12000, 15, 15, 4, 23, 41, 24, 42 },
7902                 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 13500, /* 13.5 Mb */
7903 -                       13200, 0, 0, 0, 8, 24, 24, 24 },
7904 +                       13200, 0, 0, 0, 8, 25, 25, 25 },
7905                 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 27500, /* 27.0 Mb */
7906 -                       25900, 1, 1, 2, 9, 25, 25, 25 },
7907 +                       25900, 1, 1, 2, 9, 26, 26, 26 },
7908                 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 40500, /* 40.5 Mb */
7909 -                       38600, 2, 2, 2, 10, 26, 26, 26 },
7910 +                       38600, 2, 2, 2, 10, 27, 27, 27 },
7911                 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 54000, /* 54 Mb */
7912 -                       49800, 3, 3, 4, 11, 27, 27, 27 },
7913 +                       49800, 3, 3, 4, 11, 28, 28, 28 },
7914                 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 81500, /* 81 Mb */
7915 -                       72200, 4, 4, 4, 12, 28, 28, 28 },
7916 +                       72200, 4, 4, 4, 12, 29, 29, 29 },
7917                 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 108000, /* 108 Mb */
7918 -                       92900, 5, 5, 4, 13, 29, 29, 29 },
7919 +                       92900, 5, 5, 4, 13, 30, 30, 30 },
7920                 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 121500, /* 121.5 Mb */
7921 -                       102700, 6, 6, 4, 14, 30, 30, 30 },
7922 +                       102700, 6, 6, 4, 14, 31, 31, 31 },
7923                 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 135000, /* 135 Mb */
7924 -                       112000, 7, 7, 4, 15, 31, 32, 32 },
7925 +                       112000, 7, 7, 4, 15, 32, 33, 33 },
7926                 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS_HGI, 150000, /* 150 Mb */
7927 -                       122000, 7, 7, 4, 15, 31, 32, 32 },
7928 +                       122000, 7, 7, 4, 15, 32, 33, 33 },
7929                 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 27000, /* 27 Mb */
7930 -                       25800, 8, 8, 0, 16, 33, 33, 33 },
7931 +                       25800, 8, 8, 0, 16, 34, 34, 34 },
7932                 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 54000, /* 54 Mb */
7933 -                       49800, 9, 9, 2, 17, 34, 34, 34 },
7934 +                       49800, 9, 9, 2, 17, 35, 35, 35 },
7935                 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 81000, /* 81 Mb */
7936 -                       71900, 10, 10, 2, 18, 35, 35, 35 },
7937 +                       71900, 10, 10, 2, 18, 36, 36, 36 },
7938                 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 108000, /* 108 Mb */
7939 -                       92500, 11, 11, 4, 19, 36, 36, 36 },
7940 +                       92500, 11, 11, 4, 19, 37, 37, 37 },
7941                 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 162000, /* 162 Mb */
7942 -                       130300, 12, 12, 4, 20, 37, 37, 37 },
7943 +                       130300, 12, 12, 4, 20, 38, 38, 38 },
7944                 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 216000, /* 216 Mb */
7945 -                       162800, 13, 13, 4, 21, 38, 38, 38 },
7946 +                       162800, 13, 13, 4, 21, 39, 39, 39 },
7947                 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 243000, /* 243 Mb */
7948 -                       178200, 14, 14, 4, 22, 39, 39, 39 },
7949 +                       178200, 14, 14, 4, 22, 40, 40, 40 },
7950                 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 270000, /* 270 Mb */
7951 -                       192100, 15, 15, 4, 23, 40, 41, 41 },
7952 +                       192100, 15, 15, 4, 23, 41, 42, 42 },
7953                 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS_HGI, 300000, /* 300 Mb */
7954 -                       207000, 15, 15, 4, 23, 40, 41, 41 },
7955 +                       207000, 15, 15, 4, 23, 41, 42, 42 },
7956         },
7957         50,  /* probe interval */
7958         WLAN_RC_HT_FLAG,  /* Phy rates allowed initially */
7959 @@ -144,73 +146,75 @@ static const struct ath_rate_table ar541
7960                 { VALID, VALID, WLAN_RC_PHY_OFDM, 54000, /* 54 Mb */
7961                         30900, 11, 108, 8, 11, 11, 11, 11 },
7962                 { INVALID, INVALID, WLAN_RC_PHY_HT_20_SS, 6500, /* 6.5 Mb */
7963 -                       6400, 0, 0, 4, 12, 28, 12, 28 },
7964 +                       6400, 0, 0, 4, 12, 29, 12, 29 },
7965                 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 13000, /* 13 Mb */
7966 -                       12700, 1, 1, 6, 13, 29, 13, 29 },
7967 +                       12700, 1, 1, 6, 13, 30, 13, 30 },
7968                 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 19500, /* 19.5 Mb */
7969 -                       18800, 2, 2, 6, 14, 30, 14, 30 },
7970 +                       18800, 2, 2, 6, 14, 31, 14, 31 },
7971                 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 26000, /* 26 Mb */
7972 -                       25000, 3, 3, 8, 15, 31, 15, 31 },
7973 +                       25000, 3, 3, 8, 15, 32, 15, 32 },
7974                 { VALID_20, VALID_20, WLAN_RC_PHY_HT_20_SS, 39000, /* 39 Mb */
7975 -                       36700, 4, 4, 8, 16, 32, 16, 32 },
7976 +                       36700, 4, 4, 8, 16, 33, 16, 33 },
7977                 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 52000, /* 52 Mb */
7978 -                       48100, 5, 5, 8, 17, 33, 17, 33 },
7979 +                       48100, 5, 5, 8, 17, 34, 17, 34 },
7980                 { INVALID,  VALID_20, WLAN_RC_PHY_HT_20_SS, 58500, /* 58.5 Mb */
7981 -                       53500, 6, 6, 8, 18, 34, 18, 34 },
7982 +                       53500, 6, 6, 8, 18, 35, 18, 35 },
7983                 { INVALID, VALID_20, WLAN_RC_PHY_HT_20_SS, 65000, /* 65 Mb */
7984 -                       59000, 7, 7, 8, 19, 35, 19, 36 },
7985 +                       59000, 7, 7, 8, 19, 36, 19, 37 },
7986                 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 13000, /* 13 Mb */
7987 -                       12700, 8, 8, 4, 20, 37, 20, 37 },
7988 +                       12700, 8, 8, 4, 20, 38, 20, 38 },
7989                 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 26000, /* 26 Mb */
7990 -                       24800, 9, 9, 6, 21, 38, 21, 38 },
7991 +                       24800, 9, 9, 6, 21, 39, 21, 39 },
7992                 { INVALID, INVALID, WLAN_RC_PHY_HT_20_DS, 39000, /* 39 Mb */
7993 -                       36600, 10, 10, 6, 22, 39, 22, 39 },
7994 +                       36600, 10, 10, 6, 22, 40, 22, 40 },
7995                 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 52000, /* 52 Mb */
7996 -                       48100, 11, 11, 8, 23, 40, 23, 40 },
7997 +                       48100, 11, 11, 8, 23, 41, 23, 41 },
7998                 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 78000, /* 78 Mb */
7999 -                       69500, 12, 12, 8, 24, 41, 24, 41 },
8000 +                       69500, 12, 12, 8, 24, 42, 24, 42 },
8001                 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 104000, /* 104 Mb */
8002 -                       89500, 13, 13, 8, 25, 42, 25, 42 },
8003 +                       89500, 13, 13, 8, 25, 43, 25, 43 },
8004                 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 117000, /* 117 Mb */
8005 -                       98900, 14, 14, 8, 26, 43, 26, 44 },
8006 +                       98900, 14, 14, 8, 26, 44, 26, 44 },
8007                 { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS, 130000, /* 130 Mb */
8008 -                       108300, 15, 15, 8, 27, 44, 27, 45 },
8009 +                       108300, 15, 15, 8, 27, 45, 28, 46 },
8010 +               { VALID_20, INVALID, WLAN_RC_PHY_HT_20_DS_HGI, 144400, /* 130 Mb */
8011 +                       120000, 15, 15, 8, 27, 45, 28, 46 },
8012                 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 13500, /* 13.5 Mb */
8013 -                       13200, 0, 0, 8, 12, 28, 28, 28 },
8014 +                       13200, 0, 0, 8, 12, 29, 29, 29 },
8015                 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 27500, /* 27.0 Mb */
8016 -                       25900, 1, 1, 8, 13, 29, 29, 29 },
8017 +                       25900, 1, 1, 8, 13, 30, 30, 30 },
8018                 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 40500, /* 40.5 Mb */
8019 -                       38600, 2, 2, 8, 14, 30, 30, 30 },
8020 +                       38600, 2, 2, 8, 14, 31, 31, 31 },
8021                 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 54000, /* 54 Mb */
8022 -                       49800, 3, 3, 8,  15, 31, 31, 31 },
8023 +                       49800, 3, 3, 8,  15, 32, 32, 32 },
8024                 { VALID_40, VALID_40, WLAN_RC_PHY_HT_40_SS, 81500, /* 81 Mb */
8025 -                       72200, 4, 4, 8, 16, 32, 32, 32 },
8026 +                       72200, 4, 4, 8, 16, 33, 33, 33 },
8027                 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 108000, /* 108 Mb */
8028 -                       92900, 5, 5, 8, 17, 33, 33, 33 },
8029 +                       92900, 5, 5, 8, 17, 34, 34, 34 },
8030                 { INVALID,  VALID_40, WLAN_RC_PHY_HT_40_SS, 121500, /* 121.5 Mb */
8031 -                       102700, 6, 6, 8, 18, 34, 34, 34 },
8032 +                       102700, 6, 6, 8, 18, 35, 35, 35 },
8033                 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS, 135000, /* 135 Mb */
8034 -                       112000, 7, 7, 8, 19, 35, 36, 36 },
8035 +                       112000, 7, 7, 8, 19, 36, 37, 37 },
8036                 { INVALID, VALID_40, WLAN_RC_PHY_HT_40_SS_HGI, 150000, /* 150 Mb */
8037 -                       122000, 7, 7, 8, 19, 35, 36, 36 },
8038 +                       122000, 7, 7, 8, 19, 36, 37, 37 },
8039                 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 27000, /* 27 Mb */
8040 -                       25800, 8, 8, 8, 20, 37, 37, 37 },
8041 +                       25800, 8, 8, 8, 20, 38, 38, 38 },
8042                 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 54000, /* 54 Mb */
8043 -                       49800, 9, 9, 8, 21, 38, 38, 38 },
8044 +                       49800, 9, 9, 8, 21, 39, 39, 39 },
8045                 { INVALID, INVALID, WLAN_RC_PHY_HT_40_DS, 81000, /* 81 Mb */
8046 -                       71900, 10, 10, 8, 22, 39, 39, 39 },
8047 +                       71900, 10, 10, 8, 22, 40, 40, 40 },
8048                 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 108000, /* 108 Mb */
8049 -                       92500, 11, 11, 8, 23, 40, 40, 40 },
8050 +                       92500, 11, 11, 8, 23, 41, 41, 41 },
8051                 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 162000, /* 162 Mb */
8052 -                       130300, 12, 12, 8, 24, 41, 41, 41 },
8053 +                       130300, 12, 12, 8, 24, 42, 42, 42 },
8054                 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 216000, /* 216 Mb */
8055 -                       162800, 13, 13, 8, 25, 42, 42, 42 },
8056 +                       162800, 13, 13, 8, 25, 43, 43, 43 },
8057                 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 243000, /* 243 Mb */
8058 -                       178200, 14, 14, 8, 26, 43, 43, 43 },
8059 +                       178200, 14, 14, 8, 26, 44, 44, 44 },
8060                 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS, 270000, /* 270 Mb */
8061 -                       192100, 15, 15, 8, 27, 44, 45, 45 },
8062 +                       192100, 15, 15, 8, 27, 45, 46, 46 },
8063                 { VALID_40, INVALID, WLAN_RC_PHY_HT_40_DS_HGI, 300000, /* 300 Mb */
8064 -                       207000, 15, 15, 8, 27, 44, 45, 45 },
8065 +                       207000, 15, 15, 8, 27, 45, 46, 46 },
8066         },
8067         50,  /* probe interval */
8068         WLAN_RC_HT_FLAG,  /* Phy rates allowed initially */
8069 @@ -510,7 +514,7 @@ static u8 ath_rc_setvalid_htrates(struct
8070  static u8 ath_rc_get_highest_rix(struct ath_softc *sc,
8071                                  struct ath_rate_priv *ath_rc_priv,
8072                                  const struct ath_rate_table *rate_table,
8073 -                                int *is_probing)
8074 +                                int *is_probing, u16 ac)
8075  {
8076         u32 best_thruput, this_thruput, now_msec;
8077         u8 rate, next_rate, best_rate, maxindex, minindex;
8078 @@ -598,6 +602,8 @@ static u8 ath_rc_get_highest_rix(struct 
8079  
8080         rate = ath_rc_priv->valid_rate_index[0];
8081  
8082 +      ath9k_pktlog_rc(sc, ath_rc_priv,  rate_table->info[rate].ratecode,
8083 +                     rate, *is_probing, ac);
8084         return rate;
8085  }
8086  
8087 @@ -689,7 +695,7 @@ static void ath_get_rate(void *priv, str
8088         try_per_rate = 4;
8089  
8090         rate_table = sc->cur_rate_table;
8091 -       rix = ath_rc_get_highest_rix(sc, ath_rc_priv, rate_table, &is_probe);
8092 +       rix = ath_rc_get_highest_rix(sc, ath_rc_priv, rate_table, &is_probe, skb_get_queue_mapping(skb));
8093  
8094         /*
8095          * If we're in HT mode and both us and our peer supports LDPC.
8096 @@ -929,7 +935,8 @@ static bool ath_rc_update_per(struct ath
8097  static void ath_rc_update_ht(struct ath_softc *sc,
8098                              struct ath_rate_priv *ath_rc_priv,
8099                              struct ieee80211_tx_info *tx_info,
8100 -                            int tx_rate, int xretries, int retries)
8101 +                            int tx_rate, int xretries, int retries,
8102 +                            u16 ac)
8103  {
8104         u32 now_msec = jiffies_to_msecs(jiffies);
8105         int rate;
8106 @@ -998,6 +1005,9 @@ static void ath_rc_update_ht(struct ath_
8107         ath_debug_stat_retries(sc, tx_rate, xretries, retries,
8108                                ath_rc_priv->per[tx_rate]);
8109  
8110 +       ath9k_pktlog_rcupdate(sc, ath_rc_priv, tx_rate,
8111 +                       rate_table->info[tx_rate].ratecode,
8112 +                       xretries, retries, tx_info->status.ack_signal, ac);
8113  }
8114  
8115  static int ath_rc_get_rateindex(const struct ath_rate_table *rate_table,
8116 @@ -1025,7 +1035,8 @@ static int ath_rc_get_rateindex(const st
8117  static void ath_rc_tx_status(struct ath_softc *sc,
8118                              struct ath_rate_priv *ath_rc_priv,
8119                              struct ieee80211_tx_info *tx_info,
8120 -                            int final_ts_idx, int xretries, int long_retry)
8121 +                            int final_ts_idx, int xretries, int long_retry,
8122 +                            u16 ac)
8123  {
8124         const struct ath_rate_table *rate_table;
8125         struct ieee80211_tx_rate *rates = tx_info->status.rates;
8126 @@ -1054,7 +1065,7 @@ static void ath_rc_tx_status(struct ath_
8127                                 rix = ath_rc_get_rateindex(rate_table, &rates[i]);
8128                                 ath_rc_update_ht(sc, ath_rc_priv, tx_info,
8129                                                 rix, xretries ? 1 : 2,
8130 -                                               rates[i].count);
8131 +                                               rates[i].count, ac);
8132                         }
8133                 }
8134         } else {
8135 @@ -1076,7 +1087,7 @@ static void ath_rc_tx_status(struct ath_
8136                 return;
8137  
8138         rix = ath_rc_get_rateindex(rate_table, &rates[i]);
8139 -       ath_rc_update_ht(sc, ath_rc_priv, tx_info, rix, xretries, long_retry);
8140 +       ath_rc_update_ht(sc, ath_rc_priv, tx_info, rix, xretries, long_retry, ac);
8141  }
8142  
8143  static const
8144 @@ -1193,7 +1204,7 @@ static void ath_rc_init(struct ath_softc
8145  }
8146  
8147  static u8 ath_rc_build_ht_caps(struct ath_softc *sc, struct ieee80211_sta *sta,
8148 -                              bool is_cw40, bool is_sgi40)
8149 +                              bool is_cw40, bool is_sgi)
8150  {
8151         u8 caps = 0;
8152  
8153 @@ -1206,8 +1217,9 @@ static u8 ath_rc_build_ht_caps(struct at
8154                 }
8155                 if (is_cw40)
8156                         caps |= WLAN_RC_40_FLAG;
8157 -               if (is_sgi40)
8158 +               if (is_sgi)
8159                         caps |= WLAN_RC_SGI_FLAG;
8160 +
8161         }
8162  
8163         return caps;
8164 @@ -1272,7 +1284,8 @@ static void ath_tx_status(void *priv, st
8165                 tx_status = 1;
8166  
8167         ath_rc_tx_status(sc, ath_rc_priv, tx_info, final_ts_idx, tx_status,
8168 -                        (is_underrun) ? sc->hw->max_rate_tries : long_retry);
8169 +                        (is_underrun) ? sc->hw->max_rate_tries : long_retry,
8170 +                        skb_get_queue_mapping(skb));
8171  
8172         /* Check if aggregation has to be enabled for this tid */
8173         if (conf_is_ht(&sc->hw->conf) &&
8174 @@ -1300,7 +1313,7 @@ static void ath_rate_init(void *priv, st
8175         struct ath_softc *sc = priv;
8176         struct ath_rate_priv *ath_rc_priv = priv_sta;
8177         const struct ath_rate_table *rate_table;
8178 -       bool is_cw40, is_sgi40;
8179 +       bool is_cw40, is_sgi = false;
8180         int i, j = 0;
8181  
8182         for (i = 0; i < sband->n_bitrates; i++) {
8183 @@ -1323,7 +1336,11 @@ static void ath_rate_init(void *priv, st
8184         }
8185  
8186         is_cw40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40;
8187 -       is_sgi40 = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40;
8188 +
8189 +       if (is_cw40)
8190 +               is_sgi = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40;
8191 +       else if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_SGI_20)
8192 +               is_sgi = sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20;
8193  
8194         /* Choose rate table first */
8195  
8196 @@ -1336,7 +1353,7 @@ static void ath_rate_init(void *priv, st
8197                 rate_table = hw_rate_table[sc->cur_rate_mode];
8198         }
8199  
8200 -       ath_rc_priv->ht_cap = ath_rc_build_ht_caps(sc, sta, is_cw40, is_sgi40);
8201 +       ath_rc_priv->ht_cap = ath_rc_build_ht_caps(sc, sta, is_cw40, is_sgi);
8202         ath_rc_init(sc, priv_sta, sband, sta, rate_table);
8203  }
8204  
8205 @@ -1347,10 +1364,10 @@ static void ath_rate_update(void *priv, 
8206         struct ath_softc *sc = priv;
8207         struct ath_rate_priv *ath_rc_priv = priv_sta;
8208         const struct ath_rate_table *rate_table = NULL;
8209 -       bool oper_cw40 = false, oper_sgi40;
8210 +       bool oper_cw40 = false, oper_sgi;
8211         bool local_cw40 = (ath_rc_priv->ht_cap & WLAN_RC_40_FLAG) ?
8212                 true : false;
8213 -       bool local_sgi40 = (ath_rc_priv->ht_cap & WLAN_RC_SGI_FLAG) ?
8214 +       bool local_sgi = (ath_rc_priv->ht_cap & WLAN_RC_SGI_FLAG) ?
8215                 true : false;
8216  
8217         /* FIXME: Handle AP mode later when we support CWM */
8218 @@ -1363,15 +1380,21 @@ static void ath_rate_update(void *priv, 
8219                     oper_chan_type == NL80211_CHAN_HT40PLUS)
8220                         oper_cw40 = true;
8221  
8222 -               oper_sgi40 = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ?
8223 -                       true : false;
8224 +               if (oper_cw40)
8225 +                       oper_sgi = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ?
8226 +                                  true : false;
8227 +               else if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_SGI_20)
8228 +                       oper_sgi = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ?
8229 +                                  true : false;
8230 +               else
8231 +                       oper_sgi = false;
8232  
8233 -               if ((local_cw40 != oper_cw40) || (local_sgi40 != oper_sgi40)) {
8234 +               if ((local_cw40 != oper_cw40) || (local_sgi != oper_sgi)) {
8235                         rate_table = ath_choose_rate_table(sc, sband->band,
8236                                                    sta->ht_cap.ht_supported,
8237                                                    oper_cw40);
8238                         ath_rc_priv->ht_cap = ath_rc_build_ht_caps(sc, sta,
8239 -                                                  oper_cw40, oper_sgi40);
8240 +                                                  oper_cw40, oper_sgi);
8241                         ath_rc_init(sc, priv_sta, sband, sta, rate_table);
8242  
8243                         ath_print(ath9k_hw_common(sc->sc_ah), ATH_DBG_CONFIG,
8244 --- a/drivers/net/wireless/ath/ath9k/recv.c
8245 +++ b/drivers/net/wireless/ath/ath9k/recv.c
8246 @@ -700,12 +700,16 @@ static bool ath_edma_get_buffers(struct 
8247         bf = SKB_CB_ATHBUF(skb);
8248         BUG_ON(!bf);
8249  
8250 -       dma_sync_single_for_device(sc->dev, bf->bf_buf_addr,
8251 +       dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr,
8252                                 common->rx_bufsize, DMA_FROM_DEVICE);
8253  
8254         ret = ath9k_hw_process_rxdesc_edma(ah, NULL, skb->data);
8255 -       if (ret == -EINPROGRESS)
8256 +       if (ret == -EINPROGRESS) {
8257 +               /*let device gain the buffer again*/
8258 +               dma_sync_single_for_device(sc->dev, bf->bf_buf_addr,
8259 +                               common->rx_bufsize, DMA_FROM_DEVICE);
8260                 return false;
8261 +       }
8262  
8263         __skb_unlink(skb, &rx_edma->rx_fifo);
8264         if (ret == -EINVAL) {
8265 @@ -814,13 +818,266 @@ static struct ath_buf *ath_get_next_rx_b
8266          * 1. accessing the frame
8267          * 2. requeueing the same buffer to h/w
8268          */
8269 -       dma_sync_single_for_device(sc->dev, bf->bf_buf_addr,
8270 +       dma_sync_single_for_cpu(sc->dev, bf->bf_buf_addr,
8271                         common->rx_bufsize,
8272                         DMA_FROM_DEVICE);
8273  
8274         return bf;
8275  }
8276  
8277 +/* Assumes you've already done the endian to CPU conversion */
8278 +static bool ath9k_rx_accept(struct ath_common *common,
8279 +                           struct ieee80211_hdr *hdr,
8280 +                           struct ieee80211_rx_status *rxs,
8281 +                           struct ath_rx_status *rx_stats,
8282 +                           bool *decrypt_error)
8283 +{
8284 +       struct ath_hw *ah = common->ah;
8285 +       __le16 fc;
8286 +       u8 rx_status_len = ah->caps.rx_status_len;
8287 +
8288 +       fc = hdr->frame_control;
8289 +
8290 +       if (!rx_stats->rs_datalen)
8291 +               return false;
8292 +        /*
8293 +         * rs_status follows rs_datalen so if rs_datalen is too large
8294 +         * we can take a hint that hardware corrupted it, so ignore
8295 +         * those frames.
8296 +         */
8297 +       if (rx_stats->rs_datalen > (common->rx_bufsize - rx_status_len))
8298 +               return false;
8299 +
8300 +       /*
8301 +        * rs_more indicates chained descriptors which can be used
8302 +        * to link buffers together for a sort of scatter-gather
8303 +        * operation.
8304 +        * reject the frame, we don't support scatter-gather yet and
8305 +        * the frame is probably corrupt anyway
8306 +        */
8307 +       if (rx_stats->rs_more)
8308 +               return false;
8309 +
8310 +       /*
8311 +        * The rx_stats->rs_status will not be set until the end of the
8312 +        * chained descriptors so it can be ignored if rs_more is set. The
8313 +        * rs_more will be false at the last element of the chained
8314 +        * descriptors.
8315 +        */
8316 +       if (rx_stats->rs_status != 0) {
8317 +               if (rx_stats->rs_status & ATH9K_RXERR_CRC)
8318 +                       rxs->flag |= RX_FLAG_FAILED_FCS_CRC;
8319 +               if (rx_stats->rs_status & ATH9K_RXERR_PHY)
8320 +                       return false;
8321 +
8322 +               if (rx_stats->rs_status & ATH9K_RXERR_DECRYPT) {
8323 +                       *decrypt_error = true;
8324 +               } else if (rx_stats->rs_status & ATH9K_RXERR_MIC) {
8325 +                       if (ieee80211_is_ctl(fc))
8326 +                               /*
8327 +                                * Sometimes, we get invalid
8328 +                                * MIC failures on valid control frames.
8329 +                                * Remove these mic errors.
8330 +                                */
8331 +                               rx_stats->rs_status &= ~ATH9K_RXERR_MIC;
8332 +                       else
8333 +                               rxs->flag |= RX_FLAG_MMIC_ERROR;
8334 +               }
8335 +               /*
8336 +                * Reject error frames with the exception of
8337 +                * decryption and MIC failures. For monitor mode,
8338 +                * we also ignore the CRC error.
8339 +                */
8340 +               if (ah->opmode == NL80211_IFTYPE_MONITOR) {
8341 +                       if (rx_stats->rs_status &
8342 +                           ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC |
8343 +                             ATH9K_RXERR_CRC))
8344 +                               return false;
8345 +               } else {
8346 +                       if (rx_stats->rs_status &
8347 +                           ~(ATH9K_RXERR_DECRYPT | ATH9K_RXERR_MIC)) {
8348 +                               return false;
8349 +                       }
8350 +               }
8351 +       }
8352 +       return true;
8353 +}
8354 +
8355 +static int ath9k_process_rate(struct ath_common *common,
8356 +                             struct ieee80211_hw *hw,
8357 +                             struct ath_rx_status *rx_stats,
8358 +                             struct ieee80211_rx_status *rxs)
8359 +{
8360 +       struct ieee80211_supported_band *sband;
8361 +       enum ieee80211_band band;
8362 +       unsigned int i = 0;
8363 +
8364 +       band = hw->conf.channel->band;
8365 +       sband = hw->wiphy->bands[band];
8366 +
8367 +       if (rx_stats->rs_rate & 0x80) {
8368 +               /* HT rate */
8369 +               rxs->flag |= RX_FLAG_HT;
8370 +               if (rx_stats->rs_flags & ATH9K_RX_2040)
8371 +                       rxs->flag |= RX_FLAG_40MHZ;
8372 +               if (rx_stats->rs_flags & ATH9K_RX_GI)
8373 +                       rxs->flag |= RX_FLAG_SHORT_GI;
8374 +               rxs->rate_idx = rx_stats->rs_rate & 0x7f;
8375 +               return 0;
8376 +       }
8377 +
8378 +       for (i = 0; i < sband->n_bitrates; i++) {
8379 +               if (sband->bitrates[i].hw_value == rx_stats->rs_rate) {
8380 +                       rxs->rate_idx = i;
8381 +                       return 0;
8382 +               }
8383 +               if (sband->bitrates[i].hw_value_short == rx_stats->rs_rate) {
8384 +                       rxs->flag |= RX_FLAG_SHORTPRE;
8385 +                       rxs->rate_idx = i;
8386 +                       return 0;
8387 +               }
8388 +       }
8389 +
8390 +       /*
8391 +        * No valid hardware bitrate found -- we should not get here
8392 +        * because hardware has already validated this frame as OK.
8393 +        */
8394 +       ath_print(common, ATH_DBG_XMIT, "unsupported hw bitrate detected "
8395 +                 "0x%02x using 1 Mbit\n", rx_stats->rs_rate);
8396 +
8397 +       return -EINVAL;
8398 +}
8399 +
8400 +static void ath9k_process_rssi(struct ath_common *common,
8401 +                              struct ieee80211_hw *hw,
8402 +                              struct ieee80211_hdr *hdr,
8403 +                              struct ath_rx_status *rx_stats)
8404 +{
8405 +       struct ath_hw *ah = common->ah;
8406 +       struct ieee80211_sta *sta;
8407 +       struct ath_node *an;
8408 +       int last_rssi = ATH_RSSI_DUMMY_MARKER;
8409 +       __le16 fc;
8410 +
8411 +       fc = hdr->frame_control;
8412 +
8413 +       rcu_read_lock();
8414 +       /*
8415 +        * XXX: use ieee80211_find_sta! This requires quite a bit of work
8416 +        * under the current ath9k virtual wiphy implementation as we have
8417 +        * no way of tying a vif to wiphy. Typically vifs are attached to
8418 +        * at least one sdata of a wiphy on mac80211 but with ath9k virtual
8419 +        * wiphy you'd have to iterate over every wiphy and each sdata.
8420 +        */
8421 +       sta = ieee80211_find_sta_by_hw(hw, hdr->addr2);
8422 +       if (sta) {
8423 +               an = (struct ath_node *) sta->drv_priv;
8424 +               if (rx_stats->rs_rssi != ATH9K_RSSI_BAD &&
8425 +                  !rx_stats->rs_moreaggr)
8426 +                       ATH_RSSI_LPF(an->last_rssi, rx_stats->rs_rssi);
8427 +               last_rssi = an->last_rssi;
8428 +       }
8429 +       rcu_read_unlock();
8430 +
8431 +       if (likely(last_rssi != ATH_RSSI_DUMMY_MARKER))
8432 +               rx_stats->rs_rssi = ATH_EP_RND(last_rssi,
8433 +                                             ATH_RSSI_EP_MULTIPLIER);
8434 +       if (rx_stats->rs_rssi < 0)
8435 +               rx_stats->rs_rssi = 0;
8436 +
8437 +       /* Update Beacon RSSI, this is used by ANI. */
8438 +       if (ieee80211_is_beacon(fc))
8439 +               ah->stats.avgbrssi = rx_stats->rs_rssi;
8440 +}
8441 +
8442 +/*
8443 + * For Decrypt or Demic errors, we only mark packet status here and always push
8444 + * up the frame up to let mac80211 handle the actual error case, be it no
8445 + * decryption key or real decryption error. This let us keep statistics there.
8446 + */
8447 +static int ath9k_rx_skb_preprocess(struct ath_common *common,
8448 +                                  struct ieee80211_hw *hw,
8449 +                                  struct ieee80211_hdr *hdr,
8450 +                                  struct ath_rx_status *rx_stats,
8451 +                                  struct ieee80211_rx_status *rx_status,
8452 +                                  bool *decrypt_error)
8453 +{
8454 +       struct ath_hw *ah = common->ah;
8455 +
8456 +       memset(rx_status, 0, sizeof(struct ieee80211_rx_status));
8457 +
8458 +       /*
8459 +        * everything but the rate is checked here, the rate check is done
8460 +        * separately to avoid doing two lookups for a rate for each frame.
8461 +        */
8462 +       if (!ath9k_rx_accept(common, hdr, rx_status, rx_stats, decrypt_error))
8463 +               return -EINVAL;
8464 +
8465 +       ath9k_process_rssi(common, hw, hdr, rx_stats);
8466 +
8467 +       if (ath9k_process_rate(common, hw, rx_stats, rx_status))
8468 +               return -EINVAL;
8469 +
8470 +       rx_status->mactime = ath9k_hw_extend_tsf(ah, rx_stats->rs_tstamp);
8471 +       rx_status->band = hw->conf.channel->band;
8472 +       rx_status->freq = hw->conf.channel->center_freq;
8473 +       rx_status->signal = ATH_DEFAULT_NOISE_FLOOR + rx_stats->rs_rssi;
8474 +       rx_status->antenna = rx_stats->rs_antenna;
8475 +       rx_status->flag |= RX_FLAG_TSFT;
8476 +
8477 +       return 0;
8478 +}
8479 +
8480 +static void ath9k_rx_skb_postprocess(struct ath_common *common,
8481 +                                    struct sk_buff *skb,
8482 +                                    struct ath_rx_status *rx_stats,
8483 +                                    struct ieee80211_rx_status *rxs,
8484 +                                    bool decrypt_error)
8485 +{
8486 +       struct ath_hw *ah = common->ah;
8487 +       struct ieee80211_hdr *hdr;
8488 +       int hdrlen, padpos, padsize;
8489 +       u8 keyix;
8490 +       __le16 fc;
8491 +
8492 +       /* see if any padding is done by the hw and remove it */
8493 +       hdr = (struct ieee80211_hdr *) skb->data;
8494 +       hdrlen = ieee80211_get_hdrlen_from_skb(skb);
8495 +       fc = hdr->frame_control;
8496 +       padpos = ath9k_cmn_padpos(hdr->frame_control);
8497 +
8498 +       /* The MAC header is padded to have 32-bit boundary if the
8499 +        * packet payload is non-zero. The general calculation for
8500 +        * padsize would take into account odd header lengths:
8501 +        * padsize = (4 - padpos % 4) % 4; However, since only
8502 +        * even-length headers are used, padding can only be 0 or 2
8503 +        * bytes and we can optimize this a bit. In addition, we must
8504 +        * not try to remove padding from short control frames that do
8505 +        * not have payload. */
8506 +       padsize = padpos & 3;
8507 +       if (padsize && skb->len>=padpos+padsize+FCS_LEN) {
8508 +               memmove(skb->data + padsize, skb->data, padpos);
8509 +               skb_pull(skb, padsize);
8510 +       }
8511 +
8512 +       keyix = rx_stats->rs_keyix;
8513 +
8514 +       if (!(keyix == ATH9K_RXKEYIX_INVALID) && !decrypt_error &&
8515 +           ieee80211_has_protected(fc)) {
8516 +               rxs->flag |= RX_FLAG_DECRYPTED;
8517 +       } else if (ieee80211_has_protected(fc)
8518 +                  && !decrypt_error && skb->len >= hdrlen + 4) {
8519 +               keyix = skb->data[hdrlen + 3] >> 6;
8520 +
8521 +               if (test_bit(keyix, common->keymap))
8522 +                       rxs->flag |= RX_FLAG_DECRYPTED;
8523 +       }
8524 +       if (ah->sw_mgmt_crypto &&
8525 +           (rxs->flag & RX_FLAG_DECRYPTED) &&
8526 +           ieee80211_is_mgmt(fc))
8527 +               /* Use software decrypt for management frames. */
8528 +               rxs->flag &= ~RX_FLAG_DECRYPTED;
8529 +}
8530  
8531  int ath_rx_tasklet(struct ath_softc *sc, int flush, bool hp)
8532  {
8533 @@ -829,6 +1086,7 @@ int ath_rx_tasklet(struct ath_softc *sc,
8534         struct ieee80211_rx_status *rxs;
8535         struct ath_hw *ah = sc->sc_ah;
8536         struct ath_common *common = ath9k_hw_common(ah);
8537 +       u32 *rx_desc = NULL;
8538         /*
8539          * The hw can techncically differ from common->hw when using ath9k
8540          * virtual wiphy so to account for that we iterate over the active
8541 @@ -842,6 +1100,7 @@ int ath_rx_tasklet(struct ath_softc *sc,
8542         enum ath9k_rx_qtype qtype;
8543         bool edma = !!(ah->caps.hw_caps & ATH9K_HW_CAP_EDMA);
8544         int dma_type;
8545 +       u8 rx_status_len = ah->caps.rx_status_len;
8546  
8547         if (edma)
8548                 dma_type = DMA_FROM_DEVICE;
8549 @@ -869,7 +1128,7 @@ int ath_rx_tasklet(struct ath_softc *sc,
8550                 if (!skb)
8551                         continue;
8552  
8553 -               hdr = (struct ieee80211_hdr *) skb->data;
8554 +               hdr = (struct ieee80211_hdr *) (skb->data + rx_status_len);
8555                 rxs =  IEEE80211_SKB_RXCB(skb);
8556  
8557                 hw = ath_get_virt_hw(sc, hdr);
8558 @@ -883,8 +1142,8 @@ int ath_rx_tasklet(struct ath_softc *sc,
8559                 if (flush)
8560                         goto requeue;
8561  
8562 -               retval = ath9k_cmn_rx_skb_preprocess(common, hw, skb, &rs,
8563 -                                                    rxs, &decrypt_error);
8564 +               retval = ath9k_rx_skb_preprocess(common, hw, hdr, &rs,
8565 +                                                rxs, &decrypt_error);
8566                 if (retval)
8567                         goto requeue;
8568  
8569 @@ -905,11 +1164,23 @@ int ath_rx_tasklet(struct ath_softc *sc,
8570                                  dma_type);
8571  
8572                 skb_put(skb, rs.rs_datalen + ah->caps.rx_status_len);
8573 -               if (ah->caps.rx_status_len)
8574 +               if (ah->caps.rx_status_len) {
8575 +                       rx_desc = kzalloc(ah->caps.rx_status_len, GFP_ATOMIC);
8576 +                       if (rx_desc == NULL)
8577 +                               BUG_ON(1);
8578 +                       memcpy(rx_desc, skb->data, ah->caps.rx_status_len);
8579                         skb_pull(skb, ah->caps.rx_status_len);
8580 +               }
8581 +
8582 +               ath9k_rx_skb_postprocess(common, skb, &rs,
8583 +                                        rxs, decrypt_error);
8584  
8585 -               ath9k_cmn_rx_skb_postprocess(common, skb, &rs,
8586 -                                            rxs, decrypt_error);
8587 +               if (rx_desc) {
8588 +                       ath_pktlog_rx(sc, (void *) rx_desc, skb);
8589 +                       kfree(rx_desc);
8590 +               } else {
8591 +                       ath_pktlog_rx(sc, bf->bf_desc, skb);
8592 +               }
8593  
8594                 /* We will now give hardware our shiny new allocated skb */
8595                 bf->bf_mpdu = requeue_skb;
8596 --- a/drivers/net/wireless/ath/ath9k/reg.h
8597 +++ b/drivers/net/wireless/ath/ath9k/reg.h
8598 @@ -222,6 +222,7 @@
8599  
8600  #define AR_ISR_S2              0x008c
8601  #define AR_ISR_S2_QCU_TXURN    0x000003FF
8602 +#define AR_ISR_S2_BB_WATCHDOG  0x00010000
8603  #define AR_ISR_S2_CST          0x00400000
8604  #define AR_ISR_S2_GTT          0x00800000
8605  #define AR_ISR_S2_TIM          0x01000000
8606 --- a/drivers/net/wireless/ath/ath9k/xmit.c
8607 +++ b/drivers/net/wireless/ath/ath9k/xmit.c
8608 @@ -418,6 +418,8 @@ static void ath_tx_complete_aggr(struct 
8609                         list_move_tail(&bf->list, &bf_head);
8610                 }
8611  
8612 +               ath9k_pktlog_txcomplete(sc, &bf_head, bf, bf_last);
8613 +
8614                 if (!txpending) {
8615                         /*
8616                          * complete the acked-ones/xretried ones; update
8617 @@ -1728,6 +1730,8 @@ static int ath_tx_setup_buffer(struct ie
8618         } else
8619                 bf->bf_isnullfunc = false;
8620  
8621 +       bf->bf_tx_aborted = false;
8622 +
8623         return 0;
8624  }
8625  
8626 @@ -1989,7 +1993,7 @@ static int ath_tx_num_badfrms(struct ath
8627         int nbad = 0;
8628         int isaggr = 0;
8629  
8630 -       if (bf->bf_tx_aborted)
8631 +       if (bf->bf_lastbf->bf_tx_aborted)
8632                 return 0;
8633  
8634         isaggr = bf_isaggr(bf);
8635 @@ -2115,7 +2119,7 @@ static void ath_tx_processq(struct ath_s
8636                 ds = lastbf->bf_desc;
8637  
8638                 memset(&ts, 0, sizeof(ts));
8639 -               status = ath9k_hw_txprocdesc(ah, ds, &ts);
8640 +               status = ath9k_hw_txprocdesc(ah, ds, &ts, NULL);
8641                 if (status == -EINPROGRESS) {
8642                         spin_unlock_bh(&txq->axq_lock);
8643                         break;
8644 @@ -2165,10 +2169,14 @@ static void ath_tx_processq(struct ath_s
8645                         ath_tx_rc_status(bf, &ts, 0, txok, true);
8646                 }
8647  
8648 -               if (bf_isampdu(bf))
8649 +               if (bf_isampdu(bf)) {
8650                         ath_tx_complete_aggr(sc, txq, bf, &bf_head, &ts, txok);
8651 -               else
8652 +               } else {
8653 +                       ath9k_pktlog_txctrl(sc, &bf_head, lastbf);
8654                         ath_tx_complete_buf(sc, bf, txq, &bf_head, &ts, txok, 0);
8655 +               }
8656 +
8657 +               ath_pktlog_txstatus(sc, lastbf->bf_desc);
8658  
8659                 ath_wake_mac80211_queue(sc, txq);
8660  
8661 @@ -2240,9 +2248,11 @@ void ath_tx_edma_tasklet(struct ath_soft
8662         struct list_head bf_head;
8663         int status;
8664         int txok;
8665 +       u32 txs_desc[9];
8666  
8667         for (;;) {
8668 -               status = ath9k_hw_txprocdesc(ah, NULL, (void *)&txs);
8669 +               status = ath9k_hw_txprocdesc(ah, NULL, (void *)&txs,
8670 +                                            (void *) txs_desc);
8671                 if (status == -EINPROGRESS)
8672                         break;
8673                 if (status == -EIO) {
8674 @@ -2277,6 +2287,17 @@ void ath_tx_edma_tasklet(struct ath_soft
8675  
8676                 txok = !(txs.ts_status & ATH9K_TXERR_MASK);
8677  
8678 +               /*
8679 +                * Make sure null func frame is acked before configuring
8680 +                * hw into ps mode.
8681 +                */
8682 +               if (bf->bf_isnullfunc && txok) {
8683 +                       if ((sc->ps_flags & PS_ENABLED))
8684 +                               ath9k_enable_ps(sc);
8685 +                       else
8686 +                               sc->ps_flags |= PS_NULLFUNC_COMPLETED;
8687 +               }
8688 +
8689                 if (!bf_isampdu(bf)) {
8690                         bf->bf_retries = txs.ts_longretry;
8691                         if (txs.ts_status & ATH9K_TXERR_XRETRY)
8692 @@ -2284,14 +2305,18 @@ void ath_tx_edma_tasklet(struct ath_soft
8693                         ath_tx_rc_status(bf, &txs, 0, txok, true);
8694                 }
8695  
8696 -               if (bf_isampdu(bf))
8697 +               if (bf_isampdu(bf)) {
8698                         ath_tx_complete_aggr(sc, txq, bf, &bf_head, &txs, txok);
8699 -               else
8700 +               } else {
8701 +                       ath9k_pktlog_txctrl(sc, &bf_head, lastbf);
8702                         ath_tx_complete_buf(sc, bf, txq, &bf_head,
8703                                             &txs, txok, 0);
8704 +               }
8705  
8706                 ath_wake_mac80211_queue(sc, txq);
8707  
8708 +               ath_pktlog_txstatus(sc, txs_desc);
8709 +
8710                 spin_lock_bh(&txq->axq_lock);
8711                 if (!list_empty(&txq->txq_fifo_pending)) {
8712                         INIT_LIST_HEAD(&bf_head);
8713 --- a/net/mac80211/Kconfig
8714 +++ b/net/mac80211/Kconfig
8715 @@ -33,6 +33,13 @@ config MAC80211_RC_MINSTREL
8716         ---help---
8717           This option enables the 'minstrel' TX rate control algorithm
8718  
8719 +config MAC80211_RC_MINSTREL_HT
8720 +       bool "Minstrel 802.11n support" if EMBEDDED
8721 +       depends on MAC80211_RC_MINSTREL
8722 +       default y
8723 +       ---help---
8724 +         This option enables the 'minstrel_ht' TX rate control algorithm
8725 +
8726  choice
8727         prompt "Default rate control algorithm"
8728         depends on MAC80211_HAS_RC
8729 --- a/net/mac80211/Makefile
8730 +++ b/net/mac80211/Makefile
8731 @@ -51,7 +51,11 @@ rc80211_pid-$(CONFIG_MAC80211_DEBUGFS) +
8732  rc80211_minstrel-y := rc80211_minstrel.o
8733  rc80211_minstrel-$(CONFIG_MAC80211_DEBUGFS) += rc80211_minstrel_debugfs.o
8734  
8735 +rc80211_minstrel_ht-y := rc80211_minstrel_ht.o
8736 +rc80211_minstrel_ht-$(CONFIG_MAC80211_DEBUGFS) += rc80211_minstrel_ht_debugfs.o
8737 +
8738  mac80211-$(CONFIG_MAC80211_RC_PID) += $(rc80211_pid-y)
8739  mac80211-$(CONFIG_MAC80211_RC_MINSTREL) += $(rc80211_minstrel-y)
8740 +mac80211-$(CONFIG_MAC80211_RC_MINSTREL_HT) += $(rc80211_minstrel_ht-y)
8741  
8742  ccflags-y += -D__CHECK_ENDIAN__
8743 --- a/net/mac80211/main.c
8744 +++ b/net/mac80211/main.c
8745 @@ -710,6 +710,10 @@ static int __init ieee80211_init(void)
8746         if (ret)
8747                 return ret;
8748  
8749 +       ret = rc80211_minstrel_ht_init();
8750 +       if (ret)
8751 +               goto err_minstrel;
8752 +
8753         ret = rc80211_pid_init();
8754         if (ret)
8755                 goto err_pid;
8756 @@ -722,6 +726,8 @@ static int __init ieee80211_init(void)
8757   err_netdev:
8758         rc80211_pid_exit();
8759   err_pid:
8760 +       rc80211_minstrel_ht_exit();
8761 + err_minstrel:
8762         rc80211_minstrel_exit();
8763  
8764         return ret;
8765 @@ -730,6 +736,7 @@ static int __init ieee80211_init(void)
8766  static void __exit ieee80211_exit(void)
8767  {
8768         rc80211_pid_exit();
8769 +       rc80211_minstrel_ht_exit();
8770         rc80211_minstrel_exit();
8771  
8772         /*
8773 --- a/net/mac80211/rate.h
8774 +++ b/net/mac80211/rate.h
8775 @@ -147,5 +147,18 @@ static inline void rc80211_minstrel_exit
8776  }
8777  #endif
8778  
8779 +#ifdef CONFIG_MAC80211_RC_MINSTREL_HT
8780 +extern int rc80211_minstrel_ht_init(void);
8781 +extern void rc80211_minstrel_ht_exit(void);
8782 +#else
8783 +static inline int rc80211_minstrel_ht_init(void)
8784 +{
8785 +       return 0;
8786 +}
8787 +static inline void rc80211_minstrel_ht_exit(void)
8788 +{
8789 +}
8790 +#endif
8791 +
8792  
8793  #endif /* IEEE80211_RATE_H */
8794 --- /dev/null
8795 +++ b/net/mac80211/rc80211_minstrel_ht.c
8796 @@ -0,0 +1,824 @@
8797 +/*
8798 + * Copyright (C) 2010 Felix Fietkau <nbd@openwrt.org>
8799 + *
8800 + * This program is free software; you can redistribute it and/or modify
8801 + * it under the terms of the GNU General Public License version 2 as
8802 + * published by the Free Software Foundation.
8803 + */
8804 +#include <linux/netdevice.h>
8805 +#include <linux/types.h>
8806 +#include <linux/skbuff.h>
8807 +#include <linux/debugfs.h>
8808 +#include <linux/random.h>
8809 +#include <linux/ieee80211.h>
8810 +#include <net/mac80211.h>
8811 +#include "rate.h"
8812 +#include "rc80211_minstrel.h"
8813 +#include "rc80211_minstrel_ht.h"
8814 +
8815 +#define AVG_PKT_SIZE   1200
8816 +#define SAMPLE_COLUMNS 10
8817 +#define EWMA_LEVEL             75
8818 +
8819 +/* Number of bits for an average sized packet */
8820 +#define MCS_NBITS (AVG_PKT_SIZE << 3)
8821 +
8822 +/* Number of symbols for a packet with (bps) bits per symbol */
8823 +#define MCS_NSYMS(bps) ((MCS_NBITS + (bps) - 1) / (bps))
8824 +
8825 +/* Transmission time for a packet containing (syms) symbols */
8826 +#define MCS_SYMBOL_TIME(sgi, syms)                                     \
8827 +       (sgi ?                                                          \
8828 +         ((syms) * 18 + 4) / 5 :       /* syms * 3.6 us */             \
8829 +         (syms) << 2                   /* syms * 4 us */               \
8830 +       )
8831 +
8832 +/* Transmit duration for the raw data part of an average sized packet */
8833 +#define MCS_DURATION(streams, sgi, bps) MCS_SYMBOL_TIME(sgi, MCS_NSYMS((streams) * (bps)))
8834 +
8835 +/* MCS rate information for an MCS group */
8836 +#define MCS_GROUP(_streams, _sgi, _ht40) {                             \
8837 +       .streams = _streams,                                            \
8838 +       .flags =                                                        \
8839 +               (_sgi ? IEEE80211_TX_RC_SHORT_GI : 0) |                 \
8840 +               (_ht40 ? IEEE80211_TX_RC_40_MHZ_WIDTH : 0),             \
8841 +       .duration = {                                                   \
8842 +               MCS_DURATION(_streams, _sgi, _ht40 ? 54 : 26),          \
8843 +               MCS_DURATION(_streams, _sgi, _ht40 ? 108 : 52),         \
8844 +               MCS_DURATION(_streams, _sgi, _ht40 ? 162 : 78),         \
8845 +               MCS_DURATION(_streams, _sgi, _ht40 ? 216 : 104),        \
8846 +               MCS_DURATION(_streams, _sgi, _ht40 ? 324 : 156),        \
8847 +               MCS_DURATION(_streams, _sgi, _ht40 ? 432 : 208),        \
8848 +               MCS_DURATION(_streams, _sgi, _ht40 ? 486 : 234),        \
8849 +               MCS_DURATION(_streams, _sgi, _ht40 ? 540 : 260)         \
8850 +       }                                                               \
8851 +}
8852 +
8853 +/*
8854 + * To enable sufficiently targeted rate sampling, MCS rates are divided into
8855 + * groups, based on the number of streams and flags (HT40, SGI) that they
8856 + * use.
8857 + */
8858 +const struct mcs_group minstrel_mcs_groups[] = {
8859 +       MCS_GROUP(1, 0, 0),
8860 +       MCS_GROUP(2, 0, 0),
8861 +#if MINSTREL_MAX_STREAMS >= 3
8862 +       MCS_GROUP(3, 0, 0),
8863 +#endif
8864 +
8865 +       MCS_GROUP(1, 1, 0),
8866 +       MCS_GROUP(2, 1, 0),
8867 +#if MINSTREL_MAX_STREAMS >= 3
8868 +       MCS_GROUP(3, 1, 0),
8869 +#endif
8870 +
8871 +       MCS_GROUP(1, 0, 1),
8872 +       MCS_GROUP(2, 0, 1),
8873 +#if MINSTREL_MAX_STREAMS >= 3
8874 +       MCS_GROUP(3, 0, 1),
8875 +#endif
8876 +
8877 +       MCS_GROUP(1, 1, 1),
8878 +       MCS_GROUP(2, 1, 1),
8879 +#if MINSTREL_MAX_STREAMS >= 3
8880 +       MCS_GROUP(3, 1, 1),
8881 +#endif
8882 +};
8883 +
8884 +static u8 sample_table[SAMPLE_COLUMNS][MCS_GROUP_RATES];
8885 +
8886 +/*
8887 + * Perform EWMA (Exponentially Weighted Moving Average) calculation
8888 + */
8889 +static int
8890 +minstrel_ewma(int old, int new, int weight)
8891 +{
8892 +       return (new * (100 - weight) + old * weight) / 100;
8893 +}
8894 +
8895 +/*
8896 + * Look up an MCS group index based on mac80211 rate information
8897 + */
8898 +static int
8899 +minstrel_ht_get_group_idx(struct ieee80211_tx_rate *rate)
8900 +{
8901 +       int streams = (rate->idx / MCS_GROUP_RATES) + 1;
8902 +       u32 flags = IEEE80211_TX_RC_SHORT_GI | IEEE80211_TX_RC_40_MHZ_WIDTH;
8903 +       int i;
8904 +
8905 +       for (i = 0; i < ARRAY_SIZE(minstrel_mcs_groups); i++) {
8906 +               if (minstrel_mcs_groups[i].streams != streams)
8907 +                       continue;
8908 +               if (minstrel_mcs_groups[i].flags != (rate->flags & flags))
8909 +                       continue;
8910 +
8911 +               return i;
8912 +       }
8913 +
8914 +       WARN_ON(1);
8915 +       return 0;
8916 +}
8917 +
8918 +static inline struct minstrel_rate_stats *
8919 +minstrel_get_ratestats(struct minstrel_ht_sta *mi, int index)
8920 +{
8921 +       return &mi->groups[index / MCS_GROUP_RATES].rates[index % MCS_GROUP_RATES];
8922 +}
8923 +
8924 +
8925 +/*
8926 + * Recalculate success probabilities and counters for a rate using EWMA
8927 + */
8928 +static void
8929 +minstrel_calc_rate_ewma(struct minstrel_priv *mp, struct minstrel_rate_stats *mr)
8930 +{
8931 +       if (unlikely(mr->attempts > 0)) {
8932 +               mr->sample_skipped = 0;
8933 +               mr->cur_prob = MINSTREL_FRAC(mr->success, mr->attempts);
8934 +               if (!mr->att_hist)
8935 +                       mr->probability = mr->cur_prob;
8936 +               else
8937 +                       mr->probability = minstrel_ewma(mr->probability,
8938 +                               mr->cur_prob, EWMA_LEVEL);
8939 +               mr->att_hist += mr->attempts;
8940 +               mr->succ_hist += mr->success;
8941 +       } else {
8942 +               mr->sample_skipped++;
8943 +       }
8944 +       mr->last_success = mr->success;
8945 +       mr->last_attempts = mr->attempts;
8946 +       mr->success = 0;
8947 +       mr->attempts = 0;
8948 +}
8949 +
8950 +/*
8951 + * Calculate throughput based on the average A-MPDU length, taking into account
8952 + * the expected number of retransmissions and their expected length
8953 + */
8954 +static void
8955 +minstrel_ht_calc_tp(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
8956 +                    int group, int rate)
8957 +{
8958 +       struct minstrel_rate_stats *mr;
8959 +       unsigned int usecs;
8960 +
8961 +       mr = &mi->groups[group].rates[rate];
8962 +
8963 +       if (mr->probability < MINSTREL_FRAC(1, 10)) {
8964 +               mr->cur_tp = 0;
8965 +               return;
8966 +       }
8967 +
8968 +       usecs = mi->overhead / MINSTREL_TRUNC(mi->avg_ampdu_len);
8969 +       usecs += minstrel_mcs_groups[group].duration[rate];
8970 +       mr->cur_tp = MINSTREL_TRUNC((1000000 / usecs) * mr->probability);
8971 +}
8972 +
8973 +/*
8974 + * Update rate statistics and select new primary rates
8975 + *
8976 + * Rules for rate selection:
8977 + *  - max_prob_rate must use only one stream, as a tradeoff between delivery
8978 + *    probability and throughput during strong fluctuations
8979 + *  - as long as the max prob rate has a probability of more than 3/4, pick
8980 + *    higher throughput rates, even if the probablity is a bit lower
8981 + */
8982 +static void
8983 +minstrel_ht_update_stats(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
8984 +{
8985 +       struct minstrel_mcs_group_data *mg;
8986 +       struct minstrel_rate_stats *mr;
8987 +       int cur_prob, cur_prob_tp, cur_tp, cur_tp2;
8988 +       int group, i, index;
8989 +
8990 +       if (mi->ampdu_packets > 0) {
8991 +               mi->avg_ampdu_len = minstrel_ewma(mi->avg_ampdu_len,
8992 +                       MINSTREL_FRAC(mi->ampdu_len, mi->ampdu_packets), EWMA_LEVEL);
8993 +               mi->ampdu_len = 0;
8994 +               mi->ampdu_packets = 0;
8995 +       }
8996 +
8997 +       mi->sample_slow = 0;
8998 +       mi->sample_count = 0;
8999 +       mi->max_tp_rate = 0;
9000 +       mi->max_tp_rate2 = 0;
9001 +       mi->max_prob_rate = 0;
9002 +
9003 +       for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
9004 +               cur_prob = 0;
9005 +               cur_prob_tp = 0;
9006 +               cur_tp = 0;
9007 +               cur_tp2 = 0;
9008 +
9009 +               mg = &mi->groups[group];
9010 +               if (!mg->supported)
9011 +                       continue;
9012 +
9013 +               mg->max_tp_rate = 0;
9014 +               mg->max_tp_rate2 = 0;
9015 +               mg->max_prob_rate = 0;
9016 +               mi->sample_count++;
9017 +
9018 +               for (i = 0; i < MCS_GROUP_RATES; i++) {
9019 +                       if (!(mg->supported & BIT(i)))
9020 +                               continue;
9021 +
9022 +                       mr = &mg->rates[i];
9023 +                       mr->retry_updated = false;
9024 +                       index = MCS_GROUP_RATES * group + i;
9025 +                       minstrel_calc_rate_ewma(mp, mr);
9026 +                       minstrel_ht_calc_tp(mp, mi, group, i);
9027 +
9028 +                       if (!mr->cur_tp)
9029 +                               continue;
9030 +
9031 +                       /* ignore the lowest rate of each single-stream group */
9032 +                       if (!i && minstrel_mcs_groups[group].streams == 1)
9033 +                               continue;
9034 +
9035 +                       if ((mr->cur_tp > cur_prob_tp && mr->probability >
9036 +                            MINSTREL_FRAC(3, 4)) || mr->probability > cur_prob) {
9037 +                               mg->max_prob_rate = index;
9038 +                               cur_prob = mr->probability;
9039 +                       }
9040 +
9041 +                       if (mr->cur_tp > cur_tp) {
9042 +                               swap(index, mg->max_tp_rate);
9043 +                               cur_tp = mr->cur_tp;
9044 +                               mr = minstrel_get_ratestats(mi, index);
9045 +                       }
9046 +
9047 +                       if (index >= mg->max_tp_rate)
9048 +                               continue;
9049 +
9050 +                       if (mr->cur_tp > cur_tp2) {
9051 +                               mg->max_tp_rate2 = index;
9052 +                               cur_tp2 = mr->cur_tp;
9053 +                       }
9054 +               }
9055 +       }
9056 +
9057 +       /* try to sample up to half of the availble rates during each interval */
9058 +       mi->sample_count *= 4;
9059 +
9060 +       cur_prob = 0;
9061 +       cur_prob_tp = 0;
9062 +       cur_tp = 0;
9063 +       cur_tp2 = 0;
9064 +       for (group = 0; group < ARRAY_SIZE(minstrel_mcs_groups); group++) {
9065 +               mg = &mi->groups[group];
9066 +               if (!mg->supported)
9067 +                       continue;
9068 +
9069 +               mr = minstrel_get_ratestats(mi, mg->max_prob_rate);
9070 +               if (cur_prob_tp < mr->cur_tp &&
9071 +                   minstrel_mcs_groups[group].streams == 1) {
9072 +                       mi->max_prob_rate = mg->max_prob_rate;
9073 +                       cur_prob = mr->cur_prob;
9074 +               }
9075 +
9076 +               mr = minstrel_get_ratestats(mi, mg->max_tp_rate);
9077 +               if (cur_tp < mr->cur_tp) {
9078 +                       mi->max_tp_rate = mg->max_tp_rate;
9079 +                       cur_tp = mr->cur_tp;
9080 +               }
9081 +
9082 +               mr = minstrel_get_ratestats(mi, mg->max_tp_rate2);
9083 +               if (cur_tp2 < mr->cur_tp) {
9084 +                       mi->max_tp_rate2 = mg->max_tp_rate2;
9085 +                       cur_tp2 = mr->cur_tp;
9086 +               }
9087 +       }
9088 +
9089 +       mi->stats_update = jiffies;
9090 +}
9091 +
9092 +static bool
9093 +minstrel_ht_txstat_valid(struct ieee80211_tx_rate *rate)
9094 +{
9095 +       if (!rate->count)
9096 +               return false;
9097 +
9098 +       if (rate->idx < 0)
9099 +               return false;
9100 +
9101 +       return !!(rate->flags & IEEE80211_TX_RC_MCS);
9102 +}
9103 +
9104 +static void
9105 +minstrel_next_sample_idx(struct minstrel_ht_sta *mi)
9106 +{
9107 +       struct minstrel_mcs_group_data *mg;
9108 +
9109 +       for (;;) {
9110 +               mi->sample_group++;
9111 +               mi->sample_group %= ARRAY_SIZE(minstrel_mcs_groups);
9112 +               mg = &mi->groups[mi->sample_group];
9113 +
9114 +               if (!mg->supported)
9115 +                       continue;
9116 +
9117 +               if (++mg->index >= MCS_GROUP_RATES) {
9118 +                       mg->index = 0;
9119 +                       if (++mg->column >= ARRAY_SIZE(sample_table))
9120 +                               mg->column = 0;
9121 +               }
9122 +               break;
9123 +       }
9124 +}
9125 +
9126 +static void
9127 +minstrel_downgrade_rate(struct minstrel_ht_sta *mi, int *idx, bool primary)
9128 +{
9129 +       int group, orig_group;
9130 +
9131 +       orig_group = group = *idx / MCS_GROUP_RATES;
9132 +       while (group > 0) {
9133 +               group--;
9134 +
9135 +               if (!mi->groups[group].supported)
9136 +                       continue;
9137 +
9138 +               if (minstrel_mcs_groups[group].streams >
9139 +                   minstrel_mcs_groups[orig_group].streams)
9140 +                       continue;
9141 +
9142 +               if (primary)
9143 +                       *idx = mi->groups[group].max_tp_rate;
9144 +               else
9145 +                       *idx = mi->groups[group].max_tp_rate2;
9146 +               break;
9147 +       }
9148 +}
9149 +
9150 +static void
9151 +minstrel_aggr_check(struct minstrel_priv *mp, struct ieee80211_sta *pubsta, struct sk_buff *skb)
9152 +{
9153 +       struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
9154 +       struct sta_info *sta = container_of(pubsta, struct sta_info, sta);
9155 +       u16 tid;
9156 +
9157 +       if (unlikely(!ieee80211_is_data_qos(hdr->frame_control)))
9158 +               return;
9159 +
9160 +       if (unlikely(skb->protocol == cpu_to_be16(ETH_P_PAE)))
9161 +               return;
9162 +
9163 +       tid = *ieee80211_get_qos_ctl(hdr) & IEEE80211_QOS_CTL_TID_MASK;
9164 +       if (likely(sta->ampdu_mlme.tid_state_tx[tid] != HT_AGG_STATE_IDLE))
9165 +               return;
9166 +
9167 +       ieee80211_start_tx_ba_session(pubsta, tid);
9168 +}
9169 +
9170 +static void
9171 +minstrel_ht_tx_status(void *priv, struct ieee80211_supported_band *sband,
9172 +                      struct ieee80211_sta *sta, void *priv_sta,
9173 +                      struct sk_buff *skb)
9174 +{
9175 +       struct minstrel_ht_sta_priv *msp = priv_sta;
9176 +       struct minstrel_ht_sta *mi = &msp->ht;
9177 +       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
9178 +       struct ieee80211_tx_rate *ar = info->status.rates;
9179 +       struct minstrel_rate_stats *rate, *rate2;
9180 +       struct minstrel_priv *mp = priv;
9181 +       bool last = false;
9182 +       int group;
9183 +       int i = 0;
9184 +
9185 +       if (!msp->is_ht)
9186 +               return mac80211_minstrel.tx_status(priv, sband, sta, &msp->legacy, skb);
9187 +
9188 +       /* This packet was aggregated but doesn't carry status info */
9189 +       if ((info->flags & IEEE80211_TX_CTL_AMPDU) &&
9190 +           !(info->flags & IEEE80211_TX_STAT_AMPDU))
9191 +               return;
9192 +
9193 +       if (!info->status.ampdu_len) {
9194 +               info->status.ampdu_ack_len = 1;
9195 +               info->status.ampdu_len = 1;
9196 +       }
9197 +
9198 +       mi->ampdu_packets++;
9199 +       mi->ampdu_len += info->status.ampdu_len;
9200 +
9201 +       if (!mi->sample_wait && !mi->sample_tries && mi->sample_count > 0) {
9202 +               mi->sample_wait = 4 + 2 * MINSTREL_TRUNC(mi->avg_ampdu_len);
9203 +               mi->sample_tries = 3;
9204 +               mi->sample_count--;
9205 +       }
9206 +
9207 +       if (info->flags & IEEE80211_TX_CTL_RATE_CTRL_PROBE) {
9208 +               mi->sample_packets += info->status.ampdu_len;
9209 +               minstrel_next_sample_idx(mi);
9210 +       }
9211 +
9212 +       for (i = 0; !last; i++) {
9213 +               last = (i == IEEE80211_TX_MAX_RATES - 1) ||
9214 +                      !minstrel_ht_txstat_valid(&ar[i + 1]);
9215 +
9216 +               if (!minstrel_ht_txstat_valid(&ar[i]))
9217 +                       break;
9218 +
9219 +               group = minstrel_ht_get_group_idx(&ar[i]);
9220 +               rate = &mi->groups[group].rates[ar[i].idx % 8];
9221 +
9222 +               if (last && (info->flags & IEEE80211_TX_STAT_ACK))
9223 +                       rate->success += info->status.ampdu_ack_len;
9224 +
9225 +               rate->attempts += ar[i].count * info->status.ampdu_len;
9226 +       }
9227 +
9228 +       /*
9229 +        * check for sudden death of spatial multiplexing,
9230 +        * downgrade to a lower number of streams if necessary.
9231 +        */
9232 +       rate = minstrel_get_ratestats(mi, mi->max_tp_rate);
9233 +       if (rate->attempts > 30 &&
9234 +           MINSTREL_FRAC(rate->success, rate->attempts) <
9235 +           MINSTREL_FRAC(20, 100))
9236 +               minstrel_downgrade_rate(mi, &mi->max_tp_rate, true);
9237 +
9238 +       rate2 = minstrel_get_ratestats(mi, mi->max_tp_rate2);
9239 +       if (rate->attempts > 30 &&
9240 +           MINSTREL_FRAC(rate->success, rate->attempts) <
9241 +           MINSTREL_FRAC(20, 100))
9242 +               minstrel_downgrade_rate(mi, &mi->max_tp_rate2, false);
9243 +
9244 +       if (time_after(jiffies, mi->stats_update + (mp->update_interval / 2 * HZ) / 1000)) {
9245 +               minstrel_ht_update_stats(mp, mi);
9246 +               minstrel_aggr_check(mp, sta, skb);
9247 +       }
9248 +}
9249 +
9250 +static void
9251 +minstrel_calc_retransmit(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
9252 +                         int index)
9253 +{
9254 +       struct minstrel_rate_stats *mr;
9255 +       const struct mcs_group *group;
9256 +       unsigned int tx_time, tx_time_rtscts, tx_time_data;
9257 +       unsigned int cw = mp->cw_min;
9258 +       unsigned int t_slot = 9; /* FIXME */
9259 +       unsigned int ampdu_len = MINSTREL_TRUNC(mi->avg_ampdu_len);
9260 +
9261 +       mr = minstrel_get_ratestats(mi, index);
9262 +       if (mr->probability < MINSTREL_FRAC(1, 10)) {
9263 +               mr->retry_count = 1;
9264 +               mr->retry_count_rtscts = 1;
9265 +               return;
9266 +       }
9267 +
9268 +       mr->retry_count = 2;
9269 +       mr->retry_count_rtscts = 2;
9270 +       mr->retry_updated = true;
9271 +
9272 +       group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
9273 +       tx_time_data = group->duration[index % MCS_GROUP_RATES] * ampdu_len;
9274 +       tx_time = 2 * (t_slot + mi->overhead + tx_time_data);
9275 +       tx_time_rtscts = 2 * (t_slot + mi->overhead_rtscts + tx_time_data);
9276 +       do {
9277 +               cw = (cw << 1) | 1;
9278 +               cw = min(cw, mp->cw_max);
9279 +               tx_time += cw + t_slot + mi->overhead;
9280 +               tx_time_rtscts += cw + t_slot + mi->overhead_rtscts;
9281 +               if (tx_time_rtscts < mp->segment_size)
9282 +                       mr->retry_count_rtscts++;
9283 +       } while ((tx_time < mp->segment_size) &&
9284 +                (++mr->retry_count < mp->max_retry));
9285 +}
9286 +
9287 +
9288 +static void
9289 +minstrel_ht_set_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi,
9290 +                     struct ieee80211_tx_rate *rate, int index,
9291 +                     struct ieee80211_tx_rate_control *txrc,
9292 +                     bool sample, bool rtscts)
9293 +{
9294 +       const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
9295 +       struct minstrel_rate_stats *mr;
9296 +
9297 +       mr = minstrel_get_ratestats(mi, index);
9298 +       if (!mr->retry_updated)
9299 +               minstrel_calc_retransmit(mp, mi, index);
9300 +
9301 +       if (mr->probability < MINSTREL_FRAC(20, 100))
9302 +               rate->count = 2;
9303 +       else if (rtscts)
9304 +               rate->count = mr->retry_count_rtscts;
9305 +       else
9306 +               rate->count = mr->retry_count;
9307 +
9308 +       rate->flags = IEEE80211_TX_RC_MCS | group->flags;
9309 +       if (txrc->short_preamble)
9310 +               rate->flags |= IEEE80211_TX_RC_USE_SHORT_PREAMBLE;
9311 +       if (txrc->rts || rtscts)
9312 +               rate->flags |= IEEE80211_TX_RC_USE_RTS_CTS;
9313 +       rate->idx = index % MCS_GROUP_RATES + (group->streams - 1) * MCS_GROUP_RATES;
9314 +}
9315 +
9316 +static inline int
9317 +minstrel_get_duration(int index)
9318 +{
9319 +       const struct mcs_group *group = &minstrel_mcs_groups[index / MCS_GROUP_RATES];
9320 +       return group->duration[index % MCS_GROUP_RATES];
9321 +}
9322 +
9323 +static int
9324 +minstrel_get_sample_rate(struct minstrel_priv *mp, struct minstrel_ht_sta *mi)
9325 +{
9326 +       struct minstrel_rate_stats *mr;
9327 +       struct minstrel_mcs_group_data *mg;
9328 +       int sample_idx = 0;
9329 +
9330 +       if (mi->sample_wait > 0) {
9331 +               mi->sample_wait--;
9332 +               return -1;
9333 +       }
9334 +
9335 +       if (!mi->sample_tries)
9336 +               return -1;
9337 +
9338 +       mi->sample_tries--;
9339 +       mg = &mi->groups[mi->sample_group];
9340 +       sample_idx = sample_table[mg->column][mg->index];
9341 +       mr = &mg->rates[sample_idx];
9342 +       sample_idx += mi->sample_group * MCS_GROUP_RATES;
9343 +
9344 +       /*
9345 +        * When not using MRR, do not sample if the probability is already
9346 +        * higher than 95% to avoid wasting airtime
9347 +        */
9348 +       if (!mp->has_mrr && (mr->probability > MINSTREL_FRAC(95, 100)))
9349 +               goto next;
9350 +
9351 +       /*
9352 +        * Make sure that lower rates get sampled only occasionally,
9353 +        * if the link is working perfectly.
9354 +        */
9355 +       if (minstrel_get_duration(sample_idx) >
9356 +           minstrel_get_duration(mi->max_tp_rate)) {
9357 +               if (mr->sample_skipped < 10)
9358 +                       goto next;
9359 +
9360 +               if (mi->sample_slow++ > 2)
9361 +                       goto next;
9362 +       }
9363 +
9364 +       return sample_idx;
9365 +
9366 +next:
9367 +       minstrel_next_sample_idx(mi);
9368 +       return -1;
9369 +}
9370 +
9371 +static void
9372 +minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta,
9373 +                     struct ieee80211_tx_rate_control *txrc)
9374 +{
9375 +       struct ieee80211_tx_info *info = IEEE80211_SKB_CB(txrc->skb);
9376 +       struct ieee80211_tx_rate *ar = info->status.rates;
9377 +       struct minstrel_ht_sta_priv *msp = priv_sta;
9378 +       struct minstrel_ht_sta *mi = &msp->ht;
9379 +       struct minstrel_priv *mp = priv;
9380 +       int sample_idx;
9381 +
9382 +       if (rate_control_send_low(sta, priv_sta, txrc))
9383 +               return;
9384 +
9385 +       if (!msp->is_ht)
9386 +               return mac80211_minstrel.get_rate(priv, sta, &msp->legacy, txrc);
9387 +
9388 +       info->flags |= mi->tx_flags;
9389 +       sample_idx = minstrel_get_sample_rate(mp, mi);
9390 +       if (sample_idx >= 0) {
9391 +               minstrel_ht_set_rate(mp, mi, &ar[0], sample_idx,
9392 +                       txrc, true, false);
9393 +               minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate,
9394 +                       txrc, false, true);
9395 +               info->flags |= IEEE80211_TX_CTL_RATE_CTRL_PROBE;
9396 +       } else {
9397 +               minstrel_ht_set_rate(mp, mi, &ar[0], mi->max_tp_rate,
9398 +                       txrc, false, false);
9399 +               minstrel_ht_set_rate(mp, mi, &ar[1], mi->max_tp_rate2,
9400 +                       txrc, false, true);
9401 +       }
9402 +       minstrel_ht_set_rate(mp, mi, &ar[2], mi->max_prob_rate, txrc, false, true);
9403 +
9404 +       ar[3].count = 0;
9405 +       ar[3].idx = -1;
9406 +
9407 +       mi->total_packets++;
9408 +
9409 +       /* wraparound */
9410 +       if (mi->total_packets == ~0) {
9411 +               mi->total_packets = 0;
9412 +               mi->sample_packets = 0;
9413 +       }
9414 +}
9415 +
9416 +static void
9417 +minstrel_ht_update_caps(void *priv, struct ieee80211_supported_band *sband,
9418 +                        struct ieee80211_sta *sta, void *priv_sta,
9419 +                       enum nl80211_channel_type oper_chan_type)
9420 +{
9421 +       struct minstrel_priv *mp = priv;
9422 +       struct minstrel_ht_sta_priv *msp = priv_sta;
9423 +       struct minstrel_ht_sta *mi = &msp->ht;
9424 +       struct ieee80211_mcs_info *mcs = &sta->ht_cap.mcs;
9425 +       struct ieee80211_local *local = hw_to_local(mp->hw);
9426 +       u16 sta_cap = sta->ht_cap.cap;
9427 +       int ack_dur;
9428 +       int stbc;
9429 +       int i;
9430 +
9431 +       /* fall back to the old minstrel for legacy stations */
9432 +       if (sta && !sta->ht_cap.ht_supported) {
9433 +               msp->is_ht = false;
9434 +               memset(&msp->legacy, 0, sizeof(msp->legacy));
9435 +               msp->legacy.r = msp->ratelist;
9436 +               msp->legacy.sample_table = msp->sample_table;
9437 +               return mac80211_minstrel.rate_init(priv, sband, sta, &msp->legacy);
9438 +       }
9439 +
9440 +       BUILD_BUG_ON(ARRAY_SIZE(minstrel_mcs_groups) !=
9441 +               MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS);
9442 +
9443 +       msp->is_ht = true;
9444 +       memset(mi, 0, sizeof(*mi));
9445 +       mi->stats_update = jiffies;
9446 +
9447 +       ack_dur = ieee80211_frame_duration(local, 10, 60, 1, 1);
9448 +       mi->overhead = ieee80211_frame_duration(local, 0, 60, 1, 1) + ack_dur;
9449 +       mi->overhead_rtscts = mi->overhead + 2 * ack_dur;
9450 +
9451 +       mi->avg_ampdu_len = MINSTREL_FRAC(1, 1);
9452 +
9453 +       /* When using MRR, sample more on the first attempt, without delay */
9454 +       if (mp->has_mrr) {
9455 +               mi->sample_count = 16;
9456 +               mi->sample_wait = 0;
9457 +       } else {
9458 +               mi->sample_count = 8;
9459 +               mi->sample_wait = 8;
9460 +       }
9461 +       mi->sample_tries = 4;
9462 +
9463 +       stbc = (sta_cap & IEEE80211_HT_CAP_RX_STBC) >>
9464 +               IEEE80211_HT_CAP_RX_STBC_SHIFT;
9465 +       mi->tx_flags |= stbc << IEEE80211_TX_CTL_STBC_SHIFT;
9466 +
9467 +       if (sta_cap & IEEE80211_HT_CAP_LDPC_CODING)
9468 +               mi->tx_flags |= IEEE80211_TX_CTL_LDPC;
9469 +
9470 +       if (oper_chan_type != NL80211_CHAN_HT40MINUS &&
9471 +           oper_chan_type != NL80211_CHAN_HT40PLUS)
9472 +               sta_cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
9473 +
9474 +       for (i = 0; i < ARRAY_SIZE(mi->groups); i++) {
9475 +               u16 req = 0;
9476 +
9477 +               mi->groups[i].supported = 0;
9478 +               if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_SHORT_GI) {
9479 +                       if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
9480 +                               req |= IEEE80211_HT_CAP_SGI_40;
9481 +                       else
9482 +                               req |= IEEE80211_HT_CAP_SGI_20;
9483 +               }
9484 +
9485 +               if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
9486 +                       req |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
9487 +
9488 +               if ((sta_cap & req) != req)
9489 +                       continue;
9490 +
9491 +               mi->groups[i].supported =
9492 +                       mcs->rx_mask[minstrel_mcs_groups[i].streams - 1];
9493 +       }
9494 +}
9495 +
9496 +static void
9497 +minstrel_ht_rate_init(void *priv, struct ieee80211_supported_band *sband,
9498 +                      struct ieee80211_sta *sta, void *priv_sta)
9499 +{
9500 +       struct minstrel_priv *mp = priv;
9501 +
9502 +       minstrel_ht_update_caps(priv, sband, sta, priv_sta, mp->hw->conf.channel_type);
9503 +}
9504 +
9505 +static void
9506 +minstrel_ht_rate_update(void *priv, struct ieee80211_supported_band *sband,
9507 +                        struct ieee80211_sta *sta, void *priv_sta,
9508 +                        u32 changed, enum nl80211_channel_type oper_chan_type)
9509 +{
9510 +       minstrel_ht_update_caps(priv, sband, sta, priv_sta, oper_chan_type);
9511 +}
9512 +
9513 +static void *
9514 +minstrel_ht_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
9515 +{
9516 +       struct ieee80211_supported_band *sband;
9517 +       struct minstrel_ht_sta_priv *msp;
9518 +       struct minstrel_priv *mp = priv;
9519 +       struct ieee80211_hw *hw = mp->hw;
9520 +       int max_rates = 0;
9521 +       int i;
9522 +
9523 +       for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
9524 +               sband = hw->wiphy->bands[i];
9525 +               if (sband && sband->n_bitrates > max_rates)
9526 +                       max_rates = sband->n_bitrates;
9527 +       }
9528 +
9529 +       msp = kzalloc(sizeof(struct minstrel_ht_sta), gfp);
9530 +       if (!msp)
9531 +               return NULL;
9532 +
9533 +       msp->ratelist = kzalloc(sizeof(struct minstrel_rate) * max_rates, gfp);
9534 +       if (!msp->ratelist)
9535 +               goto error;
9536 +
9537 +       msp->sample_table = kmalloc(SAMPLE_COLUMNS * max_rates, gfp);
9538 +       if (!msp->sample_table)
9539 +               goto error1;
9540 +
9541 +       return msp;
9542 +
9543 +error1:
9544 +       kfree(msp->sample_table);
9545 +error:
9546 +       kfree(msp);
9547 +       return NULL;
9548 +}
9549 +
9550 +static void
9551 +minstrel_ht_free_sta(void *priv, struct ieee80211_sta *sta, void *priv_sta)
9552 +{
9553 +       struct minstrel_ht_sta_priv *msp = priv_sta;
9554 +
9555 +       kfree(msp->sample_table);
9556 +       kfree(msp->ratelist);
9557 +       kfree(msp);
9558 +}
9559 +
9560 +static void *
9561 +minstrel_ht_alloc(struct ieee80211_hw *hw, struct dentry *debugfsdir)
9562 +{
9563 +       return mac80211_minstrel.alloc(hw, debugfsdir);
9564 +}
9565 +
9566 +static void
9567 +minstrel_ht_free(void *priv)
9568 +{
9569 +       mac80211_minstrel.free(priv);
9570 +}
9571 +
9572 +static struct rate_control_ops mac80211_minstrel_ht = {
9573 +       .name = "minstrel_ht",
9574 +       .tx_status = minstrel_ht_tx_status,
9575 +       .get_rate = minstrel_ht_get_rate,
9576 +       .rate_init = minstrel_ht_rate_init,
9577 +       .rate_update = minstrel_ht_rate_update,
9578 +       .alloc_sta = minstrel_ht_alloc_sta,
9579 +       .free_sta = minstrel_ht_free_sta,
9580 +       .alloc = minstrel_ht_alloc,
9581 +       .free = minstrel_ht_free,
9582 +#ifdef CONFIG_MAC80211_DEBUGFS
9583 +       .add_sta_debugfs = minstrel_ht_add_sta_debugfs,
9584 +       .remove_sta_debugfs = minstrel_ht_remove_sta_debugfs,
9585 +#endif
9586 +};
9587 +
9588 +
9589 +static void
9590 +init_sample_table(void)
9591 +{
9592 +       int col, i, new_idx;
9593 +       u8 rnd[MCS_GROUP_RATES];
9594 +
9595 +       memset(sample_table, 0xff, sizeof(sample_table));
9596 +       for (col = 0; col < SAMPLE_COLUMNS; col++) {
9597 +               for (i = 0; i < MCS_GROUP_RATES; i++) {
9598 +                       get_random_bytes(rnd, sizeof(rnd));
9599 +                       new_idx = (i + rnd[i]) % MCS_GROUP_RATES;
9600 +
9601 +                       while (sample_table[col][new_idx] != 0xff)
9602 +                               new_idx = (new_idx + 1) % MCS_GROUP_RATES;
9603 +
9604 +                       sample_table[col][new_idx] = i;
9605 +               }
9606 +       }
9607 +}
9608 +
9609 +int __init
9610 +rc80211_minstrel_ht_init(void)
9611 +{
9612 +       init_sample_table();
9613 +       return ieee80211_rate_control_register(&mac80211_minstrel_ht);
9614 +}
9615 +
9616 +void
9617 +rc80211_minstrel_ht_exit(void)
9618 +{
9619 +       ieee80211_rate_control_unregister(&mac80211_minstrel_ht);
9620 +}
9621 --- /dev/null
9622 +++ b/net/mac80211/rc80211_minstrel_ht.h
9623 @@ -0,0 +1,128 @@
9624 +/*
9625 + * Copyright (C) 2010 Felix Fietkau <nbd@openwrt.org>
9626 + *
9627 + * This program is free software; you can redistribute it and/or modify
9628 + * it under the terms of the GNU General Public License version 2 as
9629 + * published by the Free Software Foundation.
9630 + */
9631 +
9632 +#ifndef __RC_MINSTREL_HT_H
9633 +#define __RC_MINSTREL_HT_H
9634 +
9635 +/*
9636 + * The number of streams can be changed to 2 to reduce code
9637 + * size and memory footprint.
9638 + */
9639 +#define MINSTREL_MAX_STREAMS   3
9640 +#define MINSTREL_STREAM_GROUPS 4
9641 +
9642 +/* scaled fraction values */
9643 +#define MINSTREL_SCALE 16
9644 +#define MINSTREL_FRAC(val, div) (((val) << MINSTREL_SCALE) / div)
9645 +#define MINSTREL_TRUNC(val) ((val) >> MINSTREL_SCALE)
9646 +
9647 +#define MCS_GROUP_RATES        8
9648 +
9649 +struct mcs_group {
9650 +       u32 flags;
9651 +       unsigned int streams;
9652 +       unsigned int duration[MCS_GROUP_RATES];
9653 +};
9654 +
9655 +struct minstrel_rate_stats {
9656 +       /* current / last sampling period attempts/success counters */
9657 +       unsigned int attempts, last_attempts;
9658 +       unsigned int success, last_success;
9659 +
9660 +       /* total attempts/success counters */
9661 +       u64 att_hist, succ_hist;
9662 +
9663 +       /* current throughput */
9664 +       unsigned int cur_tp;
9665 +
9666 +       /* packet delivery probabilities */
9667 +       unsigned int cur_prob, probability;
9668 +
9669 +       /* maximum retry counts */
9670 +       unsigned int retry_count;
9671 +       unsigned int retry_count_rtscts;
9672 +
9673 +       bool retry_updated;
9674 +       u8 sample_skipped;
9675 +};
9676 +
9677 +struct minstrel_mcs_group_data {
9678 +       u8 index;
9679 +       u8 column;
9680 +
9681 +       /* bitfield of supported MCS rates of this group */
9682 +       u8 supported;
9683 +
9684 +       /* selected primary rates */
9685 +       unsigned int max_tp_rate;
9686 +       unsigned int max_tp_rate2;
9687 +       unsigned int max_prob_rate;
9688 +
9689 +       /* MCS rate statistics */
9690 +       struct minstrel_rate_stats rates[MCS_GROUP_RATES];
9691 +};
9692 +
9693 +struct minstrel_ht_sta {
9694 +       /* ampdu length (average, per sampling interval) */
9695 +       unsigned int ampdu_len;
9696 +       unsigned int ampdu_packets;
9697 +
9698 +       /* ampdu length (EWMA) */
9699 +       unsigned int avg_ampdu_len;
9700 +
9701 +       /* best throughput rate */
9702 +       unsigned int max_tp_rate;
9703 +
9704 +       /* second best throughput rate */
9705 +       unsigned int max_tp_rate2;
9706 +
9707 +       /* best probability rate */
9708 +       unsigned int max_prob_rate;
9709 +
9710 +       /* time of last status update */
9711 +       unsigned long stats_update;
9712 +
9713 +       /* overhead time in usec for each frame */
9714 +       unsigned int overhead;
9715 +       unsigned int overhead_rtscts;
9716 +
9717 +       unsigned int total_packets;
9718 +       unsigned int sample_packets;
9719 +
9720 +       /* tx flags to add for frames for this sta */
9721 +       u32 tx_flags;
9722 +
9723 +       u8 sample_wait;
9724 +       u8 sample_tries;
9725 +       u8 sample_count;
9726 +       u8 sample_slow;
9727 +
9728 +       /* current MCS group to be sampled */
9729 +       u8 sample_group;
9730 +
9731 +       /* MCS rate group info and statistics */
9732 +       struct minstrel_mcs_group_data groups[MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS];
9733 +};
9734 +
9735 +struct minstrel_ht_sta_priv {
9736 +       union {
9737 +               struct minstrel_ht_sta ht;
9738 +               struct minstrel_sta_info legacy;
9739 +       };
9740 +#ifdef CONFIG_MAC80211_DEBUGFS
9741 +       struct dentry *dbg_stats;
9742 +#endif
9743 +       void *ratelist;
9744 +       void *sample_table;
9745 +       bool is_ht;
9746 +};
9747 +
9748 +void minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir);
9749 +void minstrel_ht_remove_sta_debugfs(void *priv, void *priv_sta);
9750 +
9751 +#endif
9752 --- /dev/null
9753 +++ b/net/mac80211/rc80211_minstrel_ht_debugfs.c
9754 @@ -0,0 +1,120 @@
9755 +/*
9756 + * Copyright (C) 2010 Felix Fietkau <nbd@openwrt.org>
9757 + *
9758 + * This program is free software; you can redistribute it and/or modify
9759 + * it under the terms of the GNU General Public License version 2 as
9760 + * published by the Free Software Foundation.
9761 + */
9762 +#include <linux/netdevice.h>
9763 +#include <linux/types.h>
9764 +#include <linux/skbuff.h>
9765 +#include <linux/debugfs.h>
9766 +#include <linux/ieee80211.h>
9767 +#include <net/mac80211.h>
9768 +#include "rc80211_minstrel.h"
9769 +#include "rc80211_minstrel_ht.h"
9770 +
9771 +extern const struct mcs_group minstrel_mcs_groups[];
9772 +
9773 +static int
9774 +minstrel_ht_stats_open(struct inode *inode, struct file *file)
9775 +{
9776 +       struct minstrel_ht_sta_priv *msp = inode->i_private;
9777 +       struct minstrel_ht_sta *mi = &msp->ht;
9778 +       struct minstrel_debugfs_info *ms;
9779 +       unsigned int i, j, tp, prob, eprob;
9780 +       char *p;
9781 +       int ret;
9782 +
9783 +       if (!msp->is_ht) {
9784 +               inode->i_private = &msp->legacy;
9785 +               ret = minstrel_stats_open(inode, file);
9786 +               inode->i_private = msp;
9787 +               return ret;
9788 +       }
9789 +
9790 +       ms = kmalloc(sizeof(*ms) + 8192, GFP_KERNEL);
9791 +       if (!ms)
9792 +               return -ENOMEM;
9793 +
9794 +       file->private_data = ms;
9795 +       p = ms->buf;
9796 +       p += sprintf(p, "type      rate     throughput  ewma prob   this prob  "
9797 +                       "this succ/attempt   success    attempts\n");
9798 +       for (i = 0; i < MINSTREL_MAX_STREAMS * MINSTREL_STREAM_GROUPS; i++) {
9799 +               char htmode = '2';
9800 +               char gimode = 'L';
9801 +
9802 +               if (!mi->groups[i].supported)
9803 +                       continue;
9804 +
9805 +               if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
9806 +                       htmode = '4';
9807 +               if (minstrel_mcs_groups[i].flags & IEEE80211_TX_RC_SHORT_GI)
9808 +                       gimode = 'S';
9809 +
9810 +               for (j = 0; j < MCS_GROUP_RATES; j++) {
9811 +                       struct minstrel_rate_stats *mr = &mi->groups[i].rates[j];
9812 +                       int idx = i * MCS_GROUP_RATES + j;
9813 +
9814 +                       if (!(mi->groups[i].supported & BIT(j)))
9815 +                               continue;
9816 +
9817 +                       p += sprintf(p, "HT%c0/%cGI ", htmode, gimode);
9818 +
9819 +                       *(p++) = (idx == mi->max_tp_rate) ? 'T' : ' ';
9820 +                       *(p++) = (idx == mi->max_tp_rate2) ? 't' : ' ';
9821 +                       *(p++) = (idx == mi->max_prob_rate) ? 'P' : ' ';
9822 +                       p += sprintf(p, "MCS%-2u", (minstrel_mcs_groups[i].streams - 1) *
9823 +                                       MCS_GROUP_RATES + j);
9824 +
9825 +                       tp = mr->cur_tp / 10;
9826 +                       prob = MINSTREL_TRUNC(mr->cur_prob * 1000);
9827 +                       eprob = MINSTREL_TRUNC(mr->probability * 1000);
9828 +
9829 +                       p += sprintf(p, "  %6u.%1u   %6u.%1u   %6u.%1u        "
9830 +                                       "%3u(%3u)   %8llu    %8llu\n",
9831 +                                       tp / 10, tp % 10,
9832 +                                       eprob / 10, eprob % 10,
9833 +                                       prob / 10, prob % 10,
9834 +                                       mr->last_success,
9835 +                                       mr->last_attempts,
9836 +                                       (unsigned long long)mr->succ_hist,
9837 +                                       (unsigned long long)mr->att_hist);
9838 +               }
9839 +       }
9840 +       p += sprintf(p, "\nTotal packet count::    ideal %d      "
9841 +                       "lookaround %d\n",
9842 +                       max(0, (int) mi->total_packets - (int) mi->sample_packets),
9843 +                       mi->sample_packets);
9844 +       p += sprintf(p, "Average A-MPDU length: %d.%d\n",
9845 +               MINSTREL_TRUNC(mi->avg_ampdu_len),
9846 +               MINSTREL_TRUNC(mi->avg_ampdu_len * 10) % 10);
9847 +       ms->len = p - ms->buf;
9848 +
9849 +       return 0;
9850 +}
9851 +
9852 +static const struct file_operations minstrel_ht_stat_fops = {
9853 +       .owner = THIS_MODULE,
9854 +       .open = minstrel_ht_stats_open,
9855 +       .read = minstrel_stats_read,
9856 +       .release = minstrel_stats_release,
9857 +};
9858 +
9859 +void
9860 +minstrel_ht_add_sta_debugfs(void *priv, void *priv_sta, struct dentry *dir)
9861 +{
9862 +       struct minstrel_ht_sta_priv *msp = priv_sta;
9863 +
9864 +       msp->dbg_stats = debugfs_create_file("rc_stats", S_IRUGO, dir, msp,
9865 +                       &minstrel_ht_stat_fops);
9866 +}
9867 +
9868 +void
9869 +minstrel_ht_remove_sta_debugfs(void *priv, void *priv_sta)
9870 +{
9871 +       struct minstrel_ht_sta_priv *msp = priv_sta;
9872 +
9873 +       debugfs_remove(msp->dbg_stats);
9874 +}