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

wifi: rtw89: parse phycap of TX/RX antenna number

Two fields, TX/RX ANT NUM, are introduced to address variant TX/RX antenna
number of hardware. For example, a 1x1 chip with TX diversity, TX NSS = 1
and TX/RX ANT NUM = 2.
Signed-off-by: default avatarPing-Ke Shih <pkshih@realtek.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220908074140.39776-3-pkshih@realtek.com
parent c7ad08c6
...@@ -2823,6 +2823,7 @@ struct rtw89_hal { ...@@ -2823,6 +2823,7 @@ struct rtw89_hal {
u32 antenna_rx; u32 antenna_rx;
u8 tx_nss; u8 tx_nss;
u8 rx_nss; u8 rx_nss;
bool tx_path_diversity;
bool support_cckpd; bool support_cckpd;
bool support_igi; bool support_igi;
......
...@@ -2264,6 +2264,8 @@ int rtw89_mac_setup_phycap(struct rtw89_dev *rtwdev) ...@@ -2264,6 +2264,8 @@ int rtw89_mac_setup_phycap(struct rtw89_dev *rtwdev)
struct rtw89_mac_c2h_info c2h_info = {0}; struct rtw89_mac_c2h_info c2h_info = {0};
u8 tx_nss; u8 tx_nss;
u8 rx_nss; u8 rx_nss;
u8 tx_ant;
u8 rx_ant;
u32 ret; u32 ret;
ret = rtw89_mac_read_phycap(rtwdev, &c2h_info); ret = rtw89_mac_read_phycap(rtwdev, &c2h_info);
...@@ -2272,14 +2274,30 @@ int rtw89_mac_setup_phycap(struct rtw89_dev *rtwdev) ...@@ -2272,14 +2274,30 @@ int rtw89_mac_setup_phycap(struct rtw89_dev *rtwdev)
tx_nss = RTW89_GET_C2H_PHYCAP_TX_NSS(c2h_info.c2hreg); tx_nss = RTW89_GET_C2H_PHYCAP_TX_NSS(c2h_info.c2hreg);
rx_nss = RTW89_GET_C2H_PHYCAP_RX_NSS(c2h_info.c2hreg); rx_nss = RTW89_GET_C2H_PHYCAP_RX_NSS(c2h_info.c2hreg);
tx_ant = RTW89_GET_C2H_PHYCAP_ANT_TX_NUM(c2h_info.c2hreg);
rx_ant = RTW89_GET_C2H_PHYCAP_ANT_RX_NUM(c2h_info.c2hreg);
hal->tx_nss = tx_nss ? min_t(u8, tx_nss, chip->tx_nss) : chip->tx_nss; hal->tx_nss = tx_nss ? min_t(u8, tx_nss, chip->tx_nss) : chip->tx_nss;
hal->rx_nss = rx_nss ? min_t(u8, rx_nss, chip->rx_nss) : chip->rx_nss; hal->rx_nss = rx_nss ? min_t(u8, rx_nss, chip->rx_nss) : chip->rx_nss;
if (tx_ant == 1)
hal->antenna_tx = RF_B;
if (rx_ant == 1)
hal->antenna_rx = RF_B;
if (tx_nss == 1 && tx_ant == 2 && rx_ant == 2) {
hal->antenna_tx = RF_B;
hal->tx_path_diversity = true;
}
rtw89_debug(rtwdev, RTW89_DBG_FW, rtw89_debug(rtwdev, RTW89_DBG_FW,
"phycap hal/phy/chip: tx_nss=0x%x/0x%x/0x%x rx_nss=0x%x/0x%x/0x%x\n", "phycap hal/phy/chip: tx_nss=0x%x/0x%x/0x%x rx_nss=0x%x/0x%x/0x%x\n",
hal->tx_nss, tx_nss, chip->tx_nss, hal->tx_nss, tx_nss, chip->tx_nss,
hal->rx_nss, rx_nss, chip->rx_nss); hal->rx_nss, rx_nss, chip->rx_nss);
rtw89_debug(rtwdev, RTW89_DBG_FW,
"ant num/bitmap: tx=%d/0x%x rx=%d/0x%x\n",
tx_ant, hal->antenna_tx, rx_ant, hal->antenna_rx);
rtw89_debug(rtwdev, RTW89_DBG_FW, "TX path diversity=%d\n", hal->tx_path_diversity);
return 0; return 0;
} }
......
...@@ -674,12 +674,13 @@ int rtw89_ops_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant) ...@@ -674,12 +674,13 @@ int rtw89_ops_set_antenna(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant)
struct rtw89_dev *rtwdev = hw->priv; struct rtw89_dev *rtwdev = hw->priv;
struct rtw89_hal *hal = &rtwdev->hal; struct rtw89_hal *hal = &rtwdev->hal;
if (rx_ant != hw->wiphy->available_antennas_rx) if (rx_ant != hw->wiphy->available_antennas_rx && rx_ant != hal->antenna_rx)
return -EINVAL; return -EINVAL;
mutex_lock(&rtwdev->mutex); mutex_lock(&rtwdev->mutex);
hal->antenna_tx = tx_ant; hal->antenna_tx = tx_ant;
hal->antenna_rx = rx_ant; hal->antenna_rx = rx_ant;
hal->tx_path_diversity = false;
mutex_unlock(&rtwdev->mutex); mutex_unlock(&rtwdev->mutex);
return 0; return 0;
......
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