eeprom.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  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 "hw.h"
  17. void ath9k_hw_analog_shift_regwrite(struct ath_hw *ah, u32 reg, u32 val)
  18. {
  19. REG_WRITE(ah, reg, val);
  20. if (ah->config.analog_shiftreg)
  21. udelay(100);
  22. }
  23. void ath9k_hw_analog_shift_rmw(struct ath_hw *ah, u32 reg, u32 mask,
  24. u32 shift, u32 val)
  25. {
  26. REG_RMW(ah, reg, ((val << shift) & mask), mask);
  27. if (ah->config.analog_shiftreg)
  28. udelay(100);
  29. }
  30. int16_t ath9k_hw_interpolate(u16 target, u16 srcLeft, u16 srcRight,
  31. int16_t targetLeft, int16_t targetRight)
  32. {
  33. int16_t rv;
  34. if (srcRight == srcLeft) {
  35. rv = targetLeft;
  36. } else {
  37. rv = (int16_t) (((target - srcLeft) * targetRight +
  38. (srcRight - target) * targetLeft) /
  39. (srcRight - srcLeft));
  40. }
  41. return rv;
  42. }
  43. bool ath9k_hw_get_lower_upper_index(u8 target, u8 *pList, u16 listSize,
  44. u16 *indexL, u16 *indexR)
  45. {
  46. u16 i;
  47. if (target <= pList[0]) {
  48. *indexL = *indexR = 0;
  49. return true;
  50. }
  51. if (target >= pList[listSize - 1]) {
  52. *indexL = *indexR = (u16) (listSize - 1);
  53. return true;
  54. }
  55. for (i = 0; i < listSize - 1; i++) {
  56. if (pList[i] == target) {
  57. *indexL = *indexR = i;
  58. return true;
  59. }
  60. if (target < pList[i + 1]) {
  61. *indexL = i;
  62. *indexR = (u16) (i + 1);
  63. return false;
  64. }
  65. }
  66. return false;
  67. }
  68. void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data,
  69. int eep_start_loc, int size)
  70. {
  71. int i = 0, j, addr;
  72. u32 addrdata[8];
  73. u32 data[8];
  74. for (addr = 0; addr < size; addr++) {
  75. addrdata[i] = AR5416_EEPROM_OFFSET +
  76. ((addr + eep_start_loc) << AR5416_EEPROM_S);
  77. i++;
  78. if (i == 8) {
  79. REG_READ_MULTI(ah, addrdata, data, i);
  80. for (j = 0; j < i; j++) {
  81. *eep_data = data[j];
  82. eep_data++;
  83. }
  84. i = 0;
  85. }
  86. }
  87. if (i != 0) {
  88. REG_READ_MULTI(ah, addrdata, data, i);
  89. for (j = 0; j < i; j++) {
  90. *eep_data = data[j];
  91. eep_data++;
  92. }
  93. }
  94. }
  95. static bool ath9k_hw_nvram_read_blob(struct ath_hw *ah, u32 off,
  96. u16 *data)
  97. {
  98. u16 *blob_data;
  99. if (off * sizeof(u16) > ah->eeprom_blob->size)
  100. return false;
  101. blob_data = (u16 *)ah->eeprom_blob->data;
  102. *data = blob_data[off];
  103. return true;
  104. }
  105. bool ath9k_hw_nvram_read(struct ath_hw *ah, u32 off, u16 *data)
  106. {
  107. struct ath_common *common = ath9k_hw_common(ah);
  108. bool ret;
  109. if (ah->eeprom_blob)
  110. ret = ath9k_hw_nvram_read_blob(ah, off, data);
  111. else
  112. ret = common->bus_ops->eeprom_read(common, off, data);
  113. if (!ret)
  114. ath_dbg(common, EEPROM,
  115. "unable to read eeprom region at offset %u\n", off);
  116. return ret;
  117. }
  118. void ath9k_hw_fill_vpd_table(u8 pwrMin, u8 pwrMax, u8 *pPwrList,
  119. u8 *pVpdList, u16 numIntercepts,
  120. u8 *pRetVpdList)
  121. {
  122. u16 i, k;
  123. u8 currPwr = pwrMin;
  124. u16 idxL = 0, idxR = 0;
  125. for (i = 0; i <= (pwrMax - pwrMin) / 2; i++) {
  126. ath9k_hw_get_lower_upper_index(currPwr, pPwrList,
  127. numIntercepts, &(idxL),
  128. &(idxR));
  129. if (idxR < 1)
  130. idxR = 1;
  131. if (idxL == numIntercepts - 1)
  132. idxL = (u16) (numIntercepts - 2);
  133. if (pPwrList[idxL] == pPwrList[idxR])
  134. k = pVpdList[idxL];
  135. else
  136. k = (u16)(((currPwr - pPwrList[idxL]) * pVpdList[idxR] +
  137. (pPwrList[idxR] - currPwr) * pVpdList[idxL]) /
  138. (pPwrList[idxR] - pPwrList[idxL]));
  139. pRetVpdList[i] = (u8) k;
  140. currPwr += 2;
  141. }
  142. }
  143. void ath9k_hw_get_legacy_target_powers(struct ath_hw *ah,
  144. struct ath9k_channel *chan,
  145. struct cal_target_power_leg *powInfo,
  146. u16 numChannels,
  147. struct cal_target_power_leg *pNewPower,
  148. u16 numRates, bool isExtTarget)
  149. {
  150. struct chan_centers centers;
  151. u16 clo, chi;
  152. int i;
  153. int matchIndex = -1, lowIndex = -1;
  154. u16 freq;
  155. ath9k_hw_get_channel_centers(ah, chan, &centers);
  156. freq = (isExtTarget) ? centers.ext_center : centers.ctl_center;
  157. if (freq <= ath9k_hw_fbin2freq(powInfo[0].bChannel,
  158. IS_CHAN_2GHZ(chan))) {
  159. matchIndex = 0;
  160. } else {
  161. for (i = 0; (i < numChannels) &&
  162. (powInfo[i].bChannel != AR5416_BCHAN_UNUSED); i++) {
  163. if (freq == ath9k_hw_fbin2freq(powInfo[i].bChannel,
  164. IS_CHAN_2GHZ(chan))) {
  165. matchIndex = i;
  166. break;
  167. } else if (freq < ath9k_hw_fbin2freq(powInfo[i].bChannel,
  168. IS_CHAN_2GHZ(chan)) && i > 0 &&
  169. freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel,
  170. IS_CHAN_2GHZ(chan))) {
  171. lowIndex = i - 1;
  172. break;
  173. }
  174. }
  175. if ((matchIndex == -1) && (lowIndex == -1))
  176. matchIndex = i - 1;
  177. }
  178. if (matchIndex != -1) {
  179. *pNewPower = powInfo[matchIndex];
  180. } else {
  181. clo = ath9k_hw_fbin2freq(powInfo[lowIndex].bChannel,
  182. IS_CHAN_2GHZ(chan));
  183. chi = ath9k_hw_fbin2freq(powInfo[lowIndex + 1].bChannel,
  184. IS_CHAN_2GHZ(chan));
  185. for (i = 0; i < numRates; i++) {
  186. pNewPower->tPow2x[i] =
  187. (u8)ath9k_hw_interpolate(freq, clo, chi,
  188. powInfo[lowIndex].tPow2x[i],
  189. powInfo[lowIndex + 1].tPow2x[i]);
  190. }
  191. }
  192. }
  193. void ath9k_hw_get_target_powers(struct ath_hw *ah,
  194. struct ath9k_channel *chan,
  195. struct cal_target_power_ht *powInfo,
  196. u16 numChannels,
  197. struct cal_target_power_ht *pNewPower,
  198. u16 numRates, bool isHt40Target)
  199. {
  200. struct chan_centers centers;
  201. u16 clo, chi;
  202. int i;
  203. int matchIndex = -1, lowIndex = -1;
  204. u16 freq;
  205. ath9k_hw_get_channel_centers(ah, chan, &centers);
  206. freq = isHt40Target ? centers.synth_center : centers.ctl_center;
  207. if (freq <= ath9k_hw_fbin2freq(powInfo[0].bChannel, IS_CHAN_2GHZ(chan))) {
  208. matchIndex = 0;
  209. } else {
  210. for (i = 0; (i < numChannels) &&
  211. (powInfo[i].bChannel != AR5416_BCHAN_UNUSED); i++) {
  212. if (freq == ath9k_hw_fbin2freq(powInfo[i].bChannel,
  213. IS_CHAN_2GHZ(chan))) {
  214. matchIndex = i;
  215. break;
  216. } else
  217. if (freq < ath9k_hw_fbin2freq(powInfo[i].bChannel,
  218. IS_CHAN_2GHZ(chan)) && i > 0 &&
  219. freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel,
  220. IS_CHAN_2GHZ(chan))) {
  221. lowIndex = i - 1;
  222. break;
  223. }
  224. }
  225. if ((matchIndex == -1) && (lowIndex == -1))
  226. matchIndex = i - 1;
  227. }
  228. if (matchIndex != -1) {
  229. *pNewPower = powInfo[matchIndex];
  230. } else {
  231. clo = ath9k_hw_fbin2freq(powInfo[lowIndex].bChannel,
  232. IS_CHAN_2GHZ(chan));
  233. chi = ath9k_hw_fbin2freq(powInfo[lowIndex + 1].bChannel,
  234. IS_CHAN_2GHZ(chan));
  235. for (i = 0; i < numRates; i++) {
  236. pNewPower->tPow2x[i] = (u8)ath9k_hw_interpolate(freq,
  237. clo, chi,
  238. powInfo[lowIndex].tPow2x[i],
  239. powInfo[lowIndex + 1].tPow2x[i]);
  240. }
  241. }
  242. }
  243. u16 ath9k_hw_get_max_edge_power(u16 freq, struct cal_ctl_edges *pRdEdgesPower,
  244. bool is2GHz, int num_band_edges)
  245. {
  246. u16 twiceMaxEdgePower = MAX_RATE_POWER;
  247. int i;
  248. for (i = 0; (i < num_band_edges) &&
  249. (pRdEdgesPower[i].bChannel != AR5416_BCHAN_UNUSED); i++) {
  250. if (freq == ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel, is2GHz)) {
  251. twiceMaxEdgePower = CTL_EDGE_TPOWER(pRdEdgesPower[i].ctl);
  252. break;
  253. } else if ((i > 0) &&
  254. (freq < ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel,
  255. is2GHz))) {
  256. if (ath9k_hw_fbin2freq(pRdEdgesPower[i - 1].bChannel,
  257. is2GHz) < freq &&
  258. CTL_EDGE_FLAGS(pRdEdgesPower[i - 1].ctl)) {
  259. twiceMaxEdgePower =
  260. CTL_EDGE_TPOWER(pRdEdgesPower[i - 1].ctl);
  261. }
  262. break;
  263. }
  264. }
  265. return twiceMaxEdgePower;
  266. }
  267. u16 ath9k_hw_get_scaled_power(struct ath_hw *ah, u16 power_limit,
  268. u8 antenna_reduction)
  269. {
  270. u16 reduction = antenna_reduction;
  271. /*
  272. * Reduce scaled Power by number of chains active
  273. * to get the per chain tx power level.
  274. */
  275. switch (ar5416_get_ntxchains(ah->txchainmask)) {
  276. case 1:
  277. break;
  278. case 2:
  279. reduction += POWER_CORRECTION_FOR_TWO_CHAIN;
  280. break;
  281. case 3:
  282. reduction += POWER_CORRECTION_FOR_THREE_CHAIN;
  283. break;
  284. }
  285. if (power_limit > reduction)
  286. power_limit -= reduction;
  287. else
  288. power_limit = 0;
  289. return power_limit;
  290. }
  291. void ath9k_hw_update_regulatory_maxpower(struct ath_hw *ah)
  292. {
  293. struct ath_common *common = ath9k_hw_common(ah);
  294. struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
  295. switch (ar5416_get_ntxchains(ah->txchainmask)) {
  296. case 1:
  297. break;
  298. case 2:
  299. regulatory->max_power_level += POWER_CORRECTION_FOR_TWO_CHAIN;
  300. break;
  301. case 3:
  302. regulatory->max_power_level += POWER_CORRECTION_FOR_THREE_CHAIN;
  303. break;
  304. default:
  305. ath_dbg(common, EEPROM, "Invalid chainmask configuration\n");
  306. break;
  307. }
  308. }
  309. void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah,
  310. struct ath9k_channel *chan,
  311. void *pRawDataSet,
  312. u8 *bChans, u16 availPiers,
  313. u16 tPdGainOverlap,
  314. u16 *pPdGainBoundaries, u8 *pPDADCValues,
  315. u16 numXpdGains)
  316. {
  317. int i, j, k;
  318. int16_t ss;
  319. u16 idxL = 0, idxR = 0, numPiers;
  320. static u8 vpdTableL[AR5416_NUM_PD_GAINS]
  321. [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
  322. static u8 vpdTableR[AR5416_NUM_PD_GAINS]
  323. [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
  324. static u8 vpdTableI[AR5416_NUM_PD_GAINS]
  325. [AR5416_MAX_PWR_RANGE_IN_HALF_DB];
  326. u8 *pVpdL, *pVpdR, *pPwrL, *pPwrR;
  327. u8 minPwrT4[AR5416_NUM_PD_GAINS];
  328. u8 maxPwrT4[AR5416_NUM_PD_GAINS];
  329. int16_t vpdStep;
  330. int16_t tmpVal;
  331. u16 sizeCurrVpdTable, maxIndex, tgtIndex;
  332. bool match;
  333. int16_t minDelta = 0;
  334. struct chan_centers centers;
  335. int pdgain_boundary_default;
  336. struct cal_data_per_freq *data_def = pRawDataSet;
  337. struct cal_data_per_freq_4k *data_4k = pRawDataSet;
  338. struct cal_data_per_freq_ar9287 *data_9287 = pRawDataSet;
  339. bool eeprom_4k = AR_SREV_9285(ah) || AR_SREV_9271(ah);
  340. int intercepts;
  341. if (AR_SREV_9287(ah))
  342. intercepts = AR9287_PD_GAIN_ICEPTS;
  343. else
  344. intercepts = AR5416_PD_GAIN_ICEPTS;
  345. memset(&minPwrT4, 0, AR5416_NUM_PD_GAINS);
  346. ath9k_hw_get_channel_centers(ah, chan, &centers);
  347. for (numPiers = 0; numPiers < availPiers; numPiers++) {
  348. if (bChans[numPiers] == AR5416_BCHAN_UNUSED)
  349. break;
  350. }
  351. match = ath9k_hw_get_lower_upper_index((u8)FREQ2FBIN(centers.synth_center,
  352. IS_CHAN_2GHZ(chan)),
  353. bChans, numPiers, &idxL, &idxR);
  354. if (match) {
  355. if (AR_SREV_9287(ah)) {
  356. for (i = 0; i < numXpdGains; i++) {
  357. minPwrT4[i] = data_9287[idxL].pwrPdg[i][0];
  358. maxPwrT4[i] = data_9287[idxL].pwrPdg[i][intercepts - 1];
  359. ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
  360. data_9287[idxL].pwrPdg[i],
  361. data_9287[idxL].vpdPdg[i],
  362. intercepts,
  363. vpdTableI[i]);
  364. }
  365. } else if (eeprom_4k) {
  366. for (i = 0; i < numXpdGains; i++) {
  367. minPwrT4[i] = data_4k[idxL].pwrPdg[i][0];
  368. maxPwrT4[i] = data_4k[idxL].pwrPdg[i][intercepts - 1];
  369. ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
  370. data_4k[idxL].pwrPdg[i],
  371. data_4k[idxL].vpdPdg[i],
  372. intercepts,
  373. vpdTableI[i]);
  374. }
  375. } else {
  376. for (i = 0; i < numXpdGains; i++) {
  377. minPwrT4[i] = data_def[idxL].pwrPdg[i][0];
  378. maxPwrT4[i] = data_def[idxL].pwrPdg[i][intercepts - 1];
  379. ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
  380. data_def[idxL].pwrPdg[i],
  381. data_def[idxL].vpdPdg[i],
  382. intercepts,
  383. vpdTableI[i]);
  384. }
  385. }
  386. } else {
  387. for (i = 0; i < numXpdGains; i++) {
  388. if (AR_SREV_9287(ah)) {
  389. pVpdL = data_9287[idxL].vpdPdg[i];
  390. pPwrL = data_9287[idxL].pwrPdg[i];
  391. pVpdR = data_9287[idxR].vpdPdg[i];
  392. pPwrR = data_9287[idxR].pwrPdg[i];
  393. } else if (eeprom_4k) {
  394. pVpdL = data_4k[idxL].vpdPdg[i];
  395. pPwrL = data_4k[idxL].pwrPdg[i];
  396. pVpdR = data_4k[idxR].vpdPdg[i];
  397. pPwrR = data_4k[idxR].pwrPdg[i];
  398. } else {
  399. pVpdL = data_def[idxL].vpdPdg[i];
  400. pPwrL = data_def[idxL].pwrPdg[i];
  401. pVpdR = data_def[idxR].vpdPdg[i];
  402. pPwrR = data_def[idxR].pwrPdg[i];
  403. }
  404. minPwrT4[i] = max(pPwrL[0], pPwrR[0]);
  405. maxPwrT4[i] =
  406. min(pPwrL[intercepts - 1],
  407. pPwrR[intercepts - 1]);
  408. ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
  409. pPwrL, pVpdL,
  410. intercepts,
  411. vpdTableL[i]);
  412. ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
  413. pPwrR, pVpdR,
  414. intercepts,
  415. vpdTableR[i]);
  416. for (j = 0; j <= (maxPwrT4[i] - minPwrT4[i]) / 2; j++) {
  417. vpdTableI[i][j] =
  418. (u8)(ath9k_hw_interpolate((u16)
  419. FREQ2FBIN(centers.
  420. synth_center,
  421. IS_CHAN_2GHZ
  422. (chan)),
  423. bChans[idxL], bChans[idxR],
  424. vpdTableL[i][j], vpdTableR[i][j]));
  425. }
  426. }
  427. }
  428. k = 0;
  429. for (i = 0; i < numXpdGains; i++) {
  430. if (i == (numXpdGains - 1))
  431. pPdGainBoundaries[i] =
  432. (u16)(maxPwrT4[i] / 2);
  433. else
  434. pPdGainBoundaries[i] =
  435. (u16)((maxPwrT4[i] + minPwrT4[i + 1]) / 4);
  436. pPdGainBoundaries[i] =
  437. min((u16)MAX_RATE_POWER, pPdGainBoundaries[i]);
  438. minDelta = 0;
  439. if (i == 0) {
  440. if (AR_SREV_9280_20_OR_LATER(ah))
  441. ss = (int16_t)(0 - (minPwrT4[i] / 2));
  442. else
  443. ss = 0;
  444. } else {
  445. ss = (int16_t)((pPdGainBoundaries[i - 1] -
  446. (minPwrT4[i] / 2)) -
  447. tPdGainOverlap + 1 + minDelta);
  448. }
  449. vpdStep = (int16_t)(vpdTableI[i][1] - vpdTableI[i][0]);
  450. vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
  451. while ((ss < 0) && (k < (AR5416_NUM_PDADC_VALUES - 1))) {
  452. tmpVal = (int16_t)(vpdTableI[i][0] + ss * vpdStep);
  453. pPDADCValues[k++] = (u8)((tmpVal < 0) ? 0 : tmpVal);
  454. ss++;
  455. }
  456. sizeCurrVpdTable = (u8) ((maxPwrT4[i] - minPwrT4[i]) / 2 + 1);
  457. tgtIndex = (u8)(pPdGainBoundaries[i] + tPdGainOverlap -
  458. (minPwrT4[i] / 2));
  459. maxIndex = (tgtIndex < sizeCurrVpdTable) ?
  460. tgtIndex : sizeCurrVpdTable;
  461. while ((ss < maxIndex) && (k < (AR5416_NUM_PDADC_VALUES - 1))) {
  462. pPDADCValues[k++] = vpdTableI[i][ss++];
  463. }
  464. vpdStep = (int16_t)(vpdTableI[i][sizeCurrVpdTable - 1] -
  465. vpdTableI[i][sizeCurrVpdTable - 2]);
  466. vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
  467. if (tgtIndex >= maxIndex) {
  468. while ((ss <= tgtIndex) &&
  469. (k < (AR5416_NUM_PDADC_VALUES - 1))) {
  470. tmpVal = (int16_t)((vpdTableI[i][sizeCurrVpdTable - 1] +
  471. (ss - maxIndex + 1) * vpdStep));
  472. pPDADCValues[k++] = (u8)((tmpVal > 255) ?
  473. 255 : tmpVal);
  474. ss++;
  475. }
  476. }
  477. }
  478. if (eeprom_4k)
  479. pdgain_boundary_default = 58;
  480. else
  481. pdgain_boundary_default = pPdGainBoundaries[i - 1];
  482. while (i < AR5416_PD_GAINS_IN_MASK) {
  483. pPdGainBoundaries[i] = pdgain_boundary_default;
  484. i++;
  485. }
  486. while (k < AR5416_NUM_PDADC_VALUES) {
  487. pPDADCValues[k] = pPDADCValues[k - 1];
  488. k++;
  489. }
  490. }
  491. int ath9k_hw_eeprom_init(struct ath_hw *ah)
  492. {
  493. int status;
  494. if (AR_SREV_9300_20_OR_LATER(ah))
  495. ah->eep_ops = &eep_ar9300_ops;
  496. else if (AR_SREV_9287(ah)) {
  497. ah->eep_ops = &eep_ar9287_ops;
  498. } else if (AR_SREV_9285(ah) || AR_SREV_9271(ah)) {
  499. ah->eep_ops = &eep_4k_ops;
  500. } else {
  501. ah->eep_ops = &eep_def_ops;
  502. }
  503. if (!ah->eep_ops->fill_eeprom(ah))
  504. return -EIO;
  505. status = ah->eep_ops->check_eeprom(ah);
  506. return status;
  507. }