1 /******************************************************************************
2 *
3 * Copyright(c) 2007 - 2017 Realtek Corporation.
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 /*Image2HeaderVersion: 3.5.2*/
17 #include "mp_precomp.h"
18 #include "../phydm_precomp.h"
19
20 #if (RTL8188F_SUPPORT == 1)
21 static boolean
check_positive(struct dm_struct * dm,const u32 condition1,const u32 condition2,const u32 condition3,const u32 condition4)22 check_positive(
23 struct dm_struct *dm,
24 const u32 condition1,
25 const u32 condition2,
26 const u32 condition3,
27 const u32 condition4
28 )
29 {
30 u8 _board_type = ((dm->board_type & BIT(4)) >> 4) << 0 | /* _GLNA*/
31 ((dm->board_type & BIT(3)) >> 3) << 1 | /* _GPA*/
32 ((dm->board_type & BIT(7)) >> 7) << 2 | /* _ALNA*/
33 ((dm->board_type & BIT(6)) >> 6) << 3 | /* _APA */
34 ((dm->board_type & BIT(2)) >> 2) << 4 | /* _BT*/
35 ((dm->board_type & BIT(1)) >> 1) << 5 | /* _NGFF*/
36 ((dm->board_type & BIT(5)) >> 5) << 6; /* _TRSWT*/
37
38 u32 cond1 = condition1, cond2 = condition2, cond3 = condition3, cond4 = condition4;
39
40 u8 cut_version_for_para = (dm->cut_version == ODM_CUT_A) ? 15 : dm->cut_version;
41 u8 pkg_type_for_para = (dm->package_type == 0) ? 15 : dm->package_type;
42
43 u32 driver1 = cut_version_for_para << 24 |
44 (dm->support_interface & 0xF0) << 16 |
45 dm->support_platform << 16 |
46 pkg_type_for_para << 12 |
47 (dm->support_interface & 0x0F) << 8 |
48 _board_type;
49
50 u32 driver2 = (dm->type_glna & 0xFF) << 0 |
51 (dm->type_gpa & 0xFF) << 8 |
52 (dm->type_alna & 0xFF) << 16 |
53 (dm->type_apa & 0xFF) << 24;
54
55 u32 driver3 = 0;
56
57 u32 driver4 = (dm->type_glna & 0xFF00) >> 8 |
58 (dm->type_gpa & 0xFF00) |
59 (dm->type_alna & 0xFF00) << 8 |
60 (dm->type_apa & 0xFF00) << 16;
61
62 PHYDM_DBG(dm, ODM_COMP_INIT,
63 "===> check_positive (cond1, cond2, cond3, cond4) = (0x%X 0x%X 0x%X 0x%X)\n", cond1, cond2, cond3, cond4);
64 PHYDM_DBG(dm, ODM_COMP_INIT,
65 "===> check_positive (driver1, driver2, driver3, driver4) = (0x%X 0x%X 0x%X 0x%X)\n", driver1, driver2, driver3, driver4);
66
67 PHYDM_DBG(dm, ODM_COMP_INIT,
68 " (Platform, Interface) = (0x%X, 0x%X)\n", dm->support_platform, dm->support_interface);
69 PHYDM_DBG(dm, ODM_COMP_INIT,
70 " (Board, Package) = (0x%X, 0x%X)\n", dm->board_type, dm->package_type);
71
72
73 /*============== value Defined Check ===============*/
74 /*QFN type [15:12] and cut version [27:24] need to do value check*/
75
76 if (((cond1 & 0x0000F000) != 0) && ((cond1 & 0x0000F000) != (driver1 & 0x0000F000)))
77 return false;
78 if (((cond1 & 0x0F000000) != 0) && ((cond1 & 0x0F000000) != (driver1 & 0x0F000000)))
79 return false;
80
81 /*=============== Bit Defined Check ================*/
82 /* We don't care [31:28] */
83
84 cond1 &= 0x00FF0FFF;
85 driver1 &= 0x00FF0FFF;
86
87 if ((cond1 & driver1) == cond1) {
88 u32 bit_mask = 0;
89
90 if ((cond1 & 0x0F) == 0) /* board_type is DONTCARE*/
91 return true;
92
93 if ((cond1 & BIT(0)) != 0) /*GLNA*/
94 bit_mask |= 0x000000FF;
95 if ((cond1 & BIT(1)) != 0) /*GPA*/
96 bit_mask |= 0x0000FF00;
97 if ((cond1 & BIT(2)) != 0) /*ALNA*/
98 bit_mask |= 0x00FF0000;
99 if ((cond1 & BIT(3)) != 0) /*APA*/
100 bit_mask |= 0xFF000000;
101
102 if (((cond2 & bit_mask) == (driver2 & bit_mask)) && ((cond4 & bit_mask) == (driver4 & bit_mask))) /* board_type of each RF path is matched*/
103 return true;
104 else
105 return false;
106 } else
107 return false;
108 }
109
110 /******************************************************************************
111 * mac_reg.TXT
112 ******************************************************************************/
113
114 u32 array_mp_8188f_mac_reg[] = {
115 0x024, 0x000000DF,
116 0x025, 0x00000007,
117 0x02B, 0x0000001C,
118 0x283, 0x00000020,
119 0x421, 0x0000000F,
120 0x428, 0x0000000A,
121 0x429, 0x00000010,
122 0x430, 0x00000000,
123 0x431, 0x00000000,
124 0x432, 0x00000000,
125 0x433, 0x00000001,
126 0x434, 0x00000002,
127 0x435, 0x00000003,
128 0x436, 0x00000005,
129 0x437, 0x00000007,
130 0x438, 0x00000000,
131 0x439, 0x00000000,
132 0x43A, 0x00000000,
133 0x43B, 0x00000001,
134 0x43C, 0x00000002,
135 0x43D, 0x00000003,
136 0x43E, 0x00000005,
137 0x43F, 0x00000007,
138 0x440, 0x0000005D,
139 0x441, 0x00000001,
140 0x442, 0x00000000,
141 0x444, 0x00000010,
142 0x445, 0x00000000,
143 0x446, 0x00000000,
144 0x447, 0x00000000,
145 0x448, 0x00000000,
146 0x449, 0x000000F0,
147 0x44A, 0x0000000F,
148 0x44B, 0x0000003E,
149 0x44C, 0x00000010,
150 0x44D, 0x00000000,
151 0x44E, 0x00000000,
152 0x44F, 0x00000000,
153 0x450, 0x00000000,
154 0x451, 0x000000F0,
155 0x452, 0x0000000F,
156 0x453, 0x00000000,
157 0x456, 0x0000005E,
158 0x460, 0x00000044,
159 0x461, 0x00000044,
160 0x4BC, 0x000000C0,
161 0x4C8, 0x000000FF,
162 0x4C9, 0x00000008,
163 0x4CC, 0x000000FF,
164 0x4CD, 0x000000FF,
165 0x4CE, 0x00000001,
166 0x500, 0x00000026,
167 0x501, 0x000000A2,
168 0x502, 0x0000002F,
169 0x503, 0x00000000,
170 0x504, 0x00000028,
171 0x505, 0x000000A3,
172 0x506, 0x0000005E,
173 0x507, 0x00000000,
174 0x508, 0x0000002B,
175 0x509, 0x000000A4,
176 0x50A, 0x0000005E,
177 0x50B, 0x00000000,
178 0x50C, 0x0000004F,
179 0x50D, 0x000000A4,
180 0x50E, 0x00000000,
181 0x50F, 0x00000000,
182 0x512, 0x0000001C,
183 0x514, 0x0000000A,
184 0x515, 0x0000000E,
185 0x516, 0x0000000A,
186 0x517, 0x0000000E,
187 0x525, 0x0000004F,
188 0x550, 0x00000010,
189 0x551, 0x00000010,
190 0x559, 0x00000002,
191 0x55C, 0x00000028,
192 0x55D, 0x000000FF,
193 0x605, 0x00000030,
194 0x608, 0x0000000E,
195 0x609, 0x0000002A,
196 0x620, 0x000000FF,
197 0x621, 0x000000FF,
198 0x622, 0x000000FF,
199 0x623, 0x000000FF,
200 0x624, 0x000000FF,
201 0x625, 0x000000FF,
202 0x626, 0x000000FF,
203 0x627, 0x000000FF,
204 0x638, 0x00000028,
205 0x63C, 0x0000000A,
206 0x63D, 0x0000000A,
207 0x63E, 0x0000000E,
208 0x63F, 0x0000000E,
209 0x640, 0x00000040,
210 0x642, 0x00000040,
211 0x643, 0x00000000,
212 0x652, 0x000000C8,
213 0x66A, 0x00000020,
214 0x66E, 0x00000005,
215 0x700, 0x00000021,
216 0x701, 0x00000043,
217 0x702, 0x00000065,
218 0x703, 0x00000087,
219 0x708, 0x00000021,
220 0x709, 0x00000043,
221 0x70A, 0x00000065,
222 0x70B, 0x00000087,
223
224 };
225
226 void
odm_read_and_config_mp_8188f_mac_reg(struct dm_struct * dm)227 odm_read_and_config_mp_8188f_mac_reg(
228 struct dm_struct *dm
229 )
230 {
231 u32 i = 0;
232 u8 c_cond;
233 boolean is_matched = true, is_skipped = false;
234 u32 array_len = sizeof(array_mp_8188f_mac_reg)/sizeof(u32);
235 u32 *array = array_mp_8188f_mac_reg;
236
237 u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0;
238
239 PHYDM_DBG(dm, ODM_COMP_INIT, "===> odm_read_and_config_mp_8188f_mac_reg\n");
240
241 while ((i + 1) < array_len) {
242 v1 = array[i];
243 v2 = array[i + 1];
244
245 if (v1 & (BIT(31) | BIT(30))) {/*positive & negative condition*/
246 if (v1 & BIT(31)) {/* positive condition*/
247 c_cond = (u8)((v1 & (BIT(29)|BIT(28))) >> 28);
248 if (c_cond == COND_ENDIF) {/*end*/
249 is_matched = true;
250 is_skipped = false;
251 PHYDM_DBG(dm, ODM_COMP_INIT, "ENDIF\n");
252 } else if (c_cond == COND_ELSE) { /*else*/
253 is_matched = is_skipped?false:true;
254 PHYDM_DBG(dm, ODM_COMP_INIT, "ELSE\n");
255 } else {/*if , else if*/
256 pre_v1 = v1;
257 pre_v2 = v2;
258 PHYDM_DBG(dm, ODM_COMP_INIT, "IF or ELSE IF\n");
259 }
260 } else if (v1 & BIT(30)) { /*negative condition*/
261 if (is_skipped == false) {
262 if (check_positive(dm, pre_v1, pre_v2, v1, v2)) {
263 is_matched = true;
264 is_skipped = true;
265 } else {
266 is_matched = false;
267 is_skipped = false;
268 }
269 } else
270 is_matched = false;
271 }
272 } else {
273 if (is_matched)
274 odm_config_mac_8188f(dm, v1, (u8)v2);
275 }
276 i = i + 2;
277 }
278 }
279
280 u32
odm_get_version_mp_8188f_mac_reg(void)281 odm_get_version_mp_8188f_mac_reg(void)
282 {
283 return 45;
284 }
285
286 #endif /* end of HWIMG_SUPPORT*/
287
288