From: Ping-Ke Shih <pkshih@realtek.com>
To: <linux-wireless@vger.kernel.org>
Cc: <ku920601@realtek.com>
Subject: [PATCH rtw-next 5/9] wifi: rtw89: coex: Add Bluetooth binding for Bluetooth RX gain setting
Date: Fri, 3 Jul 2026 19:43:07 +0800 [thread overview]
Message-ID: <20260703114311.2609942-6-pkshih@realtek.com> (raw)
In-Reply-To: <20260703114311.2609942-1-pkshih@realtek.com>
From: Ching-Te Ku <ku920601@realtek.com>
Dual Bluetooth the each of Bluetooth may use different RX gain by their
condition.
Signed-off-by: Ching-Te Ku <ku920601@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
drivers/net/wireless/realtek/rtw89/coex.c | 86 ++++++++++++++++++-----
1 file changed, 68 insertions(+), 18 deletions(-)
diff --git a/drivers/net/wireless/realtek/rtw89/coex.c b/drivers/net/wireless/realtek/rtw89/coex.c
index 2080253559a7..ff3c05101ab3 100644
--- a/drivers/net/wireless/realtek/rtw89/coex.c
+++ b/drivers/net/wireless/realtek/rtw89/coex.c
@@ -730,6 +730,7 @@ enum btc_w2b_scoreboard {
BTC_WSCB_SCAN = BIT(2),
BTC_WSCB_UNDERTEST = BIT(3),
BTC_WSCB_RXGAIN = BIT(4),
+ BTC_WSCB_5GHICH = BIT(6),
BTC_WSCB_WLBUSY = BIT(7),
BTC_WSCB_EXTFEM = BIT(8),
BTC_WSCB_TDMA = BIT(9),
@@ -738,6 +739,9 @@ enum btc_w2b_scoreboard {
BTC_WSCB_RXSCAN_PRI = BIT(12),
BTC_WSCB_BT_HILNA = BIT(13),
BTC_WSCB_BTLOG = BIT(14),
+ BTC_WSCB_CTCODE = BIT(15),
+ BTC_WSCB_RXGAIN_56G = BIT(16),
+ BTC_WSCB_BT_HILNA_56G = BIT(17),
BTC_WSCB_ALL = GENMASK(23, 0),
};
@@ -3224,33 +3228,79 @@ static void _set_bt_tx_power(struct rtw89_dev *rtwdev, bool force_exec, u8 bid,
}
#define BTC_BT_RX_NORMAL_LVL 7
-
-static void _set_bt_rx_gain(struct rtw89_dev *rtwdev, u8 level)
+static void _set_bt_rx_gain(struct rtw89_dev *rtwdev, bool force_exec, u8 bid,
+ u8 rf_band, u8 level)
{
struct rtw89_btc *btc = &rtwdev->btc;
- struct rtw89_btc_bt_info *bt = &btc->cx.bt0;
+ struct rtw89_btc_cx *cx = &btc->cx;
+ struct rtw89_btc_bt_info *bt = &cx->bt0;
+ u8 h2c_func = SET_BT_LNA_CONSTRAIN;
+ u8 i, id_start, id_stop;
+ bool state = false;
+ u32 scbd_bit = 0;
+ u8 buf[2] = {};
+ u8 len = sizeof(*buf);
- if (bt->bcnt[BTC_BCNT_INFOUPDATE] == 0)
+ if (bt->bcnt[BTC_BCNT_INFOUPDATE] == 0 || !rf_band)
return;
- if ((bt->rf_para.rx_gain_freerun == level ||
- level > BTC_BT_RX_NORMAL_LVL) &&
- (!rtwdev->chip->scbd || bt->lna_constrain == level))
+ if (bt->rf_para.rx_gain_freerun == level ||
+ level > BTC_BT_RX_NORMAL_LVL || !rtwdev->chip->scbd ||
+ bid > BTC_ALL_BT)
return;
- bt->rf_para.rx_gain_freerun = level;
- btc->dm.rf_trx_para.bt_rx_gain[BTC_BT_1ST] = level;
-
- rtw89_debug(rtwdev, RTW89_DBG_BTC,
- "[BTC], %s(): level = %d\n",
- __func__, level);
+ if (bid == BTC_ALL_BT) {
+ id_start = BTC_BT_1ST;
+ id_stop = BTC_BT_2ND;
+ } else {
+ id_start = bid;
+ id_stop = bid;
+ }
- if (level == BTC_BT_RX_NORMAL_LVL)
- _write_scbd(rtwdev, BTC_WSCB_RXGAIN, false);
+ if (rf_band == RTW89_BAND_2G)
+ scbd_bit |= BTC_WSCB_RXGAIN;
else
- _write_scbd(rtwdev, BTC_WSCB_RXGAIN, true);
+ scbd_bit |= BTC_WSCB_RXGAIN_56G;
+
+ for (i = id_start; i <= id_stop; i++) {
+ if (i == BTC_BT_2ND) {
+ if (!(rtwdev->chip->para_ver & BTC_FEAT_DUAL_BT))
+ continue;
+
+ bt = &cx->bt1;
+ h2c_func |= BT_H2C_FUNC_BT2ND;
+ }
+
+ /* return if same setup */
+ if (!force_exec && !btc->cli_h2c_cmd) {
+ if (rf_band == RTW89_BAND_2G &&
+ bt->lna_constrain == level)
+ continue;
+ else if (rf_band != RTW89_BAND_2G &&
+ bt->lna_constrain_6g == level)
+ continue;
+ }
+
+ buf[0] = level;
+ buf[1] = rf_band;
+
+ if (rtwdev->chip->chip_gen == RTW89_CHIP_AX)
+ len = SET_RF_PARA_AX_LEN;
+
+ if (_send_fw_cmd(rtwdev, BTFC_SET, h2c_func, buf, len)) {
+ rtw89_debug(rtwdev, RTW89_DBG_BTC,
+ "[BTC], %s(): bt%d_rx_gain_level = %d\n",
+ __func__, i, level);
+ }
+
+ btc->dm.rf_trx_para.bt_rx_gain[i] = level;
+
+ if (buf[0] != BTC_BT_RX_NORMAL_LVL)
+ state = true;
+
+ _write_scbd(rtwdev, scbd_bit, state);
+ }
- _send_fw_cmd(rtwdev, BTFC_SET, SET_BT_LNA_CONSTRAIN, &level, sizeof(level));
}
static void _set_rf_trx_para(struct rtw89_dev *rtwdev)
@@ -3361,7 +3411,7 @@ static void _set_rf_trx_para(struct rtw89_dev *rtwdev)
_set_wl_tx_power(rtwdev, para.wl_tx_power[RTW89_PHY_0], RTW89_PHY_0);
_set_wl_rx_gain(rtwdev, para.wl_rx_gain[RTW89_PHY_0], RTW89_PHY_0);
_set_bt_tx_power(rtwdev, true, bid, rf_band, para.bt_tx_power[BTC_BT_1ST]);
- _set_bt_rx_gain(rtwdev, para.bt_rx_gain[BTC_BT_1ST]);
+ _set_bt_rx_gain(rtwdev, true, bid, rf_band, para.bt_rx_gain[BTC_BT_1ST]);
}
next:
--
2.25.1
next prev parent reply other threads:[~2026-07-03 11:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 11:43 [PATCH rtw-next 0/9] wifi: rtw89: coex: implement components for dual Bluetooth Ping-Ke Shih
2026-07-03 11:43 ` [PATCH rtw-next 1/9] wifi: rtw89: coex: Add Init info version 10 Ping-Ke Shih
2026-07-03 11:43 ` [PATCH rtw-next 2/9] wifi: rtw89: coex: add rtw89_btc_init() entry for initialization once Ping-Ke Shih
2026-07-03 11:43 ` [PATCH rtw-next 3/9] wifi: rtw89: coex: Update TDMA descriptor for dual MAC Ping-Ke Shih
2026-07-03 11:43 ` [PATCH rtw-next 4/9] wifi: rtw89: coex: Add Bluetooth binding for Bluetooth TX power setting Ping-Ke Shih
2026-07-03 11:43 ` Ping-Ke Shih [this message]
2026-07-03 11:43 ` [PATCH rtw-next 6/9] wifi: rtw89: coex: Add WiFi/Bluetooth adapter binding info Ping-Ke Shih
2026-07-03 11:43 ` [PATCH rtw-next 7/9] wifi: rtw89: coex: Add TDMA binding for dual MAC Ping-Ke Shih
2026-07-03 11:43 ` [PATCH rtw-next 8/9] wifi: rtw89: coex: Update scoreboard related logic for dual Bluetooth Ping-Ke Shih
2026-07-03 11:43 ` [PATCH rtw-next 9/9] wifi: rtw89: coex: Add Co-RX logic Ping-Ke Shih
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260703114311.2609942-6-pkshih@realtek.com \
--to=pkshih@realtek.com \
--cc=ku920601@realtek.com \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox