diff mbox series

[1/6] wifi: rtw89: 8851b: add to read efuse version to recognize hardware version B

Message ID 20230512061220.16544-2-pkshih@realtek.com (mailing list archive)
State Accepted
Commit 40bb2ab49c369b78d1cb37ed63b8a85f3102b239
Delegated to: Kalle Valo
Headers show
Series wifi: rtw89: 8851b: add more chip_ops to support 8851b | expand

Commit Message

Ping-Ke Shih May 12, 2023, 6:12 a.m. UTC
8851B hardware version A and B use different firmware, but register version
code of these two are the same, so add this helper to read efuse version to
determine which version is installed.

Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
---
 drivers/net/wireless/realtek/rtw89/efuse.c | 21 +++++++++++++++++++++
 drivers/net/wireless/realtek/rtw89/efuse.h |  1 +
 2 files changed, 22 insertions(+)

Comments

Kalle Valo May 17, 2023, 8:06 a.m. UTC | #1
Ping-Ke Shih <pkshih@realtek.com> wrote:

> 8851B hardware version A and B use different firmware, but register version
> code of these two are the same, so add this helper to read efuse version to
> determine which version is installed.
> 
> Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>

6 patches applied to wireless-next.git, thanks.

40bb2ab49c36 wifi: rtw89: 8851b: add to read efuse version to recognize hardware version B
f03bd0429f9b wifi: rtw89: 8851b: configure GPIO according to RFE type
4885b17ebb92 wifi: rtw89: 8851b: add BT coexistence support function
31df6df89f93 wifi: rtw89: 8851b: add basic power on function
e948213fb856 wifi: rtw89: 8851b: add set channel function
f4244d7fbc91 wifi: rtw89: 8851b: add to parse efuse content
diff mbox series

Patch

diff --git a/drivers/net/wireless/realtek/rtw89/efuse.c b/drivers/net/wireless/realtek/rtw89/efuse.c
index 7bd4f8558e03b..2aaf4d013e464 100644
--- a/drivers/net/wireless/realtek/rtw89/efuse.c
+++ b/drivers/net/wireless/realtek/rtw89/efuse.c
@@ -7,6 +7,10 @@ 
 #include "mac.h"
 #include "reg.h"
 
+#define EF_FV_OFSET 0x5ea
+#define EF_CV_MASK GENMASK(7, 4)
+#define EF_CV_INV 15
+
 enum rtw89_efuse_bank {
 	RTW89_EFUSE_BANK_WIFI,
 	RTW89_EFUSE_BANK_BT,
@@ -328,3 +332,20 @@  int rtw89_parse_phycap_map(struct rtw89_dev *rtwdev)
 
 	return ret;
 }
+
+int rtw89_read_efuse_ver(struct rtw89_dev *rtwdev, u8 *ecv)
+{
+	int ret;
+	u8 val;
+
+	ret = rtw89_dump_physical_efuse_map(rtwdev, &val, EF_FV_OFSET, 1, false);
+	if (ret)
+		return ret;
+
+	*ecv = u8_get_bits(val, EF_CV_MASK);
+	if (*ecv == EF_CV_INV)
+		return -ENOENT;
+
+	return 0;
+}
+EXPORT_SYMBOL(rtw89_read_efuse_ver);
diff --git a/drivers/net/wireless/realtek/rtw89/efuse.h b/drivers/net/wireless/realtek/rtw89/efuse.h
index 622ff95e74763..79071aff28de3 100644
--- a/drivers/net/wireless/realtek/rtw89/efuse.h
+++ b/drivers/net/wireless/realtek/rtw89/efuse.h
@@ -9,5 +9,6 @@ 
 
 int rtw89_parse_efuse_map(struct rtw89_dev *rtwdev);
 int rtw89_parse_phycap_map(struct rtw89_dev *rtwdev);
+int rtw89_read_efuse_ver(struct rtw89_dev *rtwdev, u8 *efv);
 
 #endif