23 if (ah->
config.analog_shiftreg)
33 regVal |= (val << shift) & mask;
37 if (ah->
config.analog_shiftreg)
46 if (srcRight == srcLeft) {
49 rv = (
int16_t) (((target - srcLeft) * targetRight +
50 (srcRight - target) * targetLeft) /
51 (srcRight - srcLeft));
61 if (target <= pList[0]) {
62 *indexL = *indexR = 0;
65 if (target >= pList[listSize - 1]) {
66 *indexL = *indexR = (
u16) (listSize - 1);
70 for (i = 0; i < listSize - 1; i++) {
71 if (pList[i] == target) {
72 *indexL = *indexR =
i;
75 if (target < pList[i + 1]) {
77 *indexR = (
u16) (i + 1);
85 int eep_start_loc,
int size)
91 for (addr = 0; addr <
size; addr++) {
98 for (
j = 0;
j <
i;
j++) {
109 for (
j = 0;
j <
i;
j++) {
118 return common->
bus_ops->eeprom_read(common, off, data);
122 u8 *pVpdList,
u16 numIntercepts,
127 u16 idxL = 0, idxR = 0;
129 for (i = 0; i <= (pwrMax - pwrMin) / 2; i++) {
131 numIntercepts, &(idxL),
135 if (idxL == numIntercepts - 1)
136 idxL = (
u16) (numIntercepts - 2);
137 if (pPwrList[idxL] == pPwrList[idxR])
140 k = (
u16)(((currPwr - pPwrList[idxL]) * pVpdList[idxR] +
141 (pPwrList[idxR] - currPwr) * pVpdList[idxL]) /
142 (pPwrList[idxR] - pPwrList[idxL]));
143 pRetVpdList[
i] = (
u8) k;
153 u16 numRates,
bool isExtTarget)
158 int matchIndex = -1, lowIndex = -1;
164 if (freq <= ath9k_hw_fbin2freq(powInfo[0].bChannel,
168 for (i = 0; (i < numChannels) &&
170 if (freq == ath9k_hw_fbin2freq(powInfo[i].bChannel,
174 }
else if (freq < ath9k_hw_fbin2freq(powInfo[i].bChannel,
176 freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel,
182 if ((matchIndex == -1) && (lowIndex == -1))
186 if (matchIndex != -1) {
187 *pNewPower = powInfo[matchIndex];
189 clo = ath9k_hw_fbin2freq(powInfo[lowIndex].bChannel,
191 chi = ath9k_hw_fbin2freq(powInfo[lowIndex + 1].bChannel,
194 for (i = 0; i < numRates; i++) {
197 powInfo[lowIndex].tPow2x[i],
198 powInfo[lowIndex + 1].tPow2x[i]);
208 u16 numRates,
bool isHt40Target)
213 int matchIndex = -1, lowIndex = -1;
219 if (freq <= ath9k_hw_fbin2freq(powInfo[0].bChannel,
IS_CHAN_2GHZ(chan))) {
222 for (i = 0; (i < numChannels) &&
224 if (freq == ath9k_hw_fbin2freq(powInfo[i].bChannel,
229 if (freq < ath9k_hw_fbin2freq(powInfo[i].bChannel,
231 freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel,
237 if ((matchIndex == -1) && (lowIndex == -1))
241 if (matchIndex != -1) {
242 *pNewPower = powInfo[matchIndex];
244 clo = ath9k_hw_fbin2freq(powInfo[lowIndex].bChannel,
246 chi = ath9k_hw_fbin2freq(powInfo[lowIndex + 1].bChannel,
249 for (i = 0; i < numRates; i++) {
252 powInfo[lowIndex].tPow2x[i],
253 powInfo[lowIndex + 1].tPow2x[i]);
259 bool is2GHz,
int num_band_edges)
264 for (i = 0; (i < num_band_edges) &&
266 if (freq == ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel, is2GHz)) {
269 }
else if ((i > 0) &&
270 (freq < ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel,
272 if (ath9k_hw_fbin2freq(pRdEdgesPower[i - 1].bChannel,
282 return twiceMaxEdgePower;
286 u8 antenna_reduction)
288 u16 reduction = antenna_reduction;
305 if (power_limit > reduction)
306 power_limit -= reduction;
328 ath_dbg(common,
EEPROM,
"Invalid chainmask configuration\n");
336 u8 *bChans,
u16 availPiers,
338 u16 *pPdGainBoundaries,
u8 *pPDADCValues,
343 u16 idxL = 0, idxR = 0, numPiers;
351 u8 *pVpdL, *pVpdR, *pPwrL, *pPwrR;
356 u16 sizeCurrVpdTable, maxIndex, tgtIndex;
360 int pdgain_boundary_default;
375 for (numPiers = 0; numPiers < availPiers; numPiers++) {
382 bChans, numPiers, &idxL, &idxR);
387 for (i = 0; i < numXpdGains; i++) {
388 minPwrT4[
i] = data_9287[idxL].
pwrPdg[
i][0];
389 maxPwrT4[
i] = data_9287[idxL].
pwrPdg[
i][4];
391 data_9287[idxL].
pwrPdg[i],
392 data_9287[idxL].
vpdPdg[i],
396 }
else if (eeprom_4k) {
397 for (i = 0; i < numXpdGains; i++) {
398 minPwrT4[
i] = data_4k[idxL].
pwrPdg[
i][0];
399 maxPwrT4[
i] = data_4k[idxL].
pwrPdg[
i][4];
407 for (i = 0; i < numXpdGains; i++) {
408 minPwrT4[
i] = data_def[idxL].
pwrPdg[
i][0];
409 maxPwrT4[
i] = data_def[idxL].
pwrPdg[
i][4];
418 for (i = 0; i < numXpdGains; i++) {
420 pVpdL = data_9287[idxL].
vpdPdg[
i];
421 pPwrL = data_9287[idxL].
pwrPdg[
i];
422 pVpdR = data_9287[idxR].
vpdPdg[
i];
423 pPwrR = data_9287[idxR].
pwrPdg[
i];
424 }
else if (eeprom_4k) {
425 pVpdL = data_4k[idxL].
vpdPdg[
i];
426 pPwrL = data_4k[idxL].
pwrPdg[
i];
427 pVpdR = data_4k[idxR].
vpdPdg[
i];
428 pPwrR = data_4k[idxR].
pwrPdg[
i];
430 pVpdL = data_def[idxL].
vpdPdg[
i];
431 pPwrL = data_def[idxL].
pwrPdg[
i];
432 pVpdR = data_def[idxR].
vpdPdg[
i];
433 pPwrR = data_def[idxR].
pwrPdg[
i];
436 minPwrT4[
i] =
max(pPwrL[0], pPwrR[0]);
439 min(pPwrL[intercepts - 1],
440 pPwrR[intercepts - 1]);
452 for (j = 0; j <= (maxPwrT4[
i] - minPwrT4[
i]) / 2; j++) {
459 bChans[idxL], bChans[idxR],
460 vpdTableL[
i][
j], vpdTableR[
i][
j]));
467 for (i = 0; i < numXpdGains; i++) {
468 if (i == (numXpdGains - 1))
469 pPdGainBoundaries[i] =
470 (
u16)(maxPwrT4[
i] / 2);
472 pPdGainBoundaries[
i] =
473 (
u16)((maxPwrT4[i] + minPwrT4[i + 1]) / 4);
475 pPdGainBoundaries[
i] =
482 ss = (
int16_t)(0 - (minPwrT4[i] / 2));
486 ss = (
int16_t)((pPdGainBoundaries[i - 1] -
488 tPdGainOverlap + 1 + minDelta);
490 vpdStep = (
int16_t)(vpdTableI[i][1] - vpdTableI[i][0]);
491 vpdStep = (
int16_t)((vpdStep < 1) ? 1 : vpdStep);
494 tmpVal = (
int16_t)(vpdTableI[i][0] + ss * vpdStep);
495 pPDADCValues[k++] = (
u8)((tmpVal < 0) ? 0 : tmpVal);
499 sizeCurrVpdTable = (
u8) ((maxPwrT4[i] - minPwrT4[i]) / 2 + 1);
500 tgtIndex = (
u8)(pPdGainBoundaries[i] + tPdGainOverlap -
502 maxIndex = (tgtIndex < sizeCurrVpdTable) ?
503 tgtIndex : sizeCurrVpdTable;
506 pPDADCValues[k++] = vpdTableI[
i][ss++];
509 vpdStep = (
int16_t)(vpdTableI[i][sizeCurrVpdTable - 1] -
510 vpdTableI[i][sizeCurrVpdTable - 2]);
511 vpdStep = (
int16_t)((vpdStep < 1) ? 1 : vpdStep);
513 if (tgtIndex >= maxIndex) {
514 while ((ss <= tgtIndex) &&
516 tmpVal = (
int16_t)((vpdTableI[i][sizeCurrVpdTable - 1] +
517 (ss - maxIndex + 1) * vpdStep));
518 pPDADCValues[k++] = (
u8)((tmpVal > 255) ?
526 pdgain_boundary_default = 58;
528 pdgain_boundary_default = pPdGainBoundaries[i - 1];
531 pPdGainBoundaries[
i] = pdgain_boundary_default;
536 pPDADCValues[
k] = pPDADCValues[k - 1];
555 if (!ah->
eep_ops->fill_eeprom(ah))
558 status = ah->
eep_ops->check_eeprom(ah);