Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wifi: rt2x00: rework MT7620 channel config function

1. Move the channel configuration code from rt2800_vco_calibration()
to the rt2800_config_channel().
2. Use MT7620 SoC specific AGC initial LNA value instead of the
RT5592's value.
3. BBP{195,196} pairing write has been replaced with
rt2800_bbp_glrt_write() to reduce redundant code.

Signed-off-by: Shiji Yang <yangshiji66@outlook.com>
Acked-by: Stanislaw Gruszka <stf_xl@wp.pl>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/TYAP286MB0315622A4340BFFA530B1B86BCD4A@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM

authored by

Shiji Yang and committed by
Kalle Valo
a28533c6 1ffe76d5

+35 -56
+35 -56
drivers/net/wireless/ralink/rt2x00/rt2800lib.c
··· 3861 3861 rfcsr |= tx_agc_fc; 3862 3862 rt2800_rfcsr_write_bank(rt2x00dev, 7, 59, rfcsr); 3863 3863 } 3864 - 3865 - if (conf_is_ht40(conf)) { 3866 - rt2800_bbp_glrt_write(rt2x00dev, 141, 0x10); 3867 - rt2800_bbp_glrt_write(rt2x00dev, 157, 0x2f); 3868 - } else { 3869 - rt2800_bbp_glrt_write(rt2x00dev, 141, 0x1a); 3870 - rt2800_bbp_glrt_write(rt2x00dev, 157, 0x40); 3871 - } 3872 3864 } 3873 3865 3874 3866 static void rt2800_config_alc_rt6352(struct rt2x00_dev *rt2x00dev, ··· 4429 4437 usleep_range(1000, 1500); 4430 4438 } 4431 4439 4432 - if (rt2x00_rt(rt2x00dev, RT5592) || rt2x00_rt(rt2x00dev, RT6352)) { 4433 - reg = 0x10; 4434 - if (!conf_is_ht40(conf)) { 4435 - if (rt2x00_rt(rt2x00dev, RT6352) && 4436 - rt2x00_has_cap_external_lna_bg(rt2x00dev)) { 4437 - reg |= 0x5; 4438 - } else { 4439 - reg |= 0xa; 4440 - } 4441 - } 4442 - rt2800_bbp_write(rt2x00dev, 195, 141); 4443 - rt2800_bbp_write(rt2x00dev, 196, reg); 4440 + if (rt2x00_rt(rt2x00dev, RT5592)) { 4441 + bbp = conf_is_ht40(conf) ? 0x10 : 0x1a; 4442 + rt2800_bbp_glrt_write(rt2x00dev, 141, bbp); 4444 4443 4445 - /* AGC init. 4446 - * Despite the vendor driver using different values here for 4447 - * RT6352 chip, we use 0x1c for now. This may have to be changed 4448 - * once TSSI got implemented. 4449 - */ 4450 - reg = (rf->channel <= 14 ? 0x1c : 0x24) + 2*rt2x00dev->lna_gain; 4451 - rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, reg); 4444 + bbp = (rf->channel <= 14 ? 0x1c : 0x24) + 2 * rt2x00dev->lna_gain; 4445 + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, bbp); 4452 4446 4453 - if (rt2x00_rt(rt2x00dev, RT5592)) 4454 - rt2800_iq_calibrate(rt2x00dev, rf->channel); 4447 + rt2800_iq_calibrate(rt2x00dev, rf->channel); 4455 4448 } 4456 4449 4457 4450 if (rt2x00_rt(rt2x00dev, RT6352)) { 4451 + /* BBP for GLRT BW */ 4452 + bbp = conf_is_ht40(conf) ? 4453 + 0x10 : rt2x00_has_cap_external_lna_bg(rt2x00dev) ? 4454 + 0x15 : 0x1a; 4455 + rt2800_bbp_glrt_write(rt2x00dev, 141, bbp); 4456 + 4457 + bbp = conf_is_ht40(conf) ? 0x2f : 0x40; 4458 + rt2800_bbp_glrt_write(rt2x00dev, 157, bbp); 4459 + 4460 + if (rt2x00dev->default_ant.rx_chain_num == 1) { 4461 + rt2800_bbp_write(rt2x00dev, 91, 0x07); 4462 + rt2800_bbp_write(rt2x00dev, 95, 0x1a); 4463 + rt2800_bbp_glrt_write(rt2x00dev, 128, 0xa0); 4464 + rt2800_bbp_glrt_write(rt2x00dev, 170, 0x12); 4465 + rt2800_bbp_glrt_write(rt2x00dev, 171, 0x10); 4466 + } else { 4467 + rt2800_bbp_write(rt2x00dev, 91, 0x06); 4468 + rt2800_bbp_write(rt2x00dev, 95, 0x9a); 4469 + rt2800_bbp_glrt_write(rt2x00dev, 128, 0xe0); 4470 + rt2800_bbp_glrt_write(rt2x00dev, 170, 0x30); 4471 + rt2800_bbp_glrt_write(rt2x00dev, 171, 0x30); 4472 + } 4473 + 4474 + /* AGC init */ 4475 + bbp = rf->channel <= 14 ? 0x04 + 2 * rt2x00dev->lna_gain : 0; 4476 + rt2800_bbp_write_with_rx_chain(rt2x00dev, 66, bbp); 4477 + 4478 + usleep_range(1000, 1500); 4479 + 4458 4480 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, 4459 4481 &rt2x00dev->cap_flags)) { 4460 4482 reg = rt2800_register_read(rt2x00dev, RF_CONTROL3); ··· 5614 5608 rt2800_register_write(rt2x00dev, TX_PIN_CFG, tx_pin); 5615 5609 5616 5610 if (rt2x00_rt(rt2x00dev, RT6352)) { 5617 - if (rt2x00dev->default_ant.rx_chain_num == 1) { 5618 - rt2800_bbp_write(rt2x00dev, 91, 0x07); 5619 - rt2800_bbp_write(rt2x00dev, 95, 0x1A); 5620 - rt2800_bbp_write(rt2x00dev, 195, 128); 5621 - rt2800_bbp_write(rt2x00dev, 196, 0xA0); 5622 - rt2800_bbp_write(rt2x00dev, 195, 170); 5623 - rt2800_bbp_write(rt2x00dev, 196, 0x12); 5624 - rt2800_bbp_write(rt2x00dev, 195, 171); 5625 - rt2800_bbp_write(rt2x00dev, 196, 0x10); 5626 - } else { 5627 - rt2800_bbp_write(rt2x00dev, 91, 0x06); 5628 - rt2800_bbp_write(rt2x00dev, 95, 0x9A); 5629 - rt2800_bbp_write(rt2x00dev, 195, 128); 5630 - rt2800_bbp_write(rt2x00dev, 196, 0xE0); 5631 - rt2800_bbp_write(rt2x00dev, 195, 170); 5632 - rt2800_bbp_write(rt2x00dev, 196, 0x30); 5633 - rt2800_bbp_write(rt2x00dev, 195, 171); 5634 - rt2800_bbp_write(rt2x00dev, 196, 0x30); 5635 - } 5636 - 5637 5611 if (rt2x00_has_cap_external_lna_bg(rt2x00dev)) { 5638 5612 rt2800_bbp_write(rt2x00dev, 75, 0x68); 5639 5613 rt2800_bbp_write(rt2x00dev, 76, 0x4C); ··· 5621 5635 rt2800_bbp_write(rt2x00dev, 80, 0x0C); 5622 5636 rt2800_bbp_write(rt2x00dev, 82, 0xB6); 5623 5637 } 5624 - 5625 - /* On 11A, We should delay and wait RF/BBP to be stable 5626 - * and the appropriate time should be 1000 micro seconds 5627 - * 2005/06/05 - On 11G, we also need this delay time. 5628 - * Otherwise it's difficult to pass the WHQL. 5629 - */ 5630 - usleep_range(1000, 1500); 5631 5638 } 5632 5639 } 5633 5640 EXPORT_SYMBOL_GPL(rt2800_vco_calibration);