1
2
3
4
5
6
7
8#include <linux/kernel.h>
9#include "odm_precomp.h"
10
11static bool CheckPositive(
12 PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
13)
14{
15 u8 _BoardType =
16 ((pDM_Odm->BoardType & BIT4) >> 4) << 0 |
17 ((pDM_Odm->BoardType & BIT3) >> 3) << 1 |
18 ((pDM_Odm->BoardType & BIT7) >> 7) << 2 |
19 ((pDM_Odm->BoardType & BIT6) >> 6) << 3 |
20 ((pDM_Odm->BoardType & BIT2) >> 2) << 4;
21
22 u32 cond1 = Condition1, cond2 = Condition2;
23 u32 driver1 =
24 pDM_Odm->CutVersion << 24 |
25 pDM_Odm->SupportPlatform << 16 |
26 pDM_Odm->PackageType << 12 |
27 pDM_Odm->SupportInterface << 8 |
28 _BoardType;
29
30 u32 driver2 =
31 pDM_Odm->TypeGLNA << 0 |
32 pDM_Odm->TypeGPA << 8 |
33 pDM_Odm->TypeALNA << 16 |
34 pDM_Odm->TypeAPA << 24;
35
36 ODM_RT_TRACE(
37 pDM_Odm,
38 ODM_COMP_INIT,
39 ODM_DBG_TRACE,
40 (
41 "===> [8812A] CheckPositive (cond1, cond2) = (0x%X 0x%X)\n",
42 cond1,
43 cond2
44 )
45 );
46 ODM_RT_TRACE(
47 pDM_Odm,
48 ODM_COMP_INIT,
49 ODM_DBG_TRACE,
50 (
51 "===> [8812A] CheckPositive (driver1, driver2) = (0x%X 0x%X)\n",
52 driver1,
53 driver2
54 )
55 );
56
57 ODM_RT_TRACE(
58 pDM_Odm,
59 ODM_COMP_INIT,
60 ODM_DBG_TRACE,
61 (" (Platform, Interface) = (0x%X, 0x%X)\n",
62 pDM_Odm->SupportPlatform,
63 pDM_Odm->SupportInterface
64 )
65 );
66 ODM_RT_TRACE(
67 pDM_Odm,
68 ODM_COMP_INIT,
69 ODM_DBG_TRACE,
70 (
71 " (Board, Package) = (0x%X, 0x%X)\n",
72 pDM_Odm->BoardType,
73 pDM_Odm->PackageType
74 )
75 );
76
77
78
79
80
81 if (((cond1 & 0x0000F000) != 0) && ((cond1 & 0x0000F000) != (driver1 & 0x0000F000)))
82 return false;
83 if (((cond1 & 0x0F000000) != 0) && ((cond1 & 0x0F000000) != (driver1 & 0x0F000000)))
84 return false;
85
86
87
88
89 cond1 &= 0x000F0FFF;
90 driver1 &= 0x000F0FFF;
91
92 if ((cond1 & driver1) == cond1) {
93 u32 bitMask = 0;
94
95 if ((cond1 & 0x0F) == 0)
96 return true;
97
98 if ((cond1 & BIT0) != 0)
99 bitMask |= 0x000000FF;
100 if ((cond1 & BIT1) != 0)
101 bitMask |= 0x0000FF00;
102 if ((cond1 & BIT2) != 0)
103 bitMask |= 0x00FF0000;
104 if ((cond1 & BIT3) != 0)
105 bitMask |= 0xFF000000;
106
107
108 if ((cond2 & bitMask) == (driver2 & bitMask))
109 return true;
110 }
111 return false;
112}
113
114static bool CheckNegative(
115 PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
116)
117{
118 return true;
119}
120
121
122
123
124
125static u32 Array_MP_8723B_AGC_TAB[] = {
126 0xC78, 0xFD000001,
127 0xC78, 0xFC010001,
128 0xC78, 0xFB020001,
129 0xC78, 0xFA030001,
130 0xC78, 0xF9040001,
131 0xC78, 0xF8050001,
132 0xC78, 0xF7060001,
133 0xC78, 0xF6070001,
134 0xC78, 0xF5080001,
135 0xC78, 0xF4090001,
136 0xC78, 0xF30A0001,
137 0xC78, 0xF20B0001,
138 0xC78, 0xF10C0001,
139 0xC78, 0xF00D0001,
140 0xC78, 0xEF0E0001,
141 0xC78, 0xEE0F0001,
142 0xC78, 0xED100001,
143 0xC78, 0xEC110001,
144 0xC78, 0xEB120001,
145 0xC78, 0xEA130001,
146 0xC78, 0xE9140001,
147 0xC78, 0xE8150001,
148 0xC78, 0xE7160001,
149 0xC78, 0xE6170001,
150 0xC78, 0xE5180001,
151 0xC78, 0xE4190001,
152 0xC78, 0xE31A0001,
153 0xC78, 0xA51B0001,
154 0xC78, 0xA41C0001,
155 0xC78, 0xA31D0001,
156 0xC78, 0x671E0001,
157 0xC78, 0x661F0001,
158 0xC78, 0x65200001,
159 0xC78, 0x64210001,
160 0xC78, 0x63220001,
161 0xC78, 0x4A230001,
162 0xC78, 0x49240001,
163 0xC78, 0x48250001,
164 0xC78, 0x47260001,
165 0xC78, 0x46270001,
166 0xC78, 0x45280001,
167 0xC78, 0x44290001,
168 0xC78, 0x432A0001,
169 0xC78, 0x422B0001,
170 0xC78, 0x292C0001,
171 0xC78, 0x282D0001,
172 0xC78, 0x272E0001,
173 0xC78, 0x262F0001,
174 0xC78, 0x0A300001,
175 0xC78, 0x09310001,
176 0xC78, 0x08320001,
177 0xC78, 0x07330001,
178 0xC78, 0x06340001,
179 0xC78, 0x05350001,
180 0xC78, 0x04360001,
181 0xC78, 0x03370001,
182 0xC78, 0x02380001,
183 0xC78, 0x01390001,
184 0xC78, 0x013A0001,
185 0xC78, 0x013B0001,
186 0xC78, 0x013C0001,
187 0xC78, 0x013D0001,
188 0xC78, 0x013E0001,
189 0xC78, 0x013F0001,
190 0xC78, 0xFC400001,
191 0xC78, 0xFB410001,
192 0xC78, 0xFA420001,
193 0xC78, 0xF9430001,
194 0xC78, 0xF8440001,
195 0xC78, 0xF7450001,
196 0xC78, 0xF6460001,
197 0xC78, 0xF5470001,
198 0xC78, 0xF4480001,
199 0xC78, 0xF3490001,
200 0xC78, 0xF24A0001,
201 0xC78, 0xF14B0001,
202 0xC78, 0xF04C0001,
203 0xC78, 0xEF4D0001,
204 0xC78, 0xEE4E0001,
205 0xC78, 0xED4F0001,
206 0xC78, 0xEC500001,
207 0xC78, 0xEB510001,
208 0xC78, 0xEA520001,
209 0xC78, 0xE9530001,
210 0xC78, 0xE8540001,
211 0xC78, 0xE7550001,
212 0xC78, 0xE6560001,
213 0xC78, 0xE5570001,
214 0xC78, 0xE4580001,
215 0xC78, 0xE3590001,
216 0xC78, 0xA65A0001,
217 0xC78, 0xA55B0001,
218 0xC78, 0xA45C0001,
219 0xC78, 0xA35D0001,
220 0xC78, 0x675E0001,
221 0xC78, 0x665F0001,
222 0xC78, 0x65600001,
223 0xC78, 0x64610001,
224 0xC78, 0x63620001,
225 0xC78, 0x62630001,
226 0xC78, 0x61640001,
227 0xC78, 0x48650001,
228 0xC78, 0x47660001,
229 0xC78, 0x46670001,
230 0xC78, 0x45680001,
231 0xC78, 0x44690001,
232 0xC78, 0x436A0001,
233 0xC78, 0x426B0001,
234 0xC78, 0x286C0001,
235 0xC78, 0x276D0001,
236 0xC78, 0x266E0001,
237 0xC78, 0x256F0001,
238 0xC78, 0x24700001,
239 0xC78, 0x09710001,
240 0xC78, 0x08720001,
241 0xC78, 0x07730001,
242 0xC78, 0x06740001,
243 0xC78, 0x05750001,
244 0xC78, 0x04760001,
245 0xC78, 0x03770001,
246 0xC78, 0x02780001,
247 0xC78, 0x01790001,
248 0xC78, 0x017A0001,
249 0xC78, 0x017B0001,
250 0xC78, 0x017C0001,
251 0xC78, 0x017D0001,
252 0xC78, 0x017E0001,
253 0xC78, 0x017F0001,
254 0xC50, 0x69553422,
255 0xC50, 0x69553420,
256 0x824, 0x00390204,
257
258};
259
260void ODM_ReadAndConfig_MP_8723B_AGC_TAB(PDM_ODM_T pDM_Odm)
261{
262 u32 i = 0;
263 u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_AGC_TAB);
264 u32 *Array = Array_MP_8723B_AGC_TAB;
265
266 ODM_RT_TRACE(
267 pDM_Odm,
268 ODM_COMP_INIT,
269 ODM_DBG_LOUD,
270 ("===> ODM_ReadAndConfig_MP_8723B_AGC_TAB\n")
271 );
272
273 for (i = 0; i < ArrayLen; i += 2) {
274 u32 v1 = Array[i];
275 u32 v2 = Array[i+1];
276
277
278 if (v1 < 0x40000000) {
279 odm_ConfigBB_AGC_8723B(pDM_Odm, v1, bMaskDWord, v2);
280 continue;
281 } else {
282
283 bool bMatched = true;
284 u8 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28);
285
286 if (cCond == COND_ELSE) {
287 bMatched = true;
288 READ_NEXT_PAIR(v1, v2, i);
289 } else if (!CheckPositive(pDM_Odm, v1, v2)) {
290 bMatched = false;
291 READ_NEXT_PAIR(v1, v2, i);
292 READ_NEXT_PAIR(v1, v2, i);
293 } else {
294 READ_NEXT_PAIR(v1, v2, i);
295 if (!CheckNegative(pDM_Odm, v1, v2))
296 bMatched = false;
297 else
298 bMatched = true;
299 READ_NEXT_PAIR(v1, v2, i);
300 }
301
302 if (!bMatched) {
303
304
305
306 while (v1 < 0x40000000 && i < ArrayLen-2)
307 READ_NEXT_PAIR(v1, v2, i);
308
309 i -= 2;
310 } else {
311
312 while (v1 < 0x40000000 && i < ArrayLen-2) {
313 odm_ConfigBB_AGC_8723B(pDM_Odm, v1, bMaskDWord, v2);
314 READ_NEXT_PAIR(v1, v2, i);
315 }
316
317
318 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28);
319 while (cCond != COND_ENDIF && i < ArrayLen-2) {
320 READ_NEXT_PAIR(v1, v2, i);
321 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28);
322 }
323 }
324 }
325 }
326}
327
328
329
330
331
332static u32 Array_MP_8723B_PHY_REG[] = {
333 0x800, 0x80040000,
334 0x804, 0x00000003,
335 0x808, 0x0000FC00,
336 0x80C, 0x0000000A,
337 0x810, 0x10001331,
338 0x814, 0x020C3D10,
339 0x818, 0x02200385,
340 0x81C, 0x00000000,
341 0x820, 0x01000100,
342 0x824, 0x00190204,
343 0x828, 0x00000000,
344 0x82C, 0x00000000,
345 0x830, 0x00000000,
346 0x834, 0x00000000,
347 0x838, 0x00000000,
348 0x83C, 0x00000000,
349 0x840, 0x00010000,
350 0x844, 0x00000000,
351 0x848, 0x00000000,
352 0x84C, 0x00000000,
353 0x850, 0x00000000,
354 0x854, 0x00000000,
355 0x858, 0x569A11A9,
356 0x85C, 0x01000014,
357 0x860, 0x66F60110,
358 0x864, 0x061F0649,
359 0x868, 0x00000000,
360 0x86C, 0x27272700,
361 0x870, 0x07000760,
362 0x874, 0x25004000,
363 0x878, 0x00000808,
364 0x87C, 0x00000000,
365 0x880, 0xB0000C1C,
366 0x884, 0x00000001,
367 0x888, 0x00000000,
368 0x88C, 0xCCC000C0,
369 0x890, 0x00000800,
370 0x894, 0xFFFFFFFE,
371 0x898, 0x40302010,
372 0x89C, 0x00706050,
373 0x900, 0x00000000,
374 0x904, 0x00000023,
375 0x908, 0x00000000,
376 0x90C, 0x81121111,
377 0x910, 0x00000002,
378 0x914, 0x00000201,
379 0xA00, 0x00D047C8,
380 0xA04, 0x80FF800C,
381 0xA08, 0x8C838300,
382 0xA0C, 0x2E7F120F,
383 0xA10, 0x9500BB78,
384 0xA14, 0x1114D028,
385 0xA18, 0x00881117,
386 0xA1C, 0x89140F00,
387 0xA20, 0x1A1B0000,
388 0xA24, 0x090E1317,
389 0xA28, 0x00000204,
390 0xA2C, 0x00D30000,
391 0xA70, 0x101FBF00,
392 0xA74, 0x00000007,
393 0xA78, 0x00000900,
394 0xA7C, 0x225B0606,
395 0xA80, 0x21806490,
396 0xB2C, 0x00000000,
397 0xC00, 0x48071D40,
398 0xC04, 0x03A05611,
399 0xC08, 0x000000E4,
400 0xC0C, 0x6C6C6C6C,
401 0xC10, 0x08800000,
402 0xC14, 0x40000100,
403 0xC18, 0x08800000,
404 0xC1C, 0x40000100,
405 0xC20, 0x00000000,
406 0xC24, 0x00000000,
407 0xC28, 0x00000000,
408 0xC2C, 0x00000000,
409 0xC30, 0x69E9AC44,
410 0xC34, 0x469652AF,
411 0xC38, 0x49795994,
412 0xC3C, 0x0A97971C,
413 0xC40, 0x1F7C403F,
414 0xC44, 0x000100B7,
415 0xC48, 0xEC020107,
416 0xC4C, 0x007F037F,
417 0xC50, 0x69553420,
418 0xC54, 0x43BC0094,
419 0xC58, 0x00013149,
420 0xC5C, 0x00250492,
421 0xC60, 0x00000000,
422 0xC64, 0x7112848B,
423 0xC68, 0x47C00BFF,
424 0xC6C, 0x00000036,
425 0xC70, 0x2C7F000D,
426 0xC74, 0x020610DB,
427 0xC78, 0x0000001F,
428 0xC7C, 0x00B91612,
429 0xC80, 0x390000E4,
430 0xC84, 0x20F60000,
431 0xC88, 0x40000100,
432 0xC8C, 0x20200000,
433 0xC90, 0x00020E1A,
434 0xC94, 0x00000000,
435 0xC98, 0x00020E1A,
436 0xC9C, 0x00007F7F,
437 0xCA0, 0x00000000,
438 0xCA4, 0x000300A0,
439 0xCA8, 0x00000000,
440 0xCAC, 0x00000000,
441 0xCB0, 0x00000000,
442 0xCB4, 0x00000000,
443 0xCB8, 0x00000000,
444 0xCBC, 0x28000000,
445 0xCC0, 0x00000000,
446 0xCC4, 0x00000000,
447 0xCC8, 0x00000000,
448 0xCCC, 0x00000000,
449 0xCD0, 0x00000000,
450 0xCD4, 0x00000000,
451 0xCD8, 0x64B22427,
452 0xCDC, 0x00766932,
453 0xCE0, 0x00222222,
454 0xCE4, 0x00000000,
455 0xCE8, 0x37644302,
456 0xCEC, 0x2F97D40C,
457 0xD00, 0x00000740,
458 0xD04, 0x40020401,
459 0xD08, 0x0000907F,
460 0xD0C, 0x20010201,
461 0xD10, 0xA0633333,
462 0xD14, 0x3333BC53,
463 0xD18, 0x7A8F5B6F,
464 0xD2C, 0xCC979975,
465 0xD30, 0x00000000,
466 0xD34, 0x80608000,
467 0xD38, 0x00000000,
468 0xD3C, 0x00127353,
469 0xD40, 0x00000000,
470 0xD44, 0x00000000,
471 0xD48, 0x00000000,
472 0xD4C, 0x00000000,
473 0xD50, 0x6437140A,
474 0xD54, 0x00000000,
475 0xD58, 0x00000282,
476 0xD5C, 0x30032064,
477 0xD60, 0x4653DE68,
478 0xD64, 0x04518A3C,
479 0xD68, 0x00002101,
480 0xD6C, 0x2A201C16,
481 0xD70, 0x1812362E,
482 0xD74, 0x322C2220,
483 0xD78, 0x000E3C24,
484 0xE00, 0x2D2D2D2D,
485 0xE04, 0x2D2D2D2D,
486 0xE08, 0x0390272D,
487 0xE10, 0x2D2D2D2D,
488 0xE14, 0x2D2D2D2D,
489 0xE18, 0x2D2D2D2D,
490 0xE1C, 0x2D2D2D2D,
491 0xE28, 0x00000000,
492 0xE30, 0x1000DC1F,
493 0xE34, 0x10008C1F,
494 0xE38, 0x02140102,
495 0xE3C, 0x681604C2,
496 0xE40, 0x01007C00,
497 0xE44, 0x01004800,
498 0xE48, 0xFB000000,
499 0xE4C, 0x000028D1,
500 0xE50, 0x1000DC1F,
501 0xE54, 0x10008C1F,
502 0xE58, 0x02140102,
503 0xE5C, 0x28160D05,
504 0xE60, 0x00000008,
505 0xE68, 0x001B2556,
506 0xE6C, 0x00C00096,
507 0xE70, 0x00C00096,
508 0xE74, 0x01000056,
509 0xE78, 0x01000014,
510 0xE7C, 0x01000056,
511 0xE80, 0x01000014,
512 0xE84, 0x00C00096,
513 0xE88, 0x01000056,
514 0xE8C, 0x00C00096,
515 0xED0, 0x00C00096,
516 0xED4, 0x00C00096,
517 0xED8, 0x00C00096,
518 0xEDC, 0x000000D6,
519 0xEE0, 0x000000D6,
520 0xEEC, 0x01C00016,
521 0xF14, 0x00000003,
522 0xF4C, 0x00000000,
523 0xF00, 0x00000300,
524 0x820, 0x01000100,
525 0x800, 0x83040000,
526
527};
528
529void ODM_ReadAndConfig_MP_8723B_PHY_REG(PDM_ODM_T pDM_Odm)
530{
531 u32 i = 0;
532 u32 ArrayLen = ARRAY_SIZE(Array_MP_8723B_PHY_REG);
533 u32 *Array = Array_MP_8723B_PHY_REG;
534
535 ODM_RT_TRACE(
536 pDM_Odm,
537 ODM_COMP_INIT,
538 ODM_DBG_LOUD,
539 ("===> ODM_ReadAndConfig_MP_8723B_PHY_REG\n")
540 );
541
542 for (i = 0; i < ArrayLen; i += 2) {
543 u32 v1 = Array[i];
544 u32 v2 = Array[i+1];
545
546
547 if (v1 < 0x40000000) {
548 odm_ConfigBB_PHY_8723B(pDM_Odm, v1, bMaskDWord, v2);
549 continue;
550 } else {
551
552 bool bMatched = true;
553 u8 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28);
554
555 if (cCond == COND_ELSE) {
556 bMatched = true;
557 READ_NEXT_PAIR(v1, v2, i);
558 } else if (!CheckPositive(pDM_Odm, v1, v2)) {
559 bMatched = false;
560 READ_NEXT_PAIR(v1, v2, i);
561 READ_NEXT_PAIR(v1, v2, i);
562 } else {
563 READ_NEXT_PAIR(v1, v2, i);
564 if (!CheckNegative(pDM_Odm, v1, v2))
565 bMatched = false;
566 else
567 bMatched = true;
568 READ_NEXT_PAIR(v1, v2, i);
569 }
570
571 if (!bMatched) {
572
573
574
575 while (v1 < 0x40000000 && i < ArrayLen-2)
576 READ_NEXT_PAIR(v1, v2, i);
577
578 i -= 2;
579 } else {
580 while (v1 < 0x40000000 && i < ArrayLen-2) {
581 odm_ConfigBB_PHY_8723B(pDM_Odm, v1, bMaskDWord, v2);
582 READ_NEXT_PAIR(v1, v2, i);
583 }
584
585
586 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28);
587 while (cCond != COND_ENDIF && i < ArrayLen-2) {
588 READ_NEXT_PAIR(v1, v2, i);
589 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28);
590 }
591 }
592 }
593 }
594}
595
596
597
598
599
600static u32 Array_MP_8723B_PHY_REG_PG[] = {
601 0, 0, 0, 0x00000e08, 0x0000ff00, 0x00003800,
602 0, 0, 0, 0x0000086c, 0xffffff00, 0x32343600,
603 0, 0, 0, 0x00000e00, 0xffffffff, 0x40424444,
604 0, 0, 0, 0x00000e04, 0xffffffff, 0x28323638,
605 0, 0, 0, 0x00000e10, 0xffffffff, 0x38404244,
606 0, 0, 0, 0x00000e14, 0xffffffff, 0x26303436
607};
608
609void ODM_ReadAndConfig_MP_8723B_PHY_REG_PG(PDM_ODM_T pDM_Odm)
610{
611 u32 i = 0;
612 u32 *Array = Array_MP_8723B_PHY_REG_PG;
613
614 ODM_RT_TRACE(
615 pDM_Odm,
616 ODM_COMP_INIT,
617 ODM_DBG_LOUD,
618 ("===> ODM_ReadAndConfig_MP_8723B_PHY_REG_PG\n")
619 );
620
621 pDM_Odm->PhyRegPgVersion = 1;
622 pDM_Odm->PhyRegPgValueType = PHY_REG_PG_EXACT_VALUE;
623
624 for (i = 0; i < ARRAY_SIZE(Array_MP_8723B_PHY_REG_PG); i += 6) {
625 u32 v1 = Array[i];
626 u32 v2 = Array[i+1];
627 u32 v3 = Array[i+2];
628 u32 v4 = Array[i+3];
629 u32 v5 = Array[i+4];
630 u32 v6 = Array[i+5];
631
632 odm_ConfigBB_PHY_REG_PG_8723B(pDM_Odm, v1, v2, v3, v4, v5, v6);
633 }
634}
635