33#include "ar5212/ar5212.ini"
35#define N(a) (sizeof(a)/sizeof(a[0]))
39#define PWR_TABLE_SIZE_2317 PWR_TABLE_SIZE_2413
64#define AR2317(ah) ((struct ar2317State *) AH5212(ah)->ah_rfHal)
67 uint32_t numBits, uint32_t firstBit, uint32_t column);
87 uint32_t channelSel = 0;
88 uint32_t bModeSynth = 0;
89 uint32_t aModeRefSel = 0;
96 channelSel = freq - 2272 ;
108 }
else if ((freq % 20) == 0 && freq >= 5120) {
110 ((freq - 4800) / 20 << 2), 8);
112 }
else if ((freq % 10) == 0) {
114 ((freq - 4800) / 10 << 1), 8);
116 }
else if ((freq % 5) == 0) {
118 (freq - 4800) / 5, 8);
126 reg32 = (channelSel << 4) | (aModeRefSel << 2) | (bModeSynth << 1) |
145 const struct ieee80211_channel *chan,
146 uint16_t modesIndex, uint16_t *rfXpdGain)
148#define RF_BANK_SETUP(_priv, _ix, _col) do { \
150 for (i = 0; i < N(ar5212Bank##_ix##_2317); i++) \
151 (_priv)->Bank##_ix##Data[i] = ar5212Bank##_ix##_2317[i][_col];\
155 uint16_t ob2GHz = 0, db2GHz = 0;
160 __func__, chan->ic_freq, chan->ic_flags, modesIndex);
165 if (IEEE80211_IS_CHAN_B(chan)) {
232 uint32_t *vlo, uint32_t *vhi)
235 const int16_t *ep = lp+listSize;
241 if (target < lp[0]) {
245 if (target >= ep[-1]) {
246 *vlo = *vhi = listSize - 1;
251 for (tp = lp; tp < ep; tp++) {
257 *vlo = *vhi = tp - (
const int16_t *) lp;
264 if (target < tp[1]) {
265 *vlo = tp - (
const int16_t *) lp;
277 const int16_t *pwrList,
const int16_t *VpdList,
278 uint16_t numIntercepts, uint16_t retVpdList[][64])
281 int16_t currPwr = (int16_t)(2*Pmin);
288 if (numIntercepts < 2)
291 while (ii <= (uint16_t)(Pmax - Pmin)) {
296 if (idxL == (uint32_t)(numIntercepts - 1))
297 idxL = numIntercepts - 2;
298 if (pwrList[idxL] == pwrList[idxR])
302 (((currPwr - pwrList[idxL])*VpdList[idxR]+
303 (pwrList[idxR] - currPwr)*VpdList[idxL])/
304 (pwrList[idxR] - pwrList[idxL]));
305 retVpdList[pdGainIdx][ii] = kk;
318 int16_t targetLeft, int16_t targetRight)
322 if (srcRight != srcLeft) {
323 rv = ((target - srcLeft)*targetRight +
324 (srcRight - target)*targetLeft) / (srcRight - srcLeft);
338 uint16_t pdGainOverlap_t2,
339 int16_t *pMinCalPower, uint16_t pPdGainBoundaries[],
340 uint16_t pPdGainValues[], uint16_t pPDADCValues[])
343#define VpdTable_L priv->vpdTable_L
344#define VpdTable_R priv->vpdTable_R
345#define VpdTable_I priv->vpdTable_I
350 uint32_t numPdGainsUsed = 0;
362 uint32_t sizeCurrVpdTable, maxIndex, tgtIndex;
378 Pmin_t2[numPdGainsUsed] = (int16_t)
379 (Pmin_t2[numPdGainsUsed] / 2);
382 Pmax_t2[numPdGainsUsed] =
384 Pmax_t2[numPdGainsUsed] = (int16_t)(Pmax_t2[numPdGainsUsed] / 2);
386 numPdGainsUsed, Pmin_t2[numPdGainsUsed], Pmax_t2[numPdGainsUsed],
391 numPdGainsUsed, Pmin_t2[numPdGainsUsed], Pmax_t2[numPdGainsUsed],
395 for (kk = 0; kk < (uint16_t)(Pmax_t2[numPdGainsUsed] - Pmin_t2[numPdGainsUsed]); kk++) {
407 *pMinCalPower = Pmin_t2[0];
409 for (ii = 0; ii < numPdGainsUsed; ii++) {
410 if (ii == (numPdGainsUsed - 1))
411 pPdGainBoundaries[ii] = Pmax_t2[ii] +
414 pPdGainBoundaries[ii] = (uint16_t)
415 ((Pmax_t2[ii] + Pmin_t2[ii+1]) / 2 );
416 if (pPdGainBoundaries[ii] > 63) {
418 "%s: clamp pPdGainBoundaries[%d] %d\n",
419 __func__, ii, pPdGainBoundaries[ii]);
420 pPdGainBoundaries[ii] = 63;
427 ss = (pPdGainBoundaries[ii-1] - Pmin_t2[ii]) -
430 Vpd_step = (uint16_t)((Vpd_step < 1) ? 1 : Vpd_step);
435 tmpVal = (int16_t)(
VpdTable_I[ii][0] + ss*Vpd_step);
436 pPDADCValues[kk++] = (uint16_t)((tmpVal < 0) ? 0 : tmpVal);
440 sizeCurrVpdTable = Pmax_t2[ii] - Pmin_t2[ii];
441 tgtIndex = pPdGainBoundaries[ii] + pdGainOverlap_t2 - Pmin_t2[ii];
442 maxIndex = (tgtIndex < sizeCurrVpdTable) ? tgtIndex : sizeCurrVpdTable;
444 while (ss < (int16_t)maxIndex)
447 Vpd_step = (uint16_t)(
VpdTable_I[ii][sizeCurrVpdTable-1] -
449 Vpd_step = (uint16_t)((Vpd_step < 1) ? 1 : Vpd_step);
454 if (tgtIndex > maxIndex) {
455 while(ss < (int16_t)tgtIndex) {
458 (ss-maxIndex)*Vpd_step);
459 pPDADCValues[kk++] = (tmpVal > 127) ?
467 pPdGainBoundaries[ii] = pPdGainBoundaries[ii-1];
471 pPDADCValues[kk] = pPDADCValues[kk-1];
475 return numPdGainsUsed;
483 int16_t *minPower, int16_t *maxPower,
484 const struct ieee80211_channel *chan,
490 uint16_t pdGainOverlap_t2;
491 int16_t minCalPower2317_t2;
493 uint16_t gainBoundaries[4];
494 uint32_t reg32, regoffset;
495 int i, numPdGainsUsed;
496#ifndef AH_USE_INIPDGAIN
501 __func__, chan->ic_freq, chan->ic_flags);
503 if (IEEE80211_IS_CHAN_G(chan) || IEEE80211_IS_CHAN_108G(chan))
505 else if (IEEE80211_IS_CHAN_B(chan))
516 chan->channel, pRawDataset, pdGainOverlap_t2,
517 &minCalPower2317_t2,gainBoundaries, rfXpdGain, pdadcValues);
518 HALASSERT(1 <= numPdGainsUsed && numPdGainsUsed <= 3);
520#ifdef AH_USE_INIPDGAIN
531 tpcrg1 = (tpcrg1 &~ AR_PHY_TPCRG1_NUM_PD_GAIN)
533 switch (numPdGainsUsed) {
535 tpcrg1 &= ~AR_PHY_TPCRG1_PDGAIN_SETTING3;
539 tpcrg1 &= ~AR_PHY_TPCRG1_PDGAIN_SETTING2;
543 tpcrg1 &= ~AR_PHY_TPCRG1_PDGAIN_SETTING1;
550 "pd_gains (default 0x%x, calculated 0x%x)\n",
561 if (minCalPower2317_t2 != 0)
567 regoffset = 0x9800 + (672 <<2);
568 for (i = 0; i < 32; i++) {
569 reg32 = ((pdadcValues[4*i + 0] & 0xFF) << 0) |
570 ((pdadcValues[4*i + 1] & 0xFF) << 8) |
571 ((pdadcValues[4*i + 2] & 0xFF) << 16) |
572 ((pdadcValues[4*i + 3] & 0xFF) << 24) ;
591 uint16_t Pmin=0,numVpd;
609 uint16_t Pmax=0,numVpd;
626 const struct ieee80211_channel *chan,
627 int16_t *maxPow, int16_t *minPow)
629 uint16_t freq = chan->ic_freq;
633 uint16_t numChannels;
634 int totalD,totalF, totalMin,last, i;
638 if (IEEE80211_IS_CHAN_G(chan) || IEEE80211_IS_CHAN_108G(chan))
640 else if (IEEE80211_IS_CHAN_B(chan))
654 if ((freq < data[0].channelValue) ||
655 (freq > data[numChannels-1].channelValue)) {
656 if (freq < data[0].channelValue) {
668 for (last=0,i=0; (i<numChannels) && (freq > data[i].channelValue);
673 *maxPow = (int8_t) ((totalF*(freq-data[last].channelValue) +
676 *minPow = (int8_t) ((totalMin*(freq-data[last].channelValue) +
680 if (freq == data[i].channelValue) {
718 "%s: cannot allocate private state\n", __func__);
uint32_t ath_hal_reverseBits(uint32_t val, uint32_t n)
#define MAX_NUM_PDGAINS_PER_CHANNEL
#define PD_GAIN_BOUNDARY_STRETCH_IN_HALF_DB
#define MAX_PWR_RANGE_IN_HALF_DB
#define HAL_INI_WRITE_BANK(ah, regArray, bankData, regWr)
#define HAL_INI_WRITE_ARRAY(ah, regArray, col, regWr)
void * ath_hal_malloc(size_t)
static OS_INLINE uint16_t ath_hal_gethwchannel(struct ath_hal *ah, const struct ieee80211_channel *c)
#define OS_REG_RMW_FIELD(_a, _r, _f, _v)
#define HALDEBUG(_ah, __m,...)
void ath_hal_free(void *p)
#define OS_REG_WRITE(_ah, _reg, _val)
#define OS_MARK(_ah, _id, _v)
#define OS_REG_READ(_ah, _reg)
static HAL_BOOL ar2317SetPowerTable(struct ath_hal *ah, int16_t *minPower, int16_t *maxPower, const struct ieee80211_channel *chan, uint16_t *rfXpdGain)
static HAL_BOOL ar2317FillVpdTable(uint32_t pdGainIdx, int16_t Pmin, int16_t Pmax, const int16_t *pwrList, const int16_t *VpdList, uint16_t numIntercepts, uint16_t retVpdList[][64])
static void ar2317RfDetach(struct ath_hal *ah)
void ar5212ModifyRfBuffer(uint32_t *rfBuf, uint32_t reg32, uint32_t numBits, uint32_t firstBit, uint32_t column)
static HAL_BOOL ar2317RfAttach(struct ath_hal *ah, HAL_STATUS *status)
AH_RF(RF2317, ar2317Probe, ar2317RfAttach)
static HAL_BOOL ar2317GetChannelMaxMinPower(struct ath_hal *ah, const struct ieee80211_channel *chan, int16_t *maxPow, int16_t *minPow)
RAW_DATA_STRUCT_2413 RAW_DATA_STRUCT_2317
RAW_DATA_PER_CHANNEL_2413 RAW_DATA_PER_CHANNEL_2317
static HAL_BOOL ar2317Probe(struct ath_hal *ah)
static int16_t ar2317GetMinPower(struct ath_hal *ah, const RAW_DATA_PER_CHANNEL_2317 *data)
static uint32_t * ar2317GetRfBank(struct ath_hal *ah, int bank)
static void GetLowerUpperIndex(int16_t v, const uint16_t *lp, uint16_t listSize, uint32_t *vlo, uint32_t *vhi)
static HAL_BOOL ar2317SetRfRegs(struct ath_hal *ah, const struct ieee80211_channel *chan, uint16_t modesIndex, uint16_t *rfXpdGain)
static int16_t ar2317GetMaxPower(struct ath_hal *ah, const RAW_DATA_PER_CHANNEL_2317 *data)
#define RF_BANK_SETUP(_priv, _ix, _col)
static HAL_BOOL ar2317SetChannel(struct ath_hal *ah, const struct ieee80211_channel *chan)
static void ar2317WriteRegs(struct ath_hal *ah, u_int modesIndex, u_int freqIndex, int writes)
static int ar2317getGainBoundariesAndPdadcsForPowers(struct ath_hal *ah, uint16_t channel, const RAW_DATA_STRUCT_2317 *pRawDataset, uint16_t pdGainOverlap_t2, int16_t *pMinCalPower, uint16_t pPdGainBoundaries[], uint16_t pPdGainValues[], uint16_t pPDADCValues[])
#define PWR_TABLE_SIZE_2317
static int16_t interpolate_signed(uint16_t target, uint16_t srcLeft, uint16_t srcRight, int16_t targetLeft, int16_t targetRight)
int16_t ar5212GetNfAdjust(struct ath_hal *, const HAL_CHANNEL_INTERNAL *)
#define AR_PHY_TPCRG1_PDGAIN_SETTING1
#define AR_PHY_CCK_TX_CTRL_JAPAN
#define AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_4
#define AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_2
#define AR_PHY_TPCRG1_PDGAIN_SETTING3
#define AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_1
#define AR_PHY_TPCRG5_PD_GAIN_OVERLAP
#define AR_PHY_TPCRG1_PDGAIN_SETTING2
#define AR_PHY_TPCRG1_NUM_PD_GAIN
#define AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_3
#define AR_PHY_CCK_TX_CTRL
RAW_DATA_PER_PDGAIN_2413 pDataPerPDGain[MAX_NUM_PDGAINS_PER_CHANNEL]
int16_t pwr_t4[NUM_POINTS_LAST_PDGAIN]
uint16_t Vpd[NUM_POINTS_LAST_PDGAIN]
uint16_t pChannels[NUM_11A_EEPROM_CHANNELS_2413]
RAW_DATA_PER_CHANNEL_2413 pDataPerChannel[NUM_11A_EEPROM_CHANNELS_2413]
HAL_BOOL(* getChannelMaxMinPower)(struct ath_hal *ah, const struct ieee80211_channel *, int16_t *maxPow, int16_t *minPow)
HAL_BOOL(* setRfRegs)(struct ath_hal *, const struct ieee80211_channel *, uint16_t modesIndex, uint16_t *rfXpdGain)
HAL_BOOL(* setPowerTable)(struct ath_hal *ah, int16_t *minPower, int16_t *maxPower, const struct ieee80211_channel *, uint16_t *rfXpdGain)
HAL_BOOL(* setChannel)(struct ath_hal *, const struct ieee80211_channel *)
uint32_t *(* getRfBank)(struct ath_hal *ah, int bank)
void(* writeRegs)(struct ath_hal *, u_int modeIndex, u_int freqIndex, int regWrites)
int16_t(* getNfAdjust)(struct ath_hal *, const HAL_CHANNEL_INTERNAL *)
void(* rfDetach)(struct ath_hal *ah)
uint16_t vpdTable_R[MAX_NUM_PDGAINS_PER_CHANNEL][MAX_PWR_RANGE_IN_HALF_DB]
uint32_t Bank3Data[N(ar5212Bank3_2317)]
uint16_t pcdacTable[PWR_TABLE_SIZE_2317]
uint32_t Bank7Data[N(ar5212Bank7_2317)]
uint32_t Bank2Data[N(ar5212Bank2_2317)]
uint32_t Bank1Data[N(ar5212Bank1_2317)]
uint32_t Bank6Data[N(ar5212Bank6_2317)]
uint16_t vpdTable_I[MAX_NUM_PDGAINS_PER_CHANNEL][MAX_PWR_RANGE_IN_HALF_DB]
uint16_t vpdTable_L[MAX_NUM_PDGAINS_PER_CHANNEL][MAX_PWR_RANGE_IN_HALF_DB]
int16_t ah_txPowerIndexOffset
HAL_RFGAIN ah_rfgainState