1 /******************************************************************************
3 * Copyright(c) 2009-2012 Realtek Corporation.
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
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
21 * Contact Information:
22 * wlanfae <wlanfae@realtek.com>
23 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
24 * Hsinchu 300, Taiwan.
26 * Larry Finger <Larry.Finger@lwfinger.net>
28 ****************************************************************************
41 static const u32 ofdmswing_table
[OFDM_TABLE_SIZE
] = {
81 static const u8 cckswing_table_ch1ch13
[CCK_TABLE_SIZE
][8] = {
82 {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04},
83 {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04},
84 {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03},
85 {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03},
86 {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03},
87 {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03},
88 {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03},
89 {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03},
90 {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02},
91 {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02},
92 {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02},
93 {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02},
94 {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02},
95 {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02},
96 {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02},
97 {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02},
98 {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01},
99 {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02},
100 {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01},
101 {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01},
102 {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01},
103 {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01},
104 {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01},
105 {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01},
106 {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01},
107 {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01},
108 {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01},
109 {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01},
110 {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01},
111 {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01},
112 {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01},
113 {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01},
114 {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01}
117 static const u8 cckswing_table_ch14
[CCK_TABLE_SIZE
][8] = {
118 {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00},
119 {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00},
120 {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00},
121 {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00},
122 {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00},
123 {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00},
124 {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00},
125 {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00},
126 {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00},
127 {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00},
128 {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00},
129 {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00},
130 {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00},
131 {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00},
132 {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00},
133 {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00},
134 {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00},
135 {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00},
136 {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00},
137 {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00},
138 {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00},
139 {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00},
140 {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00},
141 {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00},
142 {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00},
143 {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00},
144 {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00},
145 {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00},
146 {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00},
147 {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00},
148 {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00},
149 {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00},
150 {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00}
153 static void rtl8723ae_dm_diginit(struct ieee80211_hw
*hw
)
155 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
156 struct dig_t
*dm_digtable
= &rtlpriv
->dm_digtable
;
158 dm_digtable
->dig_enable_flag
= true;
159 dm_digtable
->dig_ext_port_stage
= DIG_EXT_PORT_STAGE_MAX
;
160 dm_digtable
->cur_igvalue
= 0x20;
161 dm_digtable
->pre_igvalue
= 0x0;
162 dm_digtable
->cursta_cstate
= DIG_STA_DISCONNECT
;
163 dm_digtable
->presta_cstate
= DIG_STA_DISCONNECT
;
164 dm_digtable
->curmultista_cstate
= DIG_MULTISTA_DISCONNECT
;
165 dm_digtable
->rssi_lowthresh
= DM_DIG_THRESH_LOW
;
166 dm_digtable
->rssi_highthresh
= DM_DIG_THRESH_HIGH
;
167 dm_digtable
->fa_lowthresh
= DM_FALSEALARM_THRESH_LOW
;
168 dm_digtable
->fa_highthresh
= DM_FALSEALARM_THRESH_HIGH
;
169 dm_digtable
->rx_gain_max
= DM_DIG_MAX
;
170 dm_digtable
->rx_gain_min
= DM_DIG_MIN
;
171 dm_digtable
->back_val
= DM_DIG_BACKOFF_DEFAULT
;
172 dm_digtable
->back_range_max
= DM_DIG_BACKOFF_MAX
;
173 dm_digtable
->back_range_min
= DM_DIG_BACKOFF_MIN
;
174 dm_digtable
->pre_cck_pd_state
= CCK_PD_STAGE_MAX
;
175 dm_digtable
->cur_cck_pd_state
= CCK_PD_STAGE_MAX
;
178 static u8
rtl_init_gain_min_pwdb(struct ieee80211_hw
*hw
)
180 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
181 struct dig_t
*dm_digtable
= &rtlpriv
->dm_digtable
;
182 long rssi_val_min
= 0;
184 if ((dm_digtable
->curmultista_cstate
== DIG_MULTISTA_CONNECT
) &&
185 (dm_digtable
->cursta_cstate
== DIG_STA_CONNECT
)) {
186 if (rtlpriv
->dm
.entry_min_undec_sm_pwdb
!= 0)
188 (rtlpriv
->dm
.entry_min_undec_sm_pwdb
>
189 rtlpriv
->dm
.undec_sm_pwdb
) ?
190 rtlpriv
->dm
.undec_sm_pwdb
:
191 rtlpriv
->dm
.entry_min_undec_sm_pwdb
;
193 rssi_val_min
= rtlpriv
->dm
.undec_sm_pwdb
;
194 } else if (dm_digtable
->cursta_cstate
== DIG_STA_CONNECT
||
195 dm_digtable
->cursta_cstate
== DIG_STA_BEFORE_CONNECT
) {
196 rssi_val_min
= rtlpriv
->dm
.undec_sm_pwdb
;
197 } else if (dm_digtable
->curmultista_cstate
== DIG_MULTISTA_CONNECT
) {
198 rssi_val_min
= rtlpriv
->dm
.entry_min_undec_sm_pwdb
;
201 return (u8
) rssi_val_min
;
204 static void rtl8723ae_dm_false_alarm_counter_statistics(struct ieee80211_hw
*hw
)
207 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
208 struct false_alarm_statistics
*falsealm_cnt
= &(rtlpriv
->falsealm_cnt
);
210 ret_value
= rtl_get_bbreg(hw
, ROFDM_PHYCOUNTER1
, MASKDWORD
);
211 falsealm_cnt
->cnt_parity_fail
= ((ret_value
& 0xffff0000) >> 16);
213 ret_value
= rtl_get_bbreg(hw
, ROFDM_PHYCOUNTER2
, MASKDWORD
);
214 falsealm_cnt
->cnt_rate_illegal
= (ret_value
& 0xffff);
215 falsealm_cnt
->cnt_crc8_fail
= ((ret_value
& 0xffff0000) >> 16);
217 ret_value
= rtl_get_bbreg(hw
, ROFDM_PHYCOUNTER3
, MASKDWORD
);
218 falsealm_cnt
->cnt_mcs_fail
= (ret_value
& 0xffff);
219 falsealm_cnt
->cnt_ofdm_fail
= falsealm_cnt
->cnt_parity_fail
+
220 falsealm_cnt
->cnt_rate_illegal
+
221 falsealm_cnt
->cnt_crc8_fail
+ falsealm_cnt
->cnt_mcs_fail
;
223 rtl_set_bbreg(hw
, RCCK0_FALSEALARMREPORT
, BIT(14), 1);
224 ret_value
= rtl_get_bbreg(hw
, RCCK0_FACOUNTERLOWER
, MASKBYTE0
);
225 falsealm_cnt
->cnt_cck_fail
= ret_value
;
227 ret_value
= rtl_get_bbreg(hw
, RCCK0_FACOUNTERUPPER
, MASKBYTE3
);
228 falsealm_cnt
->cnt_cck_fail
+= (ret_value
& 0xff) << 8;
229 falsealm_cnt
->cnt_all
= (falsealm_cnt
->cnt_parity_fail
+
230 falsealm_cnt
->cnt_rate_illegal
+
231 falsealm_cnt
->cnt_crc8_fail
+
232 falsealm_cnt
->cnt_mcs_fail
+
233 falsealm_cnt
->cnt_cck_fail
);
235 rtl_set_bbreg(hw
, ROFDM1_LSTF
, 0x08000000, 1);
236 rtl_set_bbreg(hw
, ROFDM1_LSTF
, 0x08000000, 0);
237 rtl_set_bbreg(hw
, RCCK0_FALSEALARMREPORT
, 0x0000c000, 0);
238 rtl_set_bbreg(hw
, RCCK0_FALSEALARMREPORT
, 0x0000c000, 2);
240 RT_TRACE(rtlpriv
, COMP_DIG
, DBG_TRACE
,
241 "cnt_parity_fail = %d, cnt_rate_illegal = %d, "
242 "cnt_crc8_fail = %d, cnt_mcs_fail = %d\n",
243 falsealm_cnt
->cnt_parity_fail
,
244 falsealm_cnt
->cnt_rate_illegal
,
245 falsealm_cnt
->cnt_crc8_fail
, falsealm_cnt
->cnt_mcs_fail
);
247 RT_TRACE(rtlpriv
, COMP_DIG
, DBG_TRACE
,
248 "cnt_ofdm_fail = %x, cnt_cck_fail = %x, cnt_all = %x\n",
249 falsealm_cnt
->cnt_ofdm_fail
,
250 falsealm_cnt
->cnt_cck_fail
, falsealm_cnt
->cnt_all
);
253 static void rtl92c_dm_ctrl_initgain_by_fa(struct ieee80211_hw
*hw
)
255 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
256 struct dig_t
*dm_digtable
= &rtlpriv
->dm_digtable
;
257 u8 value_igi
= dm_digtable
->cur_igvalue
;
259 if (rtlpriv
->falsealm_cnt
.cnt_all
< DM_DIG_FA_TH0
)
261 else if (rtlpriv
->falsealm_cnt
.cnt_all
< DM_DIG_FA_TH1
)
263 else if (rtlpriv
->falsealm_cnt
.cnt_all
< DM_DIG_FA_TH2
)
268 value_igi
= clamp(value_igi
, (u8
)DM_DIG_FA_LOWER
, (u8
)DM_DIG_FA_UPPER
);
269 if (rtlpriv
->falsealm_cnt
.cnt_all
> 10000)
272 dm_digtable
->cur_igvalue
= value_igi
;
273 rtl8723ae_dm_write_dig(hw
);
276 static void rtl92c_dm_ctrl_initgain_by_rssi(struct ieee80211_hw
*hw
)
278 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
279 struct dig_t
*dgtbl
= &rtlpriv
->dm_digtable
;
281 if (rtlpriv
->falsealm_cnt
.cnt_all
> dgtbl
->fa_highthresh
) {
282 if ((dgtbl
->back_val
- 2) < dgtbl
->back_range_min
)
283 dgtbl
->back_val
= dgtbl
->back_range_min
;
285 dgtbl
->back_val
-= 2;
286 } else if (rtlpriv
->falsealm_cnt
.cnt_all
< dgtbl
->fa_lowthresh
) {
287 if ((dgtbl
->back_val
+ 2) > dgtbl
->back_range_max
)
288 dgtbl
->back_val
= dgtbl
->back_range_max
;
290 dgtbl
->back_val
+= 2;
293 if ((dgtbl
->rssi_val_min
+ 10 - dgtbl
->back_val
) >
295 dgtbl
->cur_igvalue
= dgtbl
->rx_gain_max
;
296 else if ((dgtbl
->rssi_val_min
+ 10 -
297 dgtbl
->back_val
) < dgtbl
->rx_gain_min
)
298 dgtbl
->cur_igvalue
= dgtbl
->rx_gain_min
;
300 dgtbl
->cur_igvalue
= dgtbl
->rssi_val_min
+ 10 - dgtbl
->back_val
;
302 RT_TRACE(rtlpriv
, COMP_DIG
, DBG_TRACE
,
303 "rssi_val_min = %x back_val %x\n",
304 dgtbl
->rssi_val_min
, dgtbl
->back_val
);
306 rtl8723ae_dm_write_dig(hw
);
309 static void rtl8723ae_dm_initial_gain_multi_sta(struct ieee80211_hw
*hw
)
311 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
312 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
313 struct dig_t
*dm_digtable
= &rtlpriv
->dm_digtable
;
314 long rssi_strength
= rtlpriv
->dm
.entry_min_undec_sm_pwdb
;
315 bool multi_sta
= false;
317 if (mac
->opmode
== NL80211_IFTYPE_ADHOC
)
321 (dm_digtable
->cursta_cstate
!= DIG_STA_DISCONNECT
)) {
322 rtlpriv
->initialized
= false;
323 dm_digtable
->dig_ext_port_stage
= DIG_EXT_PORT_STAGE_MAX
;
325 } else if (!rtlpriv
->initialized
) {
326 rtlpriv
->initialized
= true;
327 dm_digtable
->dig_ext_port_stage
= DIG_EXT_PORT_STAGE_0
;
328 dm_digtable
->cur_igvalue
= 0x20;
329 rtl8723ae_dm_write_dig(hw
);
332 if (dm_digtable
->curmultista_cstate
== DIG_MULTISTA_CONNECT
) {
333 if ((rssi_strength
< dm_digtable
->rssi_lowthresh
) &&
334 (dm_digtable
->dig_ext_port_stage
!= DIG_EXT_PORT_STAGE_1
)) {
336 if (dm_digtable
->dig_ext_port_stage
==
337 DIG_EXT_PORT_STAGE_2
) {
338 dm_digtable
->cur_igvalue
= 0x20;
339 rtl8723ae_dm_write_dig(hw
);
342 dm_digtable
->dig_ext_port_stage
= DIG_EXT_PORT_STAGE_1
;
343 } else if (rssi_strength
> dm_digtable
->rssi_highthresh
) {
344 dm_digtable
->dig_ext_port_stage
= DIG_EXT_PORT_STAGE_2
;
345 rtl92c_dm_ctrl_initgain_by_fa(hw
);
347 } else if (dm_digtable
->dig_ext_port_stage
!= DIG_EXT_PORT_STAGE_0
) {
348 dm_digtable
->dig_ext_port_stage
= DIG_EXT_PORT_STAGE_0
;
349 dm_digtable
->cur_igvalue
= 0x20;
350 rtl8723ae_dm_write_dig(hw
);
353 RT_TRACE(rtlpriv
, COMP_DIG
, DBG_TRACE
,
354 "curmultista_cstate = %x dig_ext_port_stage %x\n",
355 dm_digtable
->curmultista_cstate
,
356 dm_digtable
->dig_ext_port_stage
);
359 static void rtl8723ae_dm_initial_gain_sta(struct ieee80211_hw
*hw
)
361 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
362 struct dig_t
*dm_digtable
= &rtlpriv
->dm_digtable
;
364 RT_TRACE(rtlpriv
, COMP_DIG
, DBG_TRACE
,
365 "presta_cstate = %x, cursta_cstate = %x\n",
366 dm_digtable
->presta_cstate
,
367 dm_digtable
->cursta_cstate
);
369 if (dm_digtable
->presta_cstate
== dm_digtable
->cursta_cstate
||
370 dm_digtable
->cursta_cstate
== DIG_STA_BEFORE_CONNECT
||
371 dm_digtable
->cursta_cstate
== DIG_STA_CONNECT
) {
373 if (dm_digtable
->cursta_cstate
!= DIG_STA_DISCONNECT
) {
374 dm_digtable
->rssi_val_min
= rtl_init_gain_min_pwdb(hw
);
375 rtl92c_dm_ctrl_initgain_by_rssi(hw
);
378 dm_digtable
->rssi_val_min
= 0;
379 dm_digtable
->dig_ext_port_stage
= DIG_EXT_PORT_STAGE_MAX
;
380 dm_digtable
->back_val
= DM_DIG_BACKOFF_DEFAULT
;
381 dm_digtable
->cur_igvalue
= 0x20;
382 dm_digtable
->pre_igvalue
= 0;
383 rtl8723ae_dm_write_dig(hw
);
386 static void rtl8723ae_dm_cck_packet_detection_thresh(struct ieee80211_hw
*hw
)
388 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
389 struct dig_t
*dm_digtable
= &rtlpriv
->dm_digtable
;
391 if (dm_digtable
->cursta_cstate
== DIG_STA_CONNECT
) {
392 dm_digtable
->rssi_val_min
= rtl_init_gain_min_pwdb(hw
);
394 if (dm_digtable
->pre_cck_pd_state
== CCK_PD_STAGE_LowRssi
) {
395 if (dm_digtable
->rssi_val_min
<= 25)
396 dm_digtable
->cur_cck_pd_state
=
397 CCK_PD_STAGE_LowRssi
;
399 dm_digtable
->cur_cck_pd_state
=
400 CCK_PD_STAGE_HighRssi
;
402 if (dm_digtable
->rssi_val_min
<= 20)
403 dm_digtable
->cur_cck_pd_state
=
404 CCK_PD_STAGE_LowRssi
;
406 dm_digtable
->cur_cck_pd_state
=
407 CCK_PD_STAGE_HighRssi
;
410 dm_digtable
->cur_cck_pd_state
= CCK_PD_STAGE_MAX
;
413 if (dm_digtable
->pre_cck_pd_state
!= dm_digtable
->cur_cck_pd_state
) {
414 if (dm_digtable
->cur_cck_pd_state
== CCK_PD_STAGE_LowRssi
) {
415 if (rtlpriv
->falsealm_cnt
.cnt_cck_fail
> 800)
416 dm_digtable
->cur_cck_fa_state
=
419 dm_digtable
->cur_cck_fa_state
=
422 if (dm_digtable
->pre_cck_fa_state
!=
423 dm_digtable
->cur_cck_fa_state
) {
424 if (dm_digtable
->cur_cck_fa_state
==
426 rtl_set_bbreg(hw
, RCCK0_CCA
, MASKBYTE2
,
429 rtl_set_bbreg(hw
, RCCK0_CCA
, MASKBYTE2
,
432 dm_digtable
->pre_cck_fa_state
=
433 dm_digtable
->cur_cck_fa_state
;
436 rtl_set_bbreg(hw
, RCCK0_SYSTEM
, MASKBYTE1
, 0x40);
439 rtl_set_bbreg(hw
, RCCK0_CCA
, MASKBYTE2
, 0xcd);
440 rtl_set_bbreg(hw
, RCCK0_SYSTEM
, MASKBYTE1
, 0x47);
443 dm_digtable
->pre_cck_pd_state
= dm_digtable
->cur_cck_pd_state
;
446 RT_TRACE(rtlpriv
, COMP_DIG
, DBG_TRACE
,
447 "CCKPDStage=%x\n", dm_digtable
->cur_cck_pd_state
);
451 static void rtl8723ae_dm_ctrl_initgain_by_twoport(struct ieee80211_hw
*hw
)
453 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
454 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
455 struct dig_t
*dm_digtable
= &rtlpriv
->dm_digtable
;
457 if (mac
->act_scanning
== true)
460 if (mac
->link_state
>= MAC80211_LINKED
)
461 dm_digtable
->cursta_cstate
= DIG_STA_CONNECT
;
463 dm_digtable
->cursta_cstate
= DIG_STA_DISCONNECT
;
465 rtl8723ae_dm_initial_gain_sta(hw
);
466 rtl8723ae_dm_initial_gain_multi_sta(hw
);
467 rtl8723ae_dm_cck_packet_detection_thresh(hw
);
469 dm_digtable
->presta_cstate
= dm_digtable
->cursta_cstate
;
473 static void rtl8723ae_dm_dig(struct ieee80211_hw
*hw
)
475 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
476 struct dig_t
*dm_digtable
= &rtlpriv
->dm_digtable
;
478 if (rtlpriv
->dm
.dm_initialgain_enable
== false)
480 if (dm_digtable
->dig_enable_flag
== false)
483 rtl8723ae_dm_ctrl_initgain_by_twoport(hw
);
486 static void rtl8723ae_dm_init_dynamic_txpower(struct ieee80211_hw
*hw
)
488 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
490 rtlpriv
->dm
.dynamic_txpower_enable
= false;
492 rtlpriv
->dm
.last_dtp_lvl
= TXHIGHPWRLEVEL_NORMAL
;
493 rtlpriv
->dm
.dynamic_txhighpower_lvl
= TXHIGHPWRLEVEL_NORMAL
;
496 static void rtl8723ae_dm_dynamic_txpower(struct ieee80211_hw
*hw
)
498 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
499 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
500 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
503 if (!rtlpriv
->dm
.dynamic_txpower_enable
)
506 if (rtlpriv
->dm
.dm_flag
& HAL_DM_HIPWR_DISABLE
) {
507 rtlpriv
->dm
.dynamic_txhighpower_lvl
= TXHIGHPWRLEVEL_NORMAL
;
511 if ((mac
->link_state
< MAC80211_LINKED
) &&
512 (rtlpriv
->dm
.entry_min_undec_sm_pwdb
== 0)) {
513 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_TRACE
,
516 rtlpriv
->dm
.dynamic_txhighpower_lvl
= TXHIGHPWRLEVEL_NORMAL
;
518 rtlpriv
->dm
.last_dtp_lvl
= TXHIGHPWRLEVEL_NORMAL
;
522 if (mac
->link_state
>= MAC80211_LINKED
) {
523 if (mac
->opmode
== NL80211_IFTYPE_ADHOC
) {
524 undec_sm_pwdb
= rtlpriv
->dm
.entry_min_undec_sm_pwdb
;
525 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_LOUD
,
526 "AP Client PWDB = 0x%lx\n",
529 undec_sm_pwdb
= rtlpriv
->dm
.undec_sm_pwdb
;
530 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_LOUD
,
531 "STA Default Port PWDB = 0x%lx\n",
535 undec_sm_pwdb
= rtlpriv
->dm
.entry_min_undec_sm_pwdb
;
537 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_LOUD
,
538 "AP Ext Port PWDB = 0x%lx\n",
542 if (undec_sm_pwdb
>= TX_POWER_NEAR_FIELD_THRESH_LVL2
) {
543 rtlpriv
->dm
.dynamic_txhighpower_lvl
= TXHIGHPWRLEVEL_LEVEL1
;
544 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_LOUD
,
545 "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x0)\n");
546 } else if ((undec_sm_pwdb
< (TX_POWER_NEAR_FIELD_THRESH_LVL2
- 3)) &&
547 (undec_sm_pwdb
>= TX_POWER_NEAR_FIELD_THRESH_LVL1
)) {
548 rtlpriv
->dm
.dynamic_txhighpower_lvl
= TXHIGHPWRLEVEL_LEVEL1
;
549 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_LOUD
,
550 "TXHIGHPWRLEVEL_LEVEL1 (TxPwr=0x10)\n");
551 } else if (undec_sm_pwdb
< (TX_POWER_NEAR_FIELD_THRESH_LVL1
- 5)) {
552 rtlpriv
->dm
.dynamic_txhighpower_lvl
= TXHIGHPWRLEVEL_NORMAL
;
553 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_LOUD
,
554 "TXHIGHPWRLEVEL_NORMAL\n");
557 if ((rtlpriv
->dm
.dynamic_txhighpower_lvl
!= rtlpriv
->dm
.last_dtp_lvl
)) {
558 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_LOUD
,
559 "PHY_SetTxPowerLevel8192S() Channel = %d\n",
560 rtlphy
->current_channel
);
561 rtl8723ae_phy_set_txpower_level(hw
, rtlphy
->current_channel
);
564 rtlpriv
->dm
.last_dtp_lvl
= rtlpriv
->dm
.dynamic_txhighpower_lvl
;
567 void rtl8723ae_dm_write_dig(struct ieee80211_hw
*hw
)
569 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
570 struct dig_t
*dm_digtable
= &rtlpriv
->dm_digtable
;
572 RT_TRACE(rtlpriv
, COMP_DIG
, DBG_LOUD
,
573 "cur_igvalue = 0x%x, "
574 "pre_igvalue = 0x%x, back_val = %d\n",
575 dm_digtable
->cur_igvalue
, dm_digtable
->pre_igvalue
,
576 dm_digtable
->back_val
);
578 if (dm_digtable
->pre_igvalue
!= dm_digtable
->cur_igvalue
) {
579 rtl_set_bbreg(hw
, ROFDM0_XAAGCCORE1
, 0x7f,
580 dm_digtable
->cur_igvalue
);
581 rtl_set_bbreg(hw
, ROFDM0_XBAGCCORE1
, 0x7f,
582 dm_digtable
->cur_igvalue
);
584 dm_digtable
->pre_igvalue
= dm_digtable
->cur_igvalue
;
588 static void rtl8723ae_dm_pwdmonitor(struct ieee80211_hw
*hw
)
592 void rtl8723ae_dm_init_edca_turbo(struct ieee80211_hw
*hw
)
594 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
596 rtlpriv
->dm
.current_turbo_edca
= false;
597 rtlpriv
->dm
.is_any_nonbepkts
= false;
598 rtlpriv
->dm
.is_cur_rdlstate
= false;
601 static void rtl8723ae_dm_check_edca_turbo(struct ieee80211_hw
*hw
)
603 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
604 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
605 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
607 u64 cur_txok_cnt
= 0;
608 u64 cur_rxok_cnt
= 0;
609 u32 edca_be_ul
= 0x5ea42b;
610 u32 edca_be_dl
= 0x5ea42b;
611 bool bt_change_edca
= false;
613 if ((mac
->last_bt_edca_ul
!= rtlpcipriv
->bt_coexist
.bt_edca_ul
) ||
614 (mac
->last_bt_edca_dl
!= rtlpcipriv
->bt_coexist
.bt_edca_dl
)) {
615 rtlpriv
->dm
.current_turbo_edca
= false;
616 mac
->last_bt_edca_ul
= rtlpcipriv
->bt_coexist
.bt_edca_ul
;
617 mac
->last_bt_edca_dl
= rtlpcipriv
->bt_coexist
.bt_edca_dl
;
620 if (rtlpcipriv
->bt_coexist
.bt_edca_ul
!= 0) {
621 edca_be_ul
= rtlpcipriv
->bt_coexist
.bt_edca_ul
;
622 bt_change_edca
= true;
625 if (rtlpcipriv
->bt_coexist
.bt_edca_dl
!= 0) {
626 edca_be_ul
= rtlpcipriv
->bt_coexist
.bt_edca_dl
;
627 bt_change_edca
= true;
630 if (mac
->link_state
!= MAC80211_LINKED
) {
631 rtlpriv
->dm
.current_turbo_edca
= false;
635 if ((!mac
->ht_enable
) && (!rtlpcipriv
->bt_coexist
.bt_coexistence
)) {
636 if (!(edca_be_ul
& 0xffff0000))
637 edca_be_ul
|= 0x005e0000;
639 if (!(edca_be_dl
& 0xffff0000))
640 edca_be_dl
|= 0x005e0000;
643 if ((bt_change_edca
) || ((!rtlpriv
->dm
.is_any_nonbepkts
) &&
644 (!rtlpriv
->dm
.disable_framebursting
))) {
646 cur_txok_cnt
= rtlpriv
->stats
.txbytesunicast
-
648 cur_rxok_cnt
= rtlpriv
->stats
.rxbytesunicast
-
651 if (cur_rxok_cnt
> 4 * cur_txok_cnt
) {
652 if (!rtlpriv
->dm
.is_cur_rdlstate
||
653 !rtlpriv
->dm
.current_turbo_edca
) {
654 rtl_write_dword(rtlpriv
,
657 rtlpriv
->dm
.is_cur_rdlstate
= true;
660 if (rtlpriv
->dm
.is_cur_rdlstate
||
661 !rtlpriv
->dm
.current_turbo_edca
) {
662 rtl_write_dword(rtlpriv
,
665 rtlpriv
->dm
.is_cur_rdlstate
= false;
668 rtlpriv
->dm
.current_turbo_edca
= true;
670 if (rtlpriv
->dm
.current_turbo_edca
) {
672 rtlpriv
->cfg
->ops
->set_hw_reg(hw
,
675 rtlpriv
->dm
.current_turbo_edca
= false;
679 rtlpriv
->dm
.is_any_nonbepkts
= false;
680 mac
->last_txok_cnt
= rtlpriv
->stats
.txbytesunicast
;
681 mac
->last_rxok_cnt
= rtlpriv
->stats
.rxbytesunicast
;
684 static void rtl8723ae_dm_initialize_txpower_tracking(struct ieee80211_hw
*hw
)
686 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
688 rtlpriv
->dm
.txpower_tracking
= true;
689 rtlpriv
->dm
.txpower_trackinginit
= false;
691 RT_TRACE(rtlpriv
, COMP_POWER_TRACKING
, DBG_LOUD
,
692 "pMgntInfo->txpower_tracking = %d\n",
693 rtlpriv
->dm
.txpower_tracking
);
696 void rtl8723ae_dm_init_rate_adaptive_mask(struct ieee80211_hw
*hw
)
698 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
699 struct rate_adaptive
*p_ra
= &(rtlpriv
->ra
);
701 p_ra
->ratr_state
= DM_RATR_STA_INIT
;
702 p_ra
->pre_ratr_state
= DM_RATR_STA_INIT
;
704 if (rtlpriv
->dm
.dm_type
== DM_TYPE_BYDRIVER
)
705 rtlpriv
->dm
.useramask
= true;
707 rtlpriv
->dm
.useramask
= false;
710 static void rtl8723ae_dm_refresh_rate_adaptive_mask(struct ieee80211_hw
*hw
)
712 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
713 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
714 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
715 struct rate_adaptive
*p_ra
= &(rtlpriv
->ra
);
716 u32 low_rssithresh_for_ra
, high_rssithresh_for_ra
;
717 struct ieee80211_sta
*sta
= NULL
;
719 if (is_hal_stop(rtlhal
)) {
720 RT_TRACE(rtlpriv
, COMP_RATE
, DBG_LOUD
,
721 " driver is going to unload\n");
725 if (!rtlpriv
->dm
.useramask
) {
726 RT_TRACE(rtlpriv
, COMP_RATE
, DBG_LOUD
,
727 " driver does not control rate adaptive mask\n");
731 if (mac
->link_state
== MAC80211_LINKED
&&
732 mac
->opmode
== NL80211_IFTYPE_STATION
) {
733 switch (p_ra
->pre_ratr_state
) {
734 case DM_RATR_STA_HIGH
:
735 high_rssithresh_for_ra
= 50;
736 low_rssithresh_for_ra
= 20;
738 case DM_RATR_STA_MIDDLE
:
739 high_rssithresh_for_ra
= 55;
740 low_rssithresh_for_ra
= 20;
742 case DM_RATR_STA_LOW
:
743 high_rssithresh_for_ra
= 50;
744 low_rssithresh_for_ra
= 25;
747 high_rssithresh_for_ra
= 50;
748 low_rssithresh_for_ra
= 20;
752 if (rtlpriv
->dm
.undec_sm_pwdb
> high_rssithresh_for_ra
)
753 p_ra
->ratr_state
= DM_RATR_STA_HIGH
;
754 else if (rtlpriv
->dm
.undec_sm_pwdb
> low_rssithresh_for_ra
)
755 p_ra
->ratr_state
= DM_RATR_STA_MIDDLE
;
757 p_ra
->ratr_state
= DM_RATR_STA_LOW
;
759 if (p_ra
->pre_ratr_state
!= p_ra
->ratr_state
) {
760 RT_TRACE(rtlpriv
, COMP_RATE
, DBG_LOUD
,
762 rtlpriv
->dm
.undec_sm_pwdb
);
763 RT_TRACE(rtlpriv
, COMP_RATE
, DBG_LOUD
,
764 "RSSI_LEVEL = %d\n", p_ra
->ratr_state
);
765 RT_TRACE(rtlpriv
, COMP_RATE
, DBG_LOUD
,
766 "PreState = %d, CurState = %d\n",
767 p_ra
->pre_ratr_state
, p_ra
->ratr_state
);
770 sta
= rtl_find_sta(hw
, mac
->bssid
);
772 rtlpriv
->cfg
->ops
->update_rate_tbl(hw
, sta
,
776 p_ra
->pre_ratr_state
= p_ra
->ratr_state
;
781 static void rtl8723ae_dm_init_dynamic_bpowersaving(struct ieee80211_hw
*hw
)
783 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
785 rtlpriv
->dm_pstable
.pre_ccastate
= CCA_MAX
;
786 rtlpriv
->dm_pstable
.cur_ccasate
= CCA_MAX
;
787 rtlpriv
->dm_pstable
.pre_rfstate
= RF_MAX
;
788 rtlpriv
->dm_pstable
.cur_rfstate
= RF_MAX
;
789 rtlpriv
->dm_pstable
.rssi_val_min
= 0;
792 void rtl8723ae_dm_rf_saving(struct ieee80211_hw
*hw
, u8 force_in_normal
)
794 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
795 struct ps_t
*dm_pstable
= &rtlpriv
->dm_pstable
;
797 if (!rtlpriv
->reg_init
) {
798 rtlpriv
->reg_874
= (rtl_get_bbreg(hw
, RFPGA0_XCD_RFINTERFACESW
,
799 MASKDWORD
) & 0x1CC000) >> 14;
801 rtlpriv
->reg_c70
= (rtl_get_bbreg(hw
, ROFDM0_AGCPARAMETER1
,
802 MASKDWORD
) & BIT(3)) >> 3;
804 rtlpriv
->reg_85c
= (rtl_get_bbreg(hw
, RFPGA0_XCD_SWITCHCONTROL
,
805 MASKDWORD
) & 0xFF000000) >> 24;
807 rtlpriv
->reg_a74
= (rtl_get_bbreg(hw
, 0xa74, MASKDWORD
) &
810 rtlpriv
->reg_init
= true;
813 if (!force_in_normal
) {
814 if (dm_pstable
->rssi_val_min
!= 0) {
815 if (dm_pstable
->pre_rfstate
== RF_NORMAL
) {
816 if (dm_pstable
->rssi_val_min
>= 30)
817 dm_pstable
->cur_rfstate
= RF_SAVE
;
819 dm_pstable
->cur_rfstate
= RF_NORMAL
;
821 if (dm_pstable
->rssi_val_min
<= 25)
822 dm_pstable
->cur_rfstate
= RF_NORMAL
;
824 dm_pstable
->cur_rfstate
= RF_SAVE
;
827 dm_pstable
->cur_rfstate
= RF_MAX
;
830 dm_pstable
->cur_rfstate
= RF_NORMAL
;
833 if (dm_pstable
->pre_rfstate
!= dm_pstable
->cur_rfstate
) {
834 if (dm_pstable
->cur_rfstate
== RF_SAVE
) {
836 rtl_set_bbreg(hw
, RFPGA0_XCD_RFINTERFACESW
,
838 rtl_set_bbreg(hw
, RFPGA0_XCD_RFINTERFACESW
,
840 rtl_set_bbreg(hw
, ROFDM0_AGCPARAMETER1
, BIT(3), 0);
841 rtl_set_bbreg(hw
, RFPGA0_XCD_SWITCHCONTROL
,
843 rtl_set_bbreg(hw
, RFPGA0_XCD_RFINTERFACESW
,
845 rtl_set_bbreg(hw
, 0xa74, 0xF000, 0x3);
846 rtl_set_bbreg(hw
, 0x818, BIT(28), 0x0);
847 rtl_set_bbreg(hw
, 0x818, BIT(28), 0x1);
849 rtl_set_bbreg(hw
, RFPGA0_XCD_RFINTERFACESW
,
850 0x1CC000, rtlpriv
->reg_874
);
851 rtl_set_bbreg(hw
, ROFDM0_AGCPARAMETER1
, BIT(3),
853 rtl_set_bbreg(hw
, RFPGA0_XCD_SWITCHCONTROL
, 0xFF000000,
855 rtl_set_bbreg(hw
, 0xa74, 0xF000, rtlpriv
->reg_a74
);
856 rtl_set_bbreg(hw
, 0x818, BIT(28), 0x0);
857 rtl_set_bbreg(hw
, RFPGA0_XCD_RFINTERFACESW
,
861 dm_pstable
->pre_rfstate
= dm_pstable
->cur_rfstate
;
865 static void rtl8723ae_dm_dynamic_bpowersaving(struct ieee80211_hw
*hw
)
867 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
868 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
869 struct ps_t
*dm_pstable
= &rtlpriv
->dm_pstable
;
871 if (((mac
->link_state
== MAC80211_NOLINK
)) &&
872 (rtlpriv
->dm
.entry_min_undec_sm_pwdb
== 0)) {
873 dm_pstable
->rssi_val_min
= 0;
874 RT_TRACE(rtlpriv
, DBG_LOUD
, DBG_LOUD
,
875 "Not connected to any\n");
878 if (mac
->link_state
== MAC80211_LINKED
) {
879 if (mac
->opmode
== NL80211_IFTYPE_ADHOC
) {
880 dm_pstable
->rssi_val_min
=
881 rtlpriv
->dm
.entry_min_undec_sm_pwdb
;
882 RT_TRACE(rtlpriv
, DBG_LOUD
, DBG_LOUD
,
883 "AP Client PWDB = 0x%lx\n",
884 dm_pstable
->rssi_val_min
);
886 dm_pstable
->rssi_val_min
= rtlpriv
->dm
.undec_sm_pwdb
;
887 RT_TRACE(rtlpriv
, DBG_LOUD
, DBG_LOUD
,
888 "STA Default Port PWDB = 0x%lx\n",
889 dm_pstable
->rssi_val_min
);
892 dm_pstable
->rssi_val_min
= rtlpriv
->dm
.entry_min_undec_sm_pwdb
;
894 RT_TRACE(rtlpriv
, DBG_LOUD
, DBG_LOUD
,
895 "AP Ext Port PWDB = 0x%lx\n",
896 dm_pstable
->rssi_val_min
);
899 rtl8723ae_dm_rf_saving(hw
, false);
902 void rtl8723ae_dm_init(struct ieee80211_hw
*hw
)
904 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
906 rtlpriv
->dm
.dm_type
= DM_TYPE_BYDRIVER
;
907 rtl8723ae_dm_diginit(hw
);
908 rtl8723ae_dm_init_dynamic_txpower(hw
);
909 rtl8723ae_dm_init_edca_turbo(hw
);
910 rtl8723ae_dm_init_rate_adaptive_mask(hw
);
911 rtl8723ae_dm_initialize_txpower_tracking(hw
);
912 rtl8723ae_dm_init_dynamic_bpowersaving(hw
);
915 void rtl8723ae_dm_watchdog(struct ieee80211_hw
*hw
)
917 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
918 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
919 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
920 bool fw_current_inpsmode
= false;
921 bool fw_ps_awake
= true;
922 rtlpriv
->cfg
->ops
->get_hw_reg(hw
, HW_VAR_FW_PSMODE_STATUS
,
923 (u8
*) (&fw_current_inpsmode
));
924 rtlpriv
->cfg
->ops
->get_hw_reg(hw
, HW_VAR_FWLPS_RF_ON
,
925 (u8
*) (&fw_ps_awake
));
927 if (ppsc
->p2p_ps_info
.p2p_ps_mode
)
930 if ((ppsc
->rfpwr_state
== ERFON
) &&
931 ((!fw_current_inpsmode
) && fw_ps_awake
) &&
932 (!ppsc
->rfchange_inprogress
)) {
933 rtl8723ae_dm_pwdmonitor(hw
);
934 rtl8723ae_dm_dig(hw
);
935 rtl8723ae_dm_false_alarm_counter_statistics(hw
);
936 rtl8723ae_dm_dynamic_bpowersaving(hw
);
937 rtl8723ae_dm_dynamic_txpower(hw
);
938 rtl8723ae_dm_refresh_rate_adaptive_mask(hw
);
939 rtl8723ae_dm_bt_coexist(hw
);
940 rtl8723ae_dm_check_edca_turbo(hw
);
942 if (rtlpcipriv
->bt_coexist
.init_set
)
943 rtl_write_byte(rtlpriv
, 0x76e, 0xc);
946 static void rtl8723ae_dm_init_bt_coexist(struct ieee80211_hw
*hw
)
948 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
949 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
951 rtlpcipriv
->bt_coexist
.bt_rfreg_origin_1e
952 = rtl_get_rfreg(hw
, (enum radio_path
)0, RF_RCK1
, 0xfffff);
953 rtlpcipriv
->bt_coexist
.bt_rfreg_origin_1f
954 = rtl_get_rfreg(hw
, (enum radio_path
)0, RF_RCK2
, 0xf0);
956 rtlpcipriv
->bt_coexist
.cstate
= 0;
957 rtlpcipriv
->bt_coexist
.previous_state
= 0;
958 rtlpcipriv
->bt_coexist
.cstate_h
= 0;
959 rtlpcipriv
->bt_coexist
.previous_state_h
= 0;
960 rtlpcipriv
->bt_coexist
.lps_counter
= 0;
962 /* Enable counter statistics */
963 rtl_write_byte(rtlpriv
, 0x76e, 0x4);
964 rtl_write_byte(rtlpriv
, 0x778, 0x3);
965 rtl_write_byte(rtlpriv
, 0x40, 0x20);
967 rtlpcipriv
->bt_coexist
.init_set
= true;
970 void rtl8723ae_dm_bt_coexist(struct ieee80211_hw
*hw
)
972 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
973 struct rtl_pci_priv
*rtlpcipriv
= rtl_pcipriv(hw
);
975 if (!rtlpcipriv
->bt_coexist
.bt_coexistence
) {
976 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
977 "[DM]{BT], BT not exist!!\n");
981 if (!rtlpcipriv
->bt_coexist
.init_set
) {
982 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
983 "[DM][BT], rtl8723ae_dm_bt_coexist()\n");
985 rtl8723ae_dm_init_bt_coexist(hw
);
988 tmp_byte
= rtl_read_byte(rtlpriv
, 0x40);
989 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_LOUD
,
990 "[DM][BT], 0x40 is 0x%x", tmp_byte
);
991 RT_TRACE(rtlpriv
, COMP_BT_COEXIST
, DBG_DMESG
,
992 "[DM][BT], bt_dm_coexist start");
993 rtl8723ae_dm_bt_coexist_8723(hw
);