All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: <linux-wireless@vger.kernel.org>
Cc: <kevin_yang@realtek.com>
Subject: [PATCH rtw-next v2 10/12] wifi: rtw89: 8922a: support different SAR configs by antenna
Date: Wed, 26 Mar 2025 10:06:41 +0800	[thread overview]
Message-ID: <20250326020643.14487-11-pkshih@realtek.com> (raw)
In-Reply-To: <20250326020643.14487-1-pkshih@realtek.com>

From: Zong-Zhe Yang <kevin_yang@realtek.com>

Set SAR configs to the corresponding CRs (control registers) according to
RF path. Then, declare to support SAR by antenna in chip info.

Signed-off-by: Zong-Zhe Yang <kevin_yang@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
v2: no change
---
 drivers/net/wireless/realtek/rtw89/reg.h      |  3 ++
 drivers/net/wireless/realtek/rtw89/rtw8922a.c | 29 ++++++++++++++++++-
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtw89/reg.h b/drivers/net/wireless/realtek/rtw89/reg.h
index c776954ad360..3c01b4994537 100644
--- a/drivers/net/wireless/realtek/rtw89/reg.h
+++ b/drivers/net/wireless/realtek/rtw89/reg.h
@@ -9360,6 +9360,9 @@
 #define R_TSSI_PWR_P0 0xE610
 #define R_TSSI_PWR_P1 0xE710
 #define B_TSSI_CONT_EN BIT(3)
+#define R_P0_TXPWRB_BE 0xE61C
+#define R_P1_TXPWRB_BE 0xE71C
+#define B_TXPWRB_MAX_BE GENMASK(20, 12)
 #define R_TSSI_MAP_OFST_P0 0xE620
 #define R_TSSI_MAP_OFST_P1 0xE720
 #define B_TSSI_MAP_OFST_OFDM GENMASK(17, 9)
diff --git a/drivers/net/wireless/realtek/rtw89/rtw8922a.c b/drivers/net/wireless/realtek/rtw89/rtw8922a.c
index 5b45c18fbbf6..cc595cae53f5 100644
--- a/drivers/net/wireless/realtek/rtw89/rtw8922a.c
+++ b/drivers/net/wireless/realtek/rtw89/rtw8922a.c
@@ -12,6 +12,7 @@
 #include "reg.h"
 #include "rtw8922a.h"
 #include "rtw8922a_rfk.h"
+#include "sar.h"
 #include "util.h"
 
 #define RTW8922A_FW_FORMAT_MAX 3
@@ -2233,6 +2234,31 @@ static void rtw8922a_set_tx_shape(struct rtw89_dev *rtwdev,
 		rtw8922a_bb_tx_triangular(rtwdev, true, phy_idx);
 }
 
+static void rtw8922a_set_txpwr_sar_diff(struct rtw89_dev *rtwdev,
+					const struct rtw89_chan *chan,
+					enum rtw89_phy_idx phy_idx)
+{
+	struct rtw89_sar_parm sar_parm = {
+		.center_freq = chan->freq,
+		.force_path = true,
+	};
+	s16 sar_rf;
+	s8 sar_mac;
+
+	if (phy_idx != RTW89_PHY_0)
+		return;
+
+	sar_parm.path = RF_PATH_A;
+	sar_mac = rtw89_query_sar(rtwdev, &sar_parm);
+	sar_rf = rtw89_phy_txpwr_mac_to_rf(rtwdev, sar_mac);
+	rtw89_phy_write32_mask(rtwdev, R_P0_TXPWRB_BE, B_TXPWRB_MAX_BE, sar_rf);
+
+	sar_parm.path = RF_PATH_B;
+	sar_mac = rtw89_query_sar(rtwdev, &sar_parm);
+	sar_rf = rtw89_phy_txpwr_mac_to_rf(rtwdev, sar_mac);
+	rtw89_phy_write32_mask(rtwdev, R_P1_TXPWRB_BE, B_TXPWRB_MAX_BE, sar_rf);
+}
+
 static void rtw8922a_set_txpwr(struct rtw89_dev *rtwdev,
 			       const struct rtw89_chan *chan,
 			       enum rtw89_phy_idx phy_idx)
@@ -2244,6 +2270,7 @@ static void rtw8922a_set_txpwr(struct rtw89_dev *rtwdev,
 	rtw89_phy_set_txpwr_limit_ru(rtwdev, chan, phy_idx);
 	rtw8922a_set_txpwr_diff(rtwdev, chan, phy_idx);
 	rtw8922a_set_txpwr_ref(rtwdev, phy_idx);
+	rtw8922a_set_txpwr_sar_diff(rtwdev, chan, phy_idx);
 }
 
 static void rtw8922a_set_txpwr_ctrl(struct rtw89_dev *rtwdev,
@@ -2823,7 +2850,7 @@ const struct rtw89_chip_info rtw8922a_chip_info = {
 	.support_unii4		= true,
 	.support_ant_gain	= true,
 	.support_tas		= false,
-	.support_sar_by_ant	= false,
+	.support_sar_by_ant	= true,
 	.ul_tb_waveform_ctrl	= false,
 	.ul_tb_pwr_diff		= false,
 	.rx_freq_frome_ie	= false,
-- 
2.25.1


  parent reply	other threads:[~2025-03-26  2:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-26  2:06 [PATCH rtw-next v2 00/12] wifi: rtw89: support SAR from BIOS ACPI Ping-Ke Shih
2025-03-26  2:06 ` [PATCH rtw-next v2 01/12] wifi: rtw89: fix typo of "access" in rtw89_sar_info description Ping-Ke Shih
2025-03-31  6:38   ` Ping-Ke Shih
2025-03-26  2:06 ` [PATCH rtw-next v2 02/12] wifi: rtw89: regd: introduce string getter for reuse Ping-Ke Shih
2025-03-26  2:06 ` [PATCH rtw-next v2 03/12] wifi: rtw89: sar: introduce structure to wrap query parameters Ping-Ke Shih
2025-03-26  2:06 ` [PATCH rtw-next v2 04/12] wifi: rtw89: sar: add skeleton for SAR configuration via ACPI Ping-Ke Shih
2025-03-26  2:06 ` [PATCH rtw-next v2 05/12] wifi: rtw89: acpi: introduce method evaluation function for reuse Ping-Ke Shih
2025-03-26  2:06 ` [PATCH rtw-next v2 06/12] wifi: rtw89: acpi: support loading static SAR table Ping-Ke Shih
2025-03-26  2:06 ` [PATCH rtw-next v2 07/12] wifi: rtw89: acpi: support loading dynamic SAR tables and indicator Ping-Ke Shih
2025-03-26  2:06 ` [PATCH rtw-next v2 08/12] wifi: rtw89: acpi: support loading GEO SAR tables Ping-Ke Shih
2025-03-26  2:06 ` [PATCH rtw-next v2 09/12] wifi: rtw89: sar: add skeleton for different configs by antenna Ping-Ke Shih
2025-03-26  2:06 ` Ping-Ke Shih [this message]
2025-03-26  2:06 ` [PATCH rtw-next v2 11/12] wifi: rtw89: 8852c: support different SAR " Ping-Ke Shih
2025-03-26  2:06 ` [PATCH rtw-next v2 12/12] wifi: rtw89: 8852bx: " 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=20250326020643.14487-11-pkshih@realtek.com \
    --to=pkshih@realtek.com \
    --cc=kevin_yang@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.