1 From 95a772e30b60e7954d03f3372268722475aa303f Mon Sep 17 00:00:00 2001
2 From: Bitterblue Smith <rtl8821cerfe2@gmail.com>
3 Date: Wed, 23 Oct 2024 17:08:24 +0300
4 Subject: [PATCH] wifi: rtw88: Extend the init table parsing for RTL8812AU
6 The chips supported so far only use the first condition, and so the
7 parsing code ignores the second condition. RTL8812AU's init tables use
8 the second condition also. Make the parsing code check it.
10 Signed-off-by: Bitterblue Smith <rtl8821cerfe2@gmail.com>
11 Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
12 Link: https://patch.msgid.link/1bee6b74-6eab-44a3-9f40-794ca006c72d@gmail.com
14 drivers/net/wireless/realtek/rtw88/main.h | 15 ++++++
15 drivers/net/wireless/realtek/rtw88/phy.c | 62 ++++++++++++++++++++---
16 2 files changed, 69 insertions(+), 8 deletions(-)
18 --- a/drivers/net/wireless/realtek/rtw88/main.h
19 +++ b/drivers/net/wireless/realtek/rtw88/main.h
20 @@ -1835,6 +1835,20 @@ struct rtw_phy_cond {
21 #define BRANCH_ENDIF 3
24 +struct rtw_phy_cond2 {
25 +#ifdef __LITTLE_ENDIAN
38 struct rtw_fifo_conf {
39 /* tx fifo information */
41 @@ -1916,6 +1930,7 @@ struct rtw_hal {
44 struct rtw_phy_cond phy_cond;
45 + struct rtw_phy_cond2 phy_cond2;
49 --- a/drivers/net/wireless/realtek/rtw88/phy.c
50 +++ b/drivers/net/wireless/realtek/rtw88/phy.c
51 @@ -18,7 +18,10 @@ struct phy_cfg_pair {
54 union phy_table_tile {
55 - struct rtw_phy_cond cond;
57 + struct rtw_phy_cond cond;
58 + struct rtw_phy_cond2 cond2;
60 struct phy_cfg_pair cfg;
63 @@ -1041,7 +1044,8 @@ void rtw_phy_setup_phy_cond(struct rtw_d
65 struct rtw_hal *hal = &rtwdev->hal;
66 struct rtw_efuse *efuse = &rtwdev->efuse;
67 - struct rtw_phy_cond cond = {0};
68 + struct rtw_phy_cond cond = {};
69 + struct rtw_phy_cond2 cond2 = {};
71 cond.cut = hal->cut_version ? hal->cut_version : 15;
72 cond.pkg = pkg ? pkg : 15;
73 @@ -1061,15 +1065,34 @@ void rtw_phy_setup_phy_cond(struct rtw_d
77 + if (rtwdev->chip->id == RTW_CHIP_TYPE_8812A ||
78 + rtwdev->chip->id == RTW_CHIP_TYPE_8821A) {
80 + cond.rfe |= efuse->ext_lna_2g;
81 + cond.rfe |= efuse->ext_pa_2g << 1;
82 + cond.rfe |= efuse->ext_lna_5g << 2;
83 + cond.rfe |= efuse->ext_pa_5g << 3;
84 + cond.rfe |= efuse->btcoex << 4;
86 + cond2.type_alna = efuse->alna_type;
87 + cond2.type_glna = efuse->glna_type;
88 + cond2.type_apa = efuse->apa_type;
89 + cond2.type_gpa = efuse->gpa_type;
93 + hal->phy_cond2 = cond2;
95 - rtw_dbg(rtwdev, RTW_DBG_PHY, "phy cond=0x%08x\n", *((u32 *)&hal->phy_cond));
96 + rtw_dbg(rtwdev, RTW_DBG_PHY, "phy cond=0x%08x cond2=0x%08x\n",
97 + *((u32 *)&hal->phy_cond), *((u32 *)&hal->phy_cond2));
100 -static bool check_positive(struct rtw_dev *rtwdev, struct rtw_phy_cond cond)
101 +static bool check_positive(struct rtw_dev *rtwdev, struct rtw_phy_cond cond,
102 + struct rtw_phy_cond2 cond2)
104 struct rtw_hal *hal = &rtwdev->hal;
105 struct rtw_phy_cond drv_cond = hal->phy_cond;
106 + struct rtw_phy_cond2 drv_cond2 = hal->phy_cond2;
108 if (cond.cut && cond.cut != drv_cond.cut)
110 @@ -1080,8 +1103,29 @@ static bool check_positive(struct rtw_de
111 if (cond.intf && cond.intf != drv_cond.intf)
114 - if (cond.rfe != drv_cond.rfe)
116 + if (rtwdev->chip->id == RTW_CHIP_TYPE_8812A ||
117 + rtwdev->chip->id == RTW_CHIP_TYPE_8821A) {
118 + if (!(cond.rfe & 0x0f))
121 + if ((cond.rfe & drv_cond.rfe) != cond.rfe)
124 + if ((cond.rfe & BIT(0)) && cond2.type_glna != drv_cond2.type_glna)
127 + if ((cond.rfe & BIT(1)) && cond2.type_gpa != drv_cond2.type_gpa)
130 + if ((cond.rfe & BIT(2)) && cond2.type_alna != drv_cond2.type_alna)
133 + if ((cond.rfe & BIT(3)) && cond2.type_apa != drv_cond2.type_apa)
136 + if (cond.rfe != drv_cond.rfe)
142 @@ -1090,7 +1134,8 @@ void rtw_parse_tbl_phy_cond(struct rtw_d
144 const union phy_table_tile *p = tbl->data;
145 const union phy_table_tile *end = p + tbl->size / 2;
146 - struct rtw_phy_cond pos_cond = {0};
147 + struct rtw_phy_cond pos_cond = {};
148 + struct rtw_phy_cond2 pos_cond2 = {};
149 bool is_matched = true, is_skipped = false;
151 BUILD_BUG_ON(sizeof(union phy_table_tile) != sizeof(struct phy_cfg_pair));
152 @@ -1109,11 +1154,12 @@ void rtw_parse_tbl_phy_cond(struct rtw_d
156 + pos_cond2 = p->cond2;
159 } else if (p->cond.neg) {
161 - if (check_positive(rtwdev, pos_cond)) {
162 + if (check_positive(rtwdev, pos_cond, pos_cond2)) {