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"
24 static bool Checkcondition(const u32 condition, const u32 hex)
26 u32 _board = (hex & 0x000000FF);
27 u32 _interface = (hex & 0x0000FF00) >> 8;
28 u32 _platform = (hex & 0x00FF0000) >> 16;
31 if (condition == 0xCDCDCDCD)
34 cond = condition & 0x000000FF;
35 if ((_board == cond) && cond != 0x00)
38 cond = condition & 0x0000FF00;
40 if ((_interface & cond) == 0 && cond != 0x07)
43 cond = condition & 0x00FF0000;
45 if ((_platform & cond) == 0 && cond != 0x0F)
50 /******************************************************************************
52 ******************************************************************************/
54 static u32 array_MAC_REG_8188E[] = {
147 enum HAL_STATUS ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *dm_odm)
149 #define READ_NEXT_PAIR(v1, v2, i) do { i += 2; v1 = array[i]; v2 = array[i+1]; } while (0)
153 u8 platform = dm_odm->SupportPlatform;
154 u8 interface_val = dm_odm->SupportInterface;
155 u8 board = dm_odm->BoardType;
156 u32 array_len = sizeof(array_MAC_REG_8188E)/sizeof(u32);
157 u32 *array = array_MAC_REG_8188E;
160 struct adapter *adapt = dm_odm->Adapter;
161 struct xmit_frame *pxmit_frame = NULL;
163 enum HAL_STATUS rst = HAL_STATUS_SUCCESS;
165 hex += interface_val << 8;
166 hex += platform << 16;
169 biol = rtw_IOL_applied(adapt);
172 pxmit_frame = rtw_IOL_accquire_xmit_frame(adapt);
173 if (pxmit_frame == NULL) {
174 pr_info("rtw_IOL_accquire_xmit_frame failed\n");
175 return HAL_STATUS_FAILURE;
179 for (i = 0; i < array_len; i += 2) {
183 /* This (offset, data) pair meets the condition. */
184 if (v1 < 0xCDCDCDCD) {
186 if (rtw_IOL_cmd_boundary_handle(pxmit_frame))
188 rtw_IOL_append_WB_cmd(pxmit_frame, (u16)v1, (u8)v2, 0xFF);
190 odm_ConfigMAC_8188E(dm_odm, v1, (u8)v2);
193 } else { /* This line is the start line of branch. */
194 if (!Checkcondition(array[i], hex)) {
195 /* Discard the following (offset, data) pairs. */
196 READ_NEXT_PAIR(v1, v2, i);
197 while (v2 != 0xDEAD &&
199 v2 != 0xCDCD && i < array_len - 2) {
200 READ_NEXT_PAIR(v1, v2, i);
202 i -= 2; /* prevent from for-loop += 2 */
203 } else { /* Configure matched pairs and skip to end of if-else. */
204 READ_NEXT_PAIR(v1, v2, i);
205 while (v2 != 0xDEAD &&
207 v2 != 0xCDCD && i < array_len - 2) {
209 if (rtw_IOL_cmd_boundary_handle(pxmit_frame))
211 rtw_IOL_append_WB_cmd(pxmit_frame, (u16)v1, (u8)v2, 0xFF);
213 odm_ConfigMAC_8188E(dm_odm, v1, (u8)v2);
216 READ_NEXT_PAIR(v1, v2, i);
218 while (v2 != 0xDEAD && i < array_len - 2)
219 READ_NEXT_PAIR(v1, v2, i);
224 if (!rtw_IOL_exec_cmds_sync(dm_odm->Adapter, pxmit_frame, 1000, bndy_cnt)) {
225 pr_info("~~~ MAC IOL_exec_cmds Failed !!!\n");
226 rst = HAL_STATUS_FAILURE;