1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
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.
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
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 ******************************************************************************/
21 #include "odm_precomp.h"
25 static bool CheckCondition(const u32 Condition, const u32 Hex)
27 u32 _board = (Hex & 0x000000FF);
28 u32 _interface = (Hex & 0x0000FF00) >> 8;
29 u32 _platform = (Hex & 0x00FF0000) >> 16;
32 if (Condition == 0xCDCDCDCD)
35 cond = Condition & 0x000000FF;
36 if ((_board == cond) && cond != 0x00)
39 cond = Condition & 0x0000FF00;
41 if ((_interface & cond) == 0 && cond != 0x07)
44 cond = Condition & 0x00FF0000;
46 if ((_platform & cond) == 0 && cond != 0x0F)
52 /******************************************************************************
54 ******************************************************************************/
56 static u32 Array_RadioA_1T_8188E[] = {
158 enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm)
160 #define READ_NEXT_PAIR(v1, v2, i) do \
161 { i += 2; v1 = Array[i]; \
162 v2 = Array[i+1]; } while (0)
166 u8 platform = pDM_Odm->SupportPlatform;
167 u8 interfaceValue = pDM_Odm->SupportInterface;
168 u8 board = pDM_Odm->BoardType;
169 u32 ArrayLen = sizeof(Array_RadioA_1T_8188E)/sizeof(u32);
170 u32 *Array = Array_RadioA_1T_8188E;
172 struct adapter *Adapter = pDM_Odm->Adapter;
173 struct xmit_frame *pxmit_frame = NULL;
175 enum HAL_STATUS rst = HAL_STATUS_SUCCESS;
178 hex += interfaceValue << 8;
179 hex += platform << 16;
181 biol = rtw_IOL_applied(Adapter);
184 pxmit_frame = rtw_IOL_accquire_xmit_frame(Adapter);
185 if (pxmit_frame == NULL) {
186 pr_info("rtw_IOL_accquire_xmit_frame failed\n");
187 return HAL_STATUS_FAILURE;
191 for (i = 0; i < ArrayLen; i += 2) {
195 /* This (offset, data) pair meets the condition. */
196 if (v1 < 0xCDCDCDCD) {
198 if (rtw_IOL_cmd_boundary_handle(pxmit_frame))
202 rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50);
204 rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5);
206 rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1);
208 rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50);
210 rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5);
212 rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1);
214 rtw_IOL_append_WRF_cmd(pxmit_frame, RF_PATH_A, (u16)v1, v2, bRFRegOffsetMask);
216 odm_ConfigRF_RadioA_8188E(pDM_Odm, v1, v2);
219 } else { /* This line is the start line of branch. */
220 if (!CheckCondition(Array[i], hex)) {
221 /* Discard the following (offset, data) pairs. */
222 READ_NEXT_PAIR(v1, v2, i);
223 while (v2 != 0xDEAD &&
225 v2 != 0xCDCD && i < ArrayLen - 2)
226 READ_NEXT_PAIR(v1, v2, i);
227 i -= 2; /* prevent from for-loop += 2 */
228 } else { /* Configure matched pairs and skip to end of if-else. */
229 READ_NEXT_PAIR(v1, v2, i);
230 while (v2 != 0xDEAD &&
232 v2 != 0xCDCD && i < ArrayLen - 2) {
234 if (rtw_IOL_cmd_boundary_handle(pxmit_frame))
238 rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50);
240 rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5);
242 rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1);
244 rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50);
246 rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5);
248 rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1);
250 rtw_IOL_append_WRF_cmd(pxmit_frame, RF_PATH_A, (u16)v1, v2, bRFRegOffsetMask);
252 odm_ConfigRF_RadioA_8188E(pDM_Odm, v1, v2);
254 READ_NEXT_PAIR(v1, v2, i);
257 while (v2 != 0xDEAD && i < ArrayLen - 2)
258 READ_NEXT_PAIR(v1, v2, i);
263 if (!rtw_IOL_exec_cmds_sync(pDM_Odm->Adapter, pxmit_frame, 1000, bndy_cnt)) {
264 rst = HAL_STATUS_FAILURE;
265 pr_info("~~~ IOL Config %s Failed !!!\n", __func__);