iPXE
ath9k_eeprom_def.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2011 Atheros Communications Inc.
3  *
4  * Modified for iPXE by Scott K Logan <logans@cottsay.net> July 2011
5  * Original from Linux kernel 3.0.1
6  *
7  * Permission to use, copy, modify, and/or distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 FILE_SECBOOT ( FORBIDDEN );
21 
22 #include <ipxe/io.h>
23 
24 #include "hw.h"
25 #include "ar9002_phy.h"
26 
27 static void ath9k_get_txgain_index(struct ath_hw *ah,
28  struct ath9k_channel *chan,
29  struct calDataPerFreqOpLoop *rawDatasetOpLoop,
30  u8 *calChans, u16 availPiers, u8 *pwr, u8 *pcdacIdx)
31 {
32  u8 pcdac, i = 0;
33  u16 idxL = 0, idxR = 0, numPiers;
34  int match;
35  struct chan_centers centers;
36 
37  ath9k_hw_get_channel_centers(ah, chan, &centers);
38 
39  for (numPiers = 0; numPiers < availPiers; numPiers++)
40  if (calChans[numPiers] == AR5416_BCHAN_UNUSED)
41  break;
42 
44  (u8)FREQ2FBIN(centers.synth_center, IS_CHAN_2GHZ(chan)),
45  calChans, numPiers, &idxL, &idxR);
46  if (match) {
47  pcdac = rawDatasetOpLoop[idxL].pcdac[0][0];
48  *pwr = rawDatasetOpLoop[idxL].pwrPdg[0][0];
49  } else {
50  pcdac = rawDatasetOpLoop[idxR].pcdac[0][0];
51  *pwr = (rawDatasetOpLoop[idxL].pwrPdg[0][0] +
52  rawDatasetOpLoop[idxR].pwrPdg[0][0])/2;
53  }
54 
55  while (pcdac > ah->originalGain[i] &&
56  i < (AR9280_TX_GAIN_TABLE_SIZE - 1))
57  i++;
58 
59  *pcdacIdx = i;
60 }
61 
62 static void ath9k_olc_get_pdadcs(struct ath_hw *ah,
63  u32 initTxGain,
64  int txPower,
65  u8 *pPDADCValues)
66 {
67  u32 i;
68  u32 offset;
69 
74 
76  AR_PHY_TX_PWRCTRL_INIT_TX_GAIN, initTxGain);
77 
78  offset = txPower;
79  for (i = 0; i < AR5416_NUM_PDADC_VALUES; i++)
80  if (i < offset)
81  pPDADCValues[i] = 0x0;
82  else
83  pPDADCValues[i] = 0xFF;
84 }
85 
87 {
88  return ((ah->eeprom.def.baseEepHeader.version >> 12) & 0xF);
89 }
90 
92 {
93  return ((ah->eeprom.def.baseEepHeader.version) & 0xFFF);
94 }
95 
96 #define SIZE_EEPROM_DEF (sizeof(struct ar5416_eeprom_def) / sizeof(u16))
97 
99 {
100  struct ath_common *common = ath9k_hw_common(ah);
101  u16 *eep_data = (u16 *)&ah->eeprom.def;
102  unsigned int addr;
103  int ar5416_eep_start_loc = 0x100;
104 
105  for (addr = 0; addr < SIZE_EEPROM_DEF; addr++) {
106  if (!ath9k_hw_nvram_read(common, addr + ar5416_eep_start_loc,
107  eep_data)) {
108  DBG("ath9k: "
109  "Unable to read eeprom region\n");
110  return 0;
111  }
112  eep_data++;
113  }
114  return 1;
115 }
116 
118 {
119  u16 *eep_data = (u16 *)&ah->eeprom.def;
120 
122  0x100, SIZE_EEPROM_DEF);
123  return 1;
124 }
125 
126 static int ath9k_hw_def_fill_eeprom(struct ath_hw *ah)
127 {
128  struct ath_common *common = ath9k_hw_common(ah);
129 
130  if (!ath9k_hw_use_flash(ah)) {
131  DBG2("ath9k: "
132  "Reading from EEPROM, not flash\n");
133  }
134 
135  if (common->bus_ops->ath_bus_type == ATH_USB)
137  else
139 }
140 
141 #undef SIZE_EEPROM_DEF
142 
144 {
145  struct ar5416_eeprom_def *eep =
146  (struct ar5416_eeprom_def *) &ah->eeprom.def;
147  struct ath_common *common = ath9k_hw_common(ah);
148  u16 *eepdata, temp, magic, magic2;
149  u32 sum = 0, el;
150  int need_swap = 0;
151  unsigned int i, addr, size;
152 
154  DBG("ath9k: Reading Magic # failed\n");
155  return 0;
156  }
157 
158  if (!ath9k_hw_use_flash(ah)) {
159  DBG2("ath9k: "
160  "Read Magic = 0x%04X\n", magic);
161 
162  if (magic != AR5416_EEPROM_MAGIC) {
163  magic2 = swab16(magic);
164 
165  if (magic2 == AR5416_EEPROM_MAGIC) {
166  size = sizeof(struct ar5416_eeprom_def);
167  need_swap = 1;
168  eepdata = (u16 *) (&ah->eeprom);
169 
170  for (addr = 0; addr < size / sizeof(u16); addr++) {
171  temp = swab16(*eepdata);
172  *eepdata = temp;
173  eepdata++;
174  }
175  } else {
176  DBG("ath9k: "
177  "Invalid EEPROM Magic. Endianness mismatch.\n");
178  return -EINVAL;
179  }
180  }
181  }
182 
183  DBG2("ath9k: need_swap = %s.\n",
184  need_swap ? "True" : "False");
185 
186  if (need_swap)
187  el = swab16(ah->eeprom.def.baseEepHeader.length);
188  else
189  el = ah->eeprom.def.baseEepHeader.length;
190 
191  if (el > sizeof(struct ar5416_eeprom_def))
192  el = sizeof(struct ar5416_eeprom_def) / sizeof(u16);
193  else
194  el = el / sizeof(u16);
195 
196  eepdata = (u16 *)(&ah->eeprom);
197 
198  for (i = 0; i < el; i++)
199  sum ^= *eepdata++;
200 
201  if (need_swap) {
202  u32 integer, j;
203  u16 word;
204 
205  DBG("ath9k: "
206  "EEPROM Endianness is not native.. Changing.\n");
207 
209  eep->baseEepHeader.length = word;
210 
212  eep->baseEepHeader.checksum = word;
213 
215  eep->baseEepHeader.version = word;
216 
217  word = swab16(eep->baseEepHeader.regDmn[0]);
218  eep->baseEepHeader.regDmn[0] = word;
219 
220  word = swab16(eep->baseEepHeader.regDmn[1]);
221  eep->baseEepHeader.regDmn[1] = word;
222 
224  eep->baseEepHeader.rfSilent = word;
225 
228 
231 
232  for (j = 0; j < ARRAY_SIZE(eep->modalHeader); j++) {
233  struct modal_eep_header *pModal =
234  &eep->modalHeader[j];
235  integer = swab32(pModal->antCtrlCommon);
236  pModal->antCtrlCommon = integer;
237 
238  for (i = 0; i < AR5416_MAX_CHAINS; i++) {
239  integer = swab32(pModal->antCtrlChain[i]);
240  pModal->antCtrlChain[i] = integer;
241  }
242  for (i = 0; i < 3; i++) {
243  word = swab16(pModal->xpaBiasLvlFreq[i]);
244  pModal->xpaBiasLvlFreq[i] = word;
245  }
246 
247  for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
248  word = swab16(pModal->spurChans[i].spurChan);
249  pModal->spurChans[i].spurChan = word;
250  }
251  }
252  }
253 
254  if (sum != 0xffff || ah->eep_ops->get_eeprom_ver(ah) != AR5416_EEP_VER ||
255  ah->eep_ops->get_eeprom_rev(ah) < AR5416_EEP_NO_BACK_VER) {
256  DBG("ath9k: Bad EEPROM checksum 0x%x or revision 0x%04x\n",
257  sum, ah->eep_ops->get_eeprom_ver(ah));
258  return -EINVAL;
259  }
260 
261  /* Enable fixup for AR_AN_TOP2 if necessary */
262  if ((ah->hw_version.devid == AR9280_DEVID_PCI) &&
263  ((eep->baseEepHeader.version & 0xff) > 0x0a) &&
264  (eep->baseEepHeader.pwdclkind == 0))
265  ah->need_an_top2_fixup = 1;
266 
267  if ((common->bus_ops->ath_bus_type == ATH_USB) &&
268  (AR_SREV_9280(ah)))
269  eep->modalHeader[0].xpaBiasLvl = 0;
270 
271  return 0;
272 }
273 
275  enum eeprom_param param)
276 {
277  struct ar5416_eeprom_def *eep = &ah->eeprom.def;
278  struct modal_eep_header *pModal = eep->modalHeader;
279  struct base_eep_header *pBase = &eep->baseEepHeader;
280 
281  switch (param) {
282  case EEP_NFTHRESH_5:
283  return pModal[0].noiseFloorThreshCh[0];
284  case EEP_NFTHRESH_2:
285  return pModal[1].noiseFloorThreshCh[0];
286  case EEP_MAC_LSW:
287  return pBase->macAddr[0] << 8 | pBase->macAddr[1];
288  case EEP_MAC_MID:
289  return pBase->macAddr[2] << 8 | pBase->macAddr[3];
290  case EEP_MAC_MSW:
291  return pBase->macAddr[4] << 8 | pBase->macAddr[5];
292  case EEP_REG_0:
293  return pBase->regDmn[0];
294  case EEP_REG_1:
295  return pBase->regDmn[1];
296  case EEP_OP_CAP:
297  return pBase->deviceCap;
298  case EEP_OP_MODE:
299  return pBase->opCapFlags;
300  case EEP_RF_SILENT:
301  return pBase->rfSilent;
302  case EEP_OB_5:
303  return pModal[0].ob;
304  case EEP_DB_5:
305  return pModal[0].db;
306  case EEP_OB_2:
307  return pModal[1].ob;
308  case EEP_DB_2:
309  return pModal[1].db;
310  case EEP_MINOR_REV:
311  return AR5416_VER_MASK;
312  case EEP_TX_MASK:
313  return pBase->txMask;
314  case EEP_RX_MASK:
315  return pBase->rxMask;
316  case EEP_FSTCLK_5G:
317  return pBase->fastClk5g;
318  case EEP_RXGAIN_TYPE:
319  return pBase->rxGainType;
320  case EEP_TXGAIN_TYPE:
321  return pBase->txGainType;
322  case EEP_OL_PWRCTRL:
324  return pBase->openLoopPwrCntl ? 1 : 0;
325  else
326  return 0;
327  case EEP_RC_CHAIN_MASK:
329  return pBase->rcChainMask;
330  else
331  return 0;
332  case EEP_DAC_HPWR_5G:
334  return pBase->dacHiPwrMode_5G;
335  else
336  return 0;
337  case EEP_FRAC_N_5G:
339  return pBase->frac_n_5g;
340  else
341  return 0;
344  return pBase->pwr_table_offset;
345  else
347  default:
348  return 0;
349  }
350 }
351 
352 static void ath9k_hw_def_set_gain(struct ath_hw *ah,
353  struct modal_eep_header *pModal,
354  struct ar5416_eeprom_def *eep,
355  u8 txRxAttenLocal, int regChainOffset, int i)
356 {
358  txRxAttenLocal = pModal->txRxAttenCh[i];
359 
361  REG_RMW_FIELD(ah, AR_PHY_GAIN_2GHZ + regChainOffset,
363  pModal->bswMargin[i]);
364  REG_RMW_FIELD(ah, AR_PHY_GAIN_2GHZ + regChainOffset,
366  pModal->bswAtten[i]);
367  REG_RMW_FIELD(ah, AR_PHY_GAIN_2GHZ + regChainOffset,
369  pModal->xatten2Margin[i]);
370  REG_RMW_FIELD(ah, AR_PHY_GAIN_2GHZ + regChainOffset,
372  pModal->xatten2Db[i]);
373  } else {
374  REG_WRITE(ah, AR_PHY_GAIN_2GHZ + regChainOffset,
375  (REG_READ(ah, AR_PHY_GAIN_2GHZ + regChainOffset) &
377  | SM(pModal-> bswMargin[i],
379  REG_WRITE(ah, AR_PHY_GAIN_2GHZ + regChainOffset,
380  (REG_READ(ah, AR_PHY_GAIN_2GHZ + regChainOffset) &
382  | SM(pModal->bswAtten[i],
384  }
385  }
386 
389  AR_PHY_RXGAIN + regChainOffset,
390  AR9280_PHY_RXGAIN_TXRX_ATTEN, txRxAttenLocal);
392  AR_PHY_RXGAIN + regChainOffset,
394  } else {
395  REG_WRITE(ah,
396  AR_PHY_RXGAIN + regChainOffset,
397  (REG_READ(ah, AR_PHY_RXGAIN + regChainOffset) &
399  | SM(txRxAttenLocal, AR_PHY_RXGAIN_TXRX_ATTEN));
400  REG_WRITE(ah,
401  AR_PHY_GAIN_2GHZ + regChainOffset,
402  (REG_READ(ah, AR_PHY_GAIN_2GHZ + regChainOffset) &
405  }
406 }
407 
409  struct ath9k_channel *chan)
410 {
411  struct modal_eep_header *pModal;
412  struct ar5416_eeprom_def *eep = &ah->eeprom.def;
413  int i, regChainOffset;
414  u8 txRxAttenLocal;
415 
416  pModal = &(eep->modalHeader[IS_CHAN_2GHZ(chan)]);
417  txRxAttenLocal = IS_CHAN_2GHZ(chan) ? 23 : 44;
418 
419  REG_WRITE(ah, AR_PHY_SWITCH_COM, pModal->antCtrlCommon & 0xffff);
420 
421  for (i = 0; i < AR5416_MAX_CHAINS; i++) {
422  if (AR_SREV_9280(ah)) {
423  if (i >= 2)
424  break;
425  }
426 
428  (ah->rxchainmask == 5 || ah->txchainmask == 5) && (i != 0))
429  regChainOffset = (i == 1) ? 0x2000 : 0x1000;
430  else
431  regChainOffset = i * 0x1000;
432 
433  REG_WRITE(ah, AR_PHY_SWITCH_CHAIN_0 + regChainOffset,
434  pModal->antCtrlChain[i]);
435 
436  REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset,
437  (REG_READ(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset) &
440  SM(pModal->iqCalICh[i],
442  SM(pModal->iqCalQCh[i],
444 
445  if ((i == 0) || AR_SREV_5416_20_OR_LATER(ah))
446  ath9k_hw_def_set_gain(ah, pModal, eep, txRxAttenLocal,
447  regChainOffset, i);
448  }
449 
451  if (IS_CHAN_2GHZ(chan)) {
455  pModal->ob);
459  pModal->db);
463  pModal->ob_ch1);
467  pModal->db_ch1);
468  } else {
472  pModal->ob);
476  pModal->db);
480  pModal->ob_ch1);
484  pModal->db_ch1);
485  }
489  pModal->xpaBiasLvl);
493  !!(pModal->lna_ctl &
496  !!(pModal->lna_ctl & LNA_CTL_FORCE_XPA));
497  }
498 
500  pModal->switchSettling);
502  pModal->adcDesiredSize);
503 
507  pModal->pgaDesiredSize);
508 
511  | SM(pModal->txEndToXpaOff,
513  | SM(pModal->txFrameToXpaOn,
515  | SM(pModal->txFrameToXpaOn,
517 
519  pModal->txEndToRxOn);
520 
523  pModal->thresh62);
526  pModal->thresh62);
527  } else {
529  pModal->thresh62);
532  pModal->thresh62);
533  }
534 
538  pModal->txFrameToDataStart);
540  pModal->txFrameToPaOn);
541  }
542 
544  if (IS_CHAN_HT40(chan))
547  pModal->swSettleHt40);
548  }
549 
554  pModal->miscBits);
555 
556 
558  if (IS_CHAN_2GHZ(chan))
560  eep->baseEepHeader.dacLpMode);
561  else if (eep->baseEepHeader.dacHiPwrMode_5G)
563  else
565  eep->baseEepHeader.dacLpMode);
566 
567  udelay(100);
568 
570  pModal->miscBits >> 2);
571 
575  }
576 }
577 
578 static void ath9k_hw_def_set_addac(struct ath_hw *ah,
579  struct ath9k_channel *chan)
580 {
581 #define XPA_LVL_FREQ(cnt) (pModal->xpaBiasLvlFreq[cnt])
582  struct modal_eep_header *pModal;
583  struct ar5416_eeprom_def *eep = &ah->eeprom.def;
584  u8 biaslevel;
585 
586  if (ah->hw_version.macVersion != AR_SREV_VERSION_9160)
587  return;
588 
589  if (ah->eep_ops->get_eeprom_rev(ah) < AR5416_EEP_MINOR_VER_7)
590  return;
591 
592  pModal = &(eep->modalHeader[IS_CHAN_2GHZ(chan)]);
593 
594  if (pModal->xpaBiasLvl != 0xff) {
595  biaslevel = pModal->xpaBiasLvl;
596  } else {
597  u16 resetFreqBin, freqBin, freqCount = 0;
598  struct chan_centers centers;
599 
600  ath9k_hw_get_channel_centers(ah, chan, &centers);
601 
602  resetFreqBin = FREQ2FBIN(centers.synth_center,
603  IS_CHAN_2GHZ(chan));
604  freqBin = XPA_LVL_FREQ(0) & 0xff;
605  biaslevel = (u8) (XPA_LVL_FREQ(0) >> 14);
606 
607  freqCount++;
608 
609  while (freqCount < 3) {
610  if (XPA_LVL_FREQ(freqCount) == 0x0)
611  break;
612 
613  freqBin = XPA_LVL_FREQ(freqCount) & 0xff;
614  if (resetFreqBin >= freqBin)
615  biaslevel = (u8)(XPA_LVL_FREQ(freqCount) >> 14);
616  else
617  break;
618  freqCount++;
619  }
620  }
621 
622  if (IS_CHAN_2GHZ(chan)) {
623  INI_RA(&ah->iniAddac, 7, 1) = (INI_RA(&ah->iniAddac,
624  7, 1) & (~0x18)) | biaslevel << 3;
625  } else {
626  INI_RA(&ah->iniAddac, 6, 1) = (INI_RA(&ah->iniAddac,
627  6, 1) & (~0xc0)) | biaslevel << 6;
628  }
629 #undef XPA_LVL_FREQ
630 }
631 
633  u16 *gb,
634  u16 numXpdGain,
635  u16 pdGainOverlap_t2,
636  int8_t pwr_table_offset,
637  int16_t *diff)
638 
639 {
640  u16 k;
641 
642  /* Prior to writing the boundaries or the pdadc vs. power table
643  * into the chip registers the default starting point on the pdadc
644  * vs. power table needs to be checked and the curve boundaries
645  * adjusted accordingly
646  */
648  u16 gb_limit;
649 
650  if (AR5416_PWR_TABLE_OFFSET_DB != pwr_table_offset) {
651  /* get the difference in dB */
652  *diff = (u16)(pwr_table_offset - AR5416_PWR_TABLE_OFFSET_DB);
653  /* get the number of half dB steps */
654  *diff *= 2;
655  /* change the original gain boundary settings
656  * by the number of half dB steps
657  */
658  for (k = 0; k < numXpdGain; k++)
659  gb[k] = (u16)(gb[k] - *diff);
660  }
661  /* Because of a hardware limitation, ensure the gain boundary
662  * is not larger than (63 - overlap)
663  */
664  gb_limit = (u16)(MAX_RATE_POWER - pdGainOverlap_t2);
665 
666  for (k = 0; k < numXpdGain; k++)
667  gb[k] = (u16)min(gb_limit, gb[k]);
668  }
669 
670  return *diff;
671 }
672 
673 static void ath9k_adjust_pdadc_values(struct ath_hw *ah,
674  int8_t pwr_table_offset,
675  int16_t diff,
676  u8 *pdadcValues)
677 {
678 #define NUM_PDADC(diff) (AR5416_NUM_PDADC_VALUES - diff)
679  u16 k;
680 
681  /* If this is a board that has a pwrTableOffset that differs from
682  * the default AR5416_PWR_TABLE_OFFSET_DB then the start of the
683  * pdadc vs pwr table needs to be adjusted prior to writing to the
684  * chip.
685  */
687  if (AR5416_PWR_TABLE_OFFSET_DB != pwr_table_offset) {
688  /* shift the table to start at the new offset */
689  for (k = 0; k < (u16)NUM_PDADC(diff); k++ ) {
690  pdadcValues[k] = pdadcValues[k + diff];
691  }
692 
693  /* fill the back of the table */
694  for (k = (u16)NUM_PDADC(diff); k < NUM_PDADC(0); k++) {
695  pdadcValues[k] = pdadcValues[NUM_PDADC(diff)];
696  }
697  }
698  }
699 #undef NUM_PDADC
700 }
701 
703  struct ath9k_channel *chan,
704  int16_t *pTxPowerIndexOffset)
705 {
706 #define SM_PD_GAIN(x) SM(0x38, AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_##x)
707 #define SM_PDGAIN_B(x, y) \
708  SM((gainBoundaries[x]), AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_##y)
709  struct ar5416_eeprom_def *pEepData = &ah->eeprom.def;
710  struct cal_data_per_freq *pRawDataset;
711  u8 *pCalBChans = NULL;
712  u16 pdGainOverlap_t2;
713  static u8 pdadcValues[AR5416_NUM_PDADC_VALUES];
714  u16 gainBoundaries[AR5416_PD_GAINS_IN_MASK];
715  u16 numPiers, i, j;
716  int16_t diff = 0;
717  u16 numXpdGain, xpdMask;
718  u16 xpdGainValues[AR5416_NUM_PD_GAINS] = { 0, 0, 0, 0 };
719  u32 reg32, regOffset, regChainOffset;
720  int16_t modalIdx;
721  int8_t pwr_table_offset;
722 
723  modalIdx = IS_CHAN_2GHZ(chan) ? 1 : 0;
724  xpdMask = pEepData->modalHeader[modalIdx].xpdGain;
725 
726  pwr_table_offset = ah->eep_ops->get_eeprom(ah, EEP_PWR_TABLE_OFFSET);
727 
728  if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
730  pdGainOverlap_t2 =
731  pEepData->modalHeader[modalIdx].pdGainOverlap;
732  } else {
733  pdGainOverlap_t2 = (u16)(MS(REG_READ(ah, AR_PHY_TPCRG5),
735  }
736 
737  if (IS_CHAN_2GHZ(chan)) {
738  pCalBChans = pEepData->calFreqPier2G;
739  numPiers = AR5416_NUM_2G_CAL_PIERS;
740  } else {
741  pCalBChans = pEepData->calFreqPier5G;
742  numPiers = AR5416_NUM_5G_CAL_PIERS;
743  }
744 
745  if (OLC_FOR_AR9280_20_LATER && IS_CHAN_2GHZ(chan)) {
746  pRawDataset = pEepData->calPierData2G[0];
747  ah->initPDADC = ((struct calDataPerFreqOpLoop *)
748  pRawDataset)->vpdPdg[0][0];
749  }
750 
751  numXpdGain = 0;
752 
753  for (i = 1; i <= AR5416_PD_GAINS_IN_MASK; i++) {
754  if ((xpdMask >> (AR5416_PD_GAINS_IN_MASK - i)) & 1) {
755  if (numXpdGain >= AR5416_NUM_PD_GAINS)
756  break;
757  xpdGainValues[numXpdGain] =
759  numXpdGain++;
760  }
761  }
762 
764  (numXpdGain - 1) & 0x3);
766  xpdGainValues[0]);
768  xpdGainValues[1]);
770  xpdGainValues[2]);
771 
772  for (i = 0; i < AR5416_MAX_CHAINS; i++) {
774  (ah->rxchainmask == 5 || ah->txchainmask == 5) &&
775  (i != 0)) {
776  regChainOffset = (i == 1) ? 0x2000 : 0x1000;
777  } else
778  regChainOffset = i * 0x1000;
779 
780  if (pEepData->baseEepHeader.txMask & (1 << i)) {
781  if (IS_CHAN_2GHZ(chan))
782  pRawDataset = pEepData->calPierData2G[i];
783  else
784  pRawDataset = pEepData->calPierData5G[i];
785 
786 
788  u8 pcdacIdx;
789  u8 txPower;
790 
792  (struct calDataPerFreqOpLoop *)pRawDataset,
793  pCalBChans, numPiers, &txPower, &pcdacIdx);
794  ath9k_olc_get_pdadcs(ah, pcdacIdx,
795  txPower/2, pdadcValues);
796  } else {
798  chan, pRawDataset,
799  pCalBChans, numPiers,
800  pdGainOverlap_t2,
801  gainBoundaries,
802  pdadcValues,
803  numXpdGain);
804  }
805 
807  gainBoundaries,
808  numXpdGain,
809  pdGainOverlap_t2,
810  pwr_table_offset,
811  &diff);
812 
814 
815  if ((i == 0) || AR_SREV_5416_20_OR_LATER(ah)) {
817  REG_WRITE(ah,
818  AR_PHY_TPCRG5 + regChainOffset,
819  SM(0x6,
821  SM_PD_GAIN(1) | SM_PD_GAIN(2) |
822  SM_PD_GAIN(3) | SM_PD_GAIN(4));
823  } else {
824  REG_WRITE(ah,
825  AR_PHY_TPCRG5 + regChainOffset,
826  SM(pdGainOverlap_t2,
828  SM_PDGAIN_B(0, 1) |
829  SM_PDGAIN_B(1, 2) |
830  SM_PDGAIN_B(2, 3) |
831  SM_PDGAIN_B(3, 4));
832  }
833  }
834 
835 
836  ath9k_adjust_pdadc_values(ah, pwr_table_offset,
837  diff, pdadcValues);
838 
839  regOffset = AR_PHY_BASE + (672 << 2) + regChainOffset;
840  for (j = 0; j < 32; j++) {
841  reg32 = ((pdadcValues[4 * j + 0] & 0xFF) << 0) |
842  ((pdadcValues[4 * j + 1] & 0xFF) << 8) |
843  ((pdadcValues[4 * j + 2] & 0xFF) << 16)|
844  ((pdadcValues[4 * j + 3] & 0xFF) << 24);
845  REG_WRITE(ah, regOffset, reg32);
846 
847  DBG2("ath9k: "
848  "PDADC (%d,%4x): %4.4x %8.8x\n",
849  i, regChainOffset, regOffset,
850  reg32);
851  DBG2("ath9k: "
852  "PDADC: Chain %d | PDADC %3d "
853  "Value %3d | PDADC %3d Value %3d | "
854  "PDADC %3d Value %3d | PDADC %3d "
855  "Value %3d |\n",
856  i, 4 * j, pdadcValues[4 * j],
857  4 * j + 1, pdadcValues[4 * j + 1],
858  4 * j + 2, pdadcValues[4 * j + 2],
859  4 * j + 3, pdadcValues[4 * j + 3]);
860 
861  regOffset += 4;
862  }
864  }
865  }
866 
867  *pTxPowerIndexOffset = 0;
868 #undef SM_PD_GAIN
869 #undef SM_PDGAIN_B
870 }
871 
873  struct ath9k_channel *chan,
874  int16_t *ratesArray,
875  u16 cfgCtl,
876  u16 AntennaReduction,
877  u16 twiceMaxRegulatoryPower,
878  u16 powerLimit)
879 {
880 #define REDUCE_SCALED_POWER_BY_TWO_CHAIN 6 /* 10*log10(2)*2 */
881 #define REDUCE_SCALED_POWER_BY_THREE_CHAIN 9 /* 10*log10(3)*2 */
882 
883  struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
884  struct ar5416_eeprom_def *pEepData = &ah->eeprom.def;
885  u16 twiceMaxEdgePower = MAX_RATE_POWER;
886  static const u16 tpScaleReductionTable[5] =
887  { 0, 3, 6, 9, MAX_RATE_POWER };
888 
889  unsigned int i;
890  int16_t twiceLargestAntenna;
891  struct cal_ctl_data *rep;
892  struct cal_target_power_leg targetPowerOfdm, targetPowerCck = {
893  0, { 0, 0, 0, 0}
894  };
895  struct cal_target_power_leg targetPowerOfdmExt = {
896  0, { 0, 0, 0, 0} }, targetPowerCckExt = {
897  0, { 0, 0, 0, 0 }
898  };
899  struct cal_target_power_ht targetPowerHt20, targetPowerHt40 = {
900  0, {0, 0, 0, 0}
901  };
902  u16 scaledPower = 0, minCtlPower, maxRegAllowedPower;
903  static const u16 ctlModesFor11a[] = {
905  };
906  static const u16 ctlModesFor11g[] = {
909  };
910  u16 numCtlModes;
911  const u16 *pCtlMode;
912  u16 ctlMode, freq;
913  struct chan_centers centers;
914  int tx_chainmask;
915  u16 twiceMinEdgePower;
916 
917  tx_chainmask = ah->txchainmask;
918 
919  ath9k_hw_get_channel_centers(ah, chan, &centers);
920 
921  twiceLargestAntenna = max(
922  pEepData->modalHeader
923  [IS_CHAN_2GHZ(chan)].antennaGainCh[0],
924  pEepData->modalHeader
925  [IS_CHAN_2GHZ(chan)].antennaGainCh[1]);
926 
927  twiceLargestAntenna = max((u8)twiceLargestAntenna,
928  pEepData->modalHeader
929  [IS_CHAN_2GHZ(chan)].antennaGainCh[2]);
930 
931  twiceLargestAntenna = (int16_t)min(AntennaReduction -
932  twiceLargestAntenna, 0);
933 
934  maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
935 
936  if (regulatory->tp_scale != ATH9K_TP_SCALE_MAX) {
937  maxRegAllowedPower -=
938  (tpScaleReductionTable[(regulatory->tp_scale)] * 2);
939  }
940 
941  scaledPower = min(powerLimit, maxRegAllowedPower);
942 
943  switch (ar5416_get_ntxchains(tx_chainmask)) {
944  case 1:
945  break;
946  case 2:
947  if (scaledPower > REDUCE_SCALED_POWER_BY_TWO_CHAIN)
948  scaledPower -= REDUCE_SCALED_POWER_BY_TWO_CHAIN;
949  else
950  scaledPower = 0;
951  break;
952  case 3:
953  if (scaledPower > REDUCE_SCALED_POWER_BY_THREE_CHAIN)
954  scaledPower -= REDUCE_SCALED_POWER_BY_THREE_CHAIN;
955  else
956  scaledPower = 0;
957  break;
958  }
959 
960  if (IS_CHAN_2GHZ(chan)) {
961  numCtlModes = ARRAY_SIZE(ctlModesFor11g) -
963  pCtlMode = ctlModesFor11g;
964 
966  pEepData->calTargetPowerCck,
968  &targetPowerCck, 4, 0);
970  pEepData->calTargetPower2G,
972  &targetPowerOfdm, 4, 0);
974  pEepData->calTargetPower2GHT20,
976  &targetPowerHt20, 8, 0);
977 
978  if (IS_CHAN_HT40(chan)) {
979  numCtlModes = ARRAY_SIZE(ctlModesFor11g);
981  pEepData->calTargetPower2GHT40,
983  &targetPowerHt40, 8, 1);
985  pEepData->calTargetPowerCck,
987  &targetPowerCckExt, 4, 1);
989  pEepData->calTargetPower2G,
991  &targetPowerOfdmExt, 4, 1);
992  }
993  } else {
994  numCtlModes = ARRAY_SIZE(ctlModesFor11a) -
996  pCtlMode = ctlModesFor11a;
997 
999  pEepData->calTargetPower5G,
1001  &targetPowerOfdm, 4, 0);
1003  pEepData->calTargetPower5GHT20,
1005  &targetPowerHt20, 8, 0);
1006 
1007  if (IS_CHAN_HT40(chan)) {
1008  numCtlModes = ARRAY_SIZE(ctlModesFor11a);
1010  pEepData->calTargetPower5GHT40,
1012  &targetPowerHt40, 8, 1);
1014  pEepData->calTargetPower5G,
1016  &targetPowerOfdmExt, 4, 1);
1017  }
1018  }
1019 
1020  for (ctlMode = 0; ctlMode < numCtlModes; ctlMode++) {
1021  int isHt40CtlMode = (pCtlMode[ctlMode] == CTL_5GHT40) ||
1022  (pCtlMode[ctlMode] == CTL_2GHT40);
1023  if (isHt40CtlMode)
1024  freq = centers.synth_center;
1025  else if (pCtlMode[ctlMode] & EXT_ADDITIVE)
1026  freq = centers.ext_center;
1027  else
1028  freq = centers.ctl_center;
1029 
1030  if (ah->eep_ops->get_eeprom_ver(ah) == 14 &&
1031  ah->eep_ops->get_eeprom_rev(ah) <= 2)
1032  twiceMaxEdgePower = MAX_RATE_POWER;
1033 
1034  for (i = 0; (i < AR5416_NUM_CTLS) && pEepData->ctlIndex[i]; i++) {
1035  if ((((cfgCtl & ~CTL_MODE_M) |
1036  (pCtlMode[ctlMode] & CTL_MODE_M)) ==
1037  pEepData->ctlIndex[i]) ||
1038  (((cfgCtl & ~CTL_MODE_M) |
1039  (pCtlMode[ctlMode] & CTL_MODE_M)) ==
1040  ((pEepData->ctlIndex[i] & CTL_MODE_M) | SD_NO_CTL))) {
1041  rep = &(pEepData->ctlData[i]);
1042 
1043  twiceMinEdgePower = ath9k_hw_get_max_edge_power(freq,
1044  rep->ctlEdges[ar5416_get_ntxchains(tx_chainmask) - 1],
1046 
1047  if ((cfgCtl & ~CTL_MODE_M) == SD_NO_CTL) {
1048  twiceMaxEdgePower = min(twiceMaxEdgePower,
1049  twiceMinEdgePower);
1050  } else {
1051  twiceMaxEdgePower = twiceMinEdgePower;
1052  break;
1053  }
1054  }
1055  }
1056 
1057  minCtlPower = min(twiceMaxEdgePower, scaledPower);
1058 
1059  switch (pCtlMode[ctlMode]) {
1060  case CTL_11B:
1061  for (i = 0; i < ARRAY_SIZE(targetPowerCck.tPow2x); i++) {
1062  targetPowerCck.tPow2x[i] =
1063  min((u16)targetPowerCck.tPow2x[i],
1064  minCtlPower);
1065  }
1066  break;
1067  case CTL_11A:
1068  case CTL_11G:
1069  for (i = 0; i < ARRAY_SIZE(targetPowerOfdm.tPow2x); i++) {
1070  targetPowerOfdm.tPow2x[i] =
1071  min((u16)targetPowerOfdm.tPow2x[i],
1072  minCtlPower);
1073  }
1074  break;
1075  case CTL_5GHT20:
1076  case CTL_2GHT20:
1077  for (i = 0; i < ARRAY_SIZE(targetPowerHt20.tPow2x); i++) {
1078  targetPowerHt20.tPow2x[i] =
1079  min((u16)targetPowerHt20.tPow2x[i],
1080  minCtlPower);
1081  }
1082  break;
1083  case CTL_11B_EXT:
1084  targetPowerCckExt.tPow2x[0] = min((u16)
1085  targetPowerCckExt.tPow2x[0],
1086  minCtlPower);
1087  break;
1088  case CTL_11A_EXT:
1089  case CTL_11G_EXT:
1090  targetPowerOfdmExt.tPow2x[0] = min((u16)
1091  targetPowerOfdmExt.tPow2x[0],
1092  minCtlPower);
1093  break;
1094  case CTL_5GHT40:
1095  case CTL_2GHT40:
1096  for (i = 0; i < ARRAY_SIZE(targetPowerHt40.tPow2x); i++) {
1097  targetPowerHt40.tPow2x[i] =
1098  min((u16)targetPowerHt40.tPow2x[i],
1099  minCtlPower);
1100  }
1101  break;
1102  default:
1103  break;
1104  }
1105  }
1106 
1107  ratesArray[rate6mb] = ratesArray[rate9mb] = ratesArray[rate12mb] =
1108  ratesArray[rate18mb] = ratesArray[rate24mb] =
1109  targetPowerOfdm.tPow2x[0];
1110  ratesArray[rate36mb] = targetPowerOfdm.tPow2x[1];
1111  ratesArray[rate48mb] = targetPowerOfdm.tPow2x[2];
1112  ratesArray[rate54mb] = targetPowerOfdm.tPow2x[3];
1113  ratesArray[rateXr] = targetPowerOfdm.tPow2x[0];
1114 
1115  for (i = 0; i < ARRAY_SIZE(targetPowerHt20.tPow2x); i++)
1116  ratesArray[rateHt20_0 + i] = targetPowerHt20.tPow2x[i];
1117 
1118  if (IS_CHAN_2GHZ(chan)) {
1119  ratesArray[rate1l] = targetPowerCck.tPow2x[0];
1120  ratesArray[rate2s] = ratesArray[rate2l] =
1121  targetPowerCck.tPow2x[1];
1122  ratesArray[rate5_5s] = ratesArray[rate5_5l] =
1123  targetPowerCck.tPow2x[2];
1124  ratesArray[rate11s] = ratesArray[rate11l] =
1125  targetPowerCck.tPow2x[3];
1126  }
1127  if (IS_CHAN_HT40(chan)) {
1128  for (i = 0; i < ARRAY_SIZE(targetPowerHt40.tPow2x); i++) {
1129  ratesArray[rateHt40_0 + i] =
1130  targetPowerHt40.tPow2x[i];
1131  }
1132  ratesArray[rateDupOfdm] = targetPowerHt40.tPow2x[0];
1133  ratesArray[rateDupCck] = targetPowerHt40.tPow2x[0];
1134  ratesArray[rateExtOfdm] = targetPowerOfdmExt.tPow2x[0];
1135  if (IS_CHAN_2GHZ(chan)) {
1136  ratesArray[rateExtCck] =
1137  targetPowerCckExt.tPow2x[0];
1138  }
1139  }
1140 }
1141 
1142 static void ath9k_hw_def_set_txpower(struct ath_hw *ah,
1143  struct ath9k_channel *chan,
1144  u16 cfgCtl,
1145  u8 twiceAntennaReduction,
1146  u8 twiceMaxRegulatoryPower,
1147  u8 powerLimit, int test)
1148 {
1149 #define RT_AR_DELTA(x) (ratesArray[x] - cck_ofdm_delta)
1150  struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
1151  struct ar5416_eeprom_def *pEepData = &ah->eeprom.def;
1152  struct modal_eep_header *pModal =
1153  &(pEepData->modalHeader[IS_CHAN_2GHZ(chan)]);
1154  int16_t ratesArray[Ar5416RateSize];
1155  int16_t txPowerIndexOffset = 0;
1157  unsigned int i, cck_ofdm_delta = 0;
1158 
1159  memset(ratesArray, 0, sizeof(ratesArray));
1160 
1161  if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
1164  }
1165 
1167  &ratesArray[0], cfgCtl,
1168  twiceAntennaReduction,
1169  twiceMaxRegulatoryPower,
1170  powerLimit);
1171 
1172  ath9k_hw_set_def_power_cal_table(ah, chan, &txPowerIndexOffset);
1173 
1174  regulatory->max_power_level = 0;
1175  for (i = 0; i < ARRAY_SIZE(ratesArray); i++) {
1176  ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]);
1177  if (ratesArray[i] > MAX_RATE_POWER)
1178  ratesArray[i] = MAX_RATE_POWER;
1179  if (ratesArray[i] > regulatory->max_power_level)
1180  regulatory->max_power_level = ratesArray[i];
1181  }
1182 
1183  if (!test) {
1184  i = rate6mb;
1185 
1186  if (IS_CHAN_HT40(chan))
1187  i = rateHt40_0;
1188  else if (IS_CHAN_HT20(chan))
1189  i = rateHt20_0;
1190 
1191  regulatory->max_power_level = ratesArray[i];
1192  }
1193 
1194  switch(ar5416_get_ntxchains(ah->txchainmask)) {
1195  case 1:
1196  break;
1197  case 2:
1199  break;
1200  case 3:
1202  break;
1203  default:
1204  DBG2("ath9k: "
1205  "Invalid chainmask configuration\n");
1206  break;
1207  }
1208 
1209  if (test)
1210  return;
1211 
1213  for (i = 0; i < Ar5416RateSize; i++) {
1214  int8_t pwr_table_offset;
1215 
1216  pwr_table_offset = ah->eep_ops->get_eeprom(ah,
1218  ratesArray[i] -= pwr_table_offset * 2;
1219  }
1220  }
1221 
1223 
1225  ATH9K_POW_SM(ratesArray[rate18mb], 24)
1226  | ATH9K_POW_SM(ratesArray[rate12mb], 16)
1227  | ATH9K_POW_SM(ratesArray[rate9mb], 8)
1228  | ATH9K_POW_SM(ratesArray[rate6mb], 0));
1230  ATH9K_POW_SM(ratesArray[rate54mb], 24)
1231  | ATH9K_POW_SM(ratesArray[rate48mb], 16)
1232  | ATH9K_POW_SM(ratesArray[rate36mb], 8)
1233  | ATH9K_POW_SM(ratesArray[rate24mb], 0));
1234 
1235  if (IS_CHAN_2GHZ(chan)) {
1237  cck_ofdm_delta = 2;
1241  | ATH9K_POW_SM(ratesArray[rateXr], 8)
1248  } else {
1250  ATH9K_POW_SM(ratesArray[rate2s], 24)
1251  | ATH9K_POW_SM(ratesArray[rate2l], 16)
1252  | ATH9K_POW_SM(ratesArray[rateXr], 8)
1253  | ATH9K_POW_SM(ratesArray[rate1l], 0));
1255  ATH9K_POW_SM(ratesArray[rate11s], 24)
1256  | ATH9K_POW_SM(ratesArray[rate11l], 16)
1257  | ATH9K_POW_SM(ratesArray[rate5_5s], 8)
1258  | ATH9K_POW_SM(ratesArray[rate5_5l], 0));
1259  }
1260  }
1261 
1263  ATH9K_POW_SM(ratesArray[rateHt20_3], 24)
1264  | ATH9K_POW_SM(ratesArray[rateHt20_2], 16)
1265  | ATH9K_POW_SM(ratesArray[rateHt20_1], 8)
1266  | ATH9K_POW_SM(ratesArray[rateHt20_0], 0));
1268  ATH9K_POW_SM(ratesArray[rateHt20_7], 24)
1269  | ATH9K_POW_SM(ratesArray[rateHt20_6], 16)
1270  | ATH9K_POW_SM(ratesArray[rateHt20_5], 8)
1271  | ATH9K_POW_SM(ratesArray[rateHt20_4], 0));
1272 
1273  if (IS_CHAN_HT40(chan)) {
1275  ATH9K_POW_SM(ratesArray[rateHt40_3] +
1277  | ATH9K_POW_SM(ratesArray[rateHt40_2] +
1279  | ATH9K_POW_SM(ratesArray[rateHt40_1] +
1281  | ATH9K_POW_SM(ratesArray[rateHt40_0] +
1282  ht40PowerIncForPdadc, 0));
1284  ATH9K_POW_SM(ratesArray[rateHt40_7] +
1286  | ATH9K_POW_SM(ratesArray[rateHt40_6] +
1288  | ATH9K_POW_SM(ratesArray[rateHt40_5] +
1290  | ATH9K_POW_SM(ratesArray[rateHt40_4] +
1291  ht40PowerIncForPdadc, 0));
1294  ATH9K_POW_SM(ratesArray[rateExtOfdm], 24)
1296  | ATH9K_POW_SM(ratesArray[rateDupOfdm], 8)
1298  } else {
1300  ATH9K_POW_SM(ratesArray[rateExtOfdm], 24)
1301  | ATH9K_POW_SM(ratesArray[rateExtCck], 16)
1302  | ATH9K_POW_SM(ratesArray[rateDupOfdm], 8)
1303  | ATH9K_POW_SM(ratesArray[rateDupCck], 0));
1304  }
1305  }
1306 
1309  | ATH9K_POW_SM(pModal->pwrDecreaseFor2Chain, 0));
1310 
1312 }
1313 
1314 static u16 ath9k_hw_def_get_spur_channel(struct ath_hw *ah, u16 i, int is2GHz)
1315 {
1316 #define EEP_DEF_SPURCHAN \
1317  (ah->eeprom.def.modalHeader[is2GHz].spurChans[i].spurChan)
1318 
1319  u16 spur_val = AR_NO_SPUR;
1320 
1321  DBG2("ath9k: "
1322  "Getting spur idx:%d is2Ghz:%d val:%x\n",
1323  i, is2GHz, ah->config.spurchans[i][is2GHz]);
1324 
1325  switch (ah->config.spurmode) {
1326  case SPUR_DISABLE:
1327  break;
1328  case SPUR_ENABLE_IOCTL:
1329  spur_val = ah->config.spurchans[i][is2GHz];
1330  DBG2("ath9k: "
1331  "Getting spur val from new loc. %d\n", spur_val);
1332  break;
1333  case SPUR_ENABLE_EEPROM:
1334  spur_val = EEP_DEF_SPURCHAN;
1335  break;
1336  }
1337 
1338  return spur_val;
1339 
1340 #undef EEP_DEF_SPURCHAN
1341 }
1342 
1343 const struct eeprom_ops eep_def_ops = {
1345  .get_eeprom = ath9k_hw_def_get_eeprom,
1346  .fill_eeprom = ath9k_hw_def_fill_eeprom,
1347  .get_eeprom_ver = ath9k_hw_def_get_eeprom_ver,
1348  .get_eeprom_rev = ath9k_hw_def_get_eeprom_rev,
1349  .set_board_values = ath9k_hw_def_set_board_values,
1350  .set_addac = ath9k_hw_def_set_addac,
1351  .set_txpower = ath9k_hw_def_set_txpower,
1352  .get_spur_channel = ath9k_hw_def_get_spur_channel
1353 };
#define AR_PHY_DESIRED_SZ_PGA
Definition: ar9002_phy.h:109
#define AR_PHY_RF_CTL4_FRAME_XPAA_ON
Definition: ar9002_phy.h:87
void ath9k_hw_get_target_powers(struct ath_hw *ah, struct ath9k_channel *chan, struct cal_target_power_ht *powInfo, u16 numChannels, struct cal_target_power_ht *pNewPower, u16 numRates, int isHt40Target)
Definition: ath9k_eeprom.c:218
#define AR5416_NUM_PD_GAINS
Definition: eeprom.h:154
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:22
#define AR_PHY_POWER_TX_RATE5
Definition: ar9002_phy.h:556
#define AR_PHY_RF_CTL4_TX_END_XPAB_OFF
Definition: ar9002_phy.h:81
#define EINVAL
Invalid argument.
Definition: errno.h:429
u32 antCtrlCommon
Definition: eeprom.h:339
iPXE I/O API
#define AR_AN_RF2G1_CH1_DB_S
Definition: reg.h:1258
Definition: hw.h:657
u16 synth_center
Definition: hw.h:423
#define AR5416_EEP_VER_MINOR_MASK
Definition: eeprom.h:133
#define AR_PHY_RF_CTL3
Definition: ar9002_phy.h:63
#define AR_AN_RF2G1_CH0_OB_S
Definition: reg.h:1244
#define AR_PHY_RXGAIN
Definition: ar9002_phy.h:96
static void ath9k_hw_def_set_addac(struct ath_hw *ah, struct ath9k_channel *chan)
#define AR_PHY_POWER_TX_RATE3
Definition: ar9002_phy.h:452
#define max(x, y)
Definition: ath.h:41
#define AR_SREV_9280_20_OR_LATER(_ah)
Definition: reg.h:825
u8 openLoopPwrCntl
Definition: eeprom.h:302
struct spur_chan spurChans[AR_EEPROM_MODAL_SPURS]
Definition: eeprom.h:377
#define ar5416_get_ntxchains(_txchainmask)
Definition: eeprom.h:707
#define CTL_2GHT40
Definition: eeprom.h:76
#define AR5416_NUM_5G_CAL_PIERS
Definition: eeprom.h:145
#define AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF
Definition: ar9002_phy.h:191
u16 regDmn[2]
Definition: eeprom.h:288
#define AR_PHY_POWER_TX_RATE2
Definition: ar9002_phy.h:208
#define AR_PHY_TX_PWRCTRL9
Definition: ar9002_phy.h:491
#define AR9280_TX_GAIN_TABLE_SIZE
Definition: eeprom.h:183
#define AR_AN_RF5G1_CH1_DB5
Definition: reg.h:1263
#define AR5416_EEPROM_MAGIC_OFFSET
Definition: eeprom.h:60
#define XPA_LVL_FREQ(cnt)
uint16_t magic
Magic signature.
Definition: bzimage.h:6
#define EXT_ADDITIVE
u8 pwrDecreaseFor2Chain
Definition: eeprom.h:360
#define IS_CHAN_2GHZ(_c)
Definition: hw.h:362
#define AR_PHY_GAIN_2GHZ_BSW_ATTEN
Definition: ar9002_phy.h:428
#define AR_AN_TOP2_LOCALBIAS
Definition: reg.h:1273
#define AR_EEPROM_MODAL_SPURS
Definition: eeprom.h:26
#define MS(_v, _f)
Definition: hw.h:103
static void ath9k_get_txgain_index(struct ath_hw *ah, struct ath9k_channel *chan, struct calDataPerFreqOpLoop *rawDatasetOpLoop, u8 *calChans, u16 availPiers, u8 *pwr, u8 *pcdacIdx)
#define INI_RA(iniarray, row, column)
Definition: calib.h:46
u16 ext_center
Definition: hw.h:425
#define REGWRITE_BUFFER_FLUSH(_ah)
Definition: hw.h:96
uint16_t size
Buffer size.
Definition: dwmac.h:14
#define AR_PHY_RF_CTL2
Definition: ar9002_phy.h:57
#define SUB_NUM_CTL_MODES_AT_5G_40
#define AR_PHY_POWER_TX_RATE4
Definition: ar9002_phy.h:453
#define AR_AN_RF2G1_CH0
Definition: reg.h:1242
struct cal_ctl_edges ctlEdges[AR5416_MAX_CHAINS][AR5416_NUM_BAND_EDGES]
Definition: eeprom.h:558
#define SPUR_DISABLE
Definition: hw.h:236
#define AR5416_EEP_MINOR_VER_20
Definition: eeprom.h:141
#define min(x, y)
Definition: ath.h:36
#define AR_PHY_TPCRG1_PD_GAIN_3
Definition: ar9002_phy.h:468
#define AR_AN_TOP2_XPABIAS_LVL_S
Definition: reg.h:1272
#define AR_PHY_GAIN_2GHZ_BSW_MARGIN
Definition: ar9002_phy.h:426
#define AR_SREV_5416_20_OR_LATER(_ah)
Definition: reg.h:802
#define ATH9K_POW_SM(_r, _s)
Definition: eeprom.h:102
u8 calFreqPier5G[AR5416_NUM_5G_CAL_PIERS]
Definition: eeprom.h:571
#define REDUCE_SCALED_POWER_BY_THREE_CHAIN
static int ath9k_hw_def_get_eeprom_rev(struct ath_hw *ah)
#define AR_PHY_EXT_CCA_THRESH62
Definition: ar9002_phy.h:335
#define AR5416_NUM_5G_20_TARGET_POWERS
Definition: eeprom.h:147
const struct eeprom_ops eep_def_ops
#define AR9280_PHY_CCA_THRESH62
Definition: ar9002_phy.h:137
static void ath9k_hw_def_set_gain(struct ath_hw *ah, struct modal_eep_header *pModal, struct ar5416_eeprom_def *eep, u8 txRxAttenLocal, int regChainOffset, int i)
#define AR_PHY_RXGAIN_TXRX_ATTEN
Definition: ar9002_phy.h:97
#define AR_AN_RF2G1_CH0_DB
Definition: reg.h:1245
#define AR5416_EEP_VER
Definition: eeprom.h:132
#define AR_PHY_POWER_TX_RATE1
Definition: ar9002_phy.h:207
struct cal_target_power_leg calTargetPower2G[AR5416_NUM_2G_20_TARGET_POWERS]
Definition: eeprom.h:585
#define AR_PHY_FRAME_CTL
Definition: ar9002_phy.h:212
#define REG_RMW_FIELD(_a, _r, _f, _v)
Definition: hw.h:104
#define FREQ2FBIN(x, y)
Definition: eeprom.h:103
#define AR5416_PD_GAINS_IN_MASK
Definition: eeprom.h:155
#define AR_AN_TOP1_DACIPMODE
Definition: reg.h:1267
#define AR_PHY_EXT_CCA
Definition: ar9002_phy.h:332
#define AR_SREV_9280_20(_ah)
Definition: reg.h:827
#define AR_AN_RF5G1_CH0_OB5
Definition: reg.h:1249
u8 iqCalQCh[AR5416_MAX_CHAINS]
Definition: eeprom.h:355
Definition: ath.h:129
#define AR_PHY_DESIRED_SZ
Definition: ar9002_phy.h:106
#define RT_AR_DELTA(x)
u8 pcdac[2][5]
Definition: eeprom.h:383
#define AR5416_EEP_MINOR_VER_7
Definition: eeprom.h:136
#define AR5416_NUM_5G_40_TARGET_POWERS
Definition: eeprom.h:148
#define AR_SREV_VERSION_9160
Definition: reg.h:773
#define AR_PHY_GAIN_2GHZ_XATTEN2_DB
Definition: ar9002_phy.h:435
#define AR_PHY_SWITCH_COM
Definition: ar9002_phy.h:253
#define LNA_CTL_FORCE_XPA
Definition: eeprom.h:223
u8 xatten2Db[AR5416_MAX_CHAINS]
Definition: eeprom.h:368
static u32 ath9k_hw_def_get_eeprom(struct ath_hw *ah, enum eeprom_param param)
#define SM(_v, _f)
Definition: hw.h:102
#define AR_PHY_FRAME_CTL_TX_CLIP
Definition: ar9002_phy.h:213
#define SIZE_EEPROM_DEF
#define AR_PHY_CCK_TX_CTRL
Definition: ar9002_phy.h:409
u8 bswAtten[AR5416_MAX_CHAINS]
Definition: eeprom.h:365
static int16_t ath9k_change_gain_boundary_setting(struct ath_hw *ah, u16 *gb, u16 numXpdGain, u16 pdGainOverlap_t2, int8_t pwr_table_offset, int16_t *diff)
#define AR_PHY_TX_END_DATA_START
Definition: ar9002_phy.h:58
#define AR_PHY_POWER_TX_SUB
Definition: ar9002_phy.h:561
#define AR_PHY_GAIN_2GHZ_XATTEN1_DB
Definition: ar9002_phy.h:437
void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah, struct ath9k_channel *chan, void *pRawDataSet, u8 *bChans, u16 availPiers, u16 tPdGainOverlap, u16 *pPdGainBoundaries, u8 *pPDADCValues, u16 numXpdGains)
Definition: ath9k_eeprom.c:320
#define AR_AN_RF5G1_CH0_DB5_S
Definition: reg.h:1252
#define AR_AN_TOP2_XPABIAS_LVL
Definition: reg.h:1271
#define AR_PHY_TIMING_CTRL4(_i)
Definition: ar9002_phy.h:188
#define AR_PHY_GAIN_2GHZ_XATTEN2_MARGIN
Definition: ar9002_phy.h:431
static struct ath_regulatory * ath9k_hw_regulatory(struct ath_hw *ah)
Definition: hw.h:875
u16 blueToothOptions
Definition: eeprom.h:293
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:61
static int ath9k_hw_def_check_eeprom(struct ath_hw *ah)
#define AR_PHY_TX_END_TO_A2_RX_ON
Definition: ar9002_phy.h:64
#define AR_PHY_SETTLING_SWITCH
Definition: ar9002_phy.h:93
#define AR_AN_RF5G1_CH1_OB5
Definition: reg.h:1261
#define AR_PHY_GAIN_2GHZ_RXTX_MARGIN
Definition: ar9002_phy.h:424
#define AR_PHY_RF_CTL4
Definition: ar9002_phy.h:80
#define u8
Definition: igbvf_osdep.h:40
Definition: eeprom.h:268
u32 antCtrlChain[AR5416_MAX_CHAINS]
Definition: eeprom.h:338
#define SPUR_ENABLE_EEPROM
Definition: hw.h:238
signed char int8_t
Definition: stdint.h:15
struct cal_target_power_ht calTargetPower5GHT20[AR5416_NUM_5G_20_TARGET_POWERS]
Definition: eeprom.h:579
static int ath9k_hw_def_get_eeprom_ver(struct ath_hw *ah)
#define AR_PHY_TX_PWRCTRL_INIT_TX_GAIN
Definition: ar9002_phy.h:486
Definition: eeprom.h:267
#define AR_PHY_CCK_TX_CTRL_TX_DAC_SCALE_CCK
Definition: ar9002_phy.h:411
#define AR_AN_RF5G1_CH1
Definition: reg.h:1260
#define REDUCE_SCALED_POWER_BY_TWO_CHAIN
#define AR_PHY_TX_DESIRED_SCALE_CCK
Definition: ar9002_phy.h:494
static void ath9k_hw_def_set_txpower(struct ath_hw *ah, struct ath9k_channel *chan, u16 cfgCtl, u8 twiceAntennaReduction, u8 twiceMaxRegulatoryPower, u8 powerLimit, int test)
#define ath9k_hw_use_flash(_ah)
Definition: eeprom.h:104
#define AR_PHY_TPCRG1_PD_GAIN_2
Definition: ar9002_phy.h:466
#define AR5416_NUM_PDADC_VALUES
Definition: eeprom.h:157
static u16 ath9k_hw_def_get_spur_channel(struct ath_hw *ah, u16 i, int is2GHz)
u16 spurChan
Definition: eeprom.h:332
int ath9k_hw_get_lower_upper_index(u8 target, u8 *pList, u16 listSize, u16 *indexL, u16 *indexR)
Definition: ath9k_eeprom.c:71
#define AR5416_NUM_2G_CCK_TARGET_POWERS
Definition: eeprom.h:149
#define AR_PHY_TPCRG1_PD_GAIN_1
Definition: ar9002_phy.h:464
#define AR5416_EEP_NO_BACK_VER
Definition: eeprom.h:131
#define AR5416_NUM_BAND_EDGES
Definition: eeprom.h:153
int ath9k_hw_nvram_read(struct ath_common *common, u32 off, u16 *data)
Definition: ath9k_eeprom.c:131
#define AR_AN_RF2G1_CH1_OB_S
Definition: reg.h:1256
#define CTL_11G_EXT
u16 ath9k_hw_get_max_edge_power(u16 freq, struct cal_ctl_edges *pRdEdgesPower, int is2GHz, int num_band_edges)
Definition: ath9k_eeprom.c:273
struct cal_ctl_data ctlData[AR5416_NUM_CTLS]
Definition: eeprom.h:592
#define AR_PHY_GAIN_2GHZ_XATTEN1_MARGIN
Definition: ar9002_phy.h:433
#define AR5416_NUM_CTLS
Definition: eeprom.h:152
#define AR5416_BCHAN_UNUSED
Definition: eeprom.h:158
#define EEP_DEF_SPURCHAN
#define AR_PHY_TX_PWRCTRL6_1
Definition: ar9002_phy.h:481
#define AR_SREV_9280(_ah)
Definition: reg.h:823
struct cal_target_power_leg calTargetPower5G[AR5416_NUM_5G_20_TARGET_POWERS]
Definition: eeprom.h:577
struct hv_monitor_parameter param[4][32]
Parameters.
Definition: hyperv.h:24
#define AR_AN_RF2G1_CH0_DB_S
Definition: reg.h:1246
#define AR_PHY_TX_PWRCTRL_ERR_EST_MODE
Definition: ar9002_phy.h:482
uint32_t addr
Buffer address.
Definition: dwmac.h:20
#define AR_AN_RF2G1_CH1_OB
Definition: reg.h:1255
#define AR5416_EEP_MINOR_VER_21
Definition: eeprom.h:142
#define AR5416_NUM_2G_20_TARGET_POWERS
Definition: eeprom.h:150
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
Definition: hw.h:870
#define AR_AN_RF5G1_CH1_DB5_S
Definition: reg.h:1264
#define AR_PHY_TPCRG1
Definition: ar9002_phy.h:460
#define ARRAY_SIZE(x)
Definition: efx_common.h:43
#define AR_PHY_EXT_CCA0_THRESH62
Definition: ar9002_phy.h:329
u8 pwr_table_offset
Definition: eeprom.h:307
#define CTL_11A
Definition: eeprom.h:71
u8 calFreqPier2G[AR5416_NUM_2G_CAL_PIERS]
Definition: eeprom.h:572
#define OLC_FOR_AR9280_20_LATER
Definition: eeprom.h:107
void ath9k_hw_analog_shift_rmw(struct ath_hw *ah, u32 reg, u32 mask, u32 shift, u32 val)
Definition: ath9k_eeprom.c:42
#define CTL_11G
Definition: eeprom.h:73
static void ath9k_adjust_pdadc_values(struct ath_hw *ah, int8_t pwr_table_offset, int16_t diff, u8 *pdadcValues)
#define AR_NO_SPUR
Definition: hw.h:241
static void ath9k_olc_get_pdadcs(struct ath_hw *ah, u32 initTxGain, int txPower, u8 *pPDADCValues)
#define AR_AN_RF2G1_CH1
Definition: reg.h:1254
#define AR_PHY_SETTLING
Definition: ar9002_phy.h:92
u8 xatten2Margin[AR5416_MAX_CHAINS]
Definition: eeprom.h:369
u16 xpaBiasLvlFreq[3]
Definition: eeprom.h:374
struct modal_eep_header modalHeader[2]
Definition: eeprom.h:570
#define AR_AN_TOP1
Definition: reg.h:1266
#define AR_PHY_FORCE_XPA_CFG
Definition: ar9002_phy.h:567
u8 pwrDecreaseFor3Chain
Definition: eeprom.h:361
static const uint32_t k[64]
MD5 constants.
Definition: md5.c:54
#define AR5416_NUM_2G_40_TARGET_POWERS
Definition: eeprom.h:151
struct ib_cm_common common
Definition: ib_mad.h:12
u8 bswMargin[AR5416_MAX_CHAINS]
Definition: eeprom.h:366
int(* check_eeprom)(struct ath_hw *hw)
Definition: eeprom.h:654
#define REG_READ(_ah, _reg)
Definition: hw.h:81
#define AR_AN_RF5G1_CH0_OB5_S
Definition: reg.h:1250
FILE_SECBOOT(FORBIDDEN)
void ath9k_hw_get_legacy_target_powers(struct ath_hw *ah, struct ath9k_channel *chan, struct cal_target_power_leg *powInfo, u16 numChannels, struct cal_target_power_leg *pNewPower, u16 numRates, int isExtTarget)
Definition: ath9k_eeprom.c:163
#define INCREASE_MAXPOW_BY_TWO_CHAIN
Definition: eeprom.h:87
#define AR5416_EEP_MINOR_VER_3
Definition: eeprom.h:135
#define AR_PHY_CCA
Definition: ar9002_phy.h:130
#define AR5416_PWR_TABLE_OFFSET_DB
Definition: eeprom.h:162
#define AR5416_MAX_CHAINS
Definition: eeprom.h:160
#define SUB_NUM_CTL_MODES_AT_2G_40
struct cal_target_power_ht calTargetPower5GHT40[AR5416_NUM_5G_40_TARGET_POWERS]
Definition: eeprom.h:581
#define SD_NO_CTL
Definition: eeprom.h:68
struct cal_target_power_ht calTargetPower2GHT20[AR5416_NUM_2G_20_TARGET_POWERS]
Definition: eeprom.h:587
#define AR9280_PHY_RXGAIN_TXRX_ATTEN
Definition: ar9002_phy.h:101
static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah, struct ath9k_channel *chan, int16_t *ratesArray, u16 cfgCtl, u16 AntennaReduction, u16 twiceMaxRegulatoryPower, u16 powerLimit)
#define swab16
Definition: ath.h:68
struct cal_target_power_leg calTargetPowerCck[AR5416_NUM_2G_CCK_TARGET_POWERS]
Definition: eeprom.h:583
u8 rxTxMarginCh[AR5416_MAX_CHAINS]
Definition: eeprom.h:343
#define AR_PHY_TPCRG5_PD_GAIN_OVERLAP
Definition: ar9002_phy.h:540
#define INCREASE_MAXPOW_BY_THREE_CHAIN
Definition: eeprom.h:88
void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data, int eep_start_loc, int size)
Definition: ath9k_eeprom.c:99
#define NUM_PDADC(diff)
#define AR_AN_RF2G1_CH0_OB
Definition: reg.h:1243
#define CTL_11A_EXT
eeprom_param
Definition: eeprom.h:226
#define AR_PHY_TX_END_PA_ON
Definition: ar9002_phy.h:60
u8 desiredScaleCCK
Definition: eeprom.h:306
#define AR_PHY_GAIN_2GHZ
Definition: ar9002_phy.h:423
#define REG_WRITE(_ah, _reg, _val)
Definition: hw.h:78
u8 ctlIndex[AR5416_NUM_CTLS]
Definition: eeprom.h:591
#define AR_AN_TOP2_LOCALBIAS_S
Definition: reg.h:1274
#define AR_PHY_BASE
Definition: phy.h:27
static void ath9k_hw_def_set_board_values(struct ath_hw *ah, struct ath9k_channel *chan)
#define AR5416_NUM_2G_CAL_PIERS
Definition: eeprom.h:146
#define CTL_2GHT20
Definition: eeprom.h:74
#define AR_PHY_TPCRG5
Definition: ar9002_phy.h:539
u8 dacHiPwrMode_5G
Definition: eeprom.h:301
#define CTL_11B
Definition: eeprom.h:72
#define AR5416_EEPROM_MAGIC
Definition: eeprom.h:34
#define AR_PHY_EXT_CCA0
Definition: ar9002_phy.h:328
unsigned short word
Definition: smc9000.h:39
struct cal_data_per_freq calPierData5G[AR5416_MAX_CHAINS][AR5416_NUM_5G_CAL_PIERS]
Definition: eeprom.h:573
static void ath9k_hw_set_def_power_cal_table(struct ath_hw *ah, struct ath9k_channel *chan, int16_t *pTxPowerIndexOffset)
#define CTL_MODE_M
Definition: eeprom.h:70
#define CTL_11B_EXT
u8 macAddr[6]
Definition: eeprom.h:289
#define AR9280_DEVID_PCI
Definition: hw.h:46
void ath9k_hw_get_channel_centers(struct ath_hw *ah __unused, struct ath9k_channel *chan, struct chan_centers *centers)
Definition: ath9k_hw.c:191
#define AR_PHY_TX_PWRCTRL6_0
Definition: ar9002_phy.h:480
#define SPUR_ENABLE_IOCTL
Definition: hw.h:237
#define AR5416_VER_MASK
Definition: eeprom.h:106
uint8_t ah
Definition: registers.h:85
#define AR_AN_RF2G1_CH1_DB
Definition: reg.h:1257
#define AR_PHY_SWITCH_CHAIN_0
Definition: ar9002_phy.h:252
#define AR_PHY_TX_PWRCTRL7
Definition: ar9002_phy.h:485
#define AR5416_EEP_MINOR_VER_22
Definition: eeprom.h:143
#define AR5416_EEP_MINOR_VER_2
Definition: eeprom.h:134
#define AR_PHY_XPA_CFG
Definition: ar9002_phy.h:566
signed short int16_t
Definition: stdint.h:16
#define IS_CHAN_HT20(_c)
Definition: hw.h:371
#define AR_PHY_POWER_TX_RATE9
Definition: ar9002_phy.h:564
struct cal_target_power_ht calTargetPower2GHT40[AR5416_NUM_2G_40_TARGET_POWERS]
Definition: eeprom.h:589
#define AR_PHY_DESIRED_SZ_ADC
Definition: ar9002_phy.h:107
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
u8 iqCalICh[AR5416_MAX_CHAINS]
Definition: eeprom.h:354
u8 pwrPdg[2][5]
Definition: eeprom.h:381
#define DBG(...)
Print a debugging message.
Definition: compiler.h:498
struct base_eep_header baseEepHeader
Definition: eeprom.h:568
#define IS_CHAN_HT40(_c)
Definition: hw.h:373
#define AR_PHY_RF_CTL4_TX_END_XPAA_OFF
Definition: ar9002_phy.h:83
#define AR9280_PHY_RXGAIN_TXRX_MARGIN
Definition: ar9002_phy.h:103
#define CTL_5GHT40
Definition: eeprom.h:77
#define AR_AN_TOP2
Definition: reg.h:1270
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
Definition: eeprom.h:267
u8 txRxAttenCh[AR5416_MAX_CHAINS]
Definition: eeprom.h:342
u8 ht40PowerIncForPdadc
Definition: eeprom.h:364
#define CTL_5GHT20
Definition: eeprom.h:75
#define AR_AN_RF5G1_CH0
Definition: reg.h:1248
#define AR_PHY_CCA_THRESH62
Definition: ar9002_phy.h:133
uint8_t u8
Definition: stdint.h:20
static int test
Definition: epic100.c:73
#define SM_PDGAIN_B(x, y)
u16 max_power_level
Definition: ath.h:141
#define MAX_RATE_POWER
Definition: hw.h:145
uint32_t u32
Definition: stdint.h:24
#define AR_PHY_TPCRG1_NUM_PD_GAIN
Definition: ar9002_phy.h:461
#define swab32
Definition: ath.h:69
Definition: eeprom.h:267
#define AR_PHY_POWER_TX_RATE7
Definition: ar9002_phy.h:562
u8 noiseFloorThreshCh[AR5416_MAX_CHAINS]
Definition: eeprom.h:351
struct cal_data_per_freq calPierData2G[AR5416_MAX_CHAINS][AR5416_NUM_2G_CAL_PIERS]
Definition: eeprom.h:575
#define ENABLE_REGWRITE_BUFFER(_ah)
Definition: hw.h:90
#define AR5416_EEP_MINOR_VER_19
Definition: eeprom.h:140
#define AR_PHY_POWER_TX_RATE8
Definition: ar9002_phy.h:563
#define DBG2(...)
Definition: compiler.h:515
static int ath9k_hw_def_fill_eeprom(struct ath_hw *ah)
if(natsemi->flags &NATSEMI_64BIT) return 1
u8 txFrameToDataStart
Definition: eeprom.h:362
#define SM_PD_GAIN(x)
static int __ath9k_hw_usb_def_fill_eeprom(struct ath_hw *ah)
#define AR_PHY_POWER_TX_RATE6
Definition: ar9002_phy.h:557
static int __ath9k_hw_def_fill_eeprom(struct ath_hw *ah)
#define AR_PHY_RF_CTL4_FRAME_XPAB_ON
Definition: ar9002_phy.h:85
u32 tp_scale
Definition: ath.h:142
void * memset(void *dest, int character, size_t len) __nonnull
#define AR_AN_RF5G1_CH1_OB5_S
Definition: reg.h:1262
#define LNA_CTL_LOCAL_BIAS
Definition: eeprom.h:222
#define AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF
Definition: ar9002_phy.h:189
#define AR_AN_RF5G1_CH0_DB5
Definition: reg.h:1251
u16 ctl_center
Definition: hw.h:424