36#define NUM_NOISEFLOOR_READINGS 6
74 return !IEEE80211_IS_CHAN_B(chan);
83 if (IEEE80211_IS_CHAN_HT20(chan) &&
86 if (IEEE80211_IS_CHAN_5GHZ(chan))
88 if (IEEE80211_IS_CHAN_HT40(chan))
111 "%s: start IQ Mismatch calibration\n", __func__);
116 "%s: start ADC Gain calibration\n", __func__);
121 "%s: start ADC DC calibration\n", __func__);
126 "%s: start Init ADC DC calibration\n", __func__);
157ar5416RunInitCals(
struct ath_hal *ah,
int init_cal_count)
170 for (i = 0; i < init_cal_count; i++) {
176 "%s: Cal %d failed to finish in 100ms.\n",
187 "%s: init cal %d did not complete.\n",
222 "%s: offset calibration did not complete in 1ms; "
223 "noisy environment?\n", __func__);
243#define MAX_CAL_CHECK 32
254 if (!
AH5416(ah)->ah_cal_initcal(ah, chan)) {
256 "%s: initial chipset calibration did "
257 "not complete in time; noisy environment?\n", __func__);
262 if (
AH5416(ah)->ah_cal_pacal)
297 if (cal->ah_cal_curr !=
AH_NULL && !ar5416RunInitCals(ah, 0))
307 "%s: enable ADC Gain Calibration.\n", __func__);
313 "%s: enable ADC DC Calibration.\n", __func__);
319 "%s: enable IQ Calibration.\n", __func__);
352 "%s: invalid channel %u/0x%x; no mapping\n",
353 __func__, chan->ic_freq, chan->ic_flags);
362 "%s: Calibration state incorrect, %d\n",
372 "%s: Resetting Cal %d state for channel %u/0x%x\n",
377 ichan->
calValid &= ~currCal->calData->calType;
397 "%s: %s Calibration, state %d, calValid 0x%x\n",
406 "%s: sample %d of %d finished\n",
414 int i, numChains = 0;
416 if (rxchainmask & (1 << i))
462 rxchainmask =
AH5416(ah)->ah_rx_chainmask;
468 "%s: invalid channel %u/0x%x; no mapping\n",
469 __func__, chan->ic_freq, chan->ic_flags);
498 if (
AH5416(ah)->ah_cal_pacal)
503 AH5416(ah)->ah_olcTempCompensation(ah);
510 if (r == 0 || r == -1) {
513 " didn't finish; delaying CCA\n", __func__);
565 const struct ieee80211_channel *chan, int16_t *nft)
567 if (IEEE80211_IS_CHAN_5GHZ(chan)) {
571 if (IEEE80211_IS_CHAN_2GHZ(chan)) {
576 __func__, chan->ic_flags);
591 static const uint32_t ar5416_cca_regs[] = {
622 h =
AH5416(ah)->ah_cal.nfCalHist;
627 if (i > 2 && !IEEE80211_IS_CHAN_HT40(chan))
630 if (chainmask & (1 << i)) {
640 val |= (((uint32_t) nf_val << 1) & 0x1ff);
664 "nf to load: AR_PHY_AGC_CONTROL=0x%x\n",
677 if (i > 2 && !IEEE80211_IS_CHAN_HT40(chan))
680 if (chainmask & (1 << i)) {
683 val |= (((uint32_t)(-50) << 1) & 0x1ff);
743 if (!chan || IEEE80211_IS_CHAN_2GHZ(chan))
744 limit = &
AH5416(ah)->nf_2g;
746 limit = &
AH5416(ah)->nf_5g;
758 if (IEEE80211_IS_CHAN_2GHZ(
AH_PRIVATE(ah)->ah_curchan))
759 limit = &
AH5416(ah)->nf_2g;
761 limit = &
AH5416(ah)->nf_5g;
767 if (nf[i] > limit->
max) {
769 "NF[%d] (%d) > MAX (%d), correcting to MAX\n",
770 i, nf[i], limit->
max);
772 }
else if (nf[i] < limit->
min) {
774 "NF[%d] (%d) < MIN (%d), correcting to NOM\n",
775 i, nf[i], limit->
min);
790 int16_t nf, nfThresh;
796 "%s: NF didn't complete in calibration window\n", __func__);
811 "%s: noise floor failed detected; "
812 "detected %d, threshold %d\n", __func__,
819 chan->ic_state |= IEEE80211_CHANSTATE_CWINT;
828 for (i = 0; i < 3; i++) {
HAL_BOOL ath_hal_wait(struct ath_hal *ah, u_int reg, uint32_t mask, uint32_t val)
#define AR5416_MAX_CHAINS
#define OS_REG_SET_BIT(_a, _r, _f)
static OS_INLINE HAL_CHANNEL_INTERNAL * ath_hal_checkchannel(struct ath_hal *ah, const struct ieee80211_channel *c)
#define ath_hal_getNoiseFloor(_ah, _nfArray)
#define ath_hal_eepromGet(_ah, _param, _val)
#define OS_REG_CLR_BIT(_a, _r, _f)
#define CHANNEL_MIMO_NF_VALID
#define IS_5GHZ_FAST_CLOCK_EN(_ah, _c)
#define OS_REG_RMW_FIELD(_a, _r, _f, _v)
#define HALDEBUG(_ah, __m,...)
#define ath_hal_eepromGetFlag(_ah, _param)
#define OS_MEMZERO(_a, _n)
#define OS_REG_WRITE(_ah, _reg, _val)
#define OS_MARK(_ah, _id, _v)
#define OS_REG_READ(_ah, _reg)
#define AR_PHY_AGC_CONTROL_CAL
#define AR_PHY_AGC_CONTROL_NF
#define AR_PHY_TIMING_CTRL4
#define AR_PHY_AGC_CONTROL
HAL_BOOL ar5212WaitNFCalComplete(struct ath_hal *ah, int i)
#define AR512_NF_CAL_HIST_MAX
int16_t ar5212GetNfHistMid(const int16_t calData[])
HAL_BOOL ar5212IsNFCalInProgress(struct ath_hal *ah)
#define AR_PHY_AGC_CONTROL_FLTR_CAL
#define AR_PHY_ADC_CTL_OFF_PWDADC
#define AR_PHY_AGC_CONTROL_ENABLE_NF
#define AR_PHY_TIMING_CTRL4_IQCAL_LOG_COUNT_MAX
#define AR_PHY_AGC_CONTROL_NO_UPDATE_NF
#define AR5416_CCA_MAX_HIGH_VALUE
#define AR5416_CCA_MAX_GOOD_VALUE
#define AR5416_CCA_MIN_BAD_VALUE
#define NUM_NOISEFLOOR_READINGS
static void ar5416SanitizeNF(struct ath_hal *ah, int16_t *nf)
HAL_BOOL ar5416PerCalibrationN(struct ath_hal *ah, struct ieee80211_channel *chan, u_int rxchainmask, HAL_BOOL longcal, HAL_BOOL *isCalDone)
static int16_t ar5416GetNf(struct ath_hal *, struct ieee80211_channel *)
HAL_BOOL ar5416ResetCalValid(struct ath_hal *ah, const struct ieee80211_channel *chan)
static HAL_BOOL ar5416LoadNF(struct ath_hal *ah, const struct ieee80211_channel *)
static void ar5416ResetMeasurement(struct ath_hal *ah, HAL_CAL_LIST *currCal)
static void ar5416DoCalibration(struct ath_hal *ah, HAL_CHANNEL_INTERNAL *ichan, uint8_t rxchainmask, HAL_CAL_LIST *currCal, HAL_BOOL *isCalDone)
void ar5416InitNfHistBuff(struct ar5212NfCalHist *h)
static uint16_t ar5416GetDefaultNF(struct ath_hal *ah, const struct ieee80211_channel *chan)
static void ar5416UpdateNFHistBuff(struct ath_hal *ah, struct ar5212NfCalHist *h, int16_t *nfarray)
static OS_INLINE HAL_BOOL ar5416IsCalSupp(struct ath_hal *ah, const struct ieee80211_channel *chan, HAL_CAL_TYPE calType)
static HAL_BOOL ar5416GetEepromNoiseFloorThresh(struct ath_hal *ah, const struct ieee80211_channel *chan, int16_t *nft)
static void ar5416SetupMeasurement(struct ath_hal *ah, HAL_CAL_LIST *currCal)
HAL_BOOL ar5416InitCal(struct ath_hal *ah, const struct ieee80211_channel *chan)
HAL_BOOL ar5416InitCalHardware(struct ath_hal *ah, const struct ieee80211_channel *chan)
HAL_BOOL ar5416PerCalibration(struct ath_hal *ah, struct ieee80211_channel *chan, HAL_BOOL *isIQdone)
static void ar5416StartNFCal(struct ath_hal *ah)
#define AR5416_NUM_NF_READINGS
#define INSERT_CAL(_cal, _perCal)
#define INIT_CAL(_perCal)
#define AR_PHY_CALMODE_IQ
#define AR_PHY_TIMING_CTRL4_DO_CAL
#define AR_PHY_CALMODE_ADC_DC_PER
#define AR_PHY_CH1_EXT_CCA
#define AR_PHY_CH2_EXT_CCA
#define AR_PHY_CALMODE_ADC_DC_INIT
#define AR_PHY_CALMODE_ADC_GAIN
#define AR_SREV_SOWL_10_OR_LATER(_ah)
#define AR_SREV_KITE(_ah)
#define AR_SREV_KIWI(_ah)
#define AR_SREV_MERLIN_10_OR_LATER(_ah)
#define AR_SREV_HOWL(_ah)
#define AR_SREV_MERLIN(_ah)
int16_t noiseFloorExt[AH_MAX_CHAINS]
int16_t noiseFloorCtl[AH_MAX_CHAINS]
int16_t nfCalBuffer[AR512_NF_CAL_HIST_MAX]
HAL_CAL_LIST adcDcCalInitData
HAL_CAL_LIST adcGainCalData
HAL_CAL_SAMPLE caldata[4][AR5416_MAX_CHAINS]
HAL_CAL_LIST adcDcCalData
struct cal_list * calNext
const HAL_PERCAL_DATA * calData
void(* calCollect)(struct ath_hal *)
void(* calPostProc)(struct ath_hal *, uint8_t)