OSDN Git Service

Add rtl8723bu driver version 4.4.5
[android-x86/external-kernel-drivers.git] / rtl8723bu / hal / phydm / rtl8723b / halhwimg8723b_mac.c
1 /******************************************************************************
2 *
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
4 *
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.
8 *
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
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17 *
18 *
19 ******************************************************************************/
20
21 /*Image2HeaderVersion: 2.14*/
22 #include "mp_precomp.h"
23 #include "../phydm_precomp.h"
24
25 #if (RTL8723B_SUPPORT == 1)
26 static BOOLEAN
27 CheckPositive(
28         IN  PDM_ODM_T     pDM_Odm,
29         IN  const u4Byte  Condition1,
30         IN  const u4Byte  Condition2,
31         IN      const u4Byte  Condition3,
32         IN      const u4Byte  Condition4
33 )
34 {
35         u1Byte    _BoardType = ((pDM_Odm->BoardType & BIT4) >> 4) << 0 | /* _GLNA*/
36                                 ((pDM_Odm->BoardType & BIT3) >> 3) << 1 | /* _GPA*/
37                                 ((pDM_Odm->BoardType & BIT7) >> 7) << 2 | /* _ALNA*/
38                                 ((pDM_Odm->BoardType & BIT6) >> 6) << 3 | /* _APA */
39                                 ((pDM_Odm->BoardType & BIT2) >> 2) << 4;  /* _BT*/
40
41         u4Byte  cond1   = Condition1, cond2 = Condition2, cond3 = Condition3, cond4 = Condition4;
42         u4Byte    driver1 = pDM_Odm->CutVersion       << 24 |
43                                 (pDM_Odm->SupportInterface & 0xF0) << 16 |
44                                 pDM_Odm->SupportPlatform  << 16 |
45                                 pDM_Odm->PackageType      << 12 |
46                                 (pDM_Odm->SupportInterface & 0x0F) << 8  |
47                                 _BoardType;
48
49         u4Byte    driver2 = (pDM_Odm->TypeGLNA & 0xFF) <<  0 |
50                                 (pDM_Odm->TypeGPA & 0xFF)  <<  8 |
51                                 (pDM_Odm->TypeALNA & 0xFF) << 16 |
52                                 (pDM_Odm->TypeAPA & 0xFF)  << 24;
53
54 u4Byte    driver3 = 0;
55
56         u4Byte    driver4 = (pDM_Odm->TypeGLNA & 0xFF00) >>  8 |
57                                 (pDM_Odm->TypeGPA & 0xFF00) |
58                                 (pDM_Odm->TypeALNA & 0xFF00) << 8 |
59                                 (pDM_Odm->TypeAPA & 0xFF00)  << 16;
60
61         ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE,
62         ("===> CheckPositive (cond1, cond2, cond3, cond4) = (0x%X 0x%X 0x%X 0x%X)\n", cond1, cond2, cond3, cond4));
63         ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE,
64         ("===> CheckPositive (driver1, driver2, driver3, driver4) = (0x%X 0x%X 0x%X 0x%X)\n", driver1, driver2, driver3, driver4));
65
66         ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE,
67         ("      (Platform, Interface) = (0x%X, 0x%X)\n", pDM_Odm->SupportPlatform, pDM_Odm->SupportInterface));
68         ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE,
69         ("      (Board, Package) = (0x%X, 0x%X)\n", pDM_Odm->BoardType, pDM_Odm->PackageType));
70
71
72         /*============== Value Defined Check ===============*/
73         /*QFN Type [15:12] and Cut Version [27:24] need to do value check*/
74
75         if (((cond1 & 0x0000F000) != 0) && ((cond1 & 0x0000F000) != (driver1 & 0x0000F000)))
76                 return FALSE;
77         if (((cond1 & 0x0F000000) != 0) && ((cond1 & 0x0F000000) != (driver1 & 0x0F000000)))
78                 return FALSE;
79
80         /*=============== Bit Defined Check ================*/
81         /* We don't care [31:28] */
82
83         cond1   &= 0x00FF0FFF;
84         driver1 &= 0x00FF0FFF;
85
86         if ((cond1 & driver1) == cond1) {
87                 u4Byte bitMask = 0;
88
89                 if ((cond1 & 0x0F) == 0) /* BoardType is DONTCARE*/
90                         return TRUE;
91
92                 if ((cond1 & BIT0) != 0) /*GLNA*/
93                         bitMask |= 0x000000FF;
94                 if ((cond1 & BIT1) != 0) /*GPA*/
95                         bitMask |= 0x0000FF00;
96                 if ((cond1 & BIT2) != 0) /*ALNA*/
97                         bitMask |= 0x00FF0000;
98                 if ((cond1 & BIT3) != 0) /*APA*/
99                         bitMask |= 0xFF000000;
100
101                 if (((cond2 & bitMask) == (driver2 & bitMask)) && ((cond4 & bitMask) == (driver4 & bitMask)))  /* BoardType of each RF path is matched*/
102                         return TRUE;
103                 else
104                         return FALSE;
105         } else
106                 return FALSE;
107 }
108 static BOOLEAN
109 CheckNegative(
110         IN  PDM_ODM_T     pDM_Odm,
111         IN  const u4Byte  Condition1,
112         IN  const u4Byte  Condition2
113 )
114 {
115         return TRUE;
116 }
117
118 /******************************************************************************
119 *                           MAC_REG.TXT
120 ******************************************************************************/
121
122 u4Byte Array_MP_8723B_MAC_REG[] = {
123                 0x02F, 0x00000030,
124                 0x035, 0x00000000,
125                 0x039, 0x00000008,
126                 0x064, 0x00000000,
127                 0x067, 0x00000020,
128                 0x421, 0x0000000F,
129                 0x428, 0x0000000A,
130                 0x429, 0x00000010,
131                 0x430, 0x00000000,
132                 0x431, 0x00000000,
133                 0x432, 0x00000000,
134                 0x433, 0x00000001,
135                 0x434, 0x00000004,
136                 0x435, 0x00000005,
137                 0x436, 0x00000007,
138                 0x437, 0x00000008,
139                 0x43C, 0x00000004,
140                 0x43D, 0x00000005,
141                 0x43E, 0x00000007,
142                 0x43F, 0x00000008,
143                 0x440, 0x0000005D,
144                 0x441, 0x00000001,
145                 0x442, 0x00000000,
146                 0x444, 0x00000010,
147                 0x445, 0x00000000,
148                 0x446, 0x00000000,
149                 0x447, 0x00000000,
150                 0x448, 0x00000000,
151                 0x449, 0x000000F0,
152                 0x44A, 0x0000000F,
153                 0x44B, 0x0000003E,
154                 0x44C, 0x00000010,
155                 0x44D, 0x00000000,
156                 0x44E, 0x00000000,
157                 0x44F, 0x00000000,
158                 0x450, 0x00000000,
159                 0x451, 0x000000F0,
160                 0x452, 0x0000000F,
161                 0x453, 0x00000000,
162                 0x456, 0x0000005E,
163                 0x460, 0x00000066,
164                 0x461, 0x00000066,
165                 0x4C8, 0x000000FF,
166                 0x4C9, 0x00000008,
167                 0x4CC, 0x000000FF,
168                 0x4CD, 0x000000FF,
169                 0x4CE, 0x00000001,
170                 0x500, 0x00000026,
171                 0x501, 0x000000A2,
172                 0x502, 0x0000002F,
173                 0x503, 0x00000000,
174                 0x504, 0x00000028,
175                 0x505, 0x000000A3,
176                 0x506, 0x0000005E,
177                 0x507, 0x00000000,
178                 0x508, 0x0000002B,
179                 0x509, 0x000000A4,
180                 0x50A, 0x0000005E,
181                 0x50B, 0x00000000,
182                 0x50C, 0x0000004F,
183                 0x50D, 0x000000A4,
184                 0x50E, 0x00000000,
185                 0x50F, 0x00000000,
186                 0x512, 0x0000001C,
187                 0x514, 0x0000000A,
188                 0x516, 0x0000000A,
189                 0x525, 0x0000004F,
190                 0x550, 0x00000010,
191                 0x551, 0x00000010,
192                 0x559, 0x00000002,
193                 0x55C, 0x00000050,
194                 0x55D, 0x000000FF,
195                 0x605, 0x00000030,
196                 0x608, 0x0000000E,
197                 0x609, 0x0000002A,
198                 0x620, 0x000000FF,
199                 0x621, 0x000000FF,
200                 0x622, 0x000000FF,
201                 0x623, 0x000000FF,
202                 0x624, 0x000000FF,
203                 0x625, 0x000000FF,
204                 0x626, 0x000000FF,
205                 0x627, 0x000000FF,
206                 0x638, 0x00000050,
207                 0x63C, 0x0000000A,
208                 0x63D, 0x0000000A,
209                 0x63E, 0x0000000E,
210                 0x63F, 0x0000000E,
211                 0x640, 0x00000040,
212                 0x642, 0x00000040,
213                 0x643, 0x00000000,
214                 0x652, 0x000000C8,
215                 0x66E, 0x00000005,
216                 0x700, 0x00000021,
217                 0x701, 0x00000043,
218                 0x702, 0x00000065,
219                 0x703, 0x00000087,
220                 0x708, 0x00000021,
221                 0x709, 0x00000043,
222                 0x70A, 0x00000065,
223                 0x70B, 0x00000087,
224                 0x765, 0x00000018,
225                 0x76E, 0x00000004,
226
227 };
228
229 void
230 ODM_ReadAndConfig_MP_8723B_MAC_REG(
231         IN   PDM_ODM_T  pDM_Odm
232 )
233 {
234         u4Byte     i         = 0;
235         u1Byte     cCond;
236         BOOLEAN bMatched = TRUE, bSkipped = FALSE;
237         u4Byte     ArrayLen    = sizeof(Array_MP_8723B_MAC_REG)/sizeof(u4Byte);
238         pu4Byte    Array       = Array_MP_8723B_MAC_REG;
239
240         u4Byte  v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0;
241
242         ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===> ODM_ReadAndConfig_MP_8723B_MAC_REG\n"));
243
244         while ((i + 1) < ArrayLen) {
245                 v1 = Array[i];
246                 v2 = Array[i + 1];
247
248                 if (v1 & (BIT31 | BIT30)) {/*positive & negative condition*/
249                         if (v1 & BIT31) {/* positive condition*/
250                                 cCond  = (u1Byte)((v1 & (BIT29|BIT28)) >> 28);
251                                 if (cCond == COND_ENDIF) {/*end*/
252                                         bMatched = TRUE;
253                                         bSkipped = FALSE;
254                                         ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("ENDIF\n"));
255                                 } else if (cCond == COND_ELSE) { /*else*/
256                                         bMatched = bSkipped?FALSE:TRUE;
257                                         ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("ELSE\n"));
258                                 }
259                                 else {/*if , else if*/
260                                         pre_v1 = v1;
261                                         pre_v2 = v2;
262                                         ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("IF or ELSE IF\n"));
263                                 }
264                         } else if (v1 & BIT30) { /*negative condition*/
265                                 if (bSkipped == FALSE) {
266                                         if (CheckPositive(pDM_Odm, pre_v1, pre_v2, v1, v2)) {
267                                                 bMatched = TRUE;
268                                                 bSkipped = TRUE;
269                                         } else {
270                                                 bMatched = FALSE;
271                                                 bSkipped = FALSE;
272                                         }
273                                 } else
274                                         bMatched = FALSE;
275                         }
276                 } else {
277                         if (bMatched)
278                                 odm_ConfigMAC_8723B(pDM_Odm, v1, (u1Byte)v2);
279                 }
280                 i = i + 2;
281         }
282 }
283
284 u4Byte
285 ODM_GetVersion_MP_8723B_MAC_REG(void)
286 {
287            return 24;
288 }
289
290 #endif /* end of HWIMG_SUPPORT*/