calib.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014
  1. /*
  2. * Copyright (c) 2008 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 "core.h"
  17. #include "hw.h"
  18. #include "reg.h"
  19. #include "phy.h"
  20. static const int16_t NOISE_FLOOR[] = { -96, -93, -98, -96, -93, -96 };
  21. /* We can tune this as we go by monitoring really low values */
  22. #define ATH9K_NF_TOO_LOW -60
  23. /* AR5416 may return very high value (like -31 dBm), in those cases the nf
  24. * is incorrect and we should use the static NF value. Later we can try to
  25. * find out why they are reporting these values */
  26. static bool ath9k_hw_nf_in_range(struct ath_hal *ah, s16 nf)
  27. {
  28. if (nf > ATH9K_NF_TOO_LOW) {
  29. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  30. "noise floor value detected (%d) is "
  31. "lower than what we think is a "
  32. "reasonable value (%d)\n",
  33. nf, ATH9K_NF_TOO_LOW);
  34. return false;
  35. }
  36. return true;
  37. }
  38. static int16_t ath9k_hw_get_nf_hist_mid(int16_t *nfCalBuffer)
  39. {
  40. int16_t nfval;
  41. int16_t sort[ATH9K_NF_CAL_HIST_MAX];
  42. int i, j;
  43. for (i = 0; i < ATH9K_NF_CAL_HIST_MAX; i++)
  44. sort[i] = nfCalBuffer[i];
  45. for (i = 0; i < ATH9K_NF_CAL_HIST_MAX - 1; i++) {
  46. for (j = 1; j < ATH9K_NF_CAL_HIST_MAX - i; j++) {
  47. if (sort[j] > sort[j - 1]) {
  48. nfval = sort[j];
  49. sort[j] = sort[j - 1];
  50. sort[j - 1] = nfval;
  51. }
  52. }
  53. }
  54. nfval = sort[(ATH9K_NF_CAL_HIST_MAX - 1) >> 1];
  55. return nfval;
  56. }
  57. static void ath9k_hw_update_nfcal_hist_buffer(struct ath9k_nfcal_hist *h,
  58. int16_t *nfarray)
  59. {
  60. int i;
  61. for (i = 0; i < NUM_NF_READINGS; i++) {
  62. h[i].nfCalBuffer[h[i].currIndex] = nfarray[i];
  63. if (++h[i].currIndex >= ATH9K_NF_CAL_HIST_MAX)
  64. h[i].currIndex = 0;
  65. if (h[i].invalidNFcount > 0) {
  66. if (nfarray[i] < AR_PHY_CCA_MIN_BAD_VALUE ||
  67. nfarray[i] > AR_PHY_CCA_MAX_HIGH_VALUE) {
  68. h[i].invalidNFcount = ATH9K_NF_CAL_HIST_MAX;
  69. } else {
  70. h[i].invalidNFcount--;
  71. h[i].privNF = nfarray[i];
  72. }
  73. } else {
  74. h[i].privNF =
  75. ath9k_hw_get_nf_hist_mid(h[i].nfCalBuffer);
  76. }
  77. }
  78. return;
  79. }
  80. static void ath9k_hw_do_getnf(struct ath_hal *ah,
  81. int16_t nfarray[NUM_NF_READINGS])
  82. {
  83. int16_t nf;
  84. if (AR_SREV_9280_10_OR_LATER(ah))
  85. nf = MS(REG_READ(ah, AR_PHY_CCA), AR9280_PHY_MINCCA_PWR);
  86. else
  87. nf = MS(REG_READ(ah, AR_PHY_CCA), AR_PHY_MINCCA_PWR);
  88. if (nf & 0x100)
  89. nf = 0 - ((nf ^ 0x1ff) + 1);
  90. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  91. "NF calibrated [ctl] [chain 0] is %d\n", nf);
  92. nfarray[0] = nf;
  93. if (AR_SREV_9280_10_OR_LATER(ah))
  94. nf = MS(REG_READ(ah, AR_PHY_CH1_CCA),
  95. AR9280_PHY_CH1_MINCCA_PWR);
  96. else
  97. nf = MS(REG_READ(ah, AR_PHY_CH1_CCA),
  98. AR_PHY_CH1_MINCCA_PWR);
  99. if (nf & 0x100)
  100. nf = 0 - ((nf ^ 0x1ff) + 1);
  101. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  102. "NF calibrated [ctl] [chain 1] is %d\n", nf);
  103. nfarray[1] = nf;
  104. if (!AR_SREV_9280(ah)) {
  105. nf = MS(REG_READ(ah, AR_PHY_CH2_CCA),
  106. AR_PHY_CH2_MINCCA_PWR);
  107. if (nf & 0x100)
  108. nf = 0 - ((nf ^ 0x1ff) + 1);
  109. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  110. "NF calibrated [ctl] [chain 2] is %d\n", nf);
  111. nfarray[2] = nf;
  112. }
  113. if (AR_SREV_9280_10_OR_LATER(ah))
  114. nf = MS(REG_READ(ah, AR_PHY_EXT_CCA),
  115. AR9280_PHY_EXT_MINCCA_PWR);
  116. else
  117. nf = MS(REG_READ(ah, AR_PHY_EXT_CCA),
  118. AR_PHY_EXT_MINCCA_PWR);
  119. if (nf & 0x100)
  120. nf = 0 - ((nf ^ 0x1ff) + 1);
  121. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  122. "NF calibrated [ext] [chain 0] is %d\n", nf);
  123. nfarray[3] = nf;
  124. if (AR_SREV_9280_10_OR_LATER(ah))
  125. nf = MS(REG_READ(ah, AR_PHY_CH1_EXT_CCA),
  126. AR9280_PHY_CH1_EXT_MINCCA_PWR);
  127. else
  128. nf = MS(REG_READ(ah, AR_PHY_CH1_EXT_CCA),
  129. AR_PHY_CH1_EXT_MINCCA_PWR);
  130. if (nf & 0x100)
  131. nf = 0 - ((nf ^ 0x1ff) + 1);
  132. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  133. "NF calibrated [ext] [chain 1] is %d\n", nf);
  134. nfarray[4] = nf;
  135. if (!AR_SREV_9280(ah)) {
  136. nf = MS(REG_READ(ah, AR_PHY_CH2_EXT_CCA),
  137. AR_PHY_CH2_EXT_MINCCA_PWR);
  138. if (nf & 0x100)
  139. nf = 0 - ((nf ^ 0x1ff) + 1);
  140. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  141. "NF calibrated [ext] [chain 2] is %d\n", nf);
  142. nfarray[5] = nf;
  143. }
  144. }
  145. static bool getNoiseFloorThresh(struct ath_hal *ah,
  146. enum ieee80211_band band,
  147. int16_t *nft)
  148. {
  149. switch (band) {
  150. case IEEE80211_BAND_5GHZ:
  151. *nft = (int8_t)ath9k_hw_get_eeprom(ah, EEP_NFTHRESH_5);
  152. break;
  153. case IEEE80211_BAND_2GHZ:
  154. *nft = (int8_t)ath9k_hw_get_eeprom(ah, EEP_NFTHRESH_2);
  155. break;
  156. default:
  157. BUG_ON(1);
  158. return false;
  159. }
  160. return true;
  161. }
  162. static void ath9k_hw_setup_calibration(struct ath_hal *ah,
  163. struct hal_cal_list *currCal)
  164. {
  165. REG_RMW_FIELD(ah, AR_PHY_TIMING_CTRL4(0),
  166. AR_PHY_TIMING_CTRL4_IQCAL_LOG_COUNT_MAX,
  167. currCal->calData->calCountMax);
  168. switch (currCal->calData->calType) {
  169. case IQ_MISMATCH_CAL:
  170. REG_WRITE(ah, AR_PHY_CALMODE, AR_PHY_CALMODE_IQ);
  171. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  172. "starting IQ Mismatch Calibration\n");
  173. break;
  174. case ADC_GAIN_CAL:
  175. REG_WRITE(ah, AR_PHY_CALMODE, AR_PHY_CALMODE_ADC_GAIN);
  176. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  177. "starting ADC Gain Calibration\n");
  178. break;
  179. case ADC_DC_CAL:
  180. REG_WRITE(ah, AR_PHY_CALMODE, AR_PHY_CALMODE_ADC_DC_PER);
  181. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  182. "starting ADC DC Calibration\n");
  183. break;
  184. case ADC_DC_INIT_CAL:
  185. REG_WRITE(ah, AR_PHY_CALMODE, AR_PHY_CALMODE_ADC_DC_INIT);
  186. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  187. "starting Init ADC DC Calibration\n");
  188. break;
  189. }
  190. REG_SET_BIT(ah, AR_PHY_TIMING_CTRL4(0),
  191. AR_PHY_TIMING_CTRL4_DO_CAL);
  192. }
  193. static void ath9k_hw_reset_calibration(struct ath_hal *ah,
  194. struct hal_cal_list *currCal)
  195. {
  196. struct ath_hal_5416 *ahp = AH5416(ah);
  197. int i;
  198. ath9k_hw_setup_calibration(ah, currCal);
  199. currCal->calState = CAL_RUNNING;
  200. for (i = 0; i < AR5416_MAX_CHAINS; i++) {
  201. ahp->ah_Meas0.sign[i] = 0;
  202. ahp->ah_Meas1.sign[i] = 0;
  203. ahp->ah_Meas2.sign[i] = 0;
  204. ahp->ah_Meas3.sign[i] = 0;
  205. }
  206. ahp->ah_CalSamples = 0;
  207. }
  208. static void ath9k_hw_per_calibration(struct ath_hal *ah,
  209. struct ath9k_channel *ichan,
  210. u8 rxchainmask,
  211. struct hal_cal_list *currCal,
  212. bool *isCalDone)
  213. {
  214. struct ath_hal_5416 *ahp = AH5416(ah);
  215. *isCalDone = false;
  216. if (currCal->calState == CAL_RUNNING) {
  217. if (!(REG_READ(ah, AR_PHY_TIMING_CTRL4(0)) &
  218. AR_PHY_TIMING_CTRL4_DO_CAL)) {
  219. currCal->calData->calCollect(ah);
  220. ahp->ah_CalSamples++;
  221. if (ahp->ah_CalSamples >= currCal->calData->calNumSamples) {
  222. int i, numChains = 0;
  223. for (i = 0; i < AR5416_MAX_CHAINS; i++) {
  224. if (rxchainmask & (1 << i))
  225. numChains++;
  226. }
  227. currCal->calData->calPostProc(ah, numChains);
  228. ichan->CalValid |= currCal->calData->calType;
  229. currCal->calState = CAL_DONE;
  230. *isCalDone = true;
  231. } else {
  232. ath9k_hw_setup_calibration(ah, currCal);
  233. }
  234. }
  235. } else if (!(ichan->CalValid & currCal->calData->calType)) {
  236. ath9k_hw_reset_calibration(ah, currCal);
  237. }
  238. }
  239. static bool ath9k_hw_iscal_supported(struct ath_hal *ah,
  240. struct ath9k_channel *chan,
  241. enum hal_cal_types calType)
  242. {
  243. struct ath_hal_5416 *ahp = AH5416(ah);
  244. bool retval = false;
  245. switch (calType & ahp->ah_suppCals) {
  246. case IQ_MISMATCH_CAL:
  247. if (!IS_CHAN_B(chan))
  248. retval = true;
  249. break;
  250. case ADC_GAIN_CAL:
  251. case ADC_DC_CAL:
  252. if (!IS_CHAN_B(chan)
  253. && !(IS_CHAN_2GHZ(chan) && IS_CHAN_HT20(chan)))
  254. retval = true;
  255. break;
  256. }
  257. return retval;
  258. }
  259. static void ath9k_hw_iqcal_collect(struct ath_hal *ah)
  260. {
  261. struct ath_hal_5416 *ahp = AH5416(ah);
  262. int i;
  263. for (i = 0; i < AR5416_MAX_CHAINS; i++) {
  264. ahp->ah_totalPowerMeasI[i] +=
  265. REG_READ(ah, AR_PHY_CAL_MEAS_0(i));
  266. ahp->ah_totalPowerMeasQ[i] +=
  267. REG_READ(ah, AR_PHY_CAL_MEAS_1(i));
  268. ahp->ah_totalIqCorrMeas[i] +=
  269. (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_2(i));
  270. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  271. "%d: Chn %d pmi=0x%08x;pmq=0x%08x;iqcm=0x%08x;\n",
  272. ahp->ah_CalSamples, i, ahp->ah_totalPowerMeasI[i],
  273. ahp->ah_totalPowerMeasQ[i],
  274. ahp->ah_totalIqCorrMeas[i]);
  275. }
  276. }
  277. static void ath9k_hw_adc_gaincal_collect(struct ath_hal *ah)
  278. {
  279. struct ath_hal_5416 *ahp = AH5416(ah);
  280. int i;
  281. for (i = 0; i < AR5416_MAX_CHAINS; i++) {
  282. ahp->ah_totalAdcIOddPhase[i] +=
  283. REG_READ(ah, AR_PHY_CAL_MEAS_0(i));
  284. ahp->ah_totalAdcIEvenPhase[i] +=
  285. REG_READ(ah, AR_PHY_CAL_MEAS_1(i));
  286. ahp->ah_totalAdcQOddPhase[i] +=
  287. REG_READ(ah, AR_PHY_CAL_MEAS_2(i));
  288. ahp->ah_totalAdcQEvenPhase[i] +=
  289. REG_READ(ah, AR_PHY_CAL_MEAS_3(i));
  290. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  291. "%d: Chn %d oddi=0x%08x; eveni=0x%08x; "
  292. "oddq=0x%08x; evenq=0x%08x;\n",
  293. ahp->ah_CalSamples, i,
  294. ahp->ah_totalAdcIOddPhase[i],
  295. ahp->ah_totalAdcIEvenPhase[i],
  296. ahp->ah_totalAdcQOddPhase[i],
  297. ahp->ah_totalAdcQEvenPhase[i]);
  298. }
  299. }
  300. static void ath9k_hw_adc_dccal_collect(struct ath_hal *ah)
  301. {
  302. struct ath_hal_5416 *ahp = AH5416(ah);
  303. int i;
  304. for (i = 0; i < AR5416_MAX_CHAINS; i++) {
  305. ahp->ah_totalAdcDcOffsetIOddPhase[i] +=
  306. (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_0(i));
  307. ahp->ah_totalAdcDcOffsetIEvenPhase[i] +=
  308. (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_1(i));
  309. ahp->ah_totalAdcDcOffsetQOddPhase[i] +=
  310. (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_2(i));
  311. ahp->ah_totalAdcDcOffsetQEvenPhase[i] +=
  312. (int32_t) REG_READ(ah, AR_PHY_CAL_MEAS_3(i));
  313. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  314. "%d: Chn %d oddi=0x%08x; eveni=0x%08x; "
  315. "oddq=0x%08x; evenq=0x%08x;\n",
  316. ahp->ah_CalSamples, i,
  317. ahp->ah_totalAdcDcOffsetIOddPhase[i],
  318. ahp->ah_totalAdcDcOffsetIEvenPhase[i],
  319. ahp->ah_totalAdcDcOffsetQOddPhase[i],
  320. ahp->ah_totalAdcDcOffsetQEvenPhase[i]);
  321. }
  322. }
  323. static void ath9k_hw_iqcalibrate(struct ath_hal *ah, u8 numChains)
  324. {
  325. struct ath_hal_5416 *ahp = AH5416(ah);
  326. u32 powerMeasQ, powerMeasI, iqCorrMeas;
  327. u32 qCoffDenom, iCoffDenom;
  328. int32_t qCoff, iCoff;
  329. int iqCorrNeg, i;
  330. for (i = 0; i < numChains; i++) {
  331. powerMeasI = ahp->ah_totalPowerMeasI[i];
  332. powerMeasQ = ahp->ah_totalPowerMeasQ[i];
  333. iqCorrMeas = ahp->ah_totalIqCorrMeas[i];
  334. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  335. "Starting IQ Cal and Correction for Chain %d\n",
  336. i);
  337. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  338. "Orignal: Chn %diq_corr_meas = 0x%08x\n",
  339. i, ahp->ah_totalIqCorrMeas[i]);
  340. iqCorrNeg = 0;
  341. if (iqCorrMeas > 0x80000000) {
  342. iqCorrMeas = (0xffffffff - iqCorrMeas) + 1;
  343. iqCorrNeg = 1;
  344. }
  345. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  346. "Chn %d pwr_meas_i = 0x%08x\n", i, powerMeasI);
  347. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  348. "Chn %d pwr_meas_q = 0x%08x\n", i, powerMeasQ);
  349. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, "iqCorrNeg is 0x%08x\n",
  350. iqCorrNeg);
  351. iCoffDenom = (powerMeasI / 2 + powerMeasQ / 2) / 128;
  352. qCoffDenom = powerMeasQ / 64;
  353. if (powerMeasQ != 0) {
  354. iCoff = iqCorrMeas / iCoffDenom;
  355. qCoff = powerMeasI / qCoffDenom - 64;
  356. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  357. "Chn %d iCoff = 0x%08x\n", i, iCoff);
  358. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  359. "Chn %d qCoff = 0x%08x\n", i, qCoff);
  360. iCoff = iCoff & 0x3f;
  361. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  362. "New: Chn %d iCoff = 0x%08x\n", i, iCoff);
  363. if (iqCorrNeg == 0x0)
  364. iCoff = 0x40 - iCoff;
  365. if (qCoff > 15)
  366. qCoff = 15;
  367. else if (qCoff <= -16)
  368. qCoff = 16;
  369. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  370. "Chn %d : iCoff = 0x%x qCoff = 0x%x\n",
  371. i, iCoff, qCoff);
  372. REG_RMW_FIELD(ah, AR_PHY_TIMING_CTRL4(i),
  373. AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF,
  374. iCoff);
  375. REG_RMW_FIELD(ah, AR_PHY_TIMING_CTRL4(i),
  376. AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF,
  377. qCoff);
  378. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  379. "IQ Cal and Correction done for Chain %d\n",
  380. i);
  381. }
  382. }
  383. REG_SET_BIT(ah, AR_PHY_TIMING_CTRL4(0),
  384. AR_PHY_TIMING_CTRL4_IQCORR_ENABLE);
  385. }
  386. static void ath9k_hw_adc_gaincal_calibrate(struct ath_hal *ah, u8 numChains)
  387. {
  388. struct ath_hal_5416 *ahp = AH5416(ah);
  389. u32 iOddMeasOffset, iEvenMeasOffset, qOddMeasOffset, qEvenMeasOffset;
  390. u32 qGainMismatch, iGainMismatch, val, i;
  391. for (i = 0; i < numChains; i++) {
  392. iOddMeasOffset = ahp->ah_totalAdcIOddPhase[i];
  393. iEvenMeasOffset = ahp->ah_totalAdcIEvenPhase[i];
  394. qOddMeasOffset = ahp->ah_totalAdcQOddPhase[i];
  395. qEvenMeasOffset = ahp->ah_totalAdcQEvenPhase[i];
  396. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  397. "Starting ADC Gain Cal for Chain %d\n", i);
  398. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  399. "Chn %d pwr_meas_odd_i = 0x%08x\n", i,
  400. iOddMeasOffset);
  401. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  402. "Chn %d pwr_meas_even_i = 0x%08x\n", i,
  403. iEvenMeasOffset);
  404. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  405. "Chn %d pwr_meas_odd_q = 0x%08x\n", i,
  406. qOddMeasOffset);
  407. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  408. "Chn %d pwr_meas_even_q = 0x%08x\n", i,
  409. qEvenMeasOffset);
  410. if (iOddMeasOffset != 0 && qEvenMeasOffset != 0) {
  411. iGainMismatch =
  412. ((iEvenMeasOffset * 32) /
  413. iOddMeasOffset) & 0x3f;
  414. qGainMismatch =
  415. ((qOddMeasOffset * 32) /
  416. qEvenMeasOffset) & 0x3f;
  417. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  418. "Chn %d gain_mismatch_i = 0x%08x\n", i,
  419. iGainMismatch);
  420. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  421. "Chn %d gain_mismatch_q = 0x%08x\n", i,
  422. qGainMismatch);
  423. val = REG_READ(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(i));
  424. val &= 0xfffff000;
  425. val |= (qGainMismatch) | (iGainMismatch << 6);
  426. REG_WRITE(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(i), val);
  427. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  428. "ADC Gain Cal done for Chain %d\n", i);
  429. }
  430. }
  431. REG_WRITE(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(0),
  432. REG_READ(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(0)) |
  433. AR_PHY_NEW_ADC_GAIN_CORR_ENABLE);
  434. }
  435. static void ath9k_hw_adc_dccal_calibrate(struct ath_hal *ah, u8 numChains)
  436. {
  437. struct ath_hal_5416 *ahp = AH5416(ah);
  438. u32 iOddMeasOffset, iEvenMeasOffset, val, i;
  439. int32_t qOddMeasOffset, qEvenMeasOffset, qDcMismatch, iDcMismatch;
  440. const struct hal_percal_data *calData =
  441. ahp->ah_cal_list_curr->calData;
  442. u32 numSamples =
  443. (1 << (calData->calCountMax + 5)) * calData->calNumSamples;
  444. for (i = 0; i < numChains; i++) {
  445. iOddMeasOffset = ahp->ah_totalAdcDcOffsetIOddPhase[i];
  446. iEvenMeasOffset = ahp->ah_totalAdcDcOffsetIEvenPhase[i];
  447. qOddMeasOffset = ahp->ah_totalAdcDcOffsetQOddPhase[i];
  448. qEvenMeasOffset = ahp->ah_totalAdcDcOffsetQEvenPhase[i];
  449. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  450. "Starting ADC DC Offset Cal for Chain %d\n", i);
  451. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  452. "Chn %d pwr_meas_odd_i = %d\n", i,
  453. iOddMeasOffset);
  454. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  455. "Chn %d pwr_meas_even_i = %d\n", i,
  456. iEvenMeasOffset);
  457. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  458. "Chn %d pwr_meas_odd_q = %d\n", i,
  459. qOddMeasOffset);
  460. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  461. "Chn %d pwr_meas_even_q = %d\n", i,
  462. qEvenMeasOffset);
  463. iDcMismatch = (((iEvenMeasOffset - iOddMeasOffset) * 2) /
  464. numSamples) & 0x1ff;
  465. qDcMismatch = (((qOddMeasOffset - qEvenMeasOffset) * 2) /
  466. numSamples) & 0x1ff;
  467. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  468. "Chn %d dc_offset_mismatch_i = 0x%08x\n", i,
  469. iDcMismatch);
  470. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  471. "Chn %d dc_offset_mismatch_q = 0x%08x\n", i,
  472. qDcMismatch);
  473. val = REG_READ(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(i));
  474. val &= 0xc0000fff;
  475. val |= (qDcMismatch << 12) | (iDcMismatch << 21);
  476. REG_WRITE(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(i), val);
  477. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  478. "ADC DC Offset Cal done for Chain %d\n", i);
  479. }
  480. REG_WRITE(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(0),
  481. REG_READ(ah, AR_PHY_NEW_ADC_DC_GAIN_CORR(0)) |
  482. AR_PHY_NEW_ADC_DC_OFFSET_CORR_ENABLE);
  483. }
  484. void ath9k_hw_reset_calvalid(struct ath_hal *ah, struct ath9k_channel *chan,
  485. bool *isCalDone)
  486. {
  487. struct ath_hal_5416 *ahp = AH5416(ah);
  488. struct ath9k_channel *ichan =
  489. ath9k_regd_check_channel(ah, chan);
  490. struct hal_cal_list *currCal = ahp->ah_cal_list_curr;
  491. *isCalDone = true;
  492. if (!AR_SREV_9100(ah) && !AR_SREV_9160_10_OR_LATER(ah))
  493. return;
  494. if (currCal == NULL)
  495. return;
  496. if (ichan == NULL) {
  497. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  498. "invalid channel %u/0x%x; no mapping\n",
  499. chan->channel, chan->channelFlags);
  500. return;
  501. }
  502. if (currCal->calState != CAL_DONE) {
  503. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  504. "Calibration state incorrect, %d\n",
  505. currCal->calState);
  506. return;
  507. }
  508. if (!ath9k_hw_iscal_supported(ah, chan, currCal->calData->calType))
  509. return;
  510. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  511. "Resetting Cal %d state for channel %u/0x%x\n",
  512. currCal->calData->calType, chan->channel,
  513. chan->channelFlags);
  514. ichan->CalValid &= ~currCal->calData->calType;
  515. currCal->calState = CAL_WAITING;
  516. *isCalDone = false;
  517. }
  518. void ath9k_hw_start_nfcal(struct ath_hal *ah)
  519. {
  520. REG_SET_BIT(ah, AR_PHY_AGC_CONTROL,
  521. AR_PHY_AGC_CONTROL_ENABLE_NF);
  522. REG_SET_BIT(ah, AR_PHY_AGC_CONTROL,
  523. AR_PHY_AGC_CONTROL_NO_UPDATE_NF);
  524. REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF);
  525. }
  526. void ath9k_hw_loadnf(struct ath_hal *ah, struct ath9k_channel *chan)
  527. {
  528. struct ath9k_nfcal_hist *h;
  529. int i, j;
  530. int32_t val;
  531. const u32 ar5416_cca_regs[6] = {
  532. AR_PHY_CCA,
  533. AR_PHY_CH1_CCA,
  534. AR_PHY_CH2_CCA,
  535. AR_PHY_EXT_CCA,
  536. AR_PHY_CH1_EXT_CCA,
  537. AR_PHY_CH2_EXT_CCA
  538. };
  539. u8 chainmask;
  540. if (AR_SREV_9280(ah))
  541. chainmask = 0x1B;
  542. else
  543. chainmask = 0x3F;
  544. #ifdef ATH_NF_PER_CHAN
  545. h = chan->nfCalHist;
  546. #else
  547. h = ah->nfCalHist;
  548. #endif
  549. for (i = 0; i < NUM_NF_READINGS; i++) {
  550. if (chainmask & (1 << i)) {
  551. val = REG_READ(ah, ar5416_cca_regs[i]);
  552. val &= 0xFFFFFE00;
  553. val |= (((u32) (h[i].privNF) << 1) & 0x1ff);
  554. REG_WRITE(ah, ar5416_cca_regs[i], val);
  555. }
  556. }
  557. REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL,
  558. AR_PHY_AGC_CONTROL_ENABLE_NF);
  559. REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL,
  560. AR_PHY_AGC_CONTROL_NO_UPDATE_NF);
  561. REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_NF);
  562. for (j = 0; j < 1000; j++) {
  563. if ((REG_READ(ah, AR_PHY_AGC_CONTROL) &
  564. AR_PHY_AGC_CONTROL_NF) == 0)
  565. break;
  566. udelay(10);
  567. }
  568. for (i = 0; i < NUM_NF_READINGS; i++) {
  569. if (chainmask & (1 << i)) {
  570. val = REG_READ(ah, ar5416_cca_regs[i]);
  571. val &= 0xFFFFFE00;
  572. val |= (((u32) (-50) << 1) & 0x1ff);
  573. REG_WRITE(ah, ar5416_cca_regs[i], val);
  574. }
  575. }
  576. }
  577. int16_t ath9k_hw_getnf(struct ath_hal *ah,
  578. struct ath9k_channel *chan)
  579. {
  580. int16_t nf, nfThresh;
  581. int16_t nfarray[NUM_NF_READINGS] = { 0 };
  582. struct ath9k_nfcal_hist *h;
  583. struct ieee80211_channel *c = chan->chan;
  584. u8 chainmask;
  585. if (AR_SREV_9280(ah))
  586. chainmask = 0x1B;
  587. else
  588. chainmask = 0x3F;
  589. chan->channelFlags &= (~CHANNEL_CW_INT);
  590. if (REG_READ(ah, AR_PHY_AGC_CONTROL) & AR_PHY_AGC_CONTROL_NF) {
  591. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  592. "NF did not complete in calibration window\n");
  593. nf = 0;
  594. chan->rawNoiseFloor = nf;
  595. return chan->rawNoiseFloor;
  596. } else {
  597. ath9k_hw_do_getnf(ah, nfarray);
  598. nf = nfarray[0];
  599. if (getNoiseFloorThresh(ah, c->band, &nfThresh)
  600. && nf > nfThresh) {
  601. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  602. "noise floor failed detected; "
  603. "detected %d, threshold %d\n",
  604. nf, nfThresh);
  605. chan->channelFlags |= CHANNEL_CW_INT;
  606. }
  607. }
  608. #ifdef ATH_NF_PER_CHAN
  609. h = chan->nfCalHist;
  610. #else
  611. h = ah->nfCalHist;
  612. #endif
  613. ath9k_hw_update_nfcal_hist_buffer(h, nfarray);
  614. chan->rawNoiseFloor = h[0].privNF;
  615. return chan->rawNoiseFloor;
  616. }
  617. void ath9k_init_nfcal_hist_buffer(struct ath_hal *ah)
  618. {
  619. int i, j;
  620. for (i = 0; i < NUM_NF_READINGS; i++) {
  621. ah->nfCalHist[i].currIndex = 0;
  622. ah->nfCalHist[i].privNF = AR_PHY_CCA_MAX_GOOD_VALUE;
  623. ah->nfCalHist[i].invalidNFcount =
  624. AR_PHY_CCA_FILTERWINDOW_LENGTH;
  625. for (j = 0; j < ATH9K_NF_CAL_HIST_MAX; j++) {
  626. ah->nfCalHist[i].nfCalBuffer[j] =
  627. AR_PHY_CCA_MAX_GOOD_VALUE;
  628. }
  629. }
  630. return;
  631. }
  632. s16 ath9k_hw_getchan_noise(struct ath_hal *ah, struct ath9k_channel *chan)
  633. {
  634. struct ath9k_channel *ichan;
  635. s16 nf;
  636. ichan = ath9k_regd_check_channel(ah, chan);
  637. if (ichan == NULL) {
  638. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  639. "invalid channel %u/0x%x; no mapping\n",
  640. chan->channel, chan->channelFlags);
  641. return ATH_DEFAULT_NOISE_FLOOR;
  642. }
  643. if (ichan->rawNoiseFloor == 0) {
  644. enum wireless_mode mode = ath9k_hw_chan2wmode(ah, chan);
  645. nf = NOISE_FLOOR[mode];
  646. } else
  647. nf = ichan->rawNoiseFloor;
  648. if (!ath9k_hw_nf_in_range(ah, nf))
  649. nf = ATH_DEFAULT_NOISE_FLOOR;
  650. return nf;
  651. }
  652. bool ath9k_hw_calibrate(struct ath_hal *ah, struct ath9k_channel *chan,
  653. u8 rxchainmask, bool longcal,
  654. bool *isCalDone)
  655. {
  656. struct ath_hal_5416 *ahp = AH5416(ah);
  657. struct hal_cal_list *currCal = ahp->ah_cal_list_curr;
  658. struct ath9k_channel *ichan = ath9k_regd_check_channel(ah, chan);
  659. *isCalDone = true;
  660. if (ichan == NULL) {
  661. DPRINTF(ah->ah_sc, ATH_DBG_CHANNEL,
  662. "invalid channel %u/0x%x; no mapping\n",
  663. chan->channel, chan->channelFlags);
  664. return false;
  665. }
  666. if (currCal &&
  667. (currCal->calState == CAL_RUNNING ||
  668. currCal->calState == CAL_WAITING)) {
  669. ath9k_hw_per_calibration(ah, ichan, rxchainmask, currCal,
  670. isCalDone);
  671. if (*isCalDone) {
  672. ahp->ah_cal_list_curr = currCal = currCal->calNext;
  673. if (currCal->calState == CAL_WAITING) {
  674. *isCalDone = false;
  675. ath9k_hw_reset_calibration(ah, currCal);
  676. }
  677. }
  678. }
  679. if (longcal) {
  680. ath9k_hw_getnf(ah, ichan);
  681. ath9k_hw_loadnf(ah, ah->ah_curchan);
  682. ath9k_hw_start_nfcal(ah);
  683. if ((ichan->channelFlags & CHANNEL_CW_INT) != 0) {
  684. chan->channelFlags |= CHANNEL_CW_INT;
  685. ichan->channelFlags &= ~CHANNEL_CW_INT;
  686. }
  687. }
  688. return true;
  689. }
  690. static inline void ath9k_hw_9285_pa_cal(struct ath_hal *ah)
  691. {
  692. u32 regVal;
  693. int i, offset, offs_6_1, offs_0;
  694. u32 ccomp_org, reg_field;
  695. u32 regList[][2] = {
  696. { 0x786c, 0 },
  697. { 0x7854, 0 },
  698. { 0x7820, 0 },
  699. { 0x7824, 0 },
  700. { 0x7868, 0 },
  701. { 0x783c, 0 },
  702. { 0x7838, 0 },
  703. };
  704. if (AR_SREV_9285_11(ah)) {
  705. REG_WRITE(ah, AR9285_AN_TOP4, (AR9285_AN_TOP4_DEFAULT | 0x14));
  706. udelay(10);
  707. }
  708. for (i = 0; i < ARRAY_SIZE(regList); i++)
  709. regList[i][1] = REG_READ(ah, regList[i][0]);
  710. regVal = REG_READ(ah, 0x7834);
  711. regVal &= (~(0x1));
  712. REG_WRITE(ah, 0x7834, regVal);
  713. regVal = REG_READ(ah, 0x9808);
  714. regVal |= (0x1 << 27);
  715. REG_WRITE(ah, 0x9808, regVal);
  716. REG_RMW_FIELD(ah, AR9285_AN_TOP3, AR9285_AN_TOP3_PWDDAC, 1);
  717. REG_RMW_FIELD(ah, AR9285_AN_RXTXBB1, AR9285_AN_RXTXBB1_PDRXTXBB1, 1);
  718. REG_RMW_FIELD(ah, AR9285_AN_RXTXBB1, AR9285_AN_RXTXBB1_PDV2I, 1);
  719. REG_RMW_FIELD(ah, AR9285_AN_RXTXBB1, AR9285_AN_RXTXBB1_PDDACIF, 1);
  720. REG_RMW_FIELD(ah, AR9285_AN_RF2G2, AR9285_AN_RF2G2_OFFCAL, 0);
  721. REG_RMW_FIELD(ah, AR9285_AN_RF2G7, AR9285_AN_RF2G7_PWDDB, 0);
  722. REG_RMW_FIELD(ah, AR9285_AN_RF2G1, AR9285_AN_RF2G1_ENPACAL, 0);
  723. REG_RMW_FIELD(ah, AR9285_AN_RF2G1, AR9285_AN_RF2G1_PDPADRV1, 1);
  724. REG_RMW_FIELD(ah, AR9285_AN_RF2G1, AR9285_AN_RF2G1_PDPADRV2, 0);
  725. REG_RMW_FIELD(ah, AR9285_AN_RF2G1, AR9285_AN_RF2G1_PDPAOUT, 0);
  726. REG_RMW_FIELD(ah, AR9285_AN_RF2G8, AR9285_AN_RF2G8_PADRVGN2TAB0, 7);
  727. REG_RMW_FIELD(ah, AR9285_AN_RF2G7, AR9285_AN_RF2G7_PADRVGN2TAB0, 0);
  728. ccomp_org = MS(REG_READ(ah, AR9285_AN_RF2G6), AR9285_AN_RF2G6_CCOMP);
  729. REG_RMW_FIELD(ah, AR9285_AN_RF2G6, AR9285_AN_RF2G6_CCOMP, 7);
  730. REG_WRITE(ah, AR9285_AN_TOP2, 0xca0358a0);
  731. udelay(30);
  732. REG_RMW_FIELD(ah, AR9285_AN_RF2G6, AR9285_AN_RF2G6_OFFS, 0);
  733. REG_RMW_FIELD(ah, AR9285_AN_RF2G3, AR9285_AN_RF2G3_PDVCCOMP, 0);
  734. for (i = 6; i > 0; i--) {
  735. regVal = REG_READ(ah, 0x7834);
  736. regVal |= (1 << (19 + i));
  737. REG_WRITE(ah, 0x7834, regVal);
  738. udelay(1);
  739. regVal = REG_READ(ah, 0x7834);
  740. regVal &= (~(0x1 << (19 + i)));
  741. reg_field = MS(REG_READ(ah, 0x7840), AR9285_AN_RXTXBB1_SPARE9);
  742. regVal |= (reg_field << (19 + i));
  743. REG_WRITE(ah, 0x7834, regVal);
  744. }
  745. REG_RMW_FIELD(ah, AR9285_AN_RF2G3, AR9285_AN_RF2G3_PDVCCOMP, 1);
  746. udelay(1);
  747. reg_field = MS(REG_READ(ah, AR9285_AN_RF2G9), AR9285_AN_RXTXBB1_SPARE9);
  748. REG_RMW_FIELD(ah, AR9285_AN_RF2G3, AR9285_AN_RF2G3_PDVCCOMP, reg_field);
  749. offs_6_1 = MS(REG_READ(ah, AR9285_AN_RF2G6), AR9285_AN_RF2G6_OFFS);
  750. offs_0 = MS(REG_READ(ah, AR9285_AN_RF2G3), AR9285_AN_RF2G3_PDVCCOMP);
  751. offset = (offs_6_1<<1) | offs_0;
  752. offset = offset - 0;
  753. offs_6_1 = offset>>1;
  754. offs_0 = offset & 1;
  755. REG_RMW_FIELD(ah, AR9285_AN_RF2G6, AR9285_AN_RF2G6_OFFS, offs_6_1);
  756. REG_RMW_FIELD(ah, AR9285_AN_RF2G3, AR9285_AN_RF2G3_PDVCCOMP, offs_0);
  757. regVal = REG_READ(ah, 0x7834);
  758. regVal |= 0x1;
  759. REG_WRITE(ah, 0x7834, regVal);
  760. regVal = REG_READ(ah, 0x9808);
  761. regVal &= (~(0x1 << 27));
  762. REG_WRITE(ah, 0x9808, regVal);
  763. for (i = 0; i < ARRAY_SIZE(regList); i++)
  764. REG_WRITE(ah, regList[i][0], regList[i][1]);
  765. REG_RMW_FIELD(ah, AR9285_AN_RF2G6, AR9285_AN_RF2G6_CCOMP, ccomp_org);
  766. if (AR_SREV_9285_11(ah))
  767. REG_WRITE(ah, AR9285_AN_TOP4, AR9285_AN_TOP4_DEFAULT);
  768. }
  769. bool ath9k_hw_init_cal(struct ath_hal *ah,
  770. struct ath9k_channel *chan)
  771. {
  772. struct ath_hal_5416 *ahp = AH5416(ah);
  773. struct ath9k_channel *ichan = ath9k_regd_check_channel(ah, chan);
  774. REG_WRITE(ah, AR_PHY_AGC_CONTROL,
  775. REG_READ(ah, AR_PHY_AGC_CONTROL) |
  776. AR_PHY_AGC_CONTROL_CAL);
  777. if (!ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL, 0)) {
  778. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  779. "offset calibration failed to complete in 1ms; "
  780. "noisy environment?\n");
  781. return false;
  782. }
  783. if (AR_SREV_9285(ah) && AR_SREV_9285_11_OR_LATER(ah))
  784. ath9k_hw_9285_pa_cal(ah);
  785. REG_WRITE(ah, AR_PHY_AGC_CONTROL,
  786. REG_READ(ah, AR_PHY_AGC_CONTROL) |
  787. AR_PHY_AGC_CONTROL_NF);
  788. ahp->ah_cal_list = ahp->ah_cal_list_last = ahp->ah_cal_list_curr = NULL;
  789. if (AR_SREV_9100(ah) || AR_SREV_9160_10_OR_LATER(ah)) {
  790. if (ath9k_hw_iscal_supported(ah, chan, ADC_GAIN_CAL)) {
  791. INIT_CAL(&ahp->ah_adcGainCalData);
  792. INSERT_CAL(ahp, &ahp->ah_adcGainCalData);
  793. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  794. "enabling ADC Gain Calibration.\n");
  795. }
  796. if (ath9k_hw_iscal_supported(ah, chan, ADC_DC_CAL)) {
  797. INIT_CAL(&ahp->ah_adcDcCalData);
  798. INSERT_CAL(ahp, &ahp->ah_adcDcCalData);
  799. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  800. "enabling ADC DC Calibration.\n");
  801. }
  802. if (ath9k_hw_iscal_supported(ah, chan, IQ_MISMATCH_CAL)) {
  803. INIT_CAL(&ahp->ah_iqCalData);
  804. INSERT_CAL(ahp, &ahp->ah_iqCalData);
  805. DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE,
  806. "enabling IQ Calibration.\n");
  807. }
  808. ahp->ah_cal_list_curr = ahp->ah_cal_list;
  809. if (ahp->ah_cal_list_curr)
  810. ath9k_hw_reset_calibration(ah, ahp->ah_cal_list_curr);
  811. }
  812. ichan->CalValid = 0;
  813. return true;
  814. }
  815. const struct hal_percal_data iq_cal_multi_sample = {
  816. IQ_MISMATCH_CAL,
  817. MAX_CAL_SAMPLES,
  818. PER_MIN_LOG_COUNT,
  819. ath9k_hw_iqcal_collect,
  820. ath9k_hw_iqcalibrate
  821. };
  822. const struct hal_percal_data iq_cal_single_sample = {
  823. IQ_MISMATCH_CAL,
  824. MIN_CAL_SAMPLES,
  825. PER_MAX_LOG_COUNT,
  826. ath9k_hw_iqcal_collect,
  827. ath9k_hw_iqcalibrate
  828. };
  829. const struct hal_percal_data adc_gain_cal_multi_sample = {
  830. ADC_GAIN_CAL,
  831. MAX_CAL_SAMPLES,
  832. PER_MIN_LOG_COUNT,
  833. ath9k_hw_adc_gaincal_collect,
  834. ath9k_hw_adc_gaincal_calibrate
  835. };
  836. const struct hal_percal_data adc_gain_cal_single_sample = {
  837. ADC_GAIN_CAL,
  838. MIN_CAL_SAMPLES,
  839. PER_MAX_LOG_COUNT,
  840. ath9k_hw_adc_gaincal_collect,
  841. ath9k_hw_adc_gaincal_calibrate
  842. };
  843. const struct hal_percal_data adc_dc_cal_multi_sample = {
  844. ADC_DC_CAL,
  845. MAX_CAL_SAMPLES,
  846. PER_MIN_LOG_COUNT,
  847. ath9k_hw_adc_dccal_collect,
  848. ath9k_hw_adc_dccal_calibrate
  849. };
  850. const struct hal_percal_data adc_dc_cal_single_sample = {
  851. ADC_DC_CAL,
  852. MIN_CAL_SAMPLES,
  853. PER_MAX_LOG_COUNT,
  854. ath9k_hw_adc_dccal_collect,
  855. ath9k_hw_adc_dccal_calibrate
  856. };
  857. const struct hal_percal_data adc_init_dc_cal = {
  858. ADC_DC_INIT_CAL,
  859. MIN_CAL_SAMPLES,
  860. INIT_LOG_COUNT,
  861. ath9k_hw_adc_dccal_collect,
  862. ath9k_hw_adc_dccal_calibrate
  863. };