Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
nu11secur1ty
GitHub Repository: nu11secur1ty/Kali-Linux
Path: blob/master/ALFA-W1F1/RTL8814AU/hal/hal_phy.c
1307 views
1
/******************************************************************************
2
*
3
* Copyright(c) 2007 - 2017 Realtek Corporation.
4
*
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.
8
*
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
12
* more details.
13
*
14
*****************************************************************************/
15
#define _HAL_PHY_C_
16
17
#include <drv_types.h>
18
19
/**
20
* Function: PHY_CalculateBitShift
21
*
22
* OverView: Get shifted position of the BitMask
23
*
24
* Input:
25
* u32 BitMask,
26
*
27
* Output: none
28
* Return: u32 Return the shift bit bit position of the mask
29
*/
30
u32
31
PHY_CalculateBitShift(
32
u32 BitMask
33
)
34
{
35
u32 i;
36
37
for (i = 0; i <= 31; i++) {
38
if (((BitMask >> i) & 0x1) == 1)
39
break;
40
}
41
42
return i;
43
}
44
45
46
#ifdef CONFIG_RF_SHADOW_RW
47
/* ********************************************************************************
48
* Constant.
49
* ********************************************************************************
50
* 2008/11/20 MH For Debug only, RF */
51
static RF_SHADOW_T RF_Shadow[RF6052_MAX_PATH][RF6052_MAX_REG];
52
53
/*
54
* ==> RF shadow Operation API Code Section!!!
55
*
56
*-----------------------------------------------------------------------------
57
* Function: PHY_RFShadowRead
58
* PHY_RFShadowWrite
59
* PHY_RFShadowCompare
60
* PHY_RFShadowRecorver
61
* PHY_RFShadowCompareAll
62
* PHY_RFShadowRecorverAll
63
* PHY_RFShadowCompareFlagSet
64
* PHY_RFShadowRecorverFlagSet
65
*
66
* Overview: When we set RF register, we must write shadow at first.
67
* When we are running, we must compare shadow abd locate error addr.
68
* Decide to recorver or not.
69
*
70
* Input: NONE
71
*
72
* Output: NONE
73
*
74
* Return: NONE
75
*
76
* Revised History:
77
* When Who Remark
78
* 11/20/2008 MHC Create Version 0.
79
*
80
*---------------------------------------------------------------------------*/
81
u32
82
PHY_RFShadowRead(
83
PADAPTER Adapter,
84
enum rf_path eRFPath,
85
u32 Offset)
86
{
87
return RF_Shadow[eRFPath][Offset].Value;
88
89
} /* PHY_RFShadowRead */
90
91
92
void
93
PHY_RFShadowWrite(
94
PADAPTER Adapter,
95
enum rf_path eRFPath,
96
u32 Offset,
97
u32 Data)
98
{
99
RF_Shadow[eRFPath][Offset].Value = (Data & bRFRegOffsetMask);
100
RF_Shadow[eRFPath][Offset].Driver_Write = _TRUE;
101
102
} /* PHY_RFShadowWrite */
103
104
105
BOOLEAN
106
PHY_RFShadowCompare(
107
PADAPTER Adapter,
108
enum rf_path eRFPath,
109
u32 Offset)
110
{
111
u32 reg;
112
/* Check if we need to check the register */
113
if (RF_Shadow[eRFPath][Offset].Compare == _TRUE) {
114
reg = rtw_hal_read_rfreg(Adapter, eRFPath, Offset, bRFRegOffsetMask);
115
/* Compare shadow and real rf register for 20bits!! */
116
if (RF_Shadow[eRFPath][Offset].Value != reg) {
117
/* Locate error position. */
118
RF_Shadow[eRFPath][Offset].ErrorOrNot = _TRUE;
119
}
120
return RF_Shadow[eRFPath][Offset].ErrorOrNot ;
121
}
122
return _FALSE;
123
} /* PHY_RFShadowCompare */
124
125
126
void
127
PHY_RFShadowRecorver(
128
PADAPTER Adapter,
129
enum rf_path eRFPath,
130
u32 Offset)
131
{
132
/* Check if the address is error */
133
if (RF_Shadow[eRFPath][Offset].ErrorOrNot == _TRUE) {
134
/* Check if we need to recorver the register. */
135
if (RF_Shadow[eRFPath][Offset].Recorver == _TRUE) {
136
rtw_hal_write_rfreg(Adapter, eRFPath, Offset, bRFRegOffsetMask,
137
RF_Shadow[eRFPath][Offset].Value);
138
}
139
}
140
141
} /* PHY_RFShadowRecorver */
142
143
144
void
145
PHY_RFShadowCompareAll(
146
PADAPTER Adapter)
147
{
148
enum rf_path eRFPath = RF_PATH_A;
149
u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter);
150
151
for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) {
152
for (Offset = 0; Offset < maxReg; Offset++)
153
PHY_RFShadowCompare(Adapter, eRFPath, Offset);
154
}
155
156
} /* PHY_RFShadowCompareAll */
157
158
159
void
160
PHY_RFShadowRecorverAll(
161
PADAPTER Adapter)
162
{
163
enum rf_path eRFPath = RF_PATH_A;
164
u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter);
165
166
for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) {
167
for (Offset = 0; Offset < maxReg; Offset++)
168
PHY_RFShadowRecorver(Adapter, eRFPath, Offset);
169
}
170
171
} /* PHY_RFShadowRecorverAll */
172
173
174
void
175
PHY_RFShadowCompareFlagSet(
176
PADAPTER Adapter,
177
enum rf_path eRFPath,
178
u32 Offset,
179
u8 Type)
180
{
181
/* Set True or False!!! */
182
RF_Shadow[eRFPath][Offset].Compare = Type;
183
184
} /* PHY_RFShadowCompareFlagSet */
185
186
187
void
188
PHY_RFShadowRecorverFlagSet(
189
PADAPTER Adapter,
190
enum rf_path eRFPath,
191
u32 Offset,
192
u8 Type)
193
{
194
/* Set True or False!!! */
195
RF_Shadow[eRFPath][Offset].Recorver = Type;
196
197
} /* PHY_RFShadowRecorverFlagSet */
198
199
200
void
201
PHY_RFShadowCompareFlagSetAll(
202
PADAPTER Adapter)
203
{
204
enum rf_path eRFPath = RF_PATH_A;
205
u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter);
206
207
for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) {
208
for (Offset = 0; Offset < maxReg; Offset++) {
209
/* 2008/11/20 MH For S3S4 test, we only check reg 26/27 now!!!! */
210
if (Offset != 0x26 && Offset != 0x27)
211
PHY_RFShadowCompareFlagSet(Adapter, eRFPath, Offset, _FALSE);
212
else
213
PHY_RFShadowCompareFlagSet(Adapter, eRFPath, Offset, _TRUE);
214
}
215
}
216
217
} /* PHY_RFShadowCompareFlagSetAll */
218
219
220
void
221
PHY_RFShadowRecorverFlagSetAll(
222
PADAPTER Adapter)
223
{
224
enum rf_path eRFPath = RF_PATH_A;
225
u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter);
226
227
for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) {
228
for (Offset = 0; Offset < maxReg; Offset++) {
229
/* 2008/11/20 MH For S3S4 test, we only check reg 26/27 now!!!! */
230
if (Offset != 0x26 && Offset != 0x27)
231
PHY_RFShadowRecorverFlagSet(Adapter, eRFPath, Offset, _FALSE);
232
else
233
PHY_RFShadowRecorverFlagSet(Adapter, eRFPath, Offset, _TRUE);
234
}
235
}
236
237
} /* PHY_RFShadowCompareFlagSetAll */
238
239
void
240
PHY_RFShadowRefresh(
241
PADAPTER Adapter)
242
{
243
enum rf_path eRFPath = RF_PATH_A;
244
u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter);
245
246
for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) {
247
for (Offset = 0; Offset < maxReg; Offset++) {
248
RF_Shadow[eRFPath][Offset].Value = 0;
249
RF_Shadow[eRFPath][Offset].Compare = _FALSE;
250
RF_Shadow[eRFPath][Offset].Recorver = _FALSE;
251
RF_Shadow[eRFPath][Offset].ErrorOrNot = _FALSE;
252
RF_Shadow[eRFPath][Offset].Driver_Write = _FALSE;
253
}
254
}
255
256
} /* PHY_RFShadowRead */
257
#endif /*CONFIG_RF_SHADOW_RW*/
258
259