33#include "ar5212/ar5212.ini"
35#define N(a) (sizeof(a)/sizeof(a[0]))
48#define AR5111(ah) ((struct ar5111State *) AH5212(ah)->ah_rfHal)
56 uint16_t *pLowerPcdac, uint16_t *pUpperPcdac);
59 const uint16_t *pList, uint16_t listSize,
60 uint16_t *pLowerValue, uint16_t *pUpperValue);
62 uint32_t numBits, uint32_t firstBit, uint32_t column);
81#define CI_2GHZ_INDEX_CORRECTION 19
83 uint32_t refClk, reg32, data2111;
84 int16_t chan5111, chanIEEE;
92 uint32_t channelSelect;
148 chanIEEE = chan->ic_ieee;
149 if (IEEE80211_IS_CHAN_2GHZ(chan)) {
173 if (chan5111 >= 145 || (chan5111 & 0x1)) {
181 reg32 = (reg32 << 2) | (refClk << 1) | (1 << 10) | 0x1;
188#undef CI_2GHZ_INDEX_CORRECTION
221 uint16_t modesIndex, uint16_t *rfXpdGain)
226 uint16_t rfXpdGainFixed, rfPloSel, rfPwdXpd, gainI;
227 uint16_t tempOB, tempDB;
228 uint32_t ob2GHz, db2GHz, rfReg[
N(ar5212Bank6_5111)];
229 int i, regWrites = 0;
232 __func__, chan->ic_freq, chan->ic_flags, modesIndex);
236 case IEEE80211_CHAN_A:
237 if (4000 < freq && freq < 5260) {
240 }
else if (5260 <= freq && freq < 5500) {
243 }
else if (5500 <= freq && freq < 5725) {
246 }
else if (freq >= 5725) {
260 case IEEE80211_CHAN_B:
271 case IEEE80211_CHAN_G:
272 case IEEE80211_CHAN_PUREG:
285 __func__, chan->ic_flags);
293 for (i = 0; i <
N(ar5212Bank0_5111); i++)
294 rfReg[i] = ar5212Bank0_5111[i][modesIndex];
295 if (IEEE80211_IS_CHAN_2GHZ(chan)) {
311 for (i = 0; i <
N(ar5212Bank6_5111); i++)
312 rfReg[i] = ar5212Bank6_5111[i][modesIndex];
313 if (IEEE80211_IS_CHAN_A(chan)) {
325 for (i = 0; i <
N(ar5212Bank7_5111); i++)
326 rfReg[i] = ar5212Bank7_5111[i][modesIndex];
330 if (IEEE80211_IS_CHAN_QUARTER(chan) || IEEE80211_IS_CHAN_HALF(chan)) {
331 uint32_t rfWaitI, rfWaitS, rfMaxTime;
334 rfWaitI = (IEEE80211_IS_CHAN_HALF(chan)) ? 0x10 : 0x1f;
354 uint16_t targetLeft, uint16_t targetRight)
360 if ((targetLeft * targetRight) == 0)
363 if (srcRight != srcLeft) {
368 lRatio = (target - srcLeft) *
EEP_SCALE / (srcRight - srcLeft);
376 rv = (lRatio * targetRight + (
EEP_SCALE - lRatio) *
392 int16_t *pMinPower, int16_t *pMaxPower,
393 const struct ieee80211_channel *chan,
402 uint16_t *pPcdacValues;
403 int16_t *pScaledUpDbm;
404 int16_t minScaledPwr;
405 int16_t maxScaledPwr;
407 uint16_t pcdacMin = 0;
409 uint16_t pcdacTableIndex;
410 uint16_t scaledPcdac;
416 case IEEE80211_CHAN_A:
417 case IEEE80211_CHAN_ST:
422 case IEEE80211_CHAN_B:
427 case IEEE80211_CHAN_G:
428 case IEEE80211_CHAN_108G:
435 __func__, chan->ic_flags);
439 pSrcStruct = &eepromPcdacs;
441 OS_MEMZERO(&pcdacStruct,
sizeof(pcdacStruct));
456 pPcdacValues[j], pSrcStruct);
459 minScaledPwr = pScaledUpDbm[0];
464 if (minScaledPwr >= pScaledUpDbm[j]) {
465 minScaledPwr = pScaledUpDbm[j];
476 if (pScaledUpDbm[i-1] > pScaledUpDbm[i]) {
482 pScaledUpDbm[i - 1] = pScaledUpDbm[i];
487 if (maxScaledPwr < pScaledUpDbm[j]) {
488 maxScaledPwr = pScaledUpDbm[j];
509 (pwr - pScaledUpDbm[i])*(pwr - pScaledUpDbm[i+1]) > 0)
513 pScaledUpDbm[i], pScaledUpDbm[i + 1],
514 (uint16_t)(pPcdacValues[i] * 2),
515 (uint16_t)(pPcdacValues[i + 1] * 2)) + 1);
545 uint16_t lFreq, rFreq;
546 uint16_t llPcdac, ulPcdac;
547 uint16_t lrPcdac, urPcdac;
549 uint16_t lScaledPwr, rScaledPwr;
560 lFreq, pSrcStruct, &llPcdac, &ulPcdac);
562 rFreq, pSrcStruct, &lrPcdac, &urPcdac);
567 lScaledPwr =
interpolate(pcdacValue, llPcdac, ulPcdac, lPwr, uPwr);
571 rScaledPwr =
interpolate(pcdacValue, lrPcdac, urPcdac, lPwr, uPwr);
573 return interpolate(channel, lFreq, rFreq, lScaledPwr, rScaledPwr);
588 const uint16_t* pPcdac = pChannelData->
PcdacValues;
592 if (*pPcdac == pcdacValue) {
593 *powerValue = pChannelData->
PwrValues[j];
611 uint16_t *pLowerPcdac, uint16_t *pUpperPcdac)
624 pLowerPcdac, pUpperPcdac);
629 const struct ieee80211_channel *chan,
630 int16_t *maxPow, int16_t *minPow)
643 static const struct {
661 for (i = 0; c->
channel <= adjust5111[i].freqLow; i++)
663 return adjust5111[i].adjust;
695 "%s: cannot allocate private state\n", __func__);
uint32_t ath_hal_reverseBits(uint32_t val, uint32_t n)
#define HAL_INI_WRITE_BANK(ah, regArray, bankData, regWr)
#define IEEE80211_CHAN_ALLTURBOFULL
#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 IEEE80211_CHAN_ALLFULL
#define HALDEBUG(_ah, __m,...)
void ath_hal_free(void *p)
#define OS_MEMZERO(_a, _n)
#define OS_REG_WRITE(_ah, _reg, _val)
#define OS_MARK(_ah, _id, _v)
#define OS_REG_READ(_ah, _reg)
static void ar5111WriteRegs(struct ath_hal *ah, u_int modesIndex, u_int freqIndex, int writes)
void ar5212ModifyRfBuffer(uint32_t *rfBuf, uint32_t reg32, uint32_t numBits, uint32_t firstBit, uint32_t column)
static void ar5212GetLowerUpperPcdacs(uint16_t pcdac, uint16_t channel, const PCDACS_EEPROM *pSrcStruct, uint16_t *pLowerPcdac, uint16_t *pUpperPcdac)
static HAL_BOOL ar5111Probe(struct ath_hal *ah)
static uint16_t interpolate(uint16_t target, uint16_t srcLeft, uint16_t srcRight, uint16_t targetLeft, uint16_t targetRight)
static HAL_BOOL ar5111SetChannel(struct ath_hal *ah, const struct ieee80211_channel *chan)
static void ar5111RfDetach(struct ath_hal *ah)
static HAL_BOOL ar5111SetRfRegs(struct ath_hal *ah, const struct ieee80211_channel *chan, uint16_t modesIndex, uint16_t *rfXpdGain)
static int16_t ar5111GetNfAdjust(struct ath_hal *ah, const HAL_CHANNEL_INTERNAL *c)
static HAL_BOOL ar5111RfAttach(struct ath_hal *ah, HAL_STATUS *status)
static uint16_t ar5212GetScaledPower(uint16_t channel, uint16_t pcdacValue, const PCDACS_EEPROM *pSrcStruct)
AH_RF(RF5111, ar5111Probe, ar5111RfAttach)
static HAL_BOOL ar5111GetChannelMaxMinPower(struct ath_hal *ah, const struct ieee80211_channel *chan, int16_t *maxPow, int16_t *minPow)
static HAL_BOOL ar5212FindValueInList(uint16_t channel, uint16_t pcdacValue, const PCDACS_EEPROM *pSrcStruct, uint16_t *powerValue)
static uint32_t * ar5111GetRfBank(struct ath_hal *ah, int bank)
static HAL_BOOL ar5111SetPowerTable(struct ath_hal *ah, int16_t *pMinPower, int16_t *pMaxPower, const struct ieee80211_channel *chan, uint16_t *rfXpdGain)
#define CI_2GHZ_INDEX_CORRECTION
void ar5212GetLowerUpperValues(uint16_t value, const uint16_t *pList, uint16_t listSize, uint16_t *pLowerValue, uint16_t *pUpperValue)
static const CHAN_INFO_2GHZ chan2GHzData[]
#define AR_PHY_CCK_TX_CTRL_JAPAN
#define AR_PHY_CCK_TX_CTRL
uint16_t ee_channels11a[NUM_11A_EEPROM_CHANNELS]
DATA_PER_CHANNEL ee_dataPerChannel11a[NUM_11A_EEPROM_CHANNELS]
CORNER_CAL_INFO ee_cornerCal
uint16_t ee_channels11b[NUM_2_4_EEPROM_CHANNELS]
DATA_PER_CHANNEL ee_dataPerChannel11b[NUM_2_4_EEPROM_CHANNELS]
uint16_t ee_numChannels11a
uint16_t ee_numChannels2_4
DATA_PER_CHANNEL ee_dataPerChannel11g[NUM_2_4_EEPROM_CHANNELS]
uint16_t ee_channels11g[NUM_2_4_EEPROM_CHANNELS]
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 pcdacTable[PWR_TABLE_SIZE]
uint32_t Bank3Data[N(ar5212Bank3_5111)]
uint32_t Bank7Data[N(ar5212Bank7_5111)]
uint32_t Bank6Data[N(ar5212Bank6_5111)]
uint32_t Bank2Data[N(ar5212Bank2_5111)]
uint32_t Bank1Data[N(ar5212Bank1_5111)]
uint32_t Bank0Data[N(ar5212Bank0_5111)]
int16_t ah_txPowerIndexOffset
HAL_RFGAIN ah_rfgainState
int16_t PwrValues[NUM_PCDAC_VALUES]
uint16_t PcdacValues[NUM_PCDAC_VALUES]
const uint16_t * pChannelList
const DATA_PER_CHANNEL * pDataPerChannel