2020-05-07 04:23:49

by Tony Chuang

[permalink] [raw]
Subject: [PATCH v2 1/9] rtw88: 8723d: Add LC calibration

From: Ping-Ke Shih <[email protected]>

LC calibration is done by hardware circuit. Driver sets the LCK bit to kick
start, and then poll the bit to check if it's done.

Signed-off-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Yan-Hsuan Chuang <[email protected]>
---
drivers/net/wireless/realtek/rtw88/main.h | 1 +
drivers/net/wireless/realtek/rtw88/rtw8723d.c | 31 +++++++++++++++++++
drivers/net/wireless/realtek/rtw88/rtw8723d.h | 3 ++
3 files changed, 35 insertions(+)

diff --git a/drivers/net/wireless/realtek/rtw88/main.h b/drivers/net/wireless/realtek/rtw88/main.h
index e0365a70c6f7..c5046986f9af 100644
--- a/drivers/net/wireless/realtek/rtw88/main.h
+++ b/drivers/net/wireless/realtek/rtw88/main.h
@@ -11,6 +11,7 @@
#include <linux/average.h>
#include <linux/bitops.h>
#include <linux/bitfield.h>
+#include <linux/iopoll.h>
#include <linux/interrupt.h>

#include "util.h"
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.c b/drivers/net/wireless/realtek/rtw88/rtw8723d.c
index 92c742d1ce6d..0f5ddd41b019 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8723d.c
+++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.c
@@ -64,6 +64,34 @@ static const struct rtw_hw_reg rtw8723d_txagc[] = {
#define WLAN_LTR_CTRL1 0xCB004010
#define WLAN_LTR_CTRL2 0x01233425

+static void rtw8723d_lck(struct rtw_dev *rtwdev)
+{
+ u32 lc_cal;
+ u8 val_ctx, rf_val;
+ int ret;
+
+ val_ctx = rtw_read8(rtwdev, REG_CTX);
+ if ((val_ctx & BIT_MASK_CTX_TYPE) != 0)
+ rtw_write8(rtwdev, REG_CTX, val_ctx & ~BIT_MASK_CTX_TYPE);
+ else
+ rtw_write8(rtwdev, REG_TXPAUSE, 0xFF);
+ lc_cal = rtw_read_rf(rtwdev, RF_PATH_A, RF_CFGCH, RFREG_MASK);
+
+ rtw_write_rf(rtwdev, RF_PATH_A, RF_CFGCH, RFREG_MASK, lc_cal | BIT_LCK);
+
+ ret = read_poll_timeout(rtw_read_rf, rf_val, rf_val != 0x1,
+ 10000, 1000000, false,
+ rtwdev, RF_PATH_A, RF_CFGCH, BIT_LCK);
+ if (ret)
+ rtw_warn(rtwdev, "failed to poll LCK status bit\n");
+
+ rtw_write_rf(rtwdev, RF_PATH_A, RF_CFGCH, RFREG_MASK, lc_cal);
+ if ((val_ctx & BIT_MASK_CTX_TYPE) != 0)
+ rtw_write8(rtwdev, REG_CTX, val_ctx);
+ else
+ rtw_write8(rtwdev, REG_TXPAUSE, 0x00);
+}
+
static void rtw8723d_phy_set_param(struct rtw_dev *rtwdev)
{
u8 xtal_cap;
@@ -125,6 +153,9 @@ static void rtw8723d_phy_set_param(struct rtw_dev *rtwdev)
rtw_phy_init(rtwdev);

rtw_write16_set(rtwdev, REG_TXDMA_OFFSET_CHK, BIT_DROP_DATA_EN);
+
+ rtw8723d_lck(rtwdev);
+
rtw_write32_mask(rtwdev, REG_OFDM0_XAAGC1, MASKBYTE0, 0x50);
rtw_write32_mask(rtwdev, REG_OFDM0_XAAGC1, MASKBYTE0, 0x20);
}
diff --git a/drivers/net/wireless/realtek/rtw88/rtw8723d.h b/drivers/net/wireless/realtek/rtw88/rtw8723d.h
index ac66f672bec8..6a7d58992df5 100644
--- a/drivers/net/wireless/realtek/rtw88/rtw8723d.h
+++ b/drivers/net/wireless/realtek/rtw88/rtw8723d.h
@@ -78,6 +78,7 @@ struct rtw8723d_efuse {
#define RFCFGCH_BW_20M (BIT(11) | BIT(10))
#define RFCFGCH_BW_40M BIT(10)
#define BIT_MASK_RFMOD BIT(0)
+#define BIT_LCK BIT(15)

#define REG_PSDFN 0x0808
#define REG_ANALOG_P4 0x088c
@@ -115,6 +116,8 @@ struct rtw8723d_efuse {
#define REG_OFDM_FA_RSTD_11N 0x0d00
#define BIT_MASK_OFDM_FA_RST1 BIT(27)
#define BIT_MASK_OFDM_FA_KEEP1 BIT(31)
+#define REG_CTX 0x0d03
+#define BIT_MASK_CTX_TYPE GENMASK(6, 4)
#define REG_OFDM1_CFOTRK 0x0d2c
#define BIT_EN_CFOTRK BIT(28)
#define REG_OFDM1_CSI1 0x0d40
--
2.17.1


2020-05-12 08:51:00

by Kalle Valo

[permalink] [raw]
Subject: Re: [PATCH v2 1/9] rtw88: 8723d: Add LC calibration

<[email protected]> wrote:

> From: Ping-Ke Shih <[email protected]>
>
> LC calibration is done by hardware circuit. Driver sets the LCK bit to kick
> start, and then poll the bit to check if it's done.
>
> Signed-off-by: Ping-Ke Shih <[email protected]>
> Signed-off-by: Yan-Hsuan Chuang <[email protected]>

Failed to apply, please rebase and send v2.

Recorded preimage for 'drivers/net/wireless/realtek/rtw88/pci.c'
error: Failed to merge in the changes.
Applying: rtw88: 8723d: Add shutdown callback to disable BT USB suspend
Using index info to reconstruct a base tree...
M drivers/net/wireless/realtek/rtw88/pci.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/net/wireless/realtek/rtw88/pci.c
CONFLICT (content): Merge conflict in drivers/net/wireless/realtek/rtw88/pci.c
Patch failed at 0001 rtw88: 8723d: Add shutdown callback to disable BT USB suspend
The copy of the patch that failed is found in: .git/rebase-apply/patch

9 patches set to Changes Requested.

11532385 [v2,1/9] rtw88: 8723d: Add LC calibration
11532379 [v2,2/9] rtw88: 8723d: add IQ calibration
11532393 [v2,3/9] rtw88: 8723d: Add power tracking
11532389 [v2,4/9] rtw88: 8723d: Add shutdown callback to disable BT USB suspend
11532387 [v2,5/9] rtw88: 8723d: implement flush queue
11532375 [v2,6/9] rtw88: 8723d: set ltecoex register address in chip_info
11532377 [v2,7/9] rtw88: 8723d: Add coex support
11532383 [v2,8/9] rtw88: fill zeros to words 0x06 and 0x07 of security cam entry
11532381 [v2,9/9] rtw88: 8723d: Add 8723DE to Kconfig and Makefile

--
https://patchwork.kernel.org/patch/11532385/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches