26 #define AR9285_CLCAL_REDO_THRESH 1 39 switch (
ah->supp_cals & cal_type) {
67 "starting IQ Mismatch Calibration\n");
72 "starting ADC Gain Calibration\n");
77 "starting ADC DC Calibration\n");
100 if (
ah->cal_samples >=
102 int i, numChains = 0;
104 if (rxchainmask & (1 << i))
128 ah->totalPowerMeasI[i] +=
130 ah->totalPowerMeasQ[i] +=
132 ah->totalIqCorrMeas[i] +=
135 "%d: Chn %d pmi=0x%08x;pmq=0x%08x;iqcm=0x%08x;\n",
136 ah->cal_samples, i,
ah->totalPowerMeasI[i],
137 ah->totalPowerMeasQ[i],
138 ah->totalIqCorrMeas[i]);
147 ah->totalAdcIOddPhase[i] +=
149 ah->totalAdcIEvenPhase[i] +=
151 ah->totalAdcQOddPhase[i] +=
153 ah->totalAdcQEvenPhase[i] +=
157 "%d: Chn %d oddi=0x%08x; eveni=0x%08x; oddq=0x%08x; evenq=0x%08x;\n",
159 ah->totalAdcIOddPhase[i],
160 ah->totalAdcIEvenPhase[i],
161 ah->totalAdcQOddPhase[i],
162 ah->totalAdcQEvenPhase[i]);
171 ah->totalAdcDcOffsetIOddPhase[i] +=
173 ah->totalAdcDcOffsetIEvenPhase[i] +=
175 ah->totalAdcDcOffsetQOddPhase[i] +=
177 ah->totalAdcDcOffsetQEvenPhase[i] +=
181 "%d: Chn %d oddi=0x%08x; eveni=0x%08x; oddq=0x%08x; evenq=0x%08x;\n",
183 ah->totalAdcDcOffsetIOddPhase[i],
184 ah->totalAdcDcOffsetIEvenPhase[i],
185 ah->totalAdcDcOffsetQOddPhase[i],
186 ah->totalAdcDcOffsetQEvenPhase[i]);
192 u32 powerMeasQ, powerMeasI, iqCorrMeas;
193 u32 qCoffDenom, iCoffDenom;
197 for (i = 0; i < numChains; i++) {
198 powerMeasI =
ah->totalPowerMeasI[i];
199 powerMeasQ =
ah->totalPowerMeasQ[i];
200 iqCorrMeas =
ah->totalIqCorrMeas[i];
203 "Starting IQ Cal and Correction for Chain %d\n",
207 "Orignal: Chn %diq_corr_meas = 0x%08x\n",
208 i,
ah->totalIqCorrMeas[i]);
212 if (iqCorrMeas > 0x80000000) {
213 iqCorrMeas = (0xffffffff - iqCorrMeas) + 1;
218 "Chn %d pwr_meas_i = 0x%08x\n", i, powerMeasI);
220 "Chn %d pwr_meas_q = 0x%08x\n", i, powerMeasQ);
221 DBG2(
"ath9k: iqCorrNeg is 0x%08x\n",
224 iCoffDenom = (powerMeasI / 2 + powerMeasQ / 2) / 128;
225 qCoffDenom = powerMeasQ / 64;
227 if ((powerMeasQ != 0) && (iCoffDenom != 0) &&
229 iCoff = iqCorrMeas / iCoffDenom;
230 qCoff = powerMeasI / qCoffDenom - 64;
232 "Chn %d iCoff = 0x%08x\n", i,
iCoff);
234 "Chn %d qCoff = 0x%08x\n", i,
qCoff);
238 "New: Chn %d iCoff = 0x%08x\n", i,
iCoff);
239 if (iqCorrNeg == 0x0)
244 else if (
qCoff <= -16)
248 "Chn %d : iCoff = 0x%x qCoff = 0x%x\n",
258 "IQ Cal and Correction done for Chain %d\n",
269 u32 iOddMeasOffset, iEvenMeasOffset, qOddMeasOffset, qEvenMeasOffset;
270 u32 qGainMismatch, iGainMismatch,
val, i;
272 for (i = 0; i < numChains; i++) {
273 iOddMeasOffset =
ah->totalAdcIOddPhase[i];
274 iEvenMeasOffset =
ah->totalAdcIEvenPhase[i];
275 qOddMeasOffset =
ah->totalAdcQOddPhase[i];
276 qEvenMeasOffset =
ah->totalAdcQEvenPhase[i];
279 "Starting ADC Gain Cal for Chain %d\n", i);
282 "Chn %d pwr_meas_odd_i = 0x%08x\n", i,
285 "Chn %d pwr_meas_even_i = 0x%08x\n", i,
288 "Chn %d pwr_meas_odd_q = 0x%08x\n", i,
291 "Chn %d pwr_meas_even_q = 0x%08x\n", i,
294 if (iOddMeasOffset != 0 && qEvenMeasOffset != 0) {
296 ((iEvenMeasOffset * 32) /
297 iOddMeasOffset) & 0x3f;
299 ((qOddMeasOffset * 32) /
300 qEvenMeasOffset) & 0x3f;
303 "Chn %d gain_mismatch_i = 0x%08x\n", i,
306 "Chn %d gain_mismatch_q = 0x%08x\n", i,
311 val |= (qGainMismatch) | (iGainMismatch << 6);
315 "ADC Gain Cal done for Chain %d\n", i);
326 u32 iOddMeasOffset, iEvenMeasOffset,
val, i;
327 int32_t qOddMeasOffset, qEvenMeasOffset, qDcMismatch, iDcMismatch;
329 ah->cal_list_curr->calData;
333 for (i = 0; i < numChains; i++) {
334 iOddMeasOffset =
ah->totalAdcDcOffsetIOddPhase[i];
335 iEvenMeasOffset =
ah->totalAdcDcOffsetIEvenPhase[i];
336 qOddMeasOffset =
ah->totalAdcDcOffsetQOddPhase[i];
337 qEvenMeasOffset =
ah->totalAdcDcOffsetQEvenPhase[i];
340 "Starting ADC DC Offset Cal for Chain %d\n", i);
343 "Chn %d pwr_meas_odd_i = %d\n", i,
346 "Chn %d pwr_meas_even_i = %d\n", i,
349 "Chn %d pwr_meas_odd_q = %d\n", i,
352 "Chn %d pwr_meas_even_q = %d\n", i,
355 iDcMismatch = (((iEvenMeasOffset - iOddMeasOffset) * 2) /
357 qDcMismatch = (((qOddMeasOffset - qEvenMeasOffset) * 2) /
361 "Chn %d dc_offset_mismatch_i = 0x%08x\n", i,
364 "Chn %d dc_offset_mismatch_q = 0x%08x\n", i,
369 val |= (qDcMismatch << 12) | (iDcMismatch << 21);
373 "ADC DC Offset Cal done for Chain %d\n", i);
384 int32_t delta, currPDADC, slope;
389 if (
ah->initPDADC == 0 || currPDADC == 0) {
402 delta = ((currPDADC -
ah->initPDADC)*4) / slope;
414 int delta, currPDADC, regval;
419 if (
ah->initPDADC == 0 || currPDADC == 0)
423 delta = (currPDADC -
ah->initPDADC + 4) / 8;
425 delta = (currPDADC -
ah->initPDADC + 5) / 10;
427 if (delta !=
ah->PDADCdelta) {
428 ah->PDADCdelta = delta;
430 regval =
ah->originalGain[i] - delta;
463 regVal |= (0x1 << 27);
505 for (i = 6; i > 0; i--) {
507 regVal |= (1 << (20 + i));
511 regVal &= (~(0x1 << (20 + i)));
517 regVal = (regVal >> 20) & 0x7f;
520 if ((!is_reset) && ((
unsigned int)
ah->pacal_info.prev_offset == regVal)) {
522 ah->pacal_info.max_skipcount =
523 2 *
ah->pacal_info.max_skipcount;
524 ah->pacal_info.skipcount =
ah->pacal_info.max_skipcount;
526 ah->pacal_info.max_skipcount = 1;
527 ah->pacal_info.skipcount = 0;
528 ah->pacal_info.prev_offset = regVal;
537 regVal &= (~(0x1 << 27));
550 int offset, offs_6_1, offs_0;
551 u32 ccomp_org, reg_field;
562 DBG2(
"ath9k: Running PA Calibration\n");
576 regVal |= (0x1 << 27);
599 for (i = 6; i > 0; i--) {
601 regVal |= (1 << (19 + i));
605 regVal &= (~(0x1 << (19 + i)));
607 regVal |= (reg_field << (19 + i));
618 offset = (offs_6_1<<1) | offs_0;
623 if ((!is_reset) && (
ah->pacal_info.prev_offset ==
offset)) {
625 ah->pacal_info.max_skipcount =
626 2 *
ah->pacal_info.max_skipcount;
627 ah->pacal_info.skipcount =
ah->pacal_info.max_skipcount;
629 ah->pacal_info.max_skipcount = 1;
630 ah->pacal_info.skipcount = 0;
631 ah->pacal_info.prev_offset =
offset;
641 regVal &= (~(0x1 << 27));
653 if (is_reset || !
ah->pacal_info.skipcount)
656 ah->pacal_info.skipcount--;
658 if (is_reset || !
ah->pacal_info.skipcount)
661 ah->pacal_info.skipcount--;
680 int nfcal, nfcal_pending = 0;
684 nfcal_pending =
ah->caldata->nfcal_pending;
686 if (currCal && !nfcal &&
690 rxchainmask, currCal);
692 ah->cal_list_curr = currCal = currCal->
calNext;
702 if (longcal || nfcal_pending) {
742 "offset calibration failed to complete in 1ms; noisy environment?\n");
756 "offset calibration failed to complete in 1ms; noisy environment?\n");
771 uint32_t clc_gain, gain_mask = 0, clc_num = 0;
785 for (i = 0; i < (txgain_max+1); i++) {
788 if (!(gain_mask & (1 << clc_gain))) {
789 gain_mask |= (1 << clc_gain);
794 for (i = 0; i < clc_num; i++) {
805 total_num = i0_num + q0_num;
850 "offset calibration failed to complete in 1ms; noisy environment?\n");
870 ah->caldata->nfcal_pending = 1;
872 ah->cal_list =
ah->cal_list_last =
ah->cal_list_curr =
NULL;
888 "enabling ADC Gain Calibration.\n");
895 "enabling ADC DC Calibration.\n");
902 "enabling IQ Calibration.\n");
905 ah->cal_list_curr =
ah->cal_list;
907 if (
ah->cal_list_curr)
912 ah->caldata->CalValid = 0;
971 ah->adcgain_caldata.calData =
973 ah->adcdc_caldata.calData =
977 ah->adcgain_caldata.calData =
979 ah->adcdc_caldata.calData =
static const struct ath9k_percal_data iq_cal_multi_sample
#define AR_PHY_CAL_MEAS_3(_i)
static void ar9271_hw_pa_cal(struct ath_hw *ah, int is_reset)
#define AR9285_AN_RF2G2_OFFCAL
#define AR_SREV_9287_11_OR_LATER(_ah)
#define AR_PHY_TIMING_CTRL4_IQCORR_ENABLE
#define AR9285_AN_RF2G1_ENPACAL
static void ar9280_hw_olc_temp_compensation(struct ath_hw *ah)
#define AR_PHY_CALMODE_ADC_DC_PER
#define AR9285_RF2G5_IC50TX_SET
#define AR_SREV_9280_20_OR_LATER(_ah)
#define AR_PHY_TX_PWRCTRL4
#define AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF
static int ar9002_hw_init_cal(struct ath_hw *ah, struct ath9k_channel *chan)
static const struct ath9k_percal_data adc_gain_cal_multi_sample
#define AR9285_RF2G5_IC50TX
#define AR_PHY_PARALLEL_CAL_ENABLE
#define AR9285_AN_RF2G8_PADRVGN2TAB0
#define AR9280_TX_GAIN_TABLE_SIZE
static void ar9285_hw_pa_cal(struct ath_hw *ah, int is_reset)
static void ar9002_hw_adc_gaincal_collect(struct ath_hw *ah)
#define AR_PHY_TX_GAIN_TBL1
#define AR9285_AN_RF2G1_PDPADRV1
void(* calPostProc)(struct ath_hw *, u8)
void ath9k_hw_start_nfcal(struct ath_hw *ah, int update)
#define AR_PHY_CL_CAL_CTL
#define AR9285_AN_RF2G1_PDPADRV2
#define AR_PHY_TX_GAIN_CLC
#define AR9285_AN_RF2G1_PDPAOUT
#define REG_CLR_BIT(_a, _r, _f)
void(* init_cal_settings)(struct ath_hw *ah)
static void ar9002_hw_iqcalibrate(struct ath_hw *ah, u8 numChains)
#define REGWRITE_BUFFER_FLUSH(_ah)
static void ar9002_hw_adc_gaincal_calibrate(struct ath_hw *ah, u8 numChains)
struct ath9k_cal_list * calNext
struct ath_hw_private_ops - callbacks used internally by hardware code
#define AR9285_AN_RF2G7_PADRVGN2TAB0
static void ar9002_hw_setup_calibration(struct ath_hw *ah, struct ath9k_cal_list *currCal)
#define AR_SREV_9285(_ah)
void(* setup_calibration)(struct ath_hw *ah, struct ath9k_cal_list *currCal)
#define AR9285_AN_RF2G3_PDVCCOMP
#define AR5416_EEP_TXGAIN_HIGH_POWER
#define OLC_FOR_AR9287_10_LATER
static int ar9002_hw_per_calibration(struct ath_hw *ah, struct ath9k_channel *ichan __unused, u8 rxchainmask, struct ath9k_cal_list *currCal)
void ar9002_hw_attach_calib_ops(struct ath_hw *ah)
#define AR_PHY_AGC_CONTROL_CAL
#define REG_RMW_FIELD(_a, _r, _f, _v)
#define AR_PHY_NEW_ADC_DC_OFFSET_CORR_ENABLE
static void ar9002_hw_adc_dccal_collect(struct ath_hw *ah)
#define AR_SREV_9287(_ah)
static void ar9002_hw_olc_temp_compensation(struct ath_hw *ah)
#define AR_PHY_ADC_CTL_OFF_PWDADC
static int ar9285_hw_cl_cal(struct ath_hw *ah, struct ath9k_channel *chan)
#define AR9285_RF2G5_IC50TX_XE_SET
#define INIT_CAL(_perCal)
#define AR_PHY_TIMING_CTRL4(_i)
#define __unused
Declare a variable or data structure as unused.
#define AR9271_AN_RF2G3_CCOMP
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan)
#define AR_PHY_AGC_CONTROL
static int ar9002_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan, u8 rxchainmask, int longcal)
static const struct ath9k_percal_data adc_dc_cal_multi_sample
void(* calCollect)(struct ath_hw *)
#define AR_PHY_TX_PWRCTRL_OLPC_TEMP_COMP
static void ar9002_hw_pa_cal(struct ath_hw *ah, int is_reset)
#define AR9285_AN_TOP3_PWDDAC
#define AR_PHY_TPCRG1_PD_CAL_ENABLE
#define AR_PHY_CH1_TX_PWRCTRL11
#define AR_PHY_CAL_MEAS_2(_i)
struct ath_hw_ops - callbacks used by hardware code and driver code
int(* calibrate)(struct ath_hw *ah, struct ath9k_channel *chan, u8 rxchainmask, int longcal)
#define INSERT_CAL(_ahp, _perCal)
#define OLC_FOR_AR9280_20_LATER
const struct ath9k_percal_data * calData
#define AR_SREV_9285_12_OR_LATER(_ah)
#define AR9285_AN_RXTXBB1_PDV2I
#define AR_PHY_AGC_CONTROL_NF
#define AR9285_AN_RXTXBB1_SPARE9
#define AR_PHY_CL_CAL_ENABLE
#define PER_MAX_LOG_COUNT
#define AR_PHY_CALMODE_ADC_GAIN
#define AR_PHY_CH0_TX_PWRCTRL11
#define REG_READ(_ah, _reg)
#define AR9271_AN_RF2G6_OFFS
#define PER_MIN_LOG_COUNT
#define AR_SREV_9285E_20(_ah)
#define AR_PHY_NEW_ADC_GAIN_CORR_ENABLE
#define AR5416_MAX_CHAINS
static void ar9002_hw_init_cal_settings(struct ath_hw *ah)
#define REG_SET_BIT(_a, _r, _f)
static struct ath_hw_ops * ath9k_hw_ops(struct ath_hw *ah)
#define AR9285_AN_RF2G6_CCOMP
#define AR_PHY_FC_DYN2040_EN
#define AR9285_AN_RXTXBB1_PDRXTXBB1
#define AR9285_CLCAL_REDO_THRESH
#define AR_PHY_TX_PWRCTRL_TX_GAIN_TAB_MAX
int ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout)
#define REG_WRITE(_ah, _reg, _val)
#define AR9285_AN_RF2G7_PWDDB
static const struct ath9k_percal_data iq_cal_single_sample
#define AR9285_AN_RXTXBB1_PDDACIF
#define AR_SREV_9271(_ah)
#define AR_PHY_TIMING_CTRL4_IQCAL_LOG_COUNT_MAX
#define AR_PHY_NEW_ADC_DC_GAIN_CORR(_i)
static const struct ath9k_percal_data adc_dc_cal_single_sample
#define AR9285_AN_RXTXBB1
static int ar9285_hw_clc(struct ath_hw *ah, struct ath9k_channel *chan)
#define AR_PHY_CAL_MEAS_1(_i)
#define AR9285_AN_RF2G6_OFFS
#define AR_PHY_TX_PWRCTRL_PD_AVG_OUT
#define AR_PHY_TX_GAIN_CLC_S
int ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan)
static void ar9002_hw_adc_dccal_calibrate(struct ath_hw *ah, u8 numChains)
#define AR_SREV_9160_10_OR_LATER(_ah)
#define AR_PHY_TX_PWRCTRL7
static struct ath_hw_private_ops * ath9k_hw_private_ops(struct ath_hw *ah)
#define AR_PHY_TIMING_CTRL4_DO_CAL
uint16_t offset
Offset to command line.
#define DBG(...)
Print a debugging message.
uint16_t supported
Bitmask of supported option values.
static int ar9002_hw_is_cal_supported(struct ath_hw *ah, struct ath9k_channel *chan, enum ar9002_cal_types cal_type)
static void ar9287_hw_olc_temp_compensation(struct ath_hw *ah)
void ath9k_hw_reset_calibration(struct ath_hw *ah, struct ath9k_cal_list *currCal)
static const struct ath9k_percal_data adc_gain_cal_single_sample
static void ar9002_hw_iqcal_collect(struct ath_hw *ah)
#define NULL
NULL pointer (VOID *)
#define AR_PHY_CAL_MEAS_0(_i)
enum ath9k_cal_state calState
#define MAX_PACAL_SKIPCOUNT
int(* init_cal)(struct ath_hw *ah, struct ath9k_channel *chan)
#define ENABLE_REGWRITE_BUFFER(_ah)
#define AR_PHY_CALMODE_IQ
#define AR_PHY_AGC_CONTROL_FLTR_CAL
#define AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF