iPXE
Data Structures | Macros | 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
 

Macros

#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)
 

Macro Definition Documentation

◆ AR_PHY_CCA_FILTERWINDOW_LENGTH_INIT

#define AR_PHY_CCA_FILTERWINDOW_LENGTH_INIT   3

Definition at line 27 of file calib.h.

◆ AR_PHY_CCA_FILTERWINDOW_LENGTH

#define AR_PHY_CCA_FILTERWINDOW_LENGTH   5

Definition at line 28 of file calib.h.

◆ NUM_NF_READINGS

#define NUM_NF_READINGS   6

Definition at line 30 of file calib.h.

◆ ATH9K_NF_CAL_HIST_MAX

#define ATH9K_NF_CAL_HIST_MAX   5

Definition at line 31 of file calib.h.

◆ INIT_INI_ARRAY

#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)
uint32_t array
Array number.
Definition: edd.h:30
uint32_t u32
Definition: stdint.h:23

Definition at line 39 of file calib.h.

◆ INI_RA

#define INI_RA (   iniarray,
  row,
  column 
)    (((iniarray)->ia_array)[(row) * ((iniarray)->ia_columns) + (column)])

Definition at line 45 of file calib.h.

◆ INIT_CAL

#define INIT_CAL (   _perCal)
Value:
do { \
(_perCal)->calState = CAL_WAITING; \
(_perCal)->calNext = NULL; \
} while (0)
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

Definition at line 48 of file calib.h.

◆ INSERT_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)
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

Definition at line 53 of file calib.h.

◆ MIN_CAL_SAMPLES

#define MIN_CAL_SAMPLES   1

Definition at line 73 of file calib.h.

◆ MAX_CAL_SAMPLES

#define MAX_CAL_SAMPLES   64

Definition at line 74 of file calib.h.

◆ INIT_LOG_COUNT

#define INIT_LOG_COUNT   5

Definition at line 75 of file calib.h.

◆ PER_MIN_LOG_COUNT

#define PER_MIN_LOG_COUNT   2

Definition at line 76 of file calib.h.

◆ PER_MAX_LOG_COUNT

#define PER_MAX_LOG_COUNT   10

Definition at line 77 of file calib.h.

◆ MAX_PACAL_SKIPCOUNT

#define MAX_PACAL_SKIPCOUNT   8

Definition at line 100 of file calib.h.

Enumeration Type Documentation

◆ ath9k_cal_state

Enumerator
CAL_INACTIVE 
CAL_WAITING 
CAL_RUNNING 
CAL_DONE 

Definition at line 66 of file calib.h.

66  {
70  CAL_DONE
71 };
Definition: calib.h:70

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( BSD2  )

◆ ath9k_hw_reset_calvalid()

int ath9k_hw_reset_calvalid ( struct ath_hw ah)

Definition at line 173 of file ath9k_calib.c.

174 {
175  struct ath9k_cal_list *currCal = ah->cal_list_curr;
176 
177  if (!ah->caldata)
178  return 1;
179 
181  return 1;
182 
183  if (currCal == NULL)
184  return 1;
185 
186  if (currCal->calState != CAL_DONE) {
187  DBG("ath9k: "
188  "Calibration state incorrect, %d\n",
189  currCal->calState);
190  return 1;
191  }
192 
193  if (!(ah->supp_cals & currCal->calData->calType))
194  return 1;
195 
196  DBG("ath9k: "
197  "Resetting Cal %d state for channel %d\n",
198  currCal->calData->calType, (ah->dev->channels + ah->dev->channel)->center_freq);
199 
200  ah->caldata->CalValid &= ~currCal->calData->calType;
201  currCal->calState = CAL_WAITING;
202 
203  return 0;
204 }
#define AR_SREV_9100(ah)
Definition: reg.h:810
Definition: calib.h:70
const struct ath9k_percal_data * calData
Definition: calib.h:88
uint8_t ah
Definition: registers.h:85
#define AR_SREV_9160_10_OR_LATER(_ah)
Definition: reg.h:817
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
enum ath9k_cal_state calState
Definition: calib.h:89

References ah, AR_SREV_9100, AR_SREV_9160_10_OR_LATER, CAL_DONE, CAL_WAITING, ath9k_cal_list::calData, ath9k_cal_list::calState, ath9k_percal_data::calType, DBG, and NULL.

Referenced by ath_ani_calibrate().

◆ ath9k_hw_start_nfcal()

void ath9k_hw_start_nfcal ( struct ath_hw ah,
int  update 
)

Definition at line 206 of file ath9k_calib.c.

207 {
208  if (ah->caldata)
209  ah->caldata->nfcal_pending = 1;
210 
213 
214  if (update)
217  else
220 
222 }
#define REG_CLR_BIT(_a, _r, _f)
Definition: hw.h:109
#define AR_PHY_AGC_CONTROL_NO_UPDATE_NF
Definition: reg.h:1915
#define AR_PHY_AGC_CONTROL
Definition: reg.h:1909
#define AR_PHY_AGC_CONTROL_NF
Definition: reg.h:1911
#define AR_PHY_AGC_CONTROL_ENABLE_NF
Definition: reg.h:1913
#define REG_SET_BIT(_a, _r, _f)
Definition: hw.h:107
uint8_t ah
Definition: registers.h:85

References ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_ENABLE_NF, AR_PHY_AGC_CONTROL_NF, AR_PHY_AGC_CONTROL_NO_UPDATE_NF, REG_CLR_BIT, and REG_SET_BIT.

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

◆ ath9k_hw_loadnf()

void ath9k_hw_loadnf ( struct ath_hw ah,
struct ath9k_channel chan 
)

Definition at line 224 of file ath9k_calib.c.

225 {
226  struct ath9k_nfcal_hist *h = NULL;
227  unsigned i, j;
228  int32_t val;
229  u8 chainmask = (ah->rxchainmask << 3) | ah->rxchainmask;
230  s16 default_nf = ath9k_hw_get_default_nf(ah, chan);
231 
232  if (ah->caldata)
233  h = ah->caldata->nfCalHist;
234 
235  for (i = 0; i < NUM_NF_READINGS; i++) {
236  if (chainmask & (1 << i)) {
237  s16 nfval;
238 
239  if (i >= AR5416_MAX_CHAINS)
240  continue;
241 
242  if (h)
243  nfval = h[i].privNF;
244  else
245  nfval = default_nf;
246 
247  val = REG_READ(ah, ah->nf_regs[i]);
248  val &= 0xFFFFFE00;
249  val |= (((u32) nfval << 1) & 0x1ff);
250  REG_WRITE(ah, ah->nf_regs[i], val);
251  }
252  }
253 
254  /*
255  * Load software filtered NF value into baseband internal minCCApwr
256  * variable.
257  */
263 
264  /*
265  * Wait for load to complete, should be fast, a few 10s of us.
266  * The max delay was changed from an original 250us to 10000us
267  * since 250us often results in NF load timeout and causes deaf
268  * condition during stress testing 12/12/2009
269  */
270  for (j = 0; j < 10000; j++) {
272  AR_PHY_AGC_CONTROL_NF) == 0)
273  break;
274  udelay(10);
275  }
276 
277  /*
278  * We timed out waiting for the noisefloor to load, probably due to an
279  * in-progress rx. Simply return here and allow the load plenty of time
280  * to complete before the next calibration interval. We need to avoid
281  * trying to load -50 (which happens below) while the previous load is
282  * still in progress as this can cause rx deafness. Instead by returning
283  * here, the baseband nf cal will just be capped by our present
284  * noisefloor until the next calibration timer.
285  */
286  if (j == 10000) {
287  DBG("ath9k: "
288  "Timeout while waiting for nf to load: AR_PHY_AGC_CONTROL=0x%x\n",
290  return;
291  }
292 
293  /*
294  * Restore maxCCAPower register parameter again so that we're not capped
295  * by the median we just loaded. This will be initial (and max) value
296  * of next noise floor calibration the baseband does.
297  */
299  for (i = 0; i < NUM_NF_READINGS; i++) {
300  if (chainmask & (1 << i)) {
301  if (i >= AR5416_MAX_CHAINS)
302  continue;
303 
304  val = REG_READ(ah, ah->nf_regs[i]);
305  val &= 0xFFFFFE00;
306  val |= (((u32) (-50) << 1) & 0x1ff);
307  REG_WRITE(ah, ah->nf_regs[i], val);
308  }
309  }
311 }
int16_t s16
Definition: stdint.h:20
#define REG_CLR_BIT(_a, _r, _f)
Definition: hw.h:109
#define AR_PHY_AGC_CONTROL_NO_UPDATE_NF
Definition: reg.h:1915
#define REGWRITE_BUFFER_FLUSH(_ah)
Definition: hw.h:95
uint32_t h
Definition: sha256.c:35
#define u32
Definition: vga.h:21
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define AR_PHY_AGC_CONTROL
Definition: reg.h:1909
#define AR_PHY_AGC_CONTROL_NF
Definition: reg.h:1911
#define AR_PHY_AGC_CONTROL_ENABLE_NF
Definition: reg.h:1913
#define REG_READ(_ah, _reg)
Definition: hw.h:80
void __asmcall int val
Definition: setjmp.h:28
#define AR5416_MAX_CHAINS
Definition: eeprom.h:159
#define REG_SET_BIT(_a, _r, _f)
Definition: hw.h:107
signed int int32_t
Definition: stdint.h:17
#define REG_WRITE(_ah, _reg, _val)
Definition: hw.h:77
#define NUM_NF_READINGS
Definition: calib.h:30
uint8_t ah
Definition: registers.h:85
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
static s16 ath9k_hw_get_default_nf(struct ath_hw *ah, struct ath9k_channel *chan)
Definition: ath9k_calib.c:63
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
uint8_t u8
Definition: stdint.h:19
#define ENABLE_REGWRITE_BUFFER(_ah)
Definition: hw.h:89

References ah, 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(), DBG, ENABLE_REGWRITE_BUFFER, h, NULL, NUM_NF_READINGS, REG_CLR_BIT, REG_READ, REG_SET_BIT, REG_WRITE, REGWRITE_BUFFER_FLUSH, u32, udelay(), and val.

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

◆ ath9k_hw_getnf()

int ath9k_hw_getnf ( struct ath_hw ah,
struct ath9k_channel chan 
)

Definition at line 346 of file ath9k_calib.c.

347 {
348  int16_t nf, nfThresh;
349  int16_t nfarray[NUM_NF_READINGS] = { 0 };
350  struct ath9k_nfcal_hist *h;
351  struct net80211_channel *c = chan->chan;
352  struct ath9k_hw_cal_data *caldata = ah->caldata;
353 
354  chan->channelFlags &= (~CHANNEL_CW_INT);
356  DBG("ath9k: "
357  "NF did not complete in calibration window\n");
358  return 0;
359  }
360 
361  ath9k_hw_do_getnf(ah, nfarray);
362  ath9k_hw_nf_sanitize(ah, nfarray);
363  nf = nfarray[0];
364  if (ath9k_hw_get_nf_thresh(ah, c->band, &nfThresh)
365  && nf > nfThresh) {
366  DBG2("ath9k: "
367  "noise floor failed detected; detected %d, threshold %d\n",
368  nf, nfThresh);
369  chan->channelFlags |= CHANNEL_CW_INT;
370  }
371 
372  if (!caldata) {
373  chan->noisefloor = nf;
374  return 0;
375  }
376 
377  h = caldata->nfCalHist;
378  caldata->nfcal_pending = 0;
379  ath9k_hw_update_nfcal_hist_buffer(ah, caldata, nfarray);
380  chan->noisefloor = h[0].privNF;
381  return 1;
382 }
uint32_t c
Definition: md4.c:30
static void ath9k_hw_nf_sanitize(struct ath_hw *ah, s16 *nf)
Definition: ath9k_calib.c:314
static void ath9k_hw_update_nfcal_hist_buffer(struct ath_hw *ah, struct ath9k_hw_cal_data *cal, int16_t *nfarray)
Definition: ath9k_calib.c:70
static int ath9k_hw_get_nf_thresh(struct ath_hw *ah, int band, int16_t *nft)
Definition: ath9k_calib.c:135
struct net80211_channel * chan
Definition: hw.h:347
u32 channelFlags
Definition: hw.h:350
int nfcal_pending
Definition: hw.h:339
uint32_t h
Definition: sha256.c:35
#define AR_PHY_AGC_CONTROL
Definition: reg.h:1909
#define CHANNEL_CW_INT
Definition: ath5k.h:628
An 802.11 RF channel.
Definition: net80211.h:385
#define AR_PHY_AGC_CONTROL_NF
Definition: reg.h:1911
#define REG_READ(_ah, _reg)
Definition: hw.h:80
s16 noisefloor
Definition: hw.h:352
#define NUM_NF_READINGS
Definition: calib.h:30
uint8_t ah
Definition: registers.h:85
static void ath9k_hw_do_getnf(struct ath_hw *ah, int16_t nfarray[NUM_NF_READINGS])
Definition: hw-ops.h:252
signed short int16_t
Definition: stdint.h:16
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
#define DBG2(...)
Definition: compiler.h:515
struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS]
Definition: hw.h:343

