OSDN Git Service

Add rtl8821ce driver version 5.5.2
[android-x86/external-kernel-drivers.git] / rtl8821ce / hal / phydm / phydm_hwconfig.c
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  * The full GNU General Public License is included in this distribution in the
15  * file called LICENSE.
16  *
17  * Contact Information:
18  * wlanfae <wlanfae@realtek.com>
19  * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20  * Hsinchu 300, Taiwan.
21  *
22  * Larry Finger <Larry.Finger@lwfinger.net>
23  *
24  *****************************************************************************/
25
26 /*@************************************************************
27  * include files
28  ************************************************************/
29
30 #include "mp_precomp.h"
31 #include "phydm_precomp.h"
32
33 #define READ_AND_CONFIG_MP(ic, txt) (odm_read_and_config_mp_##ic##txt(dm))
34 #define READ_AND_CONFIG_TC(ic, txt) (odm_read_and_config_tc_##ic##txt(dm))
35
36 #if (PHYDM_TESTCHIP_SUPPORT == 1)
37 #define READ_AND_CONFIG(ic, txt)                     \
38         do {                                         \
39                 if (dm->is_mp_chip)                  \
40                         READ_AND_CONFIG_MP(ic, txt); \
41                 else                                 \
42                         READ_AND_CONFIG_TC(ic, txt); \
43         } while (0)
44 #else
45 #define READ_AND_CONFIG READ_AND_CONFIG_MP
46 #endif
47
48 #define GET_VERSION_MP(ic, txt) (odm_get_version_mp_##ic##txt())
49 #define GET_VERSION_TC(ic, txt) (odm_get_version_tc_##ic##txt())
50
51 #if (PHYDM_TESTCHIP_SUPPORT == 1)
52 #define GET_VERSION(ic, txt) (dm->is_mp_chip ? GET_VERSION_MP(ic, txt) : GET_VERSION_TC(ic, txt))
53 #else
54 #define GET_VERSION(ic, txt) GET_VERSION_MP(ic, txt)
55 #endif
56
57 enum hal_status
58 odm_config_rf_with_header_file(struct dm_struct *dm,
59                                enum odm_rf_config_type config_type,
60                                u8 e_rf_path)
61 {
62 #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
63         void *adapter = dm->adapter;
64         PMGNT_INFO mgnt_info = &((PADAPTER)adapter)->MgntInfo;
65 #endif
66         enum hal_status result = HAL_STATUS_SUCCESS;
67
68         PHYDM_DBG(dm, ODM_COMP_INIT, "===>%s (%s)\n", __func__,
69                   (dm->is_mp_chip) ? "MPChip" : "TestChip");
70         PHYDM_DBG(dm, ODM_COMP_INIT,
71                   "support_platform: 0x%X, support_interface: 0x%X, board_type: 0x%X\n",
72                   dm->support_platform, dm->support_interface, dm->board_type);
73
74 /* @1 AP doesn't use PHYDM power tracking table in these ICs */
75 #if (DM_ODM_SUPPORT_TYPE != ODM_AP)
76 #if (RTL8812A_SUPPORT == 1)
77         if (dm->support_ic_type == ODM_RTL8812) {
78                 if (config_type == CONFIG_RF_RADIO) {
79                         if (e_rf_path == RF_PATH_A)
80                                 READ_AND_CONFIG_MP(8812a, _radioa);
81                         else if (e_rf_path == RF_PATH_B)
82                                 READ_AND_CONFIG_MP(8812a, _radiob);
83                 } else if (config_type == CONFIG_RF_TXPWR_LMT) {
84 #if (DM_ODM_SUPPORT_TYPE & ODM_WIN) && (DEV_BUS_TYPE == RT_PCI_INTERFACE)
85                         HAL_DATA_TYPE * hal_data = GET_HAL_DATA(((PADAPTER)adapter));
86                         if ((hal_data->EEPROMSVID == 0x17AA && hal_data->EEPROMSMID == 0xA811) ||
87                             (hal_data->EEPROMSVID == 0x10EC && hal_data->EEPROMSMID == 0xA812) ||
88                             (hal_data->EEPROMSVID == 0x10EC && hal_data->EEPROMSMID == 0x8812))
89                                 READ_AND_CONFIG_MP(8812a, _txpwr_lmt_hm812a03);
90                         else
91 #endif
92                                 READ_AND_CONFIG_MP(8812a, _txpwr_lmt);
93                 }
94         }
95 #endif
96 #if (RTL8821A_SUPPORT == 1)
97         if (dm->support_ic_type == ODM_RTL8821) {
98                 if (config_type == CONFIG_RF_RADIO) {
99                         if (e_rf_path == RF_PATH_A)
100                                 READ_AND_CONFIG_MP(8821a, _radioa);
101                 } else if (config_type == CONFIG_RF_TXPWR_LMT) {
102                         if (dm->support_interface == ODM_ITRF_USB) {
103                                 if (dm->ext_pa_5g || dm->ext_lna_5g)
104                                         READ_AND_CONFIG_MP(8821a, _txpwr_lmt_8811a_u_fem);
105                                 else
106                                         READ_AND_CONFIG_MP(8821a, _txpwr_lmt_8811a_u_ipa);
107                         } else {
108 #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
109                                 if (mgnt_info->CustomerID == RT_CID_8821AE_ASUS_MB)
110                                         READ_AND_CONFIG_MP(8821a, _txpwr_lmt_8821a_sar_8mm);
111                                 else if (mgnt_info->CustomerID == RT_CID_ASUS_NB)
112                                         READ_AND_CONFIG_MP(8821a, _txpwr_lmt_8821a_sar_5mm);
113                                 else
114 #endif
115                                         READ_AND_CONFIG_MP(8821a, _txpwr_lmt_8821a);
116                         }
117                 }
118         }
119 #endif
120 #if (RTL8192E_SUPPORT == 1)
121         if (dm->support_ic_type == ODM_RTL8192E) {
122                 if (config_type == CONFIG_RF_RADIO) {
123                         if (e_rf_path == RF_PATH_A)
124                                 READ_AND_CONFIG_MP(8192e, _radioa);
125                         else if (e_rf_path == RF_PATH_B)
126                                 READ_AND_CONFIG_MP(8192e, _radiob);
127                 } else if (config_type == CONFIG_RF_TXPWR_LMT) {
128 #if (DM_ODM_SUPPORT_TYPE & ODM_WIN) && (DEV_BUS_TYPE == RT_PCI_INTERFACE) /*Refine by Vincent Lan for 5mm SAR pwr limit*/
129                         HAL_DATA_TYPE * hal_data = GET_HAL_DATA(((PADAPTER)adapter));
130
131                         if ((hal_data->EEPROMSVID == 0x11AD && hal_data->EEPROMSMID == 0x8192) ||
132                             (hal_data->EEPROMSVID == 0x11AD && hal_data->EEPROMSMID == 0x8193))
133                                 READ_AND_CONFIG_MP(8192e, _txpwr_lmt_8192e_sar_5mm);
134                         else
135 #endif
136                                 READ_AND_CONFIG_MP(8192e, _txpwr_lmt);
137                 }
138         }
139 #endif
140 #if (RTL8723D_SUPPORT == 1)
141         if (dm->support_ic_type == ODM_RTL8723D) {
142                 if (config_type == CONFIG_RF_RADIO) {
143                         if (e_rf_path == RF_PATH_A)
144                                 READ_AND_CONFIG_MP(8723d, _radioa);
145                 } else if (config_type == CONFIG_RF_TXPWR_LMT) {
146                         READ_AND_CONFIG_MP(8723d, _txpwr_lmt);
147                 }
148         }
149 #endif
150 /* @JJ ADD 20161014 */
151 #if (RTL8710B_SUPPORT == 1)
152         if (dm->support_ic_type == ODM_RTL8710B) {
153                 if (config_type == CONFIG_RF_RADIO) {
154                         if (e_rf_path == RF_PATH_A)
155                                 READ_AND_CONFIG_MP(8710b, _radioa);
156                 } else if (config_type == CONFIG_RF_TXPWR_LMT)
157                         READ_AND_CONFIG_MP(8710b, _txpwr_lmt);
158         }
159 #endif
160
161 #endif /* @(DM_ODM_SUPPORT_TYPE !=  ODM_AP) */
162 /* @1 All platforms support */
163 #if (RTL8188E_SUPPORT == 1)
164         if (dm->support_ic_type == ODM_RTL8188E) {
165                 if (config_type == CONFIG_RF_RADIO) {
166                         if (e_rf_path == RF_PATH_A)
167                                 READ_AND_CONFIG_MP(8188e, _radioa);
168                 } else if (config_type == CONFIG_RF_TXPWR_LMT)
169                         READ_AND_CONFIG_MP(8188e, _txpwr_lmt);
170         }
171 #endif
172 #if (RTL8723B_SUPPORT == 1)
173         if (dm->support_ic_type == ODM_RTL8723B) {
174                 if (config_type == CONFIG_RF_RADIO)
175                         READ_AND_CONFIG_MP(8723b, _radioa);
176                 else if (config_type == CONFIG_RF_TXPWR_LMT)
177                         READ_AND_CONFIG_MP(8723b, _txpwr_lmt);
178         }
179 #endif
180 #if (RTL8814A_SUPPORT == 1)
181         if (dm->support_ic_type == ODM_RTL8814A) {
182                 if (config_type == CONFIG_RF_RADIO) {
183                         if (e_rf_path == RF_PATH_A)
184                                 READ_AND_CONFIG_MP(8814a, _radioa);
185                         else if (e_rf_path == RF_PATH_B)
186                                 READ_AND_CONFIG_MP(8814a, _radiob);
187                         else if (e_rf_path == RF_PATH_C)
188                                 READ_AND_CONFIG_MP(8814a, _radioc);
189                         else if (e_rf_path == RF_PATH_D)
190                                 READ_AND_CONFIG_MP(8814a, _radiod);
191                 } else if (config_type == CONFIG_RF_TXPWR_LMT) {
192                         if (dm->rfe_type == 0)
193                                 READ_AND_CONFIG_MP(8814a, _txpwr_lmt_type0);
194                         else if (dm->rfe_type == 1)
195                                 READ_AND_CONFIG_MP(8814a, _txpwr_lmt_type1);
196                         else if (dm->rfe_type == 2)
197                                 READ_AND_CONFIG_MP(8814a, _txpwr_lmt_type2);
198                         else if (dm->rfe_type == 3)
199                                 READ_AND_CONFIG_MP(8814a, _txpwr_lmt_type3);
200                         else if (dm->rfe_type == 5)
201                                 READ_AND_CONFIG_MP(8814a, _txpwr_lmt_type5);
202                         else if (dm->rfe_type == 7)
203                                 READ_AND_CONFIG_MP(8814a, _txpwr_lmt_type7);
204                         else if (dm->rfe_type == 8)
205                                 READ_AND_CONFIG_MP(8814a, _txpwr_lmt_type8);
206                         else
207                                 READ_AND_CONFIG_MP(8814a, _txpwr_lmt);
208                 }
209         }
210 #endif
211 #if (RTL8703B_SUPPORT == 1)
212         if (dm->support_ic_type == ODM_RTL8703B) {
213                 if (config_type == CONFIG_RF_RADIO) {
214                         if (e_rf_path == RF_PATH_A)
215                                 READ_AND_CONFIG_MP(8703b, _radioa);
216                 }
217         }
218 #endif
219 #if (RTL8188F_SUPPORT == 1)
220         if (dm->support_ic_type == ODM_RTL8188F) {
221                 if (config_type == CONFIG_RF_RADIO) {
222                         if (e_rf_path == RF_PATH_A)
223                                 READ_AND_CONFIG_MP(8188f, _radioa);
224                 } else if (config_type == CONFIG_RF_TXPWR_LMT)
225                         READ_AND_CONFIG_MP(8188f, _txpwr_lmt);
226         }
227 #endif
228 #if (RTL8822B_SUPPORT == 1)
229         if (dm->support_ic_type == ODM_RTL8822B) {
230                 if (config_type == CONFIG_RF_RADIO) {
231                         if (e_rf_path == RF_PATH_A)
232                                 READ_AND_CONFIG_MP(8822b, _radioa);
233                         else if (e_rf_path == RF_PATH_B)
234                                 READ_AND_CONFIG_MP(8822b, _radiob);
235                 } else if (config_type == CONFIG_RF_TXPWR_LMT) {
236                         if (dm->rfe_type == 5)
237                                 READ_AND_CONFIG_MP(8822b, _txpwr_lmt_type5);
238                         else if (dm->rfe_type == 2)
239                                 READ_AND_CONFIG_MP(8822b, _txpwr_lmt_type2);
240                         else if (dm->rfe_type == 3)
241                                 READ_AND_CONFIG_MP(8822b, _txpwr_lmt_type3);
242                         else if (dm->rfe_type == 4)
243                                 READ_AND_CONFIG_MP(8822b, _txpwr_lmt_type4);
244                         else if (dm->rfe_type == 12)
245                                 READ_AND_CONFIG_MP(8822b, _txpwr_lmt_type12);
246                         else if (dm->rfe_type == 15)
247                                 READ_AND_CONFIG_MP(8822b, _txpwr_lmt_type15);
248                         else if (dm->rfe_type == 16)
249                                 READ_AND_CONFIG_MP(8822b, _txpwr_lmt_type16);
250                         else if (dm->rfe_type == 17)
251                                 READ_AND_CONFIG_MP(8822b, _txpwr_lmt_type17);
252                         else if (dm->rfe_type == 18)
253                                 READ_AND_CONFIG_MP(8822b, _txpwr_lmt_type18);
254                         else
255                                 READ_AND_CONFIG_MP(8822b, _txpwr_lmt);
256                 }
257         }
258 #endif
259
260 #if (RTL8197F_SUPPORT == 1)
261         if (dm->support_ic_type == ODM_RTL8197F) {
262                 if (config_type == CONFIG_RF_RADIO) {
263                         if (e_rf_path == RF_PATH_A)
264                                 READ_AND_CONFIG_MP(8197f, _radioa);
265                         else if (e_rf_path == RF_PATH_B)
266                                 READ_AND_CONFIG_MP(8197f, _radiob);
267                 }
268         }
269 #endif
270 /*@jj add 20170822*/
271 #if (RTL8192F_SUPPORT == 1)
272         if (dm->support_ic_type == ODM_RTL8192F) {
273                 if (config_type == CONFIG_RF_RADIO) {
274                         if (e_rf_path == RF_PATH_A)
275                                 READ_AND_CONFIG_MP(8192f, _radioa);
276                         else if (e_rf_path == RF_PATH_B)
277                                 READ_AND_CONFIG_MP(8192f, _radiob);
278                 } else if (config_type == CONFIG_RF_TXPWR_LMT) {
279                         if (dm->rfe_type == 0)
280                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type0);
281                         else if (dm->rfe_type == 1)
282                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type1);
283                         else if (dm->rfe_type == 2)
284                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type2);
285                         else if (dm->rfe_type == 3)
286                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type3);
287                         else if (dm->rfe_type == 4)
288                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type4);
289                         else if (dm->rfe_type == 5)
290                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type5);
291                         else if (dm->rfe_type == 6)
292                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type6);
293                         else if (dm->rfe_type == 7)
294                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type7);
295                         else if (dm->rfe_type == 8)
296                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type8);
297                         else if (dm->rfe_type == 9)
298                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type9);
299                         else if (dm->rfe_type == 10)
300                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type10);
301                         else if (dm->rfe_type == 11)
302                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type11);
303                         else if (dm->rfe_type == 12)
304                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type12);
305                         else if (dm->rfe_type == 13)
306                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type13);
307                         else if (dm->rfe_type == 14)
308                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type14);
309                         else if (dm->rfe_type == 15)
310                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type15);
311                         else if (dm->rfe_type == 16)
312                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type16);
313                         else if (dm->rfe_type == 17)
314                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type17);
315                         else if (dm->rfe_type == 18)
316                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type18);
317                         else if (dm->rfe_type == 19)
318                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type19);
319                         else if (dm->rfe_type == 20)
320                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type20);
321                         else if (dm->rfe_type == 21)
322                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type21);
323                         else if (dm->rfe_type == 22)
324                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type22);
325                         else if (dm->rfe_type == 23)
326                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type23);
327                         else if (dm->rfe_type == 24)
328                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type24);
329                         else if (dm->rfe_type == 25)
330                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type25);
331                         else if (dm->rfe_type == 26)
332                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type26);
333                         else if (dm->rfe_type == 27)
334                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type27);
335                         else if (dm->rfe_type == 28)
336                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type28);
337                         else if (dm->rfe_type == 29)
338                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type29);
339                         else if (dm->rfe_type == 30)
340                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type30);
341                         else if (dm->rfe_type == 31)
342                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt_type31);
343                         else
344                                 READ_AND_CONFIG_MP(8192f, _txpwr_lmt);
345                 }
346         }
347 #endif
348 #if (RTL8821C_SUPPORT == 1)
349         if (dm->support_ic_type == ODM_RTL8821C) {
350                 if (config_type == CONFIG_RF_RADIO) {
351                         if (e_rf_path == RF_PATH_A)
352                                 READ_AND_CONFIG(8821c, _radioa);
353                 } else if (config_type == CONFIG_RF_TXPWR_LMT) {
354                         READ_AND_CONFIG(8821c, _txpwr_lmt);
355                 }
356         }
357 #endif
358 #if (RTL8195B_SUPPORT == 1)
359         if (dm->support_ic_type == ODM_RTL8195B) {
360                 if (config_type == CONFIG_RF_RADIO) {
361                         if (e_rf_path == RF_PATH_A)
362                                 READ_AND_CONFIG(8195b, _radioa);
363                 }
364                 #if 0
365                 else if (config_type == CONFIG_RF_TXPWR_LMT) {
366                         READ_AND_CONFIG(8821c, _txpwr_lmt);
367                         /*@*/
368                 }
369                 #endif
370         }
371 #endif
372 #if (RTL8198F_SUPPORT == 1)
373         if (dm->support_ic_type == ODM_RTL8198F) {
374                 if (config_type == CONFIG_RF_RADIO) {
375                         if (e_rf_path == RF_PATH_A)
376                                 READ_AND_CONFIG_MP(8198f, _radioa);
377                         else if (e_rf_path == RF_PATH_B)
378                                 READ_AND_CONFIG_MP(8198f, _radiob);
379                         else if (e_rf_path == RF_PATH_C)
380                                 READ_AND_CONFIG_MP(8198f, _radioc);
381                         else if (e_rf_path == RF_PATH_D)
382                                 READ_AND_CONFIG_MP(8198f, _radiod);
383                 }
384         }
385 #endif
386
387         if (config_type == CONFIG_RF_RADIO) {
388                 if (dm->fw_offload_ability & PHYDM_PHY_PARAM_OFFLOAD) {
389                         result = phydm_set_reg_by_fw(dm,
390                                                      PHYDM_HALMAC_CMD_END,
391                                                      0,
392                                                      0,
393                                                      0,
394                                                      (enum rf_path)0,
395                                                      0);
396                         PHYDM_DBG(dm, ODM_COMP_INIT,
397                                   "rf param offload end!result = %d", result);
398                 }
399         }
400
401         return result;
402 }
403
404 enum hal_status
405 odm_config_rf_with_tx_pwr_track_header_file(struct dm_struct *dm)
406 {
407         PHYDM_DBG(dm, ODM_COMP_INIT, "===>%s (%s)\n", __func__,
408                   (dm->is_mp_chip) ? "MPChip" : "TestChip");
409         PHYDM_DBG(dm, ODM_COMP_INIT,
410                   "support_platform: 0x%X, support_interface: 0x%X, board_type: 0x%X\n",
411                   dm->support_platform, dm->support_interface, dm->board_type);
412
413 /* @1 AP doesn't use PHYDM power tracking table in these ICs */
414 #if (DM_ODM_SUPPORT_TYPE != ODM_AP)
415 #if RTL8821A_SUPPORT
416         if (dm->support_ic_type == ODM_RTL8821) {
417                 if (dm->support_interface == ODM_ITRF_PCIE)
418                         READ_AND_CONFIG_MP(8821a, _txpowertrack_pcie);
419                 else if (dm->support_interface == ODM_ITRF_USB)
420                         READ_AND_CONFIG_MP(8821a, _txpowertrack_usb);
421                 else if (dm->support_interface == ODM_ITRF_SDIO)
422                         READ_AND_CONFIG_MP(8821a, _txpowertrack_sdio);
423         }
424 #endif
425 #if RTL8812A_SUPPORT
426         if (dm->support_ic_type == ODM_RTL8812) {
427                 if (dm->support_interface == ODM_ITRF_PCIE)
428                         READ_AND_CONFIG_MP(8812a, _txpowertrack_pcie);
429                 else if (dm->support_interface == ODM_ITRF_USB) {
430                         if (dm->rfe_type == 3 && dm->is_mp_chip)
431                                 READ_AND_CONFIG_MP(8812a, _txpowertrack_rfe3);
432                         else
433                                 READ_AND_CONFIG_MP(8812a, _txpowertrack_usb);
434                 }
435         }
436 #endif
437 #if RTL8192E_SUPPORT
438         if (dm->support_ic_type == ODM_RTL8192E) {
439                 if (dm->support_interface == ODM_ITRF_PCIE)
440                         READ_AND_CONFIG_MP(8192e, _txpowertrack_pcie);
441                 else if (dm->support_interface == ODM_ITRF_USB)
442                         READ_AND_CONFIG_MP(8192e, _txpowertrack_usb);
443                 else if (dm->support_interface == ODM_ITRF_SDIO)
444                         READ_AND_CONFIG_MP(8192e, _txpowertrack_sdio);
445         }
446 #endif
447 #if RTL8723D_SUPPORT
448         if (dm->support_ic_type == ODM_RTL8723D) {
449                 if (dm->support_interface == ODM_ITRF_PCIE)
450                         READ_AND_CONFIG_MP(8723d, _txpowertrack_pcie);
451                 else if (dm->support_interface == ODM_ITRF_USB)
452                         READ_AND_CONFIG_MP(8723d, _txpowertrack_usb);
453                 else if (dm->support_interface == ODM_ITRF_SDIO)
454                         READ_AND_CONFIG_MP(8723d, _txpowertrack_sdio);
455
456                 READ_AND_CONFIG_MP(8723d, _txxtaltrack);
457         }
458 #endif
459 /* @JJ ADD 20161014 */
460 #if RTL8710B_SUPPORT
461         if (dm->support_ic_type == ODM_RTL8710B) {
462                 if (dm->package_type == 1)
463                         READ_AND_CONFIG_MP(8710b, _txpowertrack_qfn48m_smic);
464                 else if (dm->package_type == 5)
465                         READ_AND_CONFIG_MP(8710b, _txpowertrack_qfn48m_umc);
466
467                 READ_AND_CONFIG_MP(8710b, _txxtaltrack);
468         }
469 #endif
470 #if RTL8188E_SUPPORT
471         if (dm->support_ic_type == ODM_RTL8188E) {
472                 if (odm_get_mac_reg(dm, R_0xf0, 0xF000) >= 8) { /*@if 0xF0[15:12] >= 8, SMIC*/
473                         if (dm->support_interface == ODM_ITRF_PCIE)
474                                 READ_AND_CONFIG_MP(8188e, _txpowertrack_pcie_icut);
475                         else if (dm->support_interface == ODM_ITRF_USB)
476                                 READ_AND_CONFIG_MP(8188e, _txpowertrack_usb_icut);
477                         else if (dm->support_interface == ODM_ITRF_SDIO)
478                                 READ_AND_CONFIG_MP(8188e, _txpowertrack_sdio_icut);
479                 } else { /*@else 0xF0[15:12] < 8, TSMC*/
480                         if (dm->support_interface == ODM_ITRF_PCIE)
481                                 READ_AND_CONFIG_MP(8188e, _txpowertrack_pcie);
482                         else if (dm->support_interface == ODM_ITRF_USB)
483                                 READ_AND_CONFIG_MP(8188e, _txpowertrack_usb);
484                         else if (dm->support_interface == ODM_ITRF_SDIO)
485                                 READ_AND_CONFIG_MP(8188e, _txpowertrack_sdio);
486                 }
487         }
488 #endif
489 #endif /* @(DM_ODM_SUPPORT_TYPE !=  ODM_AP) */
490 /* @1 All platforms support */
491 #if RTL8723B_SUPPORT
492         if (dm->support_ic_type == ODM_RTL8723B) {
493                 if (dm->support_interface == ODM_ITRF_PCIE)
494                         READ_AND_CONFIG_MP(8723b, _txpowertrack_pcie);
495                 else if (dm->support_interface == ODM_ITRF_USB)
496                         READ_AND_CONFIG_MP(8723b, _txpowertrack_usb);
497                 else if (dm->support_interface == ODM_ITRF_SDIO)
498                         READ_AND_CONFIG_MP(8723b, _txpowertrack_sdio);
499         }
500 #endif
501 #if RTL8814A_SUPPORT
502         if (dm->support_ic_type == ODM_RTL8814A) {
503                 if (dm->rfe_type == 0)
504                         READ_AND_CONFIG_MP(8814a, _txpowertrack_type0);
505                 else if (dm->rfe_type == 2)
506                         READ_AND_CONFIG_MP(8814a, _txpowertrack_type2);
507                 else if (dm->rfe_type == 5)
508                         READ_AND_CONFIG_MP(8814a, _txpowertrack_type5);
509                 else if (dm->rfe_type == 7)
510                         READ_AND_CONFIG_MP(8814a, _txpowertrack_type7);
511                 else if (dm->rfe_type == 8)
512                         READ_AND_CONFIG_MP(8814a, _txpowertrack_type8);
513                 else
514                         READ_AND_CONFIG_MP(8814a, _txpowertrack);
515
516                 READ_AND_CONFIG_MP(8814a, _txpowertssi);
517         }
518 #endif
519 #if RTL8703B_SUPPORT
520         if (dm->support_ic_type == ODM_RTL8703B) {
521                 if (dm->support_interface == ODM_ITRF_USB)
522                         READ_AND_CONFIG_MP(8703b, _txpowertrack_usb);
523                 else if (dm->support_interface == ODM_ITRF_SDIO)
524                         READ_AND_CONFIG_MP(8703b, _txpowertrack_sdio);
525
526                 READ_AND_CONFIG_MP(8703b, _txxtaltrack);
527         }
528 #endif
529 #if RTL8188F_SUPPORT
530         if (dm->support_ic_type == ODM_RTL8188F) {
531                 if (dm->support_interface == ODM_ITRF_USB)
532                         READ_AND_CONFIG_MP(8188f, _txpowertrack_usb);
533                 else if (dm->support_interface == ODM_ITRF_SDIO)
534                         READ_AND_CONFIG_MP(8188f, _txpowertrack_sdio);
535         }
536 #endif
537 #if RTL8822B_SUPPORT
538         if (dm->support_ic_type == ODM_RTL8822B) {
539                 if (dm->rfe_type == 0)
540                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type0);
541                 else if (dm->rfe_type == 1)
542                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type1);
543                 else if (dm->rfe_type == 2)
544                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type2);
545                 else if ((dm->rfe_type == 3) || (dm->rfe_type == 5))
546                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type3_type5);
547                 else if (dm->rfe_type == 4)
548                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type4);
549                 else if (dm->rfe_type == 6)
550                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type6);
551                 else if (dm->rfe_type == 7)
552                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type7);
553                 else if (dm->rfe_type == 8)
554                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type8);
555                 else if (dm->rfe_type == 9)
556                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type9);
557                 else if (dm->rfe_type == 10)
558                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type10);
559                 else if (dm->rfe_type == 11)
560                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type11);
561                 else if (dm->rfe_type == 12)
562                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type12);
563                 else if (dm->rfe_type == 13)
564                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type13);
565                 else if (dm->rfe_type == 14)
566                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type14);
567                 else if (dm->rfe_type == 15)
568                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type15);
569                 else if (dm->rfe_type == 16)
570                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type16);
571                 else if (dm->rfe_type == 17)
572                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type17);
573                 else if (dm->rfe_type == 18)
574                         READ_AND_CONFIG_MP(8822b, _txpowertrack_type18);
575                 else
576                         READ_AND_CONFIG_MP(8822b, _txpowertrack);
577         }
578 #endif
579 #if RTL8197F_SUPPORT
580         if (dm->support_ic_type == ODM_RTL8197F) {
581                 if (dm->rfe_type == 0)
582                         READ_AND_CONFIG_MP(8197f, _txpowertrack_type0);
583                 else if (dm->rfe_type == 1)
584                         READ_AND_CONFIG_MP(8197f, _txpowertrack_type1);
585                 else
586                         READ_AND_CONFIG_MP(8197f, _txpowertrack);
587         }
588 #endif
589 /*@jj add 20170822*/
590 #if RTL8192F_SUPPORT
591         if (dm->support_ic_type == ODM_RTL8192F) {
592                 if (dm->rfe_type == 0)
593                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type0);
594                 else if (dm->rfe_type == 1)
595                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type1);
596                 else if (dm->rfe_type == 2)
597                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type2);
598                 else if (dm->rfe_type == 3)
599                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type3);
600                 else if (dm->rfe_type == 4)
601                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type4);
602                 else if (dm->rfe_type == 5)
603                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type5);
604                 else if (dm->rfe_type == 6)
605                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type6);
606                 else if (dm->rfe_type == 7)
607                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type7);
608                 else if (dm->rfe_type == 8)
609                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type8);
610                 else if (dm->rfe_type == 9)
611                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type9);
612                 else if (dm->rfe_type == 10)
613                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type10);
614                 else if (dm->rfe_type == 11)
615                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type11);
616                 else if (dm->rfe_type == 12)
617                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type12);
618                 else if (dm->rfe_type == 13)
619                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type13);
620                 else if (dm->rfe_type == 14)
621                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type14);
622                 else if (dm->rfe_type == 15)
623                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type15);
624                 else if (dm->rfe_type == 16)
625                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type16);
626                 else if (dm->rfe_type == 17)
627                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type17);
628                 else if (dm->rfe_type == 18)
629                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type18);
630                 else if (dm->rfe_type == 19)
631                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type19);
632                 else if (dm->rfe_type == 20)
633                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type20);
634                 else if (dm->rfe_type == 21)
635                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type21);
636                 else if (dm->rfe_type == 22)
637                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type22);
638                 else if (dm->rfe_type == 23)
639                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type23);
640                 else if (dm->rfe_type == 24)
641                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type24);
642                 else if (dm->rfe_type == 25)
643                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type25);
644                 else if (dm->rfe_type == 26)
645                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type26);
646                 else if (dm->rfe_type == 27)
647                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type27);
648                 else if (dm->rfe_type == 28)
649                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type28);
650                 else if (dm->rfe_type == 29)
651                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type29);
652                 else if (dm->rfe_type == 30)
653                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type30);
654                 else if (dm->rfe_type == 31)
655                         READ_AND_CONFIG_MP(8192f, _txpowertrack_type31);
656                 else
657                         READ_AND_CONFIG_MP(8192f, _txpowertrack);
658
659                 READ_AND_CONFIG_MP(8192f, _txxtaltrack);
660         }
661 #endif
662 #if RTL8821C_SUPPORT
663         if (dm->support_ic_type == ODM_RTL8821C) {
664                 if (dm->rfe_type == 0x5)
665                         READ_AND_CONFIG(8821c, _txpowertrack_type0x28);
666                 else if (dm->rfe_type == 0x4)
667                         READ_AND_CONFIG(8821c, _txpowertrack_type0x20);
668                 else
669                         READ_AND_CONFIG(8821c, _txpowertrack);
670         }
671 #endif
672
673 #if RTL8198F_SUPPORT
674         if (dm->support_ic_type == ODM_RTL8198F)
675                 READ_AND_CONFIG_MP(8198f, _txpowertrack);
676 #endif
677
678 #if RTL8195B_SUPPORT
679         if (dm->support_ic_type == ODM_RTL8195B) {
680                 READ_AND_CONFIG_MP(8195b, _txpowertrack);
681                 READ_AND_CONFIG_MP(8195b, _txxtaltrack);
682         }
683 #endif
684
685         return HAL_STATUS_SUCCESS;
686 }
687
688 enum hal_status
689 odm_config_bb_with_header_file(struct dm_struct *dm,
690                                enum odm_bb_config_type config_type)
691 {
692 #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
693         void *adapter = dm->adapter;
694         PMGNT_INFO mgnt_info = &((PADAPTER)adapter)->MgntInfo;
695 #endif
696         enum hal_status result = HAL_STATUS_SUCCESS;
697
698 /* @1 AP doesn't use PHYDM initialization in these ICs */
699 #if (DM_ODM_SUPPORT_TYPE != ODM_AP)
700 #if (RTL8812A_SUPPORT == 1)
701         if (dm->support_ic_type == ODM_RTL8812) {
702                 if (config_type == CONFIG_BB_PHY_REG)
703                         READ_AND_CONFIG_MP(8812a, _phy_reg);
704                 else if (config_type == CONFIG_BB_AGC_TAB)
705                         READ_AND_CONFIG_MP(8812a, _agc_tab);
706                 else if (config_type == CONFIG_BB_PHY_REG_PG) {
707                         if (dm->rfe_type == 3 && dm->is_mp_chip)
708                                 READ_AND_CONFIG_MP(8812a, _phy_reg_pg_asus);
709 #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
710                         else if (mgnt_info->CustomerID == RT_CID_WNC_NEC && dm->is_mp_chip)
711                                 READ_AND_CONFIG_MP(8812a, _phy_reg_pg_nec);
712 #if RT_PLATFORM == PLATFORM_MACOSX
713                         /*@{1827}{1024} for BUFFALO power by rate table. Isaiah 2013-11-29*/
714                         else if (mgnt_info->CustomerID == RT_CID_DNI_BUFFALO)
715                                 READ_AND_CONFIG_MP(8812a, _phy_reg_pg_dni);
716                         /* TP-Link T4UH, Isaiah 2015-03-16*/
717                         else if (mgnt_info->CustomerID == RT_CID_TPLINK_HPWR) {
718                                 pr_debug("RT_CID_TPLINK_HPWR:: _PHY_REG_PG_TPLINK\n");
719                                 READ_AND_CONFIG_MP(8812a, _phy_reg_pg_tplink);
720                         }
721 #endif
722 #endif
723                         else
724                                 READ_AND_CONFIG_MP(8812a, _phy_reg_pg);
725                 } else if (config_type == CONFIG_BB_PHY_REG_MP)
726                         READ_AND_CONFIG_MP(8812a, _phy_reg_mp);
727                 else if (config_type == CONFIG_BB_AGC_TAB_DIFF) {
728                         dm->fw_offload_ability &= ~PHYDM_PHY_PARAM_OFFLOAD;
729                         /*@AGC_TAB DIFF dont support FW offload*/
730                         if ((*dm->channel >= 36) && (*dm->channel <= 64))
731                                 AGC_DIFF_CONFIG_MP(8812a, lb);
732                         else if (*dm->channel >= 100)
733                                 AGC_DIFF_CONFIG_MP(8812a, hb);
734                 }
735         }
736 #endif
737 #if (RTL8821A_SUPPORT == 1)
738         if (dm->support_ic_type == ODM_RTL8821) {
739                 if (config_type == CONFIG_BB_PHY_REG)
740                         READ_AND_CONFIG_MP(8821a, _phy_reg);
741                 else if (config_type == CONFIG_BB_AGC_TAB)
742                         READ_AND_CONFIG_MP(8821a, _agc_tab);
743                 else if (config_type == CONFIG_BB_PHY_REG_PG) {
744 #if (DM_ODM_SUPPORT_TYPE & ODM_WIN)
745 #if (DEV_BUS_TYPE == RT_PCI_INTERFACE)
746                         HAL_DATA_TYPE * hal_data = GET_HAL_DATA(((PADAPTER)adapter));
747
748                         if ((hal_data->EEPROMSVID == 0x1043 && hal_data->EEPROMSMID == 0x207F))
749                                 READ_AND_CONFIG_MP(8821a, _phy_reg_pg_e202_sa);
750                         else
751 #endif
752 #if (RT_PLATFORM == PLATFORM_MACOSX)
753                                 /*@  for BUFFALO pwr by rate table */
754                                 if (mgnt_info->CustomerID == RT_CID_DNI_BUFFALO) {
755                                 /*@  for BUFFALO pwr by rate table (JP/US)*/
756                                 if (mgnt_info->ChannelPlan == RT_CHANNEL_DOMAIN_US_2G_CANADA_5G)
757                                         READ_AND_CONFIG_MP(8821a, _phy_reg_pg_dni_us);
758                                 else
759                                         READ_AND_CONFIG_MP(8821a, _phy_reg_pg_dni_jp);
760                         } else
761 #endif
762 #endif
763                                 READ_AND_CONFIG_MP(8821a, _phy_reg_pg);
764                 }
765         }
766 #endif
767 #if (RTL8192E_SUPPORT == 1)
768         if (dm->support_ic_type == ODM_RTL8192E) {
769                 if (config_type == CONFIG_BB_PHY_REG)
770                         READ_AND_CONFIG_MP(8192e, _phy_reg);
771                 else if (config_type == CONFIG_BB_AGC_TAB)
772                         READ_AND_CONFIG_MP(8192e, _agc_tab);
773                 else if (config_type == CONFIG_BB_PHY_REG_PG)
774                         READ_AND_CONFIG_MP(8192e, _phy_reg_pg);
775         }
776 #endif
777 #if (RTL8723D_SUPPORT == 1)
778         if (dm->support_ic_type == ODM_RTL8723D) {
779                 if (config_type == CONFIG_BB_PHY_REG)
780                         READ_AND_CONFIG_MP(8723d, _phy_reg);
781                 else if (config_type == CONFIG_BB_AGC_TAB)
782                         READ_AND_CONFIG_MP(8723d, _agc_tab);
783                 else if (config_type == CONFIG_BB_PHY_REG_PG)
784                         READ_AND_CONFIG_MP(8723d, _phy_reg_pg);
785         }
786 #endif
787 /* @JJ ADD 20161014 */
788 #if (RTL8710B_SUPPORT == 1)
789         if (dm->support_ic_type == ODM_RTL8710B) {
790                 if (config_type == CONFIG_BB_PHY_REG)
791                         READ_AND_CONFIG_MP(8710b, _phy_reg);
792                 else if (config_type == CONFIG_BB_AGC_TAB)
793                         READ_AND_CONFIG_MP(8710b, _agc_tab);
794                 else if (config_type == CONFIG_BB_PHY_REG_PG)
795                         READ_AND_CONFIG_MP(8710b, _phy_reg_pg);
796         }
797 #endif
798
799 #endif /* @(DM_ODM_SUPPORT_TYPE !=  ODM_AP) */
800 /* @1 All platforms support */
801 #if (RTL8188E_SUPPORT == 1)
802         if (dm->support_ic_type == ODM_RTL8188E) {
803                 if (config_type == CONFIG_BB_PHY_REG)
804                         READ_AND_CONFIG_MP(8188e, _phy_reg);
805                 else if (config_type == CONFIG_BB_AGC_TAB)
806                         READ_AND_CONFIG_MP(8188e, _agc_tab);
807                 else if (config_type == CONFIG_BB_PHY_REG_PG)
808                         READ_AND_CONFIG_MP(8188e, _phy_reg_pg);
809         }
810 #endif
811 #if (RTL8723B_SUPPORT == 1)
812         if (dm->support_ic_type == ODM_RTL8723B) {
813                 if (config_type == CONFIG_BB_PHY_REG)
814                         READ_AND_CONFIG_MP(8723b, _phy_reg);
815                 else if (config_type == CONFIG_BB_AGC_TAB)
816                         READ_AND_CONFIG_MP(8723b, _agc_tab);
817                 else if (config_type == CONFIG_BB_PHY_REG_PG)
818                         READ_AND_CONFIG_MP(8723b, _phy_reg_pg);
819         }
820 #endif
821 #if (RTL8814A_SUPPORT == 1)
822         if (dm->support_ic_type == ODM_RTL8814A) {
823                 if (config_type == CONFIG_BB_PHY_REG)
824                         READ_AND_CONFIG_MP(8814a, _phy_reg);
825                 else if (config_type == CONFIG_BB_AGC_TAB)
826                         READ_AND_CONFIG_MP(8814a, _agc_tab);
827                 else if (config_type == CONFIG_BB_PHY_REG_PG) {
828                         if (dm->rfe_type == 0)
829                                 READ_AND_CONFIG_MP(8814a, _phy_reg_pg_type0);
830                         else if (dm->rfe_type == 2)
831                                 READ_AND_CONFIG_MP(8814a, _phy_reg_pg_type2);
832                         else if (dm->rfe_type == 3)
833                                 READ_AND_CONFIG_MP(8814a, _phy_reg_pg_type3);
834                         else if (dm->rfe_type == 4)
835                                 READ_AND_CONFIG_MP(8814a, _phy_reg_pg_type4);
836                         else if (dm->rfe_type == 5)
837                                 READ_AND_CONFIG_MP(8814a, _phy_reg_pg_type5);
838                         else if (dm->rfe_type == 7)
839                                 READ_AND_CONFIG_MP(8814a, _phy_reg_pg_type7);
840                         else if (dm->rfe_type == 8)
841                                 READ_AND_CONFIG_MP(8814a, _phy_reg_pg_type8);
842                         else
843                                 READ_AND_CONFIG_MP(8814a, _phy_reg_pg);
844                 } else if (config_type == CONFIG_BB_PHY_REG_MP)
845                         READ_AND_CONFIG_MP(8814a, _phy_reg_mp);
846         }
847 #endif
848 #if (RTL8703B_SUPPORT == 1)
849         if (dm->support_ic_type == ODM_RTL8703B) {
850                 if (config_type == CONFIG_BB_PHY_REG)
851                         READ_AND_CONFIG_MP(8703b, _phy_reg);
852                 else if (config_type == CONFIG_BB_AGC_TAB)
853                         READ_AND_CONFIG_MP(8703b, _agc_tab);
854                 else if (config_type == CONFIG_BB_PHY_REG_PG)
855                         READ_AND_CONFIG_MP(8703b, _phy_reg_pg);
856         }
857 #endif
858 #if (RTL8188F_SUPPORT == 1)
859         if (dm->support_ic_type == ODM_RTL8188F) {
860                 if (config_type == CONFIG_BB_PHY_REG)
861                         READ_AND_CONFIG_MP(8188f, _phy_reg);
862                 else if (config_type == CONFIG_BB_AGC_TAB)
863                         READ_AND_CONFIG_MP(8188f, _agc_tab);
864                 else if (config_type == CONFIG_BB_PHY_REG_PG)
865                         READ_AND_CONFIG_MP(8188f, _phy_reg_pg);
866         }
867 #endif
868 #if (RTL8822B_SUPPORT == 1)
869         if (dm->support_ic_type == ODM_RTL8822B) {
870                 if (config_type == CONFIG_BB_PHY_REG) {
871                         READ_AND_CONFIG_MP(8822b, _phy_reg);
872                 } else if (config_type == CONFIG_BB_AGC_TAB) {
873                         READ_AND_CONFIG_MP(8822b, _agc_tab);
874                 } else if (config_type == CONFIG_BB_PHY_REG_PG) {
875                         if (dm->rfe_type == 2)
876                                 READ_AND_CONFIG_MP(8822b, _phy_reg_pg_type2);
877                         else if (dm->rfe_type == 3)
878                                 READ_AND_CONFIG_MP(8822b, _phy_reg_pg_type3);
879                         else if (dm->rfe_type == 4)
880                                 READ_AND_CONFIG_MP(8822b, _phy_reg_pg_type4);
881                         else if (dm->rfe_type == 5)
882                                 READ_AND_CONFIG_MP(8822b, _phy_reg_pg_type5);
883                         else if (dm->rfe_type == 12)
884                                 READ_AND_CONFIG_MP(8822b, _phy_reg_pg_type12);
885                         else if (dm->rfe_type == 15)
886                                 READ_AND_CONFIG_MP(8822b, _phy_reg_pg_type15);
887                         else if (dm->rfe_type == 16)
888                                 READ_AND_CONFIG_MP(8822b, _phy_reg_pg_type16);
889                         else if (dm->rfe_type == 17)
890                                 READ_AND_CONFIG_MP(8822b, _phy_reg_pg_type17);
891                         else if (dm->rfe_type == 18)
892                                 READ_AND_CONFIG_MP(8822b, _phy_reg_pg_type18);
893                         else
894                                 READ_AND_CONFIG_MP(8822b, _phy_reg_pg);
895                 }
896         }
897 #endif
898
899 #if (RTL8197F_SUPPORT == 1)
900         if (dm->support_ic_type == ODM_RTL8197F) {
901                 if (config_type == CONFIG_BB_PHY_REG) {
902                         READ_AND_CONFIG_MP(8197f, _phy_reg);
903                         if (dm->cut_version == ODM_CUT_A)
904                                 phydm_phypara_a_cut(dm);
905                 } else if (config_type == CONFIG_BB_AGC_TAB)
906                         READ_AND_CONFIG_MP(8197f, _agc_tab);
907         }
908 #endif
909 /*@jj add 20170822*/
910 #if (RTL8192F_SUPPORT == 1)
911         if (dm->support_ic_type == ODM_RTL8192F) {
912                 if (config_type == CONFIG_BB_PHY_REG) {
913                         READ_AND_CONFIG_MP(8192f, _phy_reg);
914                 } else if (config_type == CONFIG_BB_AGC_TAB) {
915                         READ_AND_CONFIG_MP(8192f, _agc_tab);
916                 } else if (config_type == CONFIG_BB_PHY_REG_PG) {
917                         if (dm->rfe_type == 0)
918                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type0);
919                         else if (dm->rfe_type == 1)
920                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type1);
921                         else if (dm->rfe_type == 2)
922                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type2);
923                         else if (dm->rfe_type == 3)
924                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type3);
925                         else if (dm->rfe_type == 4)
926                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type4);
927                         else if (dm->rfe_type == 5)
928                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type5);
929                         else if (dm->rfe_type == 6)
930                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type6);
931                         else if (dm->rfe_type == 7)
932                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type7);
933                         else if (dm->rfe_type == 8)
934                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type8);
935                         else if (dm->rfe_type == 9)
936                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type9);
937                         else if (dm->rfe_type == 10)
938                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type10);
939                         else if (dm->rfe_type == 11)
940                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type11);
941                         else if (dm->rfe_type == 12)
942                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type12);
943                         else if (dm->rfe_type == 13)
944                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type13);
945                         else if (dm->rfe_type == 14)
946                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type14);
947                         else if (dm->rfe_type == 15)
948                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type15);
949                         else if (dm->rfe_type == 16)
950                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type16);
951                         else if (dm->rfe_type == 17)
952                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type17);
953                         else if (dm->rfe_type == 18)
954                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type18);
955                         else if (dm->rfe_type == 19)
956                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type19);
957                         else if (dm->rfe_type == 20)
958                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type20);
959                         else if (dm->rfe_type == 21)
960                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type21);
961                         else if (dm->rfe_type == 22)
962                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type22);
963                         else if (dm->rfe_type == 23)
964                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type23);
965                         else if (dm->rfe_type == 24)
966                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type24);
967                         else if (dm->rfe_type == 25)
968                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type25);
969                         else if (dm->rfe_type == 26)
970                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type26);
971                         else if (dm->rfe_type == 27)
972                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type27);
973                         else if (dm->rfe_type == 28)
974                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type28);
975                         else if (dm->rfe_type == 29)
976                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type29);
977                         else if (dm->rfe_type == 30)
978                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type30);
979                         else if (dm->rfe_type == 31)
980                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg_type31);
981                         else
982                                 READ_AND_CONFIG_MP(8192f, _phy_reg_pg);
983                 }
984         }
985 #endif
986 #if (RTL8821C_SUPPORT == 1)
987         if (dm->support_ic_type == ODM_RTL8821C) {
988                 if (config_type == CONFIG_BB_PHY_REG) {
989                         READ_AND_CONFIG(8821c, _phy_reg);
990                 } else if (config_type == CONFIG_BB_AGC_TAB) {
991                         READ_AND_CONFIG(8821c, _agc_tab);
992                         /* @According to RFEtype, choosing correct AGC table*/
993                         if (dm->default_rf_set_8821c == SWITCH_TO_BTG)
994                                 AGC_DIFF_CONFIG_MP(8821c, btg);
995                 } else if (config_type == CONFIG_BB_PHY_REG_PG) {
996                         if (dm->rfe_type == 0x5)
997                                 READ_AND_CONFIG(8821c, _phy_reg_pg_type0x28);
998                         else
999                                 READ_AND_CONFIG(8821c, _phy_reg_pg);
1000                 } else if (config_type == CONFIG_BB_AGC_TAB_DIFF) {
1001                         dm->fw_offload_ability &= ~PHYDM_PHY_PARAM_OFFLOAD;
1002                         /*@AGC_TAB DIFF dont support FW offload*/
1003                         if (dm->current_rf_set_8821c == SWITCH_TO_BTG)
1004                                 AGC_DIFF_CONFIG_MP(8821c, btg);
1005                         else if (dm->current_rf_set_8821c == SWITCH_TO_WLG)
1006                                 AGC_DIFF_CONFIG_MP(8821c, wlg);
1007                 } else if (config_type == CONFIG_BB_PHY_REG_MP) {
1008                         READ_AND_CONFIG(8821c, _phy_reg_mp);
1009                 }
1010         }
1011 #endif
1012
1013 #if (RTL8195A_SUPPORT == 1)
1014         if (dm->support_ic_type == ODM_RTL8195A) {
1015                 if (config_type == CONFIG_BB_PHY_REG)
1016                         READ_AND_CONFIG(8195a, _phy_reg);
1017                 else if (config_type == CONFIG_BB_AGC_TAB)
1018                         READ_AND_CONFIG(8195a, _agc_tab);
1019                 else if (config_type == CONFIG_BB_PHY_REG_PG)
1020                         READ_AND_CONFIG(8195a, _phy_reg_pg);
1021         }
1022 #endif
1023 #if (RTL8195B_SUPPORT == 1)
1024         if (dm->support_ic_type == ODM_RTL8195B) {
1025                 if (config_type == CONFIG_BB_PHY_REG)
1026                         READ_AND_CONFIG(8195b, _phy_reg);
1027                 else if (config_type == CONFIG_BB_AGC_TAB)
1028                         READ_AND_CONFIG(8195b, _agc_tab);
1029                 /*@else if (config_type == CONFIG_BB_PHY_REG_PG)*/
1030                 /*      READ_AND_CONFIG(8195b, _phy_reg_pg);*/
1031         }
1032 #endif
1033 #if (RTL8198F_SUPPORT == 1)
1034         if (dm->support_ic_type == ODM_RTL8198F) {
1035                 if (config_type == CONFIG_BB_PHY_REG)
1036                         READ_AND_CONFIG_MP(8198f, _phy_reg);
1037                 else if (config_type == CONFIG_BB_AGC_TAB)
1038                         READ_AND_CONFIG_MP(8198f, _agc_tab);
1039         }
1040 #endif
1041
1042         if (config_type == CONFIG_BB_PHY_REG ||
1043             config_type == CONFIG_BB_AGC_TAB)
1044                 if (dm->fw_offload_ability & PHYDM_PHY_PARAM_OFFLOAD) {
1045                         result = phydm_set_reg_by_fw(dm,
1046                                                      PHYDM_HALMAC_CMD_END,
1047                                                      0,
1048                                                      0,
1049                                                      0,
1050                                                      (enum rf_path)0,
1051                                                      0);
1052                         PHYDM_DBG(dm, ODM_COMP_INIT,
1053                                   "phy param offload end!result = %d", result);
1054                 }
1055
1056         return result;
1057 }
1058
1059 enum hal_status
1060 odm_config_mac_with_header_file(struct dm_struct *dm)
1061 {
1062         enum hal_status result = HAL_STATUS_SUCCESS;
1063
1064         PHYDM_DBG(dm, ODM_COMP_INIT, "===>%s (%s)\n", __func__,
1065                   (dm->is_mp_chip) ? "MPChip" : "TestChip");
1066         PHYDM_DBG(dm, ODM_COMP_INIT,
1067                   "support_platform: 0x%X, support_interface: 0x%X, board_type: 0x%X\n",
1068                   dm->support_platform, dm->support_interface, dm->board_type);
1069
1070 /* @1 AP doesn't use PHYDM initialization in these ICs */
1071 #if (DM_ODM_SUPPORT_TYPE != ODM_AP)
1072 #if (RTL8812A_SUPPORT == 1)
1073         if (dm->support_ic_type == ODM_RTL8812)
1074                 READ_AND_CONFIG_MP(8812a, _mac_reg);
1075 #endif
1076 #if (RTL8821A_SUPPORT == 1)
1077         if (dm->support_ic_type == ODM_RTL8821)
1078                 READ_AND_CONFIG_MP(8821a, _mac_reg);
1079 #endif
1080 #if (RTL8192E_SUPPORT == 1)
1081         if (dm->support_ic_type == ODM_RTL8192E)
1082                 READ_AND_CONFIG_MP(8192e, _mac_reg);
1083 #endif
1084 #if (RTL8723D_SUPPORT == 1)
1085         if (dm->support_ic_type == ODM_RTL8723D)
1086                 READ_AND_CONFIG_MP(8723d, _mac_reg);
1087 #endif
1088 /* @JJ ADD 20161014 */
1089 #if (RTL8710B_SUPPORT == 1)
1090         if (dm->support_ic_type == ODM_RTL8710B)
1091                 READ_AND_CONFIG_MP(8710b, _mac_reg);
1092 #endif
1093 #endif /* @(DM_ODM_SUPPORT_TYPE !=  ODM_AP) */
1094 /* @1 All platforms support */
1095 #if (RTL8188E_SUPPORT == 1)
1096         if (dm->support_ic_type == ODM_RTL8188E)
1097                 READ_AND_CONFIG_MP(8188e, _mac_reg);
1098 #endif
1099 #if (RTL8723B_SUPPORT == 1)
1100         if (dm->support_ic_type == ODM_RTL8723B)
1101                 READ_AND_CONFIG_MP(8723b, _mac_reg);
1102 #endif
1103 #if (RTL8814A_SUPPORT == 1)
1104         if (dm->support_ic_type == ODM_RTL8814A)
1105                 READ_AND_CONFIG_MP(8814a, _mac_reg);
1106 #endif
1107 #if (RTL8703B_SUPPORT == 1)
1108         if (dm->support_ic_type == ODM_RTL8703B)
1109                 READ_AND_CONFIG_MP(8703b, _mac_reg);
1110 #endif
1111 #if (RTL8188F_SUPPORT == 1)
1112         if (dm->support_ic_type == ODM_RTL8188F)
1113                 READ_AND_CONFIG_MP(8188f, _mac_reg);
1114 #endif
1115 #if (RTL8822B_SUPPORT == 1)
1116         if (dm->support_ic_type == ODM_RTL8822B)
1117                 READ_AND_CONFIG_MP(8822b, _mac_reg);
1118 #endif
1119 #if (RTL8197F_SUPPORT == 1)
1120         if (dm->support_ic_type == ODM_RTL8197F)
1121                 READ_AND_CONFIG_MP(8197f, _mac_reg);
1122 #endif
1123
1124 /*@jj add 20170822*/
1125 #if (RTL8192F_SUPPORT == 1)
1126         if (dm->support_ic_type == ODM_RTL8192F)
1127                 READ_AND_CONFIG_MP(8192f, _mac_reg);
1128 #endif
1129 #if (RTL8821C_SUPPORT == 1)
1130         if (dm->support_ic_type == ODM_RTL8821C)
1131                 READ_AND_CONFIG(8821c, _mac_reg);
1132 #endif
1133 #if (RTL8195A_SUPPORT == 1)
1134         if (dm->support_ic_type == ODM_RTL8195A)
1135                 READ_AND_CONFIG_MP(8195a, _mac_reg);
1136 #endif
1137 #if (RTL8195B_SUPPORT == 1)
1138         if (dm->support_ic_type == ODM_RTL8195B)
1139                 READ_AND_CONFIG_MP(8195b, _mac_reg);
1140 #endif
1141 #if (RTL8198F_SUPPORT == 1)
1142         if (dm->support_ic_type == ODM_RTL8198F)
1143                 READ_AND_CONFIG_MP(8198f, _mac_reg);
1144 #endif
1145
1146         if (dm->fw_offload_ability & PHYDM_PHY_PARAM_OFFLOAD) {
1147                 result = phydm_set_reg_by_fw(dm,
1148                                              PHYDM_HALMAC_CMD_END,
1149                                              0,
1150                                              0,
1151                                              0,
1152                                              (enum rf_path)0,
1153                                              0);
1154                 PHYDM_DBG(dm, ODM_COMP_INIT,
1155                           "mac param offload end!result = %d", result);
1156         }
1157
1158         return result;
1159 }
1160
1161 u32 odm_get_hw_img_version(struct dm_struct *dm)
1162 {
1163         u32 version = 0;
1164
1165 /* @1 AP doesn't use PHYDM initialization in these ICs */
1166 #if (DM_ODM_SUPPORT_TYPE != ODM_AP)
1167 #if (RTL8821A_SUPPORT == 1)
1168         if (dm->support_ic_type == ODM_RTL8821)
1169                 version = GET_VERSION_MP(8821a, _mac_reg);
1170 #endif
1171 #if (RTL8192E_SUPPORT == 1)
1172         if (dm->support_ic_type == ODM_RTL8192E)
1173                 version = GET_VERSION_MP(8192e, _mac_reg);
1174 #endif
1175 #if (RTL8812A_SUPPORT == 1)
1176         if (dm->support_ic_type == ODM_RTL8812)
1177                 version = GET_VERSION_MP(8812a, _mac_reg);
1178 #endif
1179 #if (RTL8723D_SUPPORT == 1)
1180         if (dm->support_ic_type == ODM_RTL8723D)
1181                 version = GET_VERSION_MP(8723d, _mac_reg);
1182 #endif
1183 /* @JJ ADD 20161014 */
1184 #if (RTL8710B_SUPPORT == 1)
1185         if (dm->support_ic_type == ODM_RTL8710B)
1186                 version = GET_VERSION_MP(8710b, _mac_reg);
1187 #endif
1188 #endif /* @(DM_ODM_SUPPORT_TYPE != ODM_AP) */
1189
1190 /*@1 All platforms support*/
1191 #if (RTL8188E_SUPPORT == 1)
1192         if (dm->support_ic_type == ODM_RTL8188E)
1193                 version = GET_VERSION_MP(8188e, _mac_reg);
1194 #endif
1195 #if (RTL8723B_SUPPORT == 1)
1196         if (dm->support_ic_type == ODM_RTL8723B)
1197                 version = GET_VERSION_MP(8723b, _mac_reg);
1198 #endif
1199 #if (RTL8814A_SUPPORT == 1)
1200         if (dm->support_ic_type == ODM_RTL8814A)
1201                 version = GET_VERSION_MP(8814a, _mac_reg);
1202 #endif
1203 #if (RTL8703B_SUPPORT == 1)
1204         if (dm->support_ic_type == ODM_RTL8703B)
1205                 version = GET_VERSION_MP(8703b, _mac_reg);
1206 #endif
1207 #if (RTL8188F_SUPPORT == 1)
1208         if (dm->support_ic_type == ODM_RTL8188F)
1209                 version = GET_VERSION_MP(8188f, _mac_reg);
1210 #endif
1211 #if (RTL8822B_SUPPORT == 1)
1212         if (dm->support_ic_type == ODM_RTL8822B)
1213                 version = GET_VERSION_MP(8822b, _mac_reg);
1214 #endif
1215 #if (RTL8197F_SUPPORT == 1)
1216         if (dm->support_ic_type == ODM_RTL8197F)
1217                 version = GET_VERSION_MP(8197f, _mac_reg);
1218 #endif
1219
1220 /*@jj add 20170822*/
1221 #if (RTL8192F_SUPPORT == 1)
1222         if (dm->support_ic_type == ODM_RTL8192F)
1223                 version = GET_VERSION_MP(8192f, _mac_reg);
1224 #endif
1225 #if (RTL8821C_SUPPORT == 1)
1226         if (dm->support_ic_type == ODM_RTL8821C)
1227                 version = GET_VERSION(8821c, _mac_reg);
1228 #endif
1229 #if (RTL8195B_SUPPORT == 1)
1230         if (dm->support_ic_type == ODM_RTL8195B)
1231                 version = GET_VERSION(8195b, _mac_reg);
1232 #endif
1233 #if (RTL8198F_SUPPORT == 1)
1234         if (dm->support_ic_type == ODM_RTL8198F)
1235                 version = GET_VERSION_MP(8198f, _mac_reg);
1236 #endif
1237
1238         return version;
1239 }
1240
1241 u32 query_phydm_trx_capability(struct dm_struct *dm)
1242 {
1243         u32 value32 = 0xFFFFFFFF;
1244
1245 #if (RTL8821C_SUPPORT == 1)
1246         if (dm->support_ic_type == ODM_RTL8821C)
1247                 value32 = query_phydm_trx_capability_8821c(dm);
1248 #endif
1249 #if (RTL8195B_SUPPORT == 1)
1250         if (dm->support_ic_type == ODM_RTL8195B)
1251                 value32 = query_phydm_trx_capability_8195b(dm);
1252 #endif
1253         return value32;
1254 }
1255
1256 u32 query_phydm_stbc_capability(struct dm_struct *dm)
1257 {
1258         u32 value32 = 0xFFFFFFFF;
1259
1260 #if (RTL8821C_SUPPORT == 1)
1261         if (dm->support_ic_type == ODM_RTL8821C)
1262                 value32 = query_phydm_stbc_capability_8821c(dm);
1263 #endif
1264 #if (RTL8195B_SUPPORT == 1)
1265         if (dm->support_ic_type == ODM_RTL8195B)
1266                 value32 = query_phydm_stbc_capability_8195b(dm);
1267 #endif
1268
1269         return value32;
1270 }
1271
1272 u32 query_phydm_ldpc_capability(struct dm_struct *dm)
1273 {
1274         u32 value32 = 0xFFFFFFFF;
1275
1276 #if (RTL8821C_SUPPORT == 1)
1277         if (dm->support_ic_type == ODM_RTL8821C)
1278                 value32 = query_phydm_ldpc_capability_8821c(dm);
1279 #endif
1280 #if (RTL8195B_SUPPORT == 1)
1281         if (dm->support_ic_type == ODM_RTL8195B)
1282                 value32 = query_phydm_ldpc_capability_8195b(dm);
1283 #endif
1284         return value32;
1285 }
1286
1287 u32 query_phydm_txbf_parameters(struct dm_struct *dm)
1288 {
1289         u32 value32 = 0xFFFFFFFF;
1290
1291 #if (RTL8821C_SUPPORT == 1)
1292         if (dm->support_ic_type == ODM_RTL8821C)
1293                 value32 = query_phydm_txbf_parameters_8821c(dm);
1294 #endif
1295 #if (RTL8195B_SUPPORT == 1)
1296         if (dm->support_ic_type == ODM_RTL8195B)
1297                 value32 = query_phydm_txbf_parameters_8195b(dm);
1298 #endif
1299         return value32;
1300 }
1301
1302 u32 query_phydm_txbf_capability(struct dm_struct *dm)
1303 {
1304         u32 value32 = 0xFFFFFFFF;
1305
1306 #if (RTL8821C_SUPPORT == 1)
1307         if (dm->support_ic_type == ODM_RTL8821C)
1308                 value32 = query_phydm_txbf_capability_8821c(dm);
1309 #endif
1310 #if (RTL8195B_SUPPORT == 1)
1311         if (dm->support_ic_type == ODM_RTL8195B)
1312                 value32 = query_phydm_txbf_capability_8195b(dm);
1313 #endif
1314         return value32;
1315 }