• 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 >>= 8;
34 	if ((_interface & cond) == 0 && cond != 0x07)
35 		return false;
36 
37 	cond = Condition & 0x00FF0000;
38 	cond >>= 16;
39 	if ((_platform & cond) == 0 && cond != 0x0F)
40 		return false;
41 	return true;
42 }
43 
44 /******************************************************************************
45 *                           RadioA_1T.TXT
46 ******************************************************************************/
47 
48 static u32 Array_RadioA_1T_8723A[] = {
49 	0x000, 0x00030159,
50 	0x001, 0x00031284,
51 	0x002, 0x00098000,
52 	0xFF0F011F, 0xABCD,
53 	0x003, 0x00018C63,
54 	0xCDCDCDCD, 0xCDCD,
55 	0x003, 0x00039C63,
56 	0xFF0F011F, 0xDEAD,
57 	0x004, 0x000210E7,
58 	0x009, 0x0002044F,
59 	0x00A, 0x0001A3F1,
60 	0x00B, 0x00014787,
61 	0x00C, 0x000896FE,
62 	0x00D, 0x0000E02C,
63 	0x00E, 0x00039CE7,
64 	0x00F, 0x00000451,
65 	0x019, 0x00000000,
66 	0x01A, 0x00030355,
67 	0x01B, 0x00060A00,
68 	0x01C, 0x000FC378,
69 	0x01D, 0x000A1250,
70 	0x01E, 0x0000024F,
71 	0x01F, 0x00000000,
72 	0x020, 0x0000B614,
73 	0x021, 0x0006C000,
74 	0x022, 0x00000000,
75 	0x023, 0x00001558,
76 	0x024, 0x00000060,
77 	0x025, 0x00000483,
78 	0x026, 0x0004F000,
79 	0x027, 0x000EC7D9,
80 	0x028, 0x00057730,
81 	0x029, 0x00004783,
82 	0x02A, 0x00000001,
83 	0x02B, 0x00021334,
84 	0x02A, 0x00000000,
85 	0x02B, 0x00000054,
86 	0x02A, 0x00000001,
87 	0x02B, 0x00000808,
88 	0x02B, 0x00053333,
89 	0x02C, 0x0000000C,
90 	0x02A, 0x00000002,
91 	0x02B, 0x00000808,
92 	0x02B, 0x0005B333,
93 	0x02C, 0x0000000D,
94 	0x02A, 0x00000003,
95 	0x02B, 0x00000808,
96 	0x02B, 0x00063333,
97 	0x02C, 0x0000000D,
98 	0x02A, 0x00000004,
99 	0x02B, 0x00000808,
100 	0x02B, 0x0006B333,
101 	0x02C, 0x0000000D,
102 	0x02A, 0x00000005,
103 	0x02B, 0x00000808,
104 	0x02B, 0x00073333,
105 	0x02C, 0x0000000D,
106 	0x02A, 0x00000006,
107 	0x02B, 0x00000709,
108 	0x02B, 0x0005B333,
109 	0x02C, 0x0000000D,
110 	0x02A, 0x00000007,
111 	0x02B, 0x00000709,
112 	0x02B, 0x00063333,
113 	0x02C, 0x0000000D,
114 	0x02A, 0x00000008,
115 	0x02B, 0x0000060A,
116 	0x02B, 0x0004B333,
117 	0x02C, 0x0000000D,
118 	0x02A, 0x00000009,
119 	0x02B, 0x0000060A,
120 	0x02B, 0x00053333,
121 	0x02C, 0x0000000D,
122 	0x02A, 0x0000000A,
123 	0x02B, 0x0000060A,
124 	0x02B, 0x0005B333,
125 	0x02C, 0x0000000D,
126 	0x02A, 0x0000000B,
127 	0x02B, 0x0000060A,
128 	0x02B, 0x00063333,
129 	0x02C, 0x0000000D,
130 	0x02A, 0x0000000C,
131 	0x02B, 0x0000060A,
132 	0x02B, 0x0006B333,
133 	0x02C, 0x0000000D,
134 	0x02A, 0x0000000D,
135 	0x02B, 0x0000060A,
136 	0x02B, 0x00073333,
137 	0x02C, 0x0000000D,
138 	0x02A, 0x0000000E,
139 	0x02B, 0x0000050B,
140 	0x02B, 0x00066666,
141 	0x02C, 0x0000001A,
142 	0x02A, 0x000E0000,
143 	0x010, 0x0004000F,
144 	0x011, 0x000E31FC,
145 	0x010, 0x0006000F,
146 	0x011, 0x000FF9F8,
147 	0x010, 0x0002000F,
148 	0x011, 0x000203F9,
149 	0x010, 0x0003000F,
150 	0x011, 0x000FF500,
151 	0x010, 0x00000000,
152 	0x011, 0x00000000,
153 	0x010, 0x0008000F,
154 	0x011, 0x0003F100,
155 	0x010, 0x0009000F,
156 	0x011, 0x00023100,
157 	0x012, 0x00032000,
158 	0x012, 0x00071000,
159 	0x012, 0x000B0000,
160 	0x012, 0x000FC000,
161 	0x013, 0x000287B3,
162 	0x013, 0x000244B7,
163 	0x013, 0x000204AB,
164 	0x013, 0x0001C49F,
165 	0x013, 0x00018493,
166 	0x013, 0x0001429B,
167 	0x013, 0x00010299,
168 	0x013, 0x0000C29C,
169 	0x013, 0x000081A0,
170 	0x013, 0x000040AC,
171 	0x013, 0x00000020,
172 	0x014, 0x0001944C,
173 	0x014, 0x00059444,
174 	0x014, 0x0009944C,
175 	0x014, 0x000D9444,
176 	0xFF0F011F, 0xABCD,
177 	0x015, 0x0000F424,
178 	0x015, 0x0004F424,
179 	0x015, 0x0008F424,
180 	0x015, 0x000CF424,
181 	0xCDCDCDCD, 0xCDCD,
182 	0x015, 0x0000F474,
183 	0x015, 0x0004F477,
184 	0x015, 0x0008F455,
185 	0x015, 0x000CF455,
186 	0xFF0F011F, 0xDEAD,
187 	0x016, 0x00000339,
188 	0x016, 0x00040339,
189 	0x016, 0x00080339,
190 	0xFF0F011F, 0xABCD,
191 	0x016, 0x000C0356,
192 	0xCDCDCDCD, 0xCDCD,
193 	0x016, 0x000C0366,
194 	0xFF0F011F, 0xDEAD,
195 	0x000, 0x00010159,
196 	0x018, 0x0000F401,
197 	0x0FE, 0x00000000,
198 	0x0FE, 0x00000000,
199 	0x01F, 0x00000003,
200 	0x0FE, 0x00000000,
201 	0x0FE, 0x00000000,
202 	0x01E, 0x00000247,
203 	0x01F, 0x00000000,
204 	0x000, 0x00030159,
205 };
206 
ODM_ReadAndConfig_RadioA_1T_8723A(struct dm_odm_t * pDM_Odm)207 void ODM_ReadAndConfig_RadioA_1T_8723A(struct dm_odm_t *pDM_Odm)
208 {
209 	#define READ_NEXT_PAIR(v1, v2, i)			\
210 		 do {						\
211 			 i += 2; v1 = Array[i]; v2 = Array[i+1];\
212 		 } while (0)
213 
214 	u32     hex         = 0;
215 	u32     i           = 0;
216 	u8     platform    = 0x04;
217 	u8     board       = pDM_Odm->BoardType;
218 	u32     ArrayLen    = sizeof(Array_RadioA_1T_8723A)/sizeof(u32);
219 	u32 *Array = Array_RadioA_1T_8723A;
220 
221 	hex += board;
222 	hex += ODM_ITRF_USB << 8;
223 	hex += platform << 16;
224 	hex += 0xFF000000;
225 
226 	for (i = 0; i < ArrayLen; i += 2) {
227 		u32 v1 = Array[i];
228 		u32 v2 = Array[i+1];
229 
230 		/*  This (offset, data) pair meets the condition. */
231 		if (v1 < 0xCDCDCDCD) {
232 			odm_ConfigRFReg_8723A(pDM_Odm, v1, v2, RF_PATH_A, v1);
233 			continue;
234 		} else {
235 			if (!CheckCondition(Array[i], hex)) {
236 				/*  Discard the following (offset, data) pairs. */
237 				READ_NEXT_PAIR(v1, v2, i);
238 				while (v2 != 0xDEAD &&
239 				       v2 != 0xCDEF &&
240 				       v2 != 0xCDCD && i < ArrayLen - 2)
241 					READ_NEXT_PAIR(v1, v2, i);
242 				i -= 2; /*  prevent from for-loop += 2 */
243 			} else {
244 				/*  Configure matched pairs and skip to end of if-else. */
245 				READ_NEXT_PAIR(v1, v2, i);
246 				while (v2 != 0xDEAD &&
247 				       v2 != 0xCDEF &&
248 				       v2 != 0xCDCD && i < ArrayLen - 2) {
249 					odm_ConfigRFReg_8723A(pDM_Odm, v1, v2,
250 							      RF_PATH_A, v1);
251 					READ_NEXT_PAIR(v1, v2, i);
252 				}
253 
254 				while (v2 != 0xDEAD && i < ArrayLen - 2)
255 					READ_NEXT_PAIR(v1, v2, i);
256 			}
257 		}
258 	}
259 }
260