]> git.ipfire.org Git - thirdparty/openwrt.git/blob
aec2e6aaecf6a77ab04adb926571a2ed593d3887
[thirdparty/openwrt.git] /
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
5
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.
9
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
13 ---
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(-)
17
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
22 };
23
24 +struct rtw_phy_cond2 {
25 +#ifdef __LITTLE_ENDIAN
26 + u8 type_glna;
27 + u8 type_gpa;
28 + u8 type_alna;
29 + u8 type_apa;
30 +#else
31 + u8 type_apa;
32 + u8 type_alna;
33 + u8 type_gpa;
34 + u8 type_glna;
35 +#endif
36 +};
37 +
38 struct rtw_fifo_conf {
39 /* tx fifo information */
40 u16 rsvd_boundary;
41 @@ -1916,6 +1930,7 @@ struct rtw_hal {
42 u8 oem_id;
43 u8 pkg_type;
44 struct rtw_phy_cond phy_cond;
45 + struct rtw_phy_cond2 phy_cond2;
46 bool rfe_btg;
47
48 u8 ps_mode;
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 {
52 };
53
54 union phy_table_tile {
55 - struct rtw_phy_cond cond;
56 + struct {
57 + struct rtw_phy_cond cond;
58 + struct rtw_phy_cond2 cond2;
59 + } __packed;
60 struct phy_cfg_pair cfg;
61 };
62
63 @@ -1041,7 +1044,8 @@ void rtw_phy_setup_phy_cond(struct rtw_d
64 {
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 = {};
70
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
74 break;
75 }
76
77 + if (rtwdev->chip->id == RTW_CHIP_TYPE_8812A ||
78 + rtwdev->chip->id == RTW_CHIP_TYPE_8821A) {
79 + cond.rfe = 0;
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;
85 +
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;
90 + }
91 +
92 hal->phy_cond = cond;
93 + hal->phy_cond2 = cond2;
94
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));
98 }
99
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)
103 {
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;
107
108 if (cond.cut && cond.cut != drv_cond.cut)
109 return false;
110 @@ -1080,8 +1103,29 @@ static bool check_positive(struct rtw_de
111 if (cond.intf && cond.intf != drv_cond.intf)
112 return false;
113
114 - if (cond.rfe != drv_cond.rfe)
115 - return false;
116 + if (rtwdev->chip->id == RTW_CHIP_TYPE_8812A ||
117 + rtwdev->chip->id == RTW_CHIP_TYPE_8821A) {
118 + if (!(cond.rfe & 0x0f))
119 + return true;
120 +
121 + if ((cond.rfe & drv_cond.rfe) != cond.rfe)
122 + return false;
123 +
124 + if ((cond.rfe & BIT(0)) && cond2.type_glna != drv_cond2.type_glna)
125 + return false;
126 +
127 + if ((cond.rfe & BIT(1)) && cond2.type_gpa != drv_cond2.type_gpa)
128 + return false;
129 +
130 + if ((cond.rfe & BIT(2)) && cond2.type_alna != drv_cond2.type_alna)
131 + return false;
132 +
133 + if ((cond.rfe & BIT(3)) && cond2.type_apa != drv_cond2.type_apa)
134 + return false;
135 + } else {
136 + if (cond.rfe != drv_cond.rfe)
137 + return false;
138 + }
139
140 return true;
141 }
142 @@ -1090,7 +1134,8 @@ void rtw_parse_tbl_phy_cond(struct rtw_d
143 {
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;
150
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
153 case BRANCH_ELIF:
154 default:
155 pos_cond = p->cond;
156 + pos_cond2 = p->cond2;
157 break;
158 }
159 } else if (p->cond.neg) {
160 if (!is_skipped) {
161 - if (check_positive(rtwdev, pos_cond)) {
162 + if (check_positive(rtwdev, pos_cond, pos_cond2)) {
163 is_matched = true;
164 is_skipped = true;
165 } else {