References ah, 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(), c, 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, and REG_READ.

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

◆ ath9k_init_nfcal_hist_buffer()

void ath9k_init_nfcal_hist_buffer ( struct ath_hw ah,
struct ath9k_channel chan 
)

Definition at line 384 of file ath9k_calib.c.

386 {
387  struct ath9k_nfcal_hist *h;
388  s16 default_nf;
389  int i, j;
390 
391  ah->caldata->channel = chan->channel;
392  ah->caldata->channelFlags = chan->channelFlags & ~CHANNEL_CW_INT;
393  h = ah->caldata->nfCalHist;
394  default_nf = ath9k_hw_get_default_nf(ah, chan);
395  for (i = 0; i < NUM_NF_READINGS; i++) {
396  h[i].currIndex = 0;
397  h[i].privNF = default_nf;
398  h[i].invalidNFcount = AR_PHY_CCA_FILTERWINDOW_LENGTH;
399  for (j = 0; j < ATH9K_NF_CAL_HIST_MAX; j++) {
400  h[i].nfCalBuffer[j] = default_nf;
401  }
402  }
403 }
u16 channel
Definition: hw.h:349
int16_t s16
Definition: stdint.h:20
#define AR_PHY_CCA_FILTERWINDOW_LENGTH
Definition: calib.h:28
u32 channelFlags
Definition: hw.h:350
uint32_t h
Definition: sha256.c:35
#define CHANNEL_CW_INT
Definition: ath5k.h:628
#define NUM_NF_READINGS
Definition: calib.h:30
uint8_t ah
Definition: registers.h:85
static s16 ath9k_hw_get_default_nf(struct ath_hw *ah, struct ath9k_channel *chan)
Definition: ath9k_calib.c:63
#define ATH9K_NF_CAL_HIST_MAX
Definition: calib.h:31

References ah, AR_PHY_CCA_FILTERWINDOW_LENGTH, ath9k_hw_get_default_nf(), ATH9K_NF_CAL_HIST_MAX, ath9k_channel::channel, CHANNEL_CW_INT, ath9k_channel::channelFlags, h, and NUM_NF_READINGS.

Referenced by ath9k_hw_reset().

◆ ath9k_hw_reset_calibration()

void ath9k_hw_reset_calibration ( struct ath_hw ah,
struct ath9k_cal_list currCal 
)

Definition at line 153 of file ath9k_calib.c.

155 {
156  int i;
157 
158  ath9k_hw_setup_calibration(ah, currCal);
159 
160  currCal->calState = CAL_RUNNING;
161 
162  for (i = 0; i < AR5416_MAX_CHAINS; i++) {
163  ah->meas0.sign[i] = 0;
164  ah->meas1.sign[i] = 0;
165  ah->meas2.sign[i] = 0;
166  ah->meas3.sign[i] = 0;
167  }
168 
169  ah->cal_samples = 0;
170 }
static void ath9k_hw_setup_calibration(struct ath_hw *ah, struct ath9k_cal_list *currCal)
Definition: hw-ops.h:264
#define AR5416_MAX_CHAINS
Definition: eeprom.h:159
uint8_t ah
Definition: registers.h:85
enum ath9k_cal_state calState
Definition: calib.h:89

References ah, AR5416_MAX_CHAINS, ath9k_hw_setup_calibration(), CAL_RUNNING, and ath9k_cal_list::calState.

Referenced by ar9002_hw_calibrate(), ar9002_hw_init_cal(), ar9002_hw_per_calibration(), ar9003_hw_calibrate(), ar9003_hw_init_cal(), and ar9003_hw_per_calibration().