From: <yhchuang@realtek.com>
To: <kvalo@codeaurora.org>
Cc: <linux-wireless@vger.kernel.org>, <tehuang@realtek.com>,
<bigeasy@linutronix.de>
Subject: [PATCH v3 7/7] rtw88: 8821c: add phy calibration
Date: Wed, 3 Jun 2020 17:38:04 +0800 [thread overview]
Message-ID: <20200603093804.19779-8-yhchuang@realtek.com> (raw)
In-Reply-To: <20200603093804.19779-1-yhchuang@realtek.com>
From: Tzu-En Huang <tehuang@realtek.com>
In order to get a better TX EVM, do calibration after association.
The calibration needed for 8821c is the IQK, which is done in the
firmware. Implement the rtw_chip_ops::phy_calibration() to trigger
firmware to calibrate.
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 | 34 +++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8821c.c b/drivers/net/wireless/realtek/rtw88/rtw8821c.c
index ffcb427468d7..4bd4164d23ef 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8821c.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8821c.c
@@ -563,6 +563,39 @@ static void rtw8821c_false_alarm_statistics(struct rtw_dev *rtwdev)
rtw_write32_clr(rtwdev, REG_CNTRST, BIT(0));
}
+static void rtw8821c_do_iqk(struct rtw_dev *rtwdev)
+{
+ static int do_iqk_cnt;
+ struct rtw_iqk_para para = {.clear = 0, .segment_iqk = 0};
+ u32 rf_reg, iqk_fail_mask;
+ int counter;
+ bool reload;
+
+ if (rtw_is_assoc(rtwdev))
+ para.segment_iqk = 1;
+
+ rtw_fw_do_iqk(rtwdev, ¶);
+
+ for (counter = 0; counter < 300; counter++) {
+ rf_reg = rtw_read_rf(rtwdev, RF_PATH_A, RF_DTXLOK, RFREG_MASK);
+ if (rf_reg == 0xabcde)
+ break;
+ msleep(20);
+ }
+ rtw_write_rf(rtwdev, RF_PATH_A, RF_DTXLOK, RFREG_MASK, 0x0);
+
+ reload = !!rtw_read32_mask(rtwdev, REG_IQKFAILMSK, BIT(16));
+ iqk_fail_mask = rtw_read32_mask(rtwdev, REG_IQKFAILMSK, GENMASK(7, 0));
+ rtw_dbg(rtwdev, RTW_DBG_PHY,
+ "iqk counter=%d reload=%d do_iqk_cnt=%d n_iqk_fail(mask)=0x%02x\n",
+ counter, reload, ++do_iqk_cnt, iqk_fail_mask);
+}
+
+static void rtw8821c_phy_calibration(struct rtw_dev *rtwdev)
+{
+ rtw8821c_do_iqk(rtwdev);
+}
+
static struct rtw_pwr_seq_cmd trans_carddis_to_cardemu_8821c[] = {
{0x0086,
RTW_PWR_CUT_ALL_MSK,
@@ -1001,6 +1034,7 @@ static struct rtw_chip_ops rtw8821c_ops = {
.set_tx_power_index = rtw8821c_set_tx_power_index,
.cfg_ldo25 = rtw8821c_cfg_ldo25,
.false_alarm_statistics = rtw8821c_false_alarm_statistics,
+ .phy_calibration = rtw8821c_phy_calibration,
};
struct rtw_chip_info rtw8821c_hw_spec = {
--
2.17.1
next prev parent reply other threads:[~2020-06-03 9:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-03 9:37 [PATCH v3 0/7] rtw88: 8821c: add basic function routines yhchuang
2020-06-03 9:37 ` [PATCH v3 1/7] rtw88: 8821c: add basic functions yhchuang
2020-06-03 9:37 ` [PATCH v3 2/7] rtw88: 8821c: add set tx power index yhchuang
2020-06-03 9:38 ` [PATCH v3 3/7] rtw88: 8821c: add dig related settings yhchuang
2020-06-03 9:38 ` [PATCH v3 4/7] rtw88: 8821c: add set channel support yhchuang
2020-06-03 9:38 ` [PATCH v3 5/7] rtw88: 8821c: add query rx desc support yhchuang
2020-06-05 10:44 ` Sebastian Andrzej Siewior
2020-06-05 11:16 ` Tony Chuang
2020-06-03 9:38 ` [PATCH v3 6/7] rtw88: 8821c: add false alarm statistics yhchuang
2020-06-03 9:38 ` yhchuang [this message]
2020-06-05 11:18 ` [PATCH v3 0/7] rtw88: 8821c: add basic function routines 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=20200603093804.19779-8-yhchuang@realtek.com \
--to=yhchuang@realtek.com \
--cc=bigeasy@linutronix.de \
--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