1 /******************************************************************************
3 * Copyright(c) 2009-2010 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
, ("regaddr(%#x), "
51 "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), "
71 "bitmask(%#x), original_value(%#x)\n",
72 regaddr
, rfpath
, bitmask
, original_value
));
74 return readback_value
;
77 bool rtl92c_phy_mac_config(struct ieee80211_hw
*hw
)
79 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
80 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
81 bool is92c
= IS_92C_SERIAL(rtlhal
->version
);
82 bool rtstatus
= _rtl92c_phy_config_mac_with_headerfile(hw
);
85 rtl_write_byte(rtlpriv
, 0x14, 0x71);
89 bool rtl92c_phy_bb_config(struct ieee80211_hw
*hw
)
92 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
95 u8 reg_hwparafile
= 1;
97 _rtl92c_phy_init_bb_rf_register_definition(hw
);
98 regval
= rtl_read_word(rtlpriv
, REG_SYS_FUNC_EN
);
99 rtl_write_word(rtlpriv
, REG_SYS_FUNC_EN
,
100 regval
| BIT(13) | BIT(0) | BIT(1));
101 rtl_write_byte(rtlpriv
, REG_AFE_PLL_CTRL
, 0x83);
102 rtl_write_byte(rtlpriv
, REG_AFE_PLL_CTRL
+ 1, 0xdb);
103 rtl_write_byte(rtlpriv
, REG_RF_CTRL
, RF_EN
| RF_RSTB
| RF_SDMRSTB
);
104 rtl_write_byte(rtlpriv
, REG_SYS_FUNC_EN
,
105 FEN_PPLL
| FEN_PCIEA
| FEN_DIO_PCIE
|
106 FEN_BB_GLB_RSTn
| FEN_BBRSTB
);
107 rtl_write_byte(rtlpriv
, REG_AFE_XTAL_CTRL
+ 1, 0x80);
108 regvaldw
= rtl_read_dword(rtlpriv
, REG_LEDCFG0
);
109 rtl_write_dword(rtlpriv
, REG_LEDCFG0
, regvaldw
| BIT(23));
110 if (reg_hwparafile
== 1)
111 rtstatus
= _rtl92c_phy_bb8192c_config_parafile(hw
);
115 void rtl92ce_phy_set_rf_reg(struct ieee80211_hw
*hw
,
116 enum radio_path rfpath
,
117 u32 regaddr
, u32 bitmask
, u32 data
)
119 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
120 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
121 u32 original_value
, bitshift
;
123 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
,
124 ("regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
125 regaddr
, bitmask
, data
, rfpath
));
127 spin_lock(&rtlpriv
->locks
.rf_lock
);
129 if (rtlphy
->rf_mode
!= RF_OP_BY_FW
) {
130 if (bitmask
!= RFREG_OFFSET_MASK
) {
131 original_value
= _rtl92c_phy_rf_serial_read(hw
,
134 bitshift
= _rtl92c_phy_calculate_bit_shift(bitmask
);
136 ((original_value
& (~bitmask
)) |
140 _rtl92c_phy_rf_serial_write(hw
, rfpath
, regaddr
, data
);
142 if (bitmask
!= RFREG_OFFSET_MASK
) {
143 original_value
= _rtl92c_phy_fw_rf_serial_read(hw
,
146 bitshift
= _rtl92c_phy_calculate_bit_shift(bitmask
);
148 ((original_value
& (~bitmask
)) |
151 _rtl92c_phy_fw_rf_serial_write(hw
, rfpath
, regaddr
, data
);
154 spin_unlock(&rtlpriv
->locks
.rf_lock
);
156 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
, ("regaddr(%#x), "
157 "bitmask(%#x), data(%#x), "
158 "rfpath(%#x)\n", regaddr
,
159 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
,
173 ("Img:RTL8192CEMAC_2T_ARRAY\n"));
174 for (i
= 0; i
< arraylength
; i
= i
+ 2)
175 rtl_write_byte(rtlpriv
, ptrarray
[i
], (u8
) ptrarray
[i
+ 1]);
179 bool _rtl92ce_phy_config_bb_with_headerfile(struct ieee80211_hw
*hw
,
183 u32
*phy_regarray_table
;
184 u32
*agctab_array_table
;
185 u16 phy_reg_arraylen
, agctab_arraylen
;
186 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
187 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
189 if (IS_92C_SERIAL(rtlhal
->version
)) {
190 agctab_arraylen
= AGCTAB_2TARRAYLENGTH
;
191 agctab_array_table
= RTL8192CEAGCTAB_2TARRAY
;
192 phy_reg_arraylen
= PHY_REG_2TARRAY_LENGTH
;
193 phy_regarray_table
= RTL8192CEPHY_REG_2TARRAY
;
195 agctab_arraylen
= AGCTAB_1TARRAYLENGTH
;
196 agctab_array_table
= RTL8192CEAGCTAB_1TARRAY
;
197 phy_reg_arraylen
= PHY_REG_1TARRAY_LENGTH
;
198 phy_regarray_table
= RTL8192CEPHY_REG_1TARRAY
;
200 if (configtype
== BASEBAND_CONFIG_PHY_REG
) {
201 for (i
= 0; i
< phy_reg_arraylen
; i
= i
+ 2) {
202 if (phy_regarray_table
[i
] == 0xfe)
204 else if (phy_regarray_table
[i
] == 0xfd)
206 else if (phy_regarray_table
[i
] == 0xfc)
208 else if (phy_regarray_table
[i
] == 0xfb)
210 else if (phy_regarray_table
[i
] == 0xfa)
212 else if (phy_regarray_table
[i
] == 0xf9)
214 rtl_set_bbreg(hw
, phy_regarray_table
[i
], MASKDWORD
,
215 phy_regarray_table
[i
+ 1]);
217 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
218 ("The phy_regarray_table[0] is %x"
219 " Rtl819XPHY_REGArray[1] is %x\n",
220 phy_regarray_table
[i
],
221 phy_regarray_table
[i
+ 1]));
223 } else if (configtype
== BASEBAND_CONFIG_AGC_TAB
) {
224 for (i
= 0; i
< agctab_arraylen
; i
= i
+ 2) {
225 rtl_set_bbreg(hw
, agctab_array_table
[i
], MASKDWORD
,
226 agctab_array_table
[i
+ 1]);
228 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
229 ("The agctab_array_table[0] is "
230 "%x Rtl819XPHY_REGArray[1] is %x\n",
231 agctab_array_table
[i
],
232 agctab_array_table
[i
+ 1]));
238 bool _rtl92ce_phy_config_bb_with_pgheaderfile(struct ieee80211_hw
*hw
,
241 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
243 u32
*phy_regarray_table_pg
;
244 u16 phy_regarray_pg_len
;
246 phy_regarray_pg_len
= PHY_REG_ARRAY_PGLENGTH
;
247 phy_regarray_table_pg
= RTL8192CEPHY_REG_ARRAY_PG
;
249 if (configtype
== BASEBAND_CONFIG_PHY_REG
) {
250 for (i
= 0; i
< phy_regarray_pg_len
; i
= i
+ 3) {
251 if (phy_regarray_table_pg
[i
] == 0xfe)
253 else if (phy_regarray_table_pg
[i
] == 0xfd)
255 else if (phy_regarray_table_pg
[i
] == 0xfc)
257 else if (phy_regarray_table_pg
[i
] == 0xfb)
259 else if (phy_regarray_table_pg
[i
] == 0xfa)
261 else if (phy_regarray_table_pg
[i
] == 0xf9)
264 _rtl92c_store_pwrIndex_diffrate_offset(hw
,
265 phy_regarray_table_pg
[i
],
266 phy_regarray_table_pg
[i
+ 1],
267 phy_regarray_table_pg
[i
+ 2]);
271 RT_TRACE(rtlpriv
, COMP_SEND
, DBG_TRACE
,
272 ("configtype != BaseBand_Config_PHY_REG\n"));
277 bool rtl92c_phy_config_rf_with_headerfile(struct ieee80211_hw
*hw
,
278 enum radio_path rfpath
)
282 u32
*radioa_array_table
;
283 u32
*radiob_array_table
;
284 u16 radioa_arraylen
, radiob_arraylen
;
285 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
286 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
288 if (IS_92C_SERIAL(rtlhal
->version
)) {
289 radioa_arraylen
= RADIOA_2TARRAYLENGTH
;
290 radioa_array_table
= RTL8192CERADIOA_2TARRAY
;
291 radiob_arraylen
= RADIOB_2TARRAYLENGTH
;
292 radiob_array_table
= RTL8192CE_RADIOB_2TARRAY
;
293 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
294 ("Radio_A:RTL8192CERADIOA_2TARRAY\n"));
295 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
296 ("Radio_B:RTL8192CE_RADIOB_2TARRAY\n"));
298 radioa_arraylen
= RADIOA_1TARRAYLENGTH
;
299 radioa_array_table
= RTL8192CE_RADIOA_1TARRAY
;
300 radiob_arraylen
= RADIOB_1TARRAYLENGTH
;
301 radiob_array_table
= RTL8192CE_RADIOB_1TARRAY
;
302 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
303 ("Radio_A:RTL8192CE_RADIOA_1TARRAY\n"));
304 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
305 ("Radio_B:RTL8192CE_RADIOB_1TARRAY\n"));
307 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
, ("Radio No %x\n", rfpath
));
310 for (i
= 0; i
< radioa_arraylen
; i
= i
+ 2) {
311 if (radioa_array_table
[i
] == 0xfe)
313 else if (radioa_array_table
[i
] == 0xfd)
315 else if (radioa_array_table
[i
] == 0xfc)
317 else if (radioa_array_table
[i
] == 0xfb)
319 else if (radioa_array_table
[i
] == 0xfa)
321 else if (radioa_array_table
[i
] == 0xf9)
324 rtl_set_rfreg(hw
, rfpath
, radioa_array_table
[i
],
326 radioa_array_table
[i
+ 1]);
332 for (i
= 0; i
< radiob_arraylen
; i
= i
+ 2) {
333 if (radiob_array_table
[i
] == 0xfe) {
335 } else if (radiob_array_table
[i
] == 0xfd)
337 else if (radiob_array_table
[i
] == 0xfc)
339 else if (radiob_array_table
[i
] == 0xfb)
341 else if (radiob_array_table
[i
] == 0xfa)
343 else if (radiob_array_table
[i
] == 0xf9)
346 rtl_set_rfreg(hw
, rfpath
, radiob_array_table
[i
],
348 radiob_array_table
[i
+ 1]);
354 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
355 ("switch case not process\n"));
358 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
359 ("switch case not process\n"));
365 void rtl92ce_phy_set_bw_mode_callback(struct ieee80211_hw
*hw
)
367 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
368 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
369 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
370 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
374 RT_TRACE(rtlpriv
, COMP_SCAN
, DBG_TRACE
,
375 ("Switch to %s bandwidth\n",
376 rtlphy
->current_chan_bw
== HT_CHANNEL_WIDTH_20
?
379 if (is_hal_stop(rtlhal
)) {
380 rtlphy
->set_bwmode_inprogress
= false;
384 reg_bw_opmode
= rtl_read_byte(rtlpriv
, REG_BWOPMODE
);
385 reg_prsr_rsc
= rtl_read_byte(rtlpriv
, REG_RRSR
+ 2);
387 switch (rtlphy
->current_chan_bw
) {
388 case HT_CHANNEL_WIDTH_20
:
389 reg_bw_opmode
|= BW_OPMODE_20MHZ
;
390 rtl_write_byte(rtlpriv
, REG_BWOPMODE
, reg_bw_opmode
);
392 case HT_CHANNEL_WIDTH_20_40
:
393 reg_bw_opmode
&= ~BW_OPMODE_20MHZ
;
394 rtl_write_byte(rtlpriv
, REG_BWOPMODE
, reg_bw_opmode
);
396 (reg_prsr_rsc
& 0x90) | (mac
->cur_40_prime_sc
<< 5);
397 rtl_write_byte(rtlpriv
, REG_RRSR
+ 2, reg_prsr_rsc
);
400 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
401 ("unknown bandwidth: %#X\n", rtlphy
->current_chan_bw
));
405 switch (rtlphy
->current_chan_bw
) {
406 case HT_CHANNEL_WIDTH_20
:
407 rtl_set_bbreg(hw
, RFPGA0_RFMOD
, BRFMOD
, 0x0);
408 rtl_set_bbreg(hw
, RFPGA1_RFMOD
, BRFMOD
, 0x0);
409 rtl_set_bbreg(hw
, RFPGA0_ANALOGPARAMETER2
, BIT(10), 1);
411 case HT_CHANNEL_WIDTH_20_40
:
412 rtl_set_bbreg(hw
, RFPGA0_RFMOD
, BRFMOD
, 0x1);
413 rtl_set_bbreg(hw
, RFPGA1_RFMOD
, BRFMOD
, 0x1);
415 rtl_set_bbreg(hw
, RCCK0_SYSTEM
, BCCK_SIDEBAND
,
416 (mac
->cur_40_prime_sc
>> 1));
417 rtl_set_bbreg(hw
, ROFDM1_LSTF
, 0xC00, mac
->cur_40_prime_sc
);
418 rtl_set_bbreg(hw
, RFPGA0_ANALOGPARAMETER2
, BIT(10), 0);
420 rtl_set_bbreg(hw
, 0x818, (BIT(26) | BIT(27)),
421 (mac
->cur_40_prime_sc
==
422 HAL_PRIME_CHNL_OFFSET_LOWER
) ? 2 : 1);
425 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
426 ("unknown bandwidth: %#X\n", rtlphy
->current_chan_bw
));
429 rtl92ce_phy_rf6052_set_bandwidth(hw
, rtlphy
->current_chan_bw
);
430 rtlphy
->set_bwmode_inprogress
= false;
431 RT_TRACE(rtlpriv
, COMP_SCAN
, DBG_TRACE
, ("<==\n"));
434 void _rtl92ce_phy_lc_calibrate(struct ieee80211_hw
*hw
, bool is2t
)
437 u32 rf_a_mode
= 0, rf_b_mode
= 0, lc_cal
;
438 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
440 tmpreg
= rtl_read_byte(rtlpriv
, 0xd03);
442 if ((tmpreg
& 0x70) != 0)
443 rtl_write_byte(rtlpriv
, 0xd03, tmpreg
& 0x8F);
445 rtl_write_byte(rtlpriv
, REG_TXPAUSE
, 0xFF);
447 if ((tmpreg
& 0x70) != 0) {
448 rf_a_mode
= rtl_get_rfreg(hw
, RF90_PATH_A
, 0x00, MASK12BITS
);
451 rf_b_mode
= rtl_get_rfreg(hw
, RF90_PATH_B
, 0x00,
454 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x00, MASK12BITS
,
455 (rf_a_mode
& 0x8FFFF) | 0x10000);
458 rtl_set_rfreg(hw
, RF90_PATH_B
, 0x00, MASK12BITS
,
459 (rf_b_mode
& 0x8FFFF) | 0x10000);
461 lc_cal
= rtl_get_rfreg(hw
, RF90_PATH_A
, 0x18, MASK12BITS
);
463 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x18, MASK12BITS
, lc_cal
| 0x08000);
467 if ((tmpreg
& 0x70) != 0) {
468 rtl_write_byte(rtlpriv
, 0xd03, tmpreg
);
469 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x00, MASK12BITS
, rf_a_mode
);
472 rtl_set_rfreg(hw
, RF90_PATH_B
, 0x00, MASK12BITS
,
475 rtl_write_byte(rtlpriv
, REG_TXPAUSE
, 0x00);
479 static void _rtl92ce_phy_set_rf_sleep(struct ieee80211_hw
*hw
)
483 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
485 rtl_write_byte(rtlpriv
, REG_TXPAUSE
, 0xFF);
486 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x00, RFREG_OFFSET_MASK
, 0x00);
487 rtl_write_byte(rtlpriv
, REG_APSD_CTRL
, 0x40);
488 u4b_tmp
= rtl_get_rfreg(hw
, RF90_PATH_A
, 0, RFREG_OFFSET_MASK
);
489 while (u4b_tmp
!= 0 && delay
> 0) {
490 rtl_write_byte(rtlpriv
, REG_APSD_CTRL
, 0x0);
491 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x00, RFREG_OFFSET_MASK
, 0x00);
492 rtl_write_byte(rtlpriv
, REG_APSD_CTRL
, 0x40);
493 u4b_tmp
= rtl_get_rfreg(hw
, RF90_PATH_A
, 0, RFREG_OFFSET_MASK
);
497 rtl_write_byte(rtlpriv
, REG_APSD_CTRL
, 0x00);
498 rtl_write_byte(rtlpriv
, REG_SYS_FUNC_EN
, 0xE2);
499 rtl_write_byte(rtlpriv
, REG_SYS_FUNC_EN
, 0xE3);
500 rtl_write_byte(rtlpriv
, REG_TXPAUSE
, 0x00);
501 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_TRACE
,
502 ("Switch RF timeout !!!.\n"));
505 rtl_write_byte(rtlpriv
, REG_SYS_FUNC_EN
, 0xE2);
506 rtl_write_byte(rtlpriv
, REG_SPS0_CTRL
, 0x22);
509 static bool _rtl92ce_phy_set_rf_power_state(struct ieee80211_hw
*hw
,
510 enum rf_pwrstate rfpwr_state
)
512 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
513 struct rtl_pci_priv
*pcipriv
= rtl_pcipriv(hw
);
514 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
515 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
518 struct rtl8192_tx_ring
*ring
= NULL
;
520 switch (rfpwr_state
) {
522 if ((ppsc
->rfpwr_state
== ERFOFF
) &&
523 RT_IN_PS_LEVEL(ppsc
, RT_RF_OFF_LEVL_HALT_NIC
)) {
525 u32 InitializeCount
= 0;
528 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
529 ("IPS Set eRf nic enable\n"));
530 rtstatus
= rtl_ps_enable_nic(hw
);
531 } while ((rtstatus
!= true)
532 && (InitializeCount
< 10));
533 RT_CLEAR_PS_LEVEL(ppsc
,
534 RT_RF_OFF_LEVL_HALT_NIC
);
536 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
537 ("Set ERFON sleeped:%d ms\n",
538 jiffies_to_msecs(jiffies
-
540 last_sleep_jiffies
)));
541 ppsc
->last_awake_jiffies
= jiffies
;
542 rtl92ce_phy_set_rf_on(hw
);
544 if (mac
->link_state
== MAC80211_LINKED
) {
545 rtlpriv
->cfg
->ops
->led_control(hw
,
548 rtlpriv
->cfg
->ops
->led_control(hw
,
554 if (ppsc
->reg_rfps_level
& RT_RF_OFF_LEVL_HALT_NIC
) {
555 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
556 ("IPS Set eRf nic disable\n"));
557 rtl_ps_disable_nic(hw
);
558 RT_SET_PS_LEVEL(ppsc
, RT_RF_OFF_LEVL_HALT_NIC
);
560 if (ppsc
->rfoff_reason
== RF_CHANGE_BY_IPS
) {
561 rtlpriv
->cfg
->ops
->led_control(hw
,
564 rtlpriv
->cfg
->ops
->led_control(hw
,
571 if (ppsc
->rfpwr_state
== ERFOFF
)
573 for (queue_id
= 0, i
= 0;
574 queue_id
< RTL_PCI_MAX_TX_QUEUE_COUNT
;) {
575 ring
= &pcipriv
->dev
.tx_ring
[queue_id
];
576 if (skb_queue_len(&ring
->queue
) == 0) {
580 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
581 ("eRf Off/Sleep: %d times "
582 "TcbBusyQueue[%d] =%d before "
583 "doze!\n", (i
+ 1), queue_id
,
584 skb_queue_len(&ring
->queue
)));
589 if (i
>= MAX_DOZE_WAITING_TIMES_9x
) {
590 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
591 ("\n ERFSLEEP: %d times "
592 "TcbBusyQueue[%d] = %d !\n",
593 MAX_DOZE_WAITING_TIMES_9x
,
595 skb_queue_len(&ring
->queue
)));
599 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
600 ("Set ERFSLEEP awaked:%d ms\n",
601 jiffies_to_msecs(jiffies
-
602 ppsc
->last_awake_jiffies
)));
603 ppsc
->last_sleep_jiffies
= jiffies
;
604 _rtl92ce_phy_set_rf_sleep(hw
);
608 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
609 ("switch case not process\n"));
614 ppsc
->rfpwr_state
= rfpwr_state
;
618 bool rtl92c_phy_set_rf_power_state(struct ieee80211_hw
*hw
,
619 enum rf_pwrstate rfpwr_state
)
621 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
623 bool bresult
= false;
625 if (rfpwr_state
== ppsc
->rfpwr_state
)
627 bresult
= _rtl92ce_phy_set_rf_power_state(hw
, rfpwr_state
);