998-wifi-rt2x00-rework-MT7620-PA-LNA-RF-calibration.patch 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. From: Shiji Yang <yangshiji66@outlook.com>
  2. Date: Tue, 25 Jul 2023 20:05:06 +0800
  3. Subject: [PATCH] wifi: rt2x00: rework MT7620 PA/LNA RF calibration
  4. 1. Move MT7620 PA/LNA calibration code to dedicated functions.
  5. 2. For external PA/LNA devices, restore RF and BBP registers before
  6. R-Calibration.
  7. 3. Do Rx DCOC calibration again before RXIQ calibration.
  8. 4. Correct MAC_SYS_CTRL register RX mask to 0x08 in R-Calibration
  9. function. For MAC_SYS_CTRL register, Bit[2] controls MAC_TX_EN
  10. and Bit[3] controls MAC_RX_EN (Bit index starts from 0).
  11. 5. Move the channel configuration code from rt2800_vco_calibration()
  12. to the rt2800_config_channel().
  13. 6. Use MT7620 SOC specific AGC initial LNA value instead of the
  14. RT5592's value.
  15. 7. Adjust the register operation sequence according to the vendor
  16. driver code. This may not be useful, but it can make things
  17. clearer when developers try to review it.
  18. Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
  19. ---
  20. .../net/wireless/ralink/rt2x00/rt2800lib.c | 306 ++++++++++--------
  21. drivers/net/wireless/ralink/rt2x00/rt2x00.h | 6 +
  22. 2 files changed, 182 insertions(+), 130 deletions(-)
  23. --- a/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  24. +++ b/drivers/net/wireless/ralink/rt2x00/rt2800lib.c
  25. @@ -3881,14 +3881,6 @@ static void rt2800_config_channel_rf7620
  26. rfcsr |= tx_agc_fc;
  27. rt2800_rfcsr_write_bank(rt2x00dev, 7, 59, rfcsr);
  28. }
  29. -
  30. - if (conf_is_ht40(conf)) {
  31. - rt2800_bbp_glrt_write(rt2x00dev, 141, 0x10);
  32. - rt2800_bbp_glrt_write(rt2x00dev, 157, 0x2f);
  33. - } else {
  34. - rt2800_bbp_glrt_write(rt2x00dev, 141, 0x1a);
  35. - rt2800_bbp_glrt_write(rt2x00dev, 157, 0x40);
  36. - }
  37. }
  38. static void rt2800_config_alc_rt6352(struct rt2x00_dev *rt2x00dev,
  39. @@ -4457,89 +4449,63 @@ static void rt2800_config_channel(struct
  40. usleep_range(1000, 1500);
  41. }
  42. - if (rt2x00_rt(rt2x00dev, RT5592) || rt2x00_rt(rt2x00dev, RT6352)) {
  43. + if (rt2x00_rt(rt2x00dev, RT5592)) {
  44. reg = 0x10;
  45. - if (!conf_is_ht40(conf)) {
  46. - if (rt2x00_rt(rt2x00dev, RT6352) &&
  47. - rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
  48. - reg |= 0x5;
  49. - } else {
  50. - reg |= 0xa;
  51. - }
  52. - }
  53. + if (!conf_is_ht40(conf))
  54. + reg |= 0xa;
  55. rt2800_bbp_write(rt2x00dev, 195, 141);
  56. rt2800_bbp_write(rt2x00dev, 196, reg);
  57. - /* AGC init.
  58. - * Despite the vendor driver using different values here for
  59. - * RT6352 chip, we use 0x1c for now. This may have to be changed
  60. - * once TSSI got implemented.
  61. - */
  62. reg = (rf->channel <= 14 ? 0x1c : 0x24) + 2*rt2x00dev->lna_gain;
  63. rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg);
  64. -
  65. - if (rt2x00_rt(rt2x00dev, RT5592))
  66. - rt2800_iq_calibrate(rt2x00dev, rf->channel);
  67. +
  68. + rt2800_iq_calibrate(rt2x00dev, rf->channel);
  69. }
  70. if (rt2x00_rt(rt2x00dev, RT6352)) {
  71. - if (test_bit(CAPABILITY_EXTERNAL_PA_TX0,
  72. - &rt2x00dev->cap_flags)) {
  73. - reg = rt2800_register_read(rt2x00dev, RF_CONTROL3);
  74. - reg |= 0x00000101;
  75. - rt2800_register_write(rt2x00dev, RF_CONTROL3, reg);
  76. -
  77. - reg = rt2800_register_read(rt2x00dev, RF_BYPASS3);
  78. - reg |= 0x00000101;
  79. - rt2800_register_write(rt2x00dev, RF_BYPASS3, reg);
  80. -
  81. - rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0x73);
  82. - rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0x73);
  83. - rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0x73);
  84. - rt2800_rfcsr_write_chanreg(rt2x00dev, 46, 0x27);
  85. - rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0xC8);
  86. - rt2800_rfcsr_write_chanreg(rt2x00dev, 48, 0xA4);
  87. - rt2800_rfcsr_write_chanreg(rt2x00dev, 49, 0x05);
  88. - rt2800_rfcsr_write_chanreg(rt2x00dev, 54, 0x27);
  89. - rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0xC8);
  90. - rt2800_rfcsr_write_chanreg(rt2x00dev, 56, 0xA4);
  91. - rt2800_rfcsr_write_chanreg(rt2x00dev, 57, 0x05);
  92. - rt2800_rfcsr_write_chanreg(rt2x00dev, 58, 0x27);
  93. - rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0xC8);
  94. - rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0xA4);
  95. - rt2800_rfcsr_write_chanreg(rt2x00dev, 61, 0x05);
  96. - rt2800_rfcsr_write_dccal(rt2x00dev, 05, 0x00);
  97. + /* BBP for GLRT BW */
  98. + if (conf_is_ht40(conf)) {
  99. + rt2800_bbp_glrt_write(rt2x00dev, 141, 0x10);
  100. + rt2800_bbp_glrt_write(rt2x00dev, 157, 0x2f);
  101. + } else {
  102. + rt2800_bbp_glrt_write(rt2x00dev, 141, 0x1a);
  103. + rt2800_bbp_glrt_write(rt2x00dev, 157, 0x40);
  104. - rt2800_register_write(rt2x00dev, TX0_RF_GAIN_CORRECT,
  105. - 0x36303636);
  106. - rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN,
  107. - 0x6C6C6B6C);
  108. - rt2800_register_write(rt2x00dev, TX1_RF_GAIN_ATTEN,
  109. - 0x6C6C6B6C);
  110. + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 &&
  111. + rt2x00_has_cap_external_lna_bg(rt2x00dev))
  112. + rt2800_bbp_glrt_write(rt2x00dev, 141, 0x15);
  113. }
  114. - if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
  115. - reg = rt2800_register_read(rt2x00dev, RF_CONTROL3);
  116. - reg |= 0x00000101;
  117. - rt2800_register_write(rt2x00dev, RF_CONTROL3, reg);
  118. -
  119. - reg = rt2800_register_read(rt2x00dev, RF_BYPASS3);
  120. - reg |= 0x00000101;
  121. - rt2800_register_write(rt2x00dev, RF_BYPASS3, reg);
  122. -
  123. - rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x66);
  124. - rt2800_rfcsr_write_chanreg(rt2x00dev, 17, 0x20);
  125. - rt2800_rfcsr_write_chanreg(rt2x00dev, 18, 0x42);
  126. - rt2800_bbp_write(rt2x00dev, 75, 0x68);
  127. - rt2800_bbp_write(rt2x00dev, 76, 0x4C);
  128. - rt2800_bbp_write(rt2x00dev, 79, 0x1C);
  129. - rt2800_bbp_write(rt2x00dev, 80, 0x0C);
  130. - rt2800_bbp_write(rt2x00dev, 82, 0xB6);
  131. - /* bank 0 RF reg 42 and glrt BBP reg 141 will be set in
  132. - * config channel function in dependence of channel and
  133. - * HT20/HT40 so don't touch it
  134. - */
  135. + if (rt2x00dev->default_ant.rx_chain_num == 1) {
  136. + rt2800_bbp_write(rt2x00dev, 91, 0x07);
  137. + rt2800_bbp_write(rt2x00dev, 95, 0x1A);
  138. + rt2800_bbp_write(rt2x00dev, 195, 128);
  139. + rt2800_bbp_write(rt2x00dev, 196, 0xA0);
  140. + rt2800_bbp_write(rt2x00dev, 195, 170);
  141. + rt2800_bbp_write(rt2x00dev, 196, 0x12);
  142. + rt2800_bbp_write(rt2x00dev, 195, 171);
  143. + rt2800_bbp_write(rt2x00dev, 196, 0x10);
  144. + } else {
  145. + rt2800_bbp_write(rt2x00dev, 91, 0x06);
  146. + rt2800_bbp_write(rt2x00dev, 95, 0x9A);
  147. + rt2800_bbp_write(rt2x00dev, 195, 128);
  148. + rt2800_bbp_write(rt2x00dev, 196, 0xE0);
  149. + rt2800_bbp_write(rt2x00dev, 195, 170);
  150. + rt2800_bbp_write(rt2x00dev, 196, 0x30);
  151. + rt2800_bbp_write(rt2x00dev, 195, 171);
  152. + rt2800_bbp_write(rt2x00dev, 196, 0x30);
  153. }
  154. +
  155. + /* AGC init */
  156. + reg = rf->channel <= 14 ? 0x04 + 2 * rt2x00dev->lna_gain : 0;
  157. + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg);
  158. +
  159. + /* On 11A, We should delay and wait RF/BBP to be stable
  160. + * and the appropriate time should be 1000 micro seconds
  161. + * 2005/06/05 - On 11G, we also need this delay time.
  162. + * Otherwise it's difficult to pass the WHQL.
  163. + */
  164. + usleep_range(1000, 1500);
  165. }
  166. bbp = rt2800_bbp_read(rt2x00dev, 4);
  167. @@ -5649,43 +5615,6 @@ void rt2800_vco_calibration(struct rt2x0
  168. }
  169. }
  170. rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin);
  171. -
  172. - if (rt2x00_rt(rt2x00dev, RT6352)) {
  173. - if (rt2x00dev->default_ant.rx_chain_num == 1) {
  174. - rt2800_bbp_write(rt2x00dev, 91, 0x07);
  175. - rt2800_bbp_write(rt2x00dev, 95, 0x1A);
  176. - rt2800_bbp_write(rt2x00dev, 195, 128);
  177. - rt2800_bbp_write(rt2x00dev, 196, 0xA0);
  178. - rt2800_bbp_write(rt2x00dev, 195, 170);
  179. - rt2800_bbp_write(rt2x00dev, 196, 0x12);
  180. - rt2800_bbp_write(rt2x00dev, 195, 171);
  181. - rt2800_bbp_write(rt2x00dev, 196, 0x10);
  182. - } else {
  183. - rt2800_bbp_write(rt2x00dev, 91, 0x06);
  184. - rt2800_bbp_write(rt2x00dev, 95, 0x9A);
  185. - rt2800_bbp_write(rt2x00dev, 195, 128);
  186. - rt2800_bbp_write(rt2x00dev, 196, 0xE0);
  187. - rt2800_bbp_write(rt2x00dev, 195, 170);
  188. - rt2800_bbp_write(rt2x00dev, 196, 0x30);
  189. - rt2800_bbp_write(rt2x00dev, 195, 171);
  190. - rt2800_bbp_write(rt2x00dev, 196, 0x30);
  191. - }
  192. -
  193. - if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
  194. - rt2800_bbp_write(rt2x00dev, 75, 0x68);
  195. - rt2800_bbp_write(rt2x00dev, 76, 0x4C);
  196. - rt2800_bbp_write(rt2x00dev, 79, 0x1C);
  197. - rt2800_bbp_write(rt2x00dev, 80, 0x0C);
  198. - rt2800_bbp_write(rt2x00dev, 82, 0xB6);
  199. - }
  200. -
  201. - /* On 11A, We should delay and wait RF/BBP to be stable
  202. - * and the appropriate time should be 1000 micro seconds
  203. - * 2005/06/05 - On 11G, we also need this delay time.
  204. - * Otherwise it's difficult to pass the WHQL.
  205. - */
  206. - usleep_range(1000, 1500);
  207. - }
  208. }
  209. EXPORT_SYMBOL_GPL(rt2800_vco_calibration);
  210. @@ -8650,7 +8579,7 @@ static void rt2800_r_calibration(struct
  211. rt2x00_warn(rt2x00dev, "Wait MAC Tx Status to MAX !!!\n");
  212. maccfg = rt2800_register_read(rt2x00dev, MAC_SYS_CTRL);
  213. - maccfg &= (~0x04);
  214. + maccfg &= (~0x08);
  215. rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, maccfg);
  216. if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev, MAC_STATUS_CFG_BBP_RF_BUSY_RX)))
  217. @@ -10688,30 +10617,143 @@ static void rt2800_init_rfcsr_6352(struc
  218. rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00);
  219. rt2800_rfcsr_write_dccal(rt2x00dev, 17, 0x7C);
  220. }
  221. +}
  222. - rt6352_enable_pa_pin(rt2x00dev, 0);
  223. - rt2800_r_calibration(rt2x00dev);
  224. - rt2800_rf_self_txdc_cal(rt2x00dev);
  225. - rt2800_rxdcoc_calibration(rt2x00dev);
  226. - rt2800_bw_filter_calibration(rt2x00dev, true);
  227. - rt2800_bw_filter_calibration(rt2x00dev, false);
  228. - rt2800_loft_iq_calibration(rt2x00dev);
  229. - rt2800_rxiq_calibration(rt2x00dev);
  230. - rt6352_enable_pa_pin(rt2x00dev, 1);
  231. +static void rt2800_init_palna_rt6352(struct rt2x00_dev *rt2x00dev)
  232. +{
  233. + u32 reg;
  234. +
  235. + if (rt2x00_has_cap_external_pa(rt2x00dev)) {
  236. + reg = rt2800_register_read(rt2x00dev, RF_CONTROL3);
  237. + reg |= 0x00000101;
  238. + rt2800_register_write(rt2x00dev, RF_CONTROL3, reg);
  239. +
  240. + reg = rt2800_register_read(rt2x00dev, RF_BYPASS3);
  241. + reg |= 0x00000101;
  242. + rt2800_register_write(rt2x00dev, RF_BYPASS3, reg);
  243. + }
  244. - if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
  245. + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 &&
  246. + rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
  247. rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x66);
  248. rt2800_rfcsr_write_chanreg(rt2x00dev, 17, 0x20);
  249. rt2800_rfcsr_write_chanreg(rt2x00dev, 18, 0x42);
  250. + }
  251. +
  252. + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 &&
  253. + rt2x00_has_cap_external_pa(rt2x00dev)) {
  254. + rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0x73);
  255. + rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0x73);
  256. + rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0x73);
  257. + rt2800_rfcsr_write_chanreg(rt2x00dev, 46, 0x27);
  258. + rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0xC8);
  259. + rt2800_rfcsr_write_chanreg(rt2x00dev, 48, 0xA4);
  260. + rt2800_rfcsr_write_chanreg(rt2x00dev, 49, 0x05);
  261. + rt2800_rfcsr_write_chanreg(rt2x00dev, 54, 0x27);
  262. + rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0xC8);
  263. + rt2800_rfcsr_write_chanreg(rt2x00dev, 56, 0xA4);
  264. + rt2800_rfcsr_write_chanreg(rt2x00dev, 57, 0x05);
  265. + rt2800_rfcsr_write_chanreg(rt2x00dev, 58, 0x27);
  266. + rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0xC8);
  267. + rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0xA4);
  268. + rt2800_rfcsr_write_chanreg(rt2x00dev, 61, 0x05);
  269. + }
  270. +
  271. + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 &&
  272. + rt2x00_has_cap_external_pa(rt2x00dev))
  273. + rt2800_rfcsr_write_dccal(rt2x00dev, 05, 0x00);
  274. +
  275. + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 &&
  276. + rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
  277. rt2800_bbp_write(rt2x00dev, 75, 0x68);
  278. rt2800_bbp_write(rt2x00dev, 76, 0x4C);
  279. rt2800_bbp_write(rt2x00dev, 79, 0x1C);
  280. rt2800_bbp_write(rt2x00dev, 80, 0x0C);
  281. rt2800_bbp_write(rt2x00dev, 82, 0xB6);
  282. - /* bank 0 RF reg 42 and glrt BBP reg 141 will be set in config
  283. - * channel function in dependence of channel and HT20/HT40,
  284. - * so don't touch them here.
  285. - */
  286. + }
  287. +
  288. + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 &&
  289. + rt2x00_has_cap_external_pa(rt2x00dev)) {
  290. + rt2800_register_write(rt2x00dev, TX0_RF_GAIN_CORRECT, 0x36303636);
  291. + rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN, 0x6C6C6B6C);
  292. + rt2800_register_write(rt2x00dev, TX1_RF_GAIN_ATTEN, 0x6C6C6B6C);
  293. + }
  294. +}
  295. +
  296. +static void rt2800_restore_rf_bbp_rt6352(struct rt2x00_dev *rt2x00dev)
  297. +{
  298. + if (rt2x00_has_cap_external_pa(rt2x00dev)) {
  299. + rt2800_register_write(rt2x00dev, RF_CONTROL3, 0x0);
  300. + rt2800_register_write(rt2x00dev, RF_BYPASS3, 0x0);
  301. + }
  302. +
  303. + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 &&
  304. + rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
  305. + rt2800_rfcsr_write_chanreg(rt2x00dev, 14, 0x16);
  306. + rt2800_rfcsr_write_chanreg(rt2x00dev, 17, 0x23);
  307. + rt2800_rfcsr_write_chanreg(rt2x00dev, 18, 0x02);
  308. + }
  309. +
  310. + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 &&
  311. + rt2x00_has_cap_external_pa(rt2x00dev)) {
  312. + rt2800_rfcsr_write_chanreg(rt2x00dev, 43, 0xD3);
  313. + rt2800_rfcsr_write_chanreg(rt2x00dev, 44, 0xB3);
  314. + rt2800_rfcsr_write_chanreg(rt2x00dev, 45, 0xD5);
  315. + rt2800_rfcsr_write_chanreg(rt2x00dev, 46, 0x27);
  316. + rt2800_rfcsr_write_chanreg(rt2x00dev, 47, 0x6C);
  317. + rt2800_rfcsr_write_chanreg(rt2x00dev, 48, 0xFC);
  318. + rt2800_rfcsr_write_chanreg(rt2x00dev, 49, 0x1F);
  319. + rt2800_rfcsr_write_chanreg(rt2x00dev, 54, 0x27);
  320. + rt2800_rfcsr_write_chanreg(rt2x00dev, 55, 0x66);
  321. + rt2800_rfcsr_write_chanreg(rt2x00dev, 56, 0xFF);
  322. + rt2800_rfcsr_write_chanreg(rt2x00dev, 57, 0x1C);
  323. + rt2800_rfcsr_write_chanreg(rt2x00dev, 58, 0x20);
  324. + rt2800_rfcsr_write_chanreg(rt2x00dev, 59, 0x6B);
  325. + rt2800_rfcsr_write_chanreg(rt2x00dev, 60, 0xF7);
  326. + rt2800_rfcsr_write_chanreg(rt2x00dev, 61, 0x09);
  327. + }
  328. +
  329. + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 &&
  330. + rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
  331. + rt2800_bbp_write(rt2x00dev, 75, 0x60);
  332. + rt2800_bbp_write(rt2x00dev, 76, 0x44);
  333. + rt2800_bbp_write(rt2x00dev, 79, 0x1C);
  334. + rt2800_bbp_write(rt2x00dev, 80, 0x0C);
  335. + rt2800_bbp_write(rt2x00dev, 82, 0xB6);
  336. + }
  337. +
  338. + if (rt2800_hw_get_chippkg(rt2x00dev) == 1 &&
  339. + rt2x00_has_cap_external_pa(rt2x00dev)) {
  340. + rt2800_register_write(rt2x00dev, TX0_RF_GAIN_CORRECT, 0x3630363A);
  341. + rt2800_register_write(rt2x00dev, TX0_RF_GAIN_ATTEN, 0x6C6C666C);
  342. + rt2800_register_write(rt2x00dev, TX1_RF_GAIN_ATTEN, 0x6C6C666C);
  343. + }
  344. +}
  345. +
  346. +static void rt2800_calibration_rt6352(struct rt2x00_dev *rt2x00dev)
  347. +{
  348. + if (rt2x00_has_cap_external_pa(rt2x00dev) ||
  349. + rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
  350. + rt6352_enable_pa_pin(rt2x00dev, 0);
  351. + rt2800_restore_rf_bbp_rt6352(rt2x00dev);
  352. + }
  353. +
  354. + rt2800_r_calibration(rt2x00dev);
  355. + rt2800_rf_self_txdc_cal(rt2x00dev);
  356. + rt2800_rxdcoc_calibration(rt2x00dev);
  357. + rt2800_bw_filter_calibration(rt2x00dev, true);
  358. + rt2800_bw_filter_calibration(rt2x00dev, false);
  359. + rt2800_loft_iq_calibration(rt2x00dev);
  360. +
  361. + /* missing DPD Calibration for devices using internal PA */
  362. +
  363. + rt2800_rxdcoc_calibration(rt2x00dev);
  364. + rt2800_rxiq_calibration(rt2x00dev);
  365. +
  366. + if (rt2x00_has_cap_external_pa(rt2x00dev) ||
  367. + rt2x00_has_cap_external_lna_bg(rt2x00dev)) {
  368. + rt6352_enable_pa_pin(rt2x00dev, 1);
  369. + rt2800_init_palna_rt6352(rt2x00dev);
  370. }
  371. }
  372. @@ -10804,6 +10846,10 @@ int rt2800_enable_radio(struct rt2x00_de
  373. rt2800_init_bbp(rt2x00dev);
  374. rt2800_init_rfcsr(rt2x00dev);
  375. + /* Do calibration and init PA/LNA for RT6352 */
  376. + if (rt2x00_rt(rt2x00dev, RT6352))
  377. + rt2800_calibration_rt6352(rt2x00dev);
  378. +
  379. if (rt2x00_is_usb(rt2x00dev) &&
  380. (rt2x00_rt(rt2x00dev, RT3070) ||
  381. rt2x00_rt(rt2x00dev, RT3071) ||
  382. --- a/drivers/net/wireless/ralink/rt2x00/rt2x00.h
  383. +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00.h
  384. @@ -1277,6 +1277,12 @@ rt2x00_has_cap_external_lna_bg(struct rt
  385. }
  386. static inline bool
  387. +rt2x00_has_cap_external_pa(struct rt2x00_dev *rt2x00dev)
  388. +{
  389. + return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_EXTERNAL_PA_TX0);
  390. +}
  391. +
  392. +static inline bool
  393. rt2x00_has_cap_double_antenna(struct rt2x00_dev *rt2x00dev)
  394. {
  395. return rt2x00_has_cap_flag(rt2x00dev, CAPABILITY_DOUBLE_ANTENNA);