summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/realtek/rtw88/efuse.c
diff options
context:
space:
mode:
authorTzu-En Huang <tehuang@realtek.com>2020-04-20 18:52:07 +0800
committerKalle Valo <kvalo@codeaurora.org>2020-04-21 16:00:21 +0300
commit5ad4d8957b69f3ebf95ac02212c388bda75aeb30 (patch)
tree443f49d512d6a42c726eca673398856716d75901 /drivers/net/wireless/realtek/rtw88/efuse.c
parentab0a031ecf2908c77833caebf0c86bab5e9f12b7 (diff)
rtw88: set power trim according to efuse PG values
8822C devices have power trim, thermal and PA bias values programmed in efuse. Driver should configure the RF components according to the values. If the power trim is not configured, then the devices might have distortion on the output tx power. Signed-off-by: Tzu-En Huang <tehuang@realtek.com> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org> Link: https://lore.kernel.org/r/20200420105207.31899-1-yhchuang@realtek.com
Diffstat (limited to 'drivers/net/wireless/realtek/rtw88/efuse.c')
-rw-r--r--drivers/net/wireless/realtek/rtw88/efuse.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/net/wireless/realtek/rtw88/efuse.c b/drivers/net/wireless/realtek/rtw88/efuse.c
index df969d346b41..13d1c58d6de5 100644
--- a/drivers/net/wireless/realtek/rtw88/efuse.c
+++ b/drivers/net/wireless/realtek/rtw88/efuse.c
@@ -2,6 +2,8 @@
/* Copyright(c) 2018-2019 Realtek Corporation
*/
+#include <linux/iopoll.h>
+
#include "main.h"
#include "efuse.h"
#include "reg.h"
@@ -120,6 +122,26 @@ static int rtw_dump_physical_efuse_map(struct rtw_dev *rtwdev, u8 *map)
return 0;
}
+int rtw_read8_physical_efuse(struct rtw_dev *rtwdev, u16 addr, u8 *data)
+{
+ u32 efuse_ctl;
+ int ret;
+
+ rtw_write32_mask(rtwdev, REG_EFUSE_CTRL, 0x3ff00, addr);
+ rtw_write32_clr(rtwdev, REG_EFUSE_CTRL, BIT_EF_FLAG);
+
+ ret = read_poll_timeout(rtw_read32, efuse_ctl, efuse_ctl & BIT_EF_FLAG,
+ 1000, 100000, false, rtwdev, REG_EFUSE_CTRL);
+ if (ret) {
+ *data = EFUSE_READ_FAIL;
+ return ret;
+ }
+
+ *data = rtw_read8(rtwdev, REG_EFUSE_CTRL);
+
+ return 0;
+}
+
int rtw_parse_efuse_map(struct rtw_dev *rtwdev)
{
struct rtw_chip_info *chip = rtwdev->chip;