diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416.h b/sys/dev/ath/ath_hal/ar5416/ar5416.h index 418dae7a55ae..9d390a445450 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416.h +++ b/sys/dev/ath/ath_hal/ar5416/ar5416.h @@ -74,6 +74,12 @@ struct ath_hal_5416 { void (*ah_spurMitigate)(struct ath_hal *, const struct ieee80211_channel *); + /* calibration ops */ + HAL_BOOL (*ah_cal_initcal)(struct ath_hal *, + const struct ieee80211_channel *); + void (*ah_cal_pacal)(struct ath_hal *, + HAL_BOOL is_reset); + /* optional open-loop tx power control related methods */ void (*ah_olcInit)(struct ath_hal *); void (*ah_olcTempCompensation)(struct ath_hal *); diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c b/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c index 3fb688e6f433..a38352bd14ac 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_attach.c @@ -178,6 +178,9 @@ ar5416InitState(struct ath_hal_5416 *ahp5416, uint16_t devid, HAL_SOFTC sc, AH5416(ah)->ah_writeIni = ar5416WriteIni; AH5416(ah)->ah_spurMitigate = ar5416SpurMitigate; + /* Internal calibration ops */ + AH5416(ah)->ah_cal_initcal = ar5416InitCalHardware; + /* Internal TX power control related operations */ AH5416(ah)->ah_olcInit = ar5416olcInit; AH5416(ah)->ah_olcTempCompensation = ar5416olcTempCompensation; diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c b/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c index b7ae7710c96b..f37f62f7958f 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_cal.c @@ -183,18 +183,9 @@ ar5416RunInitCals(struct ath_hal *ah, int init_cal_count) } #endif -/* - * Initialize Calibration infrastructure. - */ HAL_BOOL -ar5416InitCal(struct ath_hal *ah, const struct ieee80211_channel *chan) +ar5416InitCalHardware(struct ath_hal *ah, const struct ieee80211_channel *chan) { - struct ar5416PerCal *cal = &AH5416(ah)->ah_cal; - HAL_CHANNEL_INTERNAL *ichan; - - ichan = ath_hal_checkchannel(ah, chan); - HALASSERT(ichan != AH_NULL); - if (AR_SREV_MERLIN_10_OR_LATER(ah)) { /* Enable Rx Filter Cal */ OS_REG_CLR_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC); @@ -235,6 +226,32 @@ ar5416InitCal(struct ath_hal *ah, const struct ieee80211_channel *chan) return AH_FALSE; } + return AH_TRUE; +} + +/* + * Initialize Calibration infrastructure. + */ +HAL_BOOL +ar5416InitCal(struct ath_hal *ah, const struct ieee80211_channel *chan) +{ + struct ar5416PerCal *cal = &AH5416(ah)->ah_cal; + HAL_CHANNEL_INTERNAL *ichan; + + ichan = ath_hal_checkchannel(ah, chan); + HALASSERT(ichan != AH_NULL); + + /* Do initial chipset-specific calibration */ + if (! AH5416(ah)->ah_cal_initcal(ah, chan)) { + HALDEBUG(ah, HAL_DEBUG_ANY, "%s: initial chipset calibration did " + "not complete in time; noisy environment?\n", __func__); + return AH_FALSE; + } + + /* If there's PA Cal, do it */ + if (AH5416(ah)->ah_cal_pacal) + AH5416(ah)->ah_cal_pacal(ah, AH_TRUE); + /* * Do NF calibration after DC offset and other CALs. * Per system engineers, noise floor value can sometimes be 20 dB @@ -468,6 +485,10 @@ ar5416PerCalibrationN(struct ath_hal *ah, struct ieee80211_channel *chan, /* Do NF cal only at longer intervals */ if (longcal) { + /* Do PA calibration if the chipset supports */ + if (AH5416(ah)->ah_cal_pacal) + AH5416(ah)->ah_cal_pacal(ah, AH_FALSE); + /* Do temperature compensation if the chipset needs it */ AH5416(ah)->ah_olcTempCompensation(ah); diff --git a/sys/dev/ath/ath_hal/ar5416/ar5416_cal.h b/sys/dev/ath/ath_hal/ar5416/ar5416_cal.h index e77f300b12cf..a4f19e592c0a 100644 --- a/sys/dev/ath/ath_hal/ar5416/ar5416_cal.h +++ b/sys/dev/ath/ath_hal/ar5416/ar5416_cal.h @@ -102,6 +102,7 @@ struct ar5416PerCal { } \ } while (0) +HAL_BOOL ar5416InitCalHardware(struct ath_hal *ah, const struct ieee80211_channel *chan); HAL_BOOL ar5416InitCal(struct ath_hal *, const struct ieee80211_channel *); HAL_BOOL ar5416PerCalibration(struct ath_hal *, struct ieee80211_channel *, HAL_BOOL *isIQdone);