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 ******************************************************************************/
22 #include <drv_types.h>
24 //================================================================================
26 //================================================================================
27 // 2008/11/20 MH For Debug only, RF
28 static RF_SHADOW_T RF_Shadow[RF6052_MAX_PATH][RF6052_MAX_REG];
31 * Function: PHY_CalculateBitShift
33 * OverView: Get shifted position of the BitMask
39 * Return: u4Byte Return the shift bit bit position of the mask
42 PHY_CalculateBitShift(
50 if ( ((BitMask>>i) & 0x1 ) == 1)
59 // ==> RF shadow Operation API Code Section!!!
61 /*-----------------------------------------------------------------------------
62 * Function: PHY_RFShadowRead
65 * PHY_RFShadowRecorver
66 * PHY_RFShadowCompareAll
67 * PHY_RFShadowRecorverAll
68 * PHY_RFShadowCompareFlagSet
69 * PHY_RFShadowRecorverFlagSet
71 * Overview: When we set RF register, we must write shadow at first.
72 * When we are running, we must compare shadow abd locate error addr.
73 * Decide to recorver or not.
83 * 11/20/2008 MHC Create Version 0.
85 *---------------------------------------------------------------------------*/
92 return RF_Shadow[eRFPath][Offset].Value;
94 } /* PHY_RFShadowRead */
104 RF_Shadow[eRFPath][Offset].Value = (Data & bRFRegOffsetMask);
105 RF_Shadow[eRFPath][Offset].Driver_Write = _TRUE;
107 } /* PHY_RFShadowWrite */
117 // Check if we need to check the register
118 if (RF_Shadow[eRFPath][Offset].Compare == _TRUE)
120 reg = rtw_hal_read_rfreg(Adapter, eRFPath, Offset, bRFRegOffsetMask);
121 // Compare shadow and real rf register for 20bits!!
122 if (RF_Shadow[eRFPath][Offset].Value != reg)
124 // Locate error position.
125 RF_Shadow[eRFPath][Offset].ErrorOrNot = _TRUE;
126 //RT_TRACE(COMP_INIT, DBG_LOUD,
127 //("PHY_RFShadowCompare RF-%d Addr%02lx Err = %05lx\n",
128 //eRFPath, Offset, reg));
130 return RF_Shadow[eRFPath][Offset].ErrorOrNot ;
133 } /* PHY_RFShadowCompare */
137 PHY_RFShadowRecorver(
142 // Check if the address is error
143 if (RF_Shadow[eRFPath][Offset].ErrorOrNot == _TRUE)
145 // Check if we need to recorver the register.
146 if (RF_Shadow[eRFPath][Offset].Recorver == _TRUE)
148 rtw_hal_write_rfreg(Adapter, eRFPath, Offset, bRFRegOffsetMask,
149 RF_Shadow[eRFPath][Offset].Value);
150 //RT_TRACE(COMP_INIT, DBG_LOUD,
151 //("PHY_RFShadowRecorver RF-%d Addr%02lx=%05lx",
152 //eRFPath, Offset, RF_Shadow[eRFPath][Offset].Value));
156 } /* PHY_RFShadowRecorver */
160 PHY_RFShadowCompareAll(
164 u32 Offset = 0, maxReg= GET_RF6052_REAL_MAX_REG(Adapter);
166 for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
168 for (Offset = 0; Offset < maxReg; Offset++)
170 PHY_RFShadowCompare(Adapter, eRFPath, Offset);
174 } /* PHY_RFShadowCompareAll */
178 PHY_RFShadowRecorverAll(
182 u32 Offset = 0, maxReg= GET_RF6052_REAL_MAX_REG(Adapter);
184 for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
186 for (Offset = 0; Offset < maxReg; Offset++)
188 PHY_RFShadowRecorver(Adapter, eRFPath, Offset);
192 } /* PHY_RFShadowRecorverAll */
196 PHY_RFShadowCompareFlagSet(
202 // Set True or False!!!
203 RF_Shadow[eRFPath][Offset].Compare = Type;
205 } /* PHY_RFShadowCompareFlagSet */
209 PHY_RFShadowRecorverFlagSet(
215 // Set True or False!!!
216 RF_Shadow[eRFPath][Offset].Recorver= Type;
218 } /* PHY_RFShadowRecorverFlagSet */
222 PHY_RFShadowCompareFlagSetAll(
226 u32 Offset = 0, maxReg= GET_RF6052_REAL_MAX_REG(Adapter);
228 for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
230 for (Offset = 0; Offset < maxReg; Offset++)
232 // 2008/11/20 MH For S3S4 test, we only check reg 26/27 now!!!!
233 if (Offset != 0x26 && Offset != 0x27)
234 PHY_RFShadowCompareFlagSet(Adapter, eRFPath, Offset, _FALSE);
236 PHY_RFShadowCompareFlagSet(Adapter, eRFPath, Offset, _TRUE);
240 } /* PHY_RFShadowCompareFlagSetAll */
244 PHY_RFShadowRecorverFlagSetAll(
248 u32 Offset = 0, maxReg= GET_RF6052_REAL_MAX_REG(Adapter);
250 for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
252 for (Offset = 0; Offset < maxReg; Offset++)
254 // 2008/11/20 MH For S3S4 test, we only check reg 26/27 now!!!!
255 if (Offset != 0x26 && Offset != 0x27)
256 PHY_RFShadowRecorverFlagSet(Adapter, eRFPath, Offset, _FALSE);
258 PHY_RFShadowRecorverFlagSet(Adapter, eRFPath, Offset, _TRUE);
262 } /* PHY_RFShadowCompareFlagSetAll */
269 u32 Offset = 0, maxReg= GET_RF6052_REAL_MAX_REG(Adapter);
271 for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
273 for (Offset = 0; Offset < maxReg; Offset++)
275 RF_Shadow[eRFPath][Offset].Value = 0;
276 RF_Shadow[eRFPath][Offset].Compare = _FALSE;
277 RF_Shadow[eRFPath][Offset].Recorver = _FALSE;
278 RF_Shadow[eRFPath][Offset].ErrorOrNot = _FALSE;
279 RF_Shadow[eRFPath][Offset].Driver_Write = _FALSE;
283 } /* PHY_RFShadowRead */