• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 ******************************************************************************/
15 
16 #include "odm_precomp.h"
17 
CheckCondition(const u32 Condition,const u32 Hex)18 static bool CheckCondition(const u32  Condition, const u32  Hex)
19 {
20 	u32 _board     = (Hex & 0x000000FF);
21 	u32 _interface = (Hex & 0x0000FF00) >> 8;
22 	u32 _platform  = (Hex & 0x00FF0000) >> 16;
23 	u32 cond = Condition;
24 
25 	if (Condition == 0xCDCDCDCD)
26 		return true;
27 
28 	cond = Condition & 0x000000FF;
29 	if ((_board == cond) && cond != 0x00)
30 		return false;
31 
32 	cond = Condition & 0x0000FF00;
33 	cond = cond >> 8;
34 	if ((_interface & cond) == 0 && cond != 0x07)
35 		return false;
36 
37 	cond = Condition & 0x00FF0000;
38 	cond = cond >> 16;
39 	if ((_platform & cond) == 0 && cond != 0x0F)
40 		return false;
41 	return true;
42 }
43 
44 /******************************************************************************
45 *                           AGC_TAB_1T.TXT
46 ******************************************************************************/
47 
48 static u32 Array_AGC_TAB_1T_8723A[] = {
49 	0xC78, 0x7B000001,
50 	0xC78, 0x7B010001,
51 	0xC78, 0x7B020001,
52 	0xC78, 0x7B030001,
53 	0xC78, 0x7B040001,
54 	0xC78, 0x7B050001,
55 	0xC78, 0x7A060001,
56 	0xC78, 0x79070001,
57 	0xC78, 0x78080001,
58 	0xC78, 0x77090001,
59 	0xC78, 0x760A0001,
60 	0xC78, 0x750B0001,
61 	0xC78, 0x740C0001,
62 	0xC78, 0x730D0001,
63 	0xC78, 0x720E0001,
64 	0xC78, 0x710F0001,
65 	0xC78, 0x70100001,
66 	0xC78, 0x6F110001,
67 	0xC78, 0x6E120001,
68 	0xC78, 0x6D130001,
69 	0xC78, 0x6C140001,
70 	0xC78, 0x6B150001,
71 	0xC78, 0x6A160001,
72 	0xC78, 0x69170001,
73 	0xC78, 0x68180001,
74 	0xC78, 0x67190001,
75 	0xC78, 0x661A0001,
76 	0xC78, 0x651B0001,
77 	0xC78, 0x641C0001,
78 	0xC78, 0x631D0001,
79 	0xC78, 0x621E0001,
80 	0xC78, 0x611F0001,
81 	0xC78, 0x60200001,
82 	0xC78, 0x49210001,
83 	0xC78, 0x48220001,
84 	0xC78, 0x47230001,
85 	0xC78, 0x46240001,
86 	0xC78, 0x45250001,
87 	0xC78, 0x44260001,
88 	0xC78, 0x43270001,
89 	0xC78, 0x42280001,
90 	0xC78, 0x41290001,
91 	0xC78, 0x402A0001,
92 	0xC78, 0x262B0001,
93 	0xC78, 0x252C0001,
94 	0xC78, 0x242D0001,
95 	0xC78, 0x232E0001,
96 	0xC78, 0x222F0001,
97 	0xC78, 0x21300001,
98 	0xC78, 0x20310001,
99 	0xC78, 0x06320001,
100 	0xC78, 0x05330001,
101 	0xC78, 0x04340001,
102 	0xC78, 0x03350001,
103 	0xC78, 0x02360001,
104 	0xC78, 0x01370001,
105 	0xC78, 0x00380001,
106 	0xC78, 0x00390001,
107 	0xC78, 0x003A0001,
108 	0xC78, 0x003B0001,
109 	0xC78, 0x003C0001,
110 	0xC78, 0x003D0001,
111 	0xC78, 0x003E0001,
112 	0xC78, 0x003F0001,
113 	0xC78, 0x7B400001,
114 	0xC78, 0x7B410001,
115 	0xC78, 0x7B420001,
116 	0xC78, 0x7B430001,
117 	0xC78, 0x7B440001,
118 	0xC78, 0x7B450001,
119 	0xC78, 0x7A460001,
120 	0xC78, 0x79470001,
121 	0xC78, 0x78480001,
122 	0xC78, 0x77490001,
123 	0xC78, 0x764A0001,
124 	0xC78, 0x754B0001,
125 	0xC78, 0x744C0001,
126 	0xC78, 0x734D0001,
127 	0xC78, 0x724E0001,
128 	0xC78, 0x714F0001,
129 	0xC78, 0x70500001,
130 	0xC78, 0x6F510001,
131 	0xC78, 0x6E520001,
132 	0xC78, 0x6D530001,
133 	0xC78, 0x6C540001,
134 	0xC78, 0x6B550001,
135 	0xC78, 0x6A560001,
136 	0xC78, 0x69570001,
137 	0xC78, 0x68580001,
138 	0xC78, 0x67590001,
139 	0xC78, 0x665A0001,
140 	0xC78, 0x655B0001,
141 	0xC78, 0x645C0001,
142 	0xC78, 0x635D0001,
143 	0xC78, 0x625E0001,
144 	0xC78, 0x615F0001,
145 	0xC78, 0x60600001,
146 	0xC78, 0x49610001,
147 	0xC78, 0x48620001,
148 	0xC78, 0x47630001,
149 	0xC78, 0x46640001,
150 	0xC78, 0x45650001,
151 	0xC78, 0x44660001,
152 	0xC78, 0x43670001,
153 	0xC78, 0x42680001,
154 	0xC78, 0x41690001,
155 	0xC78, 0x406A0001,
156 	0xC78, 0x266B0001,
157 	0xC78, 0x256C0001,
158 	0xC78, 0x246D0001,
159 	0xC78, 0x236E0001,
160 	0xC78, 0x226F0001,
161 	0xC78, 0x21700001,
162 	0xC78, 0x20710001,
163 	0xC78, 0x06720001,
164 	0xC78, 0x05730001,
165 	0xC78, 0x04740001,
166 	0xC78, 0x03750001,
167 	0xC78, 0x02760001,
168 	0xC78, 0x01770001,
169 	0xC78, 0x00780001,
170 	0xC78, 0x00790001,
171 	0xC78, 0x007A0001,
172 	0xC78, 0x007B0001,
173 	0xC78, 0x007C0001,
174 	0xC78, 0x007D0001,
175 	0xC78, 0x007E0001,
176 	0xC78, 0x007F0001,
177 	0xC78, 0x3800001E,
178 	0xC78, 0x3801001E,
179 	0xC78, 0x3802001E,
180 	0xC78, 0x3803001E,
181 	0xC78, 0x3804001E,
182 	0xC78, 0x3805001E,
183 	0xC78, 0x3806001E,
184 	0xC78, 0x3807001E,
185 	0xC78, 0x3808001E,
186 	0xC78, 0x3C09001E,
187 	0xC78, 0x3E0A001E,
188 	0xC78, 0x400B001E,
189 	0xC78, 0x440C001E,
190 	0xC78, 0x480D001E,
191 	0xC78, 0x4C0E001E,
192 	0xC78, 0x500F001E,
193 	0xC78, 0x5210001E,
194 	0xC78, 0x5611001E,
195 	0xC78, 0x5A12001E,
196 	0xC78, 0x5E13001E,
197 	0xC78, 0x6014001E,
198 	0xC78, 0x6015001E,
199 	0xC78, 0x6016001E,
200 	0xC78, 0x6217001E,
201 	0xC78, 0x6218001E,
202 	0xC78, 0x6219001E,
203 	0xC78, 0x621A001E,
204 	0xC78, 0x621B001E,
205 	0xC78, 0x621C001E,
206 	0xC78, 0x621D001E,
207 	0xC78, 0x621E001E,
208 	0xC78, 0x621F001E,
209 };
210 
211 #define READ_NEXT_PAIR(v1, v2, i)			\
212 	do {						\
213 		i += 2; v1 = Array[i]; v2 = Array[i+1];	\
214 	} while (0)
215 
ODM_ReadAndConfig_AGC_TAB_1T_8723A(struct dm_odm_t * pDM_Odm)216 void ODM_ReadAndConfig_AGC_TAB_1T_8723A(struct dm_odm_t *pDM_Odm)
217 {
218 
219 	u32 hex;
220 	u32 i;
221 	u8 platform = 0x04;
222 	u8 interfaceValue   = pDM_Odm->SupportInterface;
223 	u8 board = pDM_Odm->BoardType;
224 	u32 ArrayLen = sizeof(Array_AGC_TAB_1T_8723A)/sizeof(u32);
225 	u32 *Array = Array_AGC_TAB_1T_8723A;
226 
227 	hex = board;
228 	hex += interfaceValue << 8;
229 	hex += platform << 16;
230 	hex += 0xFF000000;
231 	for (i = 0; i < ArrayLen; i += 2) {
232 		u32 v1 = Array[i];
233 		u32 v2 = Array[i+1];
234 
235 		/*  This (offset, data) pair meets the condition. */
236 		if (v1 < 0xCDCDCDCD) {
237 			odm_ConfigBB_AGC_8723A(pDM_Odm, v1, bMaskDWord, v2);
238 			continue;
239 		} else {
240 			if (!CheckCondition(Array[i], hex)) {
241 				/*  Discard the following (offset, data) pairs. */
242 				READ_NEXT_PAIR(v1, v2, i);
243 				while (v2 != 0xDEAD &&
244 				       v2 != 0xCDEF &&
245 				       v2 != 0xCDCD && i < ArrayLen - 2)
246 					READ_NEXT_PAIR(v1, v2, i);
247 				i -= 2; /*  prevent from for-loop += 2 */
248 			} else {
249 				/*  Configure matched pairs and skip to end of if-else. */
250 				READ_NEXT_PAIR(v1, v2, i);
251 				while (v2 != 0xDEAD &&
252 				       v2 != 0xCDEF &&
253 				       v2 != 0xCDCD && i < ArrayLen - 2) {
254 					odm_ConfigBB_AGC_8723A(pDM_Odm, v1, bMaskDWord, v2);
255 					READ_NEXT_PAIR(v1, v2, i);
256 				}
257 				while (v2 != 0xDEAD && i < ArrayLen - 2)
258 					READ_NEXT_PAIR(v1, v2, i);
259 			}
260 		}
261 	}
262 }
263 
264 /******************************************************************************
265 *                           PHY_REG_1T.TXT
266 ******************************************************************************/
267 
268 static u32 Array_PHY_REG_1T_8723A[] = {
269 	0x800, 0x80040000,
270 	0x804, 0x00000003,
271 	0x808, 0x0000FC00,
272 	0x80C, 0x0000000A,
273 	0x810, 0x10001331,
274 	0x814, 0x020C3D10,
275 	0x818, 0x02200385,
276 	0x81C, 0x00000000,
277 	0x820, 0x01000100,
278 	0x824, 0x00390004,
279 	0x828, 0x00000000,
280 	0x82C, 0x00000000,
281 	0x830, 0x00000000,
282 	0x834, 0x00000000,
283 	0x838, 0x00000000,
284 	0x83C, 0x00000000,
285 	0x840, 0x00010000,
286 	0x844, 0x00000000,
287 	0x848, 0x00000000,
288 	0x84C, 0x00000000,
289 	0x850, 0x00000000,
290 	0x854, 0x00000000,
291 	0x858, 0x569A569A,
292 	0x85C, 0x001B25A4,
293 	0x860, 0x66F60110,
294 	0x864, 0x061F0130,
295 	0x868, 0x00000000,
296 	0x86C, 0x32323200,
297 	0x870, 0x07000760,
298 	0x874, 0x22004000,
299 	0x878, 0x00000808,
300 	0x87C, 0x00000000,
301 	0x880, 0xC0083070,
302 	0x884, 0x000004D5,
303 	0x888, 0x00000000,
304 	0x88C, 0xCCC000C0,
305 	0x890, 0x00000800,
306 	0x894, 0xFFFFFFFE,
307 	0x898, 0x40302010,
308 	0x89C, 0x00706050,
309 	0x900, 0x00000000,
310 	0x904, 0x00000023,
311 	0x908, 0x00000000,
312 	0x90C, 0x81121111,
313 	0xA00, 0x00D047C8,
314 	0xA04, 0x80FF000C,
315 	0xA08, 0x8C838300,
316 	0xA0C, 0x2E68120F,
317 	0xA10, 0x9500BB78,
318 	0xA14, 0x11144028,
319 	0xA18, 0x00881117,
320 	0xA1C, 0x89140F00,
321 	0xA20, 0x1A1B0000,
322 	0xA24, 0x090E1317,
323 	0xA28, 0x00000204,
324 	0xA2C, 0x00D30000,
325 	0xA70, 0x101FBF00,
326 	0xA74, 0x00000007,
327 	0xA78, 0x00000900,
328 	0xC00, 0x48071D40,
329 	0xC04, 0x03A05611,
330 	0xC08, 0x000000E4,
331 	0xC0C, 0x6C6C6C6C,
332 	0xC10, 0x08800000,
333 	0xC14, 0x40000100,
334 	0xC18, 0x08800000,
335 	0xC1C, 0x40000100,
336 	0xC20, 0x00000000,
337 	0xC24, 0x00000000,
338 	0xC28, 0x00000000,
339 	0xC2C, 0x00000000,
340 	0xC30, 0x69E9AC44,
341 	0xFF0F011F, 0xABCD,
342 	0xC34, 0x469652CF,
343 	0xCDCDCDCD, 0xCDCD,
344 	0xC34, 0x469652AF,
345 	0xFF0F011F, 0xDEAD,
346 	0xC38, 0x49795994,
347 	0xC3C, 0x0A97971C,
348 	0xC40, 0x1F7C403F,
349 	0xC44, 0x000100B7,
350 	0xC48, 0xEC020107,
351 	0xC4C, 0x007F037F,
352 	0xC50, 0x69543420,
353 	0xC54, 0x43BC0094,
354 	0xC58, 0x69543420,
355 	0xC5C, 0x433C0094,
356 	0xC60, 0x00000000,
357 	0xFF0F011F, 0xABCD,
358 	0xC64, 0x7116848B,
359 	0xCDCDCDCD, 0xCDCD,
360 	0xC64, 0x7112848B,
361 	0xFF0F011F, 0xDEAD,
362 	0xC68, 0x47C00BFF,
363 	0xC6C, 0x00000036,
364 	0xC70, 0x2C7F000D,
365 	0xC74, 0x018610DB,
366 	0xC78, 0x0000001F,
367 	0xC7C, 0x00B91612,
368 	0xC80, 0x40000100,
369 	0xC84, 0x20F60000,
370 	0xC88, 0x40000100,
371 	0xC8C, 0x20200000,
372 	0xC90, 0x00121820,
373 	0xC94, 0x00000000,
374 	0xC98, 0x00121820,
375 	0xC9C, 0x00007F7F,
376 	0xCA0, 0x00000000,
377 	0xCA4, 0x00000080,
378 	0xCA8, 0x00000000,
379 	0xCAC, 0x00000000,
380 	0xCB0, 0x00000000,
381 	0xCB4, 0x00000000,
382 	0xCB8, 0x00000000,
383 	0xCBC, 0x28000000,
384 	0xCC0, 0x00000000,
385 	0xCC4, 0x00000000,
386 	0xCC8, 0x00000000,
387 	0xCCC, 0x00000000,
388 	0xCD0, 0x00000000,
389 	0xCD4, 0x00000000,
390 	0xCD8, 0x64B22427,
391 	0xCDC, 0x00766932,
392 	0xCE0, 0x00222222,
393 	0xCE4, 0x00000000,
394 	0xCE8, 0x37644302,
395 	0xCEC, 0x2F97D40C,
396 	0xD00, 0x00080740,
397 	0xD04, 0x00020401,
398 	0xD08, 0x0000907F,
399 	0xD0C, 0x20010201,
400 	0xD10, 0xA0633333,
401 	0xD14, 0x3333BC43,
402 	0xD18, 0x7A8F5B6B,
403 	0xD2C, 0xCC979975,
404 	0xD30, 0x00000000,
405 	0xD34, 0x80608000,
406 	0xD38, 0x00000000,
407 	0xD3C, 0x00027293,
408 	0xD40, 0x00000000,
409 	0xD44, 0x00000000,
410 	0xD48, 0x00000000,
411 	0xD4C, 0x00000000,
412 	0xD50, 0x6437140A,
413 	0xD54, 0x00000000,
414 	0xD58, 0x00000000,
415 	0xD5C, 0x30032064,
416 	0xD60, 0x4653DE68,
417 	0xD64, 0x04518A3C,
418 	0xD68, 0x00002101,
419 	0xD6C, 0x2A201C16,
420 	0xD70, 0x1812362E,
421 	0xD74, 0x322C2220,
422 	0xD78, 0x000E3C24,
423 	0xE00, 0x2A2A2A2A,
424 	0xE04, 0x2A2A2A2A,
425 	0xE08, 0x03902A2A,
426 	0xE10, 0x2A2A2A2A,
427 	0xE14, 0x2A2A2A2A,
428 	0xE18, 0x2A2A2A2A,
429 	0xE1C, 0x2A2A2A2A,
430 	0xE28, 0x00000000,
431 	0xE30, 0x1000DC1F,
432 	0xE34, 0x10008C1F,
433 	0xE38, 0x02140102,
434 	0xE3C, 0x681604C2,
435 	0xE40, 0x01007C00,
436 	0xE44, 0x01004800,
437 	0xE48, 0xFB000000,
438 	0xE4C, 0x000028D1,
439 	0xE50, 0x1000DC1F,
440 	0xE54, 0x10008C1F,
441 	0xE58, 0x02140102,
442 	0xE5C, 0x28160D05,
443 	0xE60, 0x00000008,
444 	0xE68, 0x001B25A4,
445 	0xE6C, 0x631B25A0,
446 	0xE70, 0x631B25A0,
447 	0xE74, 0x081B25A0,
448 	0xE78, 0x081B25A0,
449 	0xE7C, 0x081B25A0,
450 	0xE80, 0x081B25A0,
451 	0xE84, 0x631B25A0,
452 	0xE88, 0x081B25A0,
453 	0xE8C, 0x631B25A0,
454 	0xED0, 0x631B25A0,
455 	0xED4, 0x631B25A0,
456 	0xED8, 0x631B25A0,
457 	0xEDC, 0x001B25A0,
458 	0xEE0, 0x001B25A0,
459 	0xEEC, 0x6B1B25A0,
460 	0xF14, 0x00000003,
461 	0xF4C, 0x00000000,
462 	0xF00, 0x00000300,
463 };
464 
ODM_ReadAndConfig_PHY_REG_1T_8723A(struct dm_odm_t * pDM_Odm)465 void ODM_ReadAndConfig_PHY_REG_1T_8723A(struct dm_odm_t *pDM_Odm)
466 {
467 	u32 hex = 0;
468 	u32 i = 0;
469 	u8  platform = 0x04;
470 	u8  interfaceValue = pDM_Odm->SupportInterface;
471 	u8  board = pDM_Odm->BoardType;
472 	u32 ArrayLen = sizeof(Array_PHY_REG_1T_8723A)/sizeof(u32);
473 	u32 *Array = Array_PHY_REG_1T_8723A;
474 
475 	hex += board;
476 	hex += interfaceValue << 8;
477 	hex += platform << 16;
478 	hex += 0xFF000000;
479 	for (i = 0; i < ArrayLen; i += 2) {
480 		u32 v1 = Array[i];
481 		u32 v2 = Array[i+1];
482 
483 		/*  This (offset, data) pair meets the condition. */
484 		if (v1 < 0xCDCDCDCD) {
485 			odm_ConfigBB_PHY_8723A(pDM_Odm, v1, bMaskDWord, v2);
486 			continue;
487 		} else {
488 			if (!CheckCondition(Array[i], hex)) {
489 				/*  Discard the following (offset, data) pairs. */
490 				READ_NEXT_PAIR(v1, v2, i);
491 				while (v2 != 0xDEAD &&
492 				       v2 != 0xCDEF &&
493 				       v2 != 0xCDCD && i < ArrayLen - 2)
494 					READ_NEXT_PAIR(v1, v2, i);
495 				i -= 2; /*  prevent from for-loop += 2 */
496 			} else {
497 				/*  Configure matched pairs and skip to end of if-else. */
498 				READ_NEXT_PAIR(v1, v2, i);
499 				while (v2 != 0xDEAD &&
500 				       v2 != 0xCDEF &&
501 				       v2 != 0xCDCD && i < ArrayLen - 2) {
502 					odm_ConfigBB_PHY_8723A(pDM_Odm, v1, bMaskDWord, v2);
503 					READ_NEXT_PAIR(v1, v2, i);
504 				}
505 				while (v2 != 0xDEAD && i < ArrayLen - 2)
506 					READ_NEXT_PAIR(v1, v2, i);
507 			}
508 		}
509 	}
510 }
511 
512 /******************************************************************************
513 *                           PHY_REG_MP.TXT
514 ******************************************************************************/
515 
516 static u32 Array_PHY_REG_MP_8723A[] = {
517 	0xC30, 0x69E9AC4A,
518 	0xC3C, 0x0A979718,
519 };
520 
ODM_ReadAndConfig_PHY_REG_MP_8723A(struct dm_odm_t * pDM_Odm)521 void ODM_ReadAndConfig_PHY_REG_MP_8723A(struct dm_odm_t *pDM_Odm)
522 {
523 	u32     hex         = 0;
524 	u32     i           = 0;
525 	u8     platform    = 0x04;
526 	u8     interfaceValue   = pDM_Odm->SupportInterface;
527 	u8     board       = pDM_Odm->BoardType;
528 	u32     ArrayLen    = sizeof(Array_PHY_REG_MP_8723A)/sizeof(u32);
529 	u32 *Array       = Array_PHY_REG_MP_8723A;
530 
531 	hex += board;
532 	hex += interfaceValue << 8;
533 	hex += platform << 16;
534 	hex += 0xFF000000;
535 	for (i = 0; i < ArrayLen; i += 2) {
536 		u32 v1 = Array[i];
537 		u32 v2 = Array[i+1];
538 
539 		/*  This (offset, data) pair meets the condition. */
540 		if (v1 < 0xCDCDCDCD) {
541 			odm_ConfigBB_PHY_8723A(pDM_Odm, v1, bMaskDWord, v2);
542 			continue;
543 		} else {
544 			if (!CheckCondition(Array[i], hex)) {
545 				/* Discard the following (offset, data) pairs. */
546 				READ_NEXT_PAIR(v1, v2, i);
547 				while (v2 != 0xDEAD &&
548 				       v2 != 0xCDEF &&
549 				       v2 != 0xCDCD && i < ArrayLen - 2)
550 					READ_NEXT_PAIR(v1, v2, i);
551 				i -= 2; /*  prevent from for-loop += 2 */
552 			} else {
553 				/* Configure matched pairs and skip to end of if-else. */
554 				READ_NEXT_PAIR(v1, v2, i);
555 				while (v2 != 0xDEAD &&
556 				       v2 != 0xCDEF &&
557 				       v2 != 0xCDCD && i < ArrayLen - 2) {
558 					odm_ConfigBB_PHY_8723A(pDM_Odm, v1, bMaskDWord, v2);
559 					READ_NEXT_PAIR(v1, v2, i);
560 				}
561 				while (v2 != 0xDEAD && i < ArrayLen - 2)
562 					READ_NEXT_PAIR(v1, v2, i);
563 			}
564 		}
565 	}
566 }
567