1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 ******************************************************************************/
17 #include "odm_precomp.h"
19 static bool CheckPositive(
20 PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
24 ((pDM_Odm->BoardType & BIT4) >> 4) << 0 | /* _GLNA */
25 ((pDM_Odm->BoardType & BIT3) >> 3) << 1 | /* _GPA */
26 ((pDM_Odm->BoardType & BIT7) >> 7) << 2 | /* _ALNA */
27 ((pDM_Odm->BoardType & BIT6) >> 6) << 3 | /* _APA */
28 ((pDM_Odm->BoardType & BIT2) >> 2) << 4; /* _BT */
30 u32 cond1 = Condition1, cond2 = Condition2;
32 pDM_Odm->CutVersion << 24 |
33 pDM_Odm->SupportPlatform << 16 |
34 pDM_Odm->PackageType << 12 |
35 pDM_Odm->SupportInterface << 8 |
39 pDM_Odm->TypeGLNA << 0 |
40 pDM_Odm->TypeGPA << 8 |
41 pDM_Odm->TypeALNA << 16 |
42 pDM_Odm->TypeAPA << 24;
49 "===> [8812A] CheckPositive (cond1, cond2) = (0x%X 0x%X)\n",
59 "===> [8812A] CheckPositive (driver1, driver2) = (0x%X 0x%X)\n",
70 " (Platform, Interface) = (0x%X, 0x%X)\n",
71 pDM_Odm->SupportPlatform,
72 pDM_Odm->SupportInterface
80 " (Board, Package) = (0x%X, 0x%X)\n",
87 /* Value Defined Check =============== */
88 /* QFN Type [15:12] and Cut Version [27:24] need to do value check */
90 if (((cond1 & 0x0000F000) != 0) && ((cond1 & 0x0000F000) != (driver1 & 0x0000F000)))
92 if (((cond1 & 0x0F000000) != 0) && ((cond1 & 0x0F000000) != (driver1 & 0x0F000000)))
95 /* Bit Defined Check ================ */
96 /* We don't care [31:28] and [23:20] */
99 driver1 &= 0x000F0FFF;
101 if ((cond1 & driver1) == cond1) {
103 if ((cond1 & 0x0F) == 0) /* BoardType is DONTCARE */
106 if ((cond1 & BIT0) != 0) /* GLNA */
107 bitMask |= 0x000000FF;
108 if ((cond1 & BIT1) != 0) /* GPA */
109 bitMask |= 0x0000FF00;
110 if ((cond1 & BIT2) != 0) /* ALNA */
111 bitMask |= 0x00FF0000;
112 if ((cond1 & BIT3) != 0) /* APA */
113 bitMask |= 0xFF000000;
115 if ((cond2 & bitMask) == (driver2 & bitMask)) /* BoardType of each RF path is matched */
121 static bool CheckNegative(
122 PDM_ODM_T pDM_Odm, const u32 Condition1, const u32 Condition2
128 /******************************************************************************
130 ******************************************************************************/
132 static u32 Array_MP_8723B_MAC_REG[] = {
239 void ODM_ReadAndConfig_MP_8723B_MAC_REG(PDM_ODM_T pDM_Odm)
242 u32 ArrayLen = sizeof(Array_MP_8723B_MAC_REG)/sizeof(u32);
243 u32 *Array = Array_MP_8723B_MAC_REG;
249 ("===> ODM_ReadAndConfig_MP_8723B_MAC_REG\n")
252 for (i = 0; i < ArrayLen; i += 2) {
256 /* This (offset, data) pair doesn't care the condition. */
257 if (v1 < 0x40000000) {
258 odm_ConfigMAC_8723B(pDM_Odm, v1, (u8)v2);
261 /* This line is the beginning of branch. */
262 bool bMatched = true;
263 u8 cCond = (u8)((v1 & (BIT29|BIT28)) >> 28);
265 if (cCond == COND_ELSE) { /* ELSE, ENDIF */
267 READ_NEXT_PAIR(v1, v2, i);
268 } else if (!CheckPositive(pDM_Odm, v1, v2)) {
270 READ_NEXT_PAIR(v1, v2, i);
271 READ_NEXT_PAIR(v1, v2, i);
273 READ_NEXT_PAIR(v1, v2, i);
274 if (!CheckNegative(pDM_Odm, v1, v2))
278 READ_NEXT_PAIR(v1, v2, i);
281 if (bMatched == false) {
282 /* Condition isn't matched. Discard the following (offset, data) pairs. */
283 while (v1 < 0x40000000 && i < ArrayLen-2)
284 READ_NEXT_PAIR(v1, v2, i);
286 i -= 2; /* prevent from for-loop += 2 */
287 } else { /* Configure matched pairs and skip to end of if-else. */
288 while (v1 < 0x40000000 && i < ArrayLen-2) {
289 odm_ConfigMAC_8723B(pDM_Odm, v1, (u8)v2);
290 READ_NEXT_PAIR(v1, v2, i);
293 /* Keeps reading until ENDIF. */
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);