hw.c 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433
  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 "../efuse.h"
  27. #include "../base.h"
  28. #include "../regd.h"
  29. #include "../cam.h"
  30. #include "../ps.h"
  31. #include "../pci.h"
  32. #include "reg.h"
  33. #include "def.h"
  34. #include "phy.h"
  35. #include "../rtl8723com/phy_common.h"
  36. #include "dm.h"
  37. #include "../rtl8723com/dm_common.h"
  38. #include "fw.h"
  39. #include "../rtl8723com/fw_common.h"
  40. #include "led.h"
  41. #include "hw.h"
  42. #include "../pwrseqcmd.h"
  43. #include "pwrseq.h"
  44. #include "btc.h"
  45. #define LLT_CONFIG 5
  46. static void _rtl8723e_set_bcn_ctrl_reg(struct ieee80211_hw *hw,
  47. u8 set_bits, u8 clear_bits)
  48. {
  49. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  50. struct rtl_priv *rtlpriv = rtl_priv(hw);
  51. rtlpci->reg_bcn_ctrl_val |= set_bits;
  52. rtlpci->reg_bcn_ctrl_val &= ~clear_bits;
  53. rtl_write_byte(rtlpriv, REG_BCN_CTRL, (u8) rtlpci->reg_bcn_ctrl_val);
  54. }
  55. static void _rtl8723e_stop_tx_beacon(struct ieee80211_hw *hw)
  56. {
  57. struct rtl_priv *rtlpriv = rtl_priv(hw);
  58. u8 tmp1byte;
  59. tmp1byte = rtl_read_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2);
  60. rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, tmp1byte & (~BIT(6)));
  61. rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 1, 0x64);
  62. tmp1byte = rtl_read_byte(rtlpriv, REG_TBTT_PROHIBIT + 2);
  63. tmp1byte &= ~(BIT(0));
  64. rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 2, tmp1byte);
  65. }
  66. static void _rtl8723e_resume_tx_beacon(struct ieee80211_hw *hw)
  67. {
  68. struct rtl_priv *rtlpriv = rtl_priv(hw);
  69. u8 tmp1byte;
  70. tmp1byte = rtl_read_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2);
  71. rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2, tmp1byte | BIT(6));
  72. rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 1, 0xff);
  73. tmp1byte = rtl_read_byte(rtlpriv, REG_TBTT_PROHIBIT + 2);
  74. tmp1byte |= BIT(1);
  75. rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 2, tmp1byte);
  76. }
  77. static void _rtl8723e_enable_bcn_sub_func(struct ieee80211_hw *hw)
  78. {
  79. _rtl8723e_set_bcn_ctrl_reg(hw, 0, BIT(1));
  80. }
  81. static void _rtl8723e_disable_bcn_sub_func(struct ieee80211_hw *hw)
  82. {
  83. _rtl8723e_set_bcn_ctrl_reg(hw, BIT(1), 0);
  84. }
  85. void rtl8723e_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
  86. {
  87. struct rtl_priv *rtlpriv = rtl_priv(hw);
  88. struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
  89. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  90. switch (variable) {
  91. case HW_VAR_RCR:
  92. *((u32 *)(val)) = rtlpci->receive_config;
  93. break;
  94. case HW_VAR_RF_STATE:
  95. *((enum rf_pwrstate *)(val)) = ppsc->rfpwr_state;
  96. break;
  97. case HW_VAR_FWLPS_RF_ON:{
  98. enum rf_pwrstate rfstate;
  99. u32 val_rcr;
  100. rtlpriv->cfg->ops->get_hw_reg(hw,
  101. HW_VAR_RF_STATE,
  102. (u8 *)(&rfstate));
  103. if (rfstate == ERFOFF) {
  104. *((bool *)(val)) = true;
  105. } else {
  106. val_rcr = rtl_read_dword(rtlpriv, REG_RCR);
  107. val_rcr &= 0x00070000;
  108. if (val_rcr)
  109. *((bool *)(val)) = false;
  110. else
  111. *((bool *)(val)) = true;
  112. }
  113. break;
  114. }
  115. case HW_VAR_FW_PSMODE_STATUS:
  116. *((bool *)(val)) = ppsc->fw_current_inpsmode;
  117. break;
  118. case HW_VAR_CORRECT_TSF:{
  119. u64 tsf;
  120. u32 *ptsf_low = (u32 *)&tsf;
  121. u32 *ptsf_high = ((u32 *)&tsf) + 1;
  122. *ptsf_high = rtl_read_dword(rtlpriv, (REG_TSFTR + 4));
  123. *ptsf_low = rtl_read_dword(rtlpriv, REG_TSFTR);
  124. *((u64 *)(val)) = tsf;
  125. break;
  126. }
  127. case HAL_DEF_WOWLAN:
  128. break;
  129. default:
  130. RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
  131. "switch case %#x not processed\n", variable);
  132. break;
  133. }
  134. }
  135. void rtl8723e_set_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val)
  136. {
  137. struct rtl_priv *rtlpriv = rtl_priv(hw);
  138. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  139. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  140. struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
  141. struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
  142. u8 idx;
  143. switch (variable) {
  144. case HW_VAR_ETHER_ADDR:{
  145. for (idx = 0; idx < ETH_ALEN; idx++) {
  146. rtl_write_byte(rtlpriv, (REG_MACID + idx),
  147. val[idx]);
  148. }
  149. break;
  150. }
  151. case HW_VAR_BASIC_RATE:{
  152. u16 b_rate_cfg = ((u16 *)val)[0];
  153. u8 rate_index = 0;
  154. b_rate_cfg = b_rate_cfg & 0x15f;
  155. b_rate_cfg |= 0x01;
  156. rtl_write_byte(rtlpriv, REG_RRSR, b_rate_cfg & 0xff);
  157. rtl_write_byte(rtlpriv, REG_RRSR + 1,
  158. (b_rate_cfg >> 8) & 0xff);
  159. while (b_rate_cfg > 0x1) {
  160. b_rate_cfg = (b_rate_cfg >> 1);
  161. rate_index++;
  162. }
  163. rtl_write_byte(rtlpriv, REG_INIRTS_RATE_SEL,
  164. rate_index);
  165. break;
  166. }
  167. case HW_VAR_BSSID:{
  168. for (idx = 0; idx < ETH_ALEN; idx++) {
  169. rtl_write_byte(rtlpriv, (REG_BSSID + idx),
  170. val[idx]);
  171. }
  172. break;
  173. }
  174. case HW_VAR_SIFS:{
  175. rtl_write_byte(rtlpriv, REG_SIFS_CTX + 1, val[0]);
  176. rtl_write_byte(rtlpriv, REG_SIFS_TRX + 1, val[1]);
  177. rtl_write_byte(rtlpriv, REG_SPEC_SIFS + 1, val[0]);
  178. rtl_write_byte(rtlpriv, REG_MAC_SPEC_SIFS + 1, val[0]);
  179. if (!mac->ht_enable)
  180. rtl_write_word(rtlpriv, REG_RESP_SIFS_OFDM,
  181. 0x0e0e);
  182. else
  183. rtl_write_word(rtlpriv, REG_RESP_SIFS_OFDM,
  184. *((u16 *)val));
  185. break;
  186. }
  187. case HW_VAR_SLOT_TIME:{
  188. u8 e_aci;
  189. RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
  190. "HW_VAR_SLOT_TIME %x\n", val[0]);
  191. rtl_write_byte(rtlpriv, REG_SLOT, val[0]);
  192. for (e_aci = 0; e_aci < AC_MAX; e_aci++) {
  193. rtlpriv->cfg->ops->set_hw_reg(hw,
  194. HW_VAR_AC_PARAM,
  195. (u8 *)(&e_aci));
  196. }
  197. break;
  198. }
  199. case HW_VAR_ACK_PREAMBLE:{
  200. u8 reg_tmp;
  201. u8 short_preamble = (bool)(*(u8 *)val);
  202. reg_tmp = (mac->cur_40_prime_sc) << 5;
  203. if (short_preamble)
  204. reg_tmp |= 0x80;
  205. rtl_write_byte(rtlpriv, REG_RRSR + 2, reg_tmp);
  206. break;
  207. }
  208. case HW_VAR_AMPDU_MIN_SPACE:{
  209. u8 min_spacing_to_set;
  210. u8 sec_min_space;
  211. min_spacing_to_set = *((u8 *)val);
  212. if (min_spacing_to_set <= 7) {
  213. sec_min_space = 0;
  214. if (min_spacing_to_set < sec_min_space)
  215. min_spacing_to_set = sec_min_space;
  216. mac->min_space_cfg = ((mac->min_space_cfg &
  217. 0xf8) |
  218. min_spacing_to_set);
  219. *val = min_spacing_to_set;
  220. RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
  221. "Set HW_VAR_AMPDU_MIN_SPACE: %#x\n",
  222. mac->min_space_cfg);
  223. rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE,
  224. mac->min_space_cfg);
  225. }
  226. break;
  227. }
  228. case HW_VAR_SHORTGI_DENSITY:{
  229. u8 density_to_set;
  230. density_to_set = *((u8 *)val);
  231. mac->min_space_cfg |= (density_to_set << 3);
  232. RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
  233. "Set HW_VAR_SHORTGI_DENSITY: %#x\n",
  234. mac->min_space_cfg);
  235. rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE,
  236. mac->min_space_cfg);
  237. break;
  238. }
  239. case HW_VAR_AMPDU_FACTOR:{
  240. u8 regtoset_normal[4] = { 0x41, 0xa8, 0x72, 0xb9 };
  241. u8 regtoset_bt[4] = {0x31, 0x74, 0x42, 0x97};
  242. u8 factor_toset;
  243. u8 *p_regtoset = NULL;
  244. u8 index = 0;
  245. if ((rtlpriv->btcoexist.bt_coexistence) &&
  246. (rtlpriv->btcoexist.bt_coexist_type ==
  247. BT_CSR_BC4))
  248. p_regtoset = regtoset_bt;
  249. else
  250. p_regtoset = regtoset_normal;
  251. factor_toset = *((u8 *)val);
  252. if (factor_toset <= 3) {
  253. factor_toset = (1 << (factor_toset + 2));
  254. if (factor_toset > 0xf)
  255. factor_toset = 0xf;
  256. for (index = 0; index < 4; index++) {
  257. if ((p_regtoset[index] & 0xf0) >
  258. (factor_toset << 4))
  259. p_regtoset[index] =
  260. (p_regtoset[index] & 0x0f) |
  261. (factor_toset << 4);
  262. if ((p_regtoset[index] & 0x0f) >
  263. factor_toset)
  264. p_regtoset[index] =
  265. (p_regtoset[index] & 0xf0) |
  266. (factor_toset);
  267. rtl_write_byte(rtlpriv,
  268. (REG_AGGLEN_LMT + index),
  269. p_regtoset[index]);
  270. }
  271. RT_TRACE(rtlpriv, COMP_MLME, DBG_LOUD,
  272. "Set HW_VAR_AMPDU_FACTOR: %#x\n",
  273. factor_toset);
  274. }
  275. break;
  276. }
  277. case HW_VAR_AC_PARAM:{
  278. u8 e_aci = *((u8 *)val);
  279. rtl8723_dm_init_edca_turbo(hw);
  280. if (rtlpci->acm_method != EACMWAY2_SW)
  281. rtlpriv->cfg->ops->set_hw_reg(hw,
  282. HW_VAR_ACM_CTRL,
  283. (u8 *)(&e_aci));
  284. break;
  285. }
  286. case HW_VAR_ACM_CTRL:{
  287. u8 e_aci = *((u8 *)val);
  288. union aci_aifsn *p_aci_aifsn =
  289. (union aci_aifsn *)(&mac->ac[0].aifs);
  290. u8 acm = p_aci_aifsn->f.acm;
  291. u8 acm_ctrl = rtl_read_byte(rtlpriv, REG_ACMHWCTRL);
  292. acm_ctrl =
  293. acm_ctrl | ((rtlpci->acm_method == 2) ? 0x0 : 0x1);
  294. if (acm) {
  295. switch (e_aci) {
  296. case AC0_BE:
  297. acm_ctrl |= ACMHW_BEQEN;
  298. break;
  299. case AC2_VI:
  300. acm_ctrl |= ACMHW_VIQEN;
  301. break;
  302. case AC3_VO:
  303. acm_ctrl |= ACMHW_VOQEN;
  304. break;
  305. default:
  306. RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
  307. "HW_VAR_ACM_CTRL acm set failed: eACI is %d\n",
  308. acm);
  309. break;
  310. }
  311. } else {
  312. switch (e_aci) {
  313. case AC0_BE:
  314. acm_ctrl &= (~ACMHW_BEQEN);
  315. break;
  316. case AC2_VI:
  317. acm_ctrl &= (~ACMHW_VIQEN);
  318. break;
  319. case AC3_VO:
  320. acm_ctrl &= (~ACMHW_VOQEN);
  321. break;
  322. default:
  323. RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
  324. "switch case %#x not processed\n",
  325. e_aci);
  326. break;
  327. }
  328. }
  329. RT_TRACE(rtlpriv, COMP_QOS, DBG_TRACE,
  330. "SetHwReg8190pci(): [HW_VAR_ACM_CTRL] Write 0x%X\n",
  331. acm_ctrl);
  332. rtl_write_byte(rtlpriv, REG_ACMHWCTRL, acm_ctrl);
  333. break;
  334. }
  335. case HW_VAR_RCR:{
  336. rtl_write_dword(rtlpriv, REG_RCR, ((u32 *)(val))[0]);
  337. rtlpci->receive_config = ((u32 *)(val))[0];
  338. break;
  339. }
  340. case HW_VAR_RETRY_LIMIT:{
  341. u8 retry_limit = ((u8 *)(val))[0];
  342. rtl_write_word(rtlpriv, REG_RL,
  343. retry_limit << RETRY_LIMIT_SHORT_SHIFT |
  344. retry_limit << RETRY_LIMIT_LONG_SHIFT);
  345. break;
  346. }
  347. case HW_VAR_DUAL_TSF_RST:
  348. rtl_write_byte(rtlpriv, REG_DUAL_TSF_RST, (BIT(0) | BIT(1)));
  349. break;
  350. case HW_VAR_EFUSE_BYTES:
  351. rtlefuse->efuse_usedbytes = *((u16 *)val);
  352. break;
  353. case HW_VAR_EFUSE_USAGE:
  354. rtlefuse->efuse_usedpercentage = *((u8 *)val);
  355. break;
  356. case HW_VAR_IO_CMD:
  357. rtl8723e_phy_set_io_cmd(hw, (*(enum io_type *)val));
  358. break;
  359. case HW_VAR_WPA_CONFIG:
  360. rtl_write_byte(rtlpriv, REG_SECCFG, *((u8 *)val));
  361. break;
  362. case HW_VAR_SET_RPWM:{
  363. u8 rpwm_val;
  364. rpwm_val = rtl_read_byte(rtlpriv, REG_PCIE_HRPWM);
  365. udelay(1);
  366. if (rpwm_val & BIT(7)) {
  367. rtl_write_byte(rtlpriv, REG_PCIE_HRPWM,
  368. (*(u8 *)val));
  369. } else {
  370. rtl_write_byte(rtlpriv, REG_PCIE_HRPWM,
  371. ((*(u8 *)val) | BIT(7)));
  372. }
  373. break;
  374. }
  375. case HW_VAR_H2C_FW_PWRMODE:{
  376. u8 psmode = (*(u8 *)val);
  377. if (psmode != FW_PS_ACTIVE_MODE)
  378. rtl8723e_dm_rf_saving(hw, true);
  379. rtl8723e_set_fw_pwrmode_cmd(hw, (*(u8 *)val));
  380. break;
  381. }
  382. case HW_VAR_FW_PSMODE_STATUS:
  383. ppsc->fw_current_inpsmode = *((bool *)val);
  384. break;
  385. case HW_VAR_H2C_FW_JOINBSSRPT:{
  386. u8 mstatus = (*(u8 *)val);
  387. u8 tmp_regcr, tmp_reg422;
  388. bool b_recover = false;
  389. if (mstatus == RT_MEDIA_CONNECT) {
  390. rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_AID,
  391. NULL);
  392. tmp_regcr = rtl_read_byte(rtlpriv, REG_CR + 1);
  393. rtl_write_byte(rtlpriv, REG_CR + 1,
  394. (tmp_regcr | BIT(0)));
  395. _rtl8723e_set_bcn_ctrl_reg(hw, 0, BIT(3));
  396. _rtl8723e_set_bcn_ctrl_reg(hw, BIT(4), 0);
  397. tmp_reg422 =
  398. rtl_read_byte(rtlpriv,
  399. REG_FWHW_TXQ_CTRL + 2);
  400. if (tmp_reg422 & BIT(6))
  401. b_recover = true;
  402. rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 2,
  403. tmp_reg422 & (~BIT(6)));
  404. rtl8723e_set_fw_rsvdpagepkt(hw, 0);
  405. _rtl8723e_set_bcn_ctrl_reg(hw, BIT(3), 0);
  406. _rtl8723e_set_bcn_ctrl_reg(hw, 0, BIT(4));
  407. if (b_recover) {
  408. rtl_write_byte(rtlpriv,
  409. REG_FWHW_TXQ_CTRL + 2,
  410. tmp_reg422);
  411. }
  412. rtl_write_byte(rtlpriv, REG_CR + 1,
  413. (tmp_regcr & ~(BIT(0))));
  414. }
  415. rtl8723e_set_fw_joinbss_report_cmd(hw, (*(u8 *)val));
  416. break;
  417. }
  418. case HW_VAR_H2C_FW_P2P_PS_OFFLOAD:{
  419. rtl8723e_set_p2p_ps_offload_cmd(hw, (*(u8 *)val));
  420. break;
  421. }
  422. case HW_VAR_AID:{
  423. u16 u2btmp;
  424. u2btmp = rtl_read_word(rtlpriv, REG_BCN_PSR_RPT);
  425. u2btmp &= 0xC000;
  426. rtl_write_word(rtlpriv, REG_BCN_PSR_RPT,
  427. (u2btmp | mac->assoc_id));
  428. break;
  429. }
  430. case HW_VAR_CORRECT_TSF:{
  431. u8 btype_ibss = ((u8 *)(val))[0];
  432. if (btype_ibss)
  433. _rtl8723e_stop_tx_beacon(hw);
  434. _rtl8723e_set_bcn_ctrl_reg(hw, 0, BIT(3));
  435. rtl_write_dword(rtlpriv, REG_TSFTR,
  436. (u32)(mac->tsf & 0xffffffff));
  437. rtl_write_dword(rtlpriv, REG_TSFTR + 4,
  438. (u32)((mac->tsf >> 32) & 0xffffffff));
  439. _rtl8723e_set_bcn_ctrl_reg(hw, BIT(3), 0);
  440. if (btype_ibss)
  441. _rtl8723e_resume_tx_beacon(hw);
  442. break;
  443. }
  444. case HW_VAR_FW_LPS_ACTION:{
  445. bool b_enter_fwlps = *((bool *)val);
  446. u8 rpwm_val, fw_pwrmode;
  447. bool fw_current_inps;
  448. if (b_enter_fwlps) {
  449. rpwm_val = 0x02; /* RF off */
  450. fw_current_inps = true;
  451. rtlpriv->cfg->ops->set_hw_reg(hw,
  452. HW_VAR_FW_PSMODE_STATUS,
  453. (u8 *)(&fw_current_inps));
  454. rtlpriv->cfg->ops->set_hw_reg(hw,
  455. HW_VAR_H2C_FW_PWRMODE,
  456. (u8 *)(&ppsc->fwctrl_psmode));
  457. rtlpriv->cfg->ops->set_hw_reg(hw,
  458. HW_VAR_SET_RPWM,
  459. (u8 *)(&rpwm_val));
  460. } else {
  461. rpwm_val = 0x0C; /* RF on */
  462. fw_pwrmode = FW_PS_ACTIVE_MODE;
  463. fw_current_inps = false;
  464. rtlpriv->cfg->ops->set_hw_reg(hw,
  465. HW_VAR_SET_RPWM,
  466. (u8 *)(&rpwm_val));
  467. rtlpriv->cfg->ops->set_hw_reg(hw,
  468. HW_VAR_H2C_FW_PWRMODE,
  469. (u8 *)(&fw_pwrmode));
  470. rtlpriv->cfg->ops->set_hw_reg(hw,
  471. HW_VAR_FW_PSMODE_STATUS,
  472. (u8 *)(&fw_current_inps));
  473. }
  474. break;
  475. }
  476. default:
  477. RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
  478. "switch case %#x not processed\n", variable);
  479. break;
  480. }
  481. }
  482. static bool _rtl8723e_llt_write(struct ieee80211_hw *hw, u32 address, u32 data)
  483. {
  484. struct rtl_priv *rtlpriv = rtl_priv(hw);
  485. bool status = true;
  486. long count = 0;
  487. u32 value = _LLT_INIT_ADDR(address) |
  488. _LLT_INIT_DATA(data) | _LLT_OP(_LLT_WRITE_ACCESS);
  489. rtl_write_dword(rtlpriv, REG_LLT_INIT, value);
  490. do {
  491. value = rtl_read_dword(rtlpriv, REG_LLT_INIT);
  492. if (_LLT_NO_ACTIVE == _LLT_OP_VALUE(value))
  493. break;
  494. if (count > POLLING_LLT_THRESHOLD) {
  495. pr_err("Failed to polling write LLT done at address %d!\n",
  496. address);
  497. status = false;
  498. break;
  499. }
  500. } while (++count);
  501. return status;
  502. }
  503. static bool _rtl8723e_llt_table_init(struct ieee80211_hw *hw)
  504. {
  505. struct rtl_priv *rtlpriv = rtl_priv(hw);
  506. unsigned short i;
  507. u8 txpktbuf_bndy;
  508. u8 maxpage;
  509. bool status;
  510. u8 ubyte;
  511. #if LLT_CONFIG == 1
  512. maxpage = 255;
  513. txpktbuf_bndy = 252;
  514. #elif LLT_CONFIG == 2
  515. maxpage = 127;
  516. txpktbuf_bndy = 124;
  517. #elif LLT_CONFIG == 3
  518. maxpage = 255;
  519. txpktbuf_bndy = 174;
  520. #elif LLT_CONFIG == 4
  521. maxpage = 255;
  522. txpktbuf_bndy = 246;
  523. #elif LLT_CONFIG == 5
  524. maxpage = 255;
  525. txpktbuf_bndy = 246;
  526. #endif
  527. rtl_write_byte(rtlpriv, REG_CR, 0x8B);
  528. #if LLT_CONFIG == 1
  529. rtl_write_byte(rtlpriv, REG_RQPN_NPQ, 0x1c);
  530. rtl_write_dword(rtlpriv, REG_RQPN, 0x80a71c1c);
  531. #elif LLT_CONFIG == 2
  532. rtl_write_dword(rtlpriv, REG_RQPN, 0x845B1010);
  533. #elif LLT_CONFIG == 3
  534. rtl_write_dword(rtlpriv, REG_RQPN, 0x84838484);
  535. #elif LLT_CONFIG == 4
  536. rtl_write_dword(rtlpriv, REG_RQPN, 0x80bd1c1c);
  537. #elif LLT_CONFIG == 5
  538. rtl_write_word(rtlpriv, REG_RQPN_NPQ, 0x0000);
  539. rtl_write_dword(rtlpriv, REG_RQPN, 0x80ac1c29);
  540. rtl_write_byte(rtlpriv, REG_RQPN_NPQ, 0x03);
  541. #endif
  542. rtl_write_dword(rtlpriv, REG_TRXFF_BNDY, (0x27FF0000 | txpktbuf_bndy));
  543. rtl_write_byte(rtlpriv, REG_TDECTRL + 1, txpktbuf_bndy);
  544. rtl_write_byte(rtlpriv, REG_TXPKTBUF_BCNQ_BDNY, txpktbuf_bndy);
  545. rtl_write_byte(rtlpriv, REG_TXPKTBUF_MGQ_BDNY, txpktbuf_bndy);
  546. rtl_write_byte(rtlpriv, 0x45D, txpktbuf_bndy);
  547. rtl_write_byte(rtlpriv, REG_PBP, 0x11);
  548. rtl_write_byte(rtlpriv, REG_RX_DRVINFO_SZ, 0x4);
  549. for (i = 0; i < (txpktbuf_bndy - 1); i++) {
  550. status = _rtl8723e_llt_write(hw, i, i + 1);
  551. if (true != status)
  552. return status;
  553. }
  554. status = _rtl8723e_llt_write(hw, (txpktbuf_bndy - 1), 0xFF);
  555. if (true != status)
  556. return status;
  557. for (i = txpktbuf_bndy; i < maxpage; i++) {
  558. status = _rtl8723e_llt_write(hw, i, (i + 1));
  559. if (true != status)
  560. return status;
  561. }
  562. status = _rtl8723e_llt_write(hw, maxpage, txpktbuf_bndy);
  563. if (true != status)
  564. return status;
  565. rtl_write_byte(rtlpriv, REG_CR, 0xff);
  566. ubyte = rtl_read_byte(rtlpriv, REG_RQPN + 3);
  567. rtl_write_byte(rtlpriv, REG_RQPN + 3, ubyte | BIT(7));
  568. return true;
  569. }
  570. static void _rtl8723e_gen_refresh_led_state(struct ieee80211_hw *hw)
  571. {
  572. struct rtl_priv *rtlpriv = rtl_priv(hw);
  573. struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
  574. struct rtl_led *pled0 = &rtlpriv->ledctl.sw_led0;
  575. if (rtlpriv->rtlhal.up_first_time)
  576. return;
  577. if (ppsc->rfoff_reason == RF_CHANGE_BY_IPS)
  578. rtl8723e_sw_led_on(hw, pled0);
  579. else if (ppsc->rfoff_reason == RF_CHANGE_BY_INIT)
  580. rtl8723e_sw_led_on(hw, pled0);
  581. else
  582. rtl8723e_sw_led_off(hw, pled0);
  583. }
  584. static bool _rtl8712e_init_mac(struct ieee80211_hw *hw)
  585. {
  586. struct rtl_priv *rtlpriv = rtl_priv(hw);
  587. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  588. unsigned char bytetmp;
  589. unsigned short wordtmp;
  590. u16 retry = 0;
  591. u16 tmpu2b;
  592. bool mac_func_enable;
  593. rtl_write_byte(rtlpriv, REG_RSV_CTRL, 0x00);
  594. bytetmp = rtl_read_byte(rtlpriv, REG_CR);
  595. if (bytetmp == 0xFF)
  596. mac_func_enable = true;
  597. else
  598. mac_func_enable = false;
  599. /* HW Power on sequence */
  600. if (!rtl_hal_pwrseqcmdparsing(rtlpriv, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK,
  601. PWR_INTF_PCI_MSK, Rtl8723_NIC_ENABLE_FLOW))
  602. return false;
  603. bytetmp = rtl_read_byte(rtlpriv, REG_PCIE_CTRL_REG+2);
  604. rtl_write_byte(rtlpriv, REG_PCIE_CTRL_REG+2, bytetmp | BIT(4));
  605. /* eMAC time out function enable, 0x369[7]=1 */
  606. bytetmp = rtl_read_byte(rtlpriv, 0x369);
  607. rtl_write_byte(rtlpriv, 0x369, bytetmp | BIT(7));
  608. /* ePHY reg 0x1e bit[4]=1 using MDIO interface,
  609. * we should do this before Enabling ASPM backdoor.
  610. */
  611. do {
  612. rtl_write_word(rtlpriv, 0x358, 0x5e);
  613. udelay(100);
  614. rtl_write_word(rtlpriv, 0x356, 0xc280);
  615. rtl_write_word(rtlpriv, 0x354, 0xc290);
  616. rtl_write_word(rtlpriv, 0x358, 0x3e);
  617. udelay(100);
  618. rtl_write_word(rtlpriv, 0x358, 0x5e);
  619. udelay(100);
  620. tmpu2b = rtl_read_word(rtlpriv, 0x356);
  621. retry++;
  622. } while (tmpu2b != 0xc290 && retry < 100);
  623. if (retry >= 100) {
  624. RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD,
  625. "InitMAC(): ePHY configure fail!!!\n");
  626. return false;
  627. }
  628. rtl_write_word(rtlpriv, REG_CR, 0x2ff);
  629. rtl_write_word(rtlpriv, REG_CR + 1, 0x06);
  630. if (!mac_func_enable) {
  631. if (!_rtl8723e_llt_table_init(hw))
  632. return false;
  633. }
  634. rtl_write_dword(rtlpriv, REG_HISR, 0xffffffff);
  635. rtl_write_byte(rtlpriv, REG_HISRE, 0xff);
  636. rtl_write_word(rtlpriv, REG_TRXFF_BNDY + 2, 0x27ff);
  637. wordtmp = rtl_read_word(rtlpriv, REG_TRXDMA_CTRL);
  638. wordtmp &= 0xf;
  639. wordtmp |= 0xF771;
  640. rtl_write_word(rtlpriv, REG_TRXDMA_CTRL, wordtmp);
  641. rtl_write_byte(rtlpriv, REG_FWHW_TXQ_CTRL + 1, 0x1F);
  642. rtl_write_dword(rtlpriv, REG_RCR, rtlpci->receive_config);
  643. rtl_write_word(rtlpriv, REG_RXFLTMAP2, 0xFFFF);
  644. rtl_write_dword(rtlpriv, REG_TCR, rtlpci->transmit_config);
  645. rtl_write_byte(rtlpriv, 0x4d0, 0x0);
  646. rtl_write_dword(rtlpriv, REG_BCNQ_DESA,
  647. ((u64) rtlpci->tx_ring[BEACON_QUEUE].dma) &
  648. DMA_BIT_MASK(32));
  649. rtl_write_dword(rtlpriv, REG_MGQ_DESA,
  650. (u64) rtlpci->tx_ring[MGNT_QUEUE].dma &
  651. DMA_BIT_MASK(32));
  652. rtl_write_dword(rtlpriv, REG_VOQ_DESA,
  653. (u64) rtlpci->tx_ring[VO_QUEUE].dma & DMA_BIT_MASK(32));
  654. rtl_write_dword(rtlpriv, REG_VIQ_DESA,
  655. (u64) rtlpci->tx_ring[VI_QUEUE].dma & DMA_BIT_MASK(32));
  656. rtl_write_dword(rtlpriv, REG_BEQ_DESA,
  657. (u64) rtlpci->tx_ring[BE_QUEUE].dma & DMA_BIT_MASK(32));
  658. rtl_write_dword(rtlpriv, REG_BKQ_DESA,
  659. (u64) rtlpci->tx_ring[BK_QUEUE].dma & DMA_BIT_MASK(32));
  660. rtl_write_dword(rtlpriv, REG_HQ_DESA,
  661. (u64) rtlpci->tx_ring[HIGH_QUEUE].dma &
  662. DMA_BIT_MASK(32));
  663. rtl_write_dword(rtlpriv, REG_RX_DESA,
  664. (u64) rtlpci->rx_ring[RX_MPDU_QUEUE].dma &
  665. DMA_BIT_MASK(32));
  666. rtl_write_byte(rtlpriv, REG_PCIE_CTRL_REG + 3, 0x74);
  667. rtl_write_dword(rtlpriv, REG_INT_MIG, 0);
  668. bytetmp = rtl_read_byte(rtlpriv, REG_APSD_CTRL);
  669. rtl_write_byte(rtlpriv, REG_APSD_CTRL, bytetmp & ~BIT(6));
  670. do {
  671. retry++;
  672. bytetmp = rtl_read_byte(rtlpriv, REG_APSD_CTRL);
  673. } while ((retry < 200) && (bytetmp & BIT(7)));
  674. _rtl8723e_gen_refresh_led_state(hw);
  675. rtl_write_dword(rtlpriv, REG_MCUTST_1, 0x0);
  676. return true;
  677. }
  678. static void _rtl8723e_hw_configure(struct ieee80211_hw *hw)
  679. {
  680. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  681. struct rtl_priv *rtlpriv = rtl_priv(hw);
  682. u8 reg_bw_opmode;
  683. u32 reg_ratr, reg_prsr;
  684. reg_bw_opmode = BW_OPMODE_20MHZ;
  685. reg_ratr = RATE_ALL_CCK | RATE_ALL_OFDM_AG |
  686. RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS;
  687. reg_prsr = RATE_ALL_CCK | RATE_ALL_OFDM_AG;
  688. rtl_write_byte(rtlpriv, REG_INIRTS_RATE_SEL, 0x8);
  689. rtl_write_byte(rtlpriv, REG_BWOPMODE, reg_bw_opmode);
  690. rtl_write_dword(rtlpriv, REG_RRSR, reg_prsr);
  691. rtl_write_byte(rtlpriv, REG_SLOT, 0x09);
  692. rtl_write_byte(rtlpriv, REG_AMPDU_MIN_SPACE, 0x0);
  693. rtl_write_word(rtlpriv, REG_FWHW_TXQ_CTRL, 0x1F80);
  694. rtl_write_word(rtlpriv, REG_RL, 0x0707);
  695. rtl_write_dword(rtlpriv, REG_BAR_MODE_CTRL, 0x02012802);
  696. rtl_write_byte(rtlpriv, REG_HWSEQ_CTRL, 0xFF);
  697. rtl_write_dword(rtlpriv, REG_DARFRC, 0x01000000);
  698. rtl_write_dword(rtlpriv, REG_DARFRC + 4, 0x07060504);
  699. rtl_write_dword(rtlpriv, REG_RARFRC, 0x01000000);
  700. rtl_write_dword(rtlpriv, REG_RARFRC + 4, 0x07060504);
  701. if ((rtlpriv->btcoexist.bt_coexistence) &&
  702. (rtlpriv->btcoexist.bt_coexist_type == BT_CSR_BC4))
  703. rtl_write_dword(rtlpriv, REG_AGGLEN_LMT, 0x97427431);
  704. else
  705. rtl_write_dword(rtlpriv, REG_AGGLEN_LMT, 0xb972a841);
  706. rtl_write_byte(rtlpriv, REG_ATIMWND, 0x2);
  707. rtl_write_byte(rtlpriv, REG_BCN_MAX_ERR, 0xff);
  708. rtlpci->reg_bcn_ctrl_val = 0x1f;
  709. rtl_write_byte(rtlpriv, REG_BCN_CTRL, rtlpci->reg_bcn_ctrl_val);
  710. rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 1, 0xff);
  711. rtl_write_byte(rtlpriv, REG_TBTT_PROHIBIT + 1, 0xff);
  712. rtl_write_byte(rtlpriv, REG_PIFS, 0x1C);
  713. rtl_write_byte(rtlpriv, REG_AGGR_BREAK_TIME, 0x16);
  714. if ((rtlpriv->btcoexist.bt_coexistence) &&
  715. (rtlpriv->btcoexist.bt_coexist_type == BT_CSR_BC4)) {
  716. rtl_write_word(rtlpriv, REG_NAV_PROT_LEN, 0x0020);
  717. rtl_write_word(rtlpriv, REG_PROT_MODE_CTRL, 0x0402);
  718. } else {
  719. rtl_write_word(rtlpriv, REG_NAV_PROT_LEN, 0x0020);
  720. rtl_write_word(rtlpriv, REG_NAV_PROT_LEN, 0x0020);
  721. }
  722. if ((rtlpriv->btcoexist.bt_coexistence) &&
  723. (rtlpriv->btcoexist.bt_coexist_type == BT_CSR_BC4))
  724. rtl_write_dword(rtlpriv, REG_FAST_EDCA_CTRL, 0x03086666);
  725. else
  726. rtl_write_dword(rtlpriv, REG_FAST_EDCA_CTRL, 0x086666);
  727. rtl_write_byte(rtlpriv, REG_ACKTO, 0x40);
  728. rtl_write_word(rtlpriv, REG_SPEC_SIFS, 0x1010);
  729. rtl_write_word(rtlpriv, REG_MAC_SPEC_SIFS, 0x1010);
  730. rtl_write_word(rtlpriv, REG_SIFS_CTX, 0x1010);
  731. rtl_write_word(rtlpriv, REG_SIFS_TRX, 0x1010);
  732. rtl_write_dword(rtlpriv, REG_MAR, 0xffffffff);
  733. rtl_write_dword(rtlpriv, REG_MAR + 4, 0xffffffff);
  734. rtl_write_dword(rtlpriv, 0x394, 0x1);
  735. }
  736. static void _rtl8723e_enable_aspm_back_door(struct ieee80211_hw *hw)
  737. {
  738. struct rtl_priv *rtlpriv = rtl_priv(hw);
  739. struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
  740. rtl_write_byte(rtlpriv, 0x34b, 0x93);
  741. rtl_write_word(rtlpriv, 0x350, 0x870c);
  742. rtl_write_byte(rtlpriv, 0x352, 0x1);
  743. if (ppsc->support_backdoor)
  744. rtl_write_byte(rtlpriv, 0x349, 0x1b);
  745. else
  746. rtl_write_byte(rtlpriv, 0x349, 0x03);
  747. rtl_write_word(rtlpriv, 0x350, 0x2718);
  748. rtl_write_byte(rtlpriv, 0x352, 0x1);
  749. }
  750. void rtl8723e_enable_hw_security_config(struct ieee80211_hw *hw)
  751. {
  752. struct rtl_priv *rtlpriv = rtl_priv(hw);
  753. u8 sec_reg_value;
  754. RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
  755. "PairwiseEncAlgorithm = %d GroupEncAlgorithm = %d\n",
  756. rtlpriv->sec.pairwise_enc_algorithm,
  757. rtlpriv->sec.group_enc_algorithm);
  758. if (rtlpriv->cfg->mod_params->sw_crypto || rtlpriv->sec.use_sw_sec) {
  759. RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
  760. "not open hw encryption\n");
  761. return;
  762. }
  763. sec_reg_value = SCR_TXENCENABLE | SCR_RXDECENABLE;
  764. if (rtlpriv->sec.use_defaultkey) {
  765. sec_reg_value |= SCR_TXUSEDK;
  766. sec_reg_value |= SCR_RXUSEDK;
  767. }
  768. sec_reg_value |= (SCR_RXBCUSEDK | SCR_TXBCUSEDK);
  769. rtl_write_byte(rtlpriv, REG_CR + 1, 0x02);
  770. RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
  771. "The SECR-value %x\n", sec_reg_value);
  772. rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_WPA_CONFIG, &sec_reg_value);
  773. }
  774. int rtl8723e_hw_init(struct ieee80211_hw *hw)
  775. {
  776. struct rtl_priv *rtlpriv = rtl_priv(hw);
  777. struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
  778. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  779. struct rtl_phy *rtlphy = &(rtlpriv->phy);
  780. struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
  781. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  782. bool rtstatus = true;
  783. int err;
  784. u8 tmp_u1b;
  785. unsigned long flags;
  786. rtlpriv->rtlhal.being_init_adapter = true;
  787. /* As this function can take a very long time (up to 350 ms)
  788. * and can be called with irqs disabled, reenable the irqs
  789. * to let the other devices continue being serviced.
  790. *
  791. * It is safe doing so since our own interrupts will only be enabled
  792. * in a subsequent step.
  793. */
  794. local_save_flags(flags);
  795. local_irq_enable();
  796. rtlhal->fw_ready = false;
  797. rtlpriv->intf_ops->disable_aspm(hw);
  798. rtstatus = _rtl8712e_init_mac(hw);
  799. if (rtstatus != true) {
  800. pr_err("Init MAC failed\n");
  801. err = 1;
  802. goto exit;
  803. }
  804. err = rtl8723_download_fw(hw, false, FW_8723A_POLLING_TIMEOUT_COUNT);
  805. if (err) {
  806. RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
  807. "Failed to download FW. Init HW without FW now..\n");
  808. err = 1;
  809. goto exit;
  810. }
  811. rtlhal->fw_ready = true;
  812. rtlhal->last_hmeboxnum = 0;
  813. rtl8723e_phy_mac_config(hw);
  814. /* because last function modify RCR, so we update
  815. * rcr var here, or TP will unstable for receive_config
  816. * is wrong, RX RCR_ACRC32 will cause TP unstable & Rx
  817. * RCR_APP_ICV will cause mac80211 unassoc for cisco 1252
  818. */
  819. rtlpci->receive_config = rtl_read_dword(rtlpriv, REG_RCR);
  820. rtlpci->receive_config &= ~(RCR_ACRC32 | RCR_AICV);
  821. rtl_write_dword(rtlpriv, REG_RCR, rtlpci->receive_config);
  822. rtl8723e_phy_bb_config(hw);
  823. rtlphy->rf_mode = RF_OP_BY_SW_3WIRE;
  824. rtl8723e_phy_rf_config(hw);
  825. if (IS_VENDOR_UMC_A_CUT(rtlhal->version)) {
  826. rtl_set_rfreg(hw, RF90_PATH_A, RF_RX_G1, MASKDWORD, 0x30255);
  827. rtl_set_rfreg(hw, RF90_PATH_A, RF_RX_G2, MASKDWORD, 0x50a00);
  828. } else if (IS_81xxC_VENDOR_UMC_B_CUT(rtlhal->version)) {
  829. rtl_set_rfreg(hw, RF90_PATH_A, 0x0C, MASKDWORD, 0x894AE);
  830. rtl_set_rfreg(hw, RF90_PATH_A, 0x0A, MASKDWORD, 0x1AF31);
  831. rtl_set_rfreg(hw, RF90_PATH_A, RF_IPA, MASKDWORD, 0x8F425);
  832. rtl_set_rfreg(hw, RF90_PATH_A, RF_SYN_G2, MASKDWORD, 0x4F200);
  833. rtl_set_rfreg(hw, RF90_PATH_A, RF_RCK1, MASKDWORD, 0x44053);
  834. rtl_set_rfreg(hw, RF90_PATH_A, RF_RCK2, MASKDWORD, 0x80201);
  835. }
  836. rtlphy->rfreg_chnlval[0] = rtl_get_rfreg(hw, (enum radio_path)0,
  837. RF_CHNLBW, RFREG_OFFSET_MASK);
  838. rtlphy->rfreg_chnlval[1] = rtl_get_rfreg(hw, (enum radio_path)1,
  839. RF_CHNLBW, RFREG_OFFSET_MASK);
  840. rtl_set_bbreg(hw, RFPGA0_RFMOD, BCCKEN, 0x1);
  841. rtl_set_bbreg(hw, RFPGA0_RFMOD, BOFDMEN, 0x1);
  842. rtl_set_bbreg(hw, RFPGA0_ANALOGPARAMETER2, BIT(10), 1);
  843. _rtl8723e_hw_configure(hw);
  844. rtl_cam_reset_all_entry(hw);
  845. rtl8723e_enable_hw_security_config(hw);
  846. ppsc->rfpwr_state = ERFON;
  847. rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, mac->mac_addr);
  848. _rtl8723e_enable_aspm_back_door(hw);
  849. rtlpriv->intf_ops->enable_aspm(hw);
  850. rtl8723e_bt_hw_init(hw);
  851. if (ppsc->rfpwr_state == ERFON) {
  852. rtl8723e_phy_set_rfpath_switch(hw, 1);
  853. if (rtlphy->iqk_initialized) {
  854. rtl8723e_phy_iq_calibrate(hw, true);
  855. } else {
  856. rtl8723e_phy_iq_calibrate(hw, false);
  857. rtlphy->iqk_initialized = true;
  858. }
  859. rtl8723e_dm_check_txpower_tracking(hw);
  860. rtl8723e_phy_lc_calibrate(hw);
  861. }
  862. tmp_u1b = efuse_read_1byte(hw, 0x1FA);
  863. if (!(tmp_u1b & BIT(0))) {
  864. rtl_set_rfreg(hw, RF90_PATH_A, 0x15, 0x0F, 0x05);
  865. RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "PA BIAS path A\n");
  866. }
  867. if (!(tmp_u1b & BIT(4))) {
  868. tmp_u1b = rtl_read_byte(rtlpriv, 0x16);
  869. tmp_u1b &= 0x0F;
  870. rtl_write_byte(rtlpriv, 0x16, tmp_u1b | 0x80);
  871. udelay(10);
  872. rtl_write_byte(rtlpriv, 0x16, tmp_u1b | 0x90);
  873. RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "under 1.5V\n");
  874. }
  875. rtl8723e_dm_init(hw);
  876. exit:
  877. local_irq_restore(flags);
  878. rtlpriv->rtlhal.being_init_adapter = false;
  879. return err;
  880. }
  881. static enum version_8723e _rtl8723e_read_chip_version(struct ieee80211_hw *hw)
  882. {
  883. struct rtl_priv *rtlpriv = rtl_priv(hw);
  884. struct rtl_phy *rtlphy = &(rtlpriv->phy);
  885. enum version_8723e version = 0x0000;
  886. u32 value32;
  887. value32 = rtl_read_dword(rtlpriv, REG_SYS_CFG);
  888. if (value32 & TRP_VAUX_EN) {
  889. version = (enum version_8723e)(version |
  890. ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : 0));
  891. /* RTL8723 with BT function. */
  892. version = (enum version_8723e)(version |
  893. ((value32 & BT_FUNC) ? CHIP_8723 : 0));
  894. } else {
  895. /* Normal mass production chip. */
  896. version = (enum version_8723e) NORMAL_CHIP;
  897. version = (enum version_8723e)(version |
  898. ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : 0));
  899. /* RTL8723 with BT function. */
  900. version = (enum version_8723e)(version |
  901. ((value32 & BT_FUNC) ? CHIP_8723 : 0));
  902. if (IS_CHIP_VENDOR_UMC(version))
  903. version = (enum version_8723e)(version |
  904. ((value32 & CHIP_VER_RTL_MASK)));/* IC version (CUT) */
  905. if (IS_8723_SERIES(version)) {
  906. value32 = rtl_read_dword(rtlpriv, REG_GPIO_OUTSTS);
  907. /* ROM code version. */
  908. version = (enum version_8723e)(version |
  909. ((value32 & RF_RL_ID)>>20));
  910. }
  911. }
  912. if (IS_8723_SERIES(version)) {
  913. value32 = rtl_read_dword(rtlpriv, REG_MULTI_FUNC_CTRL);
  914. rtlphy->polarity_ctl = ((value32 & WL_HWPDN_SL) ?
  915. RT_POLARITY_HIGH_ACT :
  916. RT_POLARITY_LOW_ACT);
  917. }
  918. switch (version) {
  919. case VERSION_TEST_UMC_CHIP_8723:
  920. RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
  921. "Chip Version ID: VERSION_TEST_UMC_CHIP_8723.\n");
  922. break;
  923. case VERSION_NORMAL_UMC_CHIP_8723_1T1R_A_CUT:
  924. RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
  925. "Chip Version ID: VERSION_NORMAL_UMC_CHIP_8723_1T1R_A_CUT.\n");
  926. break;
  927. case VERSION_NORMAL_UMC_CHIP_8723_1T1R_B_CUT:
  928. RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
  929. "Chip Version ID: VERSION_NORMAL_UMC_CHIP_8723_1T1R_B_CUT.\n");
  930. break;
  931. default:
  932. pr_err("Chip Version ID: Unknown. Bug?\n");
  933. break;
  934. }
  935. if (IS_8723_SERIES(version))
  936. rtlphy->rf_type = RF_1T1R;
  937. RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Chip RF Type: %s\n",
  938. (rtlphy->rf_type == RF_2T2R) ? "RF_2T2R" : "RF_1T1R");
  939. return version;
  940. }
  941. static int _rtl8723e_set_media_status(struct ieee80211_hw *hw,
  942. enum nl80211_iftype type)
  943. {
  944. struct rtl_priv *rtlpriv = rtl_priv(hw);
  945. u8 bt_msr = rtl_read_byte(rtlpriv, MSR) & 0xfc;
  946. enum led_ctl_mode ledaction = LED_CTL_NO_LINK;
  947. u8 mode = MSR_NOLINK;
  948. rtl_write_dword(rtlpriv, REG_BCN_CTRL, 0);
  949. RT_TRACE(rtlpriv, COMP_BEACON, DBG_LOUD,
  950. "clear 0x550 when set HW_VAR_MEDIA_STATUS\n");
  951. switch (type) {
  952. case NL80211_IFTYPE_UNSPECIFIED:
  953. mode = MSR_NOLINK;
  954. RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
  955. "Set Network type to NO LINK!\n");
  956. break;
  957. case NL80211_IFTYPE_ADHOC:
  958. mode = MSR_ADHOC;
  959. RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
  960. "Set Network type to Ad Hoc!\n");
  961. break;
  962. case NL80211_IFTYPE_STATION:
  963. mode = MSR_INFRA;
  964. ledaction = LED_CTL_LINK;
  965. RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
  966. "Set Network type to STA!\n");
  967. break;
  968. case NL80211_IFTYPE_AP:
  969. mode = MSR_AP;
  970. ledaction = LED_CTL_LINK;
  971. RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
  972. "Set Network type to AP!\n");
  973. break;
  974. default:
  975. pr_err("Network type %d not support!\n", type);
  976. return 1;
  977. break;
  978. }
  979. /* MSR_INFRA == Link in infrastructure network;
  980. * MSR_ADHOC == Link in ad hoc network;
  981. * Therefore, check link state is necessary.
  982. *
  983. * MSR_AP == AP mode; link state is not cared here.
  984. */
  985. if (mode != MSR_AP &&
  986. rtlpriv->mac80211.link_state < MAC80211_LINKED) {
  987. mode = MSR_NOLINK;
  988. ledaction = LED_CTL_NO_LINK;
  989. }
  990. if (mode == MSR_NOLINK || mode == MSR_INFRA) {
  991. _rtl8723e_stop_tx_beacon(hw);
  992. _rtl8723e_enable_bcn_sub_func(hw);
  993. } else if (mode == MSR_ADHOC || mode == MSR_AP) {
  994. _rtl8723e_resume_tx_beacon(hw);
  995. _rtl8723e_disable_bcn_sub_func(hw);
  996. } else {
  997. RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING,
  998. "Set HW_VAR_MEDIA_STATUS: No such media status(%x).\n",
  999. mode);
  1000. }
  1001. rtl_write_byte(rtlpriv, MSR, bt_msr | mode);
  1002. rtlpriv->cfg->ops->led_control(hw, ledaction);
  1003. if (mode == MSR_AP)
  1004. rtl_write_byte(rtlpriv, REG_BCNTCFG + 1, 0x00);
  1005. else
  1006. rtl_write_byte(rtlpriv, REG_BCNTCFG + 1, 0x66);
  1007. return 0;
  1008. }
  1009. void rtl8723e_set_check_bssid(struct ieee80211_hw *hw, bool check_bssid)
  1010. {
  1011. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1012. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  1013. u32 reg_rcr = rtlpci->receive_config;
  1014. if (rtlpriv->psc.rfpwr_state != ERFON)
  1015. return;
  1016. if (check_bssid) {
  1017. reg_rcr |= (RCR_CBSSID_DATA | RCR_CBSSID_BCN);
  1018. rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_RCR,
  1019. (u8 *)(&reg_rcr));
  1020. _rtl8723e_set_bcn_ctrl_reg(hw, 0, BIT(4));
  1021. } else if (!check_bssid) {
  1022. reg_rcr &= (~(RCR_CBSSID_DATA | RCR_CBSSID_BCN));
  1023. _rtl8723e_set_bcn_ctrl_reg(hw, BIT(4), 0);
  1024. rtlpriv->cfg->ops->set_hw_reg(hw,
  1025. HW_VAR_RCR, (u8 *)(&reg_rcr));
  1026. }
  1027. }
  1028. int rtl8723e_set_network_type(struct ieee80211_hw *hw,
  1029. enum nl80211_iftype type)
  1030. {
  1031. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1032. if (_rtl8723e_set_media_status(hw, type))
  1033. return -EOPNOTSUPP;
  1034. if (rtlpriv->mac80211.link_state == MAC80211_LINKED) {
  1035. if (type != NL80211_IFTYPE_AP)
  1036. rtl8723e_set_check_bssid(hw, true);
  1037. } else {
  1038. rtl8723e_set_check_bssid(hw, false);
  1039. }
  1040. return 0;
  1041. }
  1042. /* don't set REG_EDCA_BE_PARAM here
  1043. * because mac80211 will send pkt when scan
  1044. */
  1045. void rtl8723e_set_qos(struct ieee80211_hw *hw, int aci)
  1046. {
  1047. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1048. rtl8723_dm_init_edca_turbo(hw);
  1049. switch (aci) {
  1050. case AC1_BK:
  1051. rtl_write_dword(rtlpriv, REG_EDCA_BK_PARAM, 0xa44f);
  1052. break;
  1053. case AC0_BE:
  1054. break;
  1055. case AC2_VI:
  1056. rtl_write_dword(rtlpriv, REG_EDCA_VI_PARAM, 0x5e4322);
  1057. break;
  1058. case AC3_VO:
  1059. rtl_write_dword(rtlpriv, REG_EDCA_VO_PARAM, 0x2f3222);
  1060. break;
  1061. default:
  1062. WARN_ONCE(true, "rtl8723ae: invalid aci: %d !\n", aci);
  1063. break;
  1064. }
  1065. }
  1066. void rtl8723e_enable_interrupt(struct ieee80211_hw *hw)
  1067. {
  1068. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1069. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  1070. rtl_write_dword(rtlpriv, 0x3a8, rtlpci->irq_mask[0] & 0xFFFFFFFF);
  1071. rtl_write_dword(rtlpriv, 0x3ac, rtlpci->irq_mask[1] & 0xFFFFFFFF);
  1072. rtlpci->irq_enabled = true;
  1073. }
  1074. void rtl8723e_disable_interrupt(struct ieee80211_hw *hw)
  1075. {
  1076. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1077. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  1078. rtl_write_dword(rtlpriv, 0x3a8, IMR8190_DISABLED);
  1079. rtl_write_dword(rtlpriv, 0x3ac, IMR8190_DISABLED);
  1080. rtlpci->irq_enabled = false;
  1081. /*synchronize_irq(rtlpci->pdev->irq);*/
  1082. }
  1083. static void _rtl8723e_poweroff_adapter(struct ieee80211_hw *hw)
  1084. {
  1085. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1086. struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
  1087. u8 u1b_tmp;
  1088. /* Combo (PCIe + USB) Card and PCIe-MF Card */
  1089. /* 1. Run LPS WL RFOFF flow */
  1090. rtl_hal_pwrseqcmdparsing(rtlpriv, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK,
  1091. PWR_INTF_PCI_MSK, Rtl8723_NIC_LPS_ENTER_FLOW);
  1092. /* 2. 0x1F[7:0] = 0 */
  1093. /* turn off RF */
  1094. rtl_write_byte(rtlpriv, REG_RF_CTRL, 0x00);
  1095. if ((rtl_read_byte(rtlpriv, REG_MCUFWDL) & BIT(7)) &&
  1096. rtlhal->fw_ready) {
  1097. rtl8723ae_firmware_selfreset(hw);
  1098. }
  1099. /* Reset MCU. Suggested by Filen. */
  1100. u1b_tmp = rtl_read_byte(rtlpriv, REG_SYS_FUNC_EN+1);
  1101. rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN+1, (u1b_tmp & (~BIT(2))));
  1102. /* g. MCUFWDL 0x80[1:0]=0 */
  1103. /* reset MCU ready status */
  1104. rtl_write_byte(rtlpriv, REG_MCUFWDL, 0x00);
  1105. /* HW card disable configuration. */
  1106. rtl_hal_pwrseqcmdparsing(rtlpriv, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK,
  1107. PWR_INTF_PCI_MSK, Rtl8723_NIC_DISABLE_FLOW);
  1108. /* Reset MCU IO Wrapper */
  1109. u1b_tmp = rtl_read_byte(rtlpriv, REG_RSV_CTRL + 1);
  1110. rtl_write_byte(rtlpriv, REG_RSV_CTRL + 1, (u1b_tmp & (~BIT(0))));
  1111. u1b_tmp = rtl_read_byte(rtlpriv, REG_RSV_CTRL + 1);
  1112. rtl_write_byte(rtlpriv, REG_RSV_CTRL + 1, u1b_tmp | BIT(0));
  1113. /* 7. RSV_CTRL 0x1C[7:0] = 0x0E */
  1114. /* lock ISO/CLK/Power control register */
  1115. rtl_write_byte(rtlpriv, REG_RSV_CTRL, 0x0e);
  1116. }
  1117. void rtl8723e_card_disable(struct ieee80211_hw *hw)
  1118. {
  1119. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1120. struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
  1121. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  1122. enum nl80211_iftype opmode;
  1123. mac->link_state = MAC80211_NOLINK;
  1124. opmode = NL80211_IFTYPE_UNSPECIFIED;
  1125. _rtl8723e_set_media_status(hw, opmode);
  1126. if (rtlpriv->rtlhal.driver_is_goingto_unload ||
  1127. ppsc->rfoff_reason > RF_CHANGE_BY_PS)
  1128. rtlpriv->cfg->ops->led_control(hw, LED_CTL_POWER_OFF);
  1129. RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC);
  1130. _rtl8723e_poweroff_adapter(hw);
  1131. /* after power off we should do iqk again */
  1132. rtlpriv->phy.iqk_initialized = false;
  1133. }
  1134. void rtl8723e_interrupt_recognized(struct ieee80211_hw *hw,
  1135. struct rtl_int *intvec)
  1136. {
  1137. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1138. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  1139. intvec->inta = rtl_read_dword(rtlpriv, 0x3a0) & rtlpci->irq_mask[0];
  1140. rtl_write_dword(rtlpriv, 0x3a0, intvec->inta);
  1141. }
  1142. void rtl8723e_set_beacon_related_registers(struct ieee80211_hw *hw)
  1143. {
  1144. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1145. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  1146. u16 bcn_interval, atim_window;
  1147. bcn_interval = mac->beacon_interval;
  1148. atim_window = 2; /*FIX MERGE */
  1149. rtl8723e_disable_interrupt(hw);
  1150. rtl_write_word(rtlpriv, REG_ATIMWND, atim_window);
  1151. rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval);
  1152. rtl_write_word(rtlpriv, REG_BCNTCFG, 0x660f);
  1153. rtl_write_byte(rtlpriv, REG_RXTSF_OFFSET_CCK, 0x18);
  1154. rtl_write_byte(rtlpriv, REG_RXTSF_OFFSET_OFDM, 0x18);
  1155. rtl_write_byte(rtlpriv, 0x606, 0x30);
  1156. rtl8723e_enable_interrupt(hw);
  1157. }
  1158. void rtl8723e_set_beacon_interval(struct ieee80211_hw *hw)
  1159. {
  1160. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1161. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  1162. u16 bcn_interval = mac->beacon_interval;
  1163. RT_TRACE(rtlpriv, COMP_BEACON, DBG_DMESG,
  1164. "beacon_interval:%d\n", bcn_interval);
  1165. rtl8723e_disable_interrupt(hw);
  1166. rtl_write_word(rtlpriv, REG_BCN_INTERVAL, bcn_interval);
  1167. rtl8723e_enable_interrupt(hw);
  1168. }
  1169. void rtl8723e_update_interrupt_mask(struct ieee80211_hw *hw,
  1170. u32 add_msr, u32 rm_msr)
  1171. {
  1172. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1173. struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
  1174. RT_TRACE(rtlpriv, COMP_INTR, DBG_LOUD,
  1175. "add_msr:%x, rm_msr:%x\n", add_msr, rm_msr);
  1176. if (add_msr)
  1177. rtlpci->irq_mask[0] |= add_msr;
  1178. if (rm_msr)
  1179. rtlpci->irq_mask[0] &= (~rm_msr);
  1180. rtl8723e_disable_interrupt(hw);
  1181. rtl8723e_enable_interrupt(hw);
  1182. }
  1183. static u8 _rtl8723e_get_chnl_group(u8 chnl)
  1184. {
  1185. u8 group;
  1186. if (chnl < 3)
  1187. group = 0;
  1188. else if (chnl < 9)
  1189. group = 1;
  1190. else
  1191. group = 2;
  1192. return group;
  1193. }
  1194. static void _rtl8723e_read_txpower_info_from_hwpg(struct ieee80211_hw *hw,
  1195. bool autoload_fail,
  1196. u8 *hwinfo)
  1197. {
  1198. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1199. struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
  1200. u8 rf_path, index, tempval;
  1201. u16 i;
  1202. for (rf_path = 0; rf_path < 1; rf_path++) {
  1203. for (i = 0; i < 3; i++) {
  1204. if (!autoload_fail) {
  1205. rtlefuse->eeprom_chnlarea_txpwr_cck[rf_path][i] =
  1206. hwinfo[EEPROM_TXPOWERCCK + rf_path * 3 + i];
  1207. rtlefuse->eeprom_chnlarea_txpwr_ht40_1s[rf_path][i] =
  1208. hwinfo[EEPROM_TXPOWERHT40_1S + rf_path * 3 + i];
  1209. } else {
  1210. rtlefuse->eeprom_chnlarea_txpwr_cck[rf_path][i] =
  1211. EEPROM_DEFAULT_TXPOWERLEVEL;
  1212. rtlefuse->eeprom_chnlarea_txpwr_ht40_1s[rf_path][i] =
  1213. EEPROM_DEFAULT_TXPOWERLEVEL;
  1214. }
  1215. }
  1216. }
  1217. for (i = 0; i < 3; i++) {
  1218. if (!autoload_fail)
  1219. tempval = hwinfo[EEPROM_TXPOWERHT40_2SDIFF + i];
  1220. else
  1221. tempval = EEPROM_DEFAULT_HT40_2SDIFF;
  1222. rtlefuse->eprom_chnl_txpwr_ht40_2sdf[RF90_PATH_A][i] =
  1223. (tempval & 0xf);
  1224. rtlefuse->eprom_chnl_txpwr_ht40_2sdf[RF90_PATH_B][i] =
  1225. ((tempval & 0xf0) >> 4);
  1226. }
  1227. for (rf_path = 0; rf_path < 2; rf_path++)
  1228. for (i = 0; i < 3; i++)
  1229. RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
  1230. "RF(%d) EEPROM CCK Area(%d) = 0x%x\n", rf_path,
  1231. i, rtlefuse->eeprom_chnlarea_txpwr_cck
  1232. [rf_path][i]);
  1233. for (rf_path = 0; rf_path < 2; rf_path++)
  1234. for (i = 0; i < 3; i++)
  1235. RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
  1236. "RF(%d) EEPROM HT40 1S Area(%d) = 0x%x\n",
  1237. rf_path, i,
  1238. rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
  1239. [rf_path][i]);
  1240. for (rf_path = 0; rf_path < 2; rf_path++)
  1241. for (i = 0; i < 3; i++)
  1242. RTPRINT(rtlpriv, FINIT, INIT_EEPROM,
  1243. "RF(%d) EEPROM HT40 2S Diff Area(%d) = 0x%x\n",
  1244. rf_path, i,
  1245. rtlefuse->eprom_chnl_txpwr_ht40_2sdf
  1246. [rf_path][i]);
  1247. for (rf_path = 0; rf_path < 2; rf_path++) {
  1248. for (i = 0; i < 14; i++) {
  1249. index = _rtl8723e_get_chnl_group((u8)i);
  1250. rtlefuse->txpwrlevel_cck[rf_path][i] =
  1251. rtlefuse->eeprom_chnlarea_txpwr_cck
  1252. [rf_path][index];
  1253. rtlefuse->txpwrlevel_ht40_1s[rf_path][i] =
  1254. rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
  1255. [rf_path][index];
  1256. if ((rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
  1257. [rf_path][index] -
  1258. rtlefuse->eprom_chnl_txpwr_ht40_2sdf
  1259. [rf_path][index]) > 0) {
  1260. rtlefuse->txpwrlevel_ht40_2s[rf_path][i] =
  1261. rtlefuse->eeprom_chnlarea_txpwr_ht40_1s
  1262. [rf_path][index] -
  1263. rtlefuse->eprom_chnl_txpwr_ht40_2sdf
  1264. [rf_path][index];
  1265. } else {
  1266. rtlefuse->txpwrlevel_ht40_2s[rf_path][i] = 0;
  1267. }
  1268. }
  1269. for (i = 0; i < 14; i++) {
  1270. RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
  1271. "RF(%d)-Ch(%d) [CCK / HT40_1S / HT40_2S] = [0x%x / 0x%x / 0x%x]\n",
  1272. rf_path, i,
  1273. rtlefuse->txpwrlevel_cck[rf_path][i],
  1274. rtlefuse->txpwrlevel_ht40_1s[rf_path][i],
  1275. rtlefuse->txpwrlevel_ht40_2s[rf_path][i]);
  1276. }
  1277. }
  1278. for (i = 0; i < 3; i++) {
  1279. if (!autoload_fail) {
  1280. rtlefuse->eeprom_pwrlimit_ht40[i] =
  1281. hwinfo[EEPROM_TXPWR_GROUP + i];
  1282. rtlefuse->eeprom_pwrlimit_ht20[i] =
  1283. hwinfo[EEPROM_TXPWR_GROUP + 3 + i];
  1284. } else {
  1285. rtlefuse->eeprom_pwrlimit_ht40[i] = 0;
  1286. rtlefuse->eeprom_pwrlimit_ht20[i] = 0;
  1287. }
  1288. }
  1289. for (rf_path = 0; rf_path < 2; rf_path++) {
  1290. for (i = 0; i < 14; i++) {
  1291. index = _rtl8723e_get_chnl_group((u8)i);
  1292. if (rf_path == RF90_PATH_A) {
  1293. rtlefuse->pwrgroup_ht20[rf_path][i] =
  1294. (rtlefuse->eeprom_pwrlimit_ht20[index] & 0xf);
  1295. rtlefuse->pwrgroup_ht40[rf_path][i] =
  1296. (rtlefuse->eeprom_pwrlimit_ht40[index] & 0xf);
  1297. } else if (rf_path == RF90_PATH_B) {
  1298. rtlefuse->pwrgroup_ht20[rf_path][i] =
  1299. ((rtlefuse->eeprom_pwrlimit_ht20[index] &
  1300. 0xf0) >> 4);
  1301. rtlefuse->pwrgroup_ht40[rf_path][i] =
  1302. ((rtlefuse->eeprom_pwrlimit_ht40[index] &
  1303. 0xf0) >> 4);
  1304. }
  1305. RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
  1306. "RF-%d pwrgroup_ht20[%d] = 0x%x\n", rf_path, i,
  1307. rtlefuse->pwrgroup_ht20[rf_path][i]);
  1308. RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
  1309. "RF-%d pwrgroup_ht40[%d] = 0x%x\n", rf_path, i,
  1310. rtlefuse->pwrgroup_ht40[rf_path][i]);
  1311. }
  1312. }
  1313. for (i = 0; i < 14; i++) {
  1314. index = _rtl8723e_get_chnl_group((u8)i);
  1315. if (!autoload_fail)
  1316. tempval = hwinfo[EEPROM_TXPOWERHT20DIFF + index];
  1317. else
  1318. tempval = EEPROM_DEFAULT_HT20_DIFF;
  1319. rtlefuse->txpwr_ht20diff[RF90_PATH_A][i] = (tempval & 0xF);
  1320. rtlefuse->txpwr_ht20diff[RF90_PATH_B][i] =
  1321. ((tempval >> 4) & 0xF);
  1322. if (rtlefuse->txpwr_ht20diff[RF90_PATH_A][i] & BIT(3))
  1323. rtlefuse->txpwr_ht20diff[RF90_PATH_A][i] |= 0xF0;
  1324. if (rtlefuse->txpwr_ht20diff[RF90_PATH_B][i] & BIT(3))
  1325. rtlefuse->txpwr_ht20diff[RF90_PATH_B][i] |= 0xF0;
  1326. index = _rtl8723e_get_chnl_group((u8)i);
  1327. if (!autoload_fail)
  1328. tempval = hwinfo[EEPROM_TXPOWER_OFDMDIFF + index];
  1329. else
  1330. tempval = EEPROM_DEFAULT_LEGACYHTTXPOWERDIFF;
  1331. rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i] = (tempval & 0xF);
  1332. rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i] =
  1333. ((tempval >> 4) & 0xF);
  1334. }
  1335. rtlefuse->legacy_ht_txpowerdiff =
  1336. rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][7];
  1337. for (i = 0; i < 14; i++)
  1338. RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
  1339. "RF-A Ht20 to HT40 Diff[%d] = 0x%x\n", i,
  1340. rtlefuse->txpwr_ht20diff[RF90_PATH_A][i]);
  1341. for (i = 0; i < 14; i++)
  1342. RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
  1343. "RF-A Legacy to Ht40 Diff[%d] = 0x%x\n", i,
  1344. rtlefuse->txpwr_legacyhtdiff[RF90_PATH_A][i]);
  1345. for (i = 0; i < 14; i++)
  1346. RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
  1347. "RF-B Ht20 to HT40 Diff[%d] = 0x%x\n", i,
  1348. rtlefuse->txpwr_ht20diff[RF90_PATH_B][i]);
  1349. for (i = 0; i < 14; i++)
  1350. RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
  1351. "RF-B Legacy to HT40 Diff[%d] = 0x%x\n", i,
  1352. rtlefuse->txpwr_legacyhtdiff[RF90_PATH_B][i]);
  1353. if (!autoload_fail)
  1354. rtlefuse->eeprom_regulatory = (hwinfo[RF_OPTION1] & 0x7);
  1355. else
  1356. rtlefuse->eeprom_regulatory = 0;
  1357. RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
  1358. "eeprom_regulatory = 0x%x\n", rtlefuse->eeprom_regulatory);
  1359. if (!autoload_fail)
  1360. rtlefuse->eeprom_tssi[RF90_PATH_A] = hwinfo[EEPROM_TSSI_A];
  1361. else
  1362. rtlefuse->eeprom_tssi[RF90_PATH_A] = EEPROM_DEFAULT_TSSI;
  1363. RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
  1364. "TSSI_A = 0x%x, TSSI_B = 0x%x\n",
  1365. rtlefuse->eeprom_tssi[RF90_PATH_A],
  1366. rtlefuse->eeprom_tssi[RF90_PATH_B]);
  1367. if (!autoload_fail)
  1368. tempval = hwinfo[EEPROM_THERMAL_METER];
  1369. else
  1370. tempval = EEPROM_DEFAULT_THERMALMETER;
  1371. rtlefuse->eeprom_thermalmeter = (tempval & 0x1f);
  1372. if (rtlefuse->eeprom_thermalmeter == 0x1f || autoload_fail)
  1373. rtlefuse->apk_thermalmeterignore = true;
  1374. rtlefuse->thermalmeter[0] = rtlefuse->eeprom_thermalmeter;
  1375. RTPRINT(rtlpriv, FINIT, INIT_TXPOWER,
  1376. "thermalmeter = 0x%x\n", rtlefuse->eeprom_thermalmeter);
  1377. }
  1378. static void _rtl8723e_read_adapter_info(struct ieee80211_hw *hw,
  1379. bool b_pseudo_test)
  1380. {
  1381. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1382. struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
  1383. struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
  1384. int params[] = {RTL8190_EEPROM_ID, EEPROM_VID, EEPROM_DID,
  1385. EEPROM_SVID, EEPROM_SMID, EEPROM_MAC_ADDR,
  1386. EEPROM_CHANNELPLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID,
  1387. COUNTRY_CODE_WORLD_WIDE_13};
  1388. u8 *hwinfo;
  1389. if (b_pseudo_test) {
  1390. /* need add */
  1391. return;
  1392. }
  1393. hwinfo = kzalloc(HWSET_MAX_SIZE, GFP_KERNEL);
  1394. if (!hwinfo)
  1395. return;
  1396. if (rtl_get_hwinfo(hw, rtlpriv, HWSET_MAX_SIZE, hwinfo, params))
  1397. goto exit;
  1398. _rtl8723e_read_txpower_info_from_hwpg(hw, rtlefuse->autoload_failflag,
  1399. hwinfo);
  1400. rtl8723e_read_bt_coexist_info_from_hwpg(hw,
  1401. rtlefuse->autoload_failflag, hwinfo);
  1402. if (rtlhal->oem_id != RT_CID_DEFAULT)
  1403. goto exit;
  1404. switch (rtlefuse->eeprom_oemid) {
  1405. case EEPROM_CID_DEFAULT:
  1406. switch (rtlefuse->eeprom_did) {
  1407. case 0x8176:
  1408. switch (rtlefuse->eeprom_svid) {
  1409. case 0x10EC:
  1410. switch (rtlefuse->eeprom_smid) {
  1411. case 0x6151 ... 0x6152:
  1412. case 0x6154 ... 0x6155:
  1413. case 0x6177 ... 0x6180:
  1414. case 0x7151 ... 0x7152:
  1415. case 0x7154 ... 0x7155:
  1416. case 0x7177 ... 0x7180:
  1417. case 0x8151 ... 0x8152:
  1418. case 0x8154 ... 0x8155:
  1419. case 0x8181 ... 0x8182:
  1420. case 0x8184 ... 0x8185:
  1421. case 0x9151 ... 0x9152:
  1422. case 0x9154 ... 0x9155:
  1423. case 0x9181 ... 0x9182:
  1424. case 0x9184 ... 0x9185:
  1425. rtlhal->oem_id = RT_CID_TOSHIBA;
  1426. break;
  1427. case 0x6191 ... 0x6193:
  1428. case 0x7191 ... 0x7193:
  1429. case 0x8191 ... 0x8193:
  1430. case 0x9191 ... 0x9193:
  1431. rtlhal->oem_id = RT_CID_819X_SAMSUNG;
  1432. break;
  1433. case 0x8197:
  1434. case 0x9196:
  1435. rtlhal->oem_id = RT_CID_819X_CLEVO;
  1436. break;
  1437. case 0x8203:
  1438. rtlhal->oem_id = RT_CID_819X_PRONETS;
  1439. break;
  1440. case 0x8195:
  1441. case 0x9195:
  1442. case 0x7194:
  1443. case 0x8200 ... 0x8202:
  1444. case 0x9200:
  1445. rtlhal->oem_id = RT_CID_819X_LENOVO;
  1446. break;
  1447. }
  1448. break;
  1449. case 0x1025:
  1450. rtlhal->oem_id = RT_CID_819X_ACER;
  1451. break;
  1452. case 0x1028:
  1453. switch (rtlefuse->eeprom_smid) {
  1454. case 0x8194:
  1455. case 0x8198:
  1456. case 0x9197 ... 0x9198:
  1457. rtlhal->oem_id = RT_CID_819X_DELL;
  1458. break;
  1459. }
  1460. break;
  1461. case 0x103C:
  1462. switch (rtlefuse->eeprom_smid) {
  1463. case 0x1629:
  1464. rtlhal->oem_id = RT_CID_819X_HP;
  1465. }
  1466. break;
  1467. case 0x1A32:
  1468. switch (rtlefuse->eeprom_smid) {
  1469. case 0x2315:
  1470. rtlhal->oem_id = RT_CID_819X_QMI;
  1471. break;
  1472. }
  1473. break;
  1474. case 0x1043:
  1475. switch (rtlefuse->eeprom_smid) {
  1476. case 0x84B5:
  1477. rtlhal->oem_id =
  1478. RT_CID_819X_EDIMAX_ASUS;
  1479. }
  1480. break;
  1481. }
  1482. break;
  1483. case 0x8178:
  1484. switch (rtlefuse->eeprom_svid) {
  1485. case 0x10ec:
  1486. switch (rtlefuse->eeprom_smid) {
  1487. case 0x6181 ... 0x6182:
  1488. case 0x6184 ... 0x6185:
  1489. case 0x7181 ... 0x7182:
  1490. case 0x7184 ... 0x7185:
  1491. case 0x8181 ... 0x8182:
  1492. case 0x8184 ... 0x8185:
  1493. case 0x9181 ... 0x9182:
  1494. case 0x9184 ... 0x9185:
  1495. rtlhal->oem_id = RT_CID_TOSHIBA;
  1496. break;
  1497. case 0x8186:
  1498. rtlhal->oem_id =
  1499. RT_CID_819X_PRONETS;
  1500. break;
  1501. }
  1502. break;
  1503. case 0x1025:
  1504. rtlhal->oem_id = RT_CID_819X_ACER;
  1505. break;
  1506. case 0x1043:
  1507. switch (rtlefuse->eeprom_smid) {
  1508. case 0x8486:
  1509. rtlhal->oem_id =
  1510. RT_CID_819X_EDIMAX_ASUS;
  1511. }
  1512. break;
  1513. }
  1514. break;
  1515. }
  1516. break;
  1517. case EEPROM_CID_TOSHIBA:
  1518. rtlhal->oem_id = RT_CID_TOSHIBA;
  1519. break;
  1520. case EEPROM_CID_CCX:
  1521. rtlhal->oem_id = RT_CID_CCX;
  1522. break;
  1523. case EEPROM_CID_QMI:
  1524. rtlhal->oem_id = RT_CID_819X_QMI;
  1525. break;
  1526. case EEPROM_CID_WHQL:
  1527. break;
  1528. default:
  1529. rtlhal->oem_id = RT_CID_DEFAULT;
  1530. break;
  1531. }
  1532. exit:
  1533. kfree(hwinfo);
  1534. }
  1535. static void _rtl8723e_hal_customized_behavior(struct ieee80211_hw *hw)
  1536. {
  1537. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1538. struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
  1539. rtlpriv->ledctl.led_opendrain = true;
  1540. switch (rtlhal->oem_id) {
  1541. case RT_CID_819X_HP:
  1542. rtlpriv->ledctl.led_opendrain = true;
  1543. break;
  1544. case RT_CID_819X_LENOVO:
  1545. case RT_CID_DEFAULT:
  1546. case RT_CID_TOSHIBA:
  1547. case RT_CID_CCX:
  1548. case RT_CID_819X_ACER:
  1549. case RT_CID_WHQL:
  1550. default:
  1551. break;
  1552. }
  1553. RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG,
  1554. "RT Customized ID: 0x%02X\n", rtlhal->oem_id);
  1555. }
  1556. void rtl8723e_read_eeprom_info(struct ieee80211_hw *hw)
  1557. {
  1558. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1559. struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
  1560. struct rtl_phy *rtlphy = &(rtlpriv->phy);
  1561. struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
  1562. u8 tmp_u1b;
  1563. u32 value32;
  1564. value32 = rtl_read_dword(rtlpriv, rtlpriv->cfg->maps[EFUSE_TEST]);
  1565. value32 = (value32 & ~EFUSE_SEL_MASK) | EFUSE_SEL(EFUSE_WIFI_SEL_0);
  1566. rtl_write_dword(rtlpriv, rtlpriv->cfg->maps[EFUSE_TEST], value32);
  1567. rtlhal->version = _rtl8723e_read_chip_version(hw);
  1568. if (get_rf_type(rtlphy) == RF_1T1R)
  1569. rtlpriv->dm.rfpath_rxenable[0] = true;
  1570. else
  1571. rtlpriv->dm.rfpath_rxenable[0] =
  1572. rtlpriv->dm.rfpath_rxenable[1] = true;
  1573. RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "VersionID = 0x%4x\n",
  1574. rtlhal->version);
  1575. tmp_u1b = rtl_read_byte(rtlpriv, REG_9346CR);
  1576. if (tmp_u1b & BIT(4)) {
  1577. RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EEPROM\n");
  1578. rtlefuse->epromtype = EEPROM_93C46;
  1579. } else {
  1580. RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "Boot from EFUSE\n");
  1581. rtlefuse->epromtype = EEPROM_BOOT_EFUSE;
  1582. }
  1583. if (tmp_u1b & BIT(5)) {
  1584. RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n");
  1585. rtlefuse->autoload_failflag = false;
  1586. _rtl8723e_read_adapter_info(hw, false);
  1587. } else {
  1588. rtlefuse->autoload_failflag = true;
  1589. _rtl8723e_read_adapter_info(hw, false);
  1590. pr_err("Autoload ERR!!\n");
  1591. }
  1592. _rtl8723e_hal_customized_behavior(hw);
  1593. }
  1594. static void rtl8723e_update_hal_rate_table(struct ieee80211_hw *hw,
  1595. struct ieee80211_sta *sta)
  1596. {
  1597. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1598. struct rtl_phy *rtlphy = &(rtlpriv->phy);
  1599. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  1600. struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
  1601. u32 ratr_value;
  1602. u8 ratr_index = 0;
  1603. u8 b_nmode = mac->ht_enable;
  1604. u16 shortgi_rate;
  1605. u32 tmp_ratr_value;
  1606. u8 curtxbw_40mhz = mac->bw_40;
  1607. u8 curshortgi_40mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ?
  1608. 1 : 0;
  1609. u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ?
  1610. 1 : 0;
  1611. enum wireless_mode wirelessmode = mac->mode;
  1612. u32 ratr_mask;
  1613. if (rtlhal->current_bandtype == BAND_ON_5G)
  1614. ratr_value = sta->supp_rates[1] << 4;
  1615. else
  1616. ratr_value = sta->supp_rates[0];
  1617. if (mac->opmode == NL80211_IFTYPE_ADHOC)
  1618. ratr_value = 0xfff;
  1619. ratr_value |= (sta->ht_cap.mcs.rx_mask[1] << 20 |
  1620. sta->ht_cap.mcs.rx_mask[0] << 12);
  1621. switch (wirelessmode) {
  1622. case WIRELESS_MODE_B:
  1623. if (ratr_value & 0x0000000c)
  1624. ratr_value &= 0x0000000d;
  1625. else
  1626. ratr_value &= 0x0000000f;
  1627. break;
  1628. case WIRELESS_MODE_G:
  1629. ratr_value &= 0x00000FF5;
  1630. break;
  1631. case WIRELESS_MODE_N_24G:
  1632. case WIRELESS_MODE_N_5G:
  1633. b_nmode = 1;
  1634. if (get_rf_type(rtlphy) == RF_1T2R ||
  1635. get_rf_type(rtlphy) == RF_1T1R)
  1636. ratr_mask = 0x000ff005;
  1637. else
  1638. ratr_mask = 0x0f0ff005;
  1639. ratr_value &= ratr_mask;
  1640. break;
  1641. default:
  1642. if (rtlphy->rf_type == RF_1T2R)
  1643. ratr_value &= 0x000ff0ff;
  1644. else
  1645. ratr_value &= 0x0f0ff0ff;
  1646. break;
  1647. }
  1648. if ((rtlpriv->btcoexist.bt_coexistence) &&
  1649. (rtlpriv->btcoexist.bt_coexist_type == BT_CSR_BC4) &&
  1650. (rtlpriv->btcoexist.bt_cur_state) &&
  1651. (rtlpriv->btcoexist.bt_ant_isolation) &&
  1652. ((rtlpriv->btcoexist.bt_service == BT_SCO) ||
  1653. (rtlpriv->btcoexist.bt_service == BT_BUSY)))
  1654. ratr_value &= 0x0fffcfc0;
  1655. else
  1656. ratr_value &= 0x0FFFFFFF;
  1657. if (b_nmode &&
  1658. ((curtxbw_40mhz && curshortgi_40mhz) ||
  1659. (!curtxbw_40mhz && curshortgi_20mhz))) {
  1660. ratr_value |= 0x10000000;
  1661. tmp_ratr_value = (ratr_value >> 12);
  1662. for (shortgi_rate = 15; shortgi_rate > 0; shortgi_rate--) {
  1663. if ((1 << shortgi_rate) & tmp_ratr_value)
  1664. break;
  1665. }
  1666. shortgi_rate = (shortgi_rate << 12) | (shortgi_rate << 8) |
  1667. (shortgi_rate << 4) | (shortgi_rate);
  1668. }
  1669. rtl_write_dword(rtlpriv, REG_ARFR0 + ratr_index * 4, ratr_value);
  1670. RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG,
  1671. "%x\n", rtl_read_dword(rtlpriv, REG_ARFR0));
  1672. }
  1673. static void rtl8723e_update_hal_rate_mask(struct ieee80211_hw *hw,
  1674. struct ieee80211_sta *sta,
  1675. u8 rssi_level, bool update_bw)
  1676. {
  1677. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1678. struct rtl_phy *rtlphy = &(rtlpriv->phy);
  1679. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  1680. struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
  1681. struct rtl_sta_info *sta_entry = NULL;
  1682. u32 ratr_bitmap;
  1683. u8 ratr_index;
  1684. u8 curtxbw_40mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40)
  1685. ? 1 : 0;
  1686. u8 curshortgi_40mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_40) ?
  1687. 1 : 0;
  1688. u8 curshortgi_20mhz = (sta->ht_cap.cap & IEEE80211_HT_CAP_SGI_20) ?
  1689. 1 : 0;
  1690. enum wireless_mode wirelessmode = 0;
  1691. bool shortgi = false;
  1692. u8 rate_mask[5];
  1693. u8 macid = 0;
  1694. /*u8 mimo_ps = IEEE80211_SMPS_OFF;*/
  1695. sta_entry = (struct rtl_sta_info *)sta->drv_priv;
  1696. wirelessmode = sta_entry->wireless_mode;
  1697. if (mac->opmode == NL80211_IFTYPE_STATION)
  1698. curtxbw_40mhz = mac->bw_40;
  1699. else if (mac->opmode == NL80211_IFTYPE_AP ||
  1700. mac->opmode == NL80211_IFTYPE_ADHOC)
  1701. macid = sta->aid + 1;
  1702. if (rtlhal->current_bandtype == BAND_ON_5G)
  1703. ratr_bitmap = sta->supp_rates[1] << 4;
  1704. else
  1705. ratr_bitmap = sta->supp_rates[0];
  1706. if (mac->opmode == NL80211_IFTYPE_ADHOC)
  1707. ratr_bitmap = 0xfff;
  1708. ratr_bitmap |= (sta->ht_cap.mcs.rx_mask[1] << 20 |
  1709. sta->ht_cap.mcs.rx_mask[0] << 12);
  1710. switch (wirelessmode) {
  1711. case WIRELESS_MODE_B:
  1712. ratr_index = RATR_INX_WIRELESS_B;
  1713. if (ratr_bitmap & 0x0000000c)
  1714. ratr_bitmap &= 0x0000000d;
  1715. else
  1716. ratr_bitmap &= 0x0000000f;
  1717. break;
  1718. case WIRELESS_MODE_G:
  1719. ratr_index = RATR_INX_WIRELESS_GB;
  1720. if (rssi_level == 1)
  1721. ratr_bitmap &= 0x00000f00;
  1722. else if (rssi_level == 2)
  1723. ratr_bitmap &= 0x00000ff0;
  1724. else
  1725. ratr_bitmap &= 0x00000ff5;
  1726. break;
  1727. case WIRELESS_MODE_A:
  1728. ratr_index = RATR_INX_WIRELESS_G;
  1729. ratr_bitmap &= 0x00000ff0;
  1730. break;
  1731. case WIRELESS_MODE_N_24G:
  1732. case WIRELESS_MODE_N_5G:
  1733. ratr_index = RATR_INX_WIRELESS_NGB;
  1734. if (rtlphy->rf_type == RF_1T2R ||
  1735. rtlphy->rf_type == RF_1T1R) {
  1736. if (curtxbw_40mhz) {
  1737. if (rssi_level == 1)
  1738. ratr_bitmap &= 0x000f0000;
  1739. else if (rssi_level == 2)
  1740. ratr_bitmap &= 0x000ff000;
  1741. else
  1742. ratr_bitmap &= 0x000ff015;
  1743. } else {
  1744. if (rssi_level == 1)
  1745. ratr_bitmap &= 0x000f0000;
  1746. else if (rssi_level == 2)
  1747. ratr_bitmap &= 0x000ff000;
  1748. else
  1749. ratr_bitmap &= 0x000ff005;
  1750. }
  1751. } else {
  1752. if (curtxbw_40mhz) {
  1753. if (rssi_level == 1)
  1754. ratr_bitmap &= 0x0f0f0000;
  1755. else if (rssi_level == 2)
  1756. ratr_bitmap &= 0x0f0ff000;
  1757. else
  1758. ratr_bitmap &= 0x0f0ff015;
  1759. } else {
  1760. if (rssi_level == 1)
  1761. ratr_bitmap &= 0x0f0f0000;
  1762. else if (rssi_level == 2)
  1763. ratr_bitmap &= 0x0f0ff000;
  1764. else
  1765. ratr_bitmap &= 0x0f0ff005;
  1766. }
  1767. }
  1768. if ((curtxbw_40mhz && curshortgi_40mhz) ||
  1769. (!curtxbw_40mhz && curshortgi_20mhz)) {
  1770. if (macid == 0)
  1771. shortgi = true;
  1772. else if (macid == 1)
  1773. shortgi = false;
  1774. }
  1775. break;
  1776. default:
  1777. ratr_index = RATR_INX_WIRELESS_NGB;
  1778. if (rtlphy->rf_type == RF_1T2R)
  1779. ratr_bitmap &= 0x000ff0ff;
  1780. else
  1781. ratr_bitmap &= 0x0f0ff0ff;
  1782. break;
  1783. }
  1784. sta_entry->ratr_index = ratr_index;
  1785. RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG,
  1786. "ratr_bitmap :%x\n", ratr_bitmap);
  1787. *(u32 *)&rate_mask = (ratr_bitmap & 0x0fffffff) |
  1788. (ratr_index << 28);
  1789. rate_mask[4] = macid | (shortgi ? 0x20 : 0x00) | 0x80;
  1790. RT_TRACE(rtlpriv, COMP_RATR, DBG_DMESG,
  1791. "Rate_index:%x, ratr_val:%x, %x:%x:%x:%x:%x\n",
  1792. ratr_index, ratr_bitmap,
  1793. rate_mask[0], rate_mask[1],
  1794. rate_mask[2], rate_mask[3],
  1795. rate_mask[4]);
  1796. rtl8723e_fill_h2c_cmd(hw, H2C_RA_MASK, 5, rate_mask);
  1797. }
  1798. void rtl8723e_update_hal_rate_tbl(struct ieee80211_hw *hw,
  1799. struct ieee80211_sta *sta, u8 rssi_level,
  1800. bool update_bw)
  1801. {
  1802. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1803. if (rtlpriv->dm.useramask)
  1804. rtl8723e_update_hal_rate_mask(hw, sta, rssi_level, update_bw);
  1805. else
  1806. rtl8723e_update_hal_rate_table(hw, sta);
  1807. }
  1808. void rtl8723e_update_channel_access_setting(struct ieee80211_hw *hw)
  1809. {
  1810. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1811. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  1812. u16 sifs_timer;
  1813. rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SLOT_TIME, &mac->slot_time);
  1814. if (!mac->ht_enable)
  1815. sifs_timer = 0x0a0a;
  1816. else
  1817. sifs_timer = 0x1010;
  1818. rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_SIFS, (u8 *)&sifs_timer);
  1819. }
  1820. bool rtl8723e_gpio_radio_on_off_checking(struct ieee80211_hw *hw, u8 *valid)
  1821. {
  1822. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1823. struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));
  1824. struct rtl_phy *rtlphy = &(rtlpriv->phy);
  1825. enum rf_pwrstate e_rfpowerstate_toset;
  1826. u8 u1tmp;
  1827. bool b_actuallyset = false;
  1828. if (rtlpriv->rtlhal.being_init_adapter)
  1829. return false;
  1830. if (ppsc->swrf_processing)
  1831. return false;
  1832. spin_lock(&rtlpriv->locks.rf_ps_lock);
  1833. if (ppsc->rfchange_inprogress) {
  1834. spin_unlock(&rtlpriv->locks.rf_ps_lock);
  1835. return false;
  1836. } else {
  1837. ppsc->rfchange_inprogress = true;
  1838. spin_unlock(&rtlpriv->locks.rf_ps_lock);
  1839. }
  1840. rtl_write_byte(rtlpriv, REG_GPIO_IO_SEL_2,
  1841. rtl_read_byte(rtlpriv, REG_GPIO_IO_SEL_2)&~(BIT(1)));
  1842. u1tmp = rtl_read_byte(rtlpriv, REG_GPIO_PIN_CTRL_2);
  1843. if (rtlphy->polarity_ctl)
  1844. e_rfpowerstate_toset = (u1tmp & BIT(1)) ? ERFOFF : ERFON;
  1845. else
  1846. e_rfpowerstate_toset = (u1tmp & BIT(1)) ? ERFON : ERFOFF;
  1847. if (ppsc->hwradiooff && (e_rfpowerstate_toset == ERFON)) {
  1848. RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
  1849. "GPIOChangeRF - HW Radio ON, RF ON\n");
  1850. e_rfpowerstate_toset = ERFON;
  1851. ppsc->hwradiooff = false;
  1852. b_actuallyset = true;
  1853. } else if (!ppsc->hwradiooff && (e_rfpowerstate_toset == ERFOFF)) {
  1854. RT_TRACE(rtlpriv, COMP_RF, DBG_DMESG,
  1855. "GPIOChangeRF - HW Radio OFF, RF OFF\n");
  1856. e_rfpowerstate_toset = ERFOFF;
  1857. ppsc->hwradiooff = true;
  1858. b_actuallyset = true;
  1859. }
  1860. if (b_actuallyset) {
  1861. spin_lock(&rtlpriv->locks.rf_ps_lock);
  1862. ppsc->rfchange_inprogress = false;
  1863. spin_unlock(&rtlpriv->locks.rf_ps_lock);
  1864. } else {
  1865. if (ppsc->reg_rfps_level & RT_RF_OFF_LEVL_HALT_NIC)
  1866. RT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC);
  1867. spin_lock(&rtlpriv->locks.rf_ps_lock);
  1868. ppsc->rfchange_inprogress = false;
  1869. spin_unlock(&rtlpriv->locks.rf_ps_lock);
  1870. }
  1871. *valid = 1;
  1872. return !ppsc->hwradiooff;
  1873. }
  1874. void rtl8723e_set_key(struct ieee80211_hw *hw, u32 key_index,
  1875. u8 *p_macaddr, bool is_group, u8 enc_algo,
  1876. bool is_wepkey, bool clear_all)
  1877. {
  1878. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1879. struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
  1880. struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw));
  1881. u8 *macaddr = p_macaddr;
  1882. u32 entry_id = 0;
  1883. bool is_pairwise = false;
  1884. static u8 cam_const_addr[4][6] = {
  1885. {0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
  1886. {0x00, 0x00, 0x00, 0x00, 0x00, 0x01},
  1887. {0x00, 0x00, 0x00, 0x00, 0x00, 0x02},
  1888. {0x00, 0x00, 0x00, 0x00, 0x00, 0x03}
  1889. };
  1890. static u8 cam_const_broad[] = {
  1891. 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
  1892. };
  1893. if (clear_all) {
  1894. u8 idx = 0;
  1895. u8 cam_offset = 0;
  1896. u8 clear_number = 5;
  1897. RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG, "clear_all\n");
  1898. for (idx = 0; idx < clear_number; idx++) {
  1899. rtl_cam_mark_invalid(hw, cam_offset + idx);
  1900. rtl_cam_empty_entry(hw, cam_offset + idx);
  1901. if (idx < 5) {
  1902. memset(rtlpriv->sec.key_buf[idx], 0,
  1903. MAX_KEY_LEN);
  1904. rtlpriv->sec.key_len[idx] = 0;
  1905. }
  1906. }
  1907. } else {
  1908. switch (enc_algo) {
  1909. case WEP40_ENCRYPTION:
  1910. enc_algo = CAM_WEP40;
  1911. break;
  1912. case WEP104_ENCRYPTION:
  1913. enc_algo = CAM_WEP104;
  1914. break;
  1915. case TKIP_ENCRYPTION:
  1916. enc_algo = CAM_TKIP;
  1917. break;
  1918. case AESCCMP_ENCRYPTION:
  1919. enc_algo = CAM_AES;
  1920. break;
  1921. default:
  1922. RT_TRACE(rtlpriv, COMP_ERR, DBG_LOUD,
  1923. "switch case %#x not processed\n", enc_algo);
  1924. enc_algo = CAM_TKIP;
  1925. break;
  1926. }
  1927. if (is_wepkey || rtlpriv->sec.use_defaultkey) {
  1928. macaddr = cam_const_addr[key_index];
  1929. entry_id = key_index;
  1930. } else {
  1931. if (is_group) {
  1932. macaddr = cam_const_broad;
  1933. entry_id = key_index;
  1934. } else {
  1935. if (mac->opmode == NL80211_IFTYPE_AP) {
  1936. entry_id =
  1937. rtl_cam_get_free_entry(hw, p_macaddr);
  1938. if (entry_id >= TOTAL_CAM_ENTRY) {
  1939. pr_err("Can not find free hw security cam entry\n");
  1940. return;
  1941. }
  1942. } else {
  1943. entry_id = CAM_PAIRWISE_KEY_POSITION;
  1944. }
  1945. key_index = PAIRWISE_KEYIDX;
  1946. is_pairwise = true;
  1947. }
  1948. }
  1949. if (rtlpriv->sec.key_len[key_index] == 0) {
  1950. RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
  1951. "delete one entry, entry_id is %d\n",
  1952. entry_id);
  1953. if (mac->opmode == NL80211_IFTYPE_AP)
  1954. rtl_cam_del_entry(hw, p_macaddr);
  1955. rtl_cam_delete_one_entry(hw, p_macaddr, entry_id);
  1956. } else {
  1957. RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
  1958. "add one entry\n");
  1959. if (is_pairwise) {
  1960. RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
  1961. "set Pairwise key\n");
  1962. rtl_cam_add_one_entry(hw, macaddr, key_index,
  1963. entry_id, enc_algo,
  1964. CAM_CONFIG_NO_USEDK,
  1965. rtlpriv->sec.key_buf[key_index]);
  1966. } else {
  1967. RT_TRACE(rtlpriv, COMP_SEC, DBG_DMESG,
  1968. "set group key\n");
  1969. if (mac->opmode == NL80211_IFTYPE_ADHOC) {
  1970. rtl_cam_add_one_entry(hw,
  1971. rtlefuse->dev_addr,
  1972. PAIRWISE_KEYIDX,
  1973. CAM_PAIRWISE_KEY_POSITION,
  1974. enc_algo,
  1975. CAM_CONFIG_NO_USEDK,
  1976. rtlpriv->sec.key_buf
  1977. [entry_id]);
  1978. }
  1979. rtl_cam_add_one_entry(hw, macaddr, key_index,
  1980. entry_id, enc_algo,
  1981. CAM_CONFIG_NO_USEDK,
  1982. rtlpriv->sec.key_buf[entry_id]);
  1983. }
  1984. }
  1985. }
  1986. }
  1987. static void rtl8723e_bt_var_init(struct ieee80211_hw *hw)
  1988. {
  1989. struct rtl_priv *rtlpriv = rtl_priv(hw);
  1990. rtlpriv->btcoexist.bt_coexistence =
  1991. rtlpriv->btcoexist.eeprom_bt_coexist;
  1992. rtlpriv->btcoexist.bt_ant_num =
  1993. rtlpriv->btcoexist.eeprom_bt_ant_num;
  1994. rtlpriv->btcoexist.bt_coexist_type =
  1995. rtlpriv->btcoexist.eeprom_bt_type;
  1996. rtlpriv->btcoexist.bt_ant_isolation =
  1997. rtlpriv->btcoexist.eeprom_bt_ant_isol;
  1998. rtlpriv->btcoexist.bt_radio_shared_type =
  1999. rtlpriv->btcoexist.eeprom_bt_radio_shared;
  2000. RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
  2001. "BT Coexistence = 0x%x\n",
  2002. rtlpriv->btcoexist.bt_coexistence);
  2003. if (rtlpriv->btcoexist.bt_coexistence) {
  2004. rtlpriv->btcoexist.bt_busy_traffic = false;
  2005. rtlpriv->btcoexist.bt_traffic_mode_set = false;
  2006. rtlpriv->btcoexist.bt_non_traffic_mode_set = false;
  2007. rtlpriv->btcoexist.cstate = 0;
  2008. rtlpriv->btcoexist.previous_state = 0;
  2009. if (rtlpriv->btcoexist.bt_ant_num == ANT_X2) {
  2010. RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
  2011. "BlueTooth BT_Ant_Num = Antx2\n");
  2012. } else if (rtlpriv->btcoexist.bt_ant_num == ANT_X1) {
  2013. RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
  2014. "BlueTooth BT_Ant_Num = Antx1\n");
  2015. }
  2016. switch (rtlpriv->btcoexist.bt_coexist_type) {
  2017. case BT_2WIRE:
  2018. RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
  2019. "BlueTooth BT_CoexistType = BT_2Wire\n");
  2020. break;
  2021. case BT_ISSC_3WIRE:
  2022. RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
  2023. "BlueTooth BT_CoexistType = BT_ISSC_3Wire\n");
  2024. break;
  2025. case BT_ACCEL:
  2026. RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
  2027. "BlueTooth BT_CoexistType = BT_ACCEL\n");
  2028. break;
  2029. case BT_CSR_BC4:
  2030. RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
  2031. "BlueTooth BT_CoexistType = BT_CSR_BC4\n");
  2032. break;
  2033. case BT_CSR_BC8:
  2034. RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
  2035. "BlueTooth BT_CoexistType = BT_CSR_BC8\n");
  2036. break;
  2037. case BT_RTL8756:
  2038. RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
  2039. "BlueTooth BT_CoexistType = BT_RTL8756\n");
  2040. break;
  2041. default:
  2042. RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
  2043. "BlueTooth BT_CoexistType = Unknown\n");
  2044. break;
  2045. }
  2046. RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
  2047. "BlueTooth BT_Ant_isolation = %d\n",
  2048. rtlpriv->btcoexist.bt_ant_isolation);
  2049. RT_TRACE(rtlpriv, COMP_BT_COEXIST, DBG_TRACE,
  2050. "BT_RadioSharedType = 0x%x\n",
  2051. rtlpriv->btcoexist.bt_radio_shared_type);
  2052. rtlpriv->btcoexist.bt_active_zero_cnt = 0;
  2053. rtlpriv->btcoexist.cur_bt_disabled = false;
  2054. rtlpriv->btcoexist.pre_bt_disabled = false;
  2055. }
  2056. }
  2057. void rtl8723e_read_bt_coexist_info_from_hwpg(struct ieee80211_hw *hw,
  2058. bool auto_load_fail, u8 *hwinfo)
  2059. {
  2060. struct rtl_priv *rtlpriv = rtl_priv(hw);
  2061. u8 value;
  2062. u32 tmpu_32;
  2063. if (!auto_load_fail) {
  2064. tmpu_32 = rtl_read_dword(rtlpriv, REG_MULTI_FUNC_CTRL);
  2065. if (tmpu_32 & BIT(18))
  2066. rtlpriv->btcoexist.eeprom_bt_coexist = 1;
  2067. else
  2068. rtlpriv->btcoexist.eeprom_bt_coexist = 0;
  2069. value = hwinfo[RF_OPTION4];
  2070. rtlpriv->btcoexist.eeprom_bt_type = BT_RTL8723A;
  2071. rtlpriv->btcoexist.eeprom_bt_ant_num = (value & 0x1);
  2072. rtlpriv->btcoexist.eeprom_bt_ant_isol = ((value & 0x10) >> 4);
  2073. rtlpriv->btcoexist.eeprom_bt_radio_shared =
  2074. ((value & 0x20) >> 5);
  2075. } else {
  2076. rtlpriv->btcoexist.eeprom_bt_coexist = 0;
  2077. rtlpriv->btcoexist.eeprom_bt_type = BT_RTL8723A;
  2078. rtlpriv->btcoexist.eeprom_bt_ant_num = ANT_X2;
  2079. rtlpriv->btcoexist.eeprom_bt_ant_isol = 0;
  2080. rtlpriv->btcoexist.eeprom_bt_radio_shared = BT_RADIO_SHARED;
  2081. }
  2082. rtl8723e_bt_var_init(hw);
  2083. }
  2084. void rtl8723e_bt_reg_init(struct ieee80211_hw *hw)
  2085. {
  2086. struct rtl_priv *rtlpriv = rtl_priv(hw);
  2087. /* 0:Low, 1:High, 2:From Efuse. */
  2088. rtlpriv->btcoexist.reg_bt_iso = 2;
  2089. /* 0:Idle, 1:None-SCO, 2:SCO, 3:From Counter. */
  2090. rtlpriv->btcoexist.reg_bt_sco = 3;
  2091. /* 0:Disable BT control A-MPDU, 1:Enable BT control A-MPDU. */
  2092. rtlpriv->btcoexist.reg_bt_sco = 0;
  2093. }
  2094. void rtl8723e_bt_hw_init(struct ieee80211_hw *hw)
  2095. {
  2096. struct rtl_priv *rtlpriv = rtl_priv(hw);
  2097. if (rtlpriv->cfg->ops->get_btc_status())
  2098. rtlpriv->btcoexist.btc_ops->btc_init_hw_config(rtlpriv);
  2099. }
  2100. void rtl8723e_suspend(struct ieee80211_hw *hw)
  2101. {
  2102. }
  2103. void rtl8723e_resume(struct ieee80211_hw *hw)
  2104. {
  2105. }