blob: 4cc13940c8950d2a7ad2a3fdf1a092ac3736a7d5 [file] [log] [blame]
Luis R. Rodriguez795f5e22010-04-15 17:39:00 -04001/*
Sujith Manoharan5b681382011-05-17 13:36:18 +05302 * Copyright (c) 2010-2011 Atheros Communications Inc.
Luis R. Rodriguez795f5e22010-04-15 17:39:00 -04003 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#include "hw.h"
18#include "hw-ops.h"
19#include "ar9003_phy.h"
Rajkumar Manoharan324c74a2011-10-13 11:00:41 +053020#include "ar9003_rtt.h"
Mohammed Shafi Shajakhan3ebfcdc2011-11-30 10:41:26 +053021#include "ar9003_mci.h"
Luis R. Rodriguez795f5e22010-04-15 17:39:00 -040022
Rajkumar Manoharan5f0c04e2011-10-13 11:00:35 +053023#define MAX_MEASUREMENT MAX_IQCAL_MEASUREMENT
Rajkumar Manoharan3782c692011-04-24 21:34:39 +053024#define MAX_MAG_DELTA 11
25#define MAX_PHS_DELTA 10
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -080026
27struct coeff {
Rajkumar Manoharan3782c692011-04-24 21:34:39 +053028 int mag_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT];
29 int phs_coeff[AR9300_MAX_CHAINS][MAX_MEASUREMENT];
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -080030 int iqc_coeff[2];
31};
32
Felix Fietkau64978272010-10-03 19:07:16 +020033enum ar9003_cal_types {
34 IQ_MISMATCH_CAL = BIT(0),
Felix Fietkau64978272010-10-03 19:07:16 +020035};
36
Luis R. Rodriguez795f5e22010-04-15 17:39:00 -040037static void ar9003_hw_setup_calibration(struct ath_hw *ah,
38 struct ath9k_cal_list *currCal)
39{
Luis R. Rodriguez4b019312010-04-15 17:39:10 -040040 struct ath_common *common = ath9k_hw_common(ah);
41
42 /* Select calibration to run */
43 switch (currCal->calData->calType) {
44 case IQ_MISMATCH_CAL:
45 /*
46 * Start calibration with
47 * 2^(INIT_IQCAL_LOG_COUNT_MAX+1) samples
48 */
49 REG_RMW_FIELD(ah, AR_PHY_TIMING4,
50 AR_PHY_TIMING4_IQCAL_LOG_COUNT_MAX,
Sujith Manoharan1a6e5d72013-01-03 12:21:23 +053051 currCal->calData->calCountMax);
Luis R. Rodriguez4b019312010-04-15 17:39:10 -040052 REG_WRITE(ah, AR_PHY_CALMODE, AR_PHY_CALMODE_IQ);
53
Joe Perchesd2182b62011-12-15 14:55:53 -080054 ath_dbg(common, CALIBRATE,
Joe Perches226afe62010-12-02 19:12:37 -080055 "starting IQ Mismatch Calibration\n");
Luis R. Rodriguez4b019312010-04-15 17:39:10 -040056
57 /* Kick-off cal */
58 REG_SET_BIT(ah, AR_PHY_TIMING4, AR_PHY_TIMING4_DO_CAL);
59 break;
Sujith Manoharan1a6e5d72013-01-03 12:21:23 +053060 default:
61 ath_err(common, "Invalid calibration type\n");
Luis R. Rodriguez4b019312010-04-15 17:39:10 -040062 break;
Luis R. Rodriguez4b019312010-04-15 17:39:10 -040063 }
Luis R. Rodriguez795f5e22010-04-15 17:39:00 -040064}
65
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -040066/*
67 * Generic calibration routine.
68 * Recalibrate the lower PHY chips to account for temperature/environment
69 * changes.
70 */
71static bool ar9003_hw_per_calibration(struct ath_hw *ah,
72 struct ath9k_channel *ichan,
73 u8 rxchainmask,
74 struct ath9k_cal_list *currCal)
75{
Felix Fietkau20bd2a02010-07-31 00:12:00 +020076 struct ath9k_hw_cal_data *caldata = ah->caldata;
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -040077 /* Cal is assumed not done until explicitly set below */
78 bool iscaldone = false;
79
80 /* Calibration in progress. */
81 if (currCal->calState == CAL_RUNNING) {
82 /* Check to see if it has finished. */
83 if (!(REG_READ(ah, AR_PHY_TIMING4) & AR_PHY_TIMING4_DO_CAL)) {
84 /*
85 * Accumulate cal measures for active chains
86 */
87 currCal->calData->calCollect(ah);
88 ah->cal_samples++;
89
90 if (ah->cal_samples >=
91 currCal->calData->calNumSamples) {
92 unsigned int i, numChains = 0;
93 for (i = 0; i < AR9300_MAX_CHAINS; i++) {
94 if (rxchainmask & (1 << i))
95 numChains++;
96 }
97
98 /*
99 * Process accumulated data
100 */
101 currCal->calData->calPostProc(ah, numChains);
102
103 /* Calibration has finished. */
Felix Fietkau20bd2a02010-07-31 00:12:00 +0200104 caldata->CalValid |= currCal->calData->calType;
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400105 currCal->calState = CAL_DONE;
106 iscaldone = true;
107 } else {
108 /*
109 * Set-up collection of another sub-sample until we
110 * get desired number
111 */
112 ar9003_hw_setup_calibration(ah, currCal);
113 }
114 }
Felix Fietkau20bd2a02010-07-31 00:12:00 +0200115 } else if (!(caldata->CalValid & currCal->calData->calType)) {
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400116 /* If current cal is marked invalid in channel, kick it off */
117 ath9k_hw_reset_calibration(ah, currCal);
118 }
119
120 return iscaldone;
121}
122
Luis R. Rodriguez795f5e22010-04-15 17:39:00 -0400123static bool ar9003_hw_calibrate(struct ath_hw *ah,
124 struct ath9k_channel *chan,
125 u8 rxchainmask,
126 bool longcal)
127{
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400128 bool iscaldone = true;
129 struct ath9k_cal_list *currCal = ah->cal_list_curr;
Luis R. Rodriguez795f5e22010-04-15 17:39:00 -0400130
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400131 /*
132 * For given calibration:
133 * 1. Call generic cal routine
134 * 2. When this cal is done (isCalDone) if we have more cals waiting
135 * (eg after reset), mask this to upper layers by not propagating
136 * isCalDone if it is set to TRUE.
137 * Instead, change isCalDone to FALSE and setup the waiting cal(s)
138 * to be run.
139 */
140 if (currCal &&
141 (currCal->calState == CAL_RUNNING ||
142 currCal->calState == CAL_WAITING)) {
143 iscaldone = ar9003_hw_per_calibration(ah, chan,
144 rxchainmask, currCal);
145 if (iscaldone) {
146 ah->cal_list_curr = currCal = currCal->calNext;
147
148 if (currCal->calState == CAL_WAITING) {
149 iscaldone = false;
150 ath9k_hw_reset_calibration(ah, currCal);
151 }
152 }
153 }
154
Rajkumar Manoharan54717e52012-07-01 19:53:52 +0530155 /*
156 * Do NF cal only at longer intervals. Get the value from
157 * the previous NF cal and update history buffer.
158 */
159 if (longcal && ath9k_hw_getnf(ah, chan)) {
Felix Fietkau93697462010-07-30 21:02:10 +0200160 /*
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400161 * Load the NF from history buffer of the current channel.
162 * NF is slow time-variant, so it is OK to use a historical
163 * value.
164 */
165 ath9k_hw_loadnf(ah, ah->curchan);
166
167 /* start NF calibration, without updating BB NF register */
Felix Fietkau00c86592010-07-30 21:02:09 +0200168 ath9k_hw_start_nfcal(ah, false);
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400169 }
170
171 return iscaldone;
Luis R. Rodriguez795f5e22010-04-15 17:39:00 -0400172}
173
Luis R. Rodriguez590b7d22010-04-15 17:39:01 -0400174static void ar9003_hw_iqcal_collect(struct ath_hw *ah)
175{
176 int i;
177
178 /* Accumulate IQ cal measures for active chains */
179 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
Vasanthakumar Thiagarajan5d48ae72011-04-19 19:29:16 +0530180 if (ah->txchainmask & BIT(i)) {
181 ah->totalPowerMeasI[i] +=
182 REG_READ(ah, AR_PHY_CAL_MEAS_0(i));
183 ah->totalPowerMeasQ[i] +=
184 REG_READ(ah, AR_PHY_CAL_MEAS_1(i));
185 ah->totalIqCorrMeas[i] +=
186 (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_2(i));
Joe Perchesd2182b62011-12-15 14:55:53 -0800187 ath_dbg(ath9k_hw_common(ah), CALIBRATE,
Vasanthakumar Thiagarajan5d48ae72011-04-19 19:29:16 +0530188 "%d: Chn %d pmi=0x%08x;pmq=0x%08x;iqcm=0x%08x;\n",
189 ah->cal_samples, i, ah->totalPowerMeasI[i],
190 ah->totalPowerMeasQ[i],
191 ah->totalIqCorrMeas[i]);
192 }
Luis R. Rodriguez590b7d22010-04-15 17:39:01 -0400193 }
194}
195
196static void ar9003_hw_iqcalibrate(struct ath_hw *ah, u8 numChains)
197{
198 struct ath_common *common = ath9k_hw_common(ah);
199 u32 powerMeasQ, powerMeasI, iqCorrMeas;
200 u32 qCoffDenom, iCoffDenom;
201 int32_t qCoff, iCoff;
202 int iqCorrNeg, i;
Joe Perches07b2fa52010-11-20 18:38:53 -0800203 static const u_int32_t offset_array[3] = {
Luis R. Rodriguez590b7d22010-04-15 17:39:01 -0400204 AR_PHY_RX_IQCAL_CORR_B0,
205 AR_PHY_RX_IQCAL_CORR_B1,
206 AR_PHY_RX_IQCAL_CORR_B2,
207 };
208
209 for (i = 0; i < numChains; i++) {
210 powerMeasI = ah->totalPowerMeasI[i];
211 powerMeasQ = ah->totalPowerMeasQ[i];
212 iqCorrMeas = ah->totalIqCorrMeas[i];
213
Joe Perchesd2182b62011-12-15 14:55:53 -0800214 ath_dbg(common, CALIBRATE,
215 "Starting IQ Cal and Correction for Chain %d\n", i);
Luis R. Rodriguez590b7d22010-04-15 17:39:01 -0400216
Joe Perchesd2182b62011-12-15 14:55:53 -0800217 ath_dbg(common, CALIBRATE,
Nikolay Martynova9b2ce02011-12-02 22:39:14 -0500218 "Original: Chn %d iq_corr_meas = 0x%08x\n",
Joe Perches226afe62010-12-02 19:12:37 -0800219 i, ah->totalIqCorrMeas[i]);
Luis R. Rodriguez590b7d22010-04-15 17:39:01 -0400220
221 iqCorrNeg = 0;
222
223 if (iqCorrMeas > 0x80000000) {
224 iqCorrMeas = (0xffffffff - iqCorrMeas) + 1;
225 iqCorrNeg = 1;
226 }
227
Joe Perchesd2182b62011-12-15 14:55:53 -0800228 ath_dbg(common, CALIBRATE, "Chn %d pwr_meas_i = 0x%08x\n",
229 i, powerMeasI);
230 ath_dbg(common, CALIBRATE, "Chn %d pwr_meas_q = 0x%08x\n",
231 i, powerMeasQ);
232 ath_dbg(common, CALIBRATE, "iqCorrNeg is 0x%08x\n", iqCorrNeg);
Luis R. Rodriguez590b7d22010-04-15 17:39:01 -0400233
234 iCoffDenom = (powerMeasI / 2 + powerMeasQ / 2) / 256;
235 qCoffDenom = powerMeasQ / 64;
236
237 if ((iCoffDenom != 0) && (qCoffDenom != 0)) {
238 iCoff = iqCorrMeas / iCoffDenom;
239 qCoff = powerMeasI / qCoffDenom - 64;
Joe Perchesd2182b62011-12-15 14:55:53 -0800240 ath_dbg(common, CALIBRATE, "Chn %d iCoff = 0x%08x\n",
241 i, iCoff);
242 ath_dbg(common, CALIBRATE, "Chn %d qCoff = 0x%08x\n",
243 i, qCoff);
Luis R. Rodriguez590b7d22010-04-15 17:39:01 -0400244
245 /* Force bounds on iCoff */
246 if (iCoff >= 63)
247 iCoff = 63;
248 else if (iCoff <= -63)
249 iCoff = -63;
250
251 /* Negate iCoff if iqCorrNeg == 0 */
252 if (iqCorrNeg == 0x0)
253 iCoff = -iCoff;
254
255 /* Force bounds on qCoff */
256 if (qCoff >= 63)
257 qCoff = 63;
258 else if (qCoff <= -63)
259 qCoff = -63;
260
261 iCoff = iCoff & 0x7f;
262 qCoff = qCoff & 0x7f;
263
Joe Perchesd2182b62011-12-15 14:55:53 -0800264 ath_dbg(common, CALIBRATE,
Joe Perches226afe62010-12-02 19:12:37 -0800265 "Chn %d : iCoff = 0x%x qCoff = 0x%x\n",
266 i, iCoff, qCoff);
Joe Perchesd2182b62011-12-15 14:55:53 -0800267 ath_dbg(common, CALIBRATE,
Joe Perches226afe62010-12-02 19:12:37 -0800268 "Register offset (0x%04x) before update = 0x%x\n",
269 offset_array[i],
270 REG_READ(ah, offset_array[i]));
Luis R. Rodriguez590b7d22010-04-15 17:39:01 -0400271
Rajkumar Manoharan6f37ff92012-10-15 15:29:51 +0530272 if (AR_SREV_9565(ah) &&
273 (iCoff == 63 || qCoff == 63 ||
274 iCoff == -63 || qCoff == -63))
275 return;
276
Luis R. Rodriguez590b7d22010-04-15 17:39:01 -0400277 REG_RMW_FIELD(ah, offset_array[i],
278 AR_PHY_RX_IQCAL_CORR_IQCORR_Q_I_COFF,
279 iCoff);
280 REG_RMW_FIELD(ah, offset_array[i],
281 AR_PHY_RX_IQCAL_CORR_IQCORR_Q_Q_COFF,
282 qCoff);
Joe Perchesd2182b62011-12-15 14:55:53 -0800283 ath_dbg(common, CALIBRATE,
Joe Perches226afe62010-12-02 19:12:37 -0800284 "Register offset (0x%04x) QI COFF (bitfields 0x%08x) after update = 0x%x\n",
285 offset_array[i],
286 AR_PHY_RX_IQCAL_CORR_IQCORR_Q_I_COFF,
287 REG_READ(ah, offset_array[i]));
Joe Perchesd2182b62011-12-15 14:55:53 -0800288 ath_dbg(common, CALIBRATE,
Joe Perches226afe62010-12-02 19:12:37 -0800289 "Register offset (0x%04x) QQ COFF (bitfields 0x%08x) after update = 0x%x\n",
290 offset_array[i],
291 AR_PHY_RX_IQCAL_CORR_IQCORR_Q_Q_COFF,
292 REG_READ(ah, offset_array[i]));
Luis R. Rodriguez590b7d22010-04-15 17:39:01 -0400293
Joe Perchesd2182b62011-12-15 14:55:53 -0800294 ath_dbg(common, CALIBRATE,
Joe Perches226afe62010-12-02 19:12:37 -0800295 "IQ Cal and Correction done for Chain %d\n", i);
Luis R. Rodriguez590b7d22010-04-15 17:39:01 -0400296 }
297 }
298
299 REG_SET_BIT(ah, AR_PHY_RX_IQCAL_CORR_B0,
300 AR_PHY_RX_IQCAL_CORR_IQCORR_ENABLE);
Joe Perchesd2182b62011-12-15 14:55:53 -0800301 ath_dbg(common, CALIBRATE,
Joe Perches226afe62010-12-02 19:12:37 -0800302 "IQ Cal and Correction (offset 0x%04x) enabled (bit position 0x%08x). New Value 0x%08x\n",
303 (unsigned) (AR_PHY_RX_IQCAL_CORR_B0),
304 AR_PHY_RX_IQCAL_CORR_IQCORR_ENABLE,
305 REG_READ(ah, AR_PHY_RX_IQCAL_CORR_B0));
Luis R. Rodriguez590b7d22010-04-15 17:39:01 -0400306}
307
308static const struct ath9k_percal_data iq_cal_single_sample = {
309 IQ_MISMATCH_CAL,
310 MIN_CAL_SAMPLES,
311 PER_MAX_LOG_COUNT,
312 ar9003_hw_iqcal_collect,
313 ar9003_hw_iqcalibrate
314};
315
Luis R. Rodriguez795f5e22010-04-15 17:39:00 -0400316static void ar9003_hw_init_cal_settings(struct ath_hw *ah)
317{
Luis R. Rodriguez590b7d22010-04-15 17:39:01 -0400318 ah->iq_caldata.calData = &iq_cal_single_sample;
Sujith Manoharanb6869292013-01-03 12:21:21 +0530319
320 if (AR_SREV_9300_20_OR_LATER(ah)) {
321 ah->enabled_cals |= TX_IQ_CAL;
Sujith Manoharan03c2dc72013-01-03 14:55:48 +0530322 if (AR_SREV_9485_OR_LATER(ah) && !AR_SREV_9340(ah))
Sujith Manoharanb6869292013-01-03 12:21:21 +0530323 ah->enabled_cals |= TX_IQ_ON_AGC_CAL;
324 }
325
326 ah->supp_cals = IQ_MISMATCH_CAL;
Luis R. Rodriguez795f5e22010-04-15 17:39:00 -0400327}
328
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400329/*
330 * solve 4x4 linear equation used in loopback iq cal.
331 */
332static bool ar9003_hw_solve_iq_cal(struct ath_hw *ah,
333 s32 sin_2phi_1,
334 s32 cos_2phi_1,
335 s32 sin_2phi_2,
336 s32 cos_2phi_2,
337 s32 mag_a0_d0,
338 s32 phs_a0_d0,
339 s32 mag_a1_d0,
340 s32 phs_a1_d0,
341 s32 solved_eq[])
Luis R. Rodriguez77d6d392010-04-15 17:39:09 -0400342{
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400343 s32 f1 = cos_2phi_1 - cos_2phi_2,
344 f3 = sin_2phi_1 - sin_2phi_2,
345 f2;
346 s32 mag_tx, phs_tx, mag_rx, phs_rx;
347 const s32 result_shift = 1 << 15;
348 struct ath_common *common = ath9k_hw_common(ah);
349
350 f2 = (f1 * f1 + f3 * f3) / result_shift;
351
352 if (!f2) {
Joe Perchesd2182b62011-12-15 14:55:53 -0800353 ath_dbg(common, CALIBRATE, "Divide by 0\n");
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400354 return false;
355 }
356
357 /* mag mismatch, tx */
358 mag_tx = f1 * (mag_a0_d0 - mag_a1_d0) + f3 * (phs_a0_d0 - phs_a1_d0);
359 /* phs mismatch, tx */
360 phs_tx = f3 * (-mag_a0_d0 + mag_a1_d0) + f1 * (phs_a0_d0 - phs_a1_d0);
361
362 mag_tx = (mag_tx / f2);
363 phs_tx = (phs_tx / f2);
364
365 /* mag mismatch, rx */
366 mag_rx = mag_a0_d0 - (cos_2phi_1 * mag_tx + sin_2phi_1 * phs_tx) /
367 result_shift;
368 /* phs mismatch, rx */
369 phs_rx = phs_a0_d0 + (sin_2phi_1 * mag_tx - cos_2phi_1 * phs_tx) /
370 result_shift;
371
372 solved_eq[0] = mag_tx;
373 solved_eq[1] = phs_tx;
374 solved_eq[2] = mag_rx;
375 solved_eq[3] = phs_rx;
376
377 return true;
378}
379
380static s32 ar9003_hw_find_mag_approx(struct ath_hw *ah, s32 in_re, s32 in_im)
381{
382 s32 abs_i = abs(in_re),
383 abs_q = abs(in_im),
384 max_abs, min_abs;
385
386 if (abs_i > abs_q) {
387 max_abs = abs_i;
388 min_abs = abs_q;
389 } else {
390 max_abs = abs_q;
391 min_abs = abs_i;
392 }
393
394 return max_abs - (max_abs / 32) + (min_abs / 8) + (min_abs / 4);
395}
396
397#define DELPT 32
398
399static bool ar9003_hw_calc_iq_corr(struct ath_hw *ah,
400 s32 chain_idx,
401 const s32 iq_res[],
402 s32 iqc_coeff[])
403{
404 s32 i2_m_q2_a0_d0, i2_p_q2_a0_d0, iq_corr_a0_d0,
405 i2_m_q2_a0_d1, i2_p_q2_a0_d1, iq_corr_a0_d1,
406 i2_m_q2_a1_d0, i2_p_q2_a1_d0, iq_corr_a1_d0,
407 i2_m_q2_a1_d1, i2_p_q2_a1_d1, iq_corr_a1_d1;
408 s32 mag_a0_d0, mag_a1_d0, mag_a0_d1, mag_a1_d1,
409 phs_a0_d0, phs_a1_d0, phs_a0_d1, phs_a1_d1,
410 sin_2phi_1, cos_2phi_1,
411 sin_2phi_2, cos_2phi_2;
412 s32 mag_tx, phs_tx, mag_rx, phs_rx;
413 s32 solved_eq[4], mag_corr_tx, phs_corr_tx, mag_corr_rx, phs_corr_rx,
414 q_q_coff, q_i_coff;
415 const s32 res_scale = 1 << 15;
416 const s32 delpt_shift = 1 << 8;
417 s32 mag1, mag2;
418 struct ath_common *common = ath9k_hw_common(ah);
419
420 i2_m_q2_a0_d0 = iq_res[0] & 0xfff;
421 i2_p_q2_a0_d0 = (iq_res[0] >> 12) & 0xfff;
422 iq_corr_a0_d0 = ((iq_res[0] >> 24) & 0xff) + ((iq_res[1] & 0xf) << 8);
423
424 if (i2_m_q2_a0_d0 > 0x800)
425 i2_m_q2_a0_d0 = -((0xfff - i2_m_q2_a0_d0) + 1);
426
427 if (i2_p_q2_a0_d0 > 0x800)
428 i2_p_q2_a0_d0 = -((0xfff - i2_p_q2_a0_d0) + 1);
429
430 if (iq_corr_a0_d0 > 0x800)
431 iq_corr_a0_d0 = -((0xfff - iq_corr_a0_d0) + 1);
432
433 i2_m_q2_a0_d1 = (iq_res[1] >> 4) & 0xfff;
434 i2_p_q2_a0_d1 = (iq_res[2] & 0xfff);
435 iq_corr_a0_d1 = (iq_res[2] >> 12) & 0xfff;
436
437 if (i2_m_q2_a0_d1 > 0x800)
438 i2_m_q2_a0_d1 = -((0xfff - i2_m_q2_a0_d1) + 1);
439
440 if (i2_p_q2_a0_d1 > 0x800)
441 i2_p_q2_a0_d1 = -((0xfff - i2_p_q2_a0_d1) + 1);
442
443 if (iq_corr_a0_d1 > 0x800)
444 iq_corr_a0_d1 = -((0xfff - iq_corr_a0_d1) + 1);
445
446 i2_m_q2_a1_d0 = ((iq_res[2] >> 24) & 0xff) + ((iq_res[3] & 0xf) << 8);
447 i2_p_q2_a1_d0 = (iq_res[3] >> 4) & 0xfff;
448 iq_corr_a1_d0 = iq_res[4] & 0xfff;
449
450 if (i2_m_q2_a1_d0 > 0x800)
451 i2_m_q2_a1_d0 = -((0xfff - i2_m_q2_a1_d0) + 1);
452
453 if (i2_p_q2_a1_d0 > 0x800)
454 i2_p_q2_a1_d0 = -((0xfff - i2_p_q2_a1_d0) + 1);
455
456 if (iq_corr_a1_d0 > 0x800)
457 iq_corr_a1_d0 = -((0xfff - iq_corr_a1_d0) + 1);
458
459 i2_m_q2_a1_d1 = (iq_res[4] >> 12) & 0xfff;
460 i2_p_q2_a1_d1 = ((iq_res[4] >> 24) & 0xff) + ((iq_res[5] & 0xf) << 8);
461 iq_corr_a1_d1 = (iq_res[5] >> 4) & 0xfff;
462
463 if (i2_m_q2_a1_d1 > 0x800)
464 i2_m_q2_a1_d1 = -((0xfff - i2_m_q2_a1_d1) + 1);
465
466 if (i2_p_q2_a1_d1 > 0x800)
467 i2_p_q2_a1_d1 = -((0xfff - i2_p_q2_a1_d1) + 1);
468
469 if (iq_corr_a1_d1 > 0x800)
470 iq_corr_a1_d1 = -((0xfff - iq_corr_a1_d1) + 1);
471
472 if ((i2_p_q2_a0_d0 == 0) || (i2_p_q2_a0_d1 == 0) ||
473 (i2_p_q2_a1_d0 == 0) || (i2_p_q2_a1_d1 == 0)) {
Joe Perchesd2182b62011-12-15 14:55:53 -0800474 ath_dbg(common, CALIBRATE,
Joe Perches226afe62010-12-02 19:12:37 -0800475 "Divide by 0:\n"
476 "a0_d0=%d\n"
477 "a0_d1=%d\n"
478 "a2_d0=%d\n"
479 "a1_d1=%d\n",
480 i2_p_q2_a0_d0, i2_p_q2_a0_d1,
481 i2_p_q2_a1_d0, i2_p_q2_a1_d1);
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400482 return false;
483 }
484
485 mag_a0_d0 = (i2_m_q2_a0_d0 * res_scale) / i2_p_q2_a0_d0;
486 phs_a0_d0 = (iq_corr_a0_d0 * res_scale) / i2_p_q2_a0_d0;
487
488 mag_a0_d1 = (i2_m_q2_a0_d1 * res_scale) / i2_p_q2_a0_d1;
489 phs_a0_d1 = (iq_corr_a0_d1 * res_scale) / i2_p_q2_a0_d1;
490
491 mag_a1_d0 = (i2_m_q2_a1_d0 * res_scale) / i2_p_q2_a1_d0;
492 phs_a1_d0 = (iq_corr_a1_d0 * res_scale) / i2_p_q2_a1_d0;
493
494 mag_a1_d1 = (i2_m_q2_a1_d1 * res_scale) / i2_p_q2_a1_d1;
495 phs_a1_d1 = (iq_corr_a1_d1 * res_scale) / i2_p_q2_a1_d1;
496
497 /* w/o analog phase shift */
498 sin_2phi_1 = (((mag_a0_d0 - mag_a0_d1) * delpt_shift) / DELPT);
499 /* w/o analog phase shift */
500 cos_2phi_1 = (((phs_a0_d1 - phs_a0_d0) * delpt_shift) / DELPT);
501 /* w/ analog phase shift */
502 sin_2phi_2 = (((mag_a1_d0 - mag_a1_d1) * delpt_shift) / DELPT);
503 /* w/ analog phase shift */
504 cos_2phi_2 = (((phs_a1_d1 - phs_a1_d0) * delpt_shift) / DELPT);
505
506 /*
507 * force sin^2 + cos^2 = 1;
508 * find magnitude by approximation
509 */
510 mag1 = ar9003_hw_find_mag_approx(ah, cos_2phi_1, sin_2phi_1);
511 mag2 = ar9003_hw_find_mag_approx(ah, cos_2phi_2, sin_2phi_2);
512
513 if ((mag1 == 0) || (mag2 == 0)) {
Joe Perchesd2182b62011-12-15 14:55:53 -0800514 ath_dbg(common, CALIBRATE, "Divide by 0: mag1=%d, mag2=%d\n",
Joe Perches226afe62010-12-02 19:12:37 -0800515 mag1, mag2);
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400516 return false;
517 }
518
519 /* normalization sin and cos by mag */
520 sin_2phi_1 = (sin_2phi_1 * res_scale / mag1);
521 cos_2phi_1 = (cos_2phi_1 * res_scale / mag1);
522 sin_2phi_2 = (sin_2phi_2 * res_scale / mag2);
523 cos_2phi_2 = (cos_2phi_2 * res_scale / mag2);
524
525 /* calculate IQ mismatch */
526 if (!ar9003_hw_solve_iq_cal(ah,
527 sin_2phi_1, cos_2phi_1,
528 sin_2phi_2, cos_2phi_2,
529 mag_a0_d0, phs_a0_d0,
530 mag_a1_d0,
531 phs_a1_d0, solved_eq)) {
Joe Perchesd2182b62011-12-15 14:55:53 -0800532 ath_dbg(common, CALIBRATE,
533 "Call to ar9003_hw_solve_iq_cal() failed\n");
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400534 return false;
535 }
536
537 mag_tx = solved_eq[0];
538 phs_tx = solved_eq[1];
539 mag_rx = solved_eq[2];
540 phs_rx = solved_eq[3];
541
Joe Perchesd2182b62011-12-15 14:55:53 -0800542 ath_dbg(common, CALIBRATE,
Joe Perches226afe62010-12-02 19:12:37 -0800543 "chain %d: mag mismatch=%d phase mismatch=%d\n",
544 chain_idx, mag_tx/res_scale, phs_tx/res_scale);
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400545
546 if (res_scale == mag_tx) {
Joe Perchesd2182b62011-12-15 14:55:53 -0800547 ath_dbg(common, CALIBRATE,
Joe Perches226afe62010-12-02 19:12:37 -0800548 "Divide by 0: mag_tx=%d, res_scale=%d\n",
549 mag_tx, res_scale);
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400550 return false;
551 }
552
553 /* calculate and quantize Tx IQ correction factor */
554 mag_corr_tx = (mag_tx * res_scale) / (res_scale - mag_tx);
555 phs_corr_tx = -phs_tx;
556
557 q_q_coff = (mag_corr_tx * 128 / res_scale);
558 q_i_coff = (phs_corr_tx * 256 / res_scale);
559
Joe Perchesd2182b62011-12-15 14:55:53 -0800560 ath_dbg(common, CALIBRATE, "tx chain %d: mag corr=%d phase corr=%d\n",
Joe Perches226afe62010-12-02 19:12:37 -0800561 chain_idx, q_q_coff, q_i_coff);
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400562
563 if (q_i_coff < -63)
564 q_i_coff = -63;
565 if (q_i_coff > 63)
566 q_i_coff = 63;
567 if (q_q_coff < -63)
568 q_q_coff = -63;
569 if (q_q_coff > 63)
570 q_q_coff = 63;
571
572 iqc_coeff[0] = (q_q_coff * 128) + q_i_coff;
573
Joe Perchesd2182b62011-12-15 14:55:53 -0800574 ath_dbg(common, CALIBRATE, "tx chain %d: iq corr coeff=%x\n",
Joe Perches226afe62010-12-02 19:12:37 -0800575 chain_idx, iqc_coeff[0]);
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400576
577 if (-mag_rx == res_scale) {
Joe Perchesd2182b62011-12-15 14:55:53 -0800578 ath_dbg(common, CALIBRATE,
Joe Perches226afe62010-12-02 19:12:37 -0800579 "Divide by 0: mag_rx=%d, res_scale=%d\n",
580 mag_rx, res_scale);
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400581 return false;
582 }
583
584 /* calculate and quantize Rx IQ correction factors */
585 mag_corr_rx = (-mag_rx * res_scale) / (res_scale + mag_rx);
586 phs_corr_rx = -phs_rx;
587
588 q_q_coff = (mag_corr_rx * 128 / res_scale);
589 q_i_coff = (phs_corr_rx * 256 / res_scale);
590
Joe Perchesd2182b62011-12-15 14:55:53 -0800591 ath_dbg(common, CALIBRATE, "rx chain %d: mag corr=%d phase corr=%d\n",
Joe Perches226afe62010-12-02 19:12:37 -0800592 chain_idx, q_q_coff, q_i_coff);
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400593
594 if (q_i_coff < -63)
595 q_i_coff = -63;
596 if (q_i_coff > 63)
597 q_i_coff = 63;
598 if (q_q_coff < -63)
599 q_q_coff = -63;
600 if (q_q_coff > 63)
601 q_q_coff = 63;
602
603 iqc_coeff[1] = (q_q_coff * 128) + q_i_coff;
604
Joe Perchesd2182b62011-12-15 14:55:53 -0800605 ath_dbg(common, CALIBRATE, "rx chain %d: iq corr coeff=%x\n",
Joe Perches226afe62010-12-02 19:12:37 -0800606 chain_idx, iqc_coeff[1]);
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -0400607
608 return true;
609}
610
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530611static void ar9003_hw_detect_outlier(int *mp_coeff, int nmeasurement,
612 int max_delta)
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800613{
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530614 int mp_max = -64, max_idx = 0;
615 int mp_min = 63, min_idx = 0;
Rajkumar Manoharane948b992011-09-06 21:59:51 +0530616 int mp_avg = 0, i, outlier_idx = 0, mp_count = 0;
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800617
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530618 /* find min/max mismatch across all calibrated gains */
619 for (i = 0; i < nmeasurement; i++) {
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530620 if (mp_coeff[i] > mp_max) {
621 mp_max = mp_coeff[i];
622 max_idx = i;
623 } else if (mp_coeff[i] < mp_min) {
624 mp_min = mp_coeff[i];
625 min_idx = i;
626 }
627 }
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800628
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530629 /* find average (exclude max abs value) */
630 for (i = 0; i < nmeasurement; i++) {
631 if ((abs(mp_coeff[i]) < abs(mp_max)) ||
Rajkumar Manoharane948b992011-09-06 21:59:51 +0530632 (abs(mp_coeff[i]) < abs(mp_min))) {
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530633 mp_avg += mp_coeff[i];
Rajkumar Manoharane948b992011-09-06 21:59:51 +0530634 mp_count++;
635 }
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530636 }
Rajkumar Manoharane948b992011-09-06 21:59:51 +0530637
638 /*
639 * finding mean magnitude/phase if possible, otherwise
640 * just use the last value as the mean
641 */
642 if (mp_count)
643 mp_avg /= mp_count;
644 else
645 mp_avg = mp_coeff[nmeasurement - 1];
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800646
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530647 /* detect outlier */
648 if (abs(mp_max - mp_min) > max_delta) {
649 if (abs(mp_max - mp_avg) > abs(mp_min - mp_avg))
650 outlier_idx = max_idx;
651 else
652 outlier_idx = min_idx;
Rajkumar Manoharane9c10462011-09-15 19:02:25 +0530653
654 mp_coeff[outlier_idx] = mp_avg;
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530655 }
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800656}
657
658static void ar9003_hw_tx_iqcal_load_avg_2_passes(struct ath_hw *ah,
Rajkumar Manoharan34013522011-10-13 11:00:36 +0530659 struct coeff *coeff,
660 bool is_reusable)
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800661{
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800662 int i, im, nmeasurement;
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800663 u32 tx_corr_coeff[MAX_MEASUREMENT][AR9300_MAX_CHAINS];
Rajkumar Manoharan5f0c04e2011-10-13 11:00:35 +0530664 struct ath9k_hw_cal_data *caldata = ah->caldata;
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800665
666 memset(tx_corr_coeff, 0, sizeof(tx_corr_coeff));
667 for (i = 0; i < MAX_MEASUREMENT / 2; i++) {
668 tx_corr_coeff[i * 2][0] = tx_corr_coeff[(i * 2) + 1][0] =
669 AR_PHY_TX_IQCAL_CORR_COEFF_B0(i);
670 if (!AR_SREV_9485(ah)) {
671 tx_corr_coeff[i * 2][1] =
672 tx_corr_coeff[(i * 2) + 1][1] =
673 AR_PHY_TX_IQCAL_CORR_COEFF_B1(i);
674
675 tx_corr_coeff[i * 2][2] =
676 tx_corr_coeff[(i * 2) + 1][2] =
677 AR_PHY_TX_IQCAL_CORR_COEFF_B2(i);
678 }
679 }
680
681 /* Load the average of 2 passes */
Rajkumar Manoharan4fb71752012-06-04 16:28:14 +0530682 for (i = 0; i < AR9300_MAX_CHAINS; i++) {
683 if (!(ah->txchainmask & (1 << i)))
684 continue;
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530685 nmeasurement = REG_READ_FIELD(ah,
686 AR_PHY_TX_IQCAL_STATUS_B0,
687 AR_PHY_CALIBRATED_GAINS_0);
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800688
689 if (nmeasurement > MAX_MEASUREMENT)
690 nmeasurement = MAX_MEASUREMENT;
691
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530692 /* detect outlier only if nmeasurement > 1 */
693 if (nmeasurement > 1) {
694 /* Detect magnitude outlier */
695 ar9003_hw_detect_outlier(coeff->mag_coeff[i],
696 nmeasurement, MAX_MAG_DELTA);
697
698 /* Detect phase outlier */
699 ar9003_hw_detect_outlier(coeff->phs_coeff[i],
700 nmeasurement, MAX_PHS_DELTA);
701 }
702
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800703 for (im = 0; im < nmeasurement; im++) {
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800704
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530705 coeff->iqc_coeff[0] = (coeff->mag_coeff[i][im] & 0x7f) |
706 ((coeff->phs_coeff[i][im] & 0x7f) << 7);
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800707
708 if ((im % 2) == 0)
709 REG_RMW_FIELD(ah, tx_corr_coeff[im][i],
710 AR_PHY_TX_IQCAL_CORR_COEFF_00_COEFF_TABLE,
711 coeff->iqc_coeff[0]);
712 else
713 REG_RMW_FIELD(ah, tx_corr_coeff[im][i],
714 AR_PHY_TX_IQCAL_CORR_COEFF_01_COEFF_TABLE,
715 coeff->iqc_coeff[0]);
Rajkumar Manoharan5f0c04e2011-10-13 11:00:35 +0530716
717 if (caldata)
718 caldata->tx_corr_coeff[im][i] =
719 coeff->iqc_coeff[0];
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800720 }
Rajkumar Manoharan5f0c04e2011-10-13 11:00:35 +0530721 if (caldata)
722 caldata->num_measures[i] = nmeasurement;
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800723 }
724
725 REG_RMW_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_3,
726 AR_PHY_TX_IQCAL_CONTROL_3_IQCORR_EN, 0x1);
727 REG_RMW_FIELD(ah, AR_PHY_RX_IQCAL_CORR_B0,
728 AR_PHY_RX_IQCAL_CORR_B0_LOOPBACK_IQCORR_EN, 0x1);
Rajkumar Manoharan34013522011-10-13 11:00:36 +0530729
Rajkumar Manoharan5f0c04e2011-10-13 11:00:35 +0530730 if (caldata)
Rajkumar Manoharan34013522011-10-13 11:00:36 +0530731 caldata->done_txiqcal_once = is_reusable;
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800732
733 return;
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800734}
735
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530736static bool ar9003_hw_tx_iq_cal_run(struct ath_hw *ah)
Vasanthakumar Thiagarajan0b2084b2010-12-15 07:30:50 -0800737{
738 struct ath_common *common = ath9k_hw_common(ah);
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800739 u8 tx_gain_forced;
740
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800741 tx_gain_forced = REG_READ_FIELD(ah, AR_PHY_TX_FORCED_GAIN,
742 AR_PHY_TXGAIN_FORCE);
743 if (tx_gain_forced)
744 REG_RMW_FIELD(ah, AR_PHY_TX_FORCED_GAIN,
745 AR_PHY_TXGAIN_FORCE, 0);
746
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530747 REG_RMW_FIELD(ah, AR_PHY_TX_IQCAL_START,
748 AR_PHY_TX_IQCAL_START_DO_CAL, 1);
749
750 if (!ath9k_hw_wait(ah, AR_PHY_TX_IQCAL_START,
751 AR_PHY_TX_IQCAL_START_DO_CAL, 0,
752 AH_WAIT_TIMEOUT)) {
Joe Perchesd2182b62011-12-15 14:55:53 -0800753 ath_dbg(common, CALIBRATE, "Tx IQ Cal is not completed\n");
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530754 return false;
755 }
756 return true;
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800757}
758
Rajkumar Manoharan34013522011-10-13 11:00:36 +0530759static void ar9003_hw_tx_iq_cal_post_proc(struct ath_hw *ah, bool is_reusable)
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800760{
761 struct ath_common *common = ath9k_hw_common(ah);
762 const u32 txiqcal_status[AR9300_MAX_CHAINS] = {
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530763 AR_PHY_TX_IQCAL_STATUS_B0,
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800764 AR_PHY_TX_IQCAL_STATUS_B1,
765 AR_PHY_TX_IQCAL_STATUS_B2,
766 };
767 const u_int32_t chan_info_tab[] = {
768 AR_PHY_CHAN_INFO_TAB_0,
769 AR_PHY_CHAN_INFO_TAB_1,
770 AR_PHY_CHAN_INFO_TAB_2,
771 };
772 struct coeff coeff;
773 s32 iq_res[6];
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530774 int i, im, j;
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800775 int nmeasurement;
776
777 for (i = 0; i < AR9300_MAX_CHAINS; i++) {
Rajkumar Manoharan4fb71752012-06-04 16:28:14 +0530778 if (!(ah->txchainmask & (1 << i)))
779 continue;
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800780
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530781 nmeasurement = REG_READ_FIELD(ah,
782 AR_PHY_TX_IQCAL_STATUS_B0,
783 AR_PHY_CALIBRATED_GAINS_0);
784 if (nmeasurement > MAX_MEASUREMENT)
785 nmeasurement = MAX_MEASUREMENT;
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800786
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530787 for (im = 0; im < nmeasurement; im++) {
Joe Perchesd2182b62011-12-15 14:55:53 -0800788 ath_dbg(common, CALIBRATE,
789 "Doing Tx IQ Cal for chain %d\n", i);
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530790
791 if (REG_READ(ah, txiqcal_status[i]) &
792 AR_PHY_TX_IQCAL_STATUS_FAILED) {
Joe Perchesd2182b62011-12-15 14:55:53 -0800793 ath_dbg(common, CALIBRATE,
794 "Tx IQ Cal failed for chain %d\n", i);
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530795 goto tx_iqcal_fail;
796 }
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800797
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530798 for (j = 0; j < 3; j++) {
799 u32 idx = 2 * j, offset = 4 * (3 * im + j);
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800800
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530801 REG_RMW_FIELD(ah,
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800802 AR_PHY_CHAN_INFO_MEMORY,
803 AR_PHY_CHAN_INFO_TAB_S2_READ,
804 0);
805
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530806 /* 32 bits */
807 iq_res[idx] = REG_READ(ah,
808 chan_info_tab[i] +
809 offset);
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800810
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530811 REG_RMW_FIELD(ah,
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800812 AR_PHY_CHAN_INFO_MEMORY,
813 AR_PHY_CHAN_INFO_TAB_S2_READ,
814 1);
815
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530816 /* 16 bits */
817 iq_res[idx + 1] = 0xffff & REG_READ(ah,
818 chan_info_tab[i] + offset);
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800819
Joe Perchesd2182b62011-12-15 14:55:53 -0800820 ath_dbg(common, CALIBRATE,
821 "IQ_RES[%d]=0x%x IQ_RES[%d]=0x%x\n",
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530822 idx, iq_res[idx], idx + 1,
823 iq_res[idx + 1]);
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800824 }
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530825
826 if (!ar9003_hw_calc_iq_corr(ah, i, iq_res,
827 coeff.iqc_coeff)) {
Joe Perchesd2182b62011-12-15 14:55:53 -0800828 ath_dbg(common, CALIBRATE,
829 "Failed in calculation of IQ correction\n");
Rajkumar Manoharan3782c692011-04-24 21:34:39 +0530830 goto tx_iqcal_fail;
831 }
832
833 coeff.mag_coeff[i][im] = coeff.iqc_coeff[0] & 0x7f;
834 coeff.phs_coeff[i][im] =
835 (coeff.iqc_coeff[0] >> 7) & 0x7f;
836
837 if (coeff.mag_coeff[i][im] > 63)
838 coeff.mag_coeff[i][im] -= 128;
839 if (coeff.phs_coeff[i][im] > 63)
840 coeff.phs_coeff[i][im] -= 128;
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800841 }
842 }
Rajkumar Manoharan4fb71752012-06-04 16:28:14 +0530843 ar9003_hw_tx_iqcal_load_avg_2_passes(ah, &coeff, is_reusable);
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800844
845 return;
846
847tx_iqcal_fail:
Joe Perchesd2182b62011-12-15 14:55:53 -0800848 ath_dbg(common, CALIBRATE, "Tx IQ Cal failed\n");
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -0800849 return;
850}
Rajkumar Manoharan5f0c04e2011-10-13 11:00:35 +0530851
852static void ar9003_hw_tx_iq_cal_reload(struct ath_hw *ah)
853{
854 struct ath9k_hw_cal_data *caldata = ah->caldata;
855 u32 tx_corr_coeff[MAX_MEASUREMENT][AR9300_MAX_CHAINS];
856 int i, im;
857
858 memset(tx_corr_coeff, 0, sizeof(tx_corr_coeff));
859 for (i = 0; i < MAX_MEASUREMENT / 2; i++) {
860 tx_corr_coeff[i * 2][0] = tx_corr_coeff[(i * 2) + 1][0] =
861 AR_PHY_TX_IQCAL_CORR_COEFF_B0(i);
862 if (!AR_SREV_9485(ah)) {
863 tx_corr_coeff[i * 2][1] =
864 tx_corr_coeff[(i * 2) + 1][1] =
865 AR_PHY_TX_IQCAL_CORR_COEFF_B1(i);
866
867 tx_corr_coeff[i * 2][2] =
868 tx_corr_coeff[(i * 2) + 1][2] =
869 AR_PHY_TX_IQCAL_CORR_COEFF_B2(i);
870 }
871 }
872
873 for (i = 0; i < AR9300_MAX_CHAINS; i++) {
874 if (!(ah->txchainmask & (1 << i)))
875 continue;
876
877 for (im = 0; im < caldata->num_measures[i]; im++) {
878 if ((im % 2) == 0)
879 REG_RMW_FIELD(ah, tx_corr_coeff[im][i],
880 AR_PHY_TX_IQCAL_CORR_COEFF_00_COEFF_TABLE,
881 caldata->tx_corr_coeff[im][i]);
882 else
883 REG_RMW_FIELD(ah, tx_corr_coeff[im][i],
884 AR_PHY_TX_IQCAL_CORR_COEFF_01_COEFF_TABLE,
885 caldata->tx_corr_coeff[im][i]);
886 }
887 }
888
889 REG_RMW_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_3,
890 AR_PHY_TX_IQCAL_CONTROL_3_IQCORR_EN, 0x1);
891 REG_RMW_FIELD(ah, AR_PHY_RX_IQCAL_CORR_B0,
892 AR_PHY_RX_IQCAL_CORR_B0_LOOPBACK_IQCORR_EN, 0x1);
893}
894
Rajkumar Manoharan0b6eb362012-11-09 14:51:30 +0530895static void ar9003_hw_manual_peak_cal(struct ath_hw *ah, u8 chain, bool is_2g)
896{
897 int offset[8], total = 0, test;
898 int agc_out, i;
899
900 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_GAINSTAGES(chain),
901 AR_PHY_65NM_RXRF_GAINSTAGES_RX_OVERRIDE, 0x1);
902 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_GAINSTAGES(chain),
903 AR_PHY_65NM_RXRF_GAINSTAGES_LNAON_CALDC, 0x0);
904 if (is_2g)
905 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_GAINSTAGES(chain),
906 AR_PHY_65NM_RXRF_GAINSTAGES_LNA2G_GAIN_OVR, 0x0);
907 else
908 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_GAINSTAGES(chain),
909 AR_PHY_65NM_RXRF_GAINSTAGES_LNA5G_GAIN_OVR, 0x0);
910
911 REG_RMW_FIELD(ah, AR_PHY_65NM_RXTX2(chain),
912 AR_PHY_65NM_RXTX2_RXON_OVR, 0x1);
913 REG_RMW_FIELD(ah, AR_PHY_65NM_RXTX2(chain),
914 AR_PHY_65NM_RXTX2_RXON, 0x0);
915
916 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_AGC(chain),
917 AR_PHY_65NM_RXRF_AGC_AGC_OVERRIDE, 0x1);
918 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_AGC(chain),
919 AR_PHY_65NM_RXRF_AGC_AGC_ON_OVR, 0x1);
920 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_AGC(chain),
921 AR_PHY_65NM_RXRF_AGC_AGC_CAL_OVR, 0x1);
922 if (is_2g)
923 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_AGC(chain),
924 AR_PHY_65NM_RXRF_AGC_AGC2G_DBDAC_OVR, 0x0);
925 else
926 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_AGC(chain),
927 AR_PHY_65NM_RXRF_AGC_AGC5G_DBDAC_OVR, 0x0);
928
929 for (i = 6; i > 0; i--) {
930 offset[i] = BIT(i - 1);
931 test = total + offset[i];
932
933 if (is_2g)
934 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_AGC(chain),
935 AR_PHY_65NM_RXRF_AGC_AGC2G_CALDAC_OVR,
936 test);
937 else
938 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_AGC(chain),
939 AR_PHY_65NM_RXRF_AGC_AGC5G_CALDAC_OVR,
940 test);
941 udelay(100);
942 agc_out = REG_READ_FIELD(ah, AR_PHY_65NM_RXRF_AGC(chain),
943 AR_PHY_65NM_RXRF_AGC_AGC_OUT);
944 offset[i] = (agc_out) ? 0 : 1;
945 total += (offset[i] << (i - 1));
946 }
947
948 if (is_2g)
949 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_AGC(chain),
950 AR_PHY_65NM_RXRF_AGC_AGC2G_CALDAC_OVR, total);
951 else
952 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_AGC(chain),
953 AR_PHY_65NM_RXRF_AGC_AGC5G_CALDAC_OVR, total);
954
955 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_GAINSTAGES(chain),
956 AR_PHY_65NM_RXRF_GAINSTAGES_RX_OVERRIDE, 0);
957 REG_RMW_FIELD(ah, AR_PHY_65NM_RXTX2(chain),
958 AR_PHY_65NM_RXTX2_RXON_OVR, 0);
959 REG_RMW_FIELD(ah, AR_PHY_65NM_RXRF_AGC(chain),
960 AR_PHY_65NM_RXRF_AGC_AGC_CAL_OVR, 0);
961}
962
Sujith Manoharan96da6fd2013-01-07 14:43:33 +0530963static void ar9003_hw_do_manual_peak_cal(struct ath_hw *ah,
964 struct ath9k_channel *chan)
965{
966 int i;
967
968 if (!AR_SREV_9462(ah) && !AR_SREV_9565(ah))
969 return;
970
971 for (i = 0; i < AR9300_MAX_CHAINS; i++) {
972 if (!(ah->rxchainmask & (1 << i)))
973 continue;
974 ar9003_hw_manual_peak_cal(ah, i, IS_CHAN_2GHZ(chan));
975 }
976}
977
978static void ar9003_hw_cl_cal_post_proc(struct ath_hw *ah, bool is_reusable)
979{
980 u32 cl_idx[AR9300_MAX_CHAINS] = { AR_PHY_CL_TAB_0,
981 AR_PHY_CL_TAB_1,
982 AR_PHY_CL_TAB_2 };
983 struct ath9k_hw_cal_data *caldata = ah->caldata;
984 bool txclcal_done = false;
985 int i, j;
986
987 if (!caldata || !(ah->enabled_cals & TX_CL_CAL))
988 return;
989
990 txclcal_done = !!(REG_READ(ah, AR_PHY_AGC_CONTROL) &
991 AR_PHY_AGC_CONTROL_CLC_SUCCESS);
992
993 if (caldata->done_txclcal_once) {
994 for (i = 0; i < AR9300_MAX_CHAINS; i++) {
995 if (!(ah->txchainmask & (1 << i)))
996 continue;
997 for (j = 0; j < MAX_CL_TAB_ENTRY; j++)
998 REG_WRITE(ah, CL_TAB_ENTRY(cl_idx[i]),
999 caldata->tx_clcal[i][j]);
1000 }
1001 } else if (is_reusable && txclcal_done) {
1002 for (i = 0; i < AR9300_MAX_CHAINS; i++) {
1003 if (!(ah->txchainmask & (1 << i)))
1004 continue;
1005 for (j = 0; j < MAX_CL_TAB_ENTRY; j++)
1006 caldata->tx_clcal[i][j] =
1007 REG_READ(ah, CL_TAB_ENTRY(cl_idx[i]));
1008 }
1009 caldata->done_txclcal_once = true;
1010 }
1011}
1012
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -04001013static bool ar9003_hw_init_cal(struct ath_hw *ah,
1014 struct ath9k_channel *chan)
1015{
1016 struct ath_common *common = ath9k_hw_common(ah);
Rajkumar Manoharan5f0c04e2011-10-13 11:00:35 +05301017 struct ath9k_hw_cal_data *caldata = ah->caldata;
Sujith Manoharan96da6fd2013-01-07 14:43:33 +05301018 bool txiqcal_done = false;
Rajkumar Manoharan324c74a2011-10-13 11:00:41 +05301019 bool is_reusable = true, status = true;
Sujith Manoharandfcca602013-01-07 13:53:47 +05301020 bool run_rtt_cal = false, run_agc_cal, sep_iq_cal = false;
Rajkumar Manoharan324c74a2011-10-13 11:00:41 +05301021 bool rtt = !!(ah->caps.hw_caps & ATH9K_HW_CAP_RTT);
1022 u32 agc_ctrl = 0, agc_supp_cals = AR_PHY_AGC_CONTROL_OFFSET_CAL |
1023 AR_PHY_AGC_CONTROL_FLTR_CAL |
1024 AR_PHY_AGC_CONTROL_PKDET_CAL;
Rajkumar Manoharan77a5a662011-10-13 11:00:37 +05301025
Felix Fietkau4a8f1992013-01-20 21:55:20 +01001026 ar9003_hw_set_chain_masks(ah, ah->caps.rx_chainmask, ah->caps.tx_chainmask);
1027
Rajkumar Manoharan324c74a2011-10-13 11:00:41 +05301028 if (rtt) {
1029 if (!ar9003_hw_rtt_restore(ah, chan))
1030 run_rtt_cal = true;
1031
Sujith Manoharan8a905552012-05-04 13:23:59 +05301032 if (run_rtt_cal)
1033 ath_dbg(common, CALIBRATE, "RTT calibration to be done\n");
Rajkumar Manoharan324c74a2011-10-13 11:00:41 +05301034 }
Sujith Manoharan8a905552012-05-04 13:23:59 +05301035
Rajkumar Manoharan324c74a2011-10-13 11:00:41 +05301036 run_agc_cal = run_rtt_cal;
1037
1038 if (run_rtt_cal) {
1039 ar9003_hw_rtt_enable(ah);
1040 ar9003_hw_rtt_set_mask(ah, 0x00);
1041 ar9003_hw_rtt_clear_hist(ah);
1042 }
1043
1044 if (rtt && !run_rtt_cal) {
1045 agc_ctrl = REG_READ(ah, AR_PHY_AGC_CONTROL);
1046 agc_supp_cals &= agc_ctrl;
1047 agc_ctrl &= ~(AR_PHY_AGC_CONTROL_OFFSET_CAL |
1048 AR_PHY_AGC_CONTROL_FLTR_CAL |
1049 AR_PHY_AGC_CONTROL_PKDET_CAL);
1050 REG_WRITE(ah, AR_PHY_AGC_CONTROL, agc_ctrl);
1051 }
1052
Rajkumar Manoharan8ad74c42011-10-13 11:00:38 +05301053 if (ah->enabled_cals & TX_CL_CAL) {
Rajkumar Manoharan77a5a662011-10-13 11:00:37 +05301054 if (caldata && caldata->done_txclcal_once)
1055 REG_CLR_BIT(ah, AR_PHY_CL_CAL_CTL,
1056 AR_PHY_CL_CAL_ENABLE);
Rajkumar Manoharan324c74a2011-10-13 11:00:41 +05301057 else {
Rajkumar Manoharan77a5a662011-10-13 11:00:37 +05301058 REG_SET_BIT(ah, AR_PHY_CL_CAL_CTL,
1059 AR_PHY_CL_CAL_ENABLE);
Rajkumar Manoharan324c74a2011-10-13 11:00:41 +05301060 run_agc_cal = true;
1061 }
Rajkumar Manoharan77a5a662011-10-13 11:00:37 +05301062 }
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -04001063
Sujith Manoharan4656b8f2013-01-07 13:53:46 +05301064 if ((IS_CHAN_HALF_RATE(chan) || IS_CHAN_QUARTER_RATE(chan)) ||
1065 !(ah->enabled_cals & TX_IQ_CAL))
Rajkumar Manoharan8ad74c42011-10-13 11:00:38 +05301066 goto skip_tx_iqcal;
1067
Luis R. Rodriguezc5395b62010-05-19 16:45:50 -04001068 /* Do Tx IQ Calibration */
Rajkumar Manoharan3782c692011-04-24 21:34:39 +05301069 REG_RMW_FIELD(ah, AR_PHY_TX_IQCAL_CONTROL_1,
1070 AR_PHY_TX_IQCAL_CONTROL_1_IQCORR_I_Q_COFF_DELPT,
1071 DELPT);
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -08001072
Rajkumar Manoharan3782c692011-04-24 21:34:39 +05301073 /*
1074 * For AR9485 or later chips, TxIQ cal runs as part of
1075 * AGC calibration
1076 */
Rajkumar Manoharan8ad74c42011-10-13 11:00:38 +05301077 if (ah->enabled_cals & TX_IQ_ON_AGC_CAL) {
Rajkumar Manoharan5f0c04e2011-10-13 11:00:35 +05301078 if (caldata && !caldata->done_txiqcal_once)
1079 REG_SET_BIT(ah, AR_PHY_TX_IQCAL_CONTROL_0,
1080 AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL);
1081 else
1082 REG_CLR_BIT(ah, AR_PHY_TX_IQCAL_CONTROL_0,
1083 AR_PHY_TX_IQCAL_CONTROL_0_ENABLE_TXIQ_CAL);
Rajkumar Manoharan324c74a2011-10-13 11:00:41 +05301084 txiqcal_done = run_agc_cal = true;
Sujith Manoharandfcca602013-01-07 13:53:47 +05301085 } else if (caldata && !caldata->done_txiqcal_once) {
Rajkumar Manoharan324c74a2011-10-13 11:00:41 +05301086 run_agc_cal = true;
Sujith Manoharandfcca602013-01-07 13:53:47 +05301087 sep_iq_cal = true;
1088 }
Rajkumar Manoharan324c74a2011-10-13 11:00:41 +05301089
Sujith Manoharandfcca602013-01-07 13:53:47 +05301090skip_tx_iqcal:
Sujith Manoharan5955b2b2012-06-04 16:27:30 +05301091 if (ath9k_hw_mci_is_enabled(ah) && IS_CHAN_2GHZ(chan) && run_agc_cal)
Sujith Manoharanf2f408e2012-02-22 12:41:06 +05301092 ar9003_mci_init_cal_req(ah, &is_reusable);
Mohammed Shafi Shajakhan3ebfcdc2011-11-30 10:41:26 +05301093
Sujith Manoharandfcca602013-01-07 13:53:47 +05301094 if (sep_iq_cal) {
1095 txiqcal_done = ar9003_hw_tx_iq_cal_run(ah);
1096 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_DIS);
1097 udelay(5);
1098 REG_WRITE(ah, AR_PHY_ACTIVE, AR_PHY_ACTIVE_EN);
1099 }
Luis R. Rodriguezc5395b62010-05-19 16:45:50 -04001100
Rajkumar Manoharana126ff52011-10-13 11:00:42 +05301101 if (run_agc_cal || !(ah->ah_flags & AH_FASTCC)) {
Rajkumar Manoharan324c74a2011-10-13 11:00:41 +05301102 /* Calibrate the AGC */
1103 REG_WRITE(ah, AR_PHY_AGC_CONTROL,
1104 REG_READ(ah, AR_PHY_AGC_CONTROL) |
1105 AR_PHY_AGC_CONTROL_CAL);
1106
1107 /* Poll for offset calibration complete */
1108 status = ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL,
1109 AR_PHY_AGC_CONTROL_CAL,
1110 0, AH_WAIT_TIMEOUT);
Sujith Manoharan96da6fd2013-01-07 14:43:33 +05301111
1112 ar9003_hw_do_manual_peak_cal(ah, chan);
Rajkumar Manoharan324c74a2011-10-13 11:00:41 +05301113 }
Mohammed Shafi Shajakhan3ebfcdc2011-11-30 10:41:26 +05301114
Sujith Manoharan5955b2b2012-06-04 16:27:30 +05301115 if (ath9k_hw_mci_is_enabled(ah) && IS_CHAN_2GHZ(chan) && run_agc_cal)
Sujith Manoharanf2f408e2012-02-22 12:41:06 +05301116 ar9003_mci_init_cal_done(ah);
Mohammed Shafi Shajakhan3ebfcdc2011-11-30 10:41:26 +05301117
Rajkumar Manoharan324c74a2011-10-13 11:00:41 +05301118 if (rtt && !run_rtt_cal) {
1119 agc_ctrl |= agc_supp_cals;
1120 REG_WRITE(ah, AR_PHY_AGC_CONTROL, agc_ctrl);
1121 }
1122
1123 if (!status) {
1124 if (run_rtt_cal)
1125 ar9003_hw_rtt_disable(ah);
1126
Joe Perchesd2182b62011-12-15 14:55:53 -08001127 ath_dbg(common, CALIBRATE,
1128 "offset calibration failed to complete in 1ms; noisy environment?\n");
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -04001129 return false;
1130 }
1131
Rajkumar Manoharan3782c692011-04-24 21:34:39 +05301132 if (txiqcal_done)
Rajkumar Manoharan34013522011-10-13 11:00:36 +05301133 ar9003_hw_tx_iq_cal_post_proc(ah, is_reusable);
Rajkumar Manoharan5f0c04e2011-10-13 11:00:35 +05301134 else if (caldata && caldata->done_txiqcal_once)
1135 ar9003_hw_tx_iq_cal_reload(ah);
Vasanthakumar Thiagarajan858b7e32010-12-06 04:27:56 -08001136
Sujith Manoharan96da6fd2013-01-07 14:43:33 +05301137 ar9003_hw_cl_cal_post_proc(ah, is_reusable);
Rajkumar Manoharan77a5a662011-10-13 11:00:37 +05301138
Rajkumar Manoharan324c74a2011-10-13 11:00:41 +05301139 if (run_rtt_cal && caldata) {
Sujith Manoharan8a905552012-05-04 13:23:59 +05301140 if (is_reusable) {
1141 if (!ath9k_hw_rfbus_req(ah))
1142 ath_err(ath9k_hw_common(ah),
1143 "Could not stop baseband\n");
1144 else
1145 ar9003_hw_rtt_fill_hist(ah);
Rajkumar Manoharan324c74a2011-10-13 11:00:41 +05301146
Sujith Manoharan8a905552012-05-04 13:23:59 +05301147 ath9k_hw_rfbus_done(ah);
Rajkumar Manoharan324c74a2011-10-13 11:00:41 +05301148 }
1149
1150 ar9003_hw_rtt_disable(ah);
1151 }
1152
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -04001153 /* Initialize list pointers */
1154 ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL;
1155
Sujith Manoharanb6869292013-01-03 12:21:21 +05301156 INIT_CAL(&ah->iq_caldata);
1157 INSERT_CAL(ah, &ah->iq_caldata);
1158 ath_dbg(common, CALIBRATE, "enabling IQ Calibration\n");
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -04001159
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -04001160 /* Initialize current pointer to first element in list */
1161 ah->cal_list_curr = ah->cal_list;
1162
1163 if (ah->cal_list_curr)
1164 ath9k_hw_reset_calibration(ah, ah->cal_list_curr);
1165
Rajkumar Manoharan5f0c04e2011-10-13 11:00:35 +05301166 if (caldata)
1167 caldata->CalValid = 0;
Luis R. Rodriguezdf23aca2010-04-15 17:39:11 -04001168
1169 return true;
Luis R. Rodriguez77d6d392010-04-15 17:39:09 -04001170}
1171
Luis R. Rodriguez795f5e22010-04-15 17:39:00 -04001172void ar9003_hw_attach_calib_ops(struct ath_hw *ah)
1173{
1174 struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
1175 struct ath_hw_ops *ops = ath9k_hw_ops(ah);
1176
1177 priv_ops->init_cal_settings = ar9003_hw_init_cal_settings;
1178 priv_ops->init_cal = ar9003_hw_init_cal;
1179 priv_ops->setup_calibration = ar9003_hw_setup_calibration;
Luis R. Rodriguez795f5e22010-04-15 17:39:00 -04001180
1181 ops->calibrate = ar9003_hw_calibrate;
1182}