eeprom_def.c 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394
  1. /*
  2. * Copyright (c) 2008-2011 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include <asm/unaligned.h>
  17. #include "hw.h"
  18. #include "ar9002_phy.h"
  19. static void ath9k_get_txgain_index(struct ath_hw *ah,
  20. struct ath9k_channel *chan,
  21. struct calDataPerFreqOpLoop *rawDatasetOpLoop,
  22. u8 *calChans, u16 availPiers, u8 *pwr, u8 *pcdacIdx)
  23. {
  24. u8 pcdac, i = 0;
  25. u16 idxL = 0, idxR = 0, numPiers;
  26. bool match;
  27. struct chan_centers centers;
  28. ath9k_hw_get_channel_centers(ah, chan, &centers);
  29. for (numPiers = 0; numPiers < availPiers; numPiers++)
  30. if (calChans[numPiers] == AR5416_BCHAN_UNUSED)
  31. break;
  32. match = ath9k_hw_get_lower_upper_index(
  33. (u8)FREQ2FBIN(centers.synth_center, IS_CHAN_2GHZ(chan)),
  34. calChans, numPiers, &idxL, &idxR);
  35. if (match) {
  36. pcdac = rawDatasetOpLoop[idxL].pcdac[0][0];
  37. *pwr = rawDatasetOpLoop[idxL].pwrPdg[0][0];
  38. } else {
  39. pcdac = rawDatasetOpLoop[idxR].pcdac[0][0];
  40. *pwr = (rawDatasetOpLoop[idxL].pwrPdg[0][0] +
  41. rawDatasetOpLoop[idxR].pwrPdg[0][0])/2;
  42. }
  43. while (pcdac > ah->originalGain[i] &&
  44. i < (AR9280_TX_GAIN_TABLE_SIZE - 1))
  45. i++;
  46. *pcdacIdx = i;
  47. }
  48. static void ath9k_olc_get_pdadcs(struct ath_hw *ah,
  49. u32 initTxGain,
  50. int txPower,
  51. u8 *pPDADCValues)
  52. {
  53. u32 i;
  54. u32 offset;
  55. REG_RMW_FIELD(ah, AR_PHY_TX_PWRCTRL6_0,
  56. AR_PHY_TX_PWRCTRL_ERR_EST_MODE, 3);
  57. REG_RMW_FIELD(ah, AR_PHY_TX_PWRCTRL6_1,
  58. AR_PHY_TX_PWRCTRL_ERR_EST_MODE, 3);
  59. REG_RMW_FIELD(ah, AR_PHY_TX_PWRCTRL7,
  60. AR_PHY_TX_PWRCTRL_INIT_TX_GAIN, initTxGain);
  61. offset = txPower;
  62. for (i = 0; i < AR5416_NUM_PDADC_VALUES; i++)
  63. if (i < offset)
  64. pPDADCValues[i] = 0x0;
  65. else
  66. pPDADCValues[i] = 0xFF;
  67. }
  68. static int ath9k_hw_def_get_eeprom_ver(struct ath_hw *ah)
  69. {
  70. return ((ah->eeprom.def.baseEepHeader.version >> 12) & 0xF);
  71. }
  72. static int ath9k_hw_def_get_eeprom_rev(struct ath_hw *ah)
  73. {
  74. return ((ah->eeprom.def.baseEepHeader.version) & 0xFFF);
  75. }
  76. #define SIZE_EEPROM_DEF (sizeof(struct ar5416_eeprom_def) / sizeof(u16))
  77. static bool __ath9k_hw_def_fill_eeprom(struct ath_hw *ah)
  78. {
  79. struct ath_common *common = ath9k_hw_common(ah);
  80. u16 *eep_data = (u16 *)&ah->eeprom.def;
  81. int addr, ar5416_eep_start_loc = 0x100;
  82. for (addr = 0; addr < SIZE_EEPROM_DEF; addr++) {
  83. if (!ath9k_hw_nvram_read(common, addr + ar5416_eep_start_loc,
  84. eep_data)) {
  85. ath_err(ath9k_hw_common(ah),
  86. "Unable to read eeprom region\n");
  87. return false;
  88. }
  89. eep_data++;
  90. }
  91. return true;
  92. }
  93. static bool __ath9k_hw_usb_def_fill_eeprom(struct ath_hw *ah)
  94. {
  95. u16 *eep_data = (u16 *)&ah->eeprom.def;
  96. ath9k_hw_usb_gen_fill_eeprom(ah, eep_data,
  97. 0x100, SIZE_EEPROM_DEF);
  98. return true;
  99. }
  100. static bool ath9k_hw_def_fill_eeprom(struct ath_hw *ah)
  101. {
  102. struct ath_common *common = ath9k_hw_common(ah);
  103. if (!ath9k_hw_use_flash(ah)) {
  104. ath_dbg(common, EEPROM, "Reading from EEPROM, not flash\n");
  105. }
  106. if (common->bus_ops->ath_bus_type == ATH_USB)
  107. return __ath9k_hw_usb_def_fill_eeprom(ah);
  108. else
  109. return __ath9k_hw_def_fill_eeprom(ah);
  110. }
  111. #undef SIZE_EEPROM_DEF
  112. #if defined(CONFIG_ATH9K_DEBUGFS) || defined(CONFIG_ATH9K_HTC_DEBUGFS)
  113. static u32 ath9k_def_dump_modal_eeprom(char *buf, u32 len, u32 size,
  114. struct modal_eep_header *modal_hdr)
  115. {
  116. PR_EEP("Chain0 Ant. Control", modal_hdr->antCtrlChain[0]);
  117. PR_EEP("Chain1 Ant. Control", modal_hdr->antCtrlChain[1]);
  118. PR_EEP("Chain2 Ant. Control", modal_hdr->antCtrlChain[2]);
  119. PR_EEP("Ant. Common Control", modal_hdr->antCtrlCommon);
  120. PR_EEP("Chain0 Ant. Gain", modal_hdr->antennaGainCh[0]);
  121. PR_EEP("Chain1 Ant. Gain", modal_hdr->antennaGainCh[1]);
  122. PR_EEP("Chain2 Ant. Gain", modal_hdr->antennaGainCh[2]);
  123. PR_EEP("Switch Settle", modal_hdr->switchSettling);
  124. PR_EEP("Chain0 TxRxAtten", modal_hdr->txRxAttenCh[0]);
  125. PR_EEP("Chain1 TxRxAtten", modal_hdr->txRxAttenCh[1]);
  126. PR_EEP("Chain2 TxRxAtten", modal_hdr->txRxAttenCh[2]);
  127. PR_EEP("Chain0 RxTxMargin", modal_hdr->rxTxMarginCh[0]);
  128. PR_EEP("Chain1 RxTxMargin", modal_hdr->rxTxMarginCh[1]);
  129. PR_EEP("Chain2 RxTxMargin", modal_hdr->rxTxMarginCh[2]);
  130. PR_EEP("ADC Desired size", modal_hdr->adcDesiredSize);
  131. PR_EEP("PGA Desired size", modal_hdr->pgaDesiredSize);
  132. PR_EEP("Chain0 xlna Gain", modal_hdr->xlnaGainCh[0]);
  133. PR_EEP("Chain1 xlna Gain", modal_hdr->xlnaGainCh[1]);
  134. PR_EEP("Chain2 xlna Gain", modal_hdr->xlnaGainCh[2]);
  135. PR_EEP("txEndToXpaOff", modal_hdr->txEndToXpaOff);
  136. PR_EEP("txEndToRxOn", modal_hdr->txEndToRxOn);
  137. PR_EEP("txFrameToXpaOn", modal_hdr->txFrameToXpaOn);
  138. PR_EEP("CCA Threshold)", modal_hdr->thresh62);
  139. PR_EEP("Chain0 NF Threshold", modal_hdr->noiseFloorThreshCh[0]);
  140. PR_EEP("Chain1 NF Threshold", modal_hdr->noiseFloorThreshCh[1]);
  141. PR_EEP("Chain2 NF Threshold", modal_hdr->noiseFloorThreshCh[2]);
  142. PR_EEP("xpdGain", modal_hdr->xpdGain);
  143. PR_EEP("External PD", modal_hdr->xpd);
  144. PR_EEP("Chain0 I Coefficient", modal_hdr->iqCalICh[0]);
  145. PR_EEP("Chain1 I Coefficient", modal_hdr->iqCalICh[1]);
  146. PR_EEP("Chain2 I Coefficient", modal_hdr->iqCalICh[2]);
  147. PR_EEP("Chain0 Q Coefficient", modal_hdr->iqCalQCh[0]);
  148. PR_EEP("Chain1 Q Coefficient", modal_hdr->iqCalQCh[1]);
  149. PR_EEP("Chain2 Q Coefficient", modal_hdr->iqCalQCh[2]);
  150. PR_EEP("pdGainOverlap", modal_hdr->pdGainOverlap);
  151. PR_EEP("Chain0 OutputBias", modal_hdr->ob);
  152. PR_EEP("Chain0 DriverBias", modal_hdr->db);
  153. PR_EEP("xPA Bias Level", modal_hdr->xpaBiasLvl);
  154. PR_EEP("2chain pwr decrease", modal_hdr->pwrDecreaseFor2Chain);
  155. PR_EEP("3chain pwr decrease", modal_hdr->pwrDecreaseFor3Chain);
  156. PR_EEP("txFrameToDataStart", modal_hdr->txFrameToDataStart);
  157. PR_EEP("txFrameToPaOn", modal_hdr->txFrameToPaOn);
  158. PR_EEP("HT40 Power Inc.", modal_hdr->ht40PowerIncForPdadc);
  159. PR_EEP("Chain0 bswAtten", modal_hdr->bswAtten[0]);
  160. PR_EEP("Chain1 bswAtten", modal_hdr->bswAtten[1]);
  161. PR_EEP("Chain2 bswAtten", modal_hdr->bswAtten[2]);
  162. PR_EEP("Chain0 bswMargin", modal_hdr->bswMargin[0]);
  163. PR_EEP("Chain1 bswMargin", modal_hdr->bswMargin[1]);
  164. PR_EEP("Chain2 bswMargin", modal_hdr->bswMargin[2]);
  165. PR_EEP("HT40 Switch Settle", modal_hdr->swSettleHt40);
  166. PR_EEP("Chain0 xatten2Db", modal_hdr->xatten2Db[0]);
  167. PR_EEP("Chain1 xatten2Db", modal_hdr->xatten2Db[1]);
  168. PR_EEP("Chain2 xatten2Db", modal_hdr->xatten2Db[2]);
  169. PR_EEP("Chain0 xatten2Margin", modal_hdr->xatten2Margin[0]);
  170. PR_EEP("Chain1 xatten2Margin", modal_hdr->xatten2Margin[1]);
  171. PR_EEP("Chain2 xatten2Margin", modal_hdr->xatten2Margin[2]);
  172. PR_EEP("Chain1 OutputBias", modal_hdr->ob_ch1);
  173. PR_EEP("Chain1 DriverBias", modal_hdr->db_ch1);
  174. PR_EEP("LNA Control", modal_hdr->lna_ctl);
  175. PR_EEP("XPA Bias Freq0", modal_hdr->xpaBiasLvlFreq[0]);
  176. PR_EEP("XPA Bias Freq1", modal_hdr->xpaBiasLvlFreq[1]);
  177. PR_EEP("XPA Bias Freq2", modal_hdr->xpaBiasLvlFreq[2]);
  178. return len;
  179. }
  180. static u32 ath9k_hw_def_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
  181. u8 *buf, u32 len, u32 size)
  182. {
  183. struct ar5416_eeprom_def *eep = &ah->eeprom.def;
  184. struct base_eep_header *pBase = &eep->baseEepHeader;
  185. if (!dump_base_hdr) {
  186. len += snprintf(buf + len, size - len,
  187. "%20s :\n", "2GHz modal Header");
  188. len += ath9k_def_dump_modal_eeprom(buf, len, size,
  189. &eep->modalHeader[0]);
  190. len += snprintf(buf + len, size - len,
  191. "%20s :\n", "5GHz modal Header");
  192. len += ath9k_def_dump_modal_eeprom(buf, len, size,
  193. &eep->modalHeader[1]);
  194. goto out;
  195. }
  196. PR_EEP("Major Version", pBase->version >> 12);
  197. PR_EEP("Minor Version", pBase->version & 0xFFF);
  198. PR_EEP("Checksum", pBase->checksum);
  199. PR_EEP("Length", pBase->length);
  200. PR_EEP("RegDomain1", pBase->regDmn[0]);
  201. PR_EEP("RegDomain2", pBase->regDmn[1]);
  202. PR_EEP("TX Mask", pBase->txMask);
  203. PR_EEP("RX Mask", pBase->rxMask);
  204. PR_EEP("Allow 5GHz", !!(pBase->opCapFlags & AR5416_OPFLAGS_11A));
  205. PR_EEP("Allow 2GHz", !!(pBase->opCapFlags & AR5416_OPFLAGS_11G));
  206. PR_EEP("Disable 2GHz HT20", !!(pBase->opCapFlags &
  207. AR5416_OPFLAGS_N_2G_HT20));
  208. PR_EEP("Disable 2GHz HT40", !!(pBase->opCapFlags &
  209. AR5416_OPFLAGS_N_2G_HT40));
  210. PR_EEP("Disable 5Ghz HT20", !!(pBase->opCapFlags &
  211. AR5416_OPFLAGS_N_5G_HT20));
  212. PR_EEP("Disable 5Ghz HT40", !!(pBase->opCapFlags &
  213. AR5416_OPFLAGS_N_5G_HT40));
  214. PR_EEP("Big Endian", !!(pBase->eepMisc & 0x01));
  215. PR_EEP("Cal Bin Major Ver", (pBase->binBuildNumber >> 24) & 0xFF);
  216. PR_EEP("Cal Bin Minor Ver", (pBase->binBuildNumber >> 16) & 0xFF);
  217. PR_EEP("Cal Bin Build", (pBase->binBuildNumber >> 8) & 0xFF);
  218. PR_EEP("OpenLoop Power Ctrl", pBase->openLoopPwrCntl);
  219. len += snprintf(buf + len, size - len, "%20s : %pM\n", "MacAddress",
  220. pBase->macAddr);
  221. out:
  222. if (len > size)
  223. len = size;
  224. return len;
  225. }
  226. #else
  227. static u32 ath9k_hw_def_dump_eeprom(struct ath_hw *ah, bool dump_base_hdr,
  228. u8 *buf, u32 len, u32 size)
  229. {
  230. return 0;
  231. }
  232. #endif
  233. static int ath9k_hw_def_check_eeprom(struct ath_hw *ah)
  234. {
  235. struct ar5416_eeprom_def *eep =
  236. (struct ar5416_eeprom_def *) &ah->eeprom.def;
  237. struct ath_common *common = ath9k_hw_common(ah);
  238. u16 *eepdata, temp, magic, magic2;
  239. u32 sum = 0, el;
  240. bool need_swap = false;
  241. int i, addr, size;
  242. if (!ath9k_hw_nvram_read(common, AR5416_EEPROM_MAGIC_OFFSET, &magic)) {
  243. ath_err(common, "Reading Magic # failed\n");
  244. return false;
  245. }
  246. if (!ath9k_hw_use_flash(ah)) {
  247. ath_dbg(common, EEPROM, "Read Magic = 0x%04X\n", magic);
  248. if (magic != AR5416_EEPROM_MAGIC) {
  249. magic2 = swab16(magic);
  250. if (magic2 == AR5416_EEPROM_MAGIC) {
  251. size = sizeof(struct ar5416_eeprom_def);
  252. need_swap = true;
  253. eepdata = (u16 *) (&ah->eeprom);
  254. for (addr = 0; addr < size / sizeof(u16); addr++) {
  255. temp = swab16(*eepdata);
  256. *eepdata = temp;
  257. eepdata++;
  258. }
  259. } else {
  260. ath_err(common,
  261. "Invalid EEPROM Magic. Endianness mismatch.\n");
  262. return -EINVAL;
  263. }
  264. }
  265. }
  266. ath_dbg(common, EEPROM, "need_swap = %s\n",
  267. need_swap ? "True" : "False");
  268. if (need_swap)
  269. el = swab16(ah->eeprom.def.baseEepHeader.length);
  270. else
  271. el = ah->eeprom.def.baseEepHeader.length;
  272. if (el > sizeof(struct ar5416_eeprom_def))
  273. el = sizeof(struct ar5416_eeprom_def) / sizeof(u16);
  274. else
  275. el = el / sizeof(u16);
  276. eepdata = (u16 *)(&ah->eeprom);
  277. for (i = 0; i < el; i++)
  278. sum ^= *eepdata++;
  279. if (need_swap) {
  280. u32 integer, j;
  281. u16 word;
  282. ath_dbg(common, EEPROM,
  283. "EEPROM Endianness is not native.. Changing.\n");
  284. word = swab16(eep->baseEepHeader.length);
  285. eep->baseEepHeader.length = word;
  286. word = swab16(eep->baseEepHeader.checksum);
  287. eep->baseEepHeader.checksum = word;
  288. word = swab16(eep->baseEepHeader.version);
  289. eep->baseEepHeader.version = word;
  290. word = swab16(eep->baseEepHeader.regDmn[0]);
  291. eep->baseEepHeader.regDmn[0] = word;
  292. word = swab16(eep->baseEepHeader.regDmn[1]);
  293. eep->baseEepHeader.regDmn[1] = word;
  294. word = swab16(eep->baseEepHeader.rfSilent);
  295. eep->baseEepHeader.rfSilent = word;
  296. word = swab16(eep->baseEepHeader.blueToothOptions);
  297. eep->baseEepHeader.blueToothOptions = word;
  298. word = swab16(eep->baseEepHeader.deviceCap);
  299. eep->baseEepHeader.deviceCap = word;
  300. for (j = 0; j < ARRAY_SIZE(eep->modalHeader); j++) {
  301. struct modal_eep_header *pModal =
  302. &eep->modalHeader[j];
  303. integer = swab32(pModal->antCtrlCommon);
  304. pModal->antCtrlCommon = integer;
  305. for (i = 0; i < AR5416_MAX_CHAINS; i++) {
  306. integer = swab32(pModal->antCtrlChain[i]);
  307. pModal->antCtrlChain[i] = integer;
  308. }
  309. for (i = 0; i < 3; i++) {
  310. word = swab16(pModal->xpaBiasLvlFreq[i]);
  311. pModal->xpaBiasLvlFreq[i] = word;
  312. }
  313. for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
  314. word = swab16(pModal->spurChans[i].spurChan);
  315. pModal->spurChans[i].spurChan = word;
  316. }
  317. }
  318. }
  319. if (sum != 0xffff || ah->eep_ops->get_eeprom_ver(ah) != AR5416_EEP_VER ||
  320. ah->eep_ops->get_eeprom_rev(ah) < AR5416_EEP_NO_BACK_VER) {
  321. ath_err(common, "Bad EEPROM checksum 0x%x or revision 0x%04x\n",
  322. sum, ah->eep_ops->get_eeprom_ver(ah));
  323. return -EINVAL;
  324. }
  325. /* Enable fixup for AR_AN_TOP2 if necessary */
  326. if ((ah->hw_version.devid == AR9280_DEVID_PCI) &&
  327. ((eep->baseEepHeader.version & 0xff) > 0x0a) &&
  328. (eep->baseEepHeader.pwdclkind == 0))
  329. ah->need_an_top2_fixup = true;
  330. if ((common->bus_ops->ath_bus_type == ATH_USB) &&
  331. (AR_SREV_9280(ah)))
  332. eep->modalHeader[0].xpaBiasLvl = 0;
  333. return 0;
  334. }
  335. static u32 ath9k_hw_def_get_eeprom(struct ath_hw *ah,
  336. enum eeprom_param param)
  337. {
  338. struct ar5416_eeprom_def *eep = &ah->eeprom.def;
  339. struct modal_eep_header *pModal = eep->modalHeader;
  340. struct base_eep_header *pBase = &eep->baseEepHeader;
  341. int band = 0;
  342. switch (param) {
  343. case EEP_NFTHRESH_5:
  344. return pModal[0].noiseFloorThreshCh[0];
  345. case EEP_NFTHRESH_2:
  346. return pModal[1].noiseFloorThreshCh[0];
  347. case EEP_MAC_LSW:
  348. return get_unaligned_be16(pBase->macAddr);
  349. case EEP_MAC_MID:
  350. return get_unaligned_be16(pBase->macAddr + 2);
  351. case EEP_MAC_MSW:
  352. return get_unaligned_be16(pBase->macAddr + 4);
  353. case EEP_REG_0:
  354. return pBase->regDmn[0];
  355. case EEP_OP_CAP:
  356. return pBase->deviceCap;
  357. case EEP_OP_MODE:
  358. return pBase->opCapFlags;
  359. case EEP_RF_SILENT:
  360. return pBase->rfSilent;
  361. case EEP_OB_5:
  362. return pModal[0].ob;
  363. case EEP_DB_5:
  364. return pModal[0].db;
  365. case EEP_OB_2:
  366. return pModal[1].ob;
  367. case EEP_DB_2:
  368. return pModal[1].db;
  369. case EEP_MINOR_REV:
  370. return AR5416_VER_MASK;
  371. case EEP_TX_MASK:
  372. return pBase->txMask;
  373. case EEP_RX_MASK:
  374. return pBase->rxMask;
  375. case EEP_FSTCLK_5G:
  376. return pBase->fastClk5g;
  377. case EEP_RXGAIN_TYPE:
  378. return pBase->rxGainType;
  379. case EEP_TXGAIN_TYPE:
  380. return pBase->txGainType;
  381. case EEP_OL_PWRCTRL:
  382. if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_19)
  383. return pBase->openLoopPwrCntl ? true : false;
  384. else
  385. return false;
  386. case EEP_RC_CHAIN_MASK:
  387. if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_19)
  388. return pBase->rcChainMask;
  389. else
  390. return 0;
  391. case EEP_DAC_HPWR_5G:
  392. if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_20)
  393. return pBase->dacHiPwrMode_5G;
  394. else
  395. return 0;
  396. case EEP_FRAC_N_5G:
  397. if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_22)
  398. return pBase->frac_n_5g;
  399. else
  400. return 0;
  401. case EEP_PWR_TABLE_OFFSET:
  402. if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_21)
  403. return pBase->pwr_table_offset;
  404. else
  405. return AR5416_PWR_TABLE_OFFSET_DB;
  406. case EEP_ANTENNA_GAIN_2G:
  407. band = 1;
  408. /* fall through */
  409. case EEP_ANTENNA_GAIN_5G:
  410. return max_t(u8, max_t(u8,
  411. pModal[band].antennaGainCh[0],
  412. pModal[band].antennaGainCh[1]),
  413. pModal[band].antennaGainCh[2]);
  414. default:
  415. return 0;
  416. }
  417. }
  418. static void ath9k_hw_def_set_gain(struct ath_hw *ah,
  419. struct modal_eep_header *pModal,
  420. struct ar5416_eeprom_def *eep,
  421. u8 txRxAttenLocal, int regChainOffset, int i)
  422. {
  423. if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_3) {
  424. txRxAttenLocal = pModal->txRxAttenCh[i];
  425. if (AR_SREV_9280_20_OR_LATER(ah)) {
  426. REG_RMW_FIELD(ah, AR_PHY_GAIN_2GHZ + regChainOffset,
  427. AR_PHY_GAIN_2GHZ_XATTEN1_MARGIN,
  428. pModal->bswMargin[i]);
  429. REG_RMW_FIELD(ah, AR_PHY_GAIN_2GHZ + regChainOffset,
  430. AR_PHY_GAIN_2GHZ_XATTEN1_DB,
  431. pModal->bswAtten[i]);
  432. REG_RMW_FIELD(ah, AR_PHY_GAIN_2GHZ + regChainOffset,
  433. AR_PHY_GAIN_2GHZ_XATTEN2_MARGIN,
  434. pModal->xatten2Margin[i]);
  435. REG_RMW_FIELD(ah, AR_PHY_GAIN_2GHZ + regChainOffset,
  436. AR_PHY_GAIN_2GHZ_XATTEN2_DB,
  437. pModal->xatten2Db[i]);
  438. } else {
  439. REG_WRITE(ah, AR_PHY_GAIN_2GHZ + regChainOffset,
  440. (REG_READ(ah, AR_PHY_GAIN_2GHZ + regChainOffset) &
  441. ~AR_PHY_GAIN_2GHZ_BSW_MARGIN)
  442. | SM(pModal-> bswMargin[i],
  443. AR_PHY_GAIN_2GHZ_BSW_MARGIN));
  444. REG_WRITE(ah, AR_PHY_GAIN_2GHZ + regChainOffset,
  445. (REG_READ(ah, AR_PHY_GAIN_2GHZ + regChainOffset) &
  446. ~AR_PHY_GAIN_2GHZ_BSW_ATTEN)
  447. | SM(pModal->bswAtten[i],
  448. AR_PHY_GAIN_2GHZ_BSW_ATTEN));
  449. }
  450. }
  451. if (AR_SREV_9280_20_OR_LATER(ah)) {
  452. REG_RMW_FIELD(ah,
  453. AR_PHY_RXGAIN + regChainOffset,
  454. AR9280_PHY_RXGAIN_TXRX_ATTEN, txRxAttenLocal);
  455. REG_RMW_FIELD(ah,
  456. AR_PHY_RXGAIN + regChainOffset,
  457. AR9280_PHY_RXGAIN_TXRX_MARGIN, pModal->rxTxMarginCh[i]);
  458. } else {
  459. REG_WRITE(ah,
  460. AR_PHY_RXGAIN + regChainOffset,
  461. (REG_READ(ah, AR_PHY_RXGAIN + regChainOffset) &
  462. ~AR_PHY_RXGAIN_TXRX_ATTEN)
  463. | SM(txRxAttenLocal, AR_PHY_RXGAIN_TXRX_ATTEN));
  464. REG_WRITE(ah,
  465. AR_PHY_GAIN_2GHZ + regChainOffset,
  466. (REG_READ(ah, AR_PHY_GAIN_2GHZ + regChainOffset) &
  467. ~AR_PHY_GAIN_2GHZ_RXTX_MARGIN) |
  468. SM(pModal->rxTxMarginCh[i], AR_PHY_GAIN_2GHZ_RXTX_MARGIN));
  469. }
  470. }
  471. static void ath9k_hw_def_set_board_values(struct ath_hw *ah,
  472. struct ath9k_channel *chan)
  473. {
  474. struct modal_eep_header *pModal;
  475. struct ar5416_eeprom_def *eep = &ah->eeprom.def;
  476. int i, regChainOffset;
  477. u8 txRxAttenLocal;
  478. pModal = &(eep->modalHeader[IS_CHAN_2GHZ(chan)]);
  479. txRxAttenLocal = IS_CHAN_2GHZ(chan) ? 23 : 44;
  480. REG_WRITE(ah, AR_PHY_SWITCH_COM, pModal->antCtrlCommon & 0xffff);
  481. for (i = 0; i < AR5416_MAX_CHAINS; i++) {
  482. if (AR_SREV_9280(ah)) {
  483. if (i >= 2)
  484. break;
  485. }
  486. if ((ah->rxchainmask == 5 || ah->txchainmask == 5) && (i != 0))
  487. regChainOffset = (i == 1) ? 0x2000 : 0x1000;
  488. else
  489. regChainOffset = i * 0x1000;
  490. REG_WRITE(ah, AR_PHY_SWITCH_CHAIN_0 + regChainOffset,
  491. pModal->antCtrlChain[i]);
  492. REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset,
  493. (REG_READ(ah, AR_PHY_TIMING_CTRL4(0) + regChainOffset) &
  494. ~(AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF |
  495. AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF)) |
  496. SM(pModal->iqCalICh[i],
  497. AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF) |
  498. SM(pModal->iqCalQCh[i],
  499. AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF));
  500. ath9k_hw_def_set_gain(ah, pModal, eep, txRxAttenLocal,
  501. regChainOffset, i);
  502. }
  503. if (AR_SREV_9280_20_OR_LATER(ah)) {
  504. if (IS_CHAN_2GHZ(chan)) {
  505. ath9k_hw_analog_shift_rmw(ah, AR_AN_RF2G1_CH0,
  506. AR_AN_RF2G1_CH0_OB,
  507. AR_AN_RF2G1_CH0_OB_S,
  508. pModal->ob);
  509. ath9k_hw_analog_shift_rmw(ah, AR_AN_RF2G1_CH0,
  510. AR_AN_RF2G1_CH0_DB,
  511. AR_AN_RF2G1_CH0_DB_S,
  512. pModal->db);
  513. ath9k_hw_analog_shift_rmw(ah, AR_AN_RF2G1_CH1,
  514. AR_AN_RF2G1_CH1_OB,
  515. AR_AN_RF2G1_CH1_OB_S,
  516. pModal->ob_ch1);
  517. ath9k_hw_analog_shift_rmw(ah, AR_AN_RF2G1_CH1,
  518. AR_AN_RF2G1_CH1_DB,
  519. AR_AN_RF2G1_CH1_DB_S,
  520. pModal->db_ch1);
  521. } else {
  522. ath9k_hw_analog_shift_rmw(ah, AR_AN_RF5G1_CH0,
  523. AR_AN_RF5G1_CH0_OB5,
  524. AR_AN_RF5G1_CH0_OB5_S,
  525. pModal->ob);
  526. ath9k_hw_analog_shift_rmw(ah, AR_AN_RF5G1_CH0,
  527. AR_AN_RF5G1_CH0_DB5,
  528. AR_AN_RF5G1_CH0_DB5_S,
  529. pModal->db);
  530. ath9k_hw_analog_shift_rmw(ah, AR_AN_RF5G1_CH1,
  531. AR_AN_RF5G1_CH1_OB5,
  532. AR_AN_RF5G1_CH1_OB5_S,
  533. pModal->ob_ch1);
  534. ath9k_hw_analog_shift_rmw(ah, AR_AN_RF5G1_CH1,
  535. AR_AN_RF5G1_CH1_DB5,
  536. AR_AN_RF5G1_CH1_DB5_S,
  537. pModal->db_ch1);
  538. }
  539. ath9k_hw_analog_shift_rmw(ah, AR_AN_TOP2,
  540. AR_AN_TOP2_XPABIAS_LVL,
  541. AR_AN_TOP2_XPABIAS_LVL_S,
  542. pModal->xpaBiasLvl);
  543. ath9k_hw_analog_shift_rmw(ah, AR_AN_TOP2,
  544. AR_AN_TOP2_LOCALBIAS,
  545. AR_AN_TOP2_LOCALBIAS_S,
  546. !!(pModal->lna_ctl &
  547. LNA_CTL_LOCAL_BIAS));
  548. REG_RMW_FIELD(ah, AR_PHY_XPA_CFG, AR_PHY_FORCE_XPA_CFG,
  549. !!(pModal->lna_ctl & LNA_CTL_FORCE_XPA));
  550. }
  551. REG_RMW_FIELD(ah, AR_PHY_SETTLING, AR_PHY_SETTLING_SWITCH,
  552. pModal->switchSettling);
  553. REG_RMW_FIELD(ah, AR_PHY_DESIRED_SZ, AR_PHY_DESIRED_SZ_ADC,
  554. pModal->adcDesiredSize);
  555. if (!AR_SREV_9280_20_OR_LATER(ah))
  556. REG_RMW_FIELD(ah, AR_PHY_DESIRED_SZ,
  557. AR_PHY_DESIRED_SZ_PGA,
  558. pModal->pgaDesiredSize);
  559. REG_WRITE(ah, AR_PHY_RF_CTL4,
  560. SM(pModal->txEndToXpaOff, AR_PHY_RF_CTL4_TX_END_XPAA_OFF)
  561. | SM(pModal->txEndToXpaOff,
  562. AR_PHY_RF_CTL4_TX_END_XPAB_OFF)
  563. | SM(pModal->txFrameToXpaOn,
  564. AR_PHY_RF_CTL4_FRAME_XPAA_ON)
  565. | SM(pModal->txFrameToXpaOn,
  566. AR_PHY_RF_CTL4_FRAME_XPAB_ON));
  567. REG_RMW_FIELD(ah, AR_PHY_RF_CTL3, AR_PHY_TX_END_TO_A2_RX_ON,
  568. pModal->txEndToRxOn);
  569. if (AR_SREV_9280_20_OR_LATER(ah)) {
  570. REG_RMW_FIELD(ah, AR_PHY_CCA, AR9280_PHY_CCA_THRESH62,
  571. pModal->thresh62);
  572. REG_RMW_FIELD(ah, AR_PHY_EXT_CCA0,
  573. AR_PHY_EXT_CCA0_THRESH62,
  574. pModal->thresh62);
  575. } else {
  576. REG_RMW_FIELD(ah, AR_PHY_CCA, AR_PHY_CCA_THRESH62,
  577. pModal->thresh62);
  578. REG_RMW_FIELD(ah, AR_PHY_EXT_CCA,
  579. AR_PHY_EXT_CCA_THRESH62,
  580. pModal->thresh62);
  581. }
  582. if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_2) {
  583. REG_RMW_FIELD(ah, AR_PHY_RF_CTL2,
  584. AR_PHY_TX_END_DATA_START,
  585. pModal->txFrameToDataStart);
  586. REG_RMW_FIELD(ah, AR_PHY_RF_CTL2, AR_PHY_TX_END_PA_ON,
  587. pModal->txFrameToPaOn);
  588. }
  589. if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_3) {
  590. if (IS_CHAN_HT40(chan))
  591. REG_RMW_FIELD(ah, AR_PHY_SETTLING,
  592. AR_PHY_SETTLING_SWITCH,
  593. pModal->swSettleHt40);
  594. }
  595. if (AR_SREV_9280_20_OR_LATER(ah) &&
  596. AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_19)
  597. REG_RMW_FIELD(ah, AR_PHY_CCK_TX_CTRL,
  598. AR_PHY_CCK_TX_CTRL_TX_DAC_SCALE_CCK,
  599. pModal->miscBits);
  600. if (AR_SREV_9280_20(ah) && AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_20) {
  601. if (IS_CHAN_2GHZ(chan))
  602. REG_RMW_FIELD(ah, AR_AN_TOP1, AR_AN_TOP1_DACIPMODE,
  603. eep->baseEepHeader.dacLpMode);
  604. else if (eep->baseEepHeader.dacHiPwrMode_5G)
  605. REG_RMW_FIELD(ah, AR_AN_TOP1, AR_AN_TOP1_DACIPMODE, 0);
  606. else
  607. REG_RMW_FIELD(ah, AR_AN_TOP1, AR_AN_TOP1_DACIPMODE,
  608. eep->baseEepHeader.dacLpMode);
  609. udelay(100);
  610. REG_RMW_FIELD(ah, AR_PHY_FRAME_CTL, AR_PHY_FRAME_CTL_TX_CLIP,
  611. pModal->miscBits >> 2);
  612. REG_RMW_FIELD(ah, AR_PHY_TX_PWRCTRL9,
  613. AR_PHY_TX_DESIRED_SCALE_CCK,
  614. eep->baseEepHeader.desiredScaleCCK);
  615. }
  616. }
  617. static void ath9k_hw_def_set_addac(struct ath_hw *ah,
  618. struct ath9k_channel *chan)
  619. {
  620. #define XPA_LVL_FREQ(cnt) (pModal->xpaBiasLvlFreq[cnt])
  621. struct modal_eep_header *pModal;
  622. struct ar5416_eeprom_def *eep = &ah->eeprom.def;
  623. u8 biaslevel;
  624. if (ah->hw_version.macVersion != AR_SREV_VERSION_9160)
  625. return;
  626. if (ah->eep_ops->get_eeprom_rev(ah) < AR5416_EEP_MINOR_VER_7)
  627. return;
  628. pModal = &(eep->modalHeader[IS_CHAN_2GHZ(chan)]);
  629. if (pModal->xpaBiasLvl != 0xff) {
  630. biaslevel = pModal->xpaBiasLvl;
  631. } else {
  632. u16 resetFreqBin, freqBin, freqCount = 0;
  633. struct chan_centers centers;
  634. ath9k_hw_get_channel_centers(ah, chan, &centers);
  635. resetFreqBin = FREQ2FBIN(centers.synth_center,
  636. IS_CHAN_2GHZ(chan));
  637. freqBin = XPA_LVL_FREQ(0) & 0xff;
  638. biaslevel = (u8) (XPA_LVL_FREQ(0) >> 14);
  639. freqCount++;
  640. while (freqCount < 3) {
  641. if (XPA_LVL_FREQ(freqCount) == 0x0)
  642. break;
  643. freqBin = XPA_LVL_FREQ(freqCount) & 0xff;
  644. if (resetFreqBin >= freqBin)
  645. biaslevel = (u8)(XPA_LVL_FREQ(freqCount) >> 14);
  646. else
  647. break;
  648. freqCount++;
  649. }
  650. }
  651. if (IS_CHAN_2GHZ(chan)) {
  652. INI_RA(&ah->iniAddac, 7, 1) = (INI_RA(&ah->iniAddac,
  653. 7, 1) & (~0x18)) | biaslevel << 3;
  654. } else {
  655. INI_RA(&ah->iniAddac, 6, 1) = (INI_RA(&ah->iniAddac,
  656. 6, 1) & (~0xc0)) | biaslevel << 6;
  657. }
  658. #undef XPA_LVL_FREQ
  659. }
  660. static int16_t ath9k_change_gain_boundary_setting(struct ath_hw *ah,
  661. u16 *gb,
  662. u16 numXpdGain,
  663. u16 pdGainOverlap_t2,
  664. int8_t pwr_table_offset,
  665. int16_t *diff)
  666. {
  667. u16 k;
  668. /* Prior to writing the boundaries or the pdadc vs. power table
  669. * into the chip registers the default starting point on the pdadc
  670. * vs. power table needs to be checked and the curve boundaries
  671. * adjusted accordingly
  672. */
  673. if (AR_SREV_9280_20_OR_LATER(ah)) {
  674. u16 gb_limit;
  675. if (AR5416_PWR_TABLE_OFFSET_DB != pwr_table_offset) {
  676. /* get the difference in dB */
  677. *diff = (u16)(pwr_table_offset - AR5416_PWR_TABLE_OFFSET_DB);
  678. /* get the number of half dB steps */
  679. *diff *= 2;
  680. /* change the original gain boundary settings
  681. * by the number of half dB steps
  682. */
  683. for (k = 0; k < numXpdGain; k++)
  684. gb[k] = (u16)(gb[k] - *diff);
  685. }
  686. /* Because of a hardware limitation, ensure the gain boundary
  687. * is not larger than (63 - overlap)
  688. */
  689. gb_limit = (u16)(MAX_RATE_POWER - pdGainOverlap_t2);
  690. for (k = 0; k < numXpdGain; k++)
  691. gb[k] = (u16)min(gb_limit, gb[k]);
  692. }
  693. return *diff;
  694. }
  695. static void ath9k_adjust_pdadc_values(struct ath_hw *ah,
  696. int8_t pwr_table_offset,
  697. int16_t diff,
  698. u8 *pdadcValues)
  699. {
  700. #define NUM_PDADC(diff) (AR5416_NUM_PDADC_VALUES - diff)
  701. u16 k;
  702. /* If this is a board that has a pwrTableOffset that differs from
  703. * the default AR5416_PWR_TABLE_OFFSET_DB then the start of the
  704. * pdadc vs pwr table needs to be adjusted prior to writing to the
  705. * chip.
  706. */
  707. if (AR_SREV_9280_20_OR_LATER(ah)) {
  708. if (AR5416_PWR_TABLE_OFFSET_DB != pwr_table_offset) {
  709. /* shift the table to start at the new offset */
  710. for (k = 0; k < (u16)NUM_PDADC(diff); k++ ) {
  711. pdadcValues[k] = pdadcValues[k + diff];
  712. }
  713. /* fill the back of the table */
  714. for (k = (u16)NUM_PDADC(diff); k < NUM_PDADC(0); k++) {
  715. pdadcValues[k] = pdadcValues[NUM_PDADC(diff)];
  716. }
  717. }
  718. }
  719. #undef NUM_PDADC
  720. }
  721. static void ath9k_hw_set_def_power_cal_table(struct ath_hw *ah,
  722. struct ath9k_channel *chan)
  723. {
  724. #define SM_PD_GAIN(x) SM(0x38, AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_##x)
  725. #define SM_PDGAIN_B(x, y) \
  726. SM((gainBoundaries[x]), AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_##y)
  727. struct ath_common *common = ath9k_hw_common(ah);
  728. struct ar5416_eeprom_def *pEepData = &ah->eeprom.def;
  729. struct cal_data_per_freq *pRawDataset;
  730. u8 *pCalBChans = NULL;
  731. u16 pdGainOverlap_t2;
  732. static u8 pdadcValues[AR5416_NUM_PDADC_VALUES];
  733. u16 gainBoundaries[AR5416_PD_GAINS_IN_MASK];
  734. u16 numPiers, i, j;
  735. int16_t diff = 0;
  736. u16 numXpdGain, xpdMask;
  737. u16 xpdGainValues[AR5416_NUM_PD_GAINS] = { 0, 0, 0, 0 };
  738. u32 reg32, regOffset, regChainOffset;
  739. int16_t modalIdx;
  740. int8_t pwr_table_offset;
  741. modalIdx = IS_CHAN_2GHZ(chan) ? 1 : 0;
  742. xpdMask = pEepData->modalHeader[modalIdx].xpdGain;
  743. pwr_table_offset = ah->eep_ops->get_eeprom(ah, EEP_PWR_TABLE_OFFSET);
  744. if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
  745. AR5416_EEP_MINOR_VER_2) {
  746. pdGainOverlap_t2 =
  747. pEepData->modalHeader[modalIdx].pdGainOverlap;
  748. } else {
  749. pdGainOverlap_t2 = (u16)(MS(REG_READ(ah, AR_PHY_TPCRG5),
  750. AR_PHY_TPCRG5_PD_GAIN_OVERLAP));
  751. }
  752. if (IS_CHAN_2GHZ(chan)) {
  753. pCalBChans = pEepData->calFreqPier2G;
  754. numPiers = AR5416_NUM_2G_CAL_PIERS;
  755. } else {
  756. pCalBChans = pEepData->calFreqPier5G;
  757. numPiers = AR5416_NUM_5G_CAL_PIERS;
  758. }
  759. if (OLC_FOR_AR9280_20_LATER && IS_CHAN_2GHZ(chan)) {
  760. pRawDataset = pEepData->calPierData2G[0];
  761. ah->initPDADC = ((struct calDataPerFreqOpLoop *)
  762. pRawDataset)->vpdPdg[0][0];
  763. }
  764. numXpdGain = 0;
  765. for (i = 1; i <= AR5416_PD_GAINS_IN_MASK; i++) {
  766. if ((xpdMask >> (AR5416_PD_GAINS_IN_MASK - i)) & 1) {
  767. if (numXpdGain >= AR5416_NUM_PD_GAINS)
  768. break;
  769. xpdGainValues[numXpdGain] =
  770. (u16)(AR5416_PD_GAINS_IN_MASK - i);
  771. numXpdGain++;
  772. }
  773. }
  774. REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_NUM_PD_GAIN,
  775. (numXpdGain - 1) & 0x3);
  776. REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_GAIN_1,
  777. xpdGainValues[0]);
  778. REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_GAIN_2,
  779. xpdGainValues[1]);
  780. REG_RMW_FIELD(ah, AR_PHY_TPCRG1, AR_PHY_TPCRG1_PD_GAIN_3,
  781. xpdGainValues[2]);
  782. for (i = 0; i < AR5416_MAX_CHAINS; i++) {
  783. if ((ah->rxchainmask == 5 || ah->txchainmask == 5) &&
  784. (i != 0)) {
  785. regChainOffset = (i == 1) ? 0x2000 : 0x1000;
  786. } else
  787. regChainOffset = i * 0x1000;
  788. if (pEepData->baseEepHeader.txMask & (1 << i)) {
  789. if (IS_CHAN_2GHZ(chan))
  790. pRawDataset = pEepData->calPierData2G[i];
  791. else
  792. pRawDataset = pEepData->calPierData5G[i];
  793. if (OLC_FOR_AR9280_20_LATER) {
  794. u8 pcdacIdx;
  795. u8 txPower;
  796. ath9k_get_txgain_index(ah, chan,
  797. (struct calDataPerFreqOpLoop *)pRawDataset,
  798. pCalBChans, numPiers, &txPower, &pcdacIdx);
  799. ath9k_olc_get_pdadcs(ah, pcdacIdx,
  800. txPower/2, pdadcValues);
  801. } else {
  802. ath9k_hw_get_gain_boundaries_pdadcs(ah,
  803. chan, pRawDataset,
  804. pCalBChans, numPiers,
  805. pdGainOverlap_t2,
  806. gainBoundaries,
  807. pdadcValues,
  808. numXpdGain);
  809. }
  810. diff = ath9k_change_gain_boundary_setting(ah,
  811. gainBoundaries,
  812. numXpdGain,
  813. pdGainOverlap_t2,
  814. pwr_table_offset,
  815. &diff);
  816. ENABLE_REGWRITE_BUFFER(ah);
  817. if (OLC_FOR_AR9280_20_LATER) {
  818. REG_WRITE(ah,
  819. AR_PHY_TPCRG5 + regChainOffset,
  820. SM(0x6,
  821. AR_PHY_TPCRG5_PD_GAIN_OVERLAP) |
  822. SM_PD_GAIN(1) | SM_PD_GAIN(2) |
  823. SM_PD_GAIN(3) | SM_PD_GAIN(4));
  824. } else {
  825. REG_WRITE(ah,
  826. AR_PHY_TPCRG5 + regChainOffset,
  827. SM(pdGainOverlap_t2,
  828. AR_PHY_TPCRG5_PD_GAIN_OVERLAP)|
  829. SM_PDGAIN_B(0, 1) |
  830. SM_PDGAIN_B(1, 2) |
  831. SM_PDGAIN_B(2, 3) |
  832. SM_PDGAIN_B(3, 4));
  833. }
  834. ath9k_adjust_pdadc_values(ah, pwr_table_offset,
  835. diff, pdadcValues);
  836. regOffset = AR_PHY_BASE + (672 << 2) + regChainOffset;
  837. for (j = 0; j < 32; j++) {
  838. reg32 = get_unaligned_le32(&pdadcValues[4 * j]);
  839. REG_WRITE(ah, regOffset, reg32);
  840. ath_dbg(common, EEPROM,
  841. "PDADC (%d,%4x): %4.4x %8.8x\n",
  842. i, regChainOffset, regOffset,
  843. reg32);
  844. ath_dbg(common, EEPROM,
  845. "PDADC: Chain %d | PDADC %3d Value %3d | PDADC %3d Value %3d | PDADC %3d Value %3d | PDADC %3d Value %3d |\n",
  846. i, 4 * j, pdadcValues[4 * j],
  847. 4 * j + 1, pdadcValues[4 * j + 1],
  848. 4 * j + 2, pdadcValues[4 * j + 2],
  849. 4 * j + 3, pdadcValues[4 * j + 3]);
  850. regOffset += 4;
  851. }
  852. REGWRITE_BUFFER_FLUSH(ah);
  853. }
  854. }
  855. #undef SM_PD_GAIN
  856. #undef SM_PDGAIN_B
  857. }
  858. static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
  859. struct ath9k_channel *chan,
  860. int16_t *ratesArray,
  861. u16 cfgCtl,
  862. u16 antenna_reduction,
  863. u16 powerLimit)
  864. {
  865. struct ar5416_eeprom_def *pEepData = &ah->eeprom.def;
  866. u16 twiceMaxEdgePower;
  867. int i;
  868. struct cal_ctl_data *rep;
  869. struct cal_target_power_leg targetPowerOfdm, targetPowerCck = {
  870. 0, { 0, 0, 0, 0}
  871. };
  872. struct cal_target_power_leg targetPowerOfdmExt = {
  873. 0, { 0, 0, 0, 0} }, targetPowerCckExt = {
  874. 0, { 0, 0, 0, 0 }
  875. };
  876. struct cal_target_power_ht targetPowerHt20, targetPowerHt40 = {
  877. 0, {0, 0, 0, 0}
  878. };
  879. u16 scaledPower = 0, minCtlPower;
  880. static const u16 ctlModesFor11a[] = {
  881. CTL_11A, CTL_5GHT20, CTL_11A_EXT, CTL_5GHT40
  882. };
  883. static const u16 ctlModesFor11g[] = {
  884. CTL_11B, CTL_11G, CTL_2GHT20,
  885. CTL_11B_EXT, CTL_11G_EXT, CTL_2GHT40
  886. };
  887. u16 numCtlModes;
  888. const u16 *pCtlMode;
  889. u16 ctlMode, freq;
  890. struct chan_centers centers;
  891. int tx_chainmask;
  892. u16 twiceMinEdgePower;
  893. tx_chainmask = ah->txchainmask;
  894. ath9k_hw_get_channel_centers(ah, chan, &centers);
  895. scaledPower = ath9k_hw_get_scaled_power(ah, powerLimit,
  896. antenna_reduction);
  897. if (IS_CHAN_2GHZ(chan)) {
  898. numCtlModes = ARRAY_SIZE(ctlModesFor11g) -
  899. SUB_NUM_CTL_MODES_AT_2G_40;
  900. pCtlMode = ctlModesFor11g;
  901. ath9k_hw_get_legacy_target_powers(ah, chan,
  902. pEepData->calTargetPowerCck,
  903. AR5416_NUM_2G_CCK_TARGET_POWERS,
  904. &targetPowerCck, 4, false);
  905. ath9k_hw_get_legacy_target_powers(ah, chan,
  906. pEepData->calTargetPower2G,
  907. AR5416_NUM_2G_20_TARGET_POWERS,
  908. &targetPowerOfdm, 4, false);
  909. ath9k_hw_get_target_powers(ah, chan,
  910. pEepData->calTargetPower2GHT20,
  911. AR5416_NUM_2G_20_TARGET_POWERS,
  912. &targetPowerHt20, 8, false);
  913. if (IS_CHAN_HT40(chan)) {
  914. numCtlModes = ARRAY_SIZE(ctlModesFor11g);
  915. ath9k_hw_get_target_powers(ah, chan,
  916. pEepData->calTargetPower2GHT40,
  917. AR5416_NUM_2G_40_TARGET_POWERS,
  918. &targetPowerHt40, 8, true);
  919. ath9k_hw_get_legacy_target_powers(ah, chan,
  920. pEepData->calTargetPowerCck,
  921. AR5416_NUM_2G_CCK_TARGET_POWERS,
  922. &targetPowerCckExt, 4, true);
  923. ath9k_hw_get_legacy_target_powers(ah, chan,
  924. pEepData->calTargetPower2G,
  925. AR5416_NUM_2G_20_TARGET_POWERS,
  926. &targetPowerOfdmExt, 4, true);
  927. }
  928. } else {
  929. numCtlModes = ARRAY_SIZE(ctlModesFor11a) -
  930. SUB_NUM_CTL_MODES_AT_5G_40;
  931. pCtlMode = ctlModesFor11a;
  932. ath9k_hw_get_legacy_target_powers(ah, chan,
  933. pEepData->calTargetPower5G,
  934. AR5416_NUM_5G_20_TARGET_POWERS,
  935. &targetPowerOfdm, 4, false);
  936. ath9k_hw_get_target_powers(ah, chan,
  937. pEepData->calTargetPower5GHT20,
  938. AR5416_NUM_5G_20_TARGET_POWERS,
  939. &targetPowerHt20, 8, false);
  940. if (IS_CHAN_HT40(chan)) {
  941. numCtlModes = ARRAY_SIZE(ctlModesFor11a);
  942. ath9k_hw_get_target_powers(ah, chan,
  943. pEepData->calTargetPower5GHT40,
  944. AR5416_NUM_5G_40_TARGET_POWERS,
  945. &targetPowerHt40, 8, true);
  946. ath9k_hw_get_legacy_target_powers(ah, chan,
  947. pEepData->calTargetPower5G,
  948. AR5416_NUM_5G_20_TARGET_POWERS,
  949. &targetPowerOfdmExt, 4, true);
  950. }
  951. }
  952. for (ctlMode = 0; ctlMode < numCtlModes; ctlMode++) {
  953. bool isHt40CtlMode = (pCtlMode[ctlMode] == CTL_5GHT40) ||
  954. (pCtlMode[ctlMode] == CTL_2GHT40);
  955. if (isHt40CtlMode)
  956. freq = centers.synth_center;
  957. else if (pCtlMode[ctlMode] & EXT_ADDITIVE)
  958. freq = centers.ext_center;
  959. else
  960. freq = centers.ctl_center;
  961. twiceMaxEdgePower = MAX_RATE_POWER;
  962. for (i = 0; (i < AR5416_NUM_CTLS) && pEepData->ctlIndex[i]; i++) {
  963. if ((((cfgCtl & ~CTL_MODE_M) |
  964. (pCtlMode[ctlMode] & CTL_MODE_M)) ==
  965. pEepData->ctlIndex[i]) ||
  966. (((cfgCtl & ~CTL_MODE_M) |
  967. (pCtlMode[ctlMode] & CTL_MODE_M)) ==
  968. ((pEepData->ctlIndex[i] & CTL_MODE_M) | SD_NO_CTL))) {
  969. rep = &(pEepData->ctlData[i]);
  970. twiceMinEdgePower = ath9k_hw_get_max_edge_power(freq,
  971. rep->ctlEdges[ar5416_get_ntxchains(tx_chainmask) - 1],
  972. IS_CHAN_2GHZ(chan), AR5416_NUM_BAND_EDGES);
  973. if ((cfgCtl & ~CTL_MODE_M) == SD_NO_CTL) {
  974. twiceMaxEdgePower = min(twiceMaxEdgePower,
  975. twiceMinEdgePower);
  976. } else {
  977. twiceMaxEdgePower = twiceMinEdgePower;
  978. break;
  979. }
  980. }
  981. }
  982. minCtlPower = min(twiceMaxEdgePower, scaledPower);
  983. switch (pCtlMode[ctlMode]) {
  984. case CTL_11B:
  985. for (i = 0; i < ARRAY_SIZE(targetPowerCck.tPow2x); i++) {
  986. targetPowerCck.tPow2x[i] =
  987. min((u16)targetPowerCck.tPow2x[i],
  988. minCtlPower);
  989. }
  990. break;
  991. case CTL_11A:
  992. case CTL_11G:
  993. for (i = 0; i < ARRAY_SIZE(targetPowerOfdm.tPow2x); i++) {
  994. targetPowerOfdm.tPow2x[i] =
  995. min((u16)targetPowerOfdm.tPow2x[i],
  996. minCtlPower);
  997. }
  998. break;
  999. case CTL_5GHT20:
  1000. case CTL_2GHT20:
  1001. for (i = 0; i < ARRAY_SIZE(targetPowerHt20.tPow2x); i++) {
  1002. targetPowerHt20.tPow2x[i] =
  1003. min((u16)targetPowerHt20.tPow2x[i],
  1004. minCtlPower);
  1005. }
  1006. break;
  1007. case CTL_11B_EXT:
  1008. targetPowerCckExt.tPow2x[0] = min((u16)
  1009. targetPowerCckExt.tPow2x[0],
  1010. minCtlPower);
  1011. break;
  1012. case CTL_11A_EXT:
  1013. case CTL_11G_EXT:
  1014. targetPowerOfdmExt.tPow2x[0] = min((u16)
  1015. targetPowerOfdmExt.tPow2x[0],
  1016. minCtlPower);
  1017. break;
  1018. case CTL_5GHT40:
  1019. case CTL_2GHT40:
  1020. for (i = 0; i < ARRAY_SIZE(targetPowerHt40.tPow2x); i++) {
  1021. targetPowerHt40.tPow2x[i] =
  1022. min((u16)targetPowerHt40.tPow2x[i],
  1023. minCtlPower);
  1024. }
  1025. break;
  1026. default:
  1027. break;
  1028. }
  1029. }
  1030. ratesArray[rate6mb] = ratesArray[rate9mb] = ratesArray[rate12mb] =
  1031. ratesArray[rate18mb] = ratesArray[rate24mb] =
  1032. targetPowerOfdm.tPow2x[0];
  1033. ratesArray[rate36mb] = targetPowerOfdm.tPow2x[1];
  1034. ratesArray[rate48mb] = targetPowerOfdm.tPow2x[2];
  1035. ratesArray[rate54mb] = targetPowerOfdm.tPow2x[3];
  1036. ratesArray[rateXr] = targetPowerOfdm.tPow2x[0];
  1037. for (i = 0; i < ARRAY_SIZE(targetPowerHt20.tPow2x); i++)
  1038. ratesArray[rateHt20_0 + i] = targetPowerHt20.tPow2x[i];
  1039. if (IS_CHAN_2GHZ(chan)) {
  1040. ratesArray[rate1l] = targetPowerCck.tPow2x[0];
  1041. ratesArray[rate2s] = ratesArray[rate2l] =
  1042. targetPowerCck.tPow2x[1];
  1043. ratesArray[rate5_5s] = ratesArray[rate5_5l] =
  1044. targetPowerCck.tPow2x[2];
  1045. ratesArray[rate11s] = ratesArray[rate11l] =
  1046. targetPowerCck.tPow2x[3];
  1047. }
  1048. if (IS_CHAN_HT40(chan)) {
  1049. for (i = 0; i < ARRAY_SIZE(targetPowerHt40.tPow2x); i++) {
  1050. ratesArray[rateHt40_0 + i] =
  1051. targetPowerHt40.tPow2x[i];
  1052. }
  1053. ratesArray[rateDupOfdm] = targetPowerHt40.tPow2x[0];
  1054. ratesArray[rateDupCck] = targetPowerHt40.tPow2x[0];
  1055. ratesArray[rateExtOfdm] = targetPowerOfdmExt.tPow2x[0];
  1056. if (IS_CHAN_2GHZ(chan)) {
  1057. ratesArray[rateExtCck] =
  1058. targetPowerCckExt.tPow2x[0];
  1059. }
  1060. }
  1061. }
  1062. static void ath9k_hw_def_set_txpower(struct ath_hw *ah,
  1063. struct ath9k_channel *chan,
  1064. u16 cfgCtl,
  1065. u8 twiceAntennaReduction,
  1066. u8 powerLimit, bool test)
  1067. {
  1068. #define RT_AR_DELTA(x) (ratesArray[x] - cck_ofdm_delta)
  1069. struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
  1070. struct ar5416_eeprom_def *pEepData = &ah->eeprom.def;
  1071. struct modal_eep_header *pModal =
  1072. &(pEepData->modalHeader[IS_CHAN_2GHZ(chan)]);
  1073. int16_t ratesArray[Ar5416RateSize];
  1074. u8 ht40PowerIncForPdadc = 2;
  1075. int i, cck_ofdm_delta = 0;
  1076. memset(ratesArray, 0, sizeof(ratesArray));
  1077. if ((pEepData->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) >=
  1078. AR5416_EEP_MINOR_VER_2) {
  1079. ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc;
  1080. }
  1081. ath9k_hw_set_def_power_per_rate_table(ah, chan,
  1082. &ratesArray[0], cfgCtl,
  1083. twiceAntennaReduction,
  1084. powerLimit);
  1085. ath9k_hw_set_def_power_cal_table(ah, chan);
  1086. regulatory->max_power_level = 0;
  1087. for (i = 0; i < ARRAY_SIZE(ratesArray); i++) {
  1088. if (ratesArray[i] > MAX_RATE_POWER)
  1089. ratesArray[i] = MAX_RATE_POWER;
  1090. if (ratesArray[i] > regulatory->max_power_level)
  1091. regulatory->max_power_level = ratesArray[i];
  1092. }
  1093. ath9k_hw_update_regulatory_maxpower(ah);
  1094. if (test)
  1095. return;
  1096. if (AR_SREV_9280_20_OR_LATER(ah)) {
  1097. for (i = 0; i < Ar5416RateSize; i++) {
  1098. int8_t pwr_table_offset;
  1099. pwr_table_offset = ah->eep_ops->get_eeprom(ah,
  1100. EEP_PWR_TABLE_OFFSET);
  1101. ratesArray[i] -= pwr_table_offset * 2;
  1102. }
  1103. }
  1104. ENABLE_REGWRITE_BUFFER(ah);
  1105. REG_WRITE(ah, AR_PHY_POWER_TX_RATE1,
  1106. ATH9K_POW_SM(ratesArray[rate18mb], 24)
  1107. | ATH9K_POW_SM(ratesArray[rate12mb], 16)
  1108. | ATH9K_POW_SM(ratesArray[rate9mb], 8)
  1109. | ATH9K_POW_SM(ratesArray[rate6mb], 0));
  1110. REG_WRITE(ah, AR_PHY_POWER_TX_RATE2,
  1111. ATH9K_POW_SM(ratesArray[rate54mb], 24)
  1112. | ATH9K_POW_SM(ratesArray[rate48mb], 16)
  1113. | ATH9K_POW_SM(ratesArray[rate36mb], 8)
  1114. | ATH9K_POW_SM(ratesArray[rate24mb], 0));
  1115. if (IS_CHAN_2GHZ(chan)) {
  1116. if (OLC_FOR_AR9280_20_LATER) {
  1117. cck_ofdm_delta = 2;
  1118. REG_WRITE(ah, AR_PHY_POWER_TX_RATE3,
  1119. ATH9K_POW_SM(RT_AR_DELTA(rate2s), 24)
  1120. | ATH9K_POW_SM(RT_AR_DELTA(rate2l), 16)
  1121. | ATH9K_POW_SM(ratesArray[rateXr], 8)
  1122. | ATH9K_POW_SM(RT_AR_DELTA(rate1l), 0));
  1123. REG_WRITE(ah, AR_PHY_POWER_TX_RATE4,
  1124. ATH9K_POW_SM(RT_AR_DELTA(rate11s), 24)
  1125. | ATH9K_POW_SM(RT_AR_DELTA(rate11l), 16)
  1126. | ATH9K_POW_SM(RT_AR_DELTA(rate5_5s), 8)
  1127. | ATH9K_POW_SM(RT_AR_DELTA(rate5_5l), 0));
  1128. } else {
  1129. REG_WRITE(ah, AR_PHY_POWER_TX_RATE3,
  1130. ATH9K_POW_SM(ratesArray[rate2s], 24)
  1131. | ATH9K_POW_SM(ratesArray[rate2l], 16)
  1132. | ATH9K_POW_SM(ratesArray[rateXr], 8)
  1133. | ATH9K_POW_SM(ratesArray[rate1l], 0));
  1134. REG_WRITE(ah, AR_PHY_POWER_TX_RATE4,
  1135. ATH9K_POW_SM(ratesArray[rate11s], 24)
  1136. | ATH9K_POW_SM(ratesArray[rate11l], 16)
  1137. | ATH9K_POW_SM(ratesArray[rate5_5s], 8)
  1138. | ATH9K_POW_SM(ratesArray[rate5_5l], 0));
  1139. }
  1140. }
  1141. REG_WRITE(ah, AR_PHY_POWER_TX_RATE5,
  1142. ATH9K_POW_SM(ratesArray[rateHt20_3], 24)
  1143. | ATH9K_POW_SM(ratesArray[rateHt20_2], 16)
  1144. | ATH9K_POW_SM(ratesArray[rateHt20_1], 8)
  1145. | ATH9K_POW_SM(ratesArray[rateHt20_0], 0));
  1146. REG_WRITE(ah, AR_PHY_POWER_TX_RATE6,
  1147. ATH9K_POW_SM(ratesArray[rateHt20_7], 24)
  1148. | ATH9K_POW_SM(ratesArray[rateHt20_6], 16)
  1149. | ATH9K_POW_SM(ratesArray[rateHt20_5], 8)
  1150. | ATH9K_POW_SM(ratesArray[rateHt20_4], 0));
  1151. if (IS_CHAN_HT40(chan)) {
  1152. REG_WRITE(ah, AR_PHY_POWER_TX_RATE7,
  1153. ATH9K_POW_SM(ratesArray[rateHt40_3] +
  1154. ht40PowerIncForPdadc, 24)
  1155. | ATH9K_POW_SM(ratesArray[rateHt40_2] +
  1156. ht40PowerIncForPdadc, 16)
  1157. | ATH9K_POW_SM(ratesArray[rateHt40_1] +
  1158. ht40PowerIncForPdadc, 8)
  1159. | ATH9K_POW_SM(ratesArray[rateHt40_0] +
  1160. ht40PowerIncForPdadc, 0));
  1161. REG_WRITE(ah, AR_PHY_POWER_TX_RATE8,
  1162. ATH9K_POW_SM(ratesArray[rateHt40_7] +
  1163. ht40PowerIncForPdadc, 24)
  1164. | ATH9K_POW_SM(ratesArray[rateHt40_6] +
  1165. ht40PowerIncForPdadc, 16)
  1166. | ATH9K_POW_SM(ratesArray[rateHt40_5] +
  1167. ht40PowerIncForPdadc, 8)
  1168. | ATH9K_POW_SM(ratesArray[rateHt40_4] +
  1169. ht40PowerIncForPdadc, 0));
  1170. if (OLC_FOR_AR9280_20_LATER) {
  1171. REG_WRITE(ah, AR_PHY_POWER_TX_RATE9,
  1172. ATH9K_POW_SM(ratesArray[rateExtOfdm], 24)
  1173. | ATH9K_POW_SM(RT_AR_DELTA(rateExtCck), 16)
  1174. | ATH9K_POW_SM(ratesArray[rateDupOfdm], 8)
  1175. | ATH9K_POW_SM(RT_AR_DELTA(rateDupCck), 0));
  1176. } else {
  1177. REG_WRITE(ah, AR_PHY_POWER_TX_RATE9,
  1178. ATH9K_POW_SM(ratesArray[rateExtOfdm], 24)
  1179. | ATH9K_POW_SM(ratesArray[rateExtCck], 16)
  1180. | ATH9K_POW_SM(ratesArray[rateDupOfdm], 8)
  1181. | ATH9K_POW_SM(ratesArray[rateDupCck], 0));
  1182. }
  1183. }
  1184. REG_WRITE(ah, AR_PHY_POWER_TX_SUB,
  1185. ATH9K_POW_SM(pModal->pwrDecreaseFor3Chain, 6)
  1186. | ATH9K_POW_SM(pModal->pwrDecreaseFor2Chain, 0));
  1187. REGWRITE_BUFFER_FLUSH(ah);
  1188. }
  1189. static u16 ath9k_hw_def_get_spur_channel(struct ath_hw *ah, u16 i, bool is2GHz)
  1190. {
  1191. #define EEP_DEF_SPURCHAN \
  1192. (ah->eeprom.def.modalHeader[is2GHz].spurChans[i].spurChan)
  1193. struct ath_common *common = ath9k_hw_common(ah);
  1194. u16 spur_val = AR_NO_SPUR;
  1195. ath_dbg(common, ANI, "Getting spur idx:%d is2Ghz:%d val:%x\n",
  1196. i, is2GHz, ah->config.spurchans[i][is2GHz]);
  1197. switch (ah->config.spurmode) {
  1198. case SPUR_DISABLE:
  1199. break;
  1200. case SPUR_ENABLE_IOCTL:
  1201. spur_val = ah->config.spurchans[i][is2GHz];
  1202. ath_dbg(common, ANI, "Getting spur val from new loc. %d\n",
  1203. spur_val);
  1204. break;
  1205. case SPUR_ENABLE_EEPROM:
  1206. spur_val = EEP_DEF_SPURCHAN;
  1207. break;
  1208. }
  1209. return spur_val;
  1210. #undef EEP_DEF_SPURCHAN
  1211. }
  1212. const struct eeprom_ops eep_def_ops = {
  1213. .check_eeprom = ath9k_hw_def_check_eeprom,
  1214. .get_eeprom = ath9k_hw_def_get_eeprom,
  1215. .fill_eeprom = ath9k_hw_def_fill_eeprom,
  1216. .dump_eeprom = ath9k_hw_def_dump_eeprom,
  1217. .get_eeprom_ver = ath9k_hw_def_get_eeprom_ver,
  1218. .get_eeprom_rev = ath9k_hw_def_get_eeprom_rev,
  1219. .set_board_values = ath9k_hw_def_set_board_values,
  1220. .set_addac = ath9k_hw_def_set_addac,
  1221. .set_txpower = ath9k_hw_def_set_txpower,
  1222. .get_spur_channel = ath9k_hw_def_get_spur_channel
  1223. };