Commit bd6f5f27 authored by Ping-Ke Shih's avatar Ping-Ke Shih Committed by Kalle Valo

wifi: rtw89: rfk: add H2C command to trigger TSSI

TSSI is short for transmitter signal strength indication, which is a
close-loop hardware circuit to feedback actual transmitting power as a
reference to adjust power for next transmission.

When connecting and switching bands or channels, do TSSI calibration and
reset hardware status to output expected power.
Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240202030642.108385-9-pkshih@realtek.com
parent af41e89e
......@@ -17,6 +17,7 @@ struct rtw89_pci_info;
struct rtw89_mac_gen_def;
struct rtw89_phy_gen_def;
struct rtw89_efuse_block_cfg;
struct rtw89_h2c_rf_tssi;
struct rtw89_fw_txpwr_track_cfg;
struct rtw89_phy_rfk_log_fmt;
......@@ -4471,6 +4472,11 @@ struct rtw89_cfo_tracking_info {
u8 lock_cnt;
};
enum rtw89_tssi_mode {
RTW89_TSSI_NORMAL = 0,
RTW89_TSSI_SCAN = 1,
};
enum rtw89_tssi_alimk_band {
TSSI_ALIMK_2G = 0,
TSSI_ALIMK_5GL,
......
......@@ -4593,6 +4593,54 @@ int rtw89_fw_h2c_rf_pre_ntfy(struct rtw89_dev *rtwdev,
return ret;
}
int rtw89_fw_h2c_rf_tssi(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx,
enum rtw89_tssi_mode tssi_mode)
{
const struct rtw89_chan *chan = rtw89_chan_get(rtwdev,
RTW89_SUB_ENTITY_0);
struct rtw89_hal *hal = &rtwdev->hal;
struct rtw89_h2c_rf_tssi *h2c;
u32 len = sizeof(*h2c);
struct sk_buff *skb;
int ret;
skb = rtw89_fw_h2c_alloc_skb_with_hdr(rtwdev, len);
if (!skb) {
rtw89_err(rtwdev, "failed to alloc skb for h2c RF TSSI\n");
return -ENOMEM;
}
skb_put(skb, len);
h2c = (struct rtw89_h2c_rf_tssi *)skb->data;
h2c->len = cpu_to_le16(len);
h2c->phy = phy_idx;
h2c->ch = chan->channel;
h2c->bw = chan->band_width;
h2c->band = chan->band_type;
h2c->hwtx_en = true;
h2c->cv = hal->cv;
h2c->tssi_mode = tssi_mode;
rtw89_phy_rfk_tssi_fill_fwcmd_efuse_to_de(rtwdev, phy_idx, chan, h2c);
rtw89_phy_rfk_tssi_fill_fwcmd_tmeter_tbl(rtwdev, phy_idx, chan, h2c);
rtw89_h2c_pkt_set_hdr(rtwdev, skb, FWCMD_TYPE_H2C,
H2C_CAT_OUTSRC, H2C_CL_OUTSRC_RF_FW_RFK,
H2C_FUNC_RFK_TSSI_OFFLOAD, 0, 0, len);
ret = rtw89_h2c_tx(rtwdev, skb, false);
if (ret) {
rtw89_err(rtwdev, "failed to send h2c\n");
goto fail;
}
return 0;
fail:
dev_kfree_skb_any(skb);
return ret;
}
int rtw89_fw_h2c_rf_iqk(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx)
{
struct rtw89_h2c_rf_iqk *h2c;
......
......@@ -3935,6 +3935,7 @@ enum rtw89_mcc_h2c_func {
#define H2C_CL_OUTSRC_RF_FW_RFK 0xb
enum rtw89_rfk_offload_h2c_func {
H2C_FUNC_RFK_TSSI_OFFLOAD = 0x0,
H2C_FUNC_RFK_IQK_OFFLOAD = 0x1,
H2C_FUNC_RFK_DPK_OFFLOAD = 0x3,
H2C_FUNC_RFK_TXGAPK_OFFLOAD = 0x4,
......@@ -3987,6 +3988,35 @@ struct rtw89_fw_h2c_rfk_pre_info {
} __packed mlo;
} __packed;
struct rtw89_h2c_rf_tssi {
__le16 len;
u8 phy;
u8 ch;
u8 bw;
u8 band;
u8 hwtx_en;
u8 cv;
s8 curr_tssi_cck_de[2];
s8 curr_tssi_cck_de_20m[2];
s8 curr_tssi_cck_de_40m[2];
s8 curr_tssi_efuse_cck_de[2];
s8 curr_tssi_ofdm_de[2];
s8 curr_tssi_ofdm_de_20m[2];
s8 curr_tssi_ofdm_de_40m[2];
s8 curr_tssi_ofdm_de_80m[2];
s8 curr_tssi_ofdm_de_160m[2];
s8 curr_tssi_ofdm_de_320m[2];
s8 curr_tssi_efuse_ofdm_de[2];
s8 curr_tssi_ofdm_de_diff_20m[2];
s8 curr_tssi_ofdm_de_diff_80m[2];
s8 curr_tssi_ofdm_de_diff_160m[2];
s8 curr_tssi_ofdm_de_diff_320m[2];
s8 curr_tssi_trim_de[2];
u8 pg_thermal[2];
u8 ftable[2][128];
u8 tssi_mode;
} __packed;
struct rtw89_h2c_rf_iqk {
__le32 phy_idx;
__le32 dbcc;
......@@ -4218,6 +4248,8 @@ int rtw89_fw_h2c_rf_reg(struct rtw89_dev *rtwdev,
int rtw89_fw_h2c_rf_ntfy_mcc(struct rtw89_dev *rtwdev);
int rtw89_fw_h2c_rf_pre_ntfy(struct rtw89_dev *rtwdev,
enum rtw89_phy_idx phy_idx);
int rtw89_fw_h2c_rf_tssi(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx,
enum rtw89_tssi_mode tssi_mode);
int rtw89_fw_h2c_rf_iqk(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx);
int rtw89_fw_h2c_rf_dpk(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx);
int rtw89_fw_h2c_rf_txgapk(struct rtw89_dev *rtwdev, enum rtw89_phy_idx phy_idx);
......
This diff is collapsed.
......@@ -888,6 +888,14 @@ void rtw89_phy_c2h_handle(struct rtw89_dev *rtwdev, struct sk_buff *skb,
void rtw89_phy_rfk_report_prep(struct rtw89_dev *rtwdev);
int rtw89_phy_rfk_report_wait(struct rtw89_dev *rtwdev, const char *rfk_name,
unsigned int ms);
void rtw89_phy_rfk_tssi_fill_fwcmd_efuse_to_de(struct rtw89_dev *rtwdev,
enum rtw89_phy_idx phy,
const struct rtw89_chan *chan,
struct rtw89_h2c_rf_tssi *h2c);
void rtw89_phy_rfk_tssi_fill_fwcmd_tmeter_tbl(struct rtw89_dev *rtwdev,
enum rtw89_phy_idx phy,
const struct rtw89_chan *chan,
struct rtw89_h2c_rf_tssi *h2c);
void rtw89_phy_cfo_track(struct rtw89_dev *rtwdev);
void rtw89_phy_cfo_track_work(struct work_struct *work);
void rtw89_phy_cfo_parse(struct rtw89_dev *rtwdev, s16 cfo_val,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment