Lines Matching +full:lower +full:- +full:cal

1 /*-
2 * SPDX-License-Identifier: ISC
4 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
5 * Copyright (c) 2002-2008 Atheros Communications, Inc.
62 #define AR2316(ah) ((struct ar2316State *) AH5212(ah)->ah_rfHal)
78 if (!ahp->ah_cwCalRequire) { in ar2316WriteRegs()
81 ahp->ah_cwCalRequire = AH_FALSE; in ar2316WriteRegs()
104 if (((freq - 2192) % 5) == 0) { in ar2316SetChannel()
105 channelSel = ((freq - 672) * 2 - 3040)/10; in ar2316SetChannel()
107 } else if (((freq - 2224) % 5) == 0) { in ar2316SetChannel()
108 channelSel = ((freq - 704) * 2 - 3040) / 10; in ar2316SetChannel()
131 ((freq - 4800) / 20 << 2), 8); in ar2316SetChannel()
135 ((freq - 4800) / 10 << 1), 8); in ar2316SetChannel()
139 (freq - 4800) / 5, 8); in ar2316SetChannel()
154 AH_PRIVATE(ah)->ah_curchan = chan; in ar2316SetChannel()
171 (_priv)->Bank##_ix##Data[i] = ar5212Bank##_ix##_2316[i][_col];\ in ar2316SetRfRegs()
174 const HAL_EEPROM *ee = AH_PRIVATE(ah)->ah_eeprom; in ar2316SetRfRegs()
180 __func__, chan->ic_freq, chan->ic_flags, modesIndex); in ar2316SetRfRegs()
186 ob2GHz = ee->ee_obFor24; in ar2316SetRfRegs()
187 db2GHz = ee->ee_dbFor24; in ar2316SetRfRegs()
189 ob2GHz = ee->ee_obFor24g; in ar2316SetRfRegs()
190 db2GHz = ee->ee_dbFor24g; in ar2316SetRfRegs()
205 ar5212ModifyRfBuffer(priv->Bank6Data, ob2GHz, 3, 178, 0); in ar2316SetRfRegs()
206 ar5212ModifyRfBuffer(priv->Bank6Data, db2GHz, 3, 175, 0); in ar2316SetRfRegs()
212 HAL_INI_WRITE_BANK(ah, ar5212Bank1_2316, priv->Bank1Data, regWrites); in ar2316SetRfRegs()
213 HAL_INI_WRITE_BANK(ah, ar5212Bank2_2316, priv->Bank2Data, regWrites); in ar2316SetRfRegs()
214 HAL_INI_WRITE_BANK(ah, ar5212Bank3_2316, priv->Bank3Data, regWrites); in ar2316SetRfRegs()
215 HAL_INI_WRITE_BANK(ah, ar5212Bank6_2316, priv->Bank6Data, regWrites); in ar2316SetRfRegs()
216 HAL_INI_WRITE_BANK(ah, ar5212Bank7_2316, priv->Bank7Data, regWrites); in ar2316SetRfRegs()
219 ahp->ah_rfgainState = HAL_RFGAIN_INACTIVE; in ar2316SetRfRegs()
235 case 1: return priv->Bank1Data; in ar2316GetRfBank()
236 case 2: return priv->Bank2Data; in ar2316GetRfBank()
237 case 3: return priv->Bank3Data; in ar2316GetRfBank()
238 case 6: return priv->Bank6Data; in ar2316GetRfBank()
239 case 7: return priv->Bank7Data; in ar2316GetRfBank()
260 * Check first and last elements for out-of-bounds conditions. in GetLowerUpperIndex()
266 if (target >= ep[-1]) { in GetLowerUpperIndex()
267 *vlo = *vhi = listSize - 1; in GetLowerUpperIndex()
278 *vlo = *vhi = tp - (const int16_t *) lp; in GetLowerUpperIndex()
286 *vlo = tp - (const int16_t *) lp; in GetLowerUpperIndex()
294 * Fill the Vpdlist for indices Pmax-Pmin
312 while (ii <= (uint16_t)(Pmax - Pmin)) { in ar2316FillVpdTable()
317 if (idxL == (uint32_t)(numIntercepts - 1)) in ar2316FillVpdTable()
318 idxL = numIntercepts - 2; /* extrapolate above */ in ar2316FillVpdTable()
323 (((currPwr - pwrList[idxL])*VpdList[idxR]+ in ar2316FillVpdTable()
324 (pwrList[idxR] - currPwr)*VpdList[idxL])/ in ar2316FillVpdTable()
325 (pwrList[idxR] - pwrList[idxL])); in ar2316FillVpdTable()
344 rv = ((target - srcLeft)*targetRight + in interpolate_signed()
345 (srcRight - target)*targetLeft) / (srcRight - srcLeft); in interpolate_signed()
364 #define VpdTable_L priv->vpdTable_L in ar2316getGainBoundariesAndPdadcsForPowers()
365 #define VpdTable_R priv->vpdTable_R in ar2316getGainBoundariesAndPdadcsForPowers()
366 #define VpdTable_I priv->vpdTable_I in ar2316getGainBoundariesAndPdadcsForPowers()
368 int32_t ss;/* potentially -ve index for taking care of pdGainOverlap */ in ar2316getGainBoundariesAndPdadcsForPowers()
372 * If desired to support -ve power levels in future, just in ar2316getGainBoundariesAndPdadcsForPowers()
373 * change pwr_I_0 to signed 5-bits. in ar2316getGainBoundariesAndPdadcsForPowers()
376 /* to accommodate -ve power levels later on. */ in ar2316getGainBoundariesAndPdadcsForPowers()
378 /* to accommodate -ve power levels later on */ in ar2316getGainBoundariesAndPdadcsForPowers()
384 /* Get upper lower index */ in ar2316getGainBoundariesAndPdadcsForPowers()
385 GetLowerUpperIndex(channel, pRawDataset->pChannels, in ar2316getGainBoundariesAndPdadcsForPowers()
386 pRawDataset->numChannels, &(idxL), &(idxR)); in ar2316getGainBoundariesAndPdadcsForPowers()
389 jj = MAX_NUM_PDGAINS_PER_CHANNEL - ii - 1; in ar2316getGainBoundariesAndPdadcsForPowers()
391 numVpd = pRawDataset->pDataPerChannel[idxL].pDataPerPDGain[jj].numVpd; in ar2316getGainBoundariesAndPdadcsForPowers()
393 pPdGainValues[numPdGainsUsed] = pRawDataset->pDataPerChannel[idxL].pDataPerPDGain[jj].pd_gain; in ar2316getGainBoundariesAndPdadcsForPowers()
394 Pmin_t2[numPdGainsUsed] = pRawDataset->pDataPerChannel[idxL].pDataPerPDGain[jj].pwr_t4[0]; in ar2316getGainBoundariesAndPdadcsForPowers()
395 if (Pmin_t2[numPdGainsUsed] >pRawDataset->pDataPerChannel[idxR].pDataPerPDGain[jj].pwr_t4[0]) { in ar2316getGainBoundariesAndPdadcsForPowers()
396 Pmin_t2[numPdGainsUsed] = pRawDataset->pDataPerChannel[idxR].pDataPerPDGain[jj].pwr_t4[0]; in ar2316getGainBoundariesAndPdadcsForPowers()
400 Pmax_t2[numPdGainsUsed] = pRawDataset->pDataPerChannel[idxL].pDataPerPDGain[jj].pwr_t4[numVpd-1]; in ar2316getGainBoundariesAndPdadcsForPowers()
401 …if (Pmax_t2[numPdGainsUsed] > pRawDataset->pDataPerChannel[idxR].pDataPerPDGain[jj].pwr_t4[numVpd- in ar2316getGainBoundariesAndPdadcsForPowers()
403 pRawDataset->pDataPerChannel[idxR].pDataPerPDGain[jj].pwr_t4[numVpd-1]; in ar2316getGainBoundariesAndPdadcsForPowers()
407 &(pRawDataset->pDataPerChannel[idxL].pDataPerPDGain[jj].pwr_t4[0]), in ar2316getGainBoundariesAndPdadcsForPowers()
408 &(pRawDataset->pDataPerChannel[idxL].pDataPerPDGain[jj].Vpd[0]), numVpd, VpdTable_L in ar2316getGainBoundariesAndPdadcsForPowers()
412 &(pRawDataset->pDataPerChannel[idxR].pDataPerPDGain[jj].pwr_t4[0]), in ar2316getGainBoundariesAndPdadcsForPowers()
413 &(pRawDataset->pDataPerChannel[idxR].pDataPerPDGain[jj].Vpd[0]), numVpd, VpdTable_R in ar2316getGainBoundariesAndPdadcsForPowers()
415 for (kk = 0; kk < (uint16_t)(Pmax_t2[numPdGainsUsed] - Pmin_t2[numPdGainsUsed]); kk++) { in ar2316getGainBoundariesAndPdadcsForPowers()
418 channel, pRawDataset->pChannels[idxL], pRawDataset->pChannels[idxR], in ar2316getGainBoundariesAndPdadcsForPowers()
430 if (ii == (numPdGainsUsed - 1)) in ar2316getGainBoundariesAndPdadcsForPowers()
447 ss = (pPdGainBoundaries[ii-1] - Pmin_t2[ii]) - in ar2316getGainBoundariesAndPdadcsForPowers()
449 Vpd_step = (uint16_t)(VpdTable_I[ii][1] - VpdTable_I[ii][0]); in ar2316getGainBoundariesAndPdadcsForPowers()
452 *-ve ss indicates need to extrapolate data below for this pdGain in ar2316getGainBoundariesAndPdadcsForPowers()
460 sizeCurrVpdTable = Pmax_t2[ii] - Pmin_t2[ii]; in ar2316getGainBoundariesAndPdadcsForPowers()
461 tgtIndex = pPdGainBoundaries[ii] + pdGainOverlap_t2 - Pmin_t2[ii]; in ar2316getGainBoundariesAndPdadcsForPowers()
467 Vpd_step = (uint16_t)(VpdTable_I[ii][sizeCurrVpdTable-1] - in ar2316getGainBoundariesAndPdadcsForPowers()
468 VpdTable_I[ii][sizeCurrVpdTable-2]); in ar2316getGainBoundariesAndPdadcsForPowers()
477 (VpdTable_I[ii][sizeCurrVpdTable-1] + in ar2316getGainBoundariesAndPdadcsForPowers()
478 (ss-maxIndex)*Vpd_step); in ar2316getGainBoundariesAndPdadcsForPowers()
487 pPdGainBoundaries[ii] = pPdGainBoundaries[ii-1]; in ar2316getGainBoundariesAndPdadcsForPowers()
491 pPDADCValues[kk] = pPDADCValues[kk-1]; in ar2316getGainBoundariesAndPdadcsForPowers()
508 const HAL_EEPROM *ee = AH_PRIVATE(ah)->ah_eeprom; in ar2316SetPowerTable()
512 uint16_t *pdadcValues = ahp->ah_pcdacTable; in ar2316SetPowerTable()
521 __func__, chan->ic_freq, chan->ic_flags); in ar2316SetPowerTable()
524 pRawDataset = &ee->ee_rawDataset2413[headerInfo11G]; in ar2316SetPowerTable()
526 pRawDataset = &ee->ee_rawDataset2413[headerInfo11B]; in ar2316SetPowerTable()
536 chan->channel, pRawDataset, pdGainOverlap_t2, in ar2316SetPowerTable()
548 (pRawDataset->pDataPerChannel[0].numPdGains - 1)); in ar2316SetPowerTable()
552 | SM(numPdGainsUsed-1, AR_PHY_TPCRG1_NUM_PD_GAIN); in ar2316SetPowerTable()
569 HALDEBUG(ah, HAL_DEBUG_RFPARAM, "%s: using non-default " in ar2316SetPowerTable()
582 ahp->ah_txPowerIndexOffset = (int16_t)(0 - minCalPower2316_t2); in ar2316SetPowerTable()
584 ahp->ah_txPowerIndexOffset = 0; in ar2316SetPowerTable()
614 jj = MAX_NUM_PDGAINS_PER_CHANNEL - ii - 1; in ar2316GetMinPower()
616 numVpd = data->pDataPerPDGain[jj].numVpd; in ar2316GetMinPower()
618 Pmin = data->pDataPerPDGain[jj].pwr_t4[0]; in ar2316GetMinPower()
633 numVpd = data->pDataPerPDGain[ii].numVpd; in ar2316GetMaxPower()
635 Pmax = data->pDataPerPDGain[ii].pwr_t4[numVpd-1]; in ar2316GetMaxPower()
647 uint16_t freq = chan->ic_freq; /* NB: never mapped */ in ar2316GetChannelMaxMinPower()
648 const HAL_EEPROM *ee = AH_PRIVATE(ah)->ah_eeprom; in ar2316GetChannelMaxMinPower()
657 pRawDataset = &ee->ee_rawDataset2413[headerInfo11G]; in ar2316GetChannelMaxMinPower()
659 pRawDataset = &ee->ee_rawDataset2413[headerInfo11B]; in ar2316GetChannelMaxMinPower()
663 numChannels = pRawDataset->numChannels; in ar2316GetChannelMaxMinPower()
664 data = pRawDataset->pDataPerChannel; in ar2316GetChannelMaxMinPower()
673 (freq > data[numChannels-1].channelValue)) { in ar2316GetChannelMaxMinPower()
679 *maxPow = ar2316GetMaxPower(ah, &data[numChannels - 1]); in ar2316GetChannelMaxMinPower()
680 *minPow = ar2316GetMinPower(ah, &data[numChannels - 1]); in ar2316GetChannelMaxMinPower()
688 totalD = data[i].channelValue - data[last].channelValue; in ar2316GetChannelMaxMinPower()
690 totalF = ar2316GetMaxPower(ah, &data[i]) - ar2316GetMaxPower(ah, &data[last]); in ar2316GetChannelMaxMinPower()
691 *maxPow = (int8_t) ((totalF*(freq-data[last].channelValue) + in ar2316GetChannelMaxMinPower()
693 totalMin = ar2316GetMinPower(ah, &data[i]) - ar2316GetMinPower(ah, &data[last]); in ar2316GetChannelMaxMinPower()
694 *minPow = (int8_t) ((totalMin*(freq-data[last].channelValue) + in ar2316GetChannelMaxMinPower()
715 HALASSERT(ahp->ah_rfHal != AH_NULL); in ar2316RfDetach()
716 ath_hal_free(ahp->ah_rfHal); in ar2316RfDetach()
717 ahp->ah_rfHal = AH_NULL; in ar2316RfDetach()
730 HALASSERT(ah->ah_magic == AR5212_MAGIC); in ar2316RfAttach()
732 HALASSERT(ahp->ah_rfHal == AH_NULL); in ar2316RfAttach()
740 priv->base.rfDetach = ar2316RfDetach; in ar2316RfAttach()
741 priv->base.writeRegs = ar2316WriteRegs; in ar2316RfAttach()
742 priv->base.getRfBank = ar2316GetRfBank; in ar2316RfAttach()
743 priv->base.setChannel = ar2316SetChannel; in ar2316RfAttach()
744 priv->base.setRfRegs = ar2316SetRfRegs; in ar2316RfAttach()
745 priv->base.setPowerTable = ar2316SetPowerTable; in ar2316RfAttach()
746 priv->base.getChannelMaxMinPower = ar2316GetChannelMaxMinPower; in ar2316RfAttach()
747 priv->base.getNfAdjust = ar5212GetNfAdjust; in ar2316RfAttach()
749 ahp->ah_pcdacTable = priv->pcdacTable; in ar2316RfAttach()
750 ahp->ah_pcdacTableSize = sizeof(priv->pcdacTable); in ar2316RfAttach()
751 ahp->ah_rfHal = &priv->base; in ar2316RfAttach()
753 ahp->ah_cwCalRequire = AH_TRUE; /* force initial cal */ in ar2316RfAttach()