Lines Matching +full:im +full:-
2 * Copyright (c) 2010-2011 Atheros Communications Inc.
18 #include "hw-ops.h"
44 switch (currCal->calData->calType) { in ar9003_hw_setup_calibration()
52 currCal->calData->calCountMax); in ar9003_hw_setup_calibration()
58 /* Kick-off cal */ in ar9003_hw_setup_calibration()
77 struct ath9k_hw_cal_data *caldata = ah->caldata; in ar9003_hw_per_calibration()
78 const struct ath9k_percal_data *cur_caldata = currCal->calData; in ar9003_hw_per_calibration()
81 if (currCal->calState == CAL_RUNNING) { in ar9003_hw_per_calibration()
89 cur_caldata->calCollect(ah); in ar9003_hw_per_calibration()
90 ah->cal_samples++; in ar9003_hw_per_calibration()
92 if (ah->cal_samples >= cur_caldata->calNumSamples) { in ar9003_hw_per_calibration()
102 cur_caldata->calPostProc(ah, numChains); in ar9003_hw_per_calibration()
105 caldata->CalValid |= cur_caldata->calType; in ar9003_hw_per_calibration()
106 currCal->calState = CAL_DONE; in ar9003_hw_per_calibration()
110 * Set-up collection of another sub-sample until we in ar9003_hw_per_calibration()
115 } else if (!(caldata->CalValid & cur_caldata->calType)) { in ar9003_hw_per_calibration()
127 struct ath9k_cal_list *currCal = ah->cal_list_curr; in ar9003_hw_calibrate()
140 (currCal->calState == CAL_RUNNING || in ar9003_hw_calibrate()
141 currCal->calState == CAL_WAITING)) { in ar9003_hw_calibrate()
145 ah->cal_list_curr = currCal = currCal->calNext; in ar9003_hw_calibrate()
147 if (currCal->calState == CAL_WAITING) { in ar9003_hw_calibrate()
161 * NF is slow time-variant, so it is OK to use a historical in ar9003_hw_calibrate()
164 ret = ath9k_hw_loadnf(ah, ah->curchan); in ar9003_hw_calibrate()
181 if (ah->txchainmask & BIT(i)) { in ar9003_hw_iqcal_collect()
182 ah->totalPowerMeasI[i] += in ar9003_hw_iqcal_collect()
184 ah->totalPowerMeasQ[i] += in ar9003_hw_iqcal_collect()
186 ah->totalIqCorrMeas[i] += in ar9003_hw_iqcal_collect()
190 ah->cal_samples, i, ah->totalPowerMeasI[i], in ar9003_hw_iqcal_collect()
191 ah->totalPowerMeasQ[i], in ar9003_hw_iqcal_collect()
192 ah->totalIqCorrMeas[i]); in ar9003_hw_iqcal_collect()
211 powerMeasI = ah->totalPowerMeasI[i]; in ar9003_hw_iqcalibrate()
212 powerMeasQ = ah->totalPowerMeasQ[i]; in ar9003_hw_iqcalibrate()
213 iqCorrMeas = ah->totalIqCorrMeas[i]; in ar9003_hw_iqcalibrate()
220 i, ah->totalIqCorrMeas[i]); in ar9003_hw_iqcalibrate()
225 iqCorrMeas = (0xffffffff - iqCorrMeas) + 1; in ar9003_hw_iqcalibrate()
240 qCoff = powerMeasI / qCoffDenom - 64; in ar9003_hw_iqcalibrate()
249 else if (iCoff <= -63) in ar9003_hw_iqcalibrate()
250 iCoff = -63; in ar9003_hw_iqcalibrate()
254 iCoff = -iCoff; in ar9003_hw_iqcalibrate()
259 else if (qCoff <= -63) in ar9003_hw_iqcalibrate()
260 qCoff = -63; in ar9003_hw_iqcalibrate()
275 iCoff == -63 || qCoff == -63)) in ar9003_hw_iqcalibrate()
319 ah->iq_caldata.calData = &iq_cal_single_sample; in ar9003_hw_init_cal_settings()
322 ah->enabled_cals |= TX_IQ_CAL; in ar9003_hw_init_cal_settings()
324 ah->enabled_cals |= TX_IQ_ON_AGC_CAL; in ar9003_hw_init_cal_settings()
327 ah->supp_cals = IQ_MISMATCH_CAL; in ar9003_hw_init_cal_settings()
562 s32 f1 = cos_2phi_1 - cos_2phi_2, in ar9003_hw_solve_iq_cal()
563 f3 = sin_2phi_1 - sin_2phi_2, in ar9003_hw_solve_iq_cal()
577 mag_tx = f1 * (mag_a0_d0 - mag_a1_d0) + f3 * (phs_a0_d0 - phs_a1_d0); in ar9003_hw_solve_iq_cal()
579 phs_tx = f3 * (-mag_a0_d0 + mag_a1_d0) + f1 * (phs_a0_d0 - phs_a1_d0); in ar9003_hw_solve_iq_cal()
585 mag_rx = mag_a0_d0 - (cos_2phi_1 * mag_tx + sin_2phi_1 * phs_tx) / in ar9003_hw_solve_iq_cal()
588 phs_rx = phs_a0_d0 + (sin_2phi_1 * mag_tx - cos_2phi_1 * phs_tx) / in ar9003_hw_solve_iq_cal()
613 return max_abs - (max_abs / 32) + (min_abs / 8) + (min_abs / 4); in ar9003_hw_find_mag_approx()
644 i2_m_q2_a0_d0 = -((0xfff - i2_m_q2_a0_d0) + 1); in ar9003_hw_calc_iq_corr()
647 i2_p_q2_a0_d0 = -((0xfff - i2_p_q2_a0_d0) + 1); in ar9003_hw_calc_iq_corr()
650 iq_corr_a0_d0 = -((0xfff - iq_corr_a0_d0) + 1); in ar9003_hw_calc_iq_corr()
657 i2_m_q2_a0_d1 = -((0xfff - i2_m_q2_a0_d1) + 1); in ar9003_hw_calc_iq_corr()
660 iq_corr_a0_d1 = -((0xfff - iq_corr_a0_d1) + 1); in ar9003_hw_calc_iq_corr()
667 i2_m_q2_a1_d0 = -((0xfff - i2_m_q2_a1_d0) + 1); in ar9003_hw_calc_iq_corr()
670 i2_p_q2_a1_d0 = -((0xfff - i2_p_q2_a1_d0) + 1); in ar9003_hw_calc_iq_corr()
673 iq_corr_a1_d0 = -((0xfff - iq_corr_a1_d0) + 1); in ar9003_hw_calc_iq_corr()
680 i2_m_q2_a1_d1 = -((0xfff - i2_m_q2_a1_d1) + 1); in ar9003_hw_calc_iq_corr()
683 i2_p_q2_a1_d1 = -((0xfff - i2_p_q2_a1_d1) + 1); in ar9003_hw_calc_iq_corr()
686 iq_corr_a1_d1 = -((0xfff - iq_corr_a1_d1) + 1); in ar9003_hw_calc_iq_corr()
727 sin_2phi_1 = (((mag_a0_d0 - mag_a0_d1) * delpt_shift) / DELPT); in ar9003_hw_calc_iq_corr()
729 cos_2phi_1 = (((phs_a0_d1 - phs_a0_d0) * delpt_shift) / DELPT); in ar9003_hw_calc_iq_corr()
731 sin_2phi_2 = (((mag_a1_d0 - mag_a1_d1) * delpt_shift) / DELPT); in ar9003_hw_calc_iq_corr()
733 cos_2phi_2 = (((phs_a1_d1 - phs_a1_d0) * delpt_shift) / DELPT); in ar9003_hw_calc_iq_corr()
783 mag_corr_tx = (mag_tx * res_scale) / (res_scale - mag_tx); in ar9003_hw_calc_iq_corr()
784 phs_corr_tx = -phs_tx; in ar9003_hw_calc_iq_corr()
792 if (q_i_coff < -63) in ar9003_hw_calc_iq_corr()
793 q_i_coff = -63; in ar9003_hw_calc_iq_corr()
796 if (q_q_coff < -63) in ar9003_hw_calc_iq_corr()
797 q_q_coff = -63; in ar9003_hw_calc_iq_corr()
806 if (-mag_rx == res_scale) { in ar9003_hw_calc_iq_corr()
814 mag_corr_rx = (-mag_rx * res_scale) / (res_scale + mag_rx); in ar9003_hw_calc_iq_corr()
815 phs_corr_rx = -phs_rx; in ar9003_hw_calc_iq_corr()
823 if (q_i_coff < -63) in ar9003_hw_calc_iq_corr()
824 q_i_coff = -63; in ar9003_hw_calc_iq_corr()
827 if (q_q_coff < -63) in ar9003_hw_calc_iq_corr()
828 q_q_coff = -63; in ar9003_hw_calc_iq_corr()
844 int mp_max = -64, max_idx = 0; in ar9003_hw_detect_outlier()
875 mp_avg = mp_coeff[nmeasurement - 1][0]; in ar9003_hw_detect_outlier()
878 if (abs(mp_max - mp_min) > max_delta) { in ar9003_hw_detect_outlier()
879 if (abs(mp_max - mp_avg) > abs(mp_min - mp_avg)) in ar9003_hw_detect_outlier()
892 int i, im, nmeasurement; in ar9003_hw_tx_iq_cal_outlier_detection() local
895 struct ath9k_hw_cal_data *caldata = ah->caldata; in ar9003_hw_tx_iq_cal_outlier_detection()
914 if (!(ah->txchainmask & (1 << i))) in ar9003_hw_tx_iq_cal_outlier_detection()
930 ar9003_hw_detect_outlier(coeff->mag_coeff[i], in ar9003_hw_tx_iq_cal_outlier_detection()
935 ar9003_hw_detect_outlier(coeff->phs_coeff[i], in ar9003_hw_tx_iq_cal_outlier_detection()
941 for (im = 0; im < nmeasurement; im++) { in ar9003_hw_tx_iq_cal_outlier_detection()
942 magnitude = coeff->mag_coeff[i][im][0]; in ar9003_hw_tx_iq_cal_outlier_detection()
943 phase = coeff->phs_coeff[i][im][0]; in ar9003_hw_tx_iq_cal_outlier_detection()
945 coeff->iqc_coeff[0] = in ar9003_hw_tx_iq_cal_outlier_detection()
948 if ((im % 2) == 0) in ar9003_hw_tx_iq_cal_outlier_detection()
949 REG_RMW_FIELD(ah, tx_corr_coeff[im][i], in ar9003_hw_tx_iq_cal_outlier_detection()
951 coeff->iqc_coeff[0]); in ar9003_hw_tx_iq_cal_outlier_detection()
953 REG_RMW_FIELD(ah, tx_corr_coeff[im][i], in ar9003_hw_tx_iq_cal_outlier_detection()
955 coeff->iqc_coeff[0]); in ar9003_hw_tx_iq_cal_outlier_detection()
958 caldata->tx_corr_coeff[im][i] = in ar9003_hw_tx_iq_cal_outlier_detection()
959 coeff->iqc_coeff[0]; in ar9003_hw_tx_iq_cal_outlier_detection()
962 caldata->num_measures[i] = nmeasurement; in ar9003_hw_tx_iq_cal_outlier_detection()
972 set_bit(TXIQCAL_DONE, &caldata->cal_flags); in ar9003_hw_tx_iq_cal_outlier_detection()
974 clear_bit(TXIQCAL_DONE, &caldata->cal_flags); in ar9003_hw_tx_iq_cal_outlier_detection()
1008 int im, ix, iy, temp; in __ar955x_tx_iq_cal_sort() local
1010 for (im = 0; im < nmeasurement; im++) { in __ar955x_tx_iq_cal_sort()
1011 for (ix = 0; ix < MAXIQCAL - 1; ix++) { in __ar955x_tx_iq_cal_sort()
1012 for (iy = ix + 1; iy <= MAXIQCAL - 1; iy++) { in __ar955x_tx_iq_cal_sort()
1013 if (coeff->mag_coeff[i][im][iy] < in __ar955x_tx_iq_cal_sort()
1014 coeff->mag_coeff[i][im][ix]) { in __ar955x_tx_iq_cal_sort()
1015 temp = coeff->mag_coeff[i][im][ix]; in __ar955x_tx_iq_cal_sort()
1016 coeff->mag_coeff[i][im][ix] = in __ar955x_tx_iq_cal_sort()
1017 coeff->mag_coeff[i][im][iy]; in __ar955x_tx_iq_cal_sort()
1018 coeff->mag_coeff[i][im][iy] = temp; in __ar955x_tx_iq_cal_sort()
1020 if (coeff->phs_coeff[i][im][iy] < in __ar955x_tx_iq_cal_sort()
1021 coeff->phs_coeff[i][im][ix]) { in __ar955x_tx_iq_cal_sort()
1022 temp = coeff->phs_coeff[i][im][ix]; in __ar955x_tx_iq_cal_sort()
1023 coeff->phs_coeff[i][im][ix] = in __ar955x_tx_iq_cal_sort()
1024 coeff->phs_coeff[i][im][iy]; in __ar955x_tx_iq_cal_sort()
1025 coeff->phs_coeff[i][im][iy] = temp; in __ar955x_tx_iq_cal_sort()
1029 coeff->mag_coeff[i][im][0] = coeff->mag_coeff[i][im][MAXIQCAL / 2]; in __ar955x_tx_iq_cal_sort()
1030 coeff->phs_coeff[i][im][0] = coeff->phs_coeff[i][im][MAXIQCAL / 2]; in __ar955x_tx_iq_cal_sort()
1034 i, im, in __ar955x_tx_iq_cal_sort()
1035 coeff->mag_coeff[i][im][0], in __ar955x_tx_iq_cal_sort()
1036 coeff->phs_coeff[i][im][0]); in __ar955x_tx_iq_cal_sort()
1074 int i, im, j; in ar9003_hw_tx_iq_cal_post_proc() local
1079 if (!(ah->txchainmask & (1 << i))) in ar9003_hw_tx_iq_cal_post_proc()
1088 for (im = 0; im < nmeasurement; im++) { in ar9003_hw_tx_iq_cal_post_proc()
1100 u32 idx = 2 * j, offset = 4 * (3 * im + j); in ar9003_hw_tx_iq_cal_post_proc()
1134 coeff.phs_coeff[i][im][iqcal_idx] = in ar9003_hw_tx_iq_cal_post_proc()
1136 coeff.mag_coeff[i][im][iqcal_idx] = in ar9003_hw_tx_iq_cal_post_proc()
1139 if (coeff.mag_coeff[i][im][iqcal_idx] > 63) in ar9003_hw_tx_iq_cal_post_proc()
1140 coeff.mag_coeff[i][im][iqcal_idx] -= 128; in ar9003_hw_tx_iq_cal_post_proc()
1141 if (coeff.phs_coeff[i][im][iqcal_idx] > 63) in ar9003_hw_tx_iq_cal_post_proc()
1142 coeff.phs_coeff[i][im][iqcal_idx] -= 128; in ar9003_hw_tx_iq_cal_post_proc()
1161 struct ath9k_hw_cal_data *caldata = ah->caldata; in ar9003_hw_tx_iq_cal_reload()
1163 int i, im; in ar9003_hw_tx_iq_cal_reload() local
1181 if (!(ah->txchainmask & (1 << i))) in ar9003_hw_tx_iq_cal_reload()
1184 for (im = 0; im < caldata->num_measures[i]; im++) { in ar9003_hw_tx_iq_cal_reload()
1185 if ((im % 2) == 0) in ar9003_hw_tx_iq_cal_reload()
1186 REG_RMW_FIELD(ah, tx_corr_coeff[im][i], in ar9003_hw_tx_iq_cal_reload()
1188 caldata->tx_corr_coeff[im][i]); in ar9003_hw_tx_iq_cal_reload()
1190 REG_RMW_FIELD(ah, tx_corr_coeff[im][i], in ar9003_hw_tx_iq_cal_reload()
1192 caldata->tx_corr_coeff[im][i]); in ar9003_hw_tx_iq_cal_reload()
1260 for (i = 6; i > 0; i--) { in ar9003_hw_manual_peak_cal()
1261 offset[i] = BIT(i - 1); in ar9003_hw_manual_peak_cal()
1276 total += (offset[i] << (i - 1)); in ar9003_hw_manual_peak_cal()
1307 struct ath9k_hw_cal_data *caldata = ah->caldata; in ar9003_hw_do_pcoem_manual_peak_cal()
1310 if ((ah->caps.hw_caps & ATH9K_HW_CAP_RTT) && !run_rtt_cal) in ar9003_hw_do_pcoem_manual_peak_cal()
1314 if (!(ah->rxchainmask & (1 << i))) in ar9003_hw_do_pcoem_manual_peak_cal()
1320 set_bit(SW_PKDET_DONE, &caldata->cal_flags); in ar9003_hw_do_pcoem_manual_peak_cal()
1322 if ((ah->caps.hw_caps & ATH9K_HW_CAP_RTT) && caldata) { in ar9003_hw_do_pcoem_manual_peak_cal()
1324 caldata->caldac[0] = REG_READ_FIELD(ah, in ar9003_hw_do_pcoem_manual_peak_cal()
1327 caldata->caldac[1] = REG_READ_FIELD(ah, in ar9003_hw_do_pcoem_manual_peak_cal()
1331 caldata->caldac[0] = REG_READ_FIELD(ah, in ar9003_hw_do_pcoem_manual_peak_cal()
1334 caldata->caldac[1] = REG_READ_FIELD(ah, in ar9003_hw_do_pcoem_manual_peak_cal()
1346 struct ath9k_hw_cal_data *caldata = ah->caldata; in ar9003_hw_cl_cal_post_proc()
1350 if (!caldata || !(ah->enabled_cals & TX_CL_CAL)) in ar9003_hw_cl_cal_post_proc()
1356 if (test_bit(TXCLCAL_DONE, &caldata->cal_flags)) { in ar9003_hw_cl_cal_post_proc()
1358 if (!(ah->txchainmask & (1 << i))) in ar9003_hw_cl_cal_post_proc()
1362 caldata->tx_clcal[i][j]); in ar9003_hw_cl_cal_post_proc()
1366 if (!(ah->txchainmask & (1 << i))) in ar9003_hw_cl_cal_post_proc()
1369 caldata->tx_clcal[i][j] = in ar9003_hw_cl_cal_post_proc()
1372 set_bit(TXCLCAL_DONE, &caldata->cal_flags); in ar9003_hw_cl_cal_post_proc()
1378 struct ath9k_hw_cal_data *caldata = ah->caldata; in ar9003_hw_init_cal_common()
1381 ah->cal_list = ah->cal_list_last = ah->cal_list_curr = NULL; in ar9003_hw_init_cal_common()
1383 INIT_CAL(&ah->iq_caldata); in ar9003_hw_init_cal_common()
1384 INSERT_CAL(ah, &ah->iq_caldata); in ar9003_hw_init_cal_common()
1387 ah->cal_list_curr = ah->cal_list; in ar9003_hw_init_cal_common()
1389 if (ah->cal_list_curr) in ar9003_hw_init_cal_common()
1390 ath9k_hw_reset_calibration(ah, ah->cal_list_curr); in ar9003_hw_init_cal_common()
1393 caldata->CalValid = 0; in ar9003_hw_init_cal_common()
1400 struct ath9k_hw_cal_data *caldata = ah->caldata; in ar9003_hw_init_cal_pcoem()
1404 bool rtt = !!(ah->caps.hw_caps & ATH9K_HW_CAP_RTT); in ar9003_hw_init_cal_pcoem()
1411 ar9003_hw_set_chain_masks(ah, ah->caps.rx_chainmask, ah->caps.tx_chainmask); in ar9003_hw_init_cal_pcoem()
1438 if (ah->ah_flags & AH_FASTCC) in ar9003_hw_init_cal_pcoem()
1443 if (ah->enabled_cals & TX_CL_CAL) { in ar9003_hw_init_cal_pcoem()
1444 if (caldata && test_bit(TXCLCAL_DONE, &caldata->cal_flags)) in ar9003_hw_init_cal_pcoem()
1455 !(ah->enabled_cals & TX_IQ_CAL)) in ar9003_hw_init_cal_pcoem()
1467 if (ah->enabled_cals & TX_IQ_ON_AGC_CAL) { in ar9003_hw_init_cal_pcoem()
1468 if (caldata && !test_bit(TXIQCAL_DONE, &caldata->cal_flags)) in ar9003_hw_init_cal_pcoem()
1490 if (run_agc_cal || !(ah->ah_flags & AH_FASTCC)) { in ar9003_hw_init_cal_pcoem()
1529 else if (caldata && test_bit(TXIQCAL_DONE, &caldata->cal_flags)) in ar9003_hw_init_cal_pcoem()
1542 if (test_bit(SW_PKDET_DONE, &caldata->cal_flags)) in ar9003_hw_init_cal_pcoem()
1553 ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask); in ar9003_hw_init_cal_pcoem()
1592 ar9003_hw_set_chain_masks(ah, ah->caps.rx_chainmask, ah->caps.tx_chainmask); in ar9003_hw_init_cal_soc()
1594 if (ah->enabled_cals & TX_CL_CAL) { in ar9003_hw_init_cal_soc()
1611 if (ah->enabled_cals & TX_IQ_ON_AGC_CAL) { in ar9003_hw_init_cal_soc()
1640 if (run_agc_cal || !(ah->ah_flags & AH_FASTCC)) { in ar9003_hw_init_cal_soc()
1642 if (!(ah->rxchainmask & (1 << i))) in ar9003_hw_init_cal_soc()
1650 * For non-AR9550 chips, we just trigger AGC calibration in ar9003_hw_init_cal_soc()
1681 ar9003_hw_set_chain_masks(ah, ah->rxchainmask, ah->txchainmask); in ar9003_hw_init_cal_soc()
1694 priv_ops->init_cal = ar9003_hw_init_cal_pcoem; in ar9003_hw_attach_calib_ops()
1696 priv_ops->init_cal = ar9003_hw_init_cal_soc; in ar9003_hw_attach_calib_ops()
1698 priv_ops->init_cal_settings = ar9003_hw_init_cal_settings; in ar9003_hw_attach_calib_ops()
1699 priv_ops->setup_calibration = ar9003_hw_setup_calibration; in ar9003_hw_attach_calib_ops()
1701 ops->calibrate = ar9003_hw_calibrate; in ar9003_hw_attach_calib_ops()