1
2
3
4
5
6
7#define _HAL_PHY_C_
8
9#include <drv_types.h>
10
11
12
13
14
15
16
17
18
19
20
21
22u32 PHY_CalculateBitShift(u32 BitMask)
23{
24 u32 i;
25
26 for (i = 0; i <= 31; i++) {
27 if (((BitMask>>i) & 0x1) == 1)
28 break;
29 }
30
31 return i;
32}
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63u32 PHY_RFShadowRead(IN PADAPTER Adapter, IN u8 eRFPath, IN u32 Offset)
64{
65 return RF_Shadow[eRFPath][Offset].Value;
66
67}
68
69
70void PHY_RFShadowWrite(
71 IN PADAPTER Adapter, IN u8 eRFPath, IN u32 Offset, IN u32 Data
72)
73{
74 RF_Shadow[eRFPath][Offset].Value = (Data & bRFRegOffsetMask);
75 RF_Shadow[eRFPath][Offset].Driver_Write = true;
76
77}
78
79
80bool PHY_RFShadowCompare(IN PADAPTER Adapter, IN u8 eRFPath, IN u32 Offset)
81{
82 u32 reg;
83
84 if (RF_Shadow[eRFPath][Offset].Compare == true) {
85 reg = rtw_hal_read_rfreg(Adapter, eRFPath, Offset, bRFRegOffsetMask);
86
87 if (RF_Shadow[eRFPath][Offset].Value != reg) {
88
89 RF_Shadow[eRFPath][Offset].ErrorOrNot = true;
90
91
92
93 }
94 return RF_Shadow[eRFPath][Offset].ErrorOrNot;
95 }
96 return false;
97}
98
99
100void PHY_RFShadowRecorver(IN PADAPTER Adapter, IN u8 eRFPath, IN u32 Offset)
101{
102
103 if (RF_Shadow[eRFPath][Offset].ErrorOrNot == true) {
104
105 if (RF_Shadow[eRFPath][Offset].Recorver == true) {
106 rtw_hal_write_rfreg(Adapter, eRFPath, Offset, bRFRegOffsetMask,
107 RF_Shadow[eRFPath][Offset].Value);
108
109
110
111 }
112 }
113
114}
115
116
117void PHY_RFShadowCompareAll(IN PADAPTER Adapter)
118{
119 u8 eRFPath = 0;
120 u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter);
121
122 for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) {
123 for (Offset = 0; Offset < maxReg; Offset++) {
124 PHY_RFShadowCompare(Adapter, eRFPath, Offset);
125 }
126 }
127
128}
129
130
131void PHY_RFShadowRecorverAll(IN PADAPTER Adapter)
132{
133 u8 eRFPath = 0;
134 u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter);
135
136 for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) {
137 for (Offset = 0; Offset < maxReg; Offset++) {
138 PHY_RFShadowRecorver(Adapter, eRFPath, Offset);
139 }
140 }
141
142}
143
144
145void
146PHY_RFShadowCompareFlagSet(
147 IN PADAPTER Adapter, IN u8 eRFPath, IN u32 Offset, IN u8 Type
148)
149{
150
151 RF_Shadow[eRFPath][Offset].Compare = Type;
152
153}
154
155
156void PHY_RFShadowRecorverFlagSet(
157 IN PADAPTER Adapter, IN u8 eRFPath, IN u32 Offset, IN u8 Type
158)
159{
160
161 RF_Shadow[eRFPath][Offset].Recorver = Type;
162
163}
164
165
166void PHY_RFShadowCompareFlagSetAll(IN PADAPTER Adapter)
167{
168 u8 eRFPath = 0;
169 u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter);
170
171 for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) {
172 for (Offset = 0; Offset < maxReg; Offset++) {
173
174 if (Offset != 0x26 && Offset != 0x27)
175 PHY_RFShadowCompareFlagSet(Adapter, eRFPath, Offset, false);
176 else
177 PHY_RFShadowCompareFlagSet(Adapter, eRFPath, Offset, true);
178 }
179 }
180
181}
182
183
184void PHY_RFShadowRecorverFlagSetAll(IN PADAPTER Adapter)
185{
186 u8 eRFPath = 0;
187 u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter);
188
189 for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) {
190 for (Offset = 0; Offset < maxReg; Offset++) {
191
192 if (Offset != 0x26 && Offset != 0x27)
193 PHY_RFShadowRecorverFlagSet(Adapter, eRFPath, Offset, false);
194 else
195 PHY_RFShadowRecorverFlagSet(Adapter, eRFPath, Offset, true);
196 }
197 }
198
199}
200
201void PHY_RFShadowRefresh(IN PADAPTER Adapter)
202{
203 u8 eRFPath = 0;
204 u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter);
205
206 for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) {
207 for (Offset = 0; Offset < maxReg; Offset++) {
208 RF_Shadow[eRFPath][Offset].Value = 0;
209 RF_Shadow[eRFPath][Offset].Compare = false;
210 RF_Shadow[eRFPath][Offset].Recorver = false;
211 RF_Shadow[eRFPath][Offset].ErrorOrNot = false;
212 RF_Shadow[eRFPath][Offset].Driver_Write = false;
213 }
214 }
215
216}
217