halrf.c 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2017 Realtek Corporation.
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of version 2 of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * The full GNU General Public License is included in this distribution in the
  15. * file called LICENSE.
  16. *
  17. * Contact Information:
  18. * wlanfae <wlanfae@realtek.com>
  19. * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
  20. * Hsinchu 300, Taiwan.
  21. *
  22. * Larry Finger <Larry.Finger@lwfinger.net>
  23. *
  24. *****************************************************************************/
  25. /* ************************************************************
  26. * include files
  27. * ************************************************************
  28. */
  29. #include "mp_precomp.h"
  30. #include "phydm_precomp.h"
  31. #if (RTL8822B_SUPPORT == 1 || RTL8821C_SUPPORT == 1 ||\
  32. RTL8195B_SUPPORT == 1 || RTL8198F_SUPPORT == 1)
  33. void _iqk_page_switch(void *dm_void)
  34. {
  35. struct dm_struct *dm = (struct dm_struct *)dm_void;
  36. if (dm->support_ic_type == ODM_RTL8821C)
  37. odm_write_4byte(dm, 0x1b00, 0xf8000008);
  38. else
  39. odm_write_4byte(dm, 0x1b00, 0xf800000a);
  40. }
  41. u32 halrf_psd_log2base(u32 val)
  42. {
  43. u8 j;
  44. u32 tmp, tmp2, val_integerd_b = 0, tindex, shiftcount = 0;
  45. u32 result, val_fractiond_b = 0;
  46. u32 table_fraction[21] = {
  47. 0, 432, 332, 274, 232, 200, 174, 151, 132, 115,
  48. 100, 86, 74, 62, 51, 42, 32, 23, 15, 7, 0};
  49. if (val == 0)
  50. return 0;
  51. tmp = val;
  52. while (1) {
  53. if (tmp == 1)
  54. break;
  55. tmp = (tmp >> 1);
  56. shiftcount++;
  57. }
  58. val_integerd_b = shiftcount + 1;
  59. tmp2 = 1;
  60. for (j = 1; j <= val_integerd_b; j++)
  61. tmp2 = tmp2 * 2;
  62. tmp = (val * 100) / tmp2;
  63. tindex = tmp / 5;
  64. if (tindex > 20)
  65. tindex = 20;
  66. val_fractiond_b = table_fraction[tindex];
  67. result = val_integerd_b * 100 - val_fractiond_b;
  68. return result;
  69. }
  70. void phydm_get_iqk_cfir(void *dm_void, u8 idx, u8 path, boolean debug)
  71. {
  72. struct dm_struct *dm = (struct dm_struct *)dm_void;
  73. struct dm_iqk_info *iqk_info = &dm->IQK_info;
  74. u8 i, ch;
  75. u32 tmp;
  76. u32 bit_mask_20_16 = BIT(20) | BIT(19) | BIT(18) | BIT(17) | BIT(16);
  77. if (debug)
  78. ch = 2;
  79. else
  80. ch = 0;
  81. odm_set_bb_reg(dm, R_0x1b00, MASKDWORD, 0xf8000008 | path << 1);
  82. if (idx == 0)
  83. odm_set_bb_reg(dm, R_0x1b0c, BIT(13) | BIT(12), 0x3);
  84. else
  85. odm_set_bb_reg(dm, R_0x1b0c, BIT(13) | BIT(12), 0x1);
  86. odm_set_bb_reg(dm, R_0x1bd4, bit_mask_20_16, 0x10);
  87. for (i = 0; i < 8; i++) {
  88. odm_set_bb_reg(dm, R_0x1bd8, MASKDWORD, 0xe0000001 + (i * 4));
  89. tmp = odm_get_bb_reg(dm, R_0x1bfc, MASKDWORD);
  90. iqk_info->iqk_cfir_real[ch][path][idx][i] =
  91. (tmp & 0x0fff0000) >> 16;
  92. iqk_info->iqk_cfir_imag[ch][path][idx][i] = tmp & 0xfff;
  93. }
  94. odm_set_bb_reg(dm, R_0x1bd8, MASKDWORD, 0x0);
  95. odm_set_bb_reg(dm, R_0x1b0c, BIT(13) | BIT(12), 0x0);
  96. }
  97. void halrf_iqk_xym_enable(struct dm_struct *dm, u8 xym_enable)
  98. {
  99. struct dm_iqk_info *iqk_info = &dm->IQK_info;
  100. if (xym_enable == 0)
  101. iqk_info->xym_read = false;
  102. else
  103. iqk_info->xym_read = true;
  104. RF_DBG(dm, DBG_RF_IQK, "[IQK]%-20s %s\n", "xym_read = ",
  105. (iqk_info->xym_read ? "true" : "false"));
  106. }
  107. /*xym_type => 0: rx_sym; 1: tx_xym; 2:gs1_xym; 3:gs2_sym; 4: rxk1_xym*/
  108. void halrf_iqk_xym_read(void *dm_void, u8 path, u8 xym_type)
  109. {
  110. struct dm_struct *dm = (struct dm_struct *)dm_void;
  111. struct dm_iqk_info *iqk_info = &dm->IQK_info;
  112. u8 i, start, num;
  113. u32 tmp1, tmp2;
  114. if (!iqk_info->xym_read)
  115. return;
  116. if (*dm->band_width == 0) {
  117. start = 3;
  118. num = 4;
  119. } else if (*dm->band_width == 1) {
  120. start = 2;
  121. num = 6;
  122. } else {
  123. start = 0;
  124. num = 10;
  125. }
  126. odm_write_4byte(dm, 0x1b00, 0xf8000008);
  127. tmp1 = odm_read_4byte(dm, 0x1b1c);
  128. odm_write_4byte(dm, 0x1b1c, 0xa2193c32);
  129. odm_write_4byte(dm, 0x1b00, 0xf800000a);
  130. tmp2 = odm_read_4byte(dm, 0x1b1c);
  131. odm_write_4byte(dm, 0x1b1c, 0xa2193c32);
  132. for (path = 0; path < 2; path++) {
  133. odm_write_4byte(dm, 0x1b00, 0xf8000008 | path << 1);
  134. switch (xym_type) {
  135. case 0:
  136. for (i = 0; i < num; i++) {
  137. odm_write_4byte(dm, 0x1b14, 0xe6 + start + i);
  138. odm_write_4byte(dm, 0x1b14, 0x0);
  139. iqk_info->rx_xym[path][i] =
  140. odm_read_4byte(dm, 0x1b38);
  141. }
  142. break;
  143. case 1:
  144. for (i = 0; i < num; i++) {
  145. odm_write_4byte(dm, 0x1b14, 0xe6 + start + i);
  146. odm_write_4byte(dm, 0x1b14, 0x0);
  147. iqk_info->tx_xym[path][i] =
  148. odm_read_4byte(dm, 0x1b38);
  149. }
  150. break;
  151. case 2:
  152. for (i = 0; i < 6; i++) {
  153. odm_write_4byte(dm, 0x1b14, 0xe0 + i);
  154. odm_write_4byte(dm, 0x1b14, 0x0);
  155. iqk_info->gs1_xym[path][i] =
  156. odm_read_4byte(dm, 0x1b38);
  157. }
  158. break;
  159. case 3:
  160. for (i = 0; i < 6; i++) {
  161. odm_write_4byte(dm, 0x1b14, 0xe0 + i);
  162. odm_write_4byte(dm, 0x1b14, 0x0);
  163. iqk_info->gs2_xym[path][i] =
  164. odm_read_4byte(dm, 0x1b38);
  165. }
  166. break;
  167. case 4:
  168. for (i = 0; i < 6; i++) {
  169. odm_write_4byte(dm, 0x1b14, 0xe0 + i);
  170. odm_write_4byte(dm, 0x1b14, 0x0);
  171. iqk_info->rxk1_xym[path][i] =
  172. odm_read_4byte(dm, 0x1b38);
  173. }
  174. break;
  175. }
  176. odm_write_4byte(dm, 0x1b38, 0x20000000);
  177. odm_write_4byte(dm, 0x1b00, 0xf8000008);
  178. odm_write_4byte(dm, 0x1b1c, tmp1);
  179. odm_write_4byte(dm, 0x1b00, 0xf800000a);
  180. odm_write_4byte(dm, 0x1b1c, tmp2);
  181. _iqk_page_switch(dm);
  182. }
  183. }
  184. /*xym_type => 0: rx_sym; 1: tx_xym; 2:gs1_xym; 3:gs2_sym; 4: rxk1_xym*/
  185. void halrf_iqk_xym_show(struct dm_struct *dm, u8 xym_type)
  186. {
  187. u8 num, path, path_num, i;
  188. struct dm_iqk_info *iqk_info = &dm->IQK_info;
  189. if (dm->rf_type == RF_1T1R)
  190. path_num = 0x1;
  191. else if (dm->rf_type == RF_2T2R)
  192. path_num = 0x2;
  193. else
  194. path_num = 0x4;
  195. if (*dm->band_width == CHANNEL_WIDTH_20)
  196. num = 4;
  197. else if (*dm->band_width == CHANNEL_WIDTH_40)
  198. num = 6;
  199. else
  200. num = 10;
  201. for (path = 0; path < path_num; path++) {
  202. switch (xym_type) {
  203. case 0:
  204. for (i = 0; i < num; i++)
  205. RF_DBG(dm, DBG_RF_IQK,
  206. "[IQK]%-20s %-2d: 0x%x\n",
  207. (path == 0) ? "PATH A RX-XYM " :
  208. "PATH B RX-XYM", i,
  209. iqk_info->rx_xym[path][i]);
  210. break;
  211. case 1:
  212. for (i = 0; i < num; i++)
  213. RF_DBG(dm, DBG_RF_IQK,
  214. "[IQK]%-20s %-2d: 0x%x\n",
  215. (path == 0) ? "PATH A TX-XYM " :
  216. "PATH B TX-XYM", i,
  217. iqk_info->tx_xym[path][i]);
  218. break;
  219. case 2:
  220. for (i = 0; i < 6; i++)
  221. RF_DBG(dm, DBG_RF_IQK,
  222. "[IQK]%-20s %-2d: 0x%x\n",
  223. (path == 0) ? "PATH A GS1-XYM " :
  224. "PATH B GS1-XYM", i,
  225. iqk_info->gs1_xym[path][i]);
  226. break;
  227. case 3:
  228. for (i = 0; i < 6; i++)
  229. RF_DBG(dm, DBG_RF_IQK,
  230. "[IQK]%-20s %-2d: 0x%x\n",
  231. (path == 0) ? "PATH A GS2-XYM " :
  232. "PATH B GS2-XYM", i,
  233. iqk_info->gs2_xym[path][i]);
  234. break;
  235. case 4:
  236. for (i = 0; i < 6; i++)
  237. RF_DBG(dm, DBG_RF_IQK,
  238. "[IQK]%-20s %-2d: 0x%x\n",
  239. (path == 0) ? "PATH A RXK1-XYM " :
  240. "PATH B RXK1-XYM", i,
  241. iqk_info->rxk1_xym[path][i]);
  242. break;
  243. }
  244. }
  245. }
  246. void halrf_iqk_xym_dump(void *dm_void)
  247. {
  248. u32 tmp1, tmp2;
  249. struct dm_struct *dm = (struct dm_struct *)dm_void;
  250. odm_write_4byte(dm, 0x1b00, 0xf8000008);
  251. tmp1 = odm_read_4byte(dm, 0x1b1c);
  252. odm_write_4byte(dm, 0x1b00, 0xf800000a);
  253. tmp2 = odm_read_4byte(dm, 0x1b1c);
  254. #if 0
  255. /*halrf_iqk_xym_read(dm, xym_type);*/
  256. #endif
  257. odm_write_4byte(dm, 0x1b00, 0xf8000008);
  258. odm_write_4byte(dm, 0x1b1c, tmp1);
  259. odm_write_4byte(dm, 0x1b00, 0xf800000a);
  260. odm_write_4byte(dm, 0x1b1c, tmp2);
  261. _iqk_page_switch(dm);
  262. }
  263. void halrf_iqk_info_dump(void *dm_void, u32 *_used, char *output, u32 *_out_len)
  264. {
  265. struct dm_struct *dm = (struct dm_struct *)dm_void;
  266. u32 used = *_used;
  267. u32 out_len = *_out_len;
  268. u8 rf_path, j, reload_iqk = 0;
  269. u32 tmp;
  270. /*two channel, PATH, TX/RX, 0:pass 1 :fail*/
  271. boolean iqk_result[2][NUM][2];
  272. struct dm_iqk_info *iqk_info = &dm->IQK_info;
  273. if (!(dm->support_ic_type & (ODM_RTL8822B | ODM_RTL8821C)))
  274. return;
  275. /* IQK INFO */
  276. PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s\n",
  277. "% IQK Info %");
  278. PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s\n",
  279. (dm->fw_offload_ability & PHYDM_RF_IQK_OFFLOAD) ? "FW-IQK" :
  280. "Driver-IQK");
  281. reload_iqk = (u8)odm_get_bb_reg(dm, R_0x1bf0, BIT(16));
  282. PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
  283. "reload", (reload_iqk) ? "True" : "False");
  284. PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
  285. "rfk_forbidden", (iqk_info->rfk_forbidden) ? "True" : "False");
  286. #if (RTL8814A_SUPPORT == 1 || RTL8822B_SUPPORT == 1 || \
  287. RTL8821C_SUPPORT == 1 || RTL8195B_SUPPORT == 1)
  288. PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
  289. "segment_iqk", (iqk_info->segment_iqk) ? "True" : "False");
  290. #endif
  291. PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s:%d %d\n",
  292. "iqk count / fail count", dm->n_iqk_cnt, dm->n_iqk_fail_cnt);
  293. PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %d\n",
  294. "channel", *dm->channel);
  295. if (*dm->band_width == CHANNEL_WIDTH_20)
  296. PDM_SNPF(out_len, used, output + used, out_len - used,
  297. "%-20s: %s\n", "bandwidth", "BW_20");
  298. else if (*dm->band_width == CHANNEL_WIDTH_40)
  299. PDM_SNPF(out_len, used, output + used, out_len - used,
  300. "%-20s: %s\n", "bandwidth", "BW_40");
  301. else if (*dm->band_width == CHANNEL_WIDTH_80)
  302. PDM_SNPF(out_len, used, output + used, out_len - used,
  303. "%-20s: %s\n", "bandwidth", "BW_80");
  304. else if (*dm->band_width == CHANNEL_WIDTH_160)
  305. PDM_SNPF(out_len, used, output + used, out_len - used,
  306. "%-20s: %s\n", "bandwidth", "BW_160");
  307. else
  308. PDM_SNPF(out_len, used, output + used, out_len - used,
  309. "%-20s: %s\n", "bandwidth", "BW_UNKNOWN");
  310. PDM_SNPF(out_len, used, output + used, out_len - used,
  311. "%-20s: %llu %s\n", "progressing_time",
  312. dm->rf_calibrate_info.iqk_total_progressing_time, "(ms)");
  313. tmp = odm_read_4byte(dm, 0x1bf0);
  314. for (rf_path = RF_PATH_A; rf_path <= RF_PATH_B; rf_path++)
  315. for (j = 0; j < 2; j++)
  316. iqk_result[0][rf_path][j] = (boolean)
  317. (tmp & (BIT(rf_path + (j * 4)) >> (rf_path + (j * 4))));
  318. PDM_SNPF(out_len, used, output + used, out_len - used,
  319. "%-20s: 0x%08x\n", "Reg0x1bf0", tmp);
  320. PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
  321. "PATH_A-Tx result",
  322. (iqk_result[0][RF_PATH_A][0]) ? "Fail" : "Pass");
  323. PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
  324. "PATH_A-Rx result",
  325. (iqk_result[0][RF_PATH_A][1]) ? "Fail" : "Pass");
  326. #if (RTL8822B_SUPPORT == 1)
  327. PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
  328. "PATH_B-Tx result",
  329. (iqk_result[0][RF_PATH_B][0]) ? "Fail" : "Pass");
  330. PDM_SNPF(out_len, used, output + used, out_len - used, "%-20s: %s\n",
  331. "PATH_B-Rx result",
  332. (iqk_result[0][RF_PATH_B][1]) ? "Fail" : "Pass");
  333. #endif
  334. *_used = used;
  335. *_out_len = out_len;
  336. }
  337. void halrf_get_fw_version(void *dm_void)
  338. {
  339. struct dm_struct *dm = (struct dm_struct *)dm_void;
  340. struct _hal_rf_ *rf = &dm->rf_table;
  341. rf->fw_ver = (dm->fw_version << 16) | dm->fw_sub_version;
  342. }
  343. void halrf_iqk_dbg(void *dm_void)
  344. {
  345. struct dm_struct *dm = (struct dm_struct *)dm_void;
  346. u8 rf_path, j;
  347. u32 tmp;
  348. /*two channel, PATH, TX/RX, 0:pass 1 :fail*/
  349. boolean iqk_result[2][NUM][2];
  350. struct dm_iqk_info *iqk_info = &dm->IQK_info;
  351. struct _hal_rf_ *rf = &dm->rf_table;
  352. /* IQK INFO */
  353. RF_DBG(dm, DBG_RF_IQK, "%-20s\n", "====== IQK Info ======");
  354. RF_DBG(dm, DBG_RF_IQK, "%-20s\n",
  355. (dm->fw_offload_ability & PHYDM_RF_IQK_OFFLOAD) ? "FW-IQK" :
  356. "Driver-IQK");
  357. if (dm->fw_offload_ability & PHYDM_RF_IQK_OFFLOAD) {
  358. halrf_get_fw_version(dm);
  359. RF_DBG(dm, DBG_RF_IQK, "%-20s: 0x%x\n", "FW_VER", rf->fw_ver);
  360. } else {
  361. RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "IQK_VER", HALRF_IQK_VER);
  362. }
  363. RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "reload",
  364. (iqk_info->is_reload) ? "True" : "False");
  365. RF_DBG(dm, DBG_RF_IQK, "%-20s: %d %d\n", "iqk count / fail count",
  366. dm->n_iqk_cnt, dm->n_iqk_fail_cnt);
  367. RF_DBG(dm, DBG_RF_IQK, "%-20s: %d\n", "channel", *dm->channel);
  368. if (*dm->band_width == CHANNEL_WIDTH_20)
  369. RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "bandwidth", "BW_20");
  370. else if (*dm->band_width == CHANNEL_WIDTH_40)
  371. RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "bandwidth", "BW_40");
  372. else if (*dm->band_width == CHANNEL_WIDTH_80)
  373. RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "bandwidth", "BW_80");
  374. else if (*dm->band_width == CHANNEL_WIDTH_160)
  375. RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "bandwidth", "BW_160");
  376. else
  377. RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "bandwidth",
  378. "BW_UNKNOWN");
  379. #if 0
  380. /*
  381. * RF_DBG(dm, DBG_RF_IQK, "%-20s: %llu %s\n",
  382. * "progressing_time",
  383. * dm->rf_calibrate_info.iqk_total_progressing_time, "(ms)");
  384. */
  385. #endif
  386. RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "rfk_forbidden",
  387. (iqk_info->rfk_forbidden) ? "True" : "False");
  388. #if (RTL8814A_SUPPORT == 1 || RTL8822B_SUPPORT == 1 || \
  389. RTL8821C_SUPPORT == 1 || RTL8195B_SUPPORT == 1)
  390. RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "segment_iqk",
  391. (iqk_info->segment_iqk) ? "True" : "False");
  392. #endif
  393. RF_DBG(dm, DBG_RF_IQK, "%-20s: %llu %s\n", "progressing_time",
  394. dm->rf_calibrate_info.iqk_progressing_time, "(ms)");
  395. tmp = odm_read_4byte(dm, 0x1bf0);
  396. for (rf_path = RF_PATH_A; rf_path <= RF_PATH_B; rf_path++)
  397. for (j = 0; j < 2; j++)
  398. iqk_result[0][rf_path][j] = (boolean)
  399. (tmp & (BIT(rf_path + (j * 4)) >> (rf_path + (j * 4))));
  400. RF_DBG(dm, DBG_RF_IQK, "%-20s: 0x%08x\n", "Reg0x1bf0", tmp);
  401. RF_DBG(dm, DBG_RF_IQK, "%-20s: 0x%08x\n", "Reg0x1be8",
  402. odm_read_4byte(dm, 0x1be8));
  403. RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "PATH_A-Tx result",
  404. (iqk_result[0][RF_PATH_A][0]) ? "Fail" : "Pass");
  405. RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "PATH_A-Rx result",
  406. (iqk_result[0][RF_PATH_A][1]) ? "Fail" : "Pass");
  407. #if (RTL8822B_SUPPORT == 1)
  408. RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "PATH_B-Tx result",
  409. (iqk_result[0][RF_PATH_B][0]) ? "Fail" : "Pass");
  410. RF_DBG(dm, DBG_RF_IQK, "%-20s: %s\n", "PATH_B-Rx result",
  411. (iqk_result[0][RF_PATH_B][1]) ? "Fail" : "Pass");
  412. #endif
  413. }
  414. void halrf_lck_dbg(struct dm_struct *dm)
  415. {
  416. RF_DBG(dm, DBG_RF_IQK, "%-20s\n", "====== LCK Info ======");
  417. #if 0
  418. /*RF_DBG(dm, DBG_RF_IQK, "%-20s\n",
  419. * (dm->fw_offload_ability & PHYDM_RF_IQK_OFFLOAD) ? "LCK" : "RTK"));
  420. */
  421. #endif
  422. RF_DBG(dm, DBG_RF_IQK, "%-20s: %llu %s\n", "progressing_time",
  423. dm->rf_calibrate_info.lck_progressing_time, "(ms)");
  424. }
  425. void halrf_iqk_dbg_cfir_backup(struct dm_struct *dm)
  426. {
  427. struct dm_iqk_info *iqk_info = &dm->IQK_info;
  428. u8 path, idx, i;
  429. RF_DBG(dm, DBG_RF_IQK, "[IQK]%-20s\n", "backup TX/RX CFIR");
  430. for (path = 0; path < 2; path++)
  431. for (idx = 0; idx < 2; idx++)
  432. phydm_get_iqk_cfir(dm, idx, path, true);
  433. for (path = 0; path < 2; path++) {
  434. for (idx = 0; idx < 2; idx++) {
  435. for (i = 0; i < 8; i++) {
  436. RF_DBG(dm, DBG_RF_IQK,
  437. "[IQK]%-7s %-3s CFIR_real: %-2d: 0x%x\n",
  438. (path == 0) ? "PATH A" : "PATH B",
  439. (idx == 0) ? "TX" : "RX", i,
  440. iqk_info->iqk_cfir_real[2][path][idx][i])
  441. ;
  442. }
  443. for (i = 0; i < 8; i++) {
  444. RF_DBG(dm, DBG_RF_IQK,
  445. "[IQK]%-7s %-3s CFIR_img:%-2d: 0x%x\n",
  446. (path == 0) ? "PATH A" : "PATH B",
  447. (idx == 0) ? "TX" : "RX", i,
  448. iqk_info->iqk_cfir_imag[2][path][idx][i])
  449. ;
  450. }
  451. }
  452. }
  453. }
  454. void halrf_iqk_dbg_cfir_backup_update(struct dm_struct *dm)
  455. {
  456. struct dm_iqk_info *iqk = &dm->IQK_info;
  457. u8 i, path, idx;
  458. u32 bmask13_12 = BIT(13) | BIT(12);
  459. u32 bmask20_16 = BIT(20) | BIT(19) | BIT(18) | BIT(17) | BIT(16);
  460. u32 data;
  461. if (iqk->iqk_cfir_real[2][0][0][0] == 0) {
  462. RF_DBG(dm, DBG_RF_IQK, "[IQK]%-20s\n", "CFIR is invalid");
  463. return;
  464. }
  465. for (path = 0; path < 2; path++) {
  466. for (idx = 0; idx < 2; idx++) {
  467. odm_set_bb_reg(dm, R_0x1b00, MASKDWORD,
  468. 0xf8000008 | path << 1);
  469. odm_set_bb_reg(dm, R_0x1b2c, MASKDWORD, 0x7);
  470. odm_set_bb_reg(dm, R_0x1b38, MASKDWORD, 0x20000000);
  471. odm_set_bb_reg(dm, R_0x1b3c, MASKDWORD, 0x20000000);
  472. odm_set_bb_reg(dm, R_0x1bcc, MASKDWORD, 0x00000000);
  473. if (idx == 0)
  474. odm_set_bb_reg(dm, R_0x1b0c, bmask13_12, 0x3);
  475. else
  476. odm_set_bb_reg(dm, R_0x1b0c, bmask13_12, 0x1);
  477. odm_set_bb_reg(dm, R_0x1bd4, bmask20_16, 0x10);
  478. for (i = 0; i < 8; i++) {
  479. data = ((0xc0000000 >> idx) + 0x3) + (i * 4) +
  480. (iqk->iqk_cfir_real[2][path][idx][i]
  481. << 9);
  482. odm_write_4byte(dm, 0x1bd8, data);
  483. data = ((0xc0000000 >> idx) + 0x1) + (i * 4) +
  484. (iqk->iqk_cfir_imag[2][path][idx][i]
  485. << 9);
  486. odm_write_4byte(dm, 0x1bd8, data);
  487. #if 0
  488. /*odm_write_4byte(dm, 0x1bd8, iqk->iqk_cfir_real[2][path][idx][i]);*/
  489. /*odm_write_4byte(dm, 0x1bd8, iqk->iqk_cfir_imag[2][path][idx][i]);*/
  490. #endif
  491. }
  492. }
  493. odm_set_bb_reg(dm, R_0x1bd8, MASKDWORD, 0x0);
  494. odm_set_bb_reg(dm, R_0x1b0c, bmask13_12, 0x0);
  495. }
  496. RF_DBG(dm, DBG_RF_IQK, "[IQK]%-20s\n", "update new CFIR");
  497. }
  498. void halrf_iqk_dbg_cfir_reload(struct dm_struct *dm)
  499. {
  500. struct dm_iqk_info *iqk = &dm->IQK_info;
  501. u8 i, path, idx;
  502. u32 bmask13_12 = BIT(13) | BIT(12);
  503. u32 bmask20_16 = BIT(20) | BIT(19) | BIT(18) | BIT(17) | BIT(16);
  504. u32 data;
  505. if (iqk->iqk_cfir_real[0][0][0][0] == 0) {
  506. RF_DBG(dm, DBG_RF_IQK, "[IQK]%-20s\n", "CFIR is invalid");
  507. return;
  508. }
  509. for (path = 0; path < 2; path++) {
  510. for (idx = 0; idx < 2; idx++) {
  511. odm_set_bb_reg(dm, R_0x1b00, MASKDWORD,
  512. 0xf8000008 | path << 1);
  513. odm_set_bb_reg(dm, R_0x1b2c, MASKDWORD, 0x7);
  514. odm_set_bb_reg(dm, R_0x1b38, MASKDWORD, 0x20000000);
  515. odm_set_bb_reg(dm, R_0x1b3c, MASKDWORD, 0x20000000);
  516. odm_set_bb_reg(dm, R_0x1bcc, MASKDWORD, 0x00000000);
  517. if (idx == 0)
  518. odm_set_bb_reg(dm, R_0x1b0c, bmask13_12, 0x3);
  519. else
  520. odm_set_bb_reg(dm, R_0x1b0c, bmask13_12, 0x1);
  521. odm_set_bb_reg(dm, R_0x1bd4, bmask20_16, 0x10);
  522. for (i = 0; i < 8; i++) {
  523. #if 0
  524. /*odm_write_4byte(dm, 0x1bd8, iqk->iqk_cfir_real[0][path][idx][i]);*/
  525. /*odm_write_4byte(dm, 0x1bd8, iqk->iqk_cfir_imag[0][path][idx][i]);*/
  526. #endif
  527. data = ((0xc0000000 >> idx) + 0x3) + (i * 4) +
  528. (iqk->iqk_cfir_real[0][path][idx][i]
  529. << 9);
  530. odm_write_4byte(dm, 0x1bd8, data);
  531. data = ((0xc0000000 >> idx) + 0x1) + (i * 4) +
  532. (iqk->iqk_cfir_imag[0][path][idx][i]
  533. << 9);
  534. odm_write_4byte(dm, 0x1bd8, data);
  535. }
  536. }
  537. odm_set_bb_reg(dm, R_0x1bd8, MASKDWORD, 0x0);
  538. odm_set_bb_reg(dm, R_0x1b0c, bmask13_12, 0x0);
  539. }
  540. RF_DBG(dm, DBG_RF_IQK, "[IQK]%-20s\n", "write CFIR with default value");
  541. }
  542. void halrf_iqk_dbg_cfir_write(struct dm_struct *dm, u8 type, u32 path, u32 idx,
  543. u32 i, u32 data)
  544. {
  545. struct dm_iqk_info *iqk_info = &dm->IQK_info;
  546. if (type == 0)
  547. iqk_info->iqk_cfir_real[2][path][idx][i] = data;
  548. else
  549. iqk_info->iqk_cfir_imag[2][path][idx][i] = data;
  550. }
  551. void halrf_iqk_dbg_cfir_backup_show(struct dm_struct *dm)
  552. {
  553. struct dm_iqk_info *iqk_info = &dm->IQK_info;
  554. u8 path, idx, i;
  555. RF_DBG(dm, DBG_RF_IQK, "[IQK]%-20s\n", "backup TX/RX CFIR");
  556. for (path = 0; path < 2; path++) {
  557. for (idx = 0; idx < 2; idx++) {
  558. for (i = 0; i < 8; i++) {
  559. RF_DBG(dm, DBG_RF_IQK,
  560. "[IQK]%-10s %-3s CFIR_real:%-2d: 0x%x\n",
  561. (path == 0) ? "PATH A" : "PATH B",
  562. (idx == 0) ? "TX" : "RX", i,
  563. iqk_info->iqk_cfir_real[2][path][idx][i])
  564. ;
  565. }
  566. for (i = 0; i < 8; i++) {
  567. RF_DBG(dm, DBG_RF_IQK,
  568. "[IQK]%-10s %-3s CFIR_img:%-2d: 0x%x\n",
  569. (path == 0) ? "PATH A" : "PATH B",
  570. (idx == 0) ? "TX" : "RX", i,
  571. iqk_info->iqk_cfir_imag[2][path][idx][i])
  572. ;
  573. }
  574. }
  575. }
  576. }
  577. void halrf_do_imr_test(void *dm_void, u8 flag_imr_test)
  578. {
  579. struct dm_struct *dm = (struct dm_struct *)dm_void;
  580. if (flag_imr_test != 0x0)
  581. switch (dm->support_ic_type) {
  582. #if (RTL8822B_SUPPORT == 1)
  583. case ODM_RTL8822B:
  584. do_imr_test_8822b(dm);
  585. break;
  586. #endif
  587. #if (RTL8821C_SUPPORT == 1)
  588. case ODM_RTL8821C:
  589. do_imr_test_8821c(dm);
  590. break;
  591. #endif
  592. default:
  593. break;
  594. }
  595. }
  596. void halrf_iqk_debug(void *dm_void, u32 *const dm_value, u32 *_used,
  597. char *output, u32 *_out_len)
  598. {
  599. struct dm_struct *dm = (struct dm_struct *)dm_void;
  600. #if 0
  601. /*dm_value[0]=0x0: backup from SRAM & show*/
  602. /*dm_value[0]=0x1: write backup CFIR to SRAM*/
  603. /*dm_value[0]=0x2: reload default CFIR to SRAM*/
  604. /*dm_value[0]=0x3: show backup*/
  605. /*dm_value[0]=0x10: write backup CFIR real part*/
  606. /*--> dm_value[1]:path, dm_value[2]:tx/rx, dm_value[3]:index, dm_value[4]:data*/
  607. /*dm_value[0]=0x11: write backup CFIR imag*/
  608. /*--> dm_value[1]:path, dm_value[2]:tx/rx, dm_value[3]:index, dm_value[4]:data*/
  609. /*dm_value[0]=0x20 :xym_read enable*/
  610. /*--> dm_value[1]:0:disable, 1:enable*/
  611. /*if dm_value[0]=0x20 = enable, */
  612. /*0x1:show rx_sym; 0x2: tx_xym; 0x3:gs1_xym; 0x4:gs2_sym; 0x5:rxk1_xym*/
  613. #endif
  614. if (dm_value[0] == 0x0)
  615. halrf_iqk_dbg_cfir_backup(dm);
  616. else if (dm_value[0] == 0x1)
  617. halrf_iqk_dbg_cfir_backup_update(dm);
  618. else if (dm_value[0] == 0x2)
  619. halrf_iqk_dbg_cfir_reload(dm);
  620. else if (dm_value[0] == 0x3)
  621. halrf_iqk_dbg_cfir_backup_show(dm);
  622. else if (dm_value[0] == 0x10)
  623. halrf_iqk_dbg_cfir_write(dm, 0, dm_value[1], dm_value[2],
  624. dm_value[3], dm_value[4]);
  625. else if (dm_value[0] == 0x11)
  626. halrf_iqk_dbg_cfir_write(dm, 1, dm_value[1], dm_value[2],
  627. dm_value[3], dm_value[4]);
  628. else if (dm_value[0] == 0x20)
  629. halrf_iqk_xym_enable(dm, (u8)dm_value[1]);
  630. else if (dm_value[0] == 0x21)
  631. halrf_iqk_xym_show(dm, (u8)dm_value[1]);
  632. else if (dm_value[0] == 0x30)
  633. halrf_do_imr_test(dm, (u8)dm_value[1]);
  634. }
  635. void halrf_iqk_hwtx_check(void *dm_void, boolean is_check)
  636. {
  637. #if 0
  638. struct dm_struct *dm = (struct dm_struct *)dm_void;
  639. struct dm_iqk_info *iqk_info = &dm->IQK_info;
  640. u32 tmp_b04;
  641. if (is_check) {
  642. iqk_info->is_hwtx = (boolean)odm_get_bb_reg(dm, R_0xb00, BIT(8));
  643. } else {
  644. if (iqk_info->is_hwtx) {
  645. tmp_b04 = odm_read_4byte(dm, 0xb04);
  646. odm_set_bb_reg(dm, R_0xb04, BIT(3) | BIT(2), 0x0);
  647. odm_write_4byte(dm, 0xb04, tmp_b04);
  648. }
  649. }
  650. #endif
  651. }
  652. void halrf_segment_iqk_trigger(void *dm_void, boolean clear,
  653. boolean segment_iqk)
  654. {
  655. struct dm_struct *dm = (struct dm_struct *)dm_void;
  656. struct dm_iqk_info *iqk_info = &dm->IQK_info;
  657. struct _hal_rf_ *rf = &dm->rf_table;
  658. u64 start_time;
  659. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
  660. if (odm_check_power_status(dm) == false)
  661. return;
  662. #endif
  663. if (dm->mp_mode &&
  664. rf->is_con_tx &&
  665. rf->is_single_tone &&
  666. rf->is_carrier_suppresion)
  667. if (*dm->mp_mode &&
  668. ((*rf->is_con_tx ||
  669. *rf->is_single_tone ||
  670. *rf->is_carrier_suppresion)))
  671. return;
  672. #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
  673. if (!(rf->rf_supportability & HAL_RF_IQK))
  674. return;
  675. #endif
  676. #if DISABLE_BB_RF
  677. return;
  678. #endif
  679. if (iqk_info->rfk_forbidden)
  680. return;
  681. if (!dm->rf_calibrate_info.is_iqk_in_progress) {
  682. odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
  683. dm->rf_calibrate_info.is_iqk_in_progress = true;
  684. odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
  685. start_time = odm_get_current_time(dm);
  686. dm->IQK_info.segment_iqk = segment_iqk;
  687. switch (dm->support_ic_type) {
  688. #if (RTL8822B_SUPPORT == 1)
  689. case ODM_RTL8822B:
  690. phy_iq_calibrate_8822b(dm, clear, segment_iqk);
  691. break;
  692. #endif
  693. #if (RTL8821C_SUPPORT == 1)
  694. case ODM_RTL8821C:
  695. phy_iq_calibrate_8821c(dm, clear, segment_iqk);
  696. break;
  697. #endif
  698. #if (RTL8814B_SUPPORT == 1)
  699. case ODM_RTL8814B:
  700. break;
  701. #endif
  702. #if (RTL8195B_SUPPORT == 1)
  703. case ODM_RTL8195B:
  704. phy_iq_calibrate_8195b(dm, clear, segment_iqk);
  705. break;
  706. #endif
  707. #if (RTL8198F_SUPPORT == 1)
  708. case ODM_RTL8198F:
  709. phy_iq_calibrate_8198f(dm, clear, segment_iqk);
  710. break;
  711. #endif
  712. default:
  713. break;
  714. }
  715. dm->rf_calibrate_info.iqk_progressing_time =
  716. odm_get_progressing_time(dm, start_time);
  717. RF_DBG(dm, DBG_RF_IQK, "[IQK]IQK progressing_time = %lld ms\n",
  718. dm->rf_calibrate_info.iqk_progressing_time);
  719. odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
  720. dm->rf_calibrate_info.is_iqk_in_progress = false;
  721. odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
  722. } else {
  723. RF_DBG(dm, DBG_RF_IQK,
  724. "== Return the IQK CMD, because RFKs in Progress ==\n");
  725. }
  726. }
  727. #endif
  728. u8 halrf_match_iqk_version(void *dm_void)
  729. {
  730. struct dm_struct *dm = (struct dm_struct *)dm_void;
  731. u32 iqk_version = 0;
  732. char temp[10] = {0};
  733. odm_move_memory(dm, temp, HALRF_IQK_VER, sizeof(temp));
  734. PHYDM_SSCANF(temp + 2, DCMD_HEX, &iqk_version);
  735. if (dm->support_ic_type == ODM_RTL8822B) {
  736. if (iqk_version >= 0x24 && (odm_get_hw_img_version(dm) >= 72))
  737. return 1;
  738. else if ((iqk_version <= 0x23) &&
  739. (odm_get_hw_img_version(dm) <= 71))
  740. return 1;
  741. else
  742. return 0;
  743. }
  744. if (dm->support_ic_type == ODM_RTL8821C) {
  745. if (iqk_version >= 0x18 && (odm_get_hw_img_version(dm) >= 37))
  746. return 1;
  747. else
  748. return 0;
  749. }
  750. return 1;
  751. }
  752. void halrf_rf_lna_setting(void *dm_void, enum halrf_lna_set type)
  753. {
  754. struct dm_struct *dm = (struct dm_struct *)dm_void;
  755. switch (dm->support_ic_type) {
  756. #if (RTL8188E_SUPPORT == 1)
  757. case ODM_RTL8188E:
  758. halrf_rf_lna_setting_8188e(dm, type);
  759. break;
  760. #endif
  761. #if (RTL8192E_SUPPORT == 1)
  762. case ODM_RTL8192E:
  763. halrf_rf_lna_setting_8192e(dm, type);
  764. break;
  765. #endif
  766. #if (RTL8192F_SUPPORT == 1)
  767. case ODM_RTL8192F:
  768. halrf_rf_lna_setting_8192f(dm, type);
  769. break;
  770. #endif
  771. #if (RTL8723B_SUPPORT == 1)
  772. case ODM_RTL8723B:
  773. halrf_rf_lna_setting_8723b(dm, type);
  774. break;
  775. #endif
  776. #if (RTL8812A_SUPPORT == 1)
  777. case ODM_RTL8812:
  778. halrf_rf_lna_setting_8812a(dm, type);
  779. break;
  780. #endif
  781. #if ((RTL8821A_SUPPORT == 1) || (RTL8881A_SUPPORT == 1))
  782. case ODM_RTL8881A:
  783. case ODM_RTL8821:
  784. halrf_rf_lna_setting_8821a(dm, type);
  785. break;
  786. #endif
  787. #if (RTL8822B_SUPPORT == 1)
  788. case ODM_RTL8822B:
  789. halrf_rf_lna_setting_8822b(dm_void, type);
  790. break;
  791. #endif
  792. #if (RTL8821C_SUPPORT == 1)
  793. case ODM_RTL8821C:
  794. halrf_rf_lna_setting_8821c(dm_void, type);
  795. break;
  796. #endif
  797. default:
  798. break;
  799. }
  800. }
  801. void halrf_support_ability_debug(void *dm_void, char input[][16], u32 *_used,
  802. char *output, u32 *_out_len)
  803. {
  804. struct dm_struct *dm = (struct dm_struct *)dm_void;
  805. struct _hal_rf_ *rf = &dm->rf_table;
  806. u32 dm_value[10] = {0};
  807. u32 used = *_used;
  808. u32 out_len = *_out_len;
  809. u8 i;
  810. for (i = 0; i < 5; i++)
  811. if (input[i + 1])
  812. PHYDM_SSCANF(input[i + 2], DCMD_DECIMAL, &dm_value[i]);
  813. if (dm_value[0] == 100) {
  814. PDM_SNPF(out_len, used, output + used, out_len - used,
  815. "\n[RF Supportability]\n");
  816. PDM_SNPF(out_len, used, output + used, out_len - used,
  817. "00. (( %s ))Power Tracking\n",
  818. ((rf->rf_supportability & HAL_RF_TX_PWR_TRACK) ?
  819. ("V") : (".")));
  820. PDM_SNPF(out_len, used, output + used, out_len - used,
  821. "01. (( %s ))IQK\n",
  822. ((rf->rf_supportability & HAL_RF_IQK) ? ("V") :
  823. (".")));
  824. PDM_SNPF(out_len, used, output + used, out_len - used,
  825. "02. (( %s ))LCK\n",
  826. ((rf->rf_supportability & HAL_RF_LCK) ? ("V") :
  827. (".")));
  828. PDM_SNPF(out_len, used, output + used, out_len - used,
  829. "03. (( %s ))DPK\n",
  830. ((rf->rf_supportability & HAL_RF_DPK) ? ("V") :
  831. (".")));
  832. PDM_SNPF(out_len, used, output + used, out_len - used,
  833. "04. (( %s ))HAL_RF_TXGAPK\n",
  834. ((rf->rf_supportability & HAL_RF_TXGAPK) ? ("V") :
  835. (".")));
  836. } else {
  837. if (dm_value[1] == 1) /* enable */
  838. rf->rf_supportability |= BIT(dm_value[0]);
  839. else if (dm_value[1] == 2) /* disable */
  840. rf->rf_supportability &= ~(BIT(dm_value[0]));
  841. else
  842. PDM_SNPF(out_len, used, output + used, out_len - used,
  843. "[Warning!!!] 1:enable, 2:disable\n");
  844. }
  845. PDM_SNPF(out_len, used, output + used, out_len - used,
  846. "\nCurr-RF_supportability = 0x%x\n\n", rf->rf_supportability);
  847. *_used = used;
  848. *_out_len = out_len;
  849. }
  850. void halrf_cmn_info_init(void *dm_void, enum halrf_cmninfo_init cmn_info,
  851. u32 value)
  852. {
  853. struct dm_struct *dm = (struct dm_struct *)dm_void;
  854. struct _hal_rf_ *rf = &dm->rf_table;
  855. switch (cmn_info) {
  856. case HALRF_CMNINFO_EEPROM_THERMAL_VALUE:
  857. rf->eeprom_thermal = (u8)value;
  858. break;
  859. case HALRF_CMNINFO_PWT_TYPE:
  860. rf->pwt_type = (u8)value;
  861. break;
  862. default:
  863. break;
  864. }
  865. }
  866. void halrf_cmn_info_hook(void *dm_void, enum halrf_cmninfo_hook cmn_info,
  867. void *value)
  868. {
  869. struct dm_struct *dm = (struct dm_struct *)dm_void;
  870. struct _hal_rf_ *rf = &dm->rf_table;
  871. switch (cmn_info) {
  872. case HALRF_CMNINFO_CON_TX:
  873. rf->is_con_tx = (boolean *)value;
  874. break;
  875. case HALRF_CMNINFO_SINGLE_TONE:
  876. rf->is_single_tone = (boolean *)value;
  877. break;
  878. case HALRF_CMNINFO_CARRIER_SUPPRESSION:
  879. rf->is_carrier_suppresion = (boolean *)value;
  880. break;
  881. case HALRF_CMNINFO_MP_RATE_INDEX:
  882. rf->mp_rate_index = (u8 *)value;
  883. break;
  884. default:
  885. /*do nothing*/
  886. break;
  887. }
  888. }
  889. void halrf_cmn_info_set(void *dm_void, u32 cmn_info, u64 value)
  890. {
  891. /* This init variable may be changed in run time. */
  892. struct dm_struct *dm = (struct dm_struct *)dm_void;
  893. struct _hal_rf_ *rf = &dm->rf_table;
  894. switch (cmn_info) {
  895. case HALRF_CMNINFO_ABILITY:
  896. rf->rf_supportability = (u32)value;
  897. break;
  898. case HALRF_CMNINFO_DPK_EN:
  899. rf->dpk_en = (u8)value;
  900. break;
  901. case HALRF_CMNINFO_RFK_FORBIDDEN:
  902. dm->IQK_info.rfk_forbidden = (boolean)value;
  903. break;
  904. #if (RTL8814A_SUPPORT == 1 || RTL8822B_SUPPORT == 1 || \
  905. RTL8821C_SUPPORT == 1 || RTL8195B_SUPPORT == 1)
  906. case HALRF_CMNINFO_IQK_SEGMENT:
  907. dm->IQK_info.segment_iqk = (boolean)value;
  908. break;
  909. #endif
  910. case HALRF_CMNINFO_RATE_INDEX:
  911. rf->p_rate_index = (u32)value;
  912. break;
  913. #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
  914. case HALRF_CMNINFO_MP_PSD_POINT:
  915. rf->halrf_psd_data.point = (u32)value;
  916. break;
  917. case HALRF_CMNINFO_MP_PSD_START_POINT:
  918. rf->halrf_psd_data.start_point = (u32)value;
  919. break;
  920. case HALRF_CMNINFO_MP_PSD_STOP_POINT:
  921. rf->halrf_psd_data.stop_point = (u32)value;
  922. break;
  923. case HALRF_CMNINFO_MP_PSD_AVERAGE:
  924. rf->halrf_psd_data.average = (u32)value;
  925. break;
  926. #endif
  927. default:
  928. /* do nothing */
  929. break;
  930. }
  931. }
  932. u64 halrf_cmn_info_get(void *dm_void, u32 cmn_info)
  933. {
  934. /* This init variable may be changed in run time. */
  935. struct dm_struct *dm = (struct dm_struct *)dm_void;
  936. struct _hal_rf_ *rf = &dm->rf_table;
  937. u64 return_value = 0;
  938. switch (cmn_info) {
  939. case HALRF_CMNINFO_ABILITY:
  940. return_value = (u32)rf->rf_supportability;
  941. break;
  942. case HALRF_CMNINFO_RFK_FORBIDDEN:
  943. return_value = dm->IQK_info.rfk_forbidden;
  944. break;
  945. #if (RTL8814A_SUPPORT == 1 || RTL8822B_SUPPORT == 1 || \
  946. RTL8821C_SUPPORT == 1 || RTL8195B_SUPPORT == 1)
  947. case HALRF_CMNINFO_IQK_SEGMENT:
  948. return_value = dm->IQK_info.segment_iqk;
  949. break;
  950. #endif
  951. default:
  952. /* do nothing */
  953. break;
  954. }
  955. return return_value;
  956. }
  957. void halrf_supportability_init_mp(void *dm_void)
  958. {
  959. struct dm_struct *dm = (struct dm_struct *)dm_void;
  960. struct _hal_rf_ *rf = &dm->rf_table;
  961. switch (dm->support_ic_type) {
  962. case ODM_RTL8814B:
  963. #if (RTL8814B_SUPPORT == 1)
  964. rf->rf_supportability =
  965. HAL_RF_TX_PWR_TRACK |
  966. HAL_RF_IQK |
  967. HAL_RF_LCK |
  968. /*HAL_RF_DPK |*/
  969. 0;
  970. #endif
  971. break;
  972. #if (RTL8822B_SUPPORT == 1)
  973. case ODM_RTL8822B:
  974. rf->rf_supportability =
  975. HAL_RF_TX_PWR_TRACK |
  976. HAL_RF_IQK |
  977. HAL_RF_LCK |
  978. /*HAL_RF_DPK |*/
  979. 0;
  980. break;
  981. #endif
  982. #if (RTL8821C_SUPPORT == 1)
  983. case ODM_RTL8821C:
  984. rf->rf_supportability =
  985. HAL_RF_TX_PWR_TRACK |
  986. HAL_RF_IQK |
  987. HAL_RF_LCK |
  988. /*HAL_RF_DPK |*/
  989. /*HAL_RF_TXGAPK |*/
  990. 0;
  991. break;
  992. #endif
  993. #if (RTL8195B_SUPPORT == 1)
  994. case ODM_RTL8195B:
  995. rf->rf_supportability =
  996. HAL_RF_TX_PWR_TRACK |
  997. HAL_RF_IQK |
  998. HAL_RF_LCK |
  999. HAL_RF_DPK |
  1000. HAL_RF_TXGAPK |
  1001. 0;
  1002. break;
  1003. #endif
  1004. default:
  1005. rf->rf_supportability =
  1006. HAL_RF_TX_PWR_TRACK |
  1007. HAL_RF_IQK |
  1008. HAL_RF_LCK |
  1009. /*HAL_RF_DPK |*/
  1010. /*HAL_RF_TXGAPK |*/
  1011. 0;
  1012. break;
  1013. }
  1014. RF_DBG(dm, DBG_RF_INIT,
  1015. "IC = ((0x%x)), RF_Supportability Init MP = ((0x%x))\n",
  1016. dm->support_ic_type, rf->rf_supportability);
  1017. }
  1018. void halrf_supportability_init(void *dm_void)
  1019. {
  1020. struct dm_struct *dm = (struct dm_struct *)dm_void;
  1021. struct _hal_rf_ *rf = &dm->rf_table;
  1022. switch (dm->support_ic_type) {
  1023. case ODM_RTL8814B:
  1024. #if (RTL8814B_SUPPORT == 1)
  1025. rf->rf_supportability =
  1026. HAL_RF_TX_PWR_TRACK |
  1027. HAL_RF_IQK |
  1028. HAL_RF_LCK |
  1029. /*HAL_RF_DPK |*/
  1030. 0;
  1031. #endif
  1032. break;
  1033. #if (RTL8822B_SUPPORT == 1)
  1034. case ODM_RTL8822B:
  1035. rf->rf_supportability =
  1036. HAL_RF_TX_PWR_TRACK |
  1037. HAL_RF_IQK |
  1038. HAL_RF_LCK |
  1039. /*HAL_RF_DPK |*/
  1040. 0;
  1041. break;
  1042. #endif
  1043. #if (RTL8821C_SUPPORT == 1)
  1044. case ODM_RTL8821C:
  1045. rf->rf_supportability =
  1046. HAL_RF_TX_PWR_TRACK |
  1047. HAL_RF_IQK |
  1048. HAL_RF_LCK |
  1049. /*HAL_RF_DPK |*/
  1050. /*HAL_RF_TXGAPK |*/
  1051. 0;
  1052. break;
  1053. #endif
  1054. #if (RTL8195B_SUPPORT == 1)
  1055. case ODM_RTL8195B:
  1056. rf->rf_supportability =
  1057. HAL_RF_TX_PWR_TRACK |
  1058. HAL_RF_IQK |
  1059. HAL_RF_LCK |
  1060. HAL_RF_DPK |
  1061. HAL_RF_TXGAPK |
  1062. 0;
  1063. break;
  1064. #endif
  1065. default:
  1066. rf->rf_supportability =
  1067. HAL_RF_TX_PWR_TRACK |
  1068. HAL_RF_IQK |
  1069. HAL_RF_LCK |
  1070. /*HAL_RF_DPK |*/
  1071. 0;
  1072. break;
  1073. }
  1074. RF_DBG(dm, DBG_RF_INIT,
  1075. "IC = ((0x%x)), RF_Supportability Init = ((0x%x))\n",
  1076. dm->support_ic_type, rf->rf_supportability);
  1077. }
  1078. void halrf_watchdog(void *dm_void)
  1079. {
  1080. struct dm_struct *dm = (struct dm_struct *)dm_void;
  1081. #if 0
  1082. /*RF_DBG(dm, DBG_RF_TMP, "%s\n", __func__);*/
  1083. #endif
  1084. phydm_rf_watchdog(dm);
  1085. }
  1086. #if 0
  1087. void
  1088. halrf_iqk_init(
  1089. void *dm_void
  1090. )
  1091. {
  1092. struct dm_struct *dm = (struct dm_struct *)dm_void;
  1093. struct _hal_rf_ *rf = &dm->rf_table;
  1094. switch (dm->support_ic_type) {
  1095. #if (RTL8814B_SUPPORT == 1)
  1096. case ODM_RTL8814B:
  1097. break;
  1098. #endif
  1099. #if (RTL8822B_SUPPORT == 1)
  1100. case ODM_RTL8822B:
  1101. _iq_calibrate_8822b_init(dm);
  1102. break;
  1103. #endif
  1104. #if (RTL8821C_SUPPORT == 1)
  1105. case ODM_RTL8821C:
  1106. break;
  1107. #endif
  1108. default:
  1109. break;
  1110. }
  1111. }
  1112. #endif
  1113. void halrf_iqk_trigger(void *dm_void, boolean is_recovery)
  1114. {
  1115. struct dm_struct *dm = (struct dm_struct *)dm_void;
  1116. struct dm_iqk_info *iqk_info = &dm->IQK_info;
  1117. struct dm_dpk_info *dpk_info = &dm->dpk_info;
  1118. struct _hal_rf_ *rf = &dm->rf_table;
  1119. u64 start_time;
  1120. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
  1121. if (odm_check_power_status(dm) == false)
  1122. return;
  1123. #endif
  1124. if (dm->mp_mode &&
  1125. rf->is_con_tx &&
  1126. rf->is_single_tone &&
  1127. rf->is_carrier_suppresion)
  1128. if (*dm->mp_mode &&
  1129. ((*rf->is_con_tx ||
  1130. *rf->is_single_tone ||
  1131. *rf->is_carrier_suppresion)))
  1132. return;
  1133. #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
  1134. if (!(rf->rf_supportability & HAL_RF_IQK))
  1135. return;
  1136. #endif
  1137. #if DISABLE_BB_RF
  1138. return;
  1139. #endif
  1140. if (iqk_info->rfk_forbidden)
  1141. return;
  1142. if (!dm->rf_calibrate_info.is_iqk_in_progress) {
  1143. odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
  1144. dm->rf_calibrate_info.is_iqk_in_progress = true;
  1145. odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
  1146. start_time = odm_get_current_time(dm);
  1147. switch (dm->support_ic_type) {
  1148. #if (RTL8188E_SUPPORT == 1)
  1149. case ODM_RTL8188E:
  1150. phy_iq_calibrate_8188e(dm, is_recovery);
  1151. break;
  1152. #endif
  1153. #if (RTL8188F_SUPPORT == 1)
  1154. case ODM_RTL8188F:
  1155. phy_iq_calibrate_8188f(dm, is_recovery);
  1156. break;
  1157. #endif
  1158. #if (RTL8192E_SUPPORT == 1)
  1159. case ODM_RTL8192E:
  1160. phy_iq_calibrate_8192e(dm, is_recovery);
  1161. break;
  1162. #endif
  1163. #if (RTL8197F_SUPPORT == 1)
  1164. case ODM_RTL8197F:
  1165. phy_iq_calibrate_8197f(dm, is_recovery);
  1166. break;
  1167. #endif
  1168. #if (RTL8192F_SUPPORT == 1)
  1169. case ODM_RTL8192F:
  1170. phy_iq_calibrate_8192f(dm, is_recovery);
  1171. break;
  1172. #endif
  1173. #if (RTL8703B_SUPPORT == 1)
  1174. case ODM_RTL8703B:
  1175. phy_iq_calibrate_8703b(dm, is_recovery);
  1176. break;
  1177. #endif
  1178. #if (RTL8710B_SUPPORT == 1)
  1179. case ODM_RTL8710B:
  1180. phy_iq_calibrate_8710b(dm, is_recovery);
  1181. break;
  1182. #endif
  1183. #if (RTL8723B_SUPPORT == 1)
  1184. case ODM_RTL8723B:
  1185. phy_iq_calibrate_8723b(dm, is_recovery);
  1186. break;
  1187. #endif
  1188. #if (RTL8723D_SUPPORT == 1)
  1189. case ODM_RTL8723D:
  1190. phy_iq_calibrate_8723d(dm, is_recovery);
  1191. break;
  1192. #endif
  1193. #if (RTL8812A_SUPPORT == 1)
  1194. case ODM_RTL8812:
  1195. phy_iq_calibrate_8812a(dm, is_recovery);
  1196. break;
  1197. #endif
  1198. #if (RTL8821A_SUPPORT == 1)
  1199. case ODM_RTL8821:
  1200. phy_iq_calibrate_8821a(dm, is_recovery);
  1201. break;
  1202. #endif
  1203. #if (RTL8814A_SUPPORT == 1)
  1204. case ODM_RTL8814A:
  1205. phy_iq_calibrate_8814a(dm, is_recovery);
  1206. break;
  1207. #endif
  1208. #if (RTL8822B_SUPPORT == 1)
  1209. case ODM_RTL8822B:
  1210. phy_iq_calibrate_8822b(dm, false, false);
  1211. break;
  1212. #endif
  1213. #if (RTL8821C_SUPPORT == 1)
  1214. case ODM_RTL8821C:
  1215. phy_iq_calibrate_8821c(dm, false, false);
  1216. break;
  1217. #endif
  1218. #if (RTL8814B_SUPPORT == 1)
  1219. case ODM_RTL8814B:
  1220. break;
  1221. #endif
  1222. #if (RTL8195B_SUPPORT == 1)
  1223. case ODM_RTL8195B:
  1224. phy_iq_calibrate_8195b(dm, false, false);
  1225. break;
  1226. #endif
  1227. #if (RTL8198F_SUPPORT == 1)
  1228. case ODM_RTL8198F:
  1229. phy_iq_calibrate_8198f(dm, false, false);
  1230. break;
  1231. #endif
  1232. default:
  1233. break;
  1234. }
  1235. dm->rf_calibrate_info.iqk_progressing_time =
  1236. odm_get_progressing_time(dm, start_time);
  1237. RF_DBG(dm, DBG_RF_IQK, "[IQK]IQK progressing_time = %lld ms\n",
  1238. dm->rf_calibrate_info.iqk_progressing_time);
  1239. odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
  1240. dm->rf_calibrate_info.is_iqk_in_progress = false;
  1241. odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
  1242. } else {
  1243. RF_DBG(dm, DBG_RF_IQK,
  1244. "== Return the IQK CMD, because RFKs in Progress ==\n");
  1245. }
  1246. }
  1247. void halrf_lck_trigger(void *dm_void)
  1248. {
  1249. struct dm_struct *dm = (struct dm_struct *)dm_void;
  1250. struct dm_iqk_info *iqk_info = &dm->IQK_info;
  1251. struct _hal_rf_ *rf = &dm->rf_table;
  1252. u64 start_time;
  1253. #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN))
  1254. if (odm_check_power_status(dm) == false)
  1255. return;
  1256. #endif
  1257. if (dm->mp_mode &&
  1258. rf->is_con_tx &&
  1259. rf->is_single_tone &&
  1260. rf->is_carrier_suppresion)
  1261. if (*dm->mp_mode &&
  1262. ((*rf->is_con_tx ||
  1263. *rf->is_single_tone ||
  1264. *rf->is_carrier_suppresion)))
  1265. return;
  1266. #if (DM_ODM_SUPPORT_TYPE == ODM_CE)
  1267. if (!(rf->rf_supportability & HAL_RF_LCK))
  1268. return;
  1269. #endif
  1270. #if DISABLE_BB_RF
  1271. return;
  1272. #endif
  1273. if (iqk_info->rfk_forbidden)
  1274. return;
  1275. while (*dm->is_scan_in_process) {
  1276. RF_DBG(dm, DBG_RF_IQK, "[LCK]scan is in process, bypass LCK\n");
  1277. return;
  1278. }
  1279. if (!dm->rf_calibrate_info.is_lck_in_progress) {
  1280. odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
  1281. dm->rf_calibrate_info.is_lck_in_progress = true;
  1282. odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
  1283. start_time = odm_get_current_time(dm);
  1284. switch (dm->support_ic_type) {
  1285. #if (RTL8188E_SUPPORT == 1)
  1286. case ODM_RTL8188E:
  1287. phy_lc_calibrate_8188e(dm);
  1288. break;
  1289. #endif
  1290. #if (RTL8188F_SUPPORT == 1)
  1291. case ODM_RTL8188F:
  1292. phy_lc_calibrate_8188f(dm);
  1293. break;
  1294. #endif
  1295. #if (RTL8192E_SUPPORT == 1)
  1296. case ODM_RTL8192E:
  1297. phy_lc_calibrate_8192e(dm);
  1298. break;
  1299. #endif
  1300. #if (RTL8197F_SUPPORT == 1)
  1301. case ODM_RTL8197F:
  1302. phy_lc_calibrate_8197f(dm);
  1303. break;
  1304. #endif
  1305. #if (RTL8192F_SUPPORT == 1)
  1306. case ODM_RTL8192F:
  1307. phy_lc_calibrate_8192f(dm);
  1308. break;
  1309. #endif
  1310. #if (RTL8703B_SUPPORT == 1)
  1311. case ODM_RTL8703B:
  1312. phy_lc_calibrate_8703b(dm);
  1313. break;
  1314. #endif
  1315. #if (RTL8710B_SUPPORT == 1)
  1316. case ODM_RTL8710B:
  1317. phy_lc_calibrate_8710b(dm);
  1318. break;
  1319. #endif
  1320. #if (RTL8723B_SUPPORT == 1)
  1321. case ODM_RTL8723B:
  1322. phy_lc_calibrate_8723b(dm);
  1323. break;
  1324. #endif
  1325. #if (RTL8723D_SUPPORT == 1)
  1326. case ODM_RTL8723D:
  1327. phy_lc_calibrate_8723d(dm);
  1328. break;
  1329. #endif
  1330. #if (RTL8812A_SUPPORT == 1)
  1331. case ODM_RTL8812:
  1332. phy_lc_calibrate_8812a(dm);
  1333. break;
  1334. #endif
  1335. #if (RTL8821A_SUPPORT == 1)
  1336. case ODM_RTL8821:
  1337. phy_lc_calibrate_8821a(dm);
  1338. break;
  1339. #endif
  1340. #if (RTL8814A_SUPPORT == 1)
  1341. case ODM_RTL8814A:
  1342. phy_lc_calibrate_8814a(dm);
  1343. break;
  1344. #endif
  1345. #if (RTL8822B_SUPPORT == 1)
  1346. case ODM_RTL8822B:
  1347. phy_lc_calibrate_8822b(dm);
  1348. break;
  1349. #endif
  1350. #if (RTL8821C_SUPPORT == 1)
  1351. case ODM_RTL8821C:
  1352. phy_lc_calibrate_8821c(dm);
  1353. break;
  1354. #endif
  1355. #if (RTL8814B_SUPPORT == 1)
  1356. case ODM_RTL8814B:
  1357. break;
  1358. #endif
  1359. default:
  1360. break;
  1361. }
  1362. dm->rf_calibrate_info.lck_progressing_time =
  1363. odm_get_progressing_time(dm, start_time);
  1364. RF_DBG(dm, DBG_RF_IQK, "[IQK]LCK progressing_time = %lld ms\n",
  1365. dm->rf_calibrate_info.lck_progressing_time);
  1366. #if (RTL8822B_SUPPORT == 1 || RTL8821C_SUPPORT == 1)
  1367. halrf_lck_dbg(dm);
  1368. #endif
  1369. odm_acquire_spin_lock(dm, RT_IQK_SPINLOCK);
  1370. dm->rf_calibrate_info.is_lck_in_progress = false;
  1371. odm_release_spin_lock(dm, RT_IQK_SPINLOCK);
  1372. } else {
  1373. RF_DBG(dm, DBG_RF_IQK,
  1374. "= Return the LCK CMD, because RFK is in Progress =\n");
  1375. }
  1376. }
  1377. void halrf_aac_check(struct dm_struct *dm)
  1378. {
  1379. switch (dm->support_ic_type) {
  1380. #if (RTL8821C_SUPPORT == 1)
  1381. case ODM_RTL8821C:
  1382. #if 0
  1383. aac_check_8821c(dm);
  1384. #endif
  1385. break;
  1386. #endif
  1387. #if (RTL8822B_SUPPORT == 1)
  1388. case ODM_RTL8822B:
  1389. #if 1
  1390. aac_check_8822b(dm);
  1391. #endif
  1392. break;
  1393. #endif
  1394. default:
  1395. break;
  1396. }
  1397. }
  1398. void halrf_init(void *dm_void)
  1399. {
  1400. struct dm_struct *dm = (struct dm_struct *)dm_void;
  1401. struct _hal_rf_ *rf = &dm->rf_table;
  1402. RF_DBG(dm, DBG_RF_INIT, "HALRF_Init\n");
  1403. rf->aac_checked = false;
  1404. halrf_init_debug_setting(dm);
  1405. if (*dm->mp_mode)
  1406. halrf_supportability_init_mp(dm);
  1407. else
  1408. halrf_supportability_init(dm);
  1409. /*Init all RF funciton*/
  1410. halrf_aac_check(dm);
  1411. }
  1412. void halrf_dpk_trigger(void *dm_void)
  1413. {
  1414. struct dm_struct *dm = (struct dm_struct *)dm_void;
  1415. struct _hal_rf_ *rf = &dm->rf_table;
  1416. u64 start_time;
  1417. start_time = odm_get_current_time(dm);
  1418. switch (dm->support_ic_type) {
  1419. #if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
  1420. #if (RTL8197F_SUPPORT == 1)
  1421. case ODM_RTL8197F:
  1422. do_dpk_8197f(dm);
  1423. break;
  1424. #endif
  1425. #if (RTL8192F_SUPPORT == 1)
  1426. case ODM_RTL8192F:
  1427. do_dpk_8192f(dm);
  1428. break;
  1429. #endif
  1430. #if (RTL8198F_SUPPORT == 1)
  1431. case ODM_RTL8198F:
  1432. do_dpk_8198f(dm);
  1433. break;
  1434. #endif
  1435. #endif
  1436. #if (DM_ODM_SUPPORT_TYPE & (ODM_IOT))
  1437. #if (RTL8195B_SUPPORT == 1)
  1438. case ODM_RTL8195B:
  1439. do_dpk_8195b(dm, false);
  1440. break;
  1441. #endif
  1442. #endif
  1443. default:
  1444. break;
  1445. }
  1446. rf->dpk_progressing_time = odm_get_progressing_time(dm, start_time);
  1447. RF_DBG(dm, DBG_RF_DPK, "[DPK]DPK progressing_time = %lld ms\n",
  1448. rf->dpk_progressing_time);
  1449. }
  1450. u8 halrf_dpk_result_check(void *dm_void)
  1451. {
  1452. struct dm_struct *dm = (struct dm_struct *)dm_void;
  1453. struct dm_dpk_info *dpk_info = &dm->dpk_info;
  1454. u8 result = 0;
  1455. switch (dm->support_ic_type) {
  1456. #if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
  1457. #if (RTL8197F_SUPPORT == 1)
  1458. case ODM_RTL8197F:
  1459. if (dpk_info->dpk_path_ok == 0x3)
  1460. result = 1;
  1461. else
  1462. result = 0;
  1463. break;
  1464. #endif
  1465. #if (RTL8192F_SUPPORT == 1)
  1466. case ODM_RTL8192F:
  1467. if (dpk_info->dpk_path_ok == 0x3)
  1468. result = 1;
  1469. else
  1470. result = 0;
  1471. break;
  1472. #endif
  1473. #if (RTL8198F_SUPPORT == 1)
  1474. case ODM_RTL8198F:
  1475. if (dpk_info->dpk_path_ok == 0xf)
  1476. result = 1;
  1477. else
  1478. result = 0;
  1479. break;
  1480. #endif
  1481. #endif
  1482. default:
  1483. break;
  1484. }
  1485. return result;
  1486. }
  1487. void halrf_dpk_sram_read(void *dm_void)
  1488. {
  1489. struct dm_struct *dm = (struct dm_struct *)dm_void;
  1490. u8 path, group;
  1491. switch (dm->support_ic_type) {
  1492. #if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
  1493. #if (RTL8197F_SUPPORT == 1)
  1494. case ODM_RTL8197F:
  1495. dpk_sram_read_8197f(dm);
  1496. break;
  1497. #endif
  1498. #if (RTL8192F_SUPPORT == 1)
  1499. case ODM_RTL8192F:
  1500. dpk_sram_read_8192f(dm);
  1501. break;
  1502. #endif
  1503. #if (RTL8198F_SUPPORT == 1)
  1504. case ODM_RTL8198F:
  1505. dpk_sram_read_8198f(dm);
  1506. break;
  1507. #endif
  1508. #endif
  1509. default:
  1510. break;
  1511. }
  1512. }
  1513. void halrf_dpk_enable_disable(void *dm_void)
  1514. {
  1515. struct dm_struct *dm = (struct dm_struct *)dm_void;
  1516. switch (dm->support_ic_type) {
  1517. #if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
  1518. #if (RTL8197F_SUPPORT == 1)
  1519. case ODM_RTL8197F:
  1520. phy_dpk_enable_disable_8197f(dm);
  1521. break;
  1522. #endif
  1523. #if (RTL8192F_SUPPORT == 1)
  1524. case ODM_RTL8192F:
  1525. phy_dpk_enable_disable_8192f(dm);
  1526. break;
  1527. #endif
  1528. #if (RTL8198F_SUPPORT == 1)
  1529. case ODM_RTL8198F:
  1530. dpk_enable_disable_8198f(dm);
  1531. break;
  1532. #endif
  1533. #endif
  1534. default:
  1535. break;
  1536. }
  1537. }
  1538. void halrf_dpk_track(void *dm_void)
  1539. {
  1540. struct dm_struct *dm = (struct dm_struct *)dm_void;
  1541. struct dm_dpk_info *dpk_info = &dm->dpk_info;
  1542. switch (dm->support_ic_type) {
  1543. #if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
  1544. #if (RTL8197F_SUPPORT == 1)
  1545. case ODM_RTL8197F:
  1546. phy_dpk_track_8197f(dm);
  1547. break;
  1548. #endif
  1549. #if (RTL8192F_SUPPORT == 1)
  1550. case ODM_RTL8192F:
  1551. phy_dpk_track_8192f(dm);
  1552. break;
  1553. #endif
  1554. #if (RTL8198F_SUPPORT == 1)
  1555. case ODM_RTL8198F:
  1556. dpk_track_8198f(dm);
  1557. break;
  1558. #endif
  1559. #endif
  1560. default:
  1561. break;
  1562. }
  1563. }
  1564. void halrf_dpk_reload(void *dm_void)
  1565. {
  1566. struct dm_struct *dm = (struct dm_struct *)dm_void;
  1567. struct dm_dpk_info *dpk_info = &dm->dpk_info;
  1568. switch (dm->support_ic_type) {
  1569. #if (DM_ODM_SUPPORT_TYPE & (ODM_AP))
  1570. #if (RTL8197F_SUPPORT == 1)
  1571. case ODM_RTL8197F:
  1572. if (dpk_info->dpk_path_ok > 0)
  1573. dpk_reload_8197f(dm);
  1574. break;
  1575. #endif
  1576. #if (RTL8192F_SUPPORT == 1)
  1577. case ODM_RTL8192F:
  1578. if (dpk_info->dpk_path_ok > 0)
  1579. dpk_reload_8192f(dm);
  1580. break;
  1581. #endif
  1582. #if (RTL8198F_SUPPORT == 1)
  1583. case ODM_RTL8198F:
  1584. if (dpk_info->dpk_path_ok > 0)
  1585. dpk_reload_8198f(dm);
  1586. break;
  1587. #endif
  1588. #endif
  1589. default:
  1590. break;
  1591. }
  1592. }
  1593. enum hal_status
  1594. halrf_config_rfk_with_header_file(void *dm_void, u32 config_type)
  1595. {
  1596. #if (RTL8198F_SUPPORT == 1)
  1597. struct dm_struct *dm = (struct dm_struct *)dm_void;
  1598. #endif
  1599. enum hal_status result = HAL_STATUS_SUCCESS;
  1600. #if 0
  1601. #if (RTL8822B_SUPPORT == 1)
  1602. if (dm->support_ic_type == ODM_RTL8822B) {
  1603. if (config_type == CONFIG_BB_RF_CAL_INIT)
  1604. odm_read_and_config_mp_8822b_cal_init(dm);
  1605. }
  1606. #endif
  1607. #endif
  1608. #if 1
  1609. #if (RTL8198F_SUPPORT == 1)
  1610. if (dm->support_ic_type == ODM_RTL8198F) {
  1611. if (config_type == CONFIG_BB_RF_CAL_INIT)
  1612. odm_read_and_config_mp_8198f_cal_init(dm);
  1613. }
  1614. #endif
  1615. #endif
  1616. return result;
  1617. }