iPXE
Data Structures | Defines | Enumerations | Functions
calib.h File Reference
#include "hw.h"

Go to the source code of this file.

Data Structures

struct  ar5416IniArray
struct  ath9k_percal_data
struct  ath9k_cal_list
struct  ath9k_nfcal_hist
struct  ath9k_pacal_info

Defines

#define AR_PHY_CCA_FILTERWINDOW_LENGTH_INIT   3
#define AR_PHY_CCA_FILTERWINDOW_LENGTH   5
#define NUM_NF_READINGS   6
#define ATH9K_NF_CAL_HIST_MAX   5
#define INIT_INI_ARRAY(iniarray, array, rows, columns)
#define INI_RA(iniarray, row, column)   (((iniarray)->ia_array)[(row) * ((iniarray)->ia_columns) + (column)])
#define INIT_CAL(_perCal)
#define INSERT_CAL(_ahp, _perCal)
#define MIN_CAL_SAMPLES   1
#define MAX_CAL_SAMPLES   64
#define INIT_LOG_COUNT   5
#define PER_MIN_LOG_COUNT   2
#define PER_MAX_LOG_COUNT   10
#define MAX_PACAL_SKIPCOUNT   8

Enumerations

enum  ath9k_cal_state { CAL_INACTIVE, CAL_WAITING, CAL_RUNNING, CAL_DONE }

Functions

 FILE_LICENCE (BSD2)
int ath9k_hw_reset_calvalid (struct ath_hw *ah)
void ath9k_hw_start_nfcal (struct ath_hw *ah, int update)
void ath9k_hw_loadnf (struct ath_hw *ah, struct ath9k_channel *chan)
int ath9k_hw_getnf (struct ath_hw *ah, struct ath9k_channel *chan)
void ath9k_init_nfcal_hist_buffer (struct ath_hw *ah, struct ath9k_channel *chan)
void ath9k_hw_reset_calibration (struct ath_hw *ah, struct ath9k_cal_list *currCal)

Define Documentation

Definition at line 27 of file calib.h.

Definition at line 28 of file calib.h.

Referenced by ath9k_init_nfcal_hist_buffer().

#define NUM_NF_READINGS   6
#define ATH9K_NF_CAL_HIST_MAX   5
#define INIT_INI_ARRAY (   iniarray,
  array,
  rows,
  columns 
)
Value:
do {    \
                (iniarray)->ia_array = (u32 *)(array);          \
                (iniarray)->ia_rows = (rows);                   \
                (iniarray)->ia_columns = (columns);             \
        } while (0)

Definition at line 39 of file calib.h.

Referenced by ar9002_hw_cck_chan14_spread(), ar9002_hw_init_mode_gain_regs(), ar9002_hw_init_mode_regs(), ar9003_hw_init_mode_regs(), ar9003_rx_gain_table_apply(), ar9003_tx_gain_table_apply(), ar9280_20_hw_init_rxgain_ini(), and ar9280_20_hw_init_txgain_ini().

#define INI_RA (   iniarray,
  row,
  column 
)    (((iniarray)->ia_array)[(row) * ((iniarray)->ia_columns) + (column)])
#define INIT_CAL (   _perCal)
Value:
do {                            \
                (_perCal)->calState = CAL_WAITING;      \
                (_perCal)->calNext = NULL;              \
        } while (0)

Definition at line 48 of file calib.h.

Referenced by ar9002_hw_init_cal(), and ar9003_hw_init_cal().

#define INSERT_CAL (   _ahp,
  _perCal 
)
Value:
do {                                                            \
                if ((_ahp)->cal_list_last == NULL) {                    \
                        (_ahp)->cal_list =                              \
                                (_ahp)->cal_list_last = (_perCal);      \
                        ((_ahp)->cal_list_last)->calNext = (_perCal); \
                } else {                                                \
                        ((_ahp)->cal_list_last)->calNext = (_perCal); \
                        (_ahp)->cal_list_last = (_perCal);              \
                        (_perCal)->calNext = (_ahp)->cal_list;  \
                }                                                       \
        } while (0)

Definition at line 53 of file calib.h.

Referenced by ar9002_hw_init_cal(), and ar9003_hw_init_cal().

#define MIN_CAL_SAMPLES   1

Definition at line 73 of file calib.h.

#define MAX_CAL_SAMPLES   64

