]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
rtw89: 8852c: implement chip_ops::get_thermal
authorPing-Ke Shih <pkshih@realtek.com>
Thu, 21 Apr 2022 12:09:01 +0000 (20:09 +0800)
committerKalle Valo <kvalo@kernel.org>
Sun, 24 Apr 2022 11:30:36 +0000 (14:30 +0300)
Read thermal value, and then we can use EWMA thermal value to do RF
calibrations if the value is changed over a threshold.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220421120903.73715-13-pkshih@realtek.com
drivers/net/wireless/realtek/rtw89/rtw8852c.c

index adcc2b597419df5e20bd91c69ff3f0d0b6d5e8fa..daf467eaef665c27914117f6345e63da3d6ee62c 100644 (file)
@@ -2327,6 +2327,17 @@ static void rtw8852c_bb_cfg_txrx_path(struct rtw89_dev *rtwdev)
        rtw8852c_ctrl_tx_path_tmac(rtwdev, RF_PATH_AB, RTW89_MAC_0);
 }
 
+static u8 rtw8852c_get_thermal(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path)
+{
+       rtw89_write_rf(rtwdev, rf_path, RR_TM, RR_TM_TRI, 0x1);
+       rtw89_write_rf(rtwdev, rf_path, RR_TM, RR_TM_TRI, 0x0);
+       rtw89_write_rf(rtwdev, rf_path, RR_TM, RR_TM_TRI, 0x1);
+
+       fsleep(200);
+
+       return rtw89_read_rf(rtwdev, rf_path, RR_TM, RR_TM_VAL);
+}
+
 static void rtw8852c_ctrl_btg(struct rtw89_dev *rtwdev, bool btg)
 {
        if (btg) {
@@ -2487,6 +2498,7 @@ static const struct rtw89_chip_ops rtw8852c_chip_ops = {
        .set_txpwr              = rtw8852c_set_txpwr,
        .set_txpwr_ctrl         = rtw8852c_set_txpwr_ctrl,
        .init_txpwr_unit        = rtw8852c_init_txpwr_unit,
+       .get_thermal            = rtw8852c_get_thermal,
        .read_rf                = rtw89_phy_read_rf_v1,
        .write_rf               = rtw89_phy_write_rf_v1,
        .set_txpwr_ul_tb_offset = rtw8852c_set_txpwr_ul_tb_offset,