4 * Copyright (c) 2004, 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org>
5 * Copyright (c) 2006, 2007 Nick Kossifidis <mickflemm@gmail.com>
6 * Copyright (c) 2007 Jiri Slaby <jirislaby@gmail.com>
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 #include <linux/delay.h>
28 /* Struct to hold initial RF register values (RF Banks) */
30 u8 rf_bank
; /* check out ath5k_reg.h */
31 u16 rf_register
; /* register address */
32 u32 rf_value
[5]; /* register value for different modes (above) */
36 * Mode-specific RF Gain table (64bytes) for RF5111/5112
37 * (RF5110 only comes with AR5210 and only supports a/turbo a mode so initial
38 * RF Gain values are included in AR5K_AR5210_INI)
40 struct ath5k_ini_rfgain
{
41 u16 rfg_register
; /* RF Gain register address */
42 u32 rfg_value
[2]; /* [freq (see below)] */
45 struct ath5k_gain_opt
{
48 const struct ath5k_gain_opt_step go_step
[AR5K_GAIN_STEP_COUNT
];
51 /* RF5111 mode-specific init registers */
52 static const struct ath5k_ini_rf rfregs_5111
[] = {
54 /* mode a/XR mode aTurbo mode b mode g mode gTurbo */
55 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
57 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
59 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
61 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
63 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
65 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
67 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
69 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
71 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
73 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
75 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
77 { 0x00380000, 0x00380000, 0x00380000, 0x00380000, 0x00380000 } },
79 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
81 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
83 { 0x00000000, 0x00000000, 0x000000c0, 0x00000080, 0x00000080 } },
85 { 0x000400f9, 0x000400f9, 0x000400ff, 0x000400fd, 0x000400fd } },
87 { 0x00000000, 0x00000000, 0x00000004, 0x00000004, 0x00000004 } },
89 { 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020 } },
91 { 0x00000010, 0x00000014, 0x00000010, 0x00000010, 0x00000014 } },
93 { 0x00601068, 0x00601068, 0x00601068, 0x00601068, 0x00601068 } },
95 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
97 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
99 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
101 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
103 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
105 { 0x10000000, 0x10000000, 0x10000000, 0x10000000, 0x10000000 } },
107 { 0x04000000, 0x04000000, 0x04000000, 0x04000000, 0x04000000 } },
109 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
111 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
113 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
115 { 0x00000000, 0x00000000, 0x0a000000, 0x00000000, 0x00000000 } },
117 { 0x003800c0, 0x00380080, 0x023800c0, 0x003800c0, 0x003800c0 } },
119 { 0x00020006, 0x00020006, 0x00000006, 0x00020006, 0x00020006 } },
121 { 0x00000089, 0x00000089, 0x00000089, 0x00000089, 0x00000089 } },
123 { 0x000000a0, 0x000000a0, 0x000000a0, 0x000000a0, 0x000000a0 } },
125 { 0x00040007, 0x00040007, 0x00040007, 0x00040007, 0x00040007 } },
127 { 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a, 0x0000001a } },
129 { 0x00000040, 0x00000048, 0x00000040, 0x00000040, 0x00000040 } },
131 { 0x00000010, 0x00000010, 0x00000010, 0x00000010, 0x00000010 } },
133 { 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008 } },
135 { 0x0000004f, 0x0000004f, 0x0000004f, 0x0000004f, 0x0000004f } },
137 { 0x000000f1, 0x000000f1, 0x00000061, 0x000000f1, 0x000000f1 } },
139 { 0x0000904f, 0x0000904f, 0x0000904c, 0x0000904f, 0x0000904f } },
141 { 0x0000125a, 0x0000125a, 0x0000129a, 0x0000125a, 0x0000125a } },
143 { 0x0000000e, 0x0000000e, 0x0000000f, 0x0000000e, 0x0000000e } },
146 /* Initial RF Gain settings for RF5111 */
147 static const struct ath5k_ini_rfgain rfgain_5111
[] = {
149 { AR5K_RF_GAIN(0), { 0x000001a9, 0x00000000 } },
150 { AR5K_RF_GAIN(1), { 0x000001e9, 0x00000040 } },
151 { AR5K_RF_GAIN(2), { 0x00000029, 0x00000080 } },
152 { AR5K_RF_GAIN(3), { 0x00000069, 0x00000150 } },
153 { AR5K_RF_GAIN(4), { 0x00000199, 0x00000190 } },
154 { AR5K_RF_GAIN(5), { 0x000001d9, 0x000001d0 } },
155 { AR5K_RF_GAIN(6), { 0x00000019, 0x00000010 } },
156 { AR5K_RF_GAIN(7), { 0x00000059, 0x00000044 } },
157 { AR5K_RF_GAIN(8), { 0x00000099, 0x00000084 } },
158 { AR5K_RF_GAIN(9), { 0x000001a5, 0x00000148 } },
159 { AR5K_RF_GAIN(10), { 0x000001e5, 0x00000188 } },
160 { AR5K_RF_GAIN(11), { 0x00000025, 0x000001c8 } },
161 { AR5K_RF_GAIN(12), { 0x000001c8, 0x00000014 } },
162 { AR5K_RF_GAIN(13), { 0x00000008, 0x00000042 } },
163 { AR5K_RF_GAIN(14), { 0x00000048, 0x00000082 } },
164 { AR5K_RF_GAIN(15), { 0x00000088, 0x00000178 } },
165 { AR5K_RF_GAIN(16), { 0x00000198, 0x000001b8 } },
166 { AR5K_RF_GAIN(17), { 0x000001d8, 0x000001f8 } },
167 { AR5K_RF_GAIN(18), { 0x00000018, 0x00000012 } },
168 { AR5K_RF_GAIN(19), { 0x00000058, 0x00000052 } },
169 { AR5K_RF_GAIN(20), { 0x00000098, 0x00000092 } },
170 { AR5K_RF_GAIN(21), { 0x000001a4, 0x0000017c } },
171 { AR5K_RF_GAIN(22), { 0x000001e4, 0x000001bc } },
172 { AR5K_RF_GAIN(23), { 0x00000024, 0x000001fc } },
173 { AR5K_RF_GAIN(24), { 0x00000064, 0x0000000a } },
174 { AR5K_RF_GAIN(25), { 0x000000a4, 0x0000004a } },
175 { AR5K_RF_GAIN(26), { 0x000000e4, 0x0000008a } },
176 { AR5K_RF_GAIN(27), { 0x0000010a, 0x0000015a } },
177 { AR5K_RF_GAIN(28), { 0x0000014a, 0x0000019a } },
178 { AR5K_RF_GAIN(29), { 0x0000018a, 0x000001da } },
179 { AR5K_RF_GAIN(30), { 0x000001ca, 0x0000000e } },
180 { AR5K_RF_GAIN(31), { 0x0000000a, 0x0000004e } },
181 { AR5K_RF_GAIN(32), { 0x0000004a, 0x0000008e } },
182 { AR5K_RF_GAIN(33), { 0x0000008a, 0x0000015e } },
183 { AR5K_RF_GAIN(34), { 0x000001ba, 0x0000019e } },
184 { AR5K_RF_GAIN(35), { 0x000001fa, 0x000001de } },
185 { AR5K_RF_GAIN(36), { 0x0000003a, 0x00000009 } },
186 { AR5K_RF_GAIN(37), { 0x0000007a, 0x00000049 } },
187 { AR5K_RF_GAIN(38), { 0x00000186, 0x00000089 } },
188 { AR5K_RF_GAIN(39), { 0x000001c6, 0x00000179 } },
189 { AR5K_RF_GAIN(40), { 0x00000006, 0x000001b9 } },
190 { AR5K_RF_GAIN(41), { 0x00000046, 0x000001f9 } },
191 { AR5K_RF_GAIN(42), { 0x00000086, 0x00000039 } },
192 { AR5K_RF_GAIN(43), { 0x000000c6, 0x00000079 } },
193 { AR5K_RF_GAIN(44), { 0x000000c6, 0x000000b9 } },
194 { AR5K_RF_GAIN(45), { 0x000000c6, 0x000001bd } },
195 { AR5K_RF_GAIN(46), { 0x000000c6, 0x000001fd } },
196 { AR5K_RF_GAIN(47), { 0x000000c6, 0x0000003d } },
197 { AR5K_RF_GAIN(48), { 0x000000c6, 0x0000007d } },
198 { AR5K_RF_GAIN(49), { 0x000000c6, 0x000000bd } },
199 { AR5K_RF_GAIN(50), { 0x000000c6, 0x000000fd } },
200 { AR5K_RF_GAIN(51), { 0x000000c6, 0x000000fd } },
201 { AR5K_RF_GAIN(52), { 0x000000c6, 0x000000fd } },
202 { AR5K_RF_GAIN(53), { 0x000000c6, 0x000000fd } },
203 { AR5K_RF_GAIN(54), { 0x000000c6, 0x000000fd } },
204 { AR5K_RF_GAIN(55), { 0x000000c6, 0x000000fd } },
205 { AR5K_RF_GAIN(56), { 0x000000c6, 0x000000fd } },
206 { AR5K_RF_GAIN(57), { 0x000000c6, 0x000000fd } },
207 { AR5K_RF_GAIN(58), { 0x000000c6, 0x000000fd } },
208 { AR5K_RF_GAIN(59), { 0x000000c6, 0x000000fd } },
209 { AR5K_RF_GAIN(60), { 0x000000c6, 0x000000fd } },
210 { AR5K_RF_GAIN(61), { 0x000000c6, 0x000000fd } },
211 { AR5K_RF_GAIN(62), { 0x000000c6, 0x000000fd } },
212 { AR5K_RF_GAIN(63), { 0x000000c6, 0x000000fd } },
215 static const struct ath5k_gain_opt rfgain_opt_5111
= {
219 { { 4, 1, 1, 1 }, 6 },
220 { { 4, 0, 1, 1 }, 4 },
221 { { 3, 1, 1, 1 }, 3 },
222 { { 4, 0, 0, 1 }, 1 },
223 { { 4, 1, 1, 0 }, 0 },
224 { { 4, 0, 1, 0 }, -2 },
225 { { 3, 1, 1, 0 }, -3 },
226 { { 4, 0, 0, 0 }, -4 },
227 { { 2, 1, 1, 0 }, -6 }
231 /* RF5112 mode-specific init registers */
232 static const struct ath5k_ini_rf rfregs_5112
[] = {
234 /* mode a/XR mode aTurbo mode b mode g mode gTurbo */
235 { 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020 } },
237 { 0x03060408, 0x03070408, 0x03060408, 0x03060408, 0x03070408 } },
239 { 0x00a0c0c0, 0x00a0c0c0, 0x00e0c0c0, 0x00e0c0c0, 0x00e0c0c0 } },
241 { 0x00a00000, 0x00a00000, 0x00a00000, 0x00a00000, 0x00a00000 } },
243 { 0x000a0000, 0x000a0000, 0x000a0000, 0x000a0000, 0x000a0000 } },
245 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
247 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
249 { 0x00660000, 0x00660000, 0x00660000, 0x00660000, 0x00660000 } },
251 { 0x00db0000, 0x00db0000, 0x00db0000, 0x00db0000, 0x00db0000 } },
253 { 0x00f10000, 0x00f10000, 0x00f10000, 0x00f10000, 0x00f10000 } },
255 { 0x00120000, 0x00120000, 0x00120000, 0x00120000, 0x00120000 } },
257 { 0x00120000, 0x00120000, 0x00120000, 0x00120000, 0x00120000 } },
259 { 0x00730000, 0x00730000, 0x00730000, 0x00730000, 0x00730000 } },
261 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
263 { 0x000c0000, 0x000c0000, 0x000c0000, 0x000c0000, 0x000c0000 } },
265 { 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000 } },
267 { 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000 } },
269 { 0x008b0000, 0x008b0000, 0x008b0000, 0x008b0000, 0x008b0000 } },
271 { 0x00600000, 0x00600000, 0x00600000, 0x00600000, 0x00600000 } },
273 { 0x000c0000, 0x000c0000, 0x000c0000, 0x000c0000, 0x000c0000 } },
275 { 0x00840000, 0x00840000, 0x00840000, 0x00840000, 0x00840000 } },
277 { 0x00640000, 0x00640000, 0x00640000, 0x00640000, 0x00640000 } },
279 { 0x00200000, 0x00200000, 0x00200000, 0x00200000, 0x00200000 } },
281 { 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240000 } },
283 { 0x00250000, 0x00250000, 0x00250000, 0x00250000, 0x00250000 } },
285 { 0x00110000, 0x00110000, 0x00110000, 0x00110000, 0x00110000 } },
287 { 0x00110000, 0x00110000, 0x00110000, 0x00110000, 0x00110000 } },
289 { 0x00510000, 0x00510000, 0x00510000, 0x00510000, 0x00510000 } },
291 { 0x1c040000, 0x1c040000, 0x1c040000, 0x1c040000, 0x1c040000 } },
293 { 0x000a0000, 0x000a0000, 0x000a0000, 0x000a0000, 0x000a0000 } },
295 { 0x00a10000, 0x00a10000, 0x00a10000, 0x00a10000, 0x00a10000 } },
297 { 0x00400000, 0x00400000, 0x00400000, 0x00400000, 0x00400000 } },
299 { 0x03090000, 0x03090000, 0x03090000, 0x03090000, 0x03090000 } },
301 { 0x06000000, 0x06000000, 0x06000000, 0x06000000, 0x06000000 } },
303 { 0x000000b0, 0x000000b0, 0x000000a8, 0x000000a8, 0x000000a8 } },
305 { 0x0000002e, 0x0000002e, 0x0000002e, 0x0000002e, 0x0000002e } },
307 { 0x006c4a41, 0x006c4a41, 0x006c4af1, 0x006c4a61, 0x006c4a61 } },
309 { 0x0050892a, 0x0050892a, 0x0050892b, 0x0050892b, 0x0050892b } },
311 { 0x00842400, 0x00842400, 0x00842400, 0x00842400, 0x00842400 } },
313 { 0x00c69200, 0x00c69200, 0x00c69200, 0x00c69200, 0x00c69200 } },
315 { 0x0002000c, 0x0002000c, 0x0002000c, 0x0002000c, 0x0002000c } },
317 { 0x00000094, 0x00000094, 0x00000094, 0x00000094, 0x00000094 } },
319 { 0x00000091, 0x00000091, 0x00000091, 0x00000091, 0x00000091 } },
321 { 0x0000000a, 0x0000000a, 0x00000012, 0x00000012, 0x00000012 } },
323 { 0x00000080, 0x00000080, 0x00000080, 0x00000080, 0x00000080 } },
325 { 0x000000c1, 0x000000c1, 0x000000c1, 0x000000c1, 0x000000c1 } },
327 { 0x00000060, 0x00000060, 0x00000060, 0x00000060, 0x00000060 } },
329 { 0x000000f0, 0x000000f0, 0x000000f0, 0x000000f0, 0x000000f0 } },
331 { 0x00000022, 0x00000022, 0x00000022, 0x00000022, 0x00000022 } },
333 { 0x00000092, 0x00000092, 0x00000092, 0x00000092, 0x00000092 } },
335 { 0x000000d4, 0x000000d4, 0x000000d4, 0x000000d4, 0x000000d4 } },
337 { 0x000014cc, 0x000014cc, 0x000014cc, 0x000014cc, 0x000014cc } },
339 { 0x0000048c, 0x0000048c, 0x0000048c, 0x0000048c, 0x0000048c } },
341 { 0x00000003, 0x00000003, 0x00000003, 0x00000003, 0x00000003 } },
344 /* RF5112A mode-specific init registers */
345 static const struct ath5k_ini_rf rfregs_5112a
[] = {
347 /* mode a/XR mode aTurbo mode b mode g mode gTurbo */
348 { 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020 } },
350 { 0x03060408, 0x03070408, 0x03060408, 0x03060408, 0x03070408 } },
352 { 0x00a0c0c0, 0x00a0c0c0, 0x00e0c0c0, 0x00e0c0c0, 0x00e0c0c0 } },
354 { 0x0f000000, 0x0f000000, 0x0f000000, 0x0f000000, 0x0f000000 } },
356 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
358 { 0x00800000, 0x00800000, 0x00800000, 0x00800000, 0x00800000 } },
360 { 0x002a0000, 0x002a0000, 0x002a0000, 0x002a0000, 0x002a0000 } },
362 { 0x00010000, 0x00010000, 0x00010000, 0x00010000, 0x00010000 } },
364 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
366 { 0x00180000, 0x00180000, 0x00180000, 0x00180000, 0x00180000 } },
368 { 0x00600000, 0x00600000, 0x006e0000, 0x006e0000, 0x006e0000 } },
370 { 0x00c70000, 0x00c70000, 0x00c70000, 0x00c70000, 0x00c70000 } },
372 { 0x004b0000, 0x004b0000, 0x004b0000, 0x004b0000, 0x004b0000 } },
374 { 0x04480000, 0x04480000, 0x04480000, 0x04480000, 0x04480000 } },
376 { 0x00220000, 0x00220000, 0x00220000, 0x00220000, 0x00220000 } },
378 { 0x00e40000, 0x00e40000, 0x00e40000, 0x00e40000, 0x00e40000 } },
380 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
382 { 0x00fc0000, 0x00fc0000, 0x00fc0000, 0x00fc0000, 0x00fc0000 } },
384 { 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000 } },
386 { 0x043f0000, 0x043f0000, 0x043f0000, 0x043f0000, 0x043f0000 } },
388 { 0x000c0000, 0x000c0000, 0x000c0000, 0x000c0000, 0x000c0000 } },
390 { 0x00190000, 0x00190000, 0x00190000, 0x00190000, 0x00190000 } },
392 { 0x00240000, 0x00240000, 0x00240000, 0x00240000, 0x00240000 } },
394 { 0x00b40000, 0x00b40000, 0x00b40000, 0x00b40000, 0x00b40000 } },
396 { 0x00990000, 0x00990000, 0x00990000, 0x00990000, 0x00990000 } },
398 { 0x00500000, 0x00500000, 0x00500000, 0x00500000, 0x00500000 } },
400 { 0x002a0000, 0x002a0000, 0x002a0000, 0x002a0000, 0x002a0000 } },
402 { 0x00120000, 0x00120000, 0x00120000, 0x00120000, 0x00120000 } },
404 { 0xc0320000, 0xc0320000, 0xc0320000, 0xc0320000, 0xc0320000 } },
406 { 0x01740000, 0x01740000, 0x01740000, 0x01740000, 0x01740000 } },
408 { 0x00110000, 0x00110000, 0x00110000, 0x00110000, 0x00110000 } },
410 { 0x86280000, 0x86280000, 0x86280000, 0x86280000, 0x86280000 } },
412 { 0x31840000, 0x31840000, 0x31840000, 0x31840000, 0x31840000 } },
414 { 0x00020080, 0x00020080, 0x00020080, 0x00020080, 0x00020080 } },
416 { 0x00080009, 0x00080009, 0x00080009, 0x00080009, 0x00080009 } },
418 { 0x00000003, 0x00000003, 0x00000003, 0x00000003, 0x00000003 } },
420 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
422 { 0x000000b2, 0x000000b2, 0x000000b2, 0x000000b2, 0x000000b2 } },
424 { 0x00b02084, 0x00b02084, 0x00b02084, 0x00b02084, 0x00b02084 } },
426 { 0x004125a4, 0x004125a4, 0x004125a4, 0x004125a4, 0x004125a4 } },
428 { 0x00119220, 0x00119220, 0x00119220, 0x00119220, 0x00119220 } },
430 { 0x001a4800, 0x001a4800, 0x001a4800, 0x001a4800, 0x001a4800 } },
432 { 0x000b0230, 0x000b0230, 0x000b0230, 0x000b0230, 0x000b0230 } },
434 { 0x00000094, 0x00000094, 0x00000094, 0x00000094, 0x00000094 } },
436 { 0x00000091, 0x00000091, 0x00000091, 0x00000091, 0x00000091 } },
438 { 0x00000012, 0x00000012, 0x00000012, 0x00000012, 0x00000012 } },
440 { 0x00000080, 0x00000080, 0x00000080, 0x00000080, 0x00000080 } },
442 { 0x000000d9, 0x000000d9, 0x000000d9, 0x000000d9, 0x000000d9 } },
444 { 0x00000060, 0x00000060, 0x00000060, 0x00000060, 0x00000060 } },
446 { 0x000000f0, 0x000000f0, 0x000000f0, 0x000000f0, 0x000000f0 } },
448 { 0x000000a2, 0x000000a2, 0x000000a2, 0x000000a2, 0x000000a2 } },
450 { 0x00000052, 0x00000052, 0x00000052, 0x00000052, 0x00000052 } },
452 { 0x000000d4, 0x000000d4, 0x000000d4, 0x000000d4, 0x000000d4 } },
454 { 0x000014cc, 0x000014cc, 0x000014cc, 0x000014cc, 0x000014cc } },
456 { 0x0000048c, 0x0000048c, 0x0000048c, 0x0000048c, 0x0000048c } },
458 { 0x00000003, 0x00000003, 0x00000003, 0x00000003, 0x00000003 } },
462 static const struct ath5k_ini_rf rfregs_2112a
[] = {
463 { 1, AR5K_RF_BUFFER_CONTROL_4
,
464 /* mode b mode g mode gTurbo */
465 { 0x00000020, 0x00000020, 0x00000020 } },
466 { 2, AR5K_RF_BUFFER_CONTROL_3
,
467 { 0x03060408, 0x03060408, 0x03070408 } },
468 { 3, AR5K_RF_BUFFER_CONTROL_6
,
469 { 0x00e020c0, 0x00e020c0, 0x00e020c0 } },
471 { 0x0a000000, 0x0a000000, 0x0a000000 } },
473 { 0x00000000, 0x00000000, 0x00000000 } },
475 { 0x00800000, 0x00800000, 0x00800000 } },
477 { 0x002a0000, 0x002a0000, 0x002a0000 } },
479 { 0x00010000, 0x00010000, 0x00010000 } },
481 { 0x00000000, 0x00000000, 0x00000000 } },
483 { 0x00180000, 0x00180000, 0x00180000 } },
485 { 0x006e0000, 0x006e0000, 0x006e0000 } },
487 { 0x00c70000, 0x00c70000, 0x00c70000 } },
489 { 0x004b0000, 0x004b0000, 0x004b0000 } },
491 { 0x04480000, 0x04480000, 0x04480000 } },
493 { 0x002a0000, 0x002a0000, 0x002a0000 } },
495 { 0x00e40000, 0x00e40000, 0x00e40000 } },
497 { 0x00000000, 0x00000000, 0x00000000 } },
499 { 0x00fc0000, 0x00fc0000, 0x00fc0000 } },
501 { 0x00ff0000, 0x00ff0000, 0x00ff0000 } },
503 { 0x043f0000, 0x043f0000, 0x043f0000 } },
505 { 0x0c0c0000, 0x0c0c0000, 0x0c0c0000 } },
507 { 0x02190000, 0x02190000, 0x02190000 } },
509 { 0x00240000, 0x00240000, 0x00240000 } },
511 { 0x00b40000, 0x00b40000, 0x00b40000 } },
513 { 0x00990000, 0x00990000, 0x00990000 } },
515 { 0x00500000, 0x00500000, 0x00500000 } },
517 { 0x002a0000, 0x002a0000, 0x002a0000 } },
519 { 0x00120000, 0x00120000, 0x00120000 } },
521 { 0xc0320000, 0xc0320000, 0xc0320000 } },
523 { 0x01740000, 0x01740000, 0x01740000 } },
525 { 0x00110000, 0x00110000, 0x00110000 } },
527 { 0x86280000, 0x86280000, 0x86280000 } },
529 { 0x31840000, 0x31840000, 0x31840000 } },
531 { 0x00f20080, 0x00f20080, 0x00f20080 } },
533 { 0x00070019, 0x00070019, 0x00070019 } },
535 { 0x00000000, 0x00000000, 0x00000000 } },
537 { 0x00000000, 0x00000000, 0x00000000 } },
539 { 0x000000b2, 0x000000b2, 0x000000b2 } },
541 { 0x00b02184, 0x00b02184, 0x00b02184 } },
543 { 0x004125a4, 0x004125a4, 0x004125a4 } },
545 { 0x00119220, 0x00119220, 0x00119220 } },
547 { 0x001a4800, 0x001a4800, 0x001a4800 } },
548 { 6, AR5K_RF_BUFFER_CONTROL_5
,
549 { 0x000b0230, 0x000b0230, 0x000b0230 } },
551 { 0x00000094, 0x00000094, 0x00000094 } },
553 { 0x00000091, 0x00000091, 0x00000091 } },
555 { 0x00000012, 0x00000012, 0x00000012 } },
557 { 0x00000080, 0x00000080, 0x00000080 } },
559 { 0x000000d9, 0x000000d9, 0x000000d9 } },
561 { 0x00000060, 0x00000060, 0x00000060 } },
563 { 0x000000f0, 0x000000f0, 0x000000f0 } },
565 { 0x000000a2, 0x000000a2, 0x000000a2 } },
567 { 0x00000052, 0x00000052, 0x00000052 } },
569 { 0x000000d4, 0x000000d4, 0x000000d4 } },
571 { 0x000014cc, 0x000014cc, 0x000014cc } },
573 { 0x0000048c, 0x0000048c, 0x0000048c } },
574 { 7, AR5K_RF_BUFFER_CONTROL_1
,
575 { 0x00000003, 0x00000003, 0x00000003 } },
578 /* RF5413/5414 mode-specific init registers */
579 static const struct ath5k_ini_rf rfregs_5413
[] = {
581 /* mode a/XR mode aTurbo mode b mode g mode gTurbo */
582 { 0x00000020, 0x00000020, 0x00000020, 0x00000020, 0x00000020 } },
584 { 0x00000008, 0x00000008, 0x00000008, 0x00000008, 0x00000008 } },
586 { 0x00a000c0, 0x00a000c0, 0x00e000c0, 0x00e000c0, 0x00e000c0 } },
588 { 0x33000000, 0x33000000, 0x33000000, 0x33000000, 0x33000000 } },
590 { 0x01000000, 0x01000000, 0x01000000, 0x01000000, 0x01000000 } },
592 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
594 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
596 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
598 { 0x1f000000, 0x1f000000, 0x1f000000, 0x1f000000, 0x1f000000 } },
600 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
602 { 0x00b80000, 0x00b80000, 0x00b80000, 0x00b80000, 0x00b80000 } },
604 { 0x00b70000, 0x00b70000, 0x00b70000, 0x00b70000, 0x00b70000 } },
606 { 0x00840000, 0x00840000, 0x00840000, 0x00840000, 0x00840000 } },
608 { 0x00980000, 0x00980000, 0x00980000, 0x00980000, 0x00980000 } },
610 { 0x00c00000, 0x00c00000, 0x00c00000, 0x00c00000, 0x00c00000 } },
612 { 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000 } },
614 { 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000 } },
616 { 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000 } },
618 { 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000, 0x00ff0000 } },
620 { 0x00d70000, 0x00d70000, 0x00d70000, 0x00d70000, 0x00d70000 } },
622 { 0x00610000, 0x00610000, 0x00610000, 0x00610000, 0x00610000 } },
624 { 0x00fe0000, 0x00fe0000, 0x00fe0000, 0x00fe0000, 0x00fe0000 } },
626 { 0x00de0000, 0x00de0000, 0x00de0000, 0x00de0000, 0x00de0000 } },
628 { 0x007f0000, 0x007f0000, 0x007f0000, 0x007f0000, 0x007f0000 } },
630 { 0x043d0000, 0x043d0000, 0x043d0000, 0x043d0000, 0x043d0000 } },
632 { 0x00770000, 0x00770000, 0x00770000, 0x00770000, 0x00770000 } },
634 { 0x00440000, 0x00440000, 0x00440000, 0x00440000, 0x00440000 } },
636 { 0x00980000, 0x00980000, 0x00980000, 0x00980000, 0x00980000 } },
638 { 0x00100080, 0x00100080, 0x00100080, 0x00100080, 0x00100080 } },
640 { 0x0005c034, 0x0005c034, 0x0005c034, 0x0005c034, 0x0005c034 } },
642 { 0x003100f0, 0x003100f0, 0x003100f0, 0x003100f0, 0x003100f0 } },
644 { 0x000c011f, 0x000c011f, 0x000c011f, 0x000c011f, 0x000c011f } },
646 { 0x00510040, 0x00510040, 0x005100a0, 0x005100a0, 0x005100a0 } },
648 { 0x0050006a, 0x0050006a, 0x005000dd, 0x005000dd, 0x005000dd } },
650 { 0x00000001, 0x00000001, 0x00000000, 0x00000000, 0x00000000 } },
652 { 0x00004044, 0x00004044, 0x00004044, 0x00004044, 0x00004044 } },
654 { 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 } },
656 { 0x000060c0, 0x000060c0, 0x000060c0, 0x000060c0, 0x000060c0 } },
658 { 0x00002c00, 0x00002c00, 0x00003600, 0x00003600, 0x00003600 } },
660 { 0x00000403, 0x00000403, 0x00040403, 0x00040403, 0x00040403 } },
662 { 0x00006400, 0x00006400, 0x00006400, 0x00006400, 0x00006400 } },
664 { 0x00000800, 0x00000800, 0x00000800, 0x00000800, 0x00000800 } },
666 { 0x0000000e, 0x0000000e, 0x0000000e, 0x0000000e, 0x0000000e } },
669 /* RF2413/2414 mode-specific init registers */
670 static const struct ath5k_ini_rf rfregs_2413
[] = {
671 { 1, AR5K_RF_BUFFER_CONTROL_4
,
672 { 0x00000020, 0x00000020, 0x00000020 } },
673 { 2, AR5K_RF_BUFFER_CONTROL_3
,
674 { 0x02001408, 0x02001408, 0x02001408 } },
675 { 3, AR5K_RF_BUFFER_CONTROL_6
,
676 { 0x00e020c0, 0x00e020c0, 0x00e020c0 } },
678 { 0xf0000000, 0xf0000000, 0xf0000000 } },
680 { 0x00000000, 0x00000000, 0x00000000 } },
682 { 0x03000000, 0x03000000, 0x03000000 } },
684 { 0x00000000, 0x00000000, 0x00000000 } },
686 { 0x00000000, 0x00000000, 0x00000000 } },
688 { 0x00000000, 0x00000000, 0x00000000 } },
690 { 0x00000000, 0x00000000, 0x00000000 } },
692 { 0x00000000, 0x00000000, 0x00000000 } },
694 { 0x40400000, 0x40400000, 0x40400000 } },
696 { 0x65050000, 0x65050000, 0x65050000 } },
698 { 0x00000000, 0x00000000, 0x00000000 } },
700 { 0x00000000, 0x00000000, 0x00000000 } },
702 { 0x00420000, 0x00420000, 0x00420000 } },
704 { 0x00b50000, 0x00b50000, 0x00b50000 } },
706 { 0x00030000, 0x00030000, 0x00030000 } },
708 { 0x00f70000, 0x00f70000, 0x00f70000 } },
710 { 0x009d0000, 0x009d0000, 0x009d0000 } },
712 { 0x00220000, 0x00220000, 0x00220000 } },
714 { 0x04220000, 0x04220000, 0x04220000 } },
716 { 0x00230018, 0x00230018, 0x00230018 } },
718 { 0x00280050, 0x00280050, 0x00280050 } },
720 { 0x005000c3, 0x005000c3, 0x005000c3 } },
722 { 0x0004007f, 0x0004007f, 0x0004007f } },
724 { 0x00000458, 0x00000458, 0x00000458 } },
726 { 0x00000000, 0x00000000, 0x00000000 } },
728 { 0x0000c000, 0x0000c000, 0x0000c000 } },
729 { 6, AR5K_RF_BUFFER_CONTROL_5
,
730 { 0x00400230, 0x00400230, 0x00400230 } },
732 { 0x00006400, 0x00006400, 0x00006400 } },
734 { 0x00000800, 0x00000800, 0x00000800 } },
735 { 7, AR5K_RF_BUFFER_CONTROL_2
,
736 { 0x0000000e, 0x0000000e, 0x0000000e } },
739 /* Initial RF Gain settings for RF5112 */
740 static const struct ath5k_ini_rfgain rfgain_5112
[] = {
742 { AR5K_RF_GAIN(0), { 0x00000007, 0x00000007 } },
743 { AR5K_RF_GAIN(1), { 0x00000047, 0x00000047 } },
744 { AR5K_RF_GAIN(2), { 0x00000087, 0x00000087 } },
745 { AR5K_RF_GAIN(3), { 0x000001a0, 0x000001a0 } },
746 { AR5K_RF_GAIN(4), { 0x000001e0, 0x000001e0 } },
747 { AR5K_RF_GAIN(5), { 0x00000020, 0x00000020 } },
748 { AR5K_RF_GAIN(6), { 0x00000060, 0x00000060 } },
749 { AR5K_RF_GAIN(7), { 0x000001a1, 0x000001a1 } },
750 { AR5K_RF_GAIN(8), { 0x000001e1, 0x000001e1 } },
751 { AR5K_RF_GAIN(9), { 0x00000021, 0x00000021 } },
752 { AR5K_RF_GAIN(10), { 0x00000061, 0x00000061 } },
753 { AR5K_RF_GAIN(11), { 0x00000162, 0x00000162 } },
754 { AR5K_RF_GAIN(12), { 0x000001a2, 0x000001a2 } },
755 { AR5K_RF_GAIN(13), { 0x000001e2, 0x000001e2 } },
756 { AR5K_RF_GAIN(14), { 0x00000022, 0x00000022 } },
757 { AR5K_RF_GAIN(15), { 0x00000062, 0x00000062 } },
758 { AR5K_RF_GAIN(16), { 0x00000163, 0x00000163 } },
759 { AR5K_RF_GAIN(17), { 0x000001a3, 0x000001a3 } },
760 { AR5K_RF_GAIN(18), { 0x000001e3, 0x000001e3 } },
761 { AR5K_RF_GAIN(19), { 0x00000023, 0x00000023 } },
762 { AR5K_RF_GAIN(20), { 0x00000063, 0x00000063 } },
763 { AR5K_RF_GAIN(21), { 0x00000184, 0x00000184 } },
764 { AR5K_RF_GAIN(22), { 0x000001c4, 0x000001c4 } },
765 { AR5K_RF_GAIN(23), { 0x00000004, 0x00000004 } },
766 { AR5K_RF_GAIN(24), { 0x000001ea, 0x0000000b } },
767 { AR5K_RF_GAIN(25), { 0x0000002a, 0x0000004b } },
768 { AR5K_RF_GAIN(26), { 0x0000006a, 0x0000008b } },
769 { AR5K_RF_GAIN(27), { 0x000000aa, 0x000001ac } },
770 { AR5K_RF_GAIN(28), { 0x000001ab, 0x000001ec } },
771 { AR5K_RF_GAIN(29), { 0x000001eb, 0x0000002c } },
772 { AR5K_RF_GAIN(30), { 0x0000002b, 0x00000012 } },
773 { AR5K_RF_GAIN(31), { 0x0000006b, 0x00000052 } },
774 { AR5K_RF_GAIN(32), { 0x000000ab, 0x00000092 } },
775 { AR5K_RF_GAIN(33), { 0x000001ac, 0x00000193 } },
776 { AR5K_RF_GAIN(34), { 0x000001ec, 0x000001d3 } },
777 { AR5K_RF_GAIN(35), { 0x0000002c, 0x00000013 } },
778 { AR5K_RF_GAIN(36), { 0x0000003a, 0x00000053 } },
779 { AR5K_RF_GAIN(37), { 0x0000007a, 0x00000093 } },
780 { AR5K_RF_GAIN(38), { 0x000000ba, 0x00000194 } },
781 { AR5K_RF_GAIN(39), { 0x000001bb, 0x000001d4 } },
782 { AR5K_RF_GAIN(40), { 0x000001fb, 0x00000014 } },
783 { AR5K_RF_GAIN(41), { 0x0000003b, 0x0000003a } },
784 { AR5K_RF_GAIN(42), { 0x0000007b, 0x0000007a } },
785 { AR5K_RF_GAIN(43), { 0x000000bb, 0x000000ba } },
786 { AR5K_RF_GAIN(44), { 0x000001bc, 0x000001bb } },
787 { AR5K_RF_GAIN(45), { 0x000001fc, 0x000001fb } },
788 { AR5K_RF_GAIN(46), { 0x0000003c, 0x0000003b } },
789 { AR5K_RF_GAIN(47), { 0x0000007c, 0x0000007b } },
790 { AR5K_RF_GAIN(48), { 0x000000bc, 0x000000bb } },
791 { AR5K_RF_GAIN(49), { 0x000000fc, 0x000001bc } },
792 { AR5K_RF_GAIN(50), { 0x000000fc, 0x000001fc } },
793 { AR5K_RF_GAIN(51), { 0x000000fc, 0x0000003c } },
794 { AR5K_RF_GAIN(52), { 0x000000fc, 0x0000007c } },
795 { AR5K_RF_GAIN(53), { 0x000000fc, 0x000000bc } },
796 { AR5K_RF_GAIN(54), { 0x000000fc, 0x000000fc } },
797 { AR5K_RF_GAIN(55), { 0x000000fc, 0x000000fc } },
798 { AR5K_RF_GAIN(56), { 0x000000fc, 0x000000fc } },
799 { AR5K_RF_GAIN(57), { 0x000000fc, 0x000000fc } },
800 { AR5K_RF_GAIN(58), { 0x000000fc, 0x000000fc } },
801 { AR5K_RF_GAIN(59), { 0x000000fc, 0x000000fc } },
802 { AR5K_RF_GAIN(60), { 0x000000fc, 0x000000fc } },
803 { AR5K_RF_GAIN(61), { 0x000000fc, 0x000000fc } },
804 { AR5K_RF_GAIN(62), { 0x000000fc, 0x000000fc } },
805 { AR5K_RF_GAIN(63), { 0x000000fc, 0x000000fc } },
808 /* Initial RF Gain settings for RF5413 */
809 static const struct ath5k_ini_rfgain rfgain_5413
[] = {
811 { AR5K_RF_GAIN(0), { 0x00000000, 0x00000000 } },
812 { AR5K_RF_GAIN(1), { 0x00000040, 0x00000040 } },
813 { AR5K_RF_GAIN(2), { 0x00000080, 0x00000080 } },
814 { AR5K_RF_GAIN(3), { 0x000001a1, 0x00000161 } },
815 { AR5K_RF_GAIN(4), { 0x000001e1, 0x000001a1 } },
816 { AR5K_RF_GAIN(5), { 0x00000021, 0x000001e1 } },
817 { AR5K_RF_GAIN(6), { 0x00000061, 0x00000021 } },
818 { AR5K_RF_GAIN(7), { 0x00000188, 0x00000061 } },
819 { AR5K_RF_GAIN(8), { 0x000001c8, 0x00000188 } },
820 { AR5K_RF_GAIN(9), { 0x00000008, 0x000001c8 } },
821 { AR5K_RF_GAIN(10), { 0x00000048, 0x00000008 } },
822 { AR5K_RF_GAIN(11), { 0x00000088, 0x00000048 } },
823 { AR5K_RF_GAIN(12), { 0x000001a9, 0x00000088 } },
824 { AR5K_RF_GAIN(13), { 0x000001e9, 0x00000169 } },
825 { AR5K_RF_GAIN(14), { 0x00000029, 0x000001a9 } },
826 { AR5K_RF_GAIN(15), { 0x00000069, 0x000001e9 } },
827 { AR5K_RF_GAIN(16), { 0x000001d0, 0x00000029 } },
828 { AR5K_RF_GAIN(17), { 0x00000010, 0x00000069 } },
829 { AR5K_RF_GAIN(18), { 0x00000050, 0x00000190 } },
830 { AR5K_RF_GAIN(19), { 0x00000090, 0x000001d0 } },
831 { AR5K_RF_GAIN(20), { 0x000001b1, 0x00000010 } },
832 { AR5K_RF_GAIN(21), { 0x000001f1, 0x00000050 } },
833 { AR5K_RF_GAIN(22), { 0x00000031, 0x00000090 } },
834 { AR5K_RF_GAIN(23), { 0x00000071, 0x00000171 } },
835 { AR5K_RF_GAIN(24), { 0x000001b8, 0x000001b1 } },
836 { AR5K_RF_GAIN(25), { 0x000001f8, 0x000001f1 } },
837 { AR5K_RF_GAIN(26), { 0x00000038, 0x00000031 } },
838 { AR5K_RF_GAIN(27), { 0x00000078, 0x00000071 } },
839 { AR5K_RF_GAIN(28), { 0x00000199, 0x00000198 } },
840 { AR5K_RF_GAIN(29), { 0x000001d9, 0x000001d8 } },
841 { AR5K_RF_GAIN(30), { 0x00000019, 0x00000018 } },
842 { AR5K_RF_GAIN(31), { 0x00000059, 0x00000058 } },
843 { AR5K_RF_GAIN(32), { 0x00000099, 0x00000098 } },
844 { AR5K_RF_GAIN(33), { 0x000000d9, 0x00000179 } },
845 { AR5K_RF_GAIN(34), { 0x000000f9, 0x000001b9 } },
846 { AR5K_RF_GAIN(35), { 0x000000f9, 0x000001f9 } },
847 { AR5K_RF_GAIN(36), { 0x000000f9, 0x00000039 } },
848 { AR5K_RF_GAIN(37), { 0x000000f9, 0x00000079 } },
849 { AR5K_RF_GAIN(38), { 0x000000f9, 0x000000b9 } },
850 { AR5K_RF_GAIN(39), { 0x000000f9, 0x000000f9 } },
851 { AR5K_RF_GAIN(40), { 0x000000f9, 0x000000f9 } },
852 { AR5K_RF_GAIN(41), { 0x000000f9, 0x000000f9 } },
853 { AR5K_RF_GAIN(42), { 0x000000f9, 0x000000f9 } },
854 { AR5K_RF_GAIN(43), { 0x000000f9, 0x000000f9 } },
855 { AR5K_RF_GAIN(44), { 0x000000f9, 0x000000f9 } },
856 { AR5K_RF_GAIN(45), { 0x000000f9, 0x000000f9 } },
857 { AR5K_RF_GAIN(46), { 0x000000f9, 0x000000f9 } },
858 { AR5K_RF_GAIN(47), { 0x000000f9, 0x000000f9 } },
859 { AR5K_RF_GAIN(48), { 0x000000f9, 0x000000f9 } },
860 { AR5K_RF_GAIN(49), { 0x000000f9, 0x000000f9 } },
861 { AR5K_RF_GAIN(50), { 0x000000f9, 0x000000f9 } },
862 { AR5K_RF_GAIN(51), { 0x000000f9, 0x000000f9 } },
863 { AR5K_RF_GAIN(52), { 0x000000f9, 0x000000f9 } },
864 { AR5K_RF_GAIN(53), { 0x000000f9, 0x000000f9 } },
865 { AR5K_RF_GAIN(54), { 0x000000f9, 0x000000f9 } },
866 { AR5K_RF_GAIN(55), { 0x000000f9, 0x000000f9 } },
867 { AR5K_RF_GAIN(56), { 0x000000f9, 0x000000f9 } },
868 { AR5K_RF_GAIN(57), { 0x000000f9, 0x000000f9 } },
869 { AR5K_RF_GAIN(58), { 0x000000f9, 0x000000f9 } },
870 { AR5K_RF_GAIN(59), { 0x000000f9, 0x000000f9 } },
871 { AR5K_RF_GAIN(60), { 0x000000f9, 0x000000f9 } },
872 { AR5K_RF_GAIN(61), { 0x000000f9, 0x000000f9 } },
873 { AR5K_RF_GAIN(62), { 0x000000f9, 0x000000f9 } },
874 { AR5K_RF_GAIN(63), { 0x000000f9, 0x000000f9 } },
877 /* Initial RF Gain settings for RF2413 */
878 static const struct ath5k_ini_rfgain rfgain_2413
[] = {
879 { AR5K_RF_GAIN(0), { 0x00000000 } },
880 { AR5K_RF_GAIN(1), { 0x00000040 } },
881 { AR5K_RF_GAIN(2), { 0x00000080 } },
882 { AR5K_RF_GAIN(3), { 0x00000181 } },
883 { AR5K_RF_GAIN(4), { 0x000001c1 } },
884 { AR5K_RF_GAIN(5), { 0x00000001 } },
885 { AR5K_RF_GAIN(6), { 0x00000041 } },
886 { AR5K_RF_GAIN(7), { 0x00000081 } },
887 { AR5K_RF_GAIN(8), { 0x00000168 } },
888 { AR5K_RF_GAIN(9), { 0x000001a8 } },
889 { AR5K_RF_GAIN(10), { 0x000001e8 } },
890 { AR5K_RF_GAIN(11), { 0x00000028 } },
891 { AR5K_RF_GAIN(12), { 0x00000068 } },
892 { AR5K_RF_GAIN(13), { 0x00000189 } },
893 { AR5K_RF_GAIN(14), { 0x000001c9 } },
894 { AR5K_RF_GAIN(15), { 0x00000009 } },
895 { AR5K_RF_GAIN(16), { 0x00000049 } },
896 { AR5K_RF_GAIN(17), { 0x00000089 } },
897 { AR5K_RF_GAIN(18), { 0x00000190 } },
898 { AR5K_RF_GAIN(19), { 0x000001d0 } },
899 { AR5K_RF_GAIN(20), { 0x00000010 } },
900 { AR5K_RF_GAIN(21), { 0x00000050 } },
901 { AR5K_RF_GAIN(22), { 0x00000090 } },
902 { AR5K_RF_GAIN(23), { 0x00000191 } },
903 { AR5K_RF_GAIN(24), { 0x000001d1 } },
904 { AR5K_RF_GAIN(25), { 0x00000011 } },
905 { AR5K_RF_GAIN(26), { 0x00000051 } },
906 { AR5K_RF_GAIN(27), { 0x00000091 } },
907 { AR5K_RF_GAIN(28), { 0x00000178 } },
908 { AR5K_RF_GAIN(29), { 0x000001b8 } },
909 { AR5K_RF_GAIN(30), { 0x000001f8 } },
910 { AR5K_RF_GAIN(31), { 0x00000038 } },
911 { AR5K_RF_GAIN(32), { 0x00000078 } },
912 { AR5K_RF_GAIN(33), { 0x00000199 } },
913 { AR5K_RF_GAIN(34), { 0x000001d9 } },
914 { AR5K_RF_GAIN(35), { 0x00000019 } },
915 { AR5K_RF_GAIN(36), { 0x00000059 } },
916 { AR5K_RF_GAIN(37), { 0x00000099 } },
917 { AR5K_RF_GAIN(38), { 0x000000d9 } },
918 { AR5K_RF_GAIN(39), { 0x000000f9 } },
919 { AR5K_RF_GAIN(40), { 0x000000f9 } },
920 { AR5K_RF_GAIN(41), { 0x000000f9 } },
921 { AR5K_RF_GAIN(42), { 0x000000f9 } },
922 { AR5K_RF_GAIN(43), { 0x000000f9 } },
923 { AR5K_RF_GAIN(44), { 0x000000f9 } },
924 { AR5K_RF_GAIN(45), { 0x000000f9 } },
925 { AR5K_RF_GAIN(46), { 0x000000f9 } },
926 { AR5K_RF_GAIN(47), { 0x000000f9 } },
927 { AR5K_RF_GAIN(48), { 0x000000f9 } },
928 { AR5K_RF_GAIN(49), { 0x000000f9 } },
929 { AR5K_RF_GAIN(50), { 0x000000f9 } },
930 { AR5K_RF_GAIN(51), { 0x000000f9 } },
931 { AR5K_RF_GAIN(52), { 0x000000f9 } },
932 { AR5K_RF_GAIN(53), { 0x000000f9 } },
933 { AR5K_RF_GAIN(54), { 0x000000f9 } },
934 { AR5K_RF_GAIN(55), { 0x000000f9 } },
935 { AR5K_RF_GAIN(56), { 0x000000f9 } },
936 { AR5K_RF_GAIN(57), { 0x000000f9 } },
937 { AR5K_RF_GAIN(58), { 0x000000f9 } },
938 { AR5K_RF_GAIN(59), { 0x000000f9 } },
939 { AR5K_RF_GAIN(60), { 0x000000f9 } },
940 { AR5K_RF_GAIN(61), { 0x000000f9 } },
941 { AR5K_RF_GAIN(62), { 0x000000f9 } },
942 { AR5K_RF_GAIN(63), { 0x000000f9 } },
945 static const struct ath5k_gain_opt rfgain_opt_5112
= {
949 { { 3, 0, 0, 0, 0, 0, 0 }, 6 },
950 { { 2, 0, 0, 0, 0, 0, 0 }, 0 },
951 { { 1, 0, 0, 0, 0, 0, 0 }, -3 },
952 { { 0, 0, 0, 0, 0, 0, 0 }, -6 },
953 { { 0, 1, 1, 0, 0, 0, 0 }, -8 },
954 { { 0, 1, 1, 0, 1, 1, 0 }, -10 },
955 { { 0, 1, 0, 1, 1, 1, 0 }, -13 },
956 { { 0, 1, 0, 1, 1, 0, 1 }, -16 },
961 * Used to modify RF Banks before writing them to AR5K_RF_BUFFER
963 static unsigned int ath5k_hw_rfregs_op(u32
*rf
, u32 offset
, u32 reg
, u32 bits
,
964 u32 first
, u32 col
, bool set
)
966 u32 mask
, entry
, last
, data
, shift
, position
;
973 /* should not happen */
976 if (!(col
<= 3 && bits
<= 32 && first
+ bits
<= 319)) {
977 ATH5K_PRINTF("invalid values at offset %u\n", offset
);
981 entry
= ((first
- 1) / 8) + offset
;
982 position
= (first
- 1) % 8;
985 data
= ath5k_hw_bitswap(reg
, bits
);
987 for (i
= shift
= 0, left
= bits
; left
> 0; position
= 0, entry
++, i
++) {
988 last
= (position
+ left
> 8) ? 8 : position
+ left
;
989 mask
= (((1 << last
) - 1) ^ ((1 << position
) - 1)) << (col
* 8);
993 rf
[entry
] |= ((data
<< position
) << (col
* 8)) & mask
;
994 data
>>= (8 - position
);
996 data
= (((rf
[entry
] & mask
) >> (col
* 8)) >> position
)
998 shift
+= last
- position
;
1001 left
-= 8 - position
;
1004 data
= set
? 1 : ath5k_hw_bitswap(data
, bits
);
1009 static u32
ath5k_hw_rfregs_gainf_corr(struct ath5k_hw
*ah
)
1014 if (ah
->ah_rf_banks
== NULL
)
1017 rf
= ah
->ah_rf_banks
;
1018 ah
->ah_gain
.g_f_corr
= 0;
1020 if (ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[7], 0, 1, 36, 0, false) != 1)
1023 step
= ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[7], 0, 4, 32, 0, false);
1024 mix
= ah
->ah_gain
.g_step
->gos_param
[0];
1028 ah
->ah_gain
.g_f_corr
= step
* 2;
1031 ah
->ah_gain
.g_f_corr
= (step
- 5) * 2;
1034 ah
->ah_gain
.g_f_corr
= step
;
1037 ah
->ah_gain
.g_f_corr
= 0;
1041 return ah
->ah_gain
.g_f_corr
;
1044 static bool ath5k_hw_rfregs_gain_readback(struct ath5k_hw
*ah
)
1046 u32 step
, mix
, level
[4];
1049 if (ah
->ah_rf_banks
== NULL
)
1052 rf
= ah
->ah_rf_banks
;
1054 if (ah
->ah_radio
== AR5K_RF5111
) {
1055 step
= ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[7], 0, 6, 37, 0,
1058 level
[1] = (step
== 0x3f) ? 0x32 : step
+ 4;
1059 level
[2] = (step
!= 0x3f) ? 0x40 : level
[0];
1060 level
[3] = level
[2] + 0x32;
1062 ah
->ah_gain
.g_high
= level
[3] -
1063 (step
== 0x3f ? AR5K_GAIN_DYN_ADJUST_HI_MARGIN
: -5);
1064 ah
->ah_gain
.g_low
= level
[0] +
1065 (step
== 0x3f ? AR5K_GAIN_DYN_ADJUST_LO_MARGIN
: 0);
1067 mix
= ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[7], 0, 1, 36, 0,
1069 level
[0] = level
[2] = 0;
1072 level
[1] = level
[3] = 83;
1074 level
[1] = level
[3] = 107;
1075 ah
->ah_gain
.g_high
= 55;
1079 return (ah
->ah_gain
.g_current
>= level
[0] &&
1080 ah
->ah_gain
.g_current
<= level
[1]) ||
1081 (ah
->ah_gain
.g_current
>= level
[2] &&
1082 ah
->ah_gain
.g_current
<= level
[3]);
1085 static s32
ath5k_hw_rfregs_gain_adjust(struct ath5k_hw
*ah
)
1087 const struct ath5k_gain_opt
*go
;
1090 switch (ah
->ah_radio
) {
1092 go
= &rfgain_opt_5111
;
1095 go
= &rfgain_opt_5112
;
1101 ah
->ah_gain
.g_step
= &go
->go_step
[ah
->ah_gain
.g_step_idx
];
1103 if (ah
->ah_gain
.g_current
>= ah
->ah_gain
.g_high
) {
1104 if (ah
->ah_gain
.g_step_idx
== 0)
1106 for (ah
->ah_gain
.g_target
= ah
->ah_gain
.g_current
;
1107 ah
->ah_gain
.g_target
>= ah
->ah_gain
.g_high
&&
1108 ah
->ah_gain
.g_step_idx
> 0;
1109 ah
->ah_gain
.g_step
=
1110 &go
->go_step
[ah
->ah_gain
.g_step_idx
])
1111 ah
->ah_gain
.g_target
-= 2 *
1112 (go
->go_step
[--(ah
->ah_gain
.g_step_idx
)].gos_gain
-
1113 ah
->ah_gain
.g_step
->gos_gain
);
1119 if (ah
->ah_gain
.g_current
<= ah
->ah_gain
.g_low
) {
1120 if (ah
->ah_gain
.g_step_idx
== (go
->go_steps_count
- 1))
1122 for (ah
->ah_gain
.g_target
= ah
->ah_gain
.g_current
;
1123 ah
->ah_gain
.g_target
<= ah
->ah_gain
.g_low
&&
1124 ah
->ah_gain
.g_step_idx
< go
->go_steps_count
-1;
1125 ah
->ah_gain
.g_step
=
1126 &go
->go_step
[ah
->ah_gain
.g_step_idx
])
1127 ah
->ah_gain
.g_target
-= 2 *
1128 (go
->go_step
[++ah
->ah_gain
.g_step_idx
].gos_gain
-
1129 ah
->ah_gain
.g_step
->gos_gain
);
1136 ATH5K_DBG(ah
->ah_sc
, ATH5K_DEBUG_CALIBRATE
,
1137 "ret %d, gain step %u, current gain %u, target gain %u\n",
1138 ret
, ah
->ah_gain
.g_step_idx
, ah
->ah_gain
.g_current
,
1139 ah
->ah_gain
.g_target
);
1145 * Read EEPROM Calibration data, modify RF Banks and Initialize RF5111
1147 static int ath5k_hw_rf5111_rfregs(struct ath5k_hw
*ah
,
1148 struct ieee80211_channel
*channel
, unsigned int mode
)
1150 struct ath5k_eeprom_info
*ee
= &ah
->ah_capabilities
.cap_eeprom
;
1152 const unsigned int rf_size
= ARRAY_SIZE(rfregs_5111
);
1154 int obdb
= -1, bank
= -1;
1157 AR5K_ASSERT_ENTRY(mode
, AR5K_MODE_MAX
);
1159 rf
= ah
->ah_rf_banks
;
1161 /* Copy values to modify them */
1162 for (i
= 0; i
< rf_size
; i
++) {
1163 if (rfregs_5111
[i
].rf_bank
>= AR5K_RF5111_INI_RF_MAX_BANKS
) {
1164 ATH5K_ERR(ah
->ah_sc
, "invalid bank\n");
1168 if (bank
!= rfregs_5111
[i
].rf_bank
) {
1169 bank
= rfregs_5111
[i
].rf_bank
;
1170 ah
->ah_offset
[bank
] = i
;
1173 rf
[i
] = rfregs_5111
[i
].rf_value
[mode
];
1177 if (channel
->hw_value
& CHANNEL_2GHZ
) {
1178 if (channel
->hw_value
& CHANNEL_CCK
)
1179 ee_mode
= AR5K_EEPROM_MODE_11B
;
1181 ee_mode
= AR5K_EEPROM_MODE_11G
;
1184 if (!ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[0],
1185 ee
->ee_ob
[ee_mode
][obdb
], 3, 119, 0, true))
1188 if (!ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[0],
1189 ee
->ee_ob
[ee_mode
][obdb
], 3, 122, 0, true))
1195 /* For 11a, Turbo and XR */
1196 ee_mode
= AR5K_EEPROM_MODE_11A
;
1197 obdb
= channel
->center_freq
>= 5725 ? 3 :
1198 (channel
->center_freq
>= 5500 ? 2 :
1199 (channel
->center_freq
>= 5260 ? 1 :
1200 (channel
->center_freq
> 4000 ? 0 : -1)));
1202 if (!ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[6],
1203 ee
->ee_pwd_84
, 1, 51, 3, true))
1206 if (!ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[6],
1207 ee
->ee_pwd_90
, 1, 45, 3, true))
1211 if (!ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[6],
1212 !ee
->ee_xpd
[ee_mode
], 1, 95, 0, true))
1215 if (!ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[6],
1216 ee
->ee_x_gain
[ee_mode
], 4, 96, 0, true))
1219 if (!ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[6], obdb
>= 0 ?
1220 ee
->ee_ob
[ee_mode
][obdb
] : 0, 3, 104, 0, true))
1223 if (!ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[6], obdb
>= 0 ?
1224 ee
->ee_db
[ee_mode
][obdb
] : 0, 3, 107, 0, true))
1228 if (!ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[7],
1229 ee
->ee_i_gain
[ee_mode
], 6, 29, 0, true))
1232 if (!ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[7],
1233 ee
->ee_xpd
[ee_mode
], 1, 4, 0, true))
1236 /* Write RF values */
1237 for (i
= 0; i
< rf_size
; i
++) {
1239 ath5k_hw_reg_write(ah
, rf
[i
], rfregs_5111
[i
].rf_register
);
1246 * Read EEPROM Calibration data, modify RF Banks and Initialize RF5112
1248 static int ath5k_hw_rf5112_rfregs(struct ath5k_hw
*ah
,
1249 struct ieee80211_channel
*channel
, unsigned int mode
)
1251 const struct ath5k_ini_rf
*rf_ini
;
1252 struct ath5k_eeprom_info
*ee
= &ah
->ah_capabilities
.cap_eeprom
;
1254 unsigned int rf_size
, i
;
1255 int obdb
= -1, bank
= -1;
1258 AR5K_ASSERT_ENTRY(mode
, AR5K_MODE_MAX
);
1260 rf
= ah
->ah_rf_banks
;
1262 if (ah
->ah_radio_5ghz_revision
>= AR5K_SREV_RAD_2112A
1263 && !test_bit(AR5K_MODE_11A
, ah
->ah_capabilities
.cap_mode
)) {
1264 rf_ini
= rfregs_2112a
;
1265 rf_size
= ARRAY_SIZE(rfregs_5112a
);
1267 ATH5K_ERR(ah
->ah_sc
,"invalid channel mode: %i\n",mode
);
1270 mode
= mode
- 2; /*no a/turboa modes for 2112*/
1271 } else if (ah
->ah_radio_5ghz_revision
>= AR5K_SREV_RAD_5112A
) {
1272 rf_ini
= rfregs_5112a
;
1273 rf_size
= ARRAY_SIZE(rfregs_5112a
);
1275 rf_ini
= rfregs_5112
;
1276 rf_size
= ARRAY_SIZE(rfregs_5112
);
1279 /* Copy values to modify them */
1280 for (i
= 0; i
< rf_size
; i
++) {
1281 if (rf_ini
[i
].rf_bank
>= AR5K_RF5112_INI_RF_MAX_BANKS
) {
1282 ATH5K_ERR(ah
->ah_sc
, "invalid bank\n");
1286 if (bank
!= rf_ini
[i
].rf_bank
) {
1287 bank
= rf_ini
[i
].rf_bank
;
1288 ah
->ah_offset
[bank
] = i
;
1291 rf
[i
] = rf_ini
[i
].rf_value
[mode
];
1295 if (channel
->hw_value
& CHANNEL_2GHZ
) {
1296 if (channel
->hw_value
& CHANNEL_OFDM
)
1297 ee_mode
= AR5K_EEPROM_MODE_11G
;
1299 ee_mode
= AR5K_EEPROM_MODE_11B
;
1302 if (!ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[6],
1303 ee
->ee_ob
[ee_mode
][obdb
], 3, 287, 0, true))
1306 if (!ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[6],
1307 ee
->ee_ob
[ee_mode
][obdb
], 3, 290, 0, true))
1310 /* For 11a, Turbo and XR */
1311 ee_mode
= AR5K_EEPROM_MODE_11A
;
1312 obdb
= channel
->center_freq
>= 5725 ? 3 :
1313 (channel
->center_freq
>= 5500 ? 2 :
1314 (channel
->center_freq
>= 5260 ? 1 :
1315 (channel
->center_freq
> 4000 ? 0 : -1)));
1320 if (!ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[6],
1321 ee
->ee_ob
[ee_mode
][obdb
], 3, 279, 0, true))
1324 if (!ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[6],
1325 ee
->ee_ob
[ee_mode
][obdb
], 3, 282, 0, true))
1329 ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[6],
1330 ee
->ee_x_gain
[ee_mode
], 2, 270, 0, true);
1331 ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[6],
1332 ee
->ee_x_gain
[ee_mode
], 2, 257, 0, true);
1334 if (!ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[6],
1335 ee
->ee_xpd
[ee_mode
], 1, 302, 0, true))
1339 if (!ath5k_hw_rfregs_op(rf
, ah
->ah_offset
[7],
1340 ee
->ee_i_gain
[ee_mode
], 6, 14, 0, true))
1343 /* Write RF values */
1344 for (i
= 0; i
< rf_size
; i
++)
1345 ath5k_hw_reg_write(ah
, rf
[i
], rf_ini
[i
].rf_register
);
1351 * Initialize RF5413/5414
1353 static int ath5k_hw_rf5413_rfregs(struct ath5k_hw
*ah
,
1354 struct ieee80211_channel
*channel
, unsigned int mode
)
1356 const struct ath5k_ini_rf
*rf_ini
;
1358 unsigned int rf_size
, i
;
1361 AR5K_ASSERT_ENTRY(mode
, AR5K_MODE_MAX
);
1363 rf
= ah
->ah_rf_banks
;
1365 if (ah
->ah_radio
== AR5K_RF5413
) {
1366 rf_ini
= rfregs_5413
;
1367 rf_size
= ARRAY_SIZE(rfregs_5413
);
1368 } else if (ah
->ah_radio
== AR5K_RF2413
) {
1369 rf_ini
= rfregs_2413
;
1370 rf_size
= ARRAY_SIZE(rfregs_2413
);
1372 ATH5K_ERR(ah
->ah_sc
,
1373 "invalid channel mode: %i\n", mode
);
1381 /* Copy values to modify them */
1382 for (i
= 0; i
< rf_size
; i
++) {
1383 if (rf_ini
[i
].rf_bank
>= AR5K_RF5112_INI_RF_MAX_BANKS
) {
1384 ATH5K_ERR(ah
->ah_sc
, "invalid bank\n");
1388 if (bank
!= rf_ini
[i
].rf_bank
) {
1389 bank
= rf_ini
[i
].rf_bank
;
1390 ah
->ah_offset
[bank
] = i
;
1393 rf
[i
] = rf_ini
[i
].rf_value
[mode
];
1397 * After compairing dumps from different cards
1398 * we get the same RF_BUFFER settings (diff returns
1399 * 0 lines). It seems that RF_BUFFER settings are static
1400 * and are written unmodified (no EEPROM stuff
1401 * is used because calibration data would be
1402 * different between different cards and would result
1403 * different RF_BUFFER settings)
1406 /* Write RF values */
1407 for (i
= 0; i
< rf_size
; i
++)
1408 ath5k_hw_reg_write(ah
, rf
[i
], rf_ini
[i
].rf_register
);
1416 int ath5k_hw_rfregs(struct ath5k_hw
*ah
, struct ieee80211_channel
*channel
,
1419 int (*func
)(struct ath5k_hw
*, struct ieee80211_channel
*, unsigned int);
1422 switch (ah
->ah_radio
) {
1424 ah
->ah_rf_banks_size
= sizeof(rfregs_5111
);
1425 func
= ath5k_hw_rf5111_rfregs
;
1428 if (ah
->ah_radio_5ghz_revision
>= AR5K_SREV_RAD_5112A
)
1429 ah
->ah_rf_banks_size
= sizeof(rfregs_5112a
);
1431 ah
->ah_rf_banks_size
= sizeof(rfregs_5112
);
1432 func
= ath5k_hw_rf5112_rfregs
;
1435 ah
->ah_rf_banks_size
= sizeof(rfregs_5413
);
1436 func
= ath5k_hw_rf5413_rfregs
;
1439 ah
->ah_rf_banks_size
= sizeof(rfregs_2413
);
1440 func
= ath5k_hw_rf5413_rfregs
;
1446 if (ah
->ah_rf_banks
== NULL
) {
1447 /* XXX do extra checks? */
1448 ah
->ah_rf_banks
= kmalloc(ah
->ah_rf_banks_size
, GFP_KERNEL
);
1449 if (ah
->ah_rf_banks
== NULL
) {
1450 ATH5K_ERR(ah
->ah_sc
, "out of memory\n");
1455 ret
= func(ah
, channel
, mode
);
1457 ah
->ah_rf_gain
= AR5K_RFGAIN_INACTIVE
;
1462 int ath5k_hw_rfgain(struct ath5k_hw
*ah
, unsigned int freq
)
1464 const struct ath5k_ini_rfgain
*ath5k_rfg
;
1465 unsigned int i
, size
;
1467 switch (ah
->ah_radio
) {
1469 ath5k_rfg
= rfgain_5111
;
1470 size
= ARRAY_SIZE(rfgain_5111
);
1473 ath5k_rfg
= rfgain_5112
;
1474 size
= ARRAY_SIZE(rfgain_5112
);
1477 ath5k_rfg
= rfgain_5413
;
1478 size
= ARRAY_SIZE(rfgain_5413
);
1481 ath5k_rfg
= rfgain_2413
;
1482 size
= ARRAY_SIZE(rfgain_2413
);
1483 freq
= 0; /* only 2Ghz */
1490 case AR5K_INI_RFGAIN_2GHZ
:
1491 case AR5K_INI_RFGAIN_5GHZ
:
1497 for (i
= 0; i
< size
; i
++) {
1499 ath5k_hw_reg_write(ah
, ath5k_rfg
[i
].rfg_value
[freq
],
1500 (u32
)ath5k_rfg
[i
].rfg_register
);
1506 enum ath5k_rfgain
ath5k_hw_get_rf_gain(struct ath5k_hw
*ah
)
1510 ATH5K_TRACE(ah
->ah_sc
);
1512 if (ah
->ah_rf_banks
== NULL
|| !ah
->ah_gain
.g_active
||
1513 ah
->ah_version
<= AR5K_AR5211
)
1514 return AR5K_RFGAIN_INACTIVE
;
1516 if (ah
->ah_rf_gain
!= AR5K_RFGAIN_READ_REQUESTED
)
1519 data
= ath5k_hw_reg_read(ah
, AR5K_PHY_PAPD_PROBE
);
1521 if (!(data
& AR5K_PHY_PAPD_PROBE_TX_NEXT
)) {
1522 ah
->ah_gain
.g_current
= data
>> AR5K_PHY_PAPD_PROBE_GAINF_S
;
1523 type
= AR5K_REG_MS(data
, AR5K_PHY_PAPD_PROBE_TYPE
);
1525 if (type
== AR5K_PHY_PAPD_PROBE_TYPE_CCK
)
1526 ah
->ah_gain
.g_current
+= AR5K_GAIN_CCK_PROBE_CORR
;
1528 if (ah
->ah_radio
>= AR5K_RF5112
) {
1529 ath5k_hw_rfregs_gainf_corr(ah
);
1530 ah
->ah_gain
.g_current
=
1531 ah
->ah_gain
.g_current
>=ah
->ah_gain
.g_f_corr
?
1532 (ah
->ah_gain
.g_current
-ah
->ah_gain
.g_f_corr
) :
1536 if (ath5k_hw_rfregs_gain_readback(ah
) &&
1537 AR5K_GAIN_CHECK_ADJUST(&ah
->ah_gain
) &&
1538 ath5k_hw_rfregs_gain_adjust(ah
))
1539 ah
->ah_rf_gain
= AR5K_RFGAIN_NEED_CHANGE
;
1543 return ah
->ah_rf_gain
;
1546 int ath5k_hw_set_rfgain_opt(struct ath5k_hw
*ah
)
1548 /* Initialize the gain optimization values */
1549 switch (ah
->ah_radio
) {
1551 ah
->ah_gain
.g_step_idx
= rfgain_opt_5111
.go_default
;
1552 ah
->ah_gain
.g_step
=
1553 &rfgain_opt_5111
.go_step
[ah
->ah_gain
.g_step_idx
];
1554 ah
->ah_gain
.g_low
= 20;
1555 ah
->ah_gain
.g_high
= 35;
1556 ah
->ah_gain
.g_active
= 1;
1559 ah
->ah_gain
.g_step_idx
= rfgain_opt_5112
.go_default
;
1560 ah
->ah_gain
.g_step
=
1561 &rfgain_opt_5112
.go_step
[ah
->ah_gain
.g_step_idx
];
1562 ah
->ah_gain
.g_low
= 20;
1563 ah
->ah_gain
.g_high
= 85;
1564 ah
->ah_gain
.g_active
= 1;
1573 /**************************\
1574 PHY/RF channel functions
1575 \**************************/
1578 * Check if a channel is supported
1580 bool ath5k_channel_ok(struct ath5k_hw
*ah
, u16 freq
, unsigned int flags
)
1582 /* Check if the channel is in our supported range */
1583 if (flags
& CHANNEL_2GHZ
) {
1584 if ((freq
>= ah
->ah_capabilities
.cap_range
.range_2ghz_min
) &&
1585 (freq
<= ah
->ah_capabilities
.cap_range
.range_2ghz_max
))
1587 } else if (flags
& CHANNEL_5GHZ
)
1588 if ((freq
>= ah
->ah_capabilities
.cap_range
.range_5ghz_min
) &&
1589 (freq
<= ah
->ah_capabilities
.cap_range
.range_5ghz_max
))
1596 * Convertion needed for RF5110
1598 static u32
ath5k_hw_rf5110_chan2athchan(struct ieee80211_channel
*channel
)
1603 * Convert IEEE channel/MHz to an internal channel value used
1604 * by the AR5210 chipset. This has not been verified with
1605 * newer chipsets like the AR5212A who have a completely
1606 * different RF/PHY part.
1608 athchan
= (ath5k_hw_bitswap(
1609 (ieee80211_frequency_to_channel(
1610 channel
->center_freq
) - 24) / 2, 5)
1611 << 1) | (1 << 6) | 0x1;
1616 * Set channel on RF5110
1618 static int ath5k_hw_rf5110_channel(struct ath5k_hw
*ah
,
1619 struct ieee80211_channel
*channel
)
1624 * Set the channel and wait
1626 data
= ath5k_hw_rf5110_chan2athchan(channel
);
1627 ath5k_hw_reg_write(ah
, data
, AR5K_RF_BUFFER
);
1628 ath5k_hw_reg_write(ah
, 0, AR5K_RF_BUFFER_CONTROL_0
);
1635 * Convertion needed for 5111
1637 static int ath5k_hw_rf5111_chan2athchan(unsigned int ieee
,
1638 struct ath5k_athchan_2ghz
*athchan
)
1642 /* Cast this value to catch negative channel numbers (>= -19) */
1643 channel
= (int)ieee
;
1646 * Map 2GHz IEEE channel to 5GHz Atheros channel
1648 if (channel
<= 13) {
1649 athchan
->a2_athchan
= 115 + channel
;
1650 athchan
->a2_flags
= 0x46;
1651 } else if (channel
== 14) {
1652 athchan
->a2_athchan
= 124;
1653 athchan
->a2_flags
= 0x44;
1654 } else if (channel
>= 15 && channel
<= 26) {
1655 athchan
->a2_athchan
= ((channel
- 14) * 4) + 132;
1656 athchan
->a2_flags
= 0x46;
1664 * Set channel on 5111
1666 static int ath5k_hw_rf5111_channel(struct ath5k_hw
*ah
,
1667 struct ieee80211_channel
*channel
)
1669 struct ath5k_athchan_2ghz ath5k_channel_2ghz
;
1670 unsigned int ath5k_channel
=
1671 ieee80211_frequency_to_channel(channel
->center_freq
);
1672 u32 data0
, data1
, clock
;
1676 * Set the channel on the RF5111 radio
1680 if (channel
->hw_value
& CHANNEL_2GHZ
) {
1681 /* Map 2GHz channel to 5GHz Atheros channel ID */
1682 ret
= ath5k_hw_rf5111_chan2athchan(
1683 ieee80211_frequency_to_channel(channel
->center_freq
),
1684 &ath5k_channel_2ghz
);
1688 ath5k_channel
= ath5k_channel_2ghz
.a2_athchan
;
1689 data0
= ((ath5k_hw_bitswap(ath5k_channel_2ghz
.a2_flags
, 8) & 0xff)
1693 if (ath5k_channel
< 145 || !(ath5k_channel
& 1)) {
1695 data1
= ((ath5k_hw_bitswap(ath5k_channel
- 24, 8) & 0xff) << 2) |
1696 (clock
<< 1) | (1 << 10) | 1;
1699 data1
= ((ath5k_hw_bitswap((ath5k_channel
- 24) / 2, 8) & 0xff)
1700 << 2) | (clock
<< 1) | (1 << 10) | 1;
1703 ath5k_hw_reg_write(ah
, (data1
& 0xff) | ((data0
& 0xff) << 8),
1705 ath5k_hw_reg_write(ah
, ((data1
>> 8) & 0xff) | (data0
& 0xff00),
1706 AR5K_RF_BUFFER_CONTROL_3
);
1712 * Set channel on 5112 and newer
1714 static int ath5k_hw_rf5112_channel(struct ath5k_hw
*ah
,
1715 struct ieee80211_channel
*channel
)
1717 u32 data
, data0
, data1
, data2
;
1720 data
= data0
= data1
= data2
= 0;
1721 c
= channel
->center_freq
;
1724 * Set the channel on the RF5112 or newer
1727 if (!((c
- 2224) % 5)) {
1728 data0
= ((2 * (c
- 704)) - 3040) / 10;
1730 } else if (!((c
- 2192) % 5)) {
1731 data0
= ((2 * (c
- 672)) - 3040) / 10;
1736 data0
= ath5k_hw_bitswap((data0
<< 2) & 0xff, 8);
1738 if (!(c
% 20) && c
>= 5120) {
1739 data0
= ath5k_hw_bitswap(((c
- 4800) / 20 << 2), 8);
1740 data2
= ath5k_hw_bitswap(3, 2);
1741 } else if (!(c
% 10)) {
1742 data0
= ath5k_hw_bitswap(((c
- 4800) / 10 << 1), 8);
1743 data2
= ath5k_hw_bitswap(2, 2);
1744 } else if (!(c
% 5)) {
1745 data0
= ath5k_hw_bitswap((c
- 4800) / 5, 8);
1746 data2
= ath5k_hw_bitswap(1, 2);
1751 data
= (data0
<< 4) | (data1
<< 1) | (data2
<< 2) | 0x1001;
1753 ath5k_hw_reg_write(ah
, data
& 0xff, AR5K_RF_BUFFER
);
1754 ath5k_hw_reg_write(ah
, (data
>> 8) & 0x7f, AR5K_RF_BUFFER_CONTROL_5
);
1760 * Set a channel on the radio chip
1762 int ath5k_hw_channel(struct ath5k_hw
*ah
, struct ieee80211_channel
*channel
)
1766 * Check bounds supported by the PHY (we don't care about regultory
1767 * restrictions at this point). Note: hw_value already has the band
1768 * (CHANNEL_2GHZ, or CHANNEL_5GHZ) so we inform ath5k_channel_ok()
1769 * of the band by that */
1770 if (!ath5k_channel_ok(ah
, channel
->center_freq
, channel
->hw_value
)) {
1771 ATH5K_ERR(ah
->ah_sc
,
1772 "channel frequency (%u MHz) out of supported "
1774 channel
->center_freq
);
1779 * Set the channel and wait
1781 switch (ah
->ah_radio
) {
1783 ret
= ath5k_hw_rf5110_channel(ah
, channel
);
1786 ret
= ath5k_hw_rf5111_channel(ah
, channel
);
1789 ret
= ath5k_hw_rf5112_channel(ah
, channel
);
1796 ah
->ah_current_channel
.center_freq
= channel
->center_freq
;
1797 ah
->ah_current_channel
.hw_value
= channel
->hw_value
;
1798 ah
->ah_turbo
= channel
->hw_value
== CHANNEL_T
? true : false;
1808 * ath5k_hw_noise_floor_calibration - perform PHY noise floor calibration
1810 * @ah: struct ath5k_hw pointer we are operating on
1811 * @freq: the channel frequency, just used for error logging
1813 * This function performs a noise floor calibration of the PHY and waits for
1814 * it to complete. Then the noise floor value is compared to some maximum
1815 * noise floor we consider valid.
1817 * Note that this is different from what the madwifi HAL does: it reads the
1818 * noise floor and afterwards initiates the calibration. Since the noise floor
1819 * calibration can take some time to finish, depending on the current channel
1820 * use, that avoids the occasional timeout warnings we are seeing now.
1822 * See the following link for an Atheros patent on noise floor calibration:
1823 * http://patft.uspto.gov/netacgi/nph-Parser?Sect1=PTO1&Sect2=HITOFF&d=PALL \
1824 * &p=1&u=%2Fnetahtml%2FPTO%2Fsrchnum.htm&r=1&f=G&l=50&s1=7245893.PN.&OS=PN/7
1828 ath5k_hw_noise_floor_calibration(struct ath5k_hw
*ah
, short freq
)
1835 * Enable noise floor calibration and wait until completion
1837 AR5K_REG_ENABLE_BITS(ah
, AR5K_PHY_AGCCTL
,
1838 AR5K_PHY_AGCCTL_NF
);
1840 ret
= ath5k_hw_register_timeout(ah
, AR5K_PHY_AGCCTL
,
1841 AR5K_PHY_AGCCTL_NF
, 0, false);
1843 ATH5K_ERR(ah
->ah_sc
,
1844 "noise floor calibration timeout (%uMHz)\n", freq
);
1848 /* Wait until the noise floor is calibrated and read the value */
1849 for (i
= 20; i
> 0; i
--) {
1851 noise_floor
= ath5k_hw_reg_read(ah
, AR5K_PHY_NF
);
1852 noise_floor
= AR5K_PHY_NF_RVAL(noise_floor
);
1853 if (noise_floor
& AR5K_PHY_NF_ACTIVE
) {
1854 noise_floor
= AR5K_PHY_NF_AVAL(noise_floor
);
1856 if (noise_floor
<= AR5K_TUNE_NOISE_FLOOR
)
1861 ATH5K_DBG_UNLIMIT(ah
->ah_sc
, ATH5K_DEBUG_CALIBRATE
,
1862 "noise floor %d\n", noise_floor
);
1864 if (noise_floor
> AR5K_TUNE_NOISE_FLOOR
) {
1865 ATH5K_ERR(ah
->ah_sc
,
1866 "noise floor calibration failed (%uMHz)\n", freq
);
1870 ah
->ah_noise_floor
= noise_floor
;
1876 * Perform a PHY calibration on RF5110
1877 * -Fix BPSK/QAM Constellation (I/Q correction)
1878 * -Calculate Noise Floor
1880 static int ath5k_hw_rf5110_calibrate(struct ath5k_hw
*ah
,
1881 struct ieee80211_channel
*channel
)
1883 u32 phy_sig
, phy_agc
, phy_sat
, beacon
;
1887 * Disable beacons and RX/TX queues, wait
1889 AR5K_REG_ENABLE_BITS(ah
, AR5K_DIAG_SW_5210
,
1890 AR5K_DIAG_SW_DIS_TX
| AR5K_DIAG_SW_DIS_RX_5210
);
1891 beacon
= ath5k_hw_reg_read(ah
, AR5K_BEACON_5210
);
1892 ath5k_hw_reg_write(ah
, beacon
& ~AR5K_BEACON_ENABLE
, AR5K_BEACON_5210
);
1897 * Set the channel (with AGC turned off)
1899 AR5K_REG_ENABLE_BITS(ah
, AR5K_PHY_AGC
, AR5K_PHY_AGC_DISABLE
);
1901 ret
= ath5k_hw_channel(ah
, channel
);
1904 * Activate PHY and wait
1906 ath5k_hw_reg_write(ah
, AR5K_PHY_ACT_ENABLE
, AR5K_PHY_ACT
);
1909 AR5K_REG_DISABLE_BITS(ah
, AR5K_PHY_AGC
, AR5K_PHY_AGC_DISABLE
);
1915 * Calibrate the radio chip
1918 /* Remember normal state */
1919 phy_sig
= ath5k_hw_reg_read(ah
, AR5K_PHY_SIG
);
1920 phy_agc
= ath5k_hw_reg_read(ah
, AR5K_PHY_AGCCOARSE
);
1921 phy_sat
= ath5k_hw_reg_read(ah
, AR5K_PHY_ADCSAT
);
1923 /* Update radio registers */
1924 ath5k_hw_reg_write(ah
, (phy_sig
& ~(AR5K_PHY_SIG_FIRPWR
)) |
1925 AR5K_REG_SM(-1, AR5K_PHY_SIG_FIRPWR
), AR5K_PHY_SIG
);
1927 ath5k_hw_reg_write(ah
, (phy_agc
& ~(AR5K_PHY_AGCCOARSE_HI
|
1928 AR5K_PHY_AGCCOARSE_LO
)) |
1929 AR5K_REG_SM(-1, AR5K_PHY_AGCCOARSE_HI
) |
1930 AR5K_REG_SM(-127, AR5K_PHY_AGCCOARSE_LO
), AR5K_PHY_AGCCOARSE
);
1932 ath5k_hw_reg_write(ah
, (phy_sat
& ~(AR5K_PHY_ADCSAT_ICNT
|
1933 AR5K_PHY_ADCSAT_THR
)) |
1934 AR5K_REG_SM(2, AR5K_PHY_ADCSAT_ICNT
) |
1935 AR5K_REG_SM(12, AR5K_PHY_ADCSAT_THR
), AR5K_PHY_ADCSAT
);
1939 AR5K_REG_ENABLE_BITS(ah
, AR5K_PHY_AGC
, AR5K_PHY_AGC_DISABLE
);
1941 ath5k_hw_reg_write(ah
, AR5K_PHY_RFSTG_DISABLE
, AR5K_PHY_RFSTG
);
1942 AR5K_REG_DISABLE_BITS(ah
, AR5K_PHY_AGC
, AR5K_PHY_AGC_DISABLE
);
1947 * Enable calibration and wait until completion
1949 AR5K_REG_ENABLE_BITS(ah
, AR5K_PHY_AGCCTL
, AR5K_PHY_AGCCTL_CAL
);
1951 ret
= ath5k_hw_register_timeout(ah
, AR5K_PHY_AGCCTL
,
1952 AR5K_PHY_AGCCTL_CAL
, 0, false);
1954 /* Reset to normal state */
1955 ath5k_hw_reg_write(ah
, phy_sig
, AR5K_PHY_SIG
);
1956 ath5k_hw_reg_write(ah
, phy_agc
, AR5K_PHY_AGCCOARSE
);
1957 ath5k_hw_reg_write(ah
, phy_sat
, AR5K_PHY_ADCSAT
);
1960 ATH5K_ERR(ah
->ah_sc
, "calibration timeout (%uMHz)\n",
1961 channel
->center_freq
);
1965 ret
= ath5k_hw_noise_floor_calibration(ah
, channel
->center_freq
);
1970 * Re-enable RX/TX and beacons
1972 AR5K_REG_DISABLE_BITS(ah
, AR5K_DIAG_SW_5210
,
1973 AR5K_DIAG_SW_DIS_TX
| AR5K_DIAG_SW_DIS_RX_5210
);
1974 ath5k_hw_reg_write(ah
, beacon
, AR5K_BEACON_5210
);
1980 * Perform a PHY calibration on RF5111/5112
1982 static int ath5k_hw_rf511x_calibrate(struct ath5k_hw
*ah
,
1983 struct ieee80211_channel
*channel
)
1986 s32 iq_corr
, i_coff
, i_coffd
, q_coff
, q_coffd
;
1987 ATH5K_TRACE(ah
->ah_sc
);
1989 if (!ah
->ah_calibration
||
1990 ath5k_hw_reg_read(ah
, AR5K_PHY_IQ
) & AR5K_PHY_IQ_RUN
)
1993 ah
->ah_calibration
= false;
1995 iq_corr
= ath5k_hw_reg_read(ah
, AR5K_PHY_IQRES_CAL_CORR
);
1996 i_pwr
= ath5k_hw_reg_read(ah
, AR5K_PHY_IQRES_CAL_PWR_I
);
1997 q_pwr
= ath5k_hw_reg_read(ah
, AR5K_PHY_IQRES_CAL_PWR_Q
);
1998 i_coffd
= ((i_pwr
>> 1) + (q_pwr
>> 1)) >> 7;
1999 q_coffd
= q_pwr
>> 6;
2001 if (i_coffd
== 0 || q_coffd
== 0)
2004 i_coff
= ((-iq_corr
) / i_coffd
) & 0x3f;
2005 q_coff
= (((s32
)i_pwr
/ q_coffd
) - 64) & 0x1f;
2007 /* Commit new IQ value */
2008 AR5K_REG_ENABLE_BITS(ah
, AR5K_PHY_IQ
, AR5K_PHY_IQ_CORR_ENABLE
|
2009 ((u32
)q_coff
) | ((u32
)i_coff
<< AR5K_PHY_IQ_CORR_Q_I_COFF_S
));
2012 ath5k_hw_noise_floor_calibration(ah
, channel
->center_freq
);
2014 /* Request RF gain */
2015 if (channel
->hw_value
& CHANNEL_5GHZ
) {
2016 ath5k_hw_reg_write(ah
, AR5K_REG_SM(ah
->ah_txpower
.txp_max
,
2017 AR5K_PHY_PAPD_PROBE_TXPOWER
) |
2018 AR5K_PHY_PAPD_PROBE_TX_NEXT
, AR5K_PHY_PAPD_PROBE
);
2019 ah
->ah_rf_gain
= AR5K_RFGAIN_READ_REQUESTED
;
2026 * Perform a PHY calibration
2028 int ath5k_hw_phy_calibrate(struct ath5k_hw
*ah
,
2029 struct ieee80211_channel
*channel
)
2033 if (ah
->ah_radio
== AR5K_RF5110
)
2034 ret
= ath5k_hw_rf5110_calibrate(ah
, channel
);
2036 ret
= ath5k_hw_rf511x_calibrate(ah
, channel
);
2041 int ath5k_hw_phy_disable(struct ath5k_hw
*ah
)
2043 ATH5K_TRACE(ah
->ah_sc
);
2045 ath5k_hw_reg_write(ah
, AR5K_PHY_ACT_DISABLE
, AR5K_PHY_ACT
);
2050 /********************\
2052 \********************/
2055 * Get the PHY Chip revision
2057 u16
ath5k_hw_radio_revision(struct ath5k_hw
*ah
, unsigned int chan
)
2063 ATH5K_TRACE(ah
->ah_sc
);
2066 * Set the radio chip access register
2070 ath5k_hw_reg_write(ah
, AR5K_PHY_SHIFT_2GHZ
, AR5K_PHY(0));
2073 ath5k_hw_reg_write(ah
, AR5K_PHY_SHIFT_5GHZ
, AR5K_PHY(0));
2081 /* ...wait until PHY is ready and read the selected radio revision */
2082 ath5k_hw_reg_write(ah
, 0x00001c16, AR5K_PHY(0x34));
2084 for (i
= 0; i
< 8; i
++)
2085 ath5k_hw_reg_write(ah
, 0x00010000, AR5K_PHY(0x20));
2087 if (ah
->ah_version
== AR5K_AR5210
) {
2088 srev
= ath5k_hw_reg_read(ah
, AR5K_PHY(256) >> 28) & 0xf;
2089 ret
= (u16
)ath5k_hw_bitswap(srev
, 4) + 1;
2091 srev
= (ath5k_hw_reg_read(ah
, AR5K_PHY(0x100)) >> 24) & 0xff;
2092 ret
= (u16
)ath5k_hw_bitswap(((srev
& 0xf0) >> 4) |
2093 ((srev
& 0x0f) << 4), 8);
2096 /* Reset to the 5GHz mode */
2097 ath5k_hw_reg_write(ah
, AR5K_PHY_SHIFT_5GHZ
, AR5K_PHY(0));
2102 void /*TODO:Boundary check*/
2103 ath5k_hw_set_def_antenna(struct ath5k_hw
*ah
, unsigned int ant
)
2105 ATH5K_TRACE(ah
->ah_sc
);
2107 if (ah
->ah_version
!= AR5K_AR5210
)
2108 ath5k_hw_reg_write(ah
, ant
, AR5K_DEFAULT_ANTENNA
);
2111 unsigned int ath5k_hw_get_def_antenna(struct ath5k_hw
*ah
)
2113 ATH5K_TRACE(ah
->ah_sc
);
2115 if (ah
->ah_version
!= AR5K_AR5210
)
2116 return ath5k_hw_reg_read(ah
, AR5K_DEFAULT_ANTENNA
);
2118 return false; /*XXX: What do we return for 5210 ?*/
2126 * Initialize the tx power table (not fully implemented)
2128 static void ath5k_txpower_table(struct ath5k_hw
*ah
,
2129 struct ieee80211_channel
*channel
, s16 max_power
)
2131 unsigned int i
, min
, max
, n
;
2132 u16 txpower
, *rates
;
2134 rates
= ah
->ah_txpower
.txp_rates
;
2136 txpower
= AR5K_TUNE_DEFAULT_TXPOWER
* 2;
2137 if (max_power
> txpower
)
2138 txpower
= max_power
> AR5K_TUNE_MAX_TXPOWER
?
2139 AR5K_TUNE_MAX_TXPOWER
: max_power
;
2141 for (i
= 0; i
< AR5K_MAX_RATES
; i
++)
2144 /* XXX setup target powers by rate */
2146 ah
->ah_txpower
.txp_min
= rates
[7];
2147 ah
->ah_txpower
.txp_max
= rates
[0];
2148 ah
->ah_txpower
.txp_ofdm
= rates
[0];
2150 /* Calculate the power table */
2151 n
= ARRAY_SIZE(ah
->ah_txpower
.txp_pcdac
);
2152 min
= AR5K_EEPROM_PCDAC_START
;
2153 max
= AR5K_EEPROM_PCDAC_STOP
;
2154 for (i
= 0; i
< n
; i
+= AR5K_EEPROM_PCDAC_STEP
)
2155 ah
->ah_txpower
.txp_pcdac
[i
] =
2157 min
+ ((i
* (max
- min
)) / n
);
2164 * Set transmition power
2166 int /*O.K. - txpower_table is unimplemented so this doesn't work*/
2167 ath5k_hw_txpower(struct ath5k_hw
*ah
, struct ieee80211_channel
*channel
,
2168 unsigned int txpower
)
2170 bool tpc
= ah
->ah_txpower
.txp_tpc
;
2173 ATH5K_TRACE(ah
->ah_sc
);
2174 if (txpower
> AR5K_TUNE_MAX_TXPOWER
) {
2175 ATH5K_ERR(ah
->ah_sc
, "invalid tx power: %u\n", txpower
);
2180 * RF2413 for some reason can't
2181 * transmit anything if we call
2182 * this funtion, so we skip it
2183 * until we fix txpower.
2185 if (ah
->ah_radio
== AR5K_RF2413
)
2188 /* Reset TX power values */
2189 memset(&ah
->ah_txpower
, 0, sizeof(ah
->ah_txpower
));
2190 ah
->ah_txpower
.txp_tpc
= tpc
;
2192 /* Initialize TX power table */
2193 ath5k_txpower_table(ah
, channel
, txpower
);
2196 * Write TX power values
2198 for (i
= 0; i
< (AR5K_EEPROM_POWER_TABLE_SIZE
/ 2); i
++) {
2199 ath5k_hw_reg_write(ah
,
2200 ((((ah
->ah_txpower
.txp_pcdac
[(i
<< 1) + 1] << 8) | 0xff) & 0xffff) << 16) |
2201 (((ah
->ah_txpower
.txp_pcdac
[(i
<< 1) ] << 8) | 0xff) & 0xffff),
2202 AR5K_PHY_PCDAC_TXPOWER(i
));
2205 ath5k_hw_reg_write(ah
, AR5K_TXPOWER_OFDM(3, 24) |
2206 AR5K_TXPOWER_OFDM(2, 16) | AR5K_TXPOWER_OFDM(1, 8) |
2207 AR5K_TXPOWER_OFDM(0, 0), AR5K_PHY_TXPOWER_RATE1
);
2209 ath5k_hw_reg_write(ah
, AR5K_TXPOWER_OFDM(7, 24) |
2210 AR5K_TXPOWER_OFDM(6, 16) | AR5K_TXPOWER_OFDM(5, 8) |
2211 AR5K_TXPOWER_OFDM(4, 0), AR5K_PHY_TXPOWER_RATE2
);
2213 ath5k_hw_reg_write(ah
, AR5K_TXPOWER_CCK(10, 24) |
2214 AR5K_TXPOWER_CCK(9, 16) | AR5K_TXPOWER_CCK(15, 8) |
2215 AR5K_TXPOWER_CCK(8, 0), AR5K_PHY_TXPOWER_RATE3
);
2217 ath5k_hw_reg_write(ah
, AR5K_TXPOWER_CCK(14, 24) |
2218 AR5K_TXPOWER_CCK(13, 16) | AR5K_TXPOWER_CCK(12, 8) |
2219 AR5K_TXPOWER_CCK(11, 0), AR5K_PHY_TXPOWER_RATE4
);
2221 if (ah
->ah_txpower
.txp_tpc
)
2222 ath5k_hw_reg_write(ah
, AR5K_PHY_TXPOWER_RATE_MAX_TPC_ENABLE
|
2223 AR5K_TUNE_MAX_TXPOWER
, AR5K_PHY_TXPOWER_RATE_MAX
);
2225 ath5k_hw_reg_write(ah
, AR5K_PHY_TXPOWER_RATE_MAX
|
2226 AR5K_TUNE_MAX_TXPOWER
, AR5K_PHY_TXPOWER_RATE_MAX
);
2231 int ath5k_hw_set_txpower_limit(struct ath5k_hw
*ah
, unsigned int power
)
2234 struct ieee80211_channel
*channel
= &ah
->ah_current_channel
;
2236 ATH5K_TRACE(ah
->ah_sc
);
2237 ATH5K_DBG(ah
->ah_sc
, ATH5K_DEBUG_TXPOWER
,
2238 "changing txpower to %d\n", power
);
2240 return ath5k_hw_txpower(ah
, channel
, power
);