44 u32 original_value, readback_value, bitshift;
48 "regaddr(%#x), rfpath(%#x), bitmask(%#x)\n",
49 regaddr, rfpath, bitmask);
58 readback_value = (original_value &
bitmask) >> bitshift;
60 "regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n",
61 regaddr, rfpath, bitmask, original_value);
62 return readback_value;
71 u32 original_value, bitshift;
74 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
75 regaddr, bitmask, data, rfpath);
83 ((original_value & (~bitmask)) |
94 ((original_value & (~bitmask)) |
100 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
101 regaddr, bitmask, data, rfpath);
113 rtl_write_byte(rtlpriv, 0x14, 0x71);
119 bool rtstatus =
true;
123 u8 b_reg_hwparafile = 1;
141 if (b_reg_hwparafile == 1)
158 for (i = 0; i < arraylength; i = i + 2)
159 rtl_write_byte(rtlpriv, ptrarray[i], (
u8) ptrarray[i + 1]);
167 u32 *phy_regarray_table;
168 u32 *agctab_array_table;
169 u16 phy_reg_arraylen, agctab_arraylen;
186 for (i = 0; i < phy_reg_arraylen; i = i + 2) {
187 if (phy_regarray_table[i] == 0xfe)
189 else if (phy_regarray_table[i] == 0xfd)
191 else if (phy_regarray_table[i] == 0xfc)
193 else if (phy_regarray_table[i] == 0xfb)
195 else if (phy_regarray_table[i] == 0xfa)
197 else if (phy_regarray_table[i] == 0xf9)
199 rtl_set_bbreg(hw, phy_regarray_table[i],
MASKDWORD,
200 phy_regarray_table[i + 1]);
203 "The phy_regarray_table[0] is %x Rtl819XPHY_REGArray[1] is %x\n",
204 phy_regarray_table[i],
205 phy_regarray_table[i + 1]);
208 for (i = 0; i < agctab_arraylen; i = i + 2) {
209 rtl_set_bbreg(hw, agctab_array_table[i],
MASKDWORD,
210 agctab_array_table[i + 1]);
213 "The agctab_array_table[0] is %x Rtl819XPHY_REGArray[1] is %x\n",
214 agctab_array_table[i],
215 agctab_array_table[i + 1]);
227 u32 *phy_regarray_table_pg;
228 u16 phy_regarray_pg_len;
234 for (i = 0; i < phy_regarray_pg_len; i = i + 3) {
235 if (phy_regarray_table_pg[i] == 0xfe)
237 else if (phy_regarray_table_pg[i] == 0xfd)
239 else if (phy_regarray_table_pg[i] == 0xfc)
241 else if (phy_regarray_table_pg[i] == 0xfb)
243 else if (phy_regarray_table_pg[i] == 0xfa)
245 else if (phy_regarray_table_pg[i] == 0xf9)
248 phy_regarray_table_pg[i],
249 phy_regarray_table_pg[i + 1],
250 phy_regarray_table_pg[i + 2]);
254 "configtype != BaseBand_Config_PHY_REG\n");
263 u32 *radioa_array_table;
264 u32 *radiob_array_table;
265 u16 radioa_arraylen, radiob_arraylen;
276 "Radio_A:RTL8192CERADIOA_2TARRAY\n");
278 "Radio_B:RTL8192CE_RADIOB_2TARRAY\n");
285 "Radio_A:RTL8192CE_RADIOA_1TARRAY\n");
287 "Radio_B:RTL8192CE_RADIOB_1TARRAY\n");
292 for (i = 0; i < radioa_arraylen; i = i + 2) {
293 if (radioa_array_table[i] == 0xfe)
295 else if (radioa_array_table[i] == 0xfd)
297 else if (radioa_array_table[i] == 0xfc)
299 else if (radioa_array_table[i] == 0xfb)
301 else if (radioa_array_table[i] == 0xfa)
303 else if (radioa_array_table[i] == 0xf9)
306 rtl_set_rfreg(hw, rfpath, radioa_array_table[i],
308 radioa_array_table[i + 1]);
314 for (i = 0; i < radiob_arraylen; i = i + 2) {
315 if (radiob_array_table[i] == 0xfe) {
317 }
else if (radiob_array_table[i] == 0xfd)
319 else if (radiob_array_table[i] == 0xfc)
321 else if (radiob_array_table[i] == 0xfb)
323 else if (radiob_array_table[i] == 0xfa)
325 else if (radiob_array_table[i] == 0xf9)
328 rtl_set_rfreg(hw, rfpath, radiob_array_table[i],
330 radiob_array_table[i + 1]);
337 "switch case not processed\n");
341 "switch case not processed\n");
359 if (is_hal_stop(rtlhal)) {
364 reg_prsr_rsc = rtl_read_byte(rtlpriv,
REG_RRSR + 2);
375 rtl_write_byte(rtlpriv,
REG_RRSR + 2, reg_prsr_rsc);
395 rtl_set_bbreg(hw, 0x818, (
BIT(26) |
BIT(27)),
422 u32 rf_a_mode = 0, rf_b_mode = 0, lc_cal;
425 tmpreg = rtl_read_byte(rtlpriv, 0xd03);
427 if ((tmpreg & 0x70) != 0)
428 rtl_write_byte(rtlpriv, 0xd03, tmpreg & 0x8F);
432 if ((tmpreg & 0x70) != 0) {
438 (rf_a_mode & 0x8FFFF) | 0x10000);
441 (rf_b_mode & 0x8FFFF) | 0x10000);
446 if ((tmpreg & 0x70) != 0) {
447 rtl_write_byte(rtlpriv, 0xd03, tmpreg);
457 static bool _rtl92cu_phy_set_rf_power_state(
struct ieee80211_hw *
hw,
468 switch (rfpwr_state) {
473 u32 InitializeCount = 0;
478 "IPS Set eRf nic enable\n");
480 }
while (!rtstatus && (InitializeCount < 10));
485 "Set ERFON sleeped:%d ms\n",
492 rtlpriv->
cfg->ops->led_control(hw,
495 rtlpriv->
cfg->ops->led_control(hw,
500 for (queue_id = 0, i = 0;
502 ring = &pcipriv->
dev.tx_ring[queue_id];
503 if (skb_queue_len(&ring->
queue) == 0 ||
509 "eRf Off/Sleep: %d times TcbBusyQueue[%d] =%d before doze!\n",
512 skb_queue_len(&ring->
queue));
518 "ERFOFF: %d times TcbBusyQueue[%d] = %d !\n",
521 skb_queue_len(&ring->
queue));
527 "IPS Set eRf nic disable\n");
532 rtlpriv->
cfg->ops->led_control(hw,
535 rtlpriv->
cfg->ops->led_control(hw,
543 for (queue_id = 0, i = 0;
545 ring = &pcipriv->
dev.tx_ring[queue_id];
546 if (skb_queue_len(&ring->
queue) == 0) {
551 "eRf Off/Sleep: %d times TcbBusyQueue[%d] =%d before doze!\n",
553 skb_queue_len(&ring->
queue));
559 "ERFSLEEP: %d times TcbBusyQueue[%d] = %d !\n",
562 skb_queue_len(&ring->
queue));
567 "Set ERFSLEEP awaked:%d ms\n",
574 "switch case not processed\n");
587 bool bresult =
false;
591 bresult = _rtl92cu_phy_set_rf_power_state(hw, rfpwr_state);