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 *****************************************************************************/
40 u32
rtl92cu_phy_query_rf_reg(struct ieee80211_hw
*hw
,
41 enum radio_path rfpath
, u32 regaddr
, u32 bitmask
)
43 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
44 u32 original_value
, readback_value
, bitshift
;
45 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
47 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
,
48 "regaddr(%#x), rfpath(%#x), bitmask(%#x)\n",
49 regaddr
, rfpath
, bitmask
);
50 if (rtlphy
->rf_mode
!= RF_OP_BY_FW
) {
51 original_value
= _rtl92c_phy_rf_serial_read(hw
,
54 original_value
= _rtl92c_phy_fw_rf_serial_read(hw
,
57 bitshift
= _rtl92c_phy_calculate_bit_shift(bitmask
);
58 readback_value
= (original_value
& bitmask
) >> bitshift
;
59 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
,
60 "regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n",
61 regaddr
, rfpath
, bitmask
, original_value
);
62 return readback_value
;
65 void rtl92cu_phy_set_rf_reg(struct ieee80211_hw
*hw
,
66 enum radio_path rfpath
,
67 u32 regaddr
, u32 bitmask
, u32 data
)
69 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
70 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
71 u32 original_value
, bitshift
;
73 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
,
74 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
75 regaddr
, bitmask
, data
, rfpath
);
76 if (rtlphy
->rf_mode
!= RF_OP_BY_FW
) {
77 if (bitmask
!= RFREG_OFFSET_MASK
) {
78 original_value
= _rtl92c_phy_rf_serial_read(hw
,
81 bitshift
= _rtl92c_phy_calculate_bit_shift(bitmask
);
83 ((original_value
& (~bitmask
)) |
86 _rtl92c_phy_rf_serial_write(hw
, rfpath
, regaddr
, data
);
88 if (bitmask
!= RFREG_OFFSET_MASK
) {
89 original_value
= _rtl92c_phy_fw_rf_serial_read(hw
,
92 bitshift
= _rtl92c_phy_calculate_bit_shift(bitmask
);
94 ((original_value
& (~bitmask
)) |
97 _rtl92c_phy_fw_rf_serial_write(hw
, rfpath
, regaddr
, data
);
99 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
,
100 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
101 regaddr
, bitmask
, data
, rfpath
);
104 bool rtl92cu_phy_mac_config(struct ieee80211_hw
*hw
)
107 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
108 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
109 bool is92c
= IS_92C_SERIAL(rtlhal
->version
);
111 rtstatus
= _rtl92cu_phy_config_mac_with_headerfile(hw
);
112 if (is92c
&& IS_HARDWARE_TYPE_8192CE(rtlhal
))
113 rtl_write_byte(rtlpriv
, 0x14, 0x71);
117 bool rtl92cu_phy_bb_config(struct ieee80211_hw
*hw
)
119 bool rtstatus
= true;
120 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
121 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
124 u8 b_reg_hwparafile
= 1;
126 _rtl92c_phy_init_bb_rf_register_definition(hw
);
127 regval
= rtl_read_word(rtlpriv
, REG_SYS_FUNC_EN
);
128 rtl_write_word(rtlpriv
, REG_SYS_FUNC_EN
, regval
| BIT(13) |
130 rtl_write_byte(rtlpriv
, REG_AFE_PLL_CTRL
, 0x83);
131 rtl_write_byte(rtlpriv
, REG_AFE_PLL_CTRL
+ 1, 0xdb);
132 rtl_write_byte(rtlpriv
, REG_RF_CTRL
, RF_EN
| RF_RSTB
| RF_SDMRSTB
);
133 if (IS_HARDWARE_TYPE_8192CE(rtlhal
)) {
134 rtl_write_byte(rtlpriv
, REG_SYS_FUNC_EN
, FEN_PPLL
| FEN_PCIEA
|
135 FEN_DIO_PCIE
| FEN_BB_GLB_RSTn
| FEN_BBRSTB
);
136 } else if (IS_HARDWARE_TYPE_8192CU(rtlhal
)) {
137 rtl_write_byte(rtlpriv
, REG_SYS_FUNC_EN
, FEN_USBA
| FEN_USBD
|
138 FEN_BB_GLB_RSTn
| FEN_BBRSTB
);
140 regval32
= rtl_read_dword(rtlpriv
, 0x87c);
141 rtl_write_dword(rtlpriv
, 0x87c, regval32
& (~BIT(31)));
142 if (IS_HARDWARE_TYPE_8192CU(rtlhal
))
143 rtl_write_byte(rtlpriv
, REG_LDOHCI12_CTRL
, 0x0f);
144 rtl_write_byte(rtlpriv
, REG_AFE_XTAL_CTRL
+ 1, 0x80);
145 if (b_reg_hwparafile
== 1)
146 rtstatus
= _rtl92c_phy_bb8192c_config_parafile(hw
);
150 bool _rtl92cu_phy_config_mac_with_headerfile(struct ieee80211_hw
*hw
)
152 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
153 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
158 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
, "Read Rtl819XMACPHY_Array\n");
159 arraylength
= rtlphy
->hwparam_tables
[MAC_REG
].length
;
160 ptrarray
= rtlphy
->hwparam_tables
[MAC_REG
].pdata
;
161 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
, "Img:RTL8192CEMAC_2T_ARRAY\n");
162 for (i
= 0; i
< arraylength
; i
= i
+ 2)
163 rtl_write_byte(rtlpriv
, ptrarray
[i
], (u8
) ptrarray
[i
+ 1]);
167 bool _rtl92cu_phy_config_bb_with_headerfile(struct ieee80211_hw
*hw
,
171 u32
*phy_regarray_table
;
172 u32
*agctab_array_table
;
173 u16 phy_reg_arraylen
, agctab_arraylen
;
174 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
175 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
176 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
178 if (IS_92C_SERIAL(rtlhal
->version
)) {
179 agctab_arraylen
= rtlphy
->hwparam_tables
[AGCTAB_2T
].length
;
180 agctab_array_table
= rtlphy
->hwparam_tables
[AGCTAB_2T
].pdata
;
181 phy_reg_arraylen
= rtlphy
->hwparam_tables
[PHY_REG_2T
].length
;
182 phy_regarray_table
= rtlphy
->hwparam_tables
[PHY_REG_2T
].pdata
;
184 agctab_arraylen
= rtlphy
->hwparam_tables
[AGCTAB_1T
].length
;
185 agctab_array_table
= rtlphy
->hwparam_tables
[AGCTAB_1T
].pdata
;
186 phy_reg_arraylen
= rtlphy
->hwparam_tables
[PHY_REG_1T
].length
;
187 phy_regarray_table
= rtlphy
->hwparam_tables
[PHY_REG_1T
].pdata
;
189 if (configtype
== BASEBAND_CONFIG_PHY_REG
) {
190 for (i
= 0; i
< phy_reg_arraylen
; i
= i
+ 2) {
191 if (phy_regarray_table
[i
] == 0xfe)
193 else if (phy_regarray_table
[i
] == 0xfd)
195 else if (phy_regarray_table
[i
] == 0xfc)
197 else if (phy_regarray_table
[i
] == 0xfb)
199 else if (phy_regarray_table
[i
] == 0xfa)
201 else if (phy_regarray_table
[i
] == 0xf9)
203 rtl_set_bbreg(hw
, phy_regarray_table
[i
], MASKDWORD
,
204 phy_regarray_table
[i
+ 1]);
206 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
207 "The phy_regarray_table[0] is %x Rtl819XPHY_REGArray[1] is %x\n",
208 phy_regarray_table
[i
],
209 phy_regarray_table
[i
+ 1]);
211 } else if (configtype
== BASEBAND_CONFIG_AGC_TAB
) {
212 for (i
= 0; i
< agctab_arraylen
; i
= i
+ 2) {
213 rtl_set_bbreg(hw
, agctab_array_table
[i
], MASKDWORD
,
214 agctab_array_table
[i
+ 1]);
216 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
217 "The agctab_array_table[0] is %x Rtl819XPHY_REGArray[1] is %x\n",
218 agctab_array_table
[i
],
219 agctab_array_table
[i
+ 1]);
225 bool _rtl92cu_phy_config_bb_with_pgheaderfile(struct ieee80211_hw
*hw
,
228 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
229 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
231 u32
*phy_regarray_table_pg
;
232 u16 phy_regarray_pg_len
;
234 rtlphy
->pwrgroup_cnt
= 0;
235 phy_regarray_pg_len
= rtlphy
->hwparam_tables
[PHY_REG_PG
].length
;
236 phy_regarray_table_pg
= rtlphy
->hwparam_tables
[PHY_REG_PG
].pdata
;
237 if (configtype
== BASEBAND_CONFIG_PHY_REG
) {
238 for (i
= 0; i
< phy_regarray_pg_len
; i
= i
+ 3) {
239 if (phy_regarray_table_pg
[i
] == 0xfe)
241 else if (phy_regarray_table_pg
[i
] == 0xfd)
243 else if (phy_regarray_table_pg
[i
] == 0xfc)
245 else if (phy_regarray_table_pg
[i
] == 0xfb)
247 else if (phy_regarray_table_pg
[i
] == 0xfa)
249 else if (phy_regarray_table_pg
[i
] == 0xf9)
251 _rtl92c_store_pwrIndex_diffrate_offset(hw
,
252 phy_regarray_table_pg
[i
],
253 phy_regarray_table_pg
[i
+ 1],
254 phy_regarray_table_pg
[i
+ 2]);
257 RT_TRACE(rtlpriv
, COMP_SEND
, DBG_TRACE
,
258 "configtype != BaseBand_Config_PHY_REG\n");
263 bool rtl92cu_phy_config_rf_with_headerfile(struct ieee80211_hw
*hw
,
264 enum radio_path rfpath
)
267 u32
*radioa_array_table
;
268 u32
*radiob_array_table
;
269 u16 radioa_arraylen
, radiob_arraylen
;
270 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
271 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
272 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
274 if (IS_92C_SERIAL(rtlhal
->version
)) {
275 radioa_arraylen
= rtlphy
->hwparam_tables
[RADIOA_2T
].length
;
276 radioa_array_table
= rtlphy
->hwparam_tables
[RADIOA_2T
].pdata
;
277 radiob_arraylen
= rtlphy
->hwparam_tables
[RADIOB_2T
].length
;
278 radiob_array_table
= rtlphy
->hwparam_tables
[RADIOB_2T
].pdata
;
279 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
280 "Radio_A:RTL8192CERADIOA_2TARRAY\n");
281 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
282 "Radio_B:RTL8192CE_RADIOB_2TARRAY\n");
284 radioa_arraylen
= rtlphy
->hwparam_tables
[RADIOA_1T
].length
;
285 radioa_array_table
= rtlphy
->hwparam_tables
[RADIOA_1T
].pdata
;
286 radiob_arraylen
= rtlphy
->hwparam_tables
[RADIOB_1T
].length
;
287 radiob_array_table
= rtlphy
->hwparam_tables
[RADIOB_1T
].pdata
;
288 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
289 "Radio_A:RTL8192CE_RADIOA_1TARRAY\n");
290 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
291 "Radio_B:RTL8192CE_RADIOB_1TARRAY\n");
293 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
, "Radio No %x\n", rfpath
);
296 for (i
= 0; i
< radioa_arraylen
; i
= i
+ 2) {
297 if (radioa_array_table
[i
] == 0xfe)
299 else if (radioa_array_table
[i
] == 0xfd)
301 else if (radioa_array_table
[i
] == 0xfc)
303 else if (radioa_array_table
[i
] == 0xfb)
305 else if (radioa_array_table
[i
] == 0xfa)
307 else if (radioa_array_table
[i
] == 0xf9)
310 rtl_set_rfreg(hw
, rfpath
, radioa_array_table
[i
],
312 radioa_array_table
[i
+ 1]);
318 for (i
= 0; i
< radiob_arraylen
; i
= i
+ 2) {
319 if (radiob_array_table
[i
] == 0xfe) {
321 } else if (radiob_array_table
[i
] == 0xfd)
323 else if (radiob_array_table
[i
] == 0xfc)
325 else if (radiob_array_table
[i
] == 0xfb)
327 else if (radiob_array_table
[i
] == 0xfa)
329 else if (radiob_array_table
[i
] == 0xf9)
332 rtl_set_rfreg(hw
, rfpath
, radiob_array_table
[i
],
334 radiob_array_table
[i
+ 1]);
340 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
341 "switch case not processed\n");
344 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
345 "switch case not processed\n");
351 void rtl92cu_phy_set_bw_mode_callback(struct ieee80211_hw
*hw
)
353 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
354 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
355 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
356 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
360 RT_TRACE(rtlpriv
, COMP_SCAN
, DBG_TRACE
, "Switch to %s bandwidth\n",
361 rtlphy
->current_chan_bw
== HT_CHANNEL_WIDTH_20
?
363 if (is_hal_stop(rtlhal
)) {
364 rtlphy
->set_bwmode_inprogress
= false;
367 reg_bw_opmode
= rtl_read_byte(rtlpriv
, REG_BWOPMODE
);
368 reg_prsr_rsc
= rtl_read_byte(rtlpriv
, REG_RRSR
+ 2);
369 switch (rtlphy
->current_chan_bw
) {
370 case HT_CHANNEL_WIDTH_20
:
371 reg_bw_opmode
|= BW_OPMODE_20MHZ
;
372 rtl_write_byte(rtlpriv
, REG_BWOPMODE
, reg_bw_opmode
);
374 case HT_CHANNEL_WIDTH_20_40
:
375 reg_bw_opmode
&= ~BW_OPMODE_20MHZ
;
376 rtl_write_byte(rtlpriv
, REG_BWOPMODE
, reg_bw_opmode
);
378 (reg_prsr_rsc
& 0x90) | (mac
->cur_40_prime_sc
<< 5);
379 rtl_write_byte(rtlpriv
, REG_RRSR
+ 2, reg_prsr_rsc
);
382 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
383 "unknown bandwidth: %#X\n", rtlphy
->current_chan_bw
);
386 switch (rtlphy
->current_chan_bw
) {
387 case HT_CHANNEL_WIDTH_20
:
388 rtl_set_bbreg(hw
, RFPGA0_RFMOD
, BRFMOD
, 0x0);
389 rtl_set_bbreg(hw
, RFPGA1_RFMOD
, BRFMOD
, 0x0);
390 rtl_set_bbreg(hw
, RFPGA0_ANALOGPARAMETER2
, BIT(10), 1);
392 case HT_CHANNEL_WIDTH_20_40
:
393 rtl_set_bbreg(hw
, RFPGA0_RFMOD
, BRFMOD
, 0x1);
394 rtl_set_bbreg(hw
, RFPGA1_RFMOD
, BRFMOD
, 0x1);
395 rtl_set_bbreg(hw
, RCCK0_SYSTEM
, BCCK_SIDEBAND
,
396 (mac
->cur_40_prime_sc
>> 1));
397 rtl_set_bbreg(hw
, ROFDM1_LSTF
, 0xC00, mac
->cur_40_prime_sc
);
398 rtl_set_bbreg(hw
, RFPGA0_ANALOGPARAMETER2
, BIT(10), 0);
399 rtl_set_bbreg(hw
, 0x818, (BIT(26) | BIT(27)),
400 (mac
->cur_40_prime_sc
==
401 HAL_PRIME_CHNL_OFFSET_LOWER
) ? 2 : 1);
404 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
405 "unknown bandwidth: %#X\n", rtlphy
->current_chan_bw
);
408 rtl92cu_phy_rf6052_set_bandwidth(hw
, rtlphy
->current_chan_bw
);
409 rtlphy
->set_bwmode_inprogress
= false;
410 RT_TRACE(rtlpriv
, COMP_SCAN
, DBG_TRACE
, "<==\n");
413 void rtl92cu_bb_block_on(struct ieee80211_hw
*hw
)
415 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
417 mutex_lock(&rtlpriv
->io
.bb_mutex
);
418 rtl_set_bbreg(hw
, RFPGA0_RFMOD
, BCCKEN
, 0x1);
419 rtl_set_bbreg(hw
, RFPGA0_RFMOD
, BOFDMEN
, 0x1);
420 mutex_unlock(&rtlpriv
->io
.bb_mutex
);
423 void _rtl92cu_phy_lc_calibrate(struct ieee80211_hw
*hw
, bool is2t
)
426 u32 rf_a_mode
= 0, rf_b_mode
= 0, lc_cal
;
427 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
429 tmpreg
= rtl_read_byte(rtlpriv
, 0xd03);
431 if ((tmpreg
& 0x70) != 0)
432 rtl_write_byte(rtlpriv
, 0xd03, tmpreg
& 0x8F);
434 rtl_write_byte(rtlpriv
, REG_TXPAUSE
, 0xFF);
436 if ((tmpreg
& 0x70) != 0) {
437 rf_a_mode
= rtl_get_rfreg(hw
, RF90_PATH_A
, 0x00, MASK12BITS
);
439 rf_b_mode
= rtl_get_rfreg(hw
, RF90_PATH_B
, 0x00,
441 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x00, MASK12BITS
,
442 (rf_a_mode
& 0x8FFFF) | 0x10000);
444 rtl_set_rfreg(hw
, RF90_PATH_B
, 0x00, MASK12BITS
,
445 (rf_b_mode
& 0x8FFFF) | 0x10000);
447 lc_cal
= rtl_get_rfreg(hw
, RF90_PATH_A
, 0x18, MASK12BITS
);
448 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x18, MASK12BITS
, lc_cal
| 0x08000);
450 if ((tmpreg
& 0x70) != 0) {
451 rtl_write_byte(rtlpriv
, 0xd03, tmpreg
);
452 rtl_set_rfreg(hw
, RF90_PATH_A
, 0x00, MASK12BITS
, rf_a_mode
);
454 rtl_set_rfreg(hw
, RF90_PATH_B
, 0x00, MASK12BITS
,
457 rtl_write_byte(rtlpriv
, REG_TXPAUSE
, 0x00);
461 static bool _rtl92cu_phy_set_rf_power_state(struct ieee80211_hw
*hw
,
462 enum rf_pwrstate rfpwr_state
)
464 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
465 struct rtl_pci_priv
*pcipriv
= rtl_pcipriv(hw
);
466 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
467 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
470 struct rtl8192_tx_ring
*ring
= NULL
;
472 switch (rfpwr_state
) {
474 if ((ppsc
->rfpwr_state
== ERFOFF
) &&
475 RT_IN_PS_LEVEL(ppsc
, RT_RF_OFF_LEVL_HALT_NIC
)) {
477 u32 InitializeCount
= 0;
481 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
482 "IPS Set eRf nic enable\n");
483 rtstatus
= rtl_ps_enable_nic(hw
);
484 } while (!rtstatus
&& (InitializeCount
< 10));
485 RT_CLEAR_PS_LEVEL(ppsc
,
486 RT_RF_OFF_LEVL_HALT_NIC
);
488 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
489 "Set ERFON sleeped:%d ms\n",
490 jiffies_to_msecs(jiffies
-
491 ppsc
->last_sleep_jiffies
));
492 ppsc
->last_awake_jiffies
= jiffies
;
493 rtl92ce_phy_set_rf_on(hw
);
495 if (mac
->link_state
== MAC80211_LINKED
) {
496 rtlpriv
->cfg
->ops
->led_control(hw
,
499 rtlpriv
->cfg
->ops
->led_control(hw
,
504 for (queue_id
= 0, i
= 0;
505 queue_id
< RTL_PCI_MAX_TX_QUEUE_COUNT
;) {
506 ring
= &pcipriv
->dev
.tx_ring
[queue_id
];
507 if (skb_queue_len(&ring
->queue
) == 0 ||
508 queue_id
== BEACON_QUEUE
) {
512 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
513 "eRf Off/Sleep: %d times TcbBusyQueue[%d] =%d before doze!\n",
516 skb_queue_len(&ring
->queue
));
520 if (i
>= MAX_DOZE_WAITING_TIMES_9x
) {
521 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
522 "ERFOFF: %d times TcbBusyQueue[%d] = %d !\n",
523 MAX_DOZE_WAITING_TIMES_9x
,
525 skb_queue_len(&ring
->queue
));
529 if (ppsc
->reg_rfps_level
& RT_RF_OFF_LEVL_HALT_NIC
) {
530 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
531 "IPS Set eRf nic disable\n");
532 rtl_ps_disable_nic(hw
);
533 RT_SET_PS_LEVEL(ppsc
, RT_RF_OFF_LEVL_HALT_NIC
);
535 if (ppsc
->rfoff_reason
== RF_CHANGE_BY_IPS
) {
536 rtlpriv
->cfg
->ops
->led_control(hw
,
539 rtlpriv
->cfg
->ops
->led_control(hw
,
545 if (ppsc
->rfpwr_state
== ERFOFF
)
547 for (queue_id
= 0, i
= 0;
548 queue_id
< RTL_PCI_MAX_TX_QUEUE_COUNT
;) {
549 ring
= &pcipriv
->dev
.tx_ring
[queue_id
];
550 if (skb_queue_len(&ring
->queue
) == 0) {
554 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
555 "eRf Off/Sleep: %d times TcbBusyQueue[%d] =%d before doze!\n",
557 skb_queue_len(&ring
->queue
));
561 if (i
>= MAX_DOZE_WAITING_TIMES_9x
) {
562 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
563 "ERFSLEEP: %d times TcbBusyQueue[%d] = %d !\n",
564 MAX_DOZE_WAITING_TIMES_9x
,
566 skb_queue_len(&ring
->queue
));
570 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
571 "Set ERFSLEEP awaked:%d ms\n",
572 jiffies_to_msecs(jiffies
- ppsc
->last_awake_jiffies
));
573 ppsc
->last_sleep_jiffies
= jiffies
;
574 _rtl92c_phy_set_rf_sleep(hw
);
577 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
578 "switch case not processed\n");
583 ppsc
->rfpwr_state
= rfpwr_state
;
587 bool rtl92cu_phy_set_rf_power_state(struct ieee80211_hw
*hw
,
588 enum rf_pwrstate rfpwr_state
)
590 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
591 bool bresult
= false;
593 if (rfpwr_state
== ppsc
->rfpwr_state
)
595 bresult
= _rtl92cu_phy_set_rf_power_state(hw
, rfpwr_state
);