• Shiji Yang's avatar
    wifi: rt2x00: limit MT7620 TX power based on eeprom calibration · 821b5192
    Shiji Yang authored
    In the vendor driver, the current channel power is queried from
    EEPROM_TXPOWER_BG1 and EEPROM_TXPOWER_BG2. And then the mixed value
    will be written into the low half-word of the TX_ALC_CFG_0 register.
    The high half-word of the TX_ALC_CFG_0 is a fixed value 0x2f2f.
    
    We can't get the accurate TX power. Based on my tests and the new
    MediaTek mt76 driver source code, the real TX power is approximately
    equal to channel_power + (max) rate_power. Usually max rate_power is
    the gain of the OFDM 6M rate, which can be readed from the offset
    EEPROM_TXPOWER_BYRATE +1.
    
    Based on these eeprom values, this patch adds basic TX power control
    for the MT7620 and limits its maximum TX power. This can avoid the
    link speed decrease caused by chip overheating. rt2800_config_alc()
    function has also been renamed to rt2800_config_alc_rt6352() because
    it's only used by RT6352 (MT7620).
    
    Notice:
    It's still need some work to sync the max channel power to the user
    interface. This part is missing from the rt2x00 driver framework. If
    we set the power exceed the calibration value, it won't take effect.
    Signed-off-by: default avatarShiji Yang <yangshiji66@outlook.com>
    Acked-by: default avatarStanislaw Gruszka <stf_xl@wp.pl>
    Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
    Link: https://lore.kernel.org/r/TYAP286MB03159090ED14044215E59FD6BC10A@TYAP286MB0315.JPNP286.PROD.OUTLOOK.COM
    821b5192
rt2800lib.c 378 KB