linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <yhchuang@realtek.com>
To: <kvalo@codeaurora.org>
Cc: <linux-wireless@vger.kernel.org>, <tehuang@realtek.com>
Subject: [PATCH 2/7] rtw88: 8821c: add set tx power index
Date: Wed, 20 May 2020 13:23:30 +0800	[thread overview]
Message-ID: <20200520052335.22466-3-yhchuang@realtek.com> (raw)
In-Reply-To: <20200520052335.22466-1-yhchuang@realtek.com>

From: Tzu-En Huang <tehuang@realtek.com>

To configure the transmit power of 8821c, implements trasmit
power index setting callback function for 8821c, which is very
similar to the callback function of 8822b.

Signed-off-by: Tzu-En Huang <tehuang@realtek.com>
Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
---
 drivers/net/wireless/realtek/rtw88/rtw8821c.c | 39 +++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.c b/drivers/net/wireless/realtek/rtw88/rtw8821c.c
index baf0cf5a35b3..ce580dace83c 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8821c.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.c
@@ -162,6 +162,44 @@ static void rtw8821c_cfg_ldo25(struct rtw_dev *rtwdev, bool enable)
 	rtw_write8(rtwdev, REG_LDO_EFUSE_CTRL + 3, ldo_pwr);
 }
 
+static void
+rtw8821c_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path, u8 rs)
+{
+	struct rtw_hal *hal = &rtwdev->hal;
+	static const u32 offset_txagc[2] = {0x1d00, 0x1d80};
+	static u32 phy_pwr_idx;
+	u8 rate, rate_idx, pwr_index, shift;
+	int j;
+
+	for (j = 0; j < rtw_rate_size[rs]; j++) {
+		rate = rtw_rate_section[rs][j];
+		pwr_index = hal->tx_pwr_tbl[path][rate];
+		shift = rate & 0x3;
+		phy_pwr_idx |= ((u32)pwr_index << (shift * 8));
+		if (shift == 0x3 || rate == DESC_RATEVHT1SS_MCS9) {
+			rate_idx = rate & 0xfc;
+			rtw_write32(rtwdev, offset_txagc[path] + rate_idx,
+				    phy_pwr_idx);
+			phy_pwr_idx = 0;
+		}
+	}
+}
+
+static void rtw8821c_set_tx_power_index(struct rtw_dev *rtwdev)
+{
+	struct rtw_hal *hal = &rtwdev->hal;
+	int rs, path;
+
+	for (path = 0; path < hal->rf_path_num; path++) {
+		for (rs = 0; rs < RTW_RATE_SECTION_MAX; rs++) {
+			if (rs == RTW_RATE_SECTION_HT_2S ||
+			    rs == RTW_RATE_SECTION_VHT_2S)
+				continue;
+			rtw8821c_set_tx_power_index_by_rate(rtwdev, path, rs);
+		}
+	}
+}
+
 static struct rtw_pwr_seq_cmd trans_carddis_to_cardemu_8821c[] = {
 	{0x0086,
 	 RTW_PWR_CUT_ALL_MSK,
@@ -591,6 +629,7 @@ static struct rtw_chip_ops rtw8821c_ops = {
 	.read_rf		= rtw_phy_read_rf,
 	.write_rf		= rtw_phy_write_rf_reg_sipi,
 	.set_antenna		= NULL,
+	.set_tx_power_index	= rtw8821c_set_tx_power_index,
 	.cfg_ldo25		= rtw8821c_cfg_ldo25,
 };
 
-- 
2.17.1


  parent reply	other threads:[~2020-05-20  5:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-20  5:23 [PATCH 0/7] rtw88: 8821c: add basic function routines yhchuang
2020-05-20  5:23 ` [PATCH 1/7] rtw88: 8821c: add basic functions yhchuang
2020-05-28 14:56   ` Sebastian Andrzej Siewior
2020-05-20  5:23 ` yhchuang [this message]
2020-05-28 14:59   ` [PATCH 2/7] rtw88: 8821c: add set tx power index Sebastian Andrzej Siewior
2020-05-20  5:23 ` [PATCH 3/7] rtw88: 8821c: add dig related settings yhchuang
2020-05-28 15:00   ` Sebastian Andrzej Siewior
2020-05-20  5:23 ` [PATCH 4/7] rtw88: 8821c: add set channel support yhchuang
2020-05-28 15:22   ` Sebastian Andrzej Siewior
2020-05-20  5:23 ` [PATCH 5/7] rtw88: 8821c: add query rx desc support yhchuang
2020-05-28 16:09   ` Sebastian Andrzej Siewior
2020-05-29  5:58     ` Tony Chuang
2020-05-20  5:23 ` [PATCH 6/7] rtw88: 8821c: add false alarm statistics yhchuang
2020-05-28 16:19   ` Sebastian Andrzej Siewior
2020-05-20  5:23 ` [PATCH 7/7] rtw88: 8821c: add phy calibration yhchuang
2020-05-28 16:27   ` Sebastian Andrzej Siewior
2020-05-29  6:31     ` Tony Chuang
2020-05-29  7:05       ` Sebastian Andrzej Siewior

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=20200520052335.22466-3-yhchuang@realtek.com \
    --to=yhchuang@realtek.com \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=tehuang@realtek.com \
    /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;
as well as URLs for NNTP newsgroup(s).