Deleted Added
full compact
ar5416_cal.c (219393) ar5416_cal.c (219480)
1/*
2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3 * Copyright (c) 2002-2008 Atheros Communications, Inc.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 *
1/*
2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3 * Copyright (c) 2002-2008 Atheros Communications, Inc.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 *
17 * $FreeBSD: head/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c 219393 2011-03-08 06:59:59Z adrian $
17 * $FreeBSD: head/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c 219480 2011-03-11 11:35:36Z adrian $
18 */
19#include "opt_ah.h"
20
21#include "ah.h"
22#include "ah_internal.h"
23#include "ah_devid.h"
24
25#include "ah_eeprom_v14.h"

--- 152 unchanged lines hidden (view full) ---

178 }
179
180 /* Re-initialize list pointers for periodic cals */
181 cal->cal_list = cal->cal_last = cal->cal_curr = AH_NULL;
182 return AH_TRUE;
183}
184#endif
185
18 */
19#include "opt_ah.h"
20
21#include "ah.h"
22#include "ah_internal.h"
23#include "ah_devid.h"
24
25#include "ah_eeprom_v14.h"

--- 152 unchanged lines hidden (view full) ---

178 }
179
180 /* Re-initialize list pointers for periodic cals */
181 cal->cal_list = cal->cal_last = cal->cal_curr = AH_NULL;
182 return AH_TRUE;
183}
184#endif
185
186/*
187 * Initialize Calibration infrastructure.
188 */
189HAL_BOOL
186HAL_BOOL
190ar5416InitCal(struct ath_hal *ah, const struct ieee80211_channel *chan)
187ar5416InitCalHardware(struct ath_hal *ah, const struct ieee80211_channel *chan)
191{
188{
192 struct ar5416PerCal *cal = &AH5416(ah)->ah_cal;
193 HAL_CHANNEL_INTERNAL *ichan;
194
195 ichan = ath_hal_checkchannel(ah, chan);
196 HALASSERT(ichan != AH_NULL);
197
198 if (AR_SREV_MERLIN_10_OR_LATER(ah)) {
199 /* Enable Rx Filter Cal */
200 OS_REG_CLR_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC);
201 OS_REG_SET_BIT(ah, AR_PHY_AGC_CONTROL,
202 AR_PHY_AGC_CONTROL_FLTR_CAL);
203
204 /* Clear the carrier leak cal bit */
205 OS_REG_CLR_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_CL_CAL_ENABLE);

--- 24 unchanged lines hidden (view full) ---

230 /* Poll for offset calibration complete */
231 if (!ath_hal_wait(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL, 0)) {
232 HALDEBUG(ah, HAL_DEBUG_ANY,
233 "%s: offset calibration did not complete in 1ms; "
234 "noisy environment?\n", __func__);
235 return AH_FALSE;
236 }
237
189 if (AR_SREV_MERLIN_10_OR_LATER(ah)) {
190 /* Enable Rx Filter Cal */
191 OS_REG_CLR_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC);
192 OS_REG_SET_BIT(ah, AR_PHY_AGC_CONTROL,
193 AR_PHY_AGC_CONTROL_FLTR_CAL);
194
195 /* Clear the carrier leak cal bit */
196 OS_REG_CLR_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_CL_CAL_ENABLE);

--- 24 unchanged lines hidden (view full) ---

221 /* Poll for offset calibration complete */
222 if (!ath_hal_wait(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL, 0)) {
223 HALDEBUG(ah, HAL_DEBUG_ANY,
224 "%s: offset calibration did not complete in 1ms; "
225 "noisy environment?\n", __func__);
226 return AH_FALSE;
227 }
228
229 return AH_TRUE;
230}
231
232/*
233 * Initialize Calibration infrastructure.
234 */
235HAL_BOOL
236ar5416InitCal(struct ath_hal *ah, const struct ieee80211_channel *chan)
237{
238 struct ar5416PerCal *cal = &AH5416(ah)->ah_cal;
239 HAL_CHANNEL_INTERNAL *ichan;
240
241 ichan = ath_hal_checkchannel(ah, chan);
242 HALASSERT(ichan != AH_NULL);
243
244 /* Do initial chipset-specific calibration */
245 if (! AH5416(ah)->ah_cal_initcal(ah, chan)) {
246 HALDEBUG(ah, HAL_DEBUG_ANY, "%s: initial chipset calibration did "
247 "not complete in time; noisy environment?\n", __func__);
248 return AH_FALSE;
249 }
250
251 /* If there's PA Cal, do it */
252 if (AH5416(ah)->ah_cal_pacal)
253 AH5416(ah)->ah_cal_pacal(ah, AH_TRUE);
254
238 /*
239 * Do NF calibration after DC offset and other CALs.
240 * Per system engineers, noise floor value can sometimes be 20 dB
241 * higher than normal value if DC offset and noise floor cal are
242 * triggered at the same time.
243 */
244 /* XXX this actually kicks off a NF calibration -adrian */
245 OS_REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF);

--- 217 unchanged lines hidden (view full) ---

463 *isCalDone = AH_FALSE;
464 ar5416ResetMeasurement(ah, currCal);
465 }
466 }
467 }
468
469 /* Do NF cal only at longer intervals */
470 if (longcal) {
255 /*
256 * Do NF calibration after DC offset and other CALs.
257 * Per system engineers, noise floor value can sometimes be 20 dB
258 * higher than normal value if DC offset and noise floor cal are
259 * triggered at the same time.
260 */
261 /* XXX this actually kicks off a NF calibration -adrian */
262 OS_REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF);

--- 217 unchanged lines hidden (view full) ---

480 *isCalDone = AH_FALSE;
481 ar5416ResetMeasurement(ah, currCal);
482 }
483 }
484 }
485
486 /* Do NF cal only at longer intervals */
487 if (longcal) {
488 /* Do PA calibration if the chipset supports */
489 if (AH5416(ah)->ah_cal_pacal)
490 AH5416(ah)->ah_cal_pacal(ah, AH_FALSE);
491
471 /* Do temperature compensation if the chipset needs it */
472 AH5416(ah)->ah_olcTempCompensation(ah);
473
474 /*
475 * Get the value from the previous NF cal
476 * and update the history buffer.
477 */
478 ar5416GetNf(ah, chan);

--- 292 unchanged lines hidden ---
492 /* Do temperature compensation if the chipset needs it */
493 AH5416(ah)->ah_olcTempCompensation(ah);
494
495 /*
496 * Get the value from the previous NF cal
497 * and update the history buffer.
498 */
499 ar5416GetNf(ah, chan);

--- 292 unchanged lines hidden ---