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 ******************************************************************************/
17 #include <drv_types.h>
20 * Function: PHY_CalculateBitShift
22 * OverView: Get shifted position of the BitMask
28 * Return: u32 Return the shift bit bit position of the mask
31 PHY_CalculateBitShift(
39 if (((BitMask>>i) & 0x1 ) == 1)
48 /* ==> RF shadow Operation API Code Section!!! */
50 /*-----------------------------------------------------------------------------
51 * Function: PHY_RFShadowRead
54 * PHY_RFShadowRecorver
55 * PHY_RFShadowCompareAll
56 * PHY_RFShadowRecorverAll
57 * PHY_RFShadowCompareFlagSet
58 * PHY_RFShadowRecorverFlagSet
60 * Overview: When we set RF register, we must write shadow at first.
61 * When we are running, we must compare shadow abd locate error addr.
62 * Decide to recorver or not.
72 * 11/20/2008 MHC Create Version 0.
74 *---------------------------------------------------------------------------*/
81 return RF_Shadow[eRFPath][Offset].Value;
83 } /* PHY_RFShadowRead */
93 RF_Shadow[eRFPath][Offset].Value = (Data & bRFRegOffsetMask);
94 RF_Shadow[eRFPath][Offset].Driver_Write = true;
96 } /* PHY_RFShadowWrite */
106 /* Check if we need to check the register */
107 if (RF_Shadow[eRFPath][Offset].Compare == true)
109 reg = rtw_hal_read_rfreg(Adapter, eRFPath, Offset, bRFRegOffsetMask);
110 /* Compare shadow and real rf register for 20bits!! */
111 if (RF_Shadow[eRFPath][Offset].Value != reg)
113 /* Locate error position. */
114 RF_Shadow[eRFPath][Offset].ErrorOrNot = true;
115 /* RT_TRACE(COMP_INIT, DBG_LOUD, */
116 /* PHY_RFShadowCompare RF-%d Addr%02lx Err = %05lx\n", */
117 /* eRFPath, Offset, reg)); */
119 return RF_Shadow[eRFPath][Offset].ErrorOrNot ;
122 } /* PHY_RFShadowCompare */
126 PHY_RFShadowRecorver(
131 /* Check if the address is error */
132 if (RF_Shadow[eRFPath][Offset].ErrorOrNot == true)
134 /* Check if we need to recorver the register. */
135 if (RF_Shadow[eRFPath][Offset].Recorver == true)
137 rtw_hal_write_rfreg(Adapter, eRFPath, Offset, bRFRegOffsetMask,
138 RF_Shadow[eRFPath][Offset].Value);
139 /* RT_TRACE(COMP_INIT, DBG_LOUD, */
140 /* PHY_RFShadowRecorver RF-%d Addr%02lx=%05lx", */
141 /* eRFPath, Offset, RF_Shadow[eRFPath][Offset].Value)); */
145 } /* PHY_RFShadowRecorver */
149 PHY_RFShadowCompareAll(
153 u32 Offset = 0, maxReg= GET_RF6052_REAL_MAX_REG(Adapter);
155 for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
157 for (Offset = 0; Offset < maxReg; Offset++)
159 PHY_RFShadowCompare(Adapter, eRFPath, Offset);
163 } /* PHY_RFShadowCompareAll */
167 PHY_RFShadowRecorverAll(
171 u32 Offset = 0, maxReg= GET_RF6052_REAL_MAX_REG(Adapter);
173 for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
175 for (Offset = 0; Offset < maxReg; Offset++)
177 PHY_RFShadowRecorver(Adapter, eRFPath, Offset);
181 } /* PHY_RFShadowRecorverAll */
185 PHY_RFShadowCompareFlagSet(
191 /* Set True or False!!! */
192 RF_Shadow[eRFPath][Offset].Compare = Type;
194 } /* PHY_RFShadowCompareFlagSet */
198 PHY_RFShadowRecorverFlagSet(
204 /* Set True or False!!! */
205 RF_Shadow[eRFPath][Offset].Recorver= Type;
207 } /* PHY_RFShadowRecorverFlagSet */
211 PHY_RFShadowCompareFlagSetAll(
215 u32 Offset = 0, maxReg= GET_RF6052_REAL_MAX_REG(Adapter);
217 for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
219 for (Offset = 0; Offset < maxReg; Offset++)
221 /* 2008/11/20 MH For S3S4 test, we only check reg 26/27 now!!!! */
222 if (Offset != 0x26 && Offset != 0x27)
223 PHY_RFShadowCompareFlagSet(Adapter, eRFPath, Offset, false);
225 PHY_RFShadowCompareFlagSet(Adapter, eRFPath, Offset, true);
229 } /* PHY_RFShadowCompareFlagSetAll */
233 PHY_RFShadowRecorverFlagSetAll(
237 u32 Offset = 0, maxReg= GET_RF6052_REAL_MAX_REG(Adapter);
239 for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
241 for (Offset = 0; Offset < maxReg; Offset++)
243 /* 2008/11/20 MH For S3S4 test, we only check reg 26/27 now!!!! */
244 if (Offset != 0x26 && Offset != 0x27)
245 PHY_RFShadowRecorverFlagSet(Adapter, eRFPath, Offset, false);
247 PHY_RFShadowRecorverFlagSet(Adapter, eRFPath, Offset, true);
251 } /* PHY_RFShadowCompareFlagSetAll */
258 u32 Offset = 0, maxReg= GET_RF6052_REAL_MAX_REG(Adapter);
260 for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++)
262 for (Offset = 0; Offset < maxReg; Offset++)
264 RF_Shadow[eRFPath][Offset].Value = 0;
265 RF_Shadow[eRFPath][Offset].Compare = false;
266 RF_Shadow[eRFPath][Offset].Recorver = false;
267 RF_Shadow[eRFPath][Offset].ErrorOrNot = false;
268 RF_Shadow[eRFPath][Offset].Driver_Write = false;
272 } /* PHY_RFShadowRead */