1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16#include <linux/kernel.h>
17#include "odm_precomp.h"
18
19static bool CheckPositive(
20 PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
21)
22{
23 u8 _BoardType =
24 ((pDM_Odm->BoardType & BIT4) >> 4) << 0 |
25 ((pDM_Odm->BoardType & BIT3) >> 3) << 1 |
26 ((pDM_Odm->BoardType & BIT7) >> 7) << 2 |
27 ((pDM_Odm->BoardType & BIT6) >> 6) << 3 |
28 ((pDM_Odm->BoardType & BIT2) >> 2) << 4;
29
30 u32 cond1 = Condition1, cond2 = Condition2;
31 u32 driver1 =
32 pDM_Odm->CutVersion << 24 |
33 pDM_Odm->SupportPlatform << 16 |
34 pDM_Odm->PackageType << 12 |
35 pDM_Odm->SupportInterface << 8 |
36 _BoardType;
37
38 u32 driver2 =
39 pDM_Odm->TypeGLNA << 0 |
40 pDM_Odm->TypeGPA << 8 |
41 pDM_Odm->TypeALNA << 16 |
42 pDM_Odm->TypeAPA << 24;
43
44 ODM_RT_TRACE(
45 pDM_Odm,
46 ODM_COMP_INIT,
47 ODM_DBG_TRACE,
48 (
49 "===> [8812A] CheckPositive (cond1, cond2) = (0x%X 0x%X)\n",
50 cond1,
51 cond2
52 )
53 );
54 ODM_RT_TRACE(
55 pDM_Odm,
56 ODM_COMP_INIT,
57 ODM_DBG_TRACE,
58 (
59 "===> [8812A] CheckPositive (driver1, driver2) = (0x%X 0x%X)\n",
60 driver1,
61 driver2
62 )
63 );
64
65 ODM_RT_TRACE(
66 pDM_Odm,
67 ODM_COMP_INIT,
68 ODM_DBG_TRACE,
69 (
70 " (Platform, Interface) = (0x%X, 0x%X)\n",
71 pDM_Odm->SupportPlatform,
72 pDM_Odm->SupportInterface
73 )
74 );
75 ODM_RT_TRACE(
76 pDM_Odm,
77 ODM_COMP_INIT,
78 ODM_DBG_TRACE,
79 (
80 " (Board, Package) = (0x%X, 0x%X)\n",
81 pDM_Odm->BoardType,
82 pDM_Odm->PackageType
83 )
84 );
85
86
87
88
89
90 if (((cond1 & 0x0000F000) != 0) && ((cond1 & 0x0000F000) != (driver1 & 0x0000F000)))
91 return false;
92 if (((cond1 & 0x0F000000) != 0) && ((cond1 & 0x0F000000) != (driver1 & 0x0F000000)))
93 return false;
94
95
96
97
98 cond1 &= 0x000F0FFF;
99 driver1 &= 0x000F0FFF;
100
101 if ((cond1 & driver1) == cond1) {
102 u32 bitMask = 0;
103 if ((cond1 & 0x0F) == 0)
104 return true;
105
106 if ((cond1 & BIT0) != 0)
107 bitMask |= 0x000000FF;
108 if ((cond1 & BIT1) != 0)
109 bitMask |= 0x0000FF00;
110 if ((cond1 & BIT2) != 0)
111 bitMask |= 0x00FF0000;
112 if ((cond1 & BIT3) != 0)
113 bitMask |= 0xFF000000;
114
115 if ((cond2 & bitMask) == (driver2 & bitMask))
116 return true;
117 }
118 return false;
119}
120
121static bool CheckNegative(
122 PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
123)
124{
125 return true;
126}
127
128
129
130
131
132static u32 Array_MP_8723B_MAC_REG[] = {
133 0x02F, 0x00000030,
134 0x035, 0x00000000,
135 0x039, 0x00000008,
136 0x04E, 0x000000E0,
137 0x064, 0x00000000,
138 0x067, 0x00000020,
139 0x428, 0x0000000A,
140 0x429, 0x00000010,
141 0x430, 0x00000000,
142 0x431, 0x00000000,
143 0x432, 0x00000000,
144 0x433, 0x00000001,
145 0x434, 0x00000004,
146 0x435, 0x00000005,
147 0x436, 0x00000007,
148 0x437, 0x00000008,
149 0x43C, 0x00000004,
150 0x43D, 0x00000005,
151 0x43E, 0x00000007,
152 0x43F, 0x00000008,
153 0x440, 0x0000005D,
154 0x441, 0x00000001,
155 0x442, 0x00000000,
156 0x444, 0x00000010,
157 0x445, 0x00000000,
158 0x446, 0x00000000,
159 0x447, 0x00000000,
160 0x448, 0x00000000,
161 0x449, 0x000000F0,
162 0x44A, 0x0000000F,
163 0x44B, 0x0000003E,
164 0x44C, 0x00000010,
165 0x44D, 0x00000000,
166 0x44E, 0x00000000,
167 0x44F, 0x00000000,
168 0x450, 0x00000000,
169 0x451, 0x000000F0,
170 0x452, 0x0000000F,
171 0x453, 0x00000000,
172 0x456, 0x0000005E,
173 0x460, 0x00000066,
174 0x461, 0x00000066,
175 0x4C8, 0x000000FF,
176 0x4C9, 0x00000008,
177 0x4CC, 0x000000FF,
178 0x4CD, 0x000000FF,
179 0x4CE, 0x00000001,
180 0x500, 0x00000026,
181 0x501, 0x000000A2,
182 0x502, 0x0000002F,
183 0x503, 0x00000000,
184 0x504, 0x00000028,
185 0x505, 0x000000A3,
186 0x506, 0x0000005E,
187 0x507, 0x00000000,
188 0x508, 0x0000002B,
189 0x509, 0x000000A4,
190 0x50A, 0x0000005E,
191 0x50B, 0x00000000,
192 0x50C, 0x0000004F,
193 0x50D, 0x000000A4,
194 0x50E, 0x00000000,
195 0x50F, 0x00000000,
196 0x512, 0x0000001C,
197 0x514, 0x0000000A,
198 0x516, 0x0000000A,
199 0x525, 0x0000004F,
200 0x550, 0x00000010,
201 0x551, 0x00000010,
202 0x559, 0x00000002,
203 0x55C, 0x00000050,
204 0x55D, 0x000000FF,
205 0x605, 0x00000030,
206 0x608, 0x0000000E,
207 0x609, 0x0000002A,
208 0x620, 0x000000FF,
209 0x621, 0x000000FF,
210 0x622, 0x000000FF,
211 0x623, 0x000000FF,
212 0x624, 0x000000FF,
213 0x625, 0x000000FF,
214 0x626, 0x000000FF,
215 0x627, 0x000000FF,
216 0x638, 0x00000050,
217 0x63C, 0x0000000A,
218 0x63D, 0x0000000A,
219 0x63E, 0x0000000E,
220 0x63F, 0x0000000E,
221 0x640, 0x00000040,
222 0x642, 0x00000040,
223 0x643, 0x00000000,
224 0x652, 0x000000C8,
225 0x66E, 0x00000005,
226 0x700, 0x00000021,
227 0x701, 0x00000043,
228 0x702, 0x00000065,
229 0x703, 0x00000087,
230 0x708, 0x00000021,
231 0x709, 0x00000043,
232 0x70A, 0x00000065,
233 0x70B, 0x00000087,
234 0x765, 0x00000018,
235 0x76E, 0x00000004,
236
237};
238
239void ODM_ReadAndConfig_MP_8723B_MAC_REG(PDM_ODM_T pDM_Odm)
240{
241 u32 i = 0;
242 u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_MAC_REG);
243 u32 *Array = Array_MP_8723B_MAC_REG;
244
245 ODM_RT_TRACE(
246 pDM_Odm,
247 ODM_COMP_INIT,
248 ODM_DBG_LOUD,
249 ("===> ODM_ReadAndConfig_MP_8723B_MAC_REG\n")
250 );
251
252 for (i = 0; i < ArrayLen; i += 2) {
253 u32 v1 = Array[i];
254 u32 v2 = Array[i+1];
255
256
257 if (v1 < 0x40000000) {
258 odm_ConfigMAC_8723B(pDM_Odm, v1, (u8)v2);
259 continue;
260 } else {
261
262 bool bMatched = true;
263 u8 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28);
264
265 if (cCond == COND_ELSE) {
266 bMatched = true;
267 READ_NEXT_PAIR(v1, v2, i);
268 } else if (!CheckPositive(pDM_Odm, v1, v2)) {
269 bMatched = false;
270 READ_NEXT_PAIR(v1, v2, i);
271 READ_NEXT_PAIR(v1, v2, i);
272 } else {
273 READ_NEXT_PAIR(v1, v2, i);
274 if (!CheckNegative(pDM_Odm, v1, v2))
275 bMatched = false;
276 else
277 bMatched = true;
278 READ_NEXT_PAIR(v1, v2, i);
279 }
280
281 if (bMatched == false) {
282
283 while (v1 < 0x40000000 && i < ArrayLen-2)
284 READ_NEXT_PAIR(v1, v2, i);
285
286 i -= 2;
287 } else {
288 while (v1 < 0x40000000 && i < ArrayLen-2) {
289 odm_ConfigMAC_8723B(pDM_Odm, v1, (u8)v2);
290 READ_NEXT_PAIR(v1, v2, i);
291 }
292
293
294 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28);
295 while (cCond != COND_ENDIF && i < ArrayLen-2) {
296 READ_NEXT_PAIR(v1, v2, i);
297 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28);
298 }
299 }
300 }
301 }
302}
303