All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ping-Ke Shih <pkshih@realtek.com>
To: <kvalo@kernel.org>
Cc: <linux-wireless@vger.kernel.org>, <leo.li@realtek.com>,
	<hsuan8331@realtek.com>, <yuanhan1020@realtek.com>
Subject: [PATCH 02/11] rtw89: 8852c: add write/read crystal function in CFO tracking
Date: Fri, 11 Mar 2022 11:02:52 +0800	[thread overview]
Message-ID: <20220311030301.33921-3-pkshih@realtek.com> (raw)
In-Reply-To: <20220311030301.33921-1-pkshih@realtek.com>

From: Yuan-Han Zhang <yuanhan1020@realtek.com>

The CFO tracking algorithm is the same, but control methods are different.
Set parameters via xtal serial interfaces (SI).

Signed-off-by: Yuan-Han Zhang <yuanhan1020@realtek.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtw89/mac.h |  2 ++
 drivers/net/wireless/realtek/rtw89/phy.c | 19 +++++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/realtek/rtw89/mac.h b/drivers/net/wireless/realtek/rtw89/mac.h
index 2f707c817fa79..680b0eea31746 100644
--- a/drivers/net/wireless/realtek/rtw89/mac.h
+++ b/drivers/net/wireless/realtek/rtw89/mac.h
@@ -884,7 +884,9 @@ int rtw89_mac_get_tx_retry_limit(struct rtw89_dev *rtwdev,
 
 enum rtw89_mac_xtal_si_offset {
 	XTAL_SI_XTAL_SC_XI = 0x04,
+#define XTAL_SC_XI_MASK		GENMASK(7, 0)
 	XTAL_SI_XTAL_SC_XO = 0x05,
+#define XTAL_SC_XO_MASK		GENMASK(7, 0)
 	XTAL_SI_PWR_CUT = 0x10,
 #define XTAL_SI_SMALL_PWR_CUT	BIT(0)
 #define XTAL_SI_BIG_PWR_CUT	BIT(1)
diff --git a/drivers/net/wireless/realtek/rtw89/phy.c b/drivers/net/wireless/realtek/rtw89/phy.c
index 6a7e08bdd00e7..b75d08697a224 100644
--- a/drivers/net/wireless/realtek/rtw89/phy.c
+++ b/drivers/net/wireless/realtek/rtw89/phy.c
@@ -4,6 +4,7 @@
 
 #include "debug.h"
 #include "fw.h"
+#include "mac.h"
 #include "phy.h"
 #include "ps.h"
 #include "reg.h"
@@ -1667,15 +1668,25 @@ static void rtw89_phy_cfo_set_crystal_cap(struct rtw89_dev *rtwdev,
 					  u8 crystal_cap, bool force)
 {
 	struct rtw89_cfo_tracking_info *cfo = &rtwdev->cfo_tracking;
+	const struct rtw89_chip_info *chip = rtwdev->chip;
 	u8 sc_xi_val, sc_xo_val;
 
 	if (!force && cfo->crystal_cap == crystal_cap)
 		return;
 	crystal_cap = clamp_t(u8, crystal_cap, 0, 127);
-	rtw89_phy_cfo_set_xcap_reg(rtwdev, true, crystal_cap);
-	rtw89_phy_cfo_set_xcap_reg(rtwdev, false, crystal_cap);
-	sc_xo_val = rtw89_phy_cfo_get_xcap_reg(rtwdev, true);
-	sc_xi_val = rtw89_phy_cfo_get_xcap_reg(rtwdev, false);
+	if (chip->chip_id == RTL8852A) {
+		rtw89_phy_cfo_set_xcap_reg(rtwdev, true, crystal_cap);
+		rtw89_phy_cfo_set_xcap_reg(rtwdev, false, crystal_cap);
+		sc_xo_val = rtw89_phy_cfo_get_xcap_reg(rtwdev, true);
+		sc_xi_val = rtw89_phy_cfo_get_xcap_reg(rtwdev, false);
+	} else {
+		rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_XTAL_SC_XO,
+					crystal_cap, XTAL_SC_XO_MASK);
+		rtw89_mac_write_xtal_si(rtwdev, XTAL_SI_XTAL_SC_XI,
+					crystal_cap, XTAL_SC_XI_MASK);
+		rtw89_mac_read_xtal_si(rtwdev, XTAL_SI_XTAL_SC_XO, &sc_xo_val);
+		rtw89_mac_read_xtal_si(rtwdev, XTAL_SI_XTAL_SC_XI, &sc_xi_val);
+	}
 	cfo->crystal_cap = sc_xi_val;
 	cfo->x_cap_ofst = (s8)((int)cfo->crystal_cap - cfo->def_x_cap);
 
-- 
2.25.1


  parent reply	other threads:[~2022-03-11  3:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-11  3:02 [PATCH 00/11] rtw89: prepare more shared code to work with 8852c Ping-Ke Shih
2022-03-11  3:02 ` [PATCH 01/11] rtw89: modify dcfo_comp to share with chips Ping-Ke Shih
2022-03-11  3:02 ` Ping-Ke Shih [this message]
2022-03-11  3:02 ` [PATCH 03/11] rtw89: 8852c: add setting of TB UL TX power offset Ping-Ke Shih
2022-03-11  3:02 ` [PATCH 04/11] rtw89: 8852c: add read/write rf register function Ping-Ke Shih
2022-03-11  3:02 ` [PATCH 05/11] rtw89: add config_rf_reg_v1 to configure RF parameter tables Ping-Ke Shih
2022-03-11  3:02 ` [PATCH 06/11] rtw89: modify MAC enable functions Ping-Ke Shih
2022-03-11  3:02 ` [PATCH 07/11] rtw89: initialize preload window of D-MAC Ping-Ke Shih
2022-03-11  3:02 ` [PATCH 08/11] rtw89: disable FW and H2C function if CPU disabled Ping-Ke Shih
2022-03-11  3:02 ` [PATCH 09/11] rtw89: 8852c: add mac_ctrl_path and mac_cfg_gnt APIs Ping-Ke Shih
2022-03-16 15:48   ` Kalle Valo
2022-03-11  3:03 ` [PATCH 10/11] rtw89: extend mac tx_en bits from 16 to 32 Ping-Ke Shih
2022-03-11  3:03 ` [PATCH 11/11] rtw89: implement stop and resume channels transmission v1 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=20220311030301.33921-3-pkshih@realtek.com \
    --to=pkshih@realtek.com \
    --cc=hsuan8331@realtek.com \
    --cc=kvalo@kernel.org \
    --cc=leo.li@realtek.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=yuanhan1020@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 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.