dm.c 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2009-2012 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. #include "../wifi.h"
  26. #include "../base.h"
  27. #include "../pci.h"
  28. #include "../core.h"
  29. #include "reg.h"
  30. #include "def.h"
  31. #include "phy.h"
  32. #include "dm.h"
  33. #include "../rtl8723com/dm_common.h"
  34. #include "fw.h"
  35. #include "hal_btc.h"
  36. static const u32 ofdmswing_table[OFDM_TABLE_SIZE] = {
  37. 0x7f8001fe,
  38. 0x788001e2,
  39. 0x71c001c7,
  40. 0x6b8001ae,
  41. 0x65400195,
  42. 0x5fc0017f,
  43. 0x5a400169,
  44. 0x55400155,
  45. 0x50800142,
  46. 0x4c000130,
  47. 0x47c0011f,
  48. 0x43c0010f,
  49. 0x40000100,
  50. 0x3c8000f2,
  51. 0x390000e4,
  52. 0x35c000d7,
  53. 0x32c000cb,
  54. 0x300000c0,
  55. 0x2d4000b5,
  56. 0x2ac000ab,
  57. 0x288000a2,
  58. 0x26000098,
  59. 0x24000090,
  60. 0x22000088,
  61. 0x20000080,
  62. 0x1e400079,
  63. 0x1c800072,
  64. 0x1b00006c,
  65. 0x19800066,
  66. 0x18000060,
  67. 0x16c0005b,
  68. 0x15800056,
  69. 0x14400051,
  70. 0x1300004c,
  71. 0x12000048,
  72. 0x11000044,
  73. 0x10000040,
  74. };
  75. static const u8 cckswing_table_ch1ch13[CCK_TABLE_SIZE][8] = {
  76. {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04},
  77. {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04},
  78. {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03},
  79. {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03},
  80. {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03},
  81. {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03},
  82. {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03},
  83. {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03},
  84. {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02},
  85. {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02},
  86. {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02},
  87. {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02},
  88. {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02},
  89. {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02},
  90. {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02},
  91. {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02},
  92. {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01},
  93. {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02},
  94. {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01},
  95. {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01},
  96. {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01},
  97. {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01},
  98. {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01},
  99. {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01},
  100. {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01},
  101. {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01},
  102. {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01},
  103. {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01},
  104. {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01},
  105. {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01},
  106. {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01},
  107. {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01},
  108. {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01}
  109. };
  110. static const u8 cckswing_table_ch14[CCK_TABLE_SIZE][8] = {
  111. {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00},
  112. {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00},
  113. {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00},
  114. {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00},
  115. {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00},
  116. {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00},
  117. {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00},
  118. {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00},
  119. {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00},
  120. {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00},
  121. {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00},
  122. {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00},
  123. {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00},
  124. {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00},
  125. {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00},
  126. {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00},
  127. {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00},
  128. {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00},
  129. {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00},
  130. {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00},
  131. {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00},
  132. {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00},
  133. {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00},
  134. {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00},
  135. {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00},
  136. {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00},
  137. {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00},
  138. {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00},
  139. {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00},
  140. {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00},
  141. {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00},
  142. {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00},
  143. {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}
  144. };
  145. static u8 rtl8723e_dm_initial_gain_min_pwdb(struct ieee80211_hw *hw)
  146. {
  147. struct rtl_priv *rtlpriv = rtl_priv(hw);
  148. struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
  149. long rssi_val_min = 0;
  150. if ((dm_digtable->curmultista_cstate == DIG_MULTISTA_CONNECT) &&
  151. (dm_digtable->cursta_cstate == DIG_STA_CONNECT)) {
  152. if (rtlpriv->dm.entry_min_undec_sm_pwdb != 0)
  153. rssi_val_min =
  154. (rtlpriv->dm.entry_min_undec_sm_pwdb >
  155. rtlpriv->dm.undec_sm_pwdb) ?
  156. rtlpriv->dm.undec_sm_pwdb :
  157. rtlpriv->dm.entry_min_undec_sm_pwdb;
  158. else
  159. rssi_val_min = rtlpriv->dm.undec_sm_pwdb;
  160. } else if (dm_digtable->cursta_cstate == DIG_STA_CONNECT ||
  161. dm_digtable->cursta_cstate == DIG_STA_BEFORE_CONNECT) {
  162. rssi_val_min = rtlpriv->dm.undec_sm_pwdb;
  163. } else if (dm_digtable->curmultista_cstate ==
  164. DIG_MULTISTA_CONNECT) {
  165. rssi_val_min = rtlpriv->dm.entry_min_undec_sm_pwdb;
  166. }
  167. return (u8) rssi_val_min;
  168. }
  169. static void rtl8723e_dm_false_alarm_counter_statistics(struct ieee80211_hw *hw)
  170. {
  171. u32 ret_value;
  172. struct rtl_priv *rtlpriv = rtl_priv(hw);
  173. struct false_alarm_statistics *falsealm_cnt = &(rtlpriv->falsealm_cnt);
  174. ret_value = rtl_get_bbreg(hw, ROFDM_PHYCOUNTER1, MASKDWORD);
  175. falsealm_cnt->cnt_parity_fail = ((ret_value & 0xffff0000) >> 16);
  176. ret_value = rtl_get_bbreg(hw, ROFDM_PHYCOUNTER2, MASKDWORD);
  177. falsealm_cnt->cnt_rate_illegal = (ret_value & 0xffff);
  178. falsealm_cnt->cnt_crc8_fail = ((ret_value & 0xffff0000) >> 16);
  179. ret_value = rtl_get_bbreg(hw, ROFDM_PHYCOUNTER3, MASKDWORD);
  180. falsealm_cnt->cnt_mcs_fail = (ret_value & 0xffff);
  181. falsealm_cnt->cnt_ofdm_fail = falsealm_cnt->cnt_parity_fail +
  182. falsealm_cnt->cnt_rate_illegal +
  183. falsealm_cnt->cnt_crc8_fail + falsealm_cnt->cnt_mcs_fail;
  184. rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, BIT(14), 1);
  185. ret_value = rtl_get_bbreg(hw, RCCK0_FACOUNTERLOWER, MASKBYTE0);
  186. falsealm_cnt->cnt_cck_fail = ret_value;
  187. ret_value = rtl_get_bbreg(hw, RCCK0_FACOUNTERUPPER, MASKBYTE3);
  188. falsealm_cnt->cnt_cck_fail += (ret_value & 0xff) << 8;
  189. falsealm_cnt->cnt_all = (falsealm_cnt->cnt_parity_fail +
  190. falsealm_cnt->cnt_rate_illegal +
  191. falsealm_cnt->cnt_crc8_fail +
  192. falsealm_cnt->cnt_mcs_fail +
  193. falsealm_cnt->cnt_cck_fail);
  194. rtl_set_bbreg(hw, ROFDM1_LSTF, 0x08000000, 1);
  195. rtl_set_bbreg(hw, ROFDM1_LSTF, 0x08000000, 0);
  196. rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, 0x0000c000, 0);
  197. rtl_set_bbreg(hw, RCCK0_FALSEALARMREPORT, 0x0000c000, 2);
  198. RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE,
  199. "cnt_parity_fail = %d, cnt_rate_illegal = %d, cnt_crc8_fail = %d, cnt_mcs_fail = %d\n",
  200. falsealm_cnt->cnt_parity_fail,
  201. falsealm_cnt->cnt_rate_illegal,
  202. falsealm_cnt->cnt_crc8_fail, falsealm_cnt->cnt_mcs_fail);
  203. RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE,
  204. "cnt_ofdm_fail = %x, cnt_cck_fail = %x, cnt_all = %x\n",
  205. falsealm_cnt->cnt_ofdm_fail,
  206. falsealm_cnt->cnt_cck_fail, falsealm_cnt->cnt_all);
  207. }
  208. static void rtl92c_dm_ctrl_initgain_by_fa(struct ieee80211_hw *hw)
  209. {
  210. struct rtl_priv *rtlpriv = rtl_priv(hw);
  211. struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
  212. u8 value_igi = dm_digtable->cur_igvalue;
  213. if (rtlpriv->falsealm_cnt.cnt_all < DM_DIG_FA_TH0)
  214. value_igi--;
  215. else if (rtlpriv->falsealm_cnt.cnt_all < DM_DIG_FA_TH1)
  216. value_igi += 0;
  217. else if (rtlpriv->falsealm_cnt.cnt_all < DM_DIG_FA_TH2)
  218. value_igi++;
  219. else if (rtlpriv->falsealm_cnt.cnt_all >= DM_DIG_FA_TH2)
  220. value_igi += 2;
  221. if (value_igi > DM_DIG_FA_UPPER)
  222. value_igi = DM_DIG_FA_UPPER;
  223. else if (value_igi < DM_DIG_FA_LOWER)
  224. value_igi = DM_DIG_FA_LOWER;
  225. if (rtlpriv->falsealm_cnt.cnt_all > 10000)
  226. value_igi = 0x32;
  227. dm_digtable->cur_igvalue = value_igi;
  228. rtl8723e_dm_write_dig(hw);
  229. }
  230. static void rtl92c_dm_ctrl_initgain_by_rssi(struct ieee80211_hw *hw)
  231. {
  232. struct rtl_priv *rtlpriv = rtl_priv(hw);
  233. struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
  234. if (rtlpriv->falsealm_cnt.cnt_all > dm_digtable->fa_highthresh) {
  235. if ((dm_digtable->back_val - 2) <
  236. dm_digtable->back_range_min)
  237. dm_digtable->back_val =
  238. dm_digtable->back_range_min;
  239. else
  240. dm_digtable->back_val -= 2;
  241. } else if (rtlpriv->falsealm_cnt.cnt_all < dm_digtable->fa_lowthresh) {
  242. if ((dm_digtable->back_val + 2) >
  243. dm_digtable->back_range_max)
  244. dm_digtable->back_val =
  245. dm_digtable->back_range_max;
  246. else
  247. dm_digtable->back_val += 2;
  248. }
  249. if ((dm_digtable->rssi_val_min + 10 - dm_digtable->back_val) >
  250. dm_digtable->rx_gain_max)
  251. dm_digtable->cur_igvalue = dm_digtable->rx_gain_max;
  252. else if ((dm_digtable->rssi_val_min + 10 -
  253. dm_digtable->back_val) < dm_digtable->rx_gain_min)
  254. dm_digtable->cur_igvalue = dm_digtable->rx_gain_min;
  255. else
  256. dm_digtable->cur_igvalue = dm_digtable->rssi_val_min + 10 -
  257. dm_digtable->back_val;
  258. RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE,
  259. "rssi_val_min = %x back_val %x\n",
  260. dm_digtable->rssi_val_min, dm_digtable->back_val);
  261. rtl8723e_dm_write_dig(hw);
  262. }
  263. static void rtl8723e_dm_initial_gain_multi_sta(struct ieee80211_hw *hw)
  264. {
  265. static u8 binitialized;
  266. struct rtl_priv *rtlpriv = rtl_priv(hw);
  267. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  268. struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
  269. long rssi_strength = rtlpriv->dm.entry_min_undec_sm_pwdb;
  270. bool multi_sta = false;
  271. if (mac->opmode == NL80211_IFTYPE_ADHOC)
  272. multi_sta = true;
  273. if (!multi_sta || (dm_digtable->cursta_cstate != DIG_STA_DISCONNECT)) {
  274. binitialized = false;
  275. dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX;
  276. return;
  277. } else if (!binitialized) {
  278. binitialized = true;
  279. dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_0;
  280. dm_digtable->cur_igvalue = 0x20;
  281. rtl8723e_dm_write_dig(hw);
  282. }
  283. if (dm_digtable->curmultista_cstate == DIG_MULTISTA_CONNECT) {
  284. if ((rssi_strength < dm_digtable->rssi_lowthresh) &&
  285. (dm_digtable->dig_ext_port_stage != DIG_EXT_PORT_STAGE_1)) {
  286. if (dm_digtable->dig_ext_port_stage ==
  287. DIG_EXT_PORT_STAGE_2) {
  288. dm_digtable->cur_igvalue = 0x20;
  289. rtl8723e_dm_write_dig(hw);
  290. }
  291. dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_1;
  292. } else if (rssi_strength > dm_digtable->rssi_highthresh) {
  293. dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_2;
  294. rtl92c_dm_ctrl_initgain_by_fa(hw);
  295. }
  296. } else if (dm_digtable->dig_ext_port_stage != DIG_EXT_PORT_STAGE_0) {
  297. dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_0;
  298. dm_digtable->cur_igvalue = 0x20;
  299. rtl8723e_dm_write_dig(hw);
  300. }
  301. RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE,
  302. "curmultista_cstate = %x dig_ext_port_stage %x\n",
  303. dm_digtable->curmultista_cstate,
  304. dm_digtable->dig_ext_port_stage);
  305. }
  306. static void rtl8723e_dm_initial_gain_sta(struct ieee80211_hw *hw)
  307. {
  308. struct rtl_priv *rtlpriv = rtl_priv(hw);
  309. struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
  310. RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE,
  311. "presta_cstate = %x, cursta_cstate = %x\n",
  312. dm_digtable->presta_cstate,
  313. dm_digtable->cursta_cstate);
  314. if (dm_digtable->presta_cstate == dm_digtable->cursta_cstate ||
  315. dm_digtable->cursta_cstate == DIG_STA_BEFORE_CONNECT ||
  316. dm_digtable->cursta_cstate == DIG_STA_CONNECT) {
  317. if (dm_digtable->cursta_cstate != DIG_STA_DISCONNECT) {
  318. dm_digtable->rssi_val_min =
  319. rtl8723e_dm_initial_gain_min_pwdb(hw);
  320. rtl92c_dm_ctrl_initgain_by_rssi(hw);
  321. }
  322. } else {
  323. dm_digtable->rssi_val_min = 0;
  324. dm_digtable->dig_ext_port_stage = DIG_EXT_PORT_STAGE_MAX;
  325. dm_digtable->back_val = DM_DIG_BACKOFF_DEFAULT;
  326. dm_digtable->cur_igvalue = 0x20;
  327. dm_digtable->pre_igvalue = 0;
  328. rtl8723e_dm_write_dig(hw);
  329. }
  330. }
  331. static void rtl8723e_dm_cck_packet_detection_thresh(struct ieee80211_hw *hw)
  332. {
  333. struct rtl_priv *rtlpriv = rtl_priv(hw);
  334. struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
  335. if (dm_digtable->cursta_cstate == DIG_STA_CONNECT) {
  336. dm_digtable->rssi_val_min = rtl8723e_dm_initial_gain_min_pwdb(hw);
  337. if (dm_digtable->pre_cck_pd_state == CCK_PD_STAGE_LOWRSSI) {
  338. if (dm_digtable->rssi_val_min <= 25)
  339. dm_digtable->cur_cck_pd_state =
  340. CCK_PD_STAGE_LOWRSSI;
  341. else
  342. dm_digtable->cur_cck_pd_state =
  343. CCK_PD_STAGE_HIGHRSSI;
  344. } else {
  345. if (dm_digtable->rssi_val_min <= 20)
  346. dm_digtable->cur_cck_pd_state =
  347. CCK_PD_STAGE_LOWRSSI;
  348. else
  349. dm_digtable->cur_cck_pd_state =
  350. CCK_PD_STAGE_HIGHRSSI;
  351. }
  352. } else {
  353. dm_digtable->cur_cck_pd_state = CCK_PD_STAGE_MAX;
  354. }
  355. if (dm_digtable->pre_cck_pd_state != dm_digtable->cur_cck_pd_state) {
  356. if (dm_digtable->cur_cck_pd_state == CCK_PD_STAGE_LOWRSSI) {
  357. if (rtlpriv->falsealm_cnt.cnt_cck_fail > 800)
  358. dm_digtable->cur_cck_fa_state =
  359. CCK_FA_STAGE_HIGH;
  360. else
  361. dm_digtable->cur_cck_fa_state =
  362. CCK_FA_STAGE_LOW;
  363. if (dm_digtable->pre_cck_fa_state !=
  364. dm_digtable->cur_cck_fa_state) {
  365. if (dm_digtable->cur_cck_fa_state ==
  366. CCK_FA_STAGE_LOW)
  367. rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2,
  368. 0x83);
  369. else
  370. rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2,
  371. 0xcd);
  372. dm_digtable->pre_cck_fa_state =
  373. dm_digtable->cur_cck_fa_state;
  374. }
  375. rtl_set_bbreg(hw, RCCK0_SYSTEM, MASKBYTE1, 0x40);
  376. } else {
  377. rtl_set_bbreg(hw, RCCK0_CCA, MASKBYTE2, 0xcd);
  378. rtl_set_bbreg(hw, RCCK0_SYSTEM, MASKBYTE1, 0x47);
  379. }
  380. dm_digtable->pre_cck_pd_state = dm_digtable->cur_cck_pd_state;
  381. }
  382. RT_TRACE(rtlpriv, COMP_DIG, DBG_TRACE,
  383. "CCKPDStage=%x\n", dm_digtable->cur_cck_pd_state);
  384. }
  385. static void rtl8723e_dm_ctrl_initgain_by_twoport(struct ieee80211_hw *hw)
  386. {
  387. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  388. struct rtl_priv *rtlpriv = rtl_priv(hw);
  389. struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
  390. if (mac->act_scanning)
  391. return;
  392. if (mac->link_state >= MAC80211_LINKED)
  393. dm_digtable->cursta_cstate = DIG_STA_CONNECT;
  394. else
  395. dm_digtable->cursta_cstate = DIG_STA_DISCONNECT;
  396. rtl8723e_dm_initial_gain_sta(hw);
  397. rtl8723e_dm_initial_gain_multi_sta(hw);
  398. rtl8723e_dm_cck_packet_detection_thresh(hw);
  399. dm_digtable->presta_cstate = dm_digtable->cursta_cstate;
  400. }
  401. static void rtl8723e_dm_dig(struct ieee80211_hw *hw)
  402. {
  403. struct rtl_priv *rtlpriv = rtl_priv(hw);
  404. struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
  405. if (!rtlpriv->dm.dm_initialgain_enable)
  406. return;
  407. if (!dm_digtable->dig_enable_flag)
  408. return;
  409. rtl8723e_dm_ctrl_initgain_by_twoport(hw);
  410. }
  411. static void rtl8723e_dm_dynamic_txpower(struct ieee80211_hw *hw)
  412. {
  413. struct rtl_priv *rtlpriv = rtl_priv(hw);
  414. struct rtl_phy *rtlphy = &(rtlpriv->phy);
  415. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  416. long undec_sm_pwdb;
  417. if (!rtlpriv->dm.dynamic_txpower_enable)
  418. return;
  419. if (rtlpriv->dm.dm_flag & HAL_DM_HIPWR_DISABLE) {
  420. rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL;
  421. return;
  422. }
  423. if ((mac->link_state < MAC80211_LINKED) &&
  424. (rtlpriv->dm.entry_min_undec_sm_pwdb == 0)) {
  425. RT_TRACE(rtlpriv, COMP_POWER, DBG_TRACE,
  426. "Not connected to any\n");
  427. rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL;
  428. rtlpriv->dm.last_dtp_lvl = TXHIGHPWRLEVEL_NORMAL;
  429. return;
  430. }
  431. if (mac->link_state >= MAC80211_LINKED) {
  432. if (mac->opmode == NL80211_IFTYPE_ADHOC) {
  433. undec_sm_pwdb =
  434. rtlpriv->dm.entry_min_undec_sm_pwdb;
  435. RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
  436. "AP Client PWDB = 0x%lx\n",
  437. undec_sm_pwdb);
  438. } else {
  439. undec_sm_pwdb =
  440. rtlpriv->dm.undec_sm_pwdb;
  441. RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
  442. "STA Default Port PWDB = 0x%lx\n",
  443. undec_sm_pwdb);
  444. }
  445. } else {
  446. undec_sm_pwdb =
  447. rtlpriv->dm.entry_min_undec_sm_pwdb;
  448. RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
  449. "AP Ext Port PWDB = 0x%lx\n",
  450. undec_sm_pwdb);
  451. }
  452. if (undec_sm_pwdb >= TX_POWER_NEAR_FIELD_THRESH_LVL2) {
  453. rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1;
  454. RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
  455. "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n");
  456. } else if ((undec_sm_pwdb <
  457. (TX_POWER_NEAR_FIELD_THRESH_LVL2 - 3)) &&
  458. (undec_sm_pwdb >=
  459. TX_POWER_NEAR_FIELD_THRESH_LVL1)) {
  460. rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_LEVEL1;
  461. RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
  462. "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n");
  463. } else if (undec_sm_pwdb <
  464. (TX_POWER_NEAR_FIELD_THRESH_LVL1 - 5)) {
  465. rtlpriv->dm.dynamic_txhighpower_lvl = TXHIGHPWRLEVEL_NORMAL;
  466. RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
  467. "TXHIGHPWRLEVEL_NORMAL\n");
  468. }
  469. if (rtlpriv->dm.dynamic_txhighpower_lvl != rtlpriv->dm.last_dtp_lvl) {
  470. RT_TRACE(rtlpriv, COMP_POWER, DBG_LOUD,
  471. "PHY_SetTxPowerLevel8192S() Channel = %d\n",
  472. rtlphy->current_channel);
  473. rtl8723e_phy_set_txpower_level(hw, rtlphy->current_channel);
  474. }
  475. rtlpriv->dm.last_dtp_lvl = rtlpriv->dm.dynamic_txhighpower_lvl;
  476. }
  477. void rtl8723e_dm_write_dig(struct ieee80211_hw *hw)
  478. {
  479. struct rtl_priv *rtlpriv = rtl_priv(hw);
  480. struct dig_t *dm_digtable = &rtlpriv->dm_digtable;
  481. RT_TRACE(rtlpriv, COMP_DIG, DBG_LOUD,
  482. "cur_igvalue = 0x%x, pre_igvalue = 0x%x, back_val = %d\n",
  483. dm_digtable->cur_igvalue, dm_digtable->pre_igvalue,
  484. dm_digtable->back_val);
  485. if (dm_digtable->pre_igvalue != dm_digtable->cur_igvalue) {
  486. rtl_set_bbreg(hw, ROFDM0_XAAGCCORE1, 0x7f,
  487. dm_digtable->cur_igvalue);
  488. rtl_set_bbreg(hw, ROFDM0_XBAGCCORE1, 0x7f,
  489. dm_digtable->cur_igvalue);
  490. dm_digtable->pre_igvalue = dm_digtable->cur_igvalue;
  491. }
  492. }
  493. static void rtl8723e_dm_pwdb_monitor(struct ieee80211_hw *hw)
  494. {
  495. }
  496. static void rtl8723e_dm_check_edca_turbo(struct ieee80211_hw *hw)
  497. {
  498. struct rtl_priv *rtlpriv = rtl_priv(hw);
  499. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  500. static u64 last_txok_cnt;
  501. static u64 last_rxok_cnt;
  502. static u32 last_bt_edca_ul;
  503. static u32 last_bt_edca_dl;
  504. u64 cur_txok_cnt = 0;
  505. u64 cur_rxok_cnt = 0;
  506. u32 edca_be_ul = 0x5ea42b;
  507. u32 edca_be_dl = 0x5ea42b;
  508. bool bt_change_edca = false;
  509. if ((last_bt_edca_ul != rtlpriv->btcoexist.bt_edca_ul) ||
  510. (last_bt_edca_dl != rtlpriv->btcoexist.bt_edca_dl)) {
  511. rtlpriv->dm.current_turbo_edca = false;
  512. last_bt_edca_ul = rtlpriv->btcoexist.bt_edca_ul;
  513. last_bt_edca_dl = rtlpriv->btcoexist.bt_edca_dl;
  514. }
  515. if (rtlpriv->btcoexist.bt_edca_ul != 0) {
  516. edca_be_ul = rtlpriv->btcoexist.bt_edca_ul;
  517. bt_change_edca = true;
  518. }
  519. if (rtlpriv->btcoexist.bt_edca_dl != 0) {
  520. edca_be_ul = rtlpriv->btcoexist.bt_edca_dl;
  521. bt_change_edca = true;
  522. }
  523. if (mac->link_state != MAC80211_LINKED) {
  524. rtlpriv->dm.current_turbo_edca = false;
  525. return;
  526. }
  527. if ((bt_change_edca) || ((!rtlpriv->dm.is_any_nonbepkts) &&
  528. (!rtlpriv->dm.disable_framebursting))) {
  529. cur_txok_cnt = rtlpriv->stats.txbytesunicast - last_txok_cnt;
  530. cur_rxok_cnt = rtlpriv->stats.rxbytesunicast - last_rxok_cnt;
  531. if (cur_rxok_cnt > 4 * cur_txok_cnt) {
  532. if (!rtlpriv->dm.is_cur_rdlstate ||
  533. !rtlpriv->dm.current_turbo_edca) {
  534. rtl_write_dword(rtlpriv,
  535. REG_EDCA_BE_PARAM,
  536. edca_be_dl);
  537. rtlpriv->dm.is_cur_rdlstate = true;
  538. }
  539. } else {
  540. if (rtlpriv->dm.is_cur_rdlstate ||
  541. !rtlpriv->dm.current_turbo_edca) {
  542. rtl_write_dword(rtlpriv,
  543. REG_EDCA_BE_PARAM,
  544. edca_be_ul);
  545. rtlpriv->dm.is_cur_rdlstate = false;
  546. }
  547. }
  548. rtlpriv->dm.current_turbo_edca = true;
  549. } else {
  550. if (rtlpriv->dm.current_turbo_edca) {
  551. u8 tmp = AC0_BE;
  552. rtlpriv->cfg->ops->set_hw_reg(hw,
  553. HW_VAR_AC_PARAM,
  554. (u8 *)(&tmp));
  555. rtlpriv->dm.current_turbo_edca = false;
  556. }
  557. }
  558. rtlpriv->dm.is_any_nonbepkts = false;
  559. last_txok_cnt = rtlpriv->stats.txbytesunicast;
  560. last_rxok_cnt = rtlpriv->stats.rxbytesunicast;
  561. }
  562. static void rtl8723e_dm_initialize_txpower_tracking_thermalmeter(
  563. struct ieee80211_hw *hw)
  564. {
  565. struct rtl_priv *rtlpriv = rtl_priv(hw);
  566. rtlpriv->dm.txpower_tracking = true;
  567. rtlpriv->dm.txpower_trackinginit = false;
  568. RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_LOUD,
  569. "pMgntInfo->txpower_tracking = %d\n",
  570. rtlpriv->dm.txpower_tracking);
  571. }
  572. static void rtl8723e_dm_initialize_txpower_tracking(struct ieee80211_hw *hw)
  573. {
  574. rtl8723e_dm_initialize_txpower_tracking_thermalmeter(hw);
  575. }
  576. void rtl8723e_dm_check_txpower_tracking(struct ieee80211_hw *hw)
  577. {
  578. return;
  579. }
  580. void rtl8723e_dm_init_rate_adaptive_mask(struct ieee80211_hw *hw)
  581. {
  582. struct rtl_priv *rtlpriv = rtl_priv(hw);
  583. struct rate_adaptive *p_ra = &(rtlpriv->ra);
  584. p_ra->ratr_state = DM_RATR_STA_INIT;
  585. p_ra->pre_ratr_state = DM_RATR_STA_INIT;
  586. if (rtlpriv->dm.dm_type == DM_TYPE_BYDRIVER)
  587. rtlpriv->dm.useramask = true;
  588. else
  589. rtlpriv->dm.useramask = false;
  590. }
  591. void rtl8723e_dm_rf_saving(struct ieee80211_hw *hw, u8 bforce_in_normal)
  592. {
  593. struct rtl_priv *rtlpriv = rtl_priv(hw);
  594. struct ps_t *dm_pstable = &rtlpriv->dm_pstable;
  595. static u8 initialize;
  596. static u32 reg_874, reg_c70, reg_85c, reg_a74;
  597. if (initialize == 0) {
  598. reg_874 = (rtl_get_bbreg(hw, RFPGA0_XCD_RFINTERFACESW,
  599. MASKDWORD) & 0x1CC000) >> 14;
  600. reg_c70 = (rtl_get_bbreg(hw, ROFDM0_AGCPARAMETER1,
  601. MASKDWORD) & BIT(3)) >> 3;
  602. reg_85c = (rtl_get_bbreg(hw, RFPGA0_XCD_SWITCHCONTROL,
  603. MASKDWORD) & 0xFF000000) >> 24;
  604. reg_a74 = (rtl_get_bbreg(hw, 0xa74, MASKDWORD) & 0xF000) >> 12;
  605. initialize = 1;
  606. }
  607. if (!bforce_in_normal) {
  608. if (dm_pstable->rssi_val_min != 0) {
  609. if (dm_pstable->pre_rfstate == RF_NORMAL) {
  610. if (dm_pstable->rssi_val_min >= 30)
  611. dm_pstable->cur_rfstate = RF_SAVE;
  612. else
  613. dm_pstable->cur_rfstate = RF_NORMAL;
  614. } else {
  615. if (dm_pstable->rssi_val_min <= 25)
  616. dm_pstable->cur_rfstate = RF_NORMAL;
  617. else
  618. dm_pstable->cur_rfstate = RF_SAVE;
  619. }
  620. } else {
  621. dm_pstable->cur_rfstate = RF_MAX;
  622. }
  623. } else {
  624. dm_pstable->cur_rfstate = RF_NORMAL;
  625. }
  626. if (dm_pstable->pre_rfstate != dm_pstable->cur_rfstate) {
  627. if (dm_pstable->cur_rfstate == RF_SAVE) {
  628. rtl_set_bbreg(hw, RFPGA0_XCD_RFINTERFACESW,
  629. BIT(5), 0x1);
  630. rtl_set_bbreg(hw, RFPGA0_XCD_RFINTERFACESW,
  631. 0x1C0000, 0x2);
  632. rtl_set_bbreg(hw, ROFDM0_AGCPARAMETER1, BIT(3), 0);
  633. rtl_set_bbreg(hw, RFPGA0_XCD_SWITCHCONTROL,
  634. 0xFF000000, 0x63);
  635. rtl_set_bbreg(hw, RFPGA0_XCD_RFINTERFACESW,
  636. 0xC000, 0x2);
  637. rtl_set_bbreg(hw, 0xa74, 0xF000, 0x3);
  638. rtl_set_bbreg(hw, 0x818, BIT(28), 0x0);
  639. rtl_set_bbreg(hw, 0x818, BIT(28), 0x1);
  640. } else {
  641. rtl_set_bbreg(hw, RFPGA0_XCD_RFINTERFACESW,
  642. 0x1CC000, reg_874);
  643. rtl_set_bbreg(hw, ROFDM0_AGCPARAMETER1, BIT(3),
  644. reg_c70);
  645. rtl_set_bbreg(hw, RFPGA0_XCD_SWITCHCONTROL, 0xFF000000,
  646. reg_85c);
  647. rtl_set_bbreg(hw, 0xa74, 0xF000, reg_a74);
  648. rtl_set_bbreg(hw, 0x818, BIT(28), 0x0);
  649. rtl_set_bbreg(hw, RFPGA0_XCD_RFINTERFACESW,
  650. BIT(5), 0x0);
  651. }
  652. dm_pstable->pre_rfstate = dm_pstable->cur_rfstate;
  653. }
  654. }
  655. static void rtl8723e_dm_dynamic_bb_powersaving(struct ieee80211_hw *hw)
  656. {
  657. struct rtl_priv *rtlpriv = rtl_priv(hw);
  658. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  659. struct ps_t *dm_pstable = &rtlpriv->dm_pstable;
  660. if (((mac->link_state == MAC80211_NOLINK)) &&
  661. (rtlpriv->dm.entry_min_undec_sm_pwdb == 0)) {
  662. dm_pstable->rssi_val_min = 0;
  663. RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD,
  664. "Not connected to any\n");
  665. }
  666. if (mac->link_state == MAC80211_LINKED) {
  667. if (mac->opmode == NL80211_IFTYPE_ADHOC) {
  668. dm_pstable->rssi_val_min =
  669. rtlpriv->dm.entry_min_undec_sm_pwdb;
  670. RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD,
  671. "AP Client PWDB = 0x%lx\n",
  672. dm_pstable->rssi_val_min);
  673. } else {
  674. dm_pstable->rssi_val_min =
  675. rtlpriv->dm.undec_sm_pwdb;
  676. RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD,
  677. "STA Default Port PWDB = 0x%lx\n",
  678. dm_pstable->rssi_val_min);
  679. }
  680. } else {
  681. dm_pstable->rssi_val_min =
  682. rtlpriv->dm.entry_min_undec_sm_pwdb;
  683. RT_TRACE(rtlpriv, DBG_LOUD, DBG_LOUD,
  684. "AP Ext Port PWDB = 0x%lx\n",
  685. dm_pstable->rssi_val_min);
  686. }
  687. rtl8723e_dm_rf_saving(hw, false);
  688. }
  689. void rtl8723e_dm_init(struct ieee80211_hw *hw)
  690. {
  691. struct rtl_priv *rtlpriv = rtl_priv(hw);
  692. rtlpriv->dm.dm_type = DM_TYPE_BYDRIVER;
  693. rtl_dm_diginit(hw, 0x20);
  694. rtl8723_dm_init_dynamic_txpower(hw);
  695. rtl8723_dm_init_edca_turbo(hw);
  696. rtl8723e_dm_init_rate_adaptive_mask(hw);
  697. rtl8723e_dm_initialize_txpower_tracking(hw);
  698. rtl8723_dm_init_dynamic_bb_powersaving(hw);
  699. }
  700. void rtl8723e_dm_watchdog(struct ieee80211_hw *hw)
  701. {
  702. struct rtl_priv *rtlpriv = rtl_priv(hw);
  703. struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
  704. bool fw_current_inpsmode = false;
  705. bool fw_ps_awake = true;
  706. rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_FW_PSMODE_STATUS,
  707. (u8 *)(&fw_current_inpsmode));
  708. rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_FWLPS_RF_ON,
  709. (u8 *)(&fw_ps_awake));
  710. if (ppsc->p2p_ps_info.p2p_ps_mode)
  711. fw_ps_awake = false;
  712. spin_lock(&rtlpriv->locks.rf_ps_lock);
  713. if ((ppsc->rfpwr_state == ERFON) &&
  714. ((!fw_current_inpsmode) && fw_ps_awake) &&
  715. (!ppsc->rfchange_inprogress)) {
  716. rtl8723e_dm_pwdb_monitor(hw);
  717. rtl8723e_dm_dig(hw);
  718. rtl8723e_dm_false_alarm_counter_statistics(hw);
  719. rtl8723e_dm_dynamic_bb_powersaving(hw);
  720. rtl8723e_dm_dynamic_txpower(hw);
  721. rtl8723e_dm_check_txpower_tracking(hw);
  722. /* rtl92c_dm_refresh_rate_adaptive_mask(hw); */
  723. rtl8723e_dm_bt_coexist(hw);
  724. rtl8723e_dm_check_edca_turbo(hw);
  725. }
  726. spin_unlock(&rtlpriv->locks.rf_ps_lock);
  727. if (rtlpriv->btcoexist.init_set)
  728. rtl_write_byte(rtlpriv, 0x76e, 0xc);
  729. }
  730. static void rtl8723e_dm_init_bt_coexist(struct ieee80211_hw *hw)
  731. {
  732. struct rtl_priv *rtlpriv = rtl_priv(hw);
  733. rtlpriv->btcoexist.bt_rfreg_origin_1e
  734. = rtl_get_rfreg(hw, (enum radio_path)0, RF_RCK1, 0xfffff);
  735. rtlpriv->btcoexist.bt_rfreg_origin_1f
  736. = rtl_get_rfreg(hw, (enum radio_path)0, RF_RCK2, 0xf0);
  737. rtlpriv->btcoexist.cstate = 0;
  738. rtlpriv->btcoexist.previous_state = 0;
  739. rtlpriv->btcoexist.cstate_h = 0;
  740. rtlpriv->btcoexist.previous_state_h = 0;
  741. rtlpriv->btcoexist.lps_counter = 0;
  742. /* Enable counter statistics */
  743. rtl_write_byte(rtlpriv, 0x76e, 0x4);
  744. rtl_write_byte(rtlpriv, 0x778, 0x3);
  745. rtl_write_byte(rtlpriv, 0x40, 0x20);
  746. rtlpriv->btcoexist.init_set = true;
  747. }
  748. void rtl8723e_dm_bt_coexist(struct ieee80211_hw *hw)
  749. {
  750. struct rtl_priv *rtlpriv = rtl_priv(hw);
  751. u8 tmp_byte = 0;
  752. if (!rtlpriv->btcoexist.bt_coexistence) {
  753. RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
  754. "[DM]{BT], BT not exist!!\n");
  755. return;
  756. }
  757. if (!rtlpriv->btcoexist.init_set) {
  758. RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
  759. "[DM][BT], rtl8723e_dm_bt_coexist()\n");
  760. rtl8723e_dm_init_bt_coexist(hw);
  761. }
  762. tmp_byte = rtl_read_byte(rtlpriv, 0x40);
  763. RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_LOUD,
  764. "[DM][BT], 0x40 is 0x%x\n", tmp_byte);
  765. RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_DMESG,
  766. "[DM][BT], bt_dm_coexist start\n");
  767. rtl8723e_dm_bt_coexist_8723(hw);
  768. }