Definition at line 74 of file calib.h.

#define INIT_LOG_COUNT   5

Definition at line 75 of file calib.h.

#define PER_MIN_LOG_COUNT   2

Definition at line 76 of file calib.h.

#define PER_MAX_LOG_COUNT   10

Definition at line 77 of file calib.h.

#define MAX_PACAL_SKIPCOUNT   8

Definition at line 100 of file calib.h.

Referenced by ar9271_hw_pa_cal(), and ar9285_hw_pa_cal().


Enumeration Type Documentation

Enumerator:
CAL_INACTIVE 
CAL_WAITING 
CAL_RUNNING 
CAL_DONE 

Definition at line 66 of file calib.h.


Function Documentation

FILE_LICENCE ( BSD2  )
int ath9k_hw_reset_calvalid ( struct ath_hw ah)

Definition at line 173 of file ath9k_calib.c.

References AR_SREV_9100, AR_SREV_9160_10_OR_LATER, CAL_DONE, ath_hw::cal_list_curr, CAL_WAITING, ath9k_cal_list::calData, ath_hw::caldata, ath9k_cal_list::calState, ath9k_percal_data::calType, ath9k_hw_cal_data::CalValid, net80211_device::channel, net80211_device::channels, DBG, ath_hw::dev, NULL, and ath_hw::supp_cals.

Referenced by ath_ani_calibrate().

{
        struct ath9k_cal_list *currCal = ah->cal_list_curr;

        if (!ah->caldata)
                return 1;

        if (!AR_SREV_9100(ah) && !AR_SREV_9160_10_OR_LATER(ah))
                return 1;

        if (currCal == NULL)
                return 1;

        if (currCal->calState != CAL_DONE) {
                DBG("ath9k: "
                        "Calibration state incorrect, %d\n",
                        currCal->calState);
                return 1;
        }

        if (!(ah->supp_cals & currCal->calData->calType))
                return 1;

        DBG("ath9k: "
                "Resetting Cal %d state for channel %d\n",
                currCal->calData->calType, (ah->dev->channels + ah->dev->channel)->center_freq);

        ah->caldata->CalValid &= ~currCal->calData->calType;
        currCal->calState = CAL_WAITING;

        return 0;
}
void ath9k_hw_start_nfcal ( struct ath_hw ah,
int  update 
)
void ath9k_hw_loadnf ( struct ath_hw ah,
struct ath9k_channel chan 
)

Definition at line 224 of file ath9k_calib.c.

References AR5416_MAX_CHAINS, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_ENABLE_NF, AR_PHY_AGC_CONTROL_NF, AR_PHY_AGC_CONTROL_NO_UPDATE_NF, ath9k_hw_get_default_nf(), ath_hw::caldata, DBG, ENABLE_REGWRITE_BUFFER, h, ath_hw::nf_regs, ath9k_hw_cal_data::nfCalHist, NULL, NUM_NF_READINGS, ath9k_nfcal_hist::privNF, REG_CLR_BIT, REG_READ, REG_SET_BIT, REG_WRITE, REGWRITE_BUFFER_FLUSH, ath_hw::rxchainmask, udelay(), and val.

Referenced by ar9002_hw_calibrate(), ar9003_hw_calibrate(), and ath9k_hw_reset().

{
        struct ath9k_nfcal_hist *h = NULL;
        unsigned i, j;
        int32_t val;
        u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
        s16 default_nf = ath9k_hw_get_default_nf(ah, chan);

        if (ah->caldata)
                h = ah->caldata->nfCalHist;

        for (i = 0; i < NUM_NF_READINGS; i++) {
                if (chainmask & (1 << i)) {
                        s16 nfval;

                        if (i >= AR5416_MAX_CHAINS)
                                continue;

                        if (h)
                                nfval = h[i].privNF;
                        else
                                nfval = default_nf;

                        val = REG_READ(ah, ah->nf_regs[i]);
                        val &= 0xFFFFFE00;
                        val |= (((u32) nfval << 1) & 0x1ff);
                        REG_WRITE(ah, ah->nf_regs[i], val);
                }
        }

        /*
         * Load software filtered NF value into baseband internal minCCApwr
         * variable.
         */
        REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL,
                    AR_PHY_AGC_CONTROL_ENABLE_NF);
        REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL,
                    AR_PHY_AGC_CONTROL_NO_UPDATE_NF);
        REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF);

        /*
         * Wait for load to complete, should be fast, a few 10s of us.
         * The max delay was changed from an original 250us to 10000us
         * since 250us often results in NF load timeout and causes deaf
         * condition during stress testing 12/12/2009
         */
        for (j = 0; j < 10000; j++) {
                if ((REG_READ(ah, AR_PHY_AGC_CONTROL) &
                     AR_PHY_AGC_CONTROL_NF) == 0)
                        break;
                udelay(10);
        }

        /*
         * We timed out waiting for the noisefloor to load, probably due to an
         * in-progress rx. Simply return here and allow the load plenty of time
         * to complete before the next calibration interval.  We need to avoid
         * trying to load -50 (which happens below) while the previous load is
         * still in progress as this can cause rx deafness. Instead by returning
         * here, the baseband nf cal will just be capped by our present
         * noisefloor until the next calibration timer.
         */
        if (j == 10000) {
                DBG("ath9k: "
                        "Timeout while waiting for nf to load: AR_PHY_AGC_CONTROL=0x%x\n",
                        REG_READ(ah, AR_PHY_AGC_CONTROL));
                return;
        }

        /*
         * Restore maxCCAPower register parameter again so that we're not capped
         * by the median we just loaded.  This will be initial (and max) value
         * of next noise floor calibration the baseband does.
         */
        ENABLE_REGWRITE_BUFFER(ah);
        for (i = 0; i < NUM_NF_READINGS; i++) {
                if (chainmask & (1 << i)) {
                        if (i >= AR5416_MAX_CHAINS)
                                continue;

                        val = REG_READ(ah, ah->nf_regs[i]);
                        val &= 0xFFFFFE00;
                        val |= (((u32) (-50) << 1) & 0x1ff);
                        REG_WRITE(ah, ah->nf_regs[i], val);
                }
        }
        REGWRITE_BUFFER_FLUSH(ah);
}
int ath9k_hw_getnf ( struct ath_hw ah,
struct ath9k_channel chan 
)

Definition at line 346 of file ath9k_calib.c.

References AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF, ath9k_hw_do_getnf(), ath9k_hw_get_nf_thresh(), ath9k_hw_nf_sanitize(), ath9k_hw_update_nfcal_hist_buffer(), net80211_channel::band, ath_hw::caldata, ath9k_channel::chan, CHANNEL_CW_INT, ath9k_channel::channelFlags, DBG, DBG2, h, ath9k_hw_cal_data::nfcal_pending, ath9k_hw_cal_data::nfCalHist, ath9k_channel::noisefloor, NUM_NF_READINGS, ath9k_nfcal_hist::privNF, and REG_READ.

Referenced by ar9002_hw_calibrate(), ar9003_hw_calibrate(), and ath9k_hw_reset().

{
        int16_t nf, nfThresh;
        int16_t nfarray[NUM_NF_READINGS] = { 0 };
        struct ath9k_nfcal_hist *h;
        struct net80211_channel *c = chan->chan;
        struct ath9k_hw_cal_data *caldata = ah->caldata;

        chan->channelFlags &= (~CHANNEL_CW_INT);
        if (REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF) {
                DBG("ath9k: "
                        "NF did not complete in calibration window\n");
                return 0;
        }

        ath9k_hw_do_getnf(ah, nfarray);
        ath9k_hw_nf_sanitize(ah, nfarray);
        nf = nfarray[0];
        if (ath9k_hw_get_nf_thresh(ah, c->band, &nfThresh)
            && nf > nfThresh) {
                DBG2("ath9k: "
                        "noise floor failed detected; detected %d, threshold %d\n",
                        nf, nfThresh);
                chan->channelFlags |= CHANNEL_CW_INT;
        }

        if (!caldata) {
                chan->noisefloor = nf;
                return 0;
        }

        h = caldata->nfCalHist;
        caldata->nfcal_pending = 0;
        ath9k_hw_update_nfcal_hist_buffer(ah, caldata, nfarray);
        chan->noisefloor = h[0].privNF;
        return 1;
}
void ath9k_init_nfcal_hist_buffer ( struct ath_hw ah,
struct ath9k_channel chan 
)
void ath9k_hw_reset_calibration ( struct ath_hw ah,
struct ath9k_cal_list currCal 
)