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 "===> %s (cond1, cond2, cond3, cond4) = (0x%X 0x%X 0x%X 0x%X)\n",
64 __func__, cond1, cond2, cond3, cond4);
65 PHYDM_DBG(dm, ODM_COMP_INIT,
66 "===> %s (driver1, driver2, driver3, driver4) = (0x%X 0x%X 0x%X 0x%X)\n",
67 __func__, driver1, driver2, driver3, driver4);
68
69 PHYDM_DBG(dm, ODM_COMP_INIT,
70 " (Platform, Interface) = (0x%X, 0x%X)\n",
71 dm->support_platform, dm->support_interface);
72 PHYDM_DBG(dm, ODM_COMP_INIT,
73 " (Board, Package) = (0x%X, 0x%X)\n", dm->board_type,
74 dm->package_type);
75
76
77 /*============== value Defined Check ===============*/
78 /*QFN type [15:12] and cut version [27:24] need to do value check*/
79
80 if (((cond1 & 0x0000F000) != 0) && ((cond1 & 0x0000F000) != (driver1 & 0x0000F000)))
81 return false;
82 if (((cond1 & 0x0F000000) != 0) && ((cond1 & 0x0F000000) != (driver1 & 0x0F000000)))
83 return false;
84
85 /*=============== Bit Defined Check ================*/
86 /* We don't care [31:28] */
87
88 cond1 &= 0x00FF0FFF;
89 driver1 &= 0x00FF0FFF;
90
91 if ((cond1 & driver1) == cond1) {
92 u32 bit_mask = 0;
93
94 if ((cond1 & 0x0F) == 0) /* board_type is DONTCARE*/
95 return true;
96
97 if ((cond1 & BIT(0)) != 0) /*GLNA*/
98 bit_mask |= 0x000000FF;
99 if ((cond1 & BIT(1)) != 0) /*GPA*/
100 bit_mask |= 0x0000FF00;
101 if ((cond1 & BIT(2)) != 0) /*ALNA*/
102 bit_mask |= 0x00FF0000;
103 if ((cond1 & BIT(3)) != 0) /*APA*/
104 bit_mask |= 0xFF000000;
105
106 if (((cond2 & bit_mask) == (driver2 & bit_mask)) && ((cond4 & bit_mask) == (driver4 & bit_mask))) /* board_type of each RF path is matched*/
107 return true;
108 else
109 return false;
110 } else
111 return false;
112 }
113
114 /******************************************************************************
115 * mac_reg.TXT
116 ******************************************************************************/
117
118 u32 array_mp_8188f_mac_reg[] = {
119 0x024, 0x000000DF,
120 0x025, 0x00000007,
121 0x02B, 0x0000001C,
122 0x283, 0x00000020,
123 0x421, 0x0000000F,
124 0x428, 0x0000000A,
125 0x429, 0x00000010,
126 0x430, 0x00000000,
127 0x431, 0x00000000,
128 0x432, 0x00000000,
129 0x433, 0x00000001,
130 0x434, 0x00000002,
131 0x435, 0x00000003,
132 0x436, 0x00000005,
133 0x437, 0x00000007,
134 0x438, 0x00000000,
135 0x439, 0x00000000,
136 0x43A, 0x00000000,
137 0x43B, 0x00000001,
138 0x43C, 0x00000002,
139 0x43D, 0x00000003,
140 0x43E, 0x00000005,
141 0x43F, 0x00000007,
142 0x440, 0x0000005D,
143 0x441, 0x00000001,
144 0x442, 0x00000000,
145 0x444, 0x00000010,
146 0x445, 0x00000000,
147 0x446, 0x00000000,
148 0x447, 0x00000000,
149 0x448, 0x00000000,
150 0x449, 0x000000F0,
151 0x44A, 0x0000000F,
152 0x44B, 0x0000003E,
153 0x44C, 0x00000010,
154 0x44D, 0x00000000,
155 0x44E, 0x00000000,
156 0x44F, 0x00000000,
157 0x450, 0x00000000,
158 0x451, 0x000000F0,
159 0x452, 0x0000000F,
160 0x453, 0x00000000,
161 0x456, 0x0000005E,
162 0x460, 0x00000044,
163 0x461, 0x00000044,
164 0x4BC, 0x000000C0,
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, 0x00000028,
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, 0x00000028,
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
225 };
226
227 void
odm_read_and_config_mp_8188f_mac_reg(struct dm_struct * dm)228 odm_read_and_config_mp_8188f_mac_reg(struct dm_struct *dm)
229 {
230 u32 i = 0;
231 u8 c_cond;
232 boolean is_matched = true, is_skipped = false;
233 u32 array_len = sizeof(array_mp_8188f_mac_reg) / sizeof(u32);
234 u32 *array = array_mp_8188f_mac_reg;
235
236 u32 v1 = 0, v2 = 0, pre_v1 = 0, pre_v2 = 0;
237
238 PHYDM_DBG(dm, ODM_COMP_INIT, "===> %s\n", __func__);
239
240 while ((i + 1) < array_len) {
241 v1 = array[i];
242 v2 = array[i + 1];
243
244 if (v1 & (BIT(31) | BIT(30))) {/*positive & negative condition*/
245 if (v1 & BIT(31)) {/* positive condition*/
246 c_cond = (u8)((v1 & (BIT(29) | BIT(28))) >> 28);
247 if (c_cond == COND_ENDIF) {/*end*/
248 is_matched = true;
249 is_skipped = false;
250 PHYDM_DBG(dm, ODM_COMP_INIT, "ENDIF\n");
251 } else if (c_cond == COND_ELSE) { /*else*/
252 is_matched = is_skipped ? false : true;
253 PHYDM_DBG(dm, ODM_COMP_INIT, "ELSE\n");
254 } else {/*if , else if*/
255 pre_v1 = v1;
256 pre_v2 = v2;
257 PHYDM_DBG(dm, ODM_COMP_INIT, "IF or ELSE IF\n");
258 }
259 } else if (v1 & BIT(30)) { /*negative condition*/
260 if (is_skipped == false) {
261 if (check_positive(dm, pre_v1, pre_v2, v1, v2)) {
262 is_matched = true;
263 is_skipped = true;
264 } else {
265 is_matched = false;
266 is_skipped = false;
267 }
268 } else
269 is_matched = false;
270 }
271 } else {
272 if (is_matched)
273 odm_config_mac_8188f(dm, v1, (u8)v2);
274 }
275 i = i + 2;
276 }
277 }
278
279 u32
odm_get_version_mp_8188f_mac_reg(void)280 odm_get_version_mp_8188f_mac_reg(void)
281 {
282 return 39;
283 }
284
285 #endif /* end of HWIMG_SUPPORT*/
286
287