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 bool _rtl92c_phy_config_mac_with_headerfile(struct ieee80211_hw
*hw
);
43 u32
rtl92c_phy_query_rf_reg(struct ieee80211_hw
*hw
,
44 enum radio_path rfpath
, u32 regaddr
, u32 bitmask
)
46 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
47 u32 original_value
, readback_value
, bitshift
;
48 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
50 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
,
51 "regaddr(%#x), rfpath(%#x), bitmask(%#x)\n",
52 regaddr
, rfpath
, bitmask
);
54 spin_lock(&rtlpriv
->locks
.rf_lock
);
56 if (rtlphy
->rf_mode
!= RF_OP_BY_FW
) {
57 original_value
= _rtl92c_phy_rf_serial_read(hw
,
60 original_value
= _rtl92c_phy_fw_rf_serial_read(hw
,
64 bitshift
= _rtl92c_phy_calculate_bit_shift(bitmask
);
65 readback_value
= (original_value
& bitmask
) >> bitshift
;
67 spin_unlock(&rtlpriv
->locks
.rf_lock
);
69 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
,
70 "regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n",
71 regaddr
, rfpath
, bitmask
, original_value
);
73 return readback_value
;
76 bool rtl92c_phy_mac_config(struct ieee80211_hw
*hw
)
78 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
79 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
80 bool is92c
= IS_92C_SERIAL(rtlhal
->version
);
81 bool rtstatus
= _rtl92c_phy_config_mac_with_headerfile(hw
);
84 rtl_write_byte(rtlpriv
, 0x14, 0x71);
86 rtl_write_byte(rtlpriv
, 0x04CA, 0x0A);
90 bool rtl92c_phy_bb_config(struct ieee80211_hw
*hw
)
93 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
96 u8 reg_hwparafile
= 1;
98 _rtl92c_phy_init_bb_rf_register_definition(hw
);
99 regval
= rtl_read_word(rtlpriv
, REG_SYS_FUNC_EN
);
100 rtl_write_word(rtlpriv
, REG_SYS_FUNC_EN
,
101 regval
| BIT(13) | BIT(0) | BIT(1));
102 rtl_write_byte(rtlpriv
, REG_AFE_PLL_CTRL
, 0x83);
103 rtl_write_byte(rtlpriv
, REG_AFE_PLL_CTRL
+ 1, 0xdb);
104 rtl_write_byte(rtlpriv
, REG_RF_CTRL
, RF_EN
| RF_RSTB
| RF_SDMRSTB
);
105 rtl_write_byte(rtlpriv
, REG_SYS_FUNC_EN
,
106 FEN_PPLL
| FEN_PCIEA
| FEN_DIO_PCIE
|
107 FEN_BB_GLB_RSTn
| FEN_BBRSTB
);
108 rtl_write_byte(rtlpriv
, REG_AFE_XTAL_CTRL
+ 1, 0x80);
109 regvaldw
= rtl_read_dword(rtlpriv
, REG_LEDCFG0
);
110 rtl_write_dword(rtlpriv
, REG_LEDCFG0
, regvaldw
| BIT(23));
111 if (reg_hwparafile
== 1)
112 rtstatus
= _rtl92c_phy_bb8192c_config_parafile(hw
);
116 void rtl92ce_phy_set_rf_reg(struct ieee80211_hw
*hw
,
117 enum radio_path rfpath
,
118 u32 regaddr
, u32 bitmask
, u32 data
)
120 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
121 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
122 u32 original_value
, bitshift
;
124 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
,
125 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
126 regaddr
, bitmask
, data
, rfpath
);
128 spin_lock(&rtlpriv
->locks
.rf_lock
);
130 if (rtlphy
->rf_mode
!= RF_OP_BY_FW
) {
131 if (bitmask
!= RFREG_OFFSET_MASK
) {
132 original_value
= _rtl92c_phy_rf_serial_read(hw
,
135 bitshift
= _rtl92c_phy_calculate_bit_shift(bitmask
);
137 ((original_value
& (~bitmask
)) |
141 _rtl92c_phy_rf_serial_write(hw
, rfpath
, regaddr
, data
);
143 if (bitmask
!= RFREG_OFFSET_MASK
) {
144 original_value
= _rtl92c_phy_fw_rf_serial_read(hw
,
147 bitshift
= _rtl92c_phy_calculate_bit_shift(bitmask
);
149 ((original_value
& (~bitmask
)) |
152 _rtl92c_phy_fw_rf_serial_write(hw
, rfpath
, regaddr
, data
);
155 spin_unlock(&rtlpriv
->locks
.rf_lock
);
157 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
,
158 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
159 regaddr
, bitmask
, data
, rfpath
);
162 static bool _rtl92c_phy_config_mac_with_headerfile(struct ieee80211_hw
*hw
)
164 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
169 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
, "Read Rtl819XMACPHY_Array\n");
170 arraylength
= MAC_2T_ARRAYLENGTH
;
171 ptrarray
= RTL8192CEMAC_2T_ARRAY
;
172 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
, "Img:RTL8192CEMAC_2T_ARRAY\n");
173 for (i
= 0; i
< arraylength
; i
= i
+ 2)
174 rtl_write_byte(rtlpriv
, ptrarray
[i
], (u8
) ptrarray
[i
+ 1]);
178 bool _rtl92ce_phy_config_bb_with_headerfile(struct ieee80211_hw
*hw
,
182 u32
*phy_regarray_table
;
183 u32
*agctab_array_table
;
184 u16 phy_reg_arraylen
, agctab_arraylen
;
185 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
186 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
188 if (IS_92C_SERIAL(rtlhal
->version
)) {
189 agctab_arraylen
= AGCTAB_2TARRAYLENGTH
;
190 agctab_array_table
= RTL8192CEAGCTAB_2TARRAY
;
191 phy_reg_arraylen
= PHY_REG_2TARRAY_LENGTH
;
192 phy_regarray_table
= RTL8192CEPHY_REG_2TARRAY
;
194 agctab_arraylen
= AGCTAB_1TARRAYLENGTH
;
195 agctab_array_table
= RTL8192CEAGCTAB_1TARRAY
;
196 phy_reg_arraylen
= PHY_REG_1TARRAY_LENGTH
;
197 phy_regarray_table
= RTL8192CEPHY_REG_1TARRAY
;
199 if (configtype
== BASEBAND_CONFIG_PHY_REG
) {
200 for (i
= 0; i
< phy_reg_arraylen
; i
= i
+ 2) {
201 if (phy_regarray_table
[i
] == 0xfe)
203 else if (phy_regarray_table
[i
] == 0xfd)
205 else if (phy_regarray_table
[i
] == 0xfc)
207 else if (phy_regarray_table
[i
] == 0xfb)
209 else if (phy_regarray_table
[i
] == 0xfa)
211 else if (phy_regarray_table
[i
] == 0xf9)
213 rtl_set_bbreg(hw
, phy_regarray_table
[i
], MASKDWORD
,
214 phy_regarray_table
[i
+ 1]);
216 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
217 "The phy_regarray_table[0] is %x Rtl819XPHY_REGArray[1] is %x\n",
218 phy_regarray_table
[i
],
219 phy_regarray_table
[i
+ 1]);
221 } else if (configtype
== BASEBAND_CONFIG_AGC_TAB
) {
222 for (i
= 0; i
< agctab_arraylen
; i
= i
+ 2) {
223 rtl_set_bbreg(hw
, agctab_array_table
[i
], MASKDWORD
,
224 agctab_array_table
[i
+ 1]);
226 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
227 "The agctab_array_table[0] is %x Rtl819XPHY_REGArray[1] is %x\n",
228 agctab_array_table
[i
],
229 agctab_array_table
[i
+ 1]);
235 bool _rtl92ce_phy_config_bb_with_pgheaderfile(struct ieee80211_hw
*hw
,
238 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
240 u32
*phy_regarray_table_pg
;
241 u16 phy_regarray_pg_len
;
243 phy_regarray_pg_len
= PHY_REG_ARRAY_PGLENGTH
;
244 phy_regarray_table_pg
= RTL8192CEPHY_REG_ARRAY_PG
;
246 if (configtype
== BASEBAND_CONFIG_PHY_REG
) {
247 for (i
= 0; i
< phy_regarray_pg_len
; i
= i
+ 3) {
248 if (phy_regarray_table_pg
[i
] == 0xfe)
250 else if (phy_regarray_table_pg
[i
] == 0xfd)
252 else if (phy_regarray_table_pg
[i
] == 0xfc)
254 else if (phy_regarray_table_pg
[i
] == 0xfb)
256 else if (phy_regarray_table_pg
[i
] == 0xfa)
258 else if (phy_regarray_table_pg
[i
] == 0xf9)
261 _rtl92c_store_pwrIndex_diffrate_offset(hw
,
262 phy_regarray_table_pg
[i
],
263 phy_regarray_table_pg
[i
+ 1],
264 phy_regarray_table_pg
[i
+ 2]);
268 RT_TRACE(rtlpriv
, COMP_SEND
, DBG_TRACE
,
269 "configtype != BaseBand_Config_PHY_REG\n");
274 bool rtl92c_phy_config_rf_with_headerfile(struct ieee80211_hw
*hw
,
275 enum radio_path rfpath
)
279 u32
*radioa_array_table
;
280 u32
*radiob_array_table
;
281 u16 radioa_arraylen
, radiob_arraylen
;
282 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
283 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
285 if (IS_92C_SERIAL(rtlhal
->version
)) {
286 radioa_arraylen
= RADIOA_2TARRAYLENGTH
;
287 radioa_array_table
= RTL8192CERADIOA_2TARRAY
;
288 radiob_arraylen
= RADIOB_2TARRAYLENGTH
;
289 radiob_array_table
= RTL8192CE_RADIOB_2TARRAY
;
290 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
291 "Radio_A:RTL8192CERADIOA_2TARRAY\n");
292 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
293 "Radio_B:RTL8192CE_RADIOB_2TARRAY\n");
295 radioa_arraylen
= RADIOA_1TARRAYLENGTH
;
296 radioa_array_table
= RTL8192CE_RADIOA_1TARRAY
;
297 radiob_arraylen
= RADIOB_1TARRAYLENGTH
;
298 radiob_array_table
= RTL8192CE_RADIOB_1TARRAY
;
299 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
300 "Radio_A:RTL8192CE_RADIOA_1TARRAY\n");
301 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
302 "Radio_B:RTL8192CE_RADIOB_1TARRAY\n");
304 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
, "Radio No %x\n", rfpath
);
307 for (i
= 0; i
< radioa_arraylen
; i
= i
+ 2) {
308 if (radioa_array_table
[i
] == 0xfe)
310 else if (radioa_array_table
[i
] == 0xfd)
312 else if (radioa_array_table
[i
] == 0xfc)
314 else if (radioa_array_table
[i
] == 0xfb)
316 else if (radioa_array_table
[i
] == 0xfa)
318 else if (radioa_array_table
[i
] == 0xf9)
321 rtl_set_rfreg(hw
, rfpath
, radioa_array_table
[i
],
323 radioa_array_table
[i
+ 1]);
329 for (i
= 0; i
< radiob_arraylen
; i
= i
+ 2) {
330 if (radiob_array_table
[i
] == 0xfe) {
332 } else if (radiob_array_table
[i
] == 0xfd)
334 else if (radiob_array_table
[i
] == 0xfc)
336 else if (radiob_array_table
[i
] == 0xfb)
338 else if (radiob_array_table
[i
] == 0xfa)
340 else if (radiob_array_table
[i
] == 0xf9)
343 rtl_set_rfreg(hw
, rfpath
, radiob_array_table
[i
],
345 radiob_array_table
[i
+ 1]);
351 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
352 "switch case not processed\n");
355 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
356 "switch case not processed\n");
362 void rtl92ce_phy_set_bw_mode_callback(struct ieee80211_hw
*hw
)
364 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
365 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
366 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
367 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
371 RT_TRACE(rtlpriv
, COMP_SCAN
, DBG_TRACE
, "Switch to %s bandwidth\n",
372 rtlphy
->current_chan_bw
== HT_CHANNEL_WIDTH_20
?
375 if (is_hal_stop(rtlhal
)) {
376 rtlphy
->set_bwmode_inprogress
= false;
380 reg_bw_opmode
= rtl_read_byte(rtlpriv
, REG_BWOPMODE
);
381 reg_prsr_rsc
= rtl_read_byte(rtlpriv
, REG_RRSR
+ 2);
383 switch (rtlphy
->current_chan_bw
) {
384 case HT_CHANNEL_WIDTH_20
:
385 reg_bw_opmode
|= BW_OPMODE_20MHZ
;
386 rtl_write_byte(rtlpriv
, REG_BWOPMODE
, reg_bw_opmode
);
388 case HT_CHANNEL_WIDTH_20_40
:
389 reg_bw_opmode
&= ~BW_OPMODE_20MHZ
;
390 rtl_write_byte(rtlpriv
, REG_BWOPMODE
, reg_bw_opmode
);
392 (reg_prsr_rsc
& 0x90) | (mac
->cur_40_prime_sc
<< 5);
393 rtl_write_byte(rtlpriv
, REG_RRSR
+ 2, reg_prsr_rsc
);
396 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
397 "unknown bandwidth: %#X\n", rtlphy
->current_chan_bw
);
401 switch (rtlphy
->current_chan_bw
) {
402 case HT_CHANNEL_WIDTH_20
:
403 rtl_set_bbreg(hw
, RFPGA0_RFMOD
, BRFMOD
, 0x0);
404 rtl_set_bbreg(hw
, RFPGA1_RFMOD
, BRFMOD
, 0x0);
405 rtl_set_bbreg(hw
, RFPGA0_ANALOGPARAMETER2
, BIT(10), 1);
407 case HT_CHANNEL_WIDTH_20_40
:
408 rtl_set_bbreg(hw
, RFPGA0_RFMOD
, BRFMOD
, 0x1);
409 rtl_set_bbreg(hw
, RFPGA1_RFMOD
, BRFMOD
, 0x1);
411 rtl_set_bbreg(hw
, RCCK0_SYSTEM
, BCCK_SIDEBAND
,
412 (mac
->cur_40_prime_sc
>> 1));
413 rtl_set_bbreg(hw
, ROFDM1_LSTF
, 0xC00, mac
->cur_40_prime_sc
);
414 rtl_set_bbreg(hw
, RFPGA0_ANALOGPARAMETER2
, BIT(10), 0);
416 rtl_set_bbreg(hw
, 0x818, (BIT(26) | BIT(27)),
417 (mac
->cur_40_prime_sc
==
418 HAL_PRIME_CHNL_OFFSET_LOWER
) ? 2 : 1);
421 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
422 "unknown bandwidth: %#X\n", rtlphy
->current_chan_bw
);
425 rtl92ce_phy_rf6052_set_bandwidth(hw
, rtlphy
->current_chan_bw
);
426 rtlphy
->set_bwmode_inprogress
= false;
427 RT_TRACE(rtlpriv
, COMP_SCAN
, DBG_TRACE
, "<==\n");
430 void _rtl92ce_phy_lc_calibrate(struct ieee80211_hw
*hw
, bool is2t
)
433 u32 rf_a_mode
= 0, rf_b_mode
= 0, lc_cal
;
434 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
436 tmpreg
= rtl_read_byte(rtlpriv
, 0xd03);
438 if ((tmpreg
& 0x70) != 0)
439 rtl_write_byte(rtlpriv
, 0xd03, tmpreg
& 0x8F);
441 rtl_write_byte(rtlpriv
, REG_TXPAUSE
, 0xFF);
443 if ((tmpreg
& 0x70) != 0) {
444 rf_a_mode
= rtl_get_rfreg(hw
, RF90_PATH_A
, 0x00, MASK12BITS
);
447 rf_b_mode
= rtl_get_rfreg(hw
, RF90_PATH_B
, 0x00,
450 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x00, MASK12BITS
,
451 (rf_a_mode
& 0x8FFFF) | 0x10000);
454 rtl_set_rfreg(hw
, RF90_PATH_B
, 0x00, MASK12BITS
,
455 (rf_b_mode
& 0x8FFFF) | 0x10000);
457 lc_cal
= rtl_get_rfreg(hw
, RF90_PATH_A
, 0x18, MASK12BITS
);
459 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x18, MASK12BITS
, lc_cal
| 0x08000);
463 if ((tmpreg
& 0x70) != 0) {
464 rtl_write_byte(rtlpriv
, 0xd03, tmpreg
);
465 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x00, MASK12BITS
, rf_a_mode
);
468 rtl_set_rfreg(hw
, RF90_PATH_B
, 0x00, MASK12BITS
,
471 rtl_write_byte(rtlpriv
, REG_TXPAUSE
, 0x00);
475 static void _rtl92ce_phy_set_rf_sleep(struct ieee80211_hw
*hw
)
479 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
481 rtl_write_byte(rtlpriv
, REG_TXPAUSE
, 0xFF);
482 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x00, RFREG_OFFSET_MASK
, 0x00);
483 rtl_write_byte(rtlpriv
, REG_APSD_CTRL
, 0x40);
484 u4b_tmp
= rtl_get_rfreg(hw
, RF90_PATH_A
, 0, RFREG_OFFSET_MASK
);
485 while (u4b_tmp
!= 0 && delay
> 0) {
486 rtl_write_byte(rtlpriv
, REG_APSD_CTRL
, 0x0);
487 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x00, RFREG_OFFSET_MASK
, 0x00);
488 rtl_write_byte(rtlpriv
, REG_APSD_CTRL
, 0x40);
489 u4b_tmp
= rtl_get_rfreg(hw
, RF90_PATH_A
, 0, RFREG_OFFSET_MASK
);
493 rtl_write_byte(rtlpriv
, REG_APSD_CTRL
, 0x00);
494 rtl_write_byte(rtlpriv
, REG_SYS_FUNC_EN
, 0xE2);
495 rtl_write_byte(rtlpriv
, REG_SYS_FUNC_EN
, 0xE3);
496 rtl_write_byte(rtlpriv
, REG_TXPAUSE
, 0x00);
497 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_TRACE
,
498 "Switch RF timeout !!!\n");
501 rtl_write_byte(rtlpriv
, REG_SYS_FUNC_EN
, 0xE2);
502 rtl_write_byte(rtlpriv
, REG_SPS0_CTRL
, 0x22);
505 static bool _rtl92ce_phy_set_rf_power_state(struct ieee80211_hw
*hw
,
506 enum rf_pwrstate rfpwr_state
)
508 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
509 struct rtl_pci_priv
*pcipriv
= rtl_pcipriv(hw
);
510 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
511 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
514 struct rtl8192_tx_ring
*ring
= NULL
;
516 switch (rfpwr_state
) {
518 if ((ppsc
->rfpwr_state
== ERFOFF
) &&
519 RT_IN_PS_LEVEL(ppsc
, RT_RF_OFF_LEVL_HALT_NIC
)) {
521 u32 InitializeCount
= 0;
524 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
525 "IPS Set eRf nic enable\n");
526 rtstatus
= rtl_ps_enable_nic(hw
);
527 } while (!rtstatus
&& (InitializeCount
< 10));
528 RT_CLEAR_PS_LEVEL(ppsc
,
529 RT_RF_OFF_LEVL_HALT_NIC
);
531 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
532 "Set ERFON sleeped:%d ms\n",
533 jiffies_to_msecs(jiffies
-
535 last_sleep_jiffies
));
536 ppsc
->last_awake_jiffies
= jiffies
;
537 rtl92ce_phy_set_rf_on(hw
);
539 if (mac
->link_state
== MAC80211_LINKED
) {
540 rtlpriv
->cfg
->ops
->led_control(hw
,
543 rtlpriv
->cfg
->ops
->led_control(hw
,
549 if (ppsc
->reg_rfps_level
& RT_RF_OFF_LEVL_HALT_NIC
) {
550 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
551 "IPS Set eRf nic disable\n");
552 rtl_ps_disable_nic(hw
);
553 RT_SET_PS_LEVEL(ppsc
, RT_RF_OFF_LEVL_HALT_NIC
);
555 if (ppsc
->rfoff_reason
== RF_CHANGE_BY_IPS
) {
556 rtlpriv
->cfg
->ops
->led_control(hw
,
559 rtlpriv
->cfg
->ops
->led_control(hw
,
566 if (ppsc
->rfpwr_state
== ERFOFF
)
568 for (queue_id
= 0, i
= 0;
569 queue_id
< RTL_PCI_MAX_TX_QUEUE_COUNT
;) {
570 ring
= &pcipriv
->dev
.tx_ring
[queue_id
];
571 if (skb_queue_len(&ring
->queue
) == 0) {
575 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
576 "eRf Off/Sleep: %d times TcbBusyQueue[%d] =%d before doze!\n",
578 skb_queue_len(&ring
->queue
));
583 if (i
>= MAX_DOZE_WAITING_TIMES_9x
) {
584 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
585 "ERFSLEEP: %d times TcbBusyQueue[%d] = %d !\n",
586 MAX_DOZE_WAITING_TIMES_9x
,
588 skb_queue_len(&ring
->queue
));
592 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
593 "Set ERFSLEEP awaked:%d ms\n",
594 jiffies_to_msecs(jiffies
-
595 ppsc
->last_awake_jiffies
));
596 ppsc
->last_sleep_jiffies
= jiffies
;
597 _rtl92ce_phy_set_rf_sleep(hw
);
601 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
602 "switch case not processed\n");
607 ppsc
->rfpwr_state
= rfpwr_state
;
611 bool rtl92c_phy_set_rf_power_state(struct ieee80211_hw
*hw
,
612 enum rf_pwrstate rfpwr_state
)
614 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
616 bool bresult
= false;
618 if (rfpwr_state
== ppsc
->rfpwr_state
)
620 bresult
= _rtl92ce_phy_set_rf_power_state(hw
, rfpwr_state
);