1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2009-2012 Realtek Corporation.*/
17 static u32
_rtl92s_phy_calculate_bit_shift(u32 bitmask
)
21 return i
? i
- 1 : 32;
24 u32
rtl92s_phy_query_bb_reg(struct ieee80211_hw
*hw
, u32 regaddr
, u32 bitmask
)
26 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
27 u32 returnvalue
= 0, originalvalue
, bitshift
;
29 rtl_dbg(rtlpriv
, COMP_RF
, DBG_TRACE
, "regaddr(%#x), bitmask(%#x)\n",
32 originalvalue
= rtl_read_dword(rtlpriv
, regaddr
);
33 bitshift
= _rtl92s_phy_calculate_bit_shift(bitmask
);
34 returnvalue
= (originalvalue
& bitmask
) >> bitshift
;
36 rtl_dbg(rtlpriv
, COMP_RF
, DBG_TRACE
, "BBR MASK=0x%x Addr[0x%x]=0x%x\n",
37 bitmask
, regaddr
, originalvalue
);
43 void rtl92s_phy_set_bb_reg(struct ieee80211_hw
*hw
, u32 regaddr
, u32 bitmask
,
46 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
47 u32 originalvalue
, bitshift
;
49 rtl_dbg(rtlpriv
, COMP_RF
, DBG_TRACE
,
50 "regaddr(%#x), bitmask(%#x), data(%#x)\n",
51 regaddr
, bitmask
, data
);
53 if (bitmask
!= MASKDWORD
) {
54 originalvalue
= rtl_read_dword(rtlpriv
, regaddr
);
55 bitshift
= _rtl92s_phy_calculate_bit_shift(bitmask
);
56 data
= ((originalvalue
& (~bitmask
)) | (data
<< bitshift
));
59 rtl_write_dword(rtlpriv
, regaddr
, data
);
61 rtl_dbg(rtlpriv
, COMP_RF
, DBG_TRACE
,
62 "regaddr(%#x), bitmask(%#x), data(%#x)\n",
63 regaddr
, bitmask
, data
);
67 static u32
_rtl92s_phy_rf_serial_read(struct ieee80211_hw
*hw
,
68 enum radio_path rfpath
, u32 offset
)
71 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
72 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
73 struct bb_reg_def
*pphyreg
= &rtlphy
->phyreg_def
[rfpath
];
75 u32 tmplong
, tmplong2
;
82 tmplong
= rtl_get_bbreg(hw
, RFPGA0_XA_HSSIPARAMETER2
, MASKDWORD
);
84 if (rfpath
== RF90_PATH_A
)
87 tmplong2
= rtl_get_bbreg(hw
, pphyreg
->rfhssi_para2
, MASKDWORD
);
89 tmplong2
= (tmplong2
& (~BLSSI_READADDRESS
)) | (newoffset
<< 23) |
92 rtl_set_bbreg(hw
, RFPGA0_XA_HSSIPARAMETER2
, MASKDWORD
,
93 tmplong
& (~BLSSI_READEDGE
));
97 rtl_set_bbreg(hw
, pphyreg
->rfhssi_para2
, MASKDWORD
, tmplong2
);
100 rtl_set_bbreg(hw
, RFPGA0_XA_HSSIPARAMETER2
, MASKDWORD
, tmplong
|
104 if (rfpath
== RF90_PATH_A
)
105 rfpi_enable
= (u8
)rtl_get_bbreg(hw
, RFPGA0_XA_HSSIPARAMETER1
,
107 else if (rfpath
== RF90_PATH_B
)
108 rfpi_enable
= (u8
)rtl_get_bbreg(hw
, RFPGA0_XB_HSSIPARAMETER1
,
112 retvalue
= rtl_get_bbreg(hw
, pphyreg
->rf_rbpi
,
113 BLSSI_READBACK_DATA
);
115 retvalue
= rtl_get_bbreg(hw
, pphyreg
->rf_rb
,
116 BLSSI_READBACK_DATA
);
118 retvalue
= rtl_get_bbreg(hw
, pphyreg
->rf_rb
,
119 BLSSI_READBACK_DATA
);
121 rtl_dbg(rtlpriv
, COMP_RF
, DBG_TRACE
, "RFR-%d Addr[0x%x]=0x%x\n",
122 rfpath
, pphyreg
->rf_rb
, retvalue
);
128 static void _rtl92s_phy_rf_serial_write(struct ieee80211_hw
*hw
,
129 enum radio_path rfpath
, u32 offset
,
132 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
133 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
134 struct bb_reg_def
*pphyreg
= &rtlphy
->phyreg_def
[rfpath
];
135 u32 data_and_addr
= 0;
141 data_and_addr
= ((newoffset
<< 20) | (data
& 0x000fffff)) & 0x0fffffff;
142 rtl_set_bbreg(hw
, pphyreg
->rf3wire_offset
, MASKDWORD
, data_and_addr
);
144 rtl_dbg(rtlpriv
, COMP_RF
, DBG_TRACE
, "RFW-%d Addr[0x%x]=0x%x\n",
145 rfpath
, pphyreg
->rf3wire_offset
, data_and_addr
);
149 u32
rtl92s_phy_query_rf_reg(struct ieee80211_hw
*hw
, enum radio_path rfpath
,
150 u32 regaddr
, u32 bitmask
)
152 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
153 u32 original_value
, readback_value
, bitshift
;
155 rtl_dbg(rtlpriv
, COMP_RF
, DBG_TRACE
,
156 "regaddr(%#x), rfpath(%#x), bitmask(%#x)\n",
157 regaddr
, rfpath
, bitmask
);
159 spin_lock(&rtlpriv
->locks
.rf_lock
);
161 original_value
= _rtl92s_phy_rf_serial_read(hw
, rfpath
, regaddr
);
163 bitshift
= _rtl92s_phy_calculate_bit_shift(bitmask
);
164 readback_value
= (original_value
& bitmask
) >> bitshift
;
166 spin_unlock(&rtlpriv
->locks
.rf_lock
);
168 rtl_dbg(rtlpriv
, COMP_RF
, DBG_TRACE
,
169 "regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n",
170 regaddr
, rfpath
, bitmask
, original_value
);
172 return readback_value
;
175 void rtl92s_phy_set_rf_reg(struct ieee80211_hw
*hw
, enum radio_path rfpath
,
176 u32 regaddr
, u32 bitmask
, u32 data
)
178 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
179 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
180 u32 original_value
, bitshift
;
182 if (!((rtlphy
->rf_pathmap
>> rfpath
) & 0x1))
185 rtl_dbg(rtlpriv
, COMP_RF
, DBG_TRACE
,
186 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
187 regaddr
, bitmask
, data
, rfpath
);
189 spin_lock(&rtlpriv
->locks
.rf_lock
);
191 if (bitmask
!= RFREG_OFFSET_MASK
) {
192 original_value
= _rtl92s_phy_rf_serial_read(hw
, rfpath
,
194 bitshift
= _rtl92s_phy_calculate_bit_shift(bitmask
);
195 data
= ((original_value
& (~bitmask
)) | (data
<< bitshift
));
198 _rtl92s_phy_rf_serial_write(hw
, rfpath
, regaddr
, data
);
200 spin_unlock(&rtlpriv
->locks
.rf_lock
);
202 rtl_dbg(rtlpriv
, COMP_RF
, DBG_TRACE
,
203 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
204 regaddr
, bitmask
, data
, rfpath
);
208 void rtl92s_phy_scan_operation_backup(struct ieee80211_hw
*hw
,
211 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
213 if (!is_hal_stop(rtlhal
)) {
215 case SCAN_OPT_BACKUP
:
216 rtl92s_phy_set_fw_cmd(hw
, FW_CMD_PAUSE_DM_BY_SCAN
);
218 case SCAN_OPT_RESTORE
:
219 rtl92s_phy_set_fw_cmd(hw
, FW_CMD_RESUME_DM_BY_SCAN
);
222 pr_err("Unknown operation\n");
228 void rtl92s_phy_set_bw_mode(struct ieee80211_hw
*hw
,
229 enum nl80211_channel_type ch_type
)
231 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
232 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
233 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
234 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
237 rtl_dbg(rtlpriv
, COMP_SCAN
, DBG_TRACE
, "Switch to %s bandwidth\n",
238 rtlphy
->current_chan_bw
== HT_CHANNEL_WIDTH_20
?
241 if (rtlphy
->set_bwmode_inprogress
)
243 if (is_hal_stop(rtlhal
))
246 rtlphy
->set_bwmode_inprogress
= true;
248 reg_bw_opmode
= rtl_read_byte(rtlpriv
, BW_OPMODE
);
250 rtl_read_byte(rtlpriv
, RRSR
+ 2);
252 switch (rtlphy
->current_chan_bw
) {
253 case HT_CHANNEL_WIDTH_20
:
254 reg_bw_opmode
|= BW_OPMODE_20MHZ
;
255 rtl_write_byte(rtlpriv
, BW_OPMODE
, reg_bw_opmode
);
257 case HT_CHANNEL_WIDTH_20_40
:
258 reg_bw_opmode
&= ~BW_OPMODE_20MHZ
;
259 rtl_write_byte(rtlpriv
, BW_OPMODE
, reg_bw_opmode
);
262 pr_err("unknown bandwidth: %#X\n",
263 rtlphy
->current_chan_bw
);
267 switch (rtlphy
->current_chan_bw
) {
268 case HT_CHANNEL_WIDTH_20
:
269 rtl_set_bbreg(hw
, RFPGA0_RFMOD
, BRFMOD
, 0x0);
270 rtl_set_bbreg(hw
, RFPGA1_RFMOD
, BRFMOD
, 0x0);
272 if (rtlhal
->version
>= VERSION_8192S_BCUT
)
273 rtl_write_byte(rtlpriv
, RFPGA0_ANALOGPARAMETER2
, 0x58);
275 case HT_CHANNEL_WIDTH_20_40
:
276 rtl_set_bbreg(hw
, RFPGA0_RFMOD
, BRFMOD
, 0x1);
277 rtl_set_bbreg(hw
, RFPGA1_RFMOD
, BRFMOD
, 0x1);
279 rtl_set_bbreg(hw
, RCCK0_SYSTEM
, BCCK_SIDEBAND
,
280 (mac
->cur_40_prime_sc
>> 1));
281 rtl_set_bbreg(hw
, ROFDM1_LSTF
, 0xC00, mac
->cur_40_prime_sc
);
283 if (rtlhal
->version
>= VERSION_8192S_BCUT
)
284 rtl_write_byte(rtlpriv
, RFPGA0_ANALOGPARAMETER2
, 0x18);
287 pr_err("unknown bandwidth: %#X\n",
288 rtlphy
->current_chan_bw
);
292 rtl92s_phy_rf6052_set_bandwidth(hw
, rtlphy
->current_chan_bw
);
293 rtlphy
->set_bwmode_inprogress
= false;
294 rtl_dbg(rtlpriv
, COMP_SCAN
, DBG_TRACE
, "<==\n");
297 static bool _rtl92s_phy_set_sw_chnl_cmdarray(struct swchnlcmd
*cmdtable
,
298 u32 cmdtableidx
, u32 cmdtablesz
, enum swchnlcmd_id cmdid
,
299 u32 para1
, u32 para2
, u32 msdelay
)
301 struct swchnlcmd
*pcmd
;
303 if (cmdtable
== NULL
) {
304 WARN_ONCE(true, "rtl8192se: cmdtable cannot be NULL\n");
308 if (cmdtableidx
>= cmdtablesz
)
311 pcmd
= cmdtable
+ cmdtableidx
;
315 pcmd
->msdelay
= msdelay
;
320 static bool _rtl92s_phy_sw_chnl_step_by_step(struct ieee80211_hw
*hw
,
321 u8 channel
, u8
*stage
, u8
*step
, u32
*delay
)
323 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
324 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
325 struct swchnlcmd precommoncmd
[MAX_PRECMD_CNT
];
327 struct swchnlcmd postcommoncmd
[MAX_POSTCMD_CNT
];
328 u32 postcommoncmdcnt
;
329 struct swchnlcmd rfdependcmd
[MAX_RFDEPENDCMD_CNT
];
331 struct swchnlcmd
*currentcmd
= NULL
;
333 u8 num_total_rfpath
= rtlphy
->num_total_rfpath
;
336 _rtl92s_phy_set_sw_chnl_cmdarray(precommoncmd
, precommoncmdcnt
++,
337 MAX_PRECMD_CNT
, CMDID_SET_TXPOWEROWER_LEVEL
, 0, 0, 0);
338 _rtl92s_phy_set_sw_chnl_cmdarray(precommoncmd
, precommoncmdcnt
++,
339 MAX_PRECMD_CNT
, CMDID_END
, 0, 0, 0);
341 postcommoncmdcnt
= 0;
343 _rtl92s_phy_set_sw_chnl_cmdarray(postcommoncmd
, postcommoncmdcnt
++,
344 MAX_POSTCMD_CNT
, CMDID_END
, 0, 0, 0);
348 WARN_ONCE((channel
< 1 || channel
> 14),
349 "rtl8192se: invalid channel for Zebra: %d\n", channel
);
351 _rtl92s_phy_set_sw_chnl_cmdarray(rfdependcmd
, rfdependcmdcnt
++,
352 MAX_RFDEPENDCMD_CNT
, CMDID_RF_WRITEREG
,
353 RF_CHNLBW
, channel
, 10);
355 _rtl92s_phy_set_sw_chnl_cmdarray(rfdependcmd
, rfdependcmdcnt
++,
356 MAX_RFDEPENDCMD_CNT
, CMDID_END
, 0, 0, 0);
361 currentcmd
= &precommoncmd
[*step
];
364 currentcmd
= &rfdependcmd
[*step
];
367 currentcmd
= &postcommoncmd
[*step
];
373 if (currentcmd
->cmdid
== CMDID_END
) {
383 switch (currentcmd
->cmdid
) {
384 case CMDID_SET_TXPOWEROWER_LEVEL
:
385 rtl92s_phy_set_txpower(hw
, channel
);
387 case CMDID_WRITEPORT_ULONG
:
388 rtl_write_dword(rtlpriv
, currentcmd
->para1
,
391 case CMDID_WRITEPORT_USHORT
:
392 rtl_write_word(rtlpriv
, currentcmd
->para1
,
393 (u16
)currentcmd
->para2
);
395 case CMDID_WRITEPORT_UCHAR
:
396 rtl_write_byte(rtlpriv
, currentcmd
->para1
,
397 (u8
)currentcmd
->para2
);
399 case CMDID_RF_WRITEREG
:
400 for (rfpath
= 0; rfpath
< num_total_rfpath
; rfpath
++) {
401 rtlphy
->rfreg_chnlval
[rfpath
] =
402 ((rtlphy
->rfreg_chnlval
[rfpath
] &
403 0xfffffc00) | currentcmd
->para2
);
404 rtl_set_rfreg(hw
, (enum radio_path
)rfpath
,
407 rtlphy
->rfreg_chnlval
[rfpath
]);
411 pr_err("switch case %#x not processed\n",
419 (*delay
) = currentcmd
->msdelay
;
424 u8
rtl92s_phy_sw_chnl(struct ieee80211_hw
*hw
)
426 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
427 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
428 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
432 rtl_dbg(rtlpriv
, COMP_SCAN
, DBG_TRACE
, "switch to channel%d\n",
433 rtlphy
->current_channel
);
435 if (rtlphy
->sw_chnl_inprogress
)
438 if (rtlphy
->set_bwmode_inprogress
)
441 if (is_hal_stop(rtlhal
))
444 rtlphy
->sw_chnl_inprogress
= true;
445 rtlphy
->sw_chnl_stage
= 0;
446 rtlphy
->sw_chnl_step
= 0;
449 if (!rtlphy
->sw_chnl_inprogress
)
452 ret
= _rtl92s_phy_sw_chnl_step_by_step(hw
,
453 rtlphy
->current_channel
,
454 &rtlphy
->sw_chnl_stage
,
455 &rtlphy
->sw_chnl_step
, &delay
);
462 rtlphy
->sw_chnl_inprogress
= false;
467 rtlphy
->sw_chnl_inprogress
= false;
469 rtl_dbg(rtlpriv
, COMP_SCAN
, DBG_TRACE
, "<==\n");
474 static void _rtl92se_phy_set_rf_sleep(struct ieee80211_hw
*hw
)
476 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
479 u1btmp
= rtl_read_byte(rtlpriv
, LDOV12D_CTRL
);
482 rtl_write_byte(rtlpriv
, LDOV12D_CTRL
, u1btmp
);
483 rtl_write_byte(rtlpriv
, SPS1_CTRL
, 0x0);
484 rtl_write_byte(rtlpriv
, TXPAUSE
, 0xFF);
485 rtl_write_word(rtlpriv
, CMDR
, 0x57FC);
488 rtl_write_word(rtlpriv
, CMDR
, 0x77FC);
489 rtl_write_byte(rtlpriv
, PHY_CCA
, 0x0);
492 rtl_write_word(rtlpriv
, CMDR
, 0x37FC);
495 rtl_write_word(rtlpriv
, CMDR
, 0x77FC);
498 rtl_write_word(rtlpriv
, CMDR
, 0x57FC);
500 /* we should chnge GPIO to input mode
501 * this will drop away current about 25mA*/
502 rtl8192se_gpiobit3_cfg_inputmode(hw
);
505 bool rtl92s_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 if (rfpwr_state
== ppsc
->rfpwr_state
)
519 switch (rfpwr_state
) {
521 if ((ppsc
->rfpwr_state
== ERFOFF
) &&
522 RT_IN_PS_LEVEL(ppsc
, RT_RF_OFF_LEVL_HALT_NIC
)) {
525 u32 initializecount
= 0;
528 rtl_dbg(rtlpriv
, COMP_RF
, DBG_DMESG
,
529 "IPS Set eRf nic enable\n");
530 rtstatus
= rtl_ps_enable_nic(hw
);
531 } while (!rtstatus
&& (initializecount
< 10));
533 RT_CLEAR_PS_LEVEL(ppsc
,
534 RT_RF_OFF_LEVL_HALT_NIC
);
536 rtl_dbg(rtlpriv
, COMP_POWER
, DBG_DMESG
,
537 "awake, slept:%d ms state_inap:%x\n",
538 jiffies_to_msecs(jiffies
-
539 ppsc
->last_sleep_jiffies
),
540 rtlpriv
->psc
.state_inap
);
541 ppsc
->last_awake_jiffies
= jiffies
;
542 rtl_write_word(rtlpriv
, CMDR
, 0x37FC);
543 rtl_write_byte(rtlpriv
, TXPAUSE
, 0x00);
544 rtl_write_byte(rtlpriv
, PHY_CCA
, 0x3);
547 if (mac
->link_state
== MAC80211_LINKED
)
548 rtlpriv
->cfg
->ops
->led_control(hw
,
551 rtlpriv
->cfg
->ops
->led_control(hw
,
556 if (ppsc
->reg_rfps_level
& RT_RF_OFF_LEVL_HALT_NIC
) {
557 rtl_dbg(rtlpriv
, COMP_RF
, DBG_DMESG
,
558 "IPS Set eRf nic disable\n");
559 rtl_ps_disable_nic(hw
);
560 RT_SET_PS_LEVEL(ppsc
, RT_RF_OFF_LEVL_HALT_NIC
);
562 if (ppsc
->rfoff_reason
== RF_CHANGE_BY_IPS
)
563 rtlpriv
->cfg
->ops
->led_control(hw
,
566 rtlpriv
->cfg
->ops
->led_control(hw
,
572 if (ppsc
->rfpwr_state
== ERFOFF
)
575 for (queue_id
= 0, i
= 0;
576 queue_id
< RTL_PCI_MAX_TX_QUEUE_COUNT
;) {
577 ring
= &pcipriv
->dev
.tx_ring
[queue_id
];
578 if (skb_queue_len(&ring
->queue
) == 0 ||
579 queue_id
== BEACON_QUEUE
) {
583 rtl_dbg(rtlpriv
, COMP_ERR
, DBG_WARNING
,
584 "eRf Off/Sleep: %d times TcbBusyQueue[%d] = %d before doze!\n",
586 skb_queue_len(&ring
->queue
));
592 if (i
>= MAX_DOZE_WAITING_TIMES_9x
) {
593 rtl_dbg(rtlpriv
, COMP_ERR
, DBG_WARNING
,
594 "ERFOFF: %d times TcbBusyQueue[%d] = %d !\n",
595 MAX_DOZE_WAITING_TIMES_9x
,
597 skb_queue_len(&ring
->queue
));
602 rtl_dbg(rtlpriv
, COMP_POWER
, DBG_DMESG
,
603 "Set ERFSLEEP awaked:%d ms\n",
604 jiffies_to_msecs(jiffies
-
605 ppsc
->last_awake_jiffies
));
607 rtl_dbg(rtlpriv
, COMP_POWER
, DBG_DMESG
,
608 "sleep awaked:%d ms state_inap:%x\n",
609 jiffies_to_msecs(jiffies
-
610 ppsc
->last_awake_jiffies
),
611 rtlpriv
->psc
.state_inap
);
612 ppsc
->last_sleep_jiffies
= jiffies
;
613 _rtl92se_phy_set_rf_sleep(hw
);
616 pr_err("switch case %#x not processed\n",
623 ppsc
->rfpwr_state
= rfpwr_state
;
628 static bool _rtl92s_phy_config_rfpa_bias_current(struct ieee80211_hw
*hw
,
629 enum radio_path rfpath
)
631 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
632 bool rtstatus
= true;
635 /* If inferiority IC, we have to increase the PA bias current */
636 if (rtlhal
->ic_class
!= IC_INFERIORITY_A
) {
637 tmpval
= rtl92s_phy_query_rf_reg(hw
, rfpath
, RF_IPA
, 0xf);
638 rtl92s_phy_set_rf_reg(hw
, rfpath
, RF_IPA
, 0xf, tmpval
+ 1);
644 static void _rtl92s_store_pwrindex_diffrate_offset(struct ieee80211_hw
*hw
,
645 u32 reg_addr
, u32 bitmask
, u32 data
)
647 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
648 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
651 if (reg_addr
== RTXAGC_RATE18_06
)
653 else if (reg_addr
== RTXAGC_RATE54_24
)
655 else if (reg_addr
== RTXAGC_CCK_MCS32
)
657 else if (reg_addr
== RTXAGC_MCS03_MCS00
)
659 else if (reg_addr
== RTXAGC_MCS07_MCS04
)
661 else if (reg_addr
== RTXAGC_MCS11_MCS08
)
663 else if (reg_addr
== RTXAGC_MCS15_MCS12
)
668 rtlphy
->mcs_offset
[rtlphy
->pwrgroup_cnt
][index
] = data
;
670 rtlphy
->pwrgroup_cnt
++;
673 static void _rtl92s_phy_init_register_definition(struct ieee80211_hw
*hw
)
675 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
676 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
678 /*RF Interface Sowrtware Control */
679 rtlphy
->phyreg_def
[RF90_PATH_A
].rfintfs
= RFPGA0_XAB_RFINTERFACESW
;
680 rtlphy
->phyreg_def
[RF90_PATH_B
].rfintfs
= RFPGA0_XAB_RFINTERFACESW
;
681 rtlphy
->phyreg_def
[RF90_PATH_C
].rfintfs
= RFPGA0_XCD_RFINTERFACESW
;
682 rtlphy
->phyreg_def
[RF90_PATH_D
].rfintfs
= RFPGA0_XCD_RFINTERFACESW
;
684 /* RF Interface Readback Value */
685 rtlphy
->phyreg_def
[RF90_PATH_A
].rfintfi
= RFPGA0_XAB_RFINTERFACERB
;
686 rtlphy
->phyreg_def
[RF90_PATH_B
].rfintfi
= RFPGA0_XAB_RFINTERFACERB
;
687 rtlphy
->phyreg_def
[RF90_PATH_C
].rfintfi
= RFPGA0_XCD_RFINTERFACERB
;
688 rtlphy
->phyreg_def
[RF90_PATH_D
].rfintfi
= RFPGA0_XCD_RFINTERFACERB
;
690 /* RF Interface Output (and Enable) */
691 rtlphy
->phyreg_def
[RF90_PATH_A
].rfintfo
= RFPGA0_XA_RFINTERFACEOE
;
692 rtlphy
->phyreg_def
[RF90_PATH_B
].rfintfo
= RFPGA0_XB_RFINTERFACEOE
;
693 rtlphy
->phyreg_def
[RF90_PATH_C
].rfintfo
= RFPGA0_XC_RFINTERFACEOE
;
694 rtlphy
->phyreg_def
[RF90_PATH_D
].rfintfo
= RFPGA0_XD_RFINTERFACEOE
;
696 /* RF Interface (Output and) Enable */
697 rtlphy
->phyreg_def
[RF90_PATH_A
].rfintfe
= RFPGA0_XA_RFINTERFACEOE
;
698 rtlphy
->phyreg_def
[RF90_PATH_B
].rfintfe
= RFPGA0_XB_RFINTERFACEOE
;
699 rtlphy
->phyreg_def
[RF90_PATH_C
].rfintfe
= RFPGA0_XC_RFINTERFACEOE
;
700 rtlphy
->phyreg_def
[RF90_PATH_D
].rfintfe
= RFPGA0_XD_RFINTERFACEOE
;
702 /* Addr of LSSI. Wirte RF register by driver */
703 rtlphy
->phyreg_def
[RF90_PATH_A
].rf3wire_offset
=
704 RFPGA0_XA_LSSIPARAMETER
;
705 rtlphy
->phyreg_def
[RF90_PATH_B
].rf3wire_offset
=
706 RFPGA0_XB_LSSIPARAMETER
;
707 rtlphy
->phyreg_def
[RF90_PATH_C
].rf3wire_offset
=
708 RFPGA0_XC_LSSIPARAMETER
;
709 rtlphy
->phyreg_def
[RF90_PATH_D
].rf3wire_offset
=
710 RFPGA0_XD_LSSIPARAMETER
;
713 rtlphy
->phyreg_def
[RF90_PATH_A
].rflssi_select
= RFPGA0_XAB_RFPARAMETER
;
714 rtlphy
->phyreg_def
[RF90_PATH_B
].rflssi_select
= RFPGA0_XAB_RFPARAMETER
;
715 rtlphy
->phyreg_def
[RF90_PATH_C
].rflssi_select
= RFPGA0_XCD_RFPARAMETER
;
716 rtlphy
->phyreg_def
[RF90_PATH_D
].rflssi_select
= RFPGA0_XCD_RFPARAMETER
;
718 /* Tx AGC Gain Stage (same for all path. Should we remove this?) */
719 rtlphy
->phyreg_def
[RF90_PATH_A
].rftxgain_stage
= RFPGA0_TXGAINSTAGE
;
720 rtlphy
->phyreg_def
[RF90_PATH_B
].rftxgain_stage
= RFPGA0_TXGAINSTAGE
;
721 rtlphy
->phyreg_def
[RF90_PATH_C
].rftxgain_stage
= RFPGA0_TXGAINSTAGE
;
722 rtlphy
->phyreg_def
[RF90_PATH_D
].rftxgain_stage
= RFPGA0_TXGAINSTAGE
;
724 /* Tranceiver A~D HSSI Parameter-1 */
725 rtlphy
->phyreg_def
[RF90_PATH_A
].rfhssi_para1
= RFPGA0_XA_HSSIPARAMETER1
;
726 rtlphy
->phyreg_def
[RF90_PATH_B
].rfhssi_para1
= RFPGA0_XB_HSSIPARAMETER1
;
727 rtlphy
->phyreg_def
[RF90_PATH_C
].rfhssi_para1
= RFPGA0_XC_HSSIPARAMETER1
;
728 rtlphy
->phyreg_def
[RF90_PATH_D
].rfhssi_para1
= RFPGA0_XD_HSSIPARAMETER1
;
730 /* Tranceiver A~D HSSI Parameter-2 */
731 rtlphy
->phyreg_def
[RF90_PATH_A
].rfhssi_para2
= RFPGA0_XA_HSSIPARAMETER2
;
732 rtlphy
->phyreg_def
[RF90_PATH_B
].rfhssi_para2
= RFPGA0_XB_HSSIPARAMETER2
;
733 rtlphy
->phyreg_def
[RF90_PATH_C
].rfhssi_para2
= RFPGA0_XC_HSSIPARAMETER2
;
734 rtlphy
->phyreg_def
[RF90_PATH_D
].rfhssi_para2
= RFPGA0_XD_HSSIPARAMETER2
;
736 /* RF switch Control */
737 rtlphy
->phyreg_def
[RF90_PATH_A
].rfsw_ctrl
= RFPGA0_XAB_SWITCHCONTROL
;
738 rtlphy
->phyreg_def
[RF90_PATH_B
].rfsw_ctrl
= RFPGA0_XAB_SWITCHCONTROL
;
739 rtlphy
->phyreg_def
[RF90_PATH_C
].rfsw_ctrl
= RFPGA0_XCD_SWITCHCONTROL
;
740 rtlphy
->phyreg_def
[RF90_PATH_D
].rfsw_ctrl
= RFPGA0_XCD_SWITCHCONTROL
;
743 rtlphy
->phyreg_def
[RF90_PATH_A
].rfagc_control1
= ROFDM0_XAAGCCORE1
;
744 rtlphy
->phyreg_def
[RF90_PATH_B
].rfagc_control1
= ROFDM0_XBAGCCORE1
;
745 rtlphy
->phyreg_def
[RF90_PATH_C
].rfagc_control1
= ROFDM0_XCAGCCORE1
;
746 rtlphy
->phyreg_def
[RF90_PATH_D
].rfagc_control1
= ROFDM0_XDAGCCORE1
;
749 rtlphy
->phyreg_def
[RF90_PATH_A
].rfagc_control2
= ROFDM0_XAAGCCORE2
;
750 rtlphy
->phyreg_def
[RF90_PATH_B
].rfagc_control2
= ROFDM0_XBAGCCORE2
;
751 rtlphy
->phyreg_def
[RF90_PATH_C
].rfagc_control2
= ROFDM0_XCAGCCORE2
;
752 rtlphy
->phyreg_def
[RF90_PATH_D
].rfagc_control2
= ROFDM0_XDAGCCORE2
;
754 /* RX AFE control 1 */
755 rtlphy
->phyreg_def
[RF90_PATH_A
].rfrxiq_imbal
= ROFDM0_XARXIQIMBALANCE
;
756 rtlphy
->phyreg_def
[RF90_PATH_B
].rfrxiq_imbal
= ROFDM0_XBRXIQIMBALANCE
;
757 rtlphy
->phyreg_def
[RF90_PATH_C
].rfrxiq_imbal
= ROFDM0_XCRXIQIMBALANCE
;
758 rtlphy
->phyreg_def
[RF90_PATH_D
].rfrxiq_imbal
= ROFDM0_XDRXIQIMBALANCE
;
760 /* RX AFE control 1 */
761 rtlphy
->phyreg_def
[RF90_PATH_A
].rfrx_afe
= ROFDM0_XARXAFE
;
762 rtlphy
->phyreg_def
[RF90_PATH_B
].rfrx_afe
= ROFDM0_XBRXAFE
;
763 rtlphy
->phyreg_def
[RF90_PATH_C
].rfrx_afe
= ROFDM0_XCRXAFE
;
764 rtlphy
->phyreg_def
[RF90_PATH_D
].rfrx_afe
= ROFDM0_XDRXAFE
;
766 /* Tx AFE control 1 */
767 rtlphy
->phyreg_def
[RF90_PATH_A
].rftxiq_imbal
= ROFDM0_XATXIQIMBALANCE
;
768 rtlphy
->phyreg_def
[RF90_PATH_B
].rftxiq_imbal
= ROFDM0_XBTXIQIMBALANCE
;
769 rtlphy
->phyreg_def
[RF90_PATH_C
].rftxiq_imbal
= ROFDM0_XCTXIQIMBALANCE
;
770 rtlphy
->phyreg_def
[RF90_PATH_D
].rftxiq_imbal
= ROFDM0_XDTXIQIMBALANCE
;
772 /* Tx AFE control 2 */
773 rtlphy
->phyreg_def
[RF90_PATH_A
].rftx_afe
= ROFDM0_XATXAFE
;
774 rtlphy
->phyreg_def
[RF90_PATH_B
].rftx_afe
= ROFDM0_XBTXAFE
;
775 rtlphy
->phyreg_def
[RF90_PATH_C
].rftx_afe
= ROFDM0_XCTXAFE
;
776 rtlphy
->phyreg_def
[RF90_PATH_D
].rftx_afe
= ROFDM0_XDTXAFE
;
778 /* Tranceiver LSSI Readback */
779 rtlphy
->phyreg_def
[RF90_PATH_A
].rf_rb
= RFPGA0_XA_LSSIREADBACK
;
780 rtlphy
->phyreg_def
[RF90_PATH_B
].rf_rb
= RFPGA0_XB_LSSIREADBACK
;
781 rtlphy
->phyreg_def
[RF90_PATH_C
].rf_rb
= RFPGA0_XC_LSSIREADBACK
;
782 rtlphy
->phyreg_def
[RF90_PATH_D
].rf_rb
= RFPGA0_XD_LSSIREADBACK
;
784 /* Tranceiver LSSI Readback PI mode */
785 rtlphy
->phyreg_def
[RF90_PATH_A
].rf_rbpi
= TRANSCEIVERA_HSPI_READBACK
;
786 rtlphy
->phyreg_def
[RF90_PATH_B
].rf_rbpi
= TRANSCEIVERB_HSPI_READBACK
;
790 static bool _rtl92s_phy_config_bb(struct ieee80211_hw
*hw
, u8 configtype
)
795 u16 phy_reg_len
, agc_len
;
797 agc_len
= AGCTAB_ARRAYLENGTH
;
798 agc_table
= rtl8192seagctab_array
;
799 /* Default RF_type: 2T2R */
800 phy_reg_len
= PHY_REG_2T2RARRAYLENGTH
;
801 phy_reg_table
= rtl8192sephy_reg_2t2rarray
;
803 if (configtype
== BASEBAND_CONFIG_PHY_REG
) {
804 for (i
= 0; i
< phy_reg_len
; i
= i
+ 2) {
805 rtl_addr_delay(phy_reg_table
[i
]);
807 /* Add delay for ECS T20 & LG malow platform, */
810 rtl92s_phy_set_bb_reg(hw
, phy_reg_table
[i
], MASKDWORD
,
811 phy_reg_table
[i
+ 1]);
813 } else if (configtype
== BASEBAND_CONFIG_AGC_TAB
) {
814 for (i
= 0; i
< agc_len
; i
= i
+ 2) {
815 rtl92s_phy_set_bb_reg(hw
, agc_table
[i
], MASKDWORD
,
818 /* Add delay for ECS T20 & LG malow platform */
826 static bool _rtl92s_phy_set_bb_to_diff_rf(struct ieee80211_hw
*hw
,
829 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
830 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
831 u32
*phy_regarray2xtxr_table
;
832 u16 phy_regarray2xtxr_len
;
835 if (rtlphy
->rf_type
== RF_1T1R
) {
836 phy_regarray2xtxr_table
= rtl8192sephy_changeto_1t1rarray
;
837 phy_regarray2xtxr_len
= PHY_CHANGETO_1T1RARRAYLENGTH
;
838 } else if (rtlphy
->rf_type
== RF_1T2R
) {
839 phy_regarray2xtxr_table
= rtl8192sephy_changeto_1t2rarray
;
840 phy_regarray2xtxr_len
= PHY_CHANGETO_1T2RARRAYLENGTH
;
845 if (configtype
== BASEBAND_CONFIG_PHY_REG
) {
846 for (i
= 0; i
< phy_regarray2xtxr_len
; i
= i
+ 3) {
847 rtl_addr_delay(phy_regarray2xtxr_table
[i
]);
849 rtl92s_phy_set_bb_reg(hw
, phy_regarray2xtxr_table
[i
],
850 phy_regarray2xtxr_table
[i
+ 1],
851 phy_regarray2xtxr_table
[i
+ 2]);
858 static bool _rtl92s_phy_config_bb_with_pg(struct ieee80211_hw
*hw
,
865 phy_pg_len
= PHY_REG_ARRAY_PGLENGTH
;
866 phy_table_pg
= rtl8192sephy_reg_array_pg
;
868 if (configtype
== BASEBAND_CONFIG_PHY_REG
) {
869 for (i
= 0; i
< phy_pg_len
; i
= i
+ 3) {
870 rtl_addr_delay(phy_table_pg
[i
]);
872 _rtl92s_store_pwrindex_diffrate_offset(hw
,
875 phy_table_pg
[i
+ 2]);
876 rtl92s_phy_set_bb_reg(hw
, phy_table_pg
[i
],
878 phy_table_pg
[i
+ 2]);
885 static bool _rtl92s_phy_bb_config_parafile(struct ieee80211_hw
*hw
)
887 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
888 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
889 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
890 bool rtstatus
= true;
892 /* 1. Read PHY_REG.TXT BB INIT!! */
893 /* We will separate as 1T1R/1T2R/1T2R_GREEN/2T2R */
894 if (rtlphy
->rf_type
== RF_1T2R
|| rtlphy
->rf_type
== RF_2T2R
||
895 rtlphy
->rf_type
== RF_1T1R
|| rtlphy
->rf_type
== RF_2T2R_GREEN
) {
896 rtstatus
= _rtl92s_phy_config_bb(hw
, BASEBAND_CONFIG_PHY_REG
);
898 if (rtlphy
->rf_type
!= RF_2T2R
&&
899 rtlphy
->rf_type
!= RF_2T2R_GREEN
)
900 /* so we should reconfig BB reg with the right
902 rtstatus
= _rtl92s_phy_set_bb_to_diff_rf(hw
,
903 BASEBAND_CONFIG_PHY_REG
);
909 pr_err("Write BB Reg Fail!!\n");
910 goto phy_bb8190_config_parafile_fail
;
913 /* 2. If EEPROM or EFUSE autoload OK, We must config by
915 if (rtlefuse
->autoload_failflag
== false) {
916 rtlphy
->pwrgroup_cnt
= 0;
918 rtstatus
= _rtl92s_phy_config_bb_with_pg(hw
,
919 BASEBAND_CONFIG_PHY_REG
);
922 pr_err("_rtl92s_phy_bb_config_parafile(): BB_PG Reg Fail!!\n");
923 goto phy_bb8190_config_parafile_fail
;
926 /* 3. BB AGC table Initialization */
927 rtstatus
= _rtl92s_phy_config_bb(hw
, BASEBAND_CONFIG_AGC_TAB
);
930 pr_err("%s(): AGC Table Fail\n", __func__
);
931 goto phy_bb8190_config_parafile_fail
;
934 /* Check if the CCK HighPower is turned ON. */
935 /* This is used to calculate PWDB. */
936 rtlphy
->cck_high_power
= (bool)(rtl92s_phy_query_bb_reg(hw
,
937 RFPGA0_XA_HSSIPARAMETER2
, 0x200));
939 phy_bb8190_config_parafile_fail
:
943 u8
rtl92s_phy_config_rf(struct ieee80211_hw
*hw
, enum radio_path rfpath
)
945 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
946 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
948 bool rtstatus
= true;
951 u16 radio_a_tblen
, radio_b_tblen
;
953 radio_a_tblen
= RADIOA_1T_ARRAYLENGTH
;
954 radio_a_table
= rtl8192seradioa_1t_array
;
956 /* Using Green mode array table for RF_2T2R_GREEN */
957 if (rtlphy
->rf_type
== RF_2T2R_GREEN
) {
958 radio_b_table
= rtl8192seradiob_gm_array
;
959 radio_b_tblen
= RADIOB_GM_ARRAYLENGTH
;
961 radio_b_table
= rtl8192seradiob_array
;
962 radio_b_tblen
= RADIOB_ARRAYLENGTH
;
965 rtl_dbg(rtlpriv
, COMP_INIT
, DBG_LOUD
, "Radio No %x\n", rfpath
);
970 for (i
= 0; i
< radio_a_tblen
; i
= i
+ 2) {
971 rtl_rfreg_delay(hw
, rfpath
, radio_a_table
[i
],
972 MASK20BITS
, radio_a_table
[i
+ 1]);
976 /* PA Bias current for inferiority IC */
977 _rtl92s_phy_config_rfpa_bias_current(hw
, rfpath
);
980 for (i
= 0; i
< radio_b_tblen
; i
= i
+ 2) {
981 rtl_rfreg_delay(hw
, rfpath
, radio_b_table
[i
],
982 MASK20BITS
, radio_b_table
[i
+ 1]);
999 bool rtl92s_phy_mac_config(struct ieee80211_hw
*hw
)
1001 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1006 arraylength
= MAC_2T_ARRAYLENGTH
;
1007 ptrarray
= rtl8192semac_2t_array
;
1009 for (i
= 0; i
< arraylength
; i
= i
+ 2)
1010 rtl_write_byte(rtlpriv
, ptrarray
[i
], (u8
)ptrarray
[i
+ 1]);
1016 bool rtl92s_phy_bb_config(struct ieee80211_hw
*hw
)
1018 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1019 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1020 bool rtstatus
= true;
1021 u8 pathmap
, index
, rf_num
= 0;
1024 _rtl92s_phy_init_register_definition(hw
);
1026 /* Config BB and AGC */
1027 rtstatus
= _rtl92s_phy_bb_config_parafile(hw
);
1030 /* Check BB/RF confiuration setting. */
1031 /* We only need to configure RF which is turned on. */
1032 path1
= (u8
)(rtl92s_phy_query_bb_reg(hw
, RFPGA0_TXINFO
, 0xf));
1034 path2
= (u8
)(rtl92s_phy_query_bb_reg(hw
, ROFDM0_TRXPATHENABLE
, 0xf));
1035 pathmap
= path1
| path2
;
1037 rtlphy
->rf_pathmap
= pathmap
;
1038 for (index
= 0; index
< 4; index
++) {
1039 if ((pathmap
>> index
) & 0x1)
1043 if ((rtlphy
->rf_type
== RF_1T1R
&& rf_num
!= 1) ||
1044 (rtlphy
->rf_type
== RF_1T2R
&& rf_num
!= 2) ||
1045 (rtlphy
->rf_type
== RF_2T2R
&& rf_num
!= 2) ||
1046 (rtlphy
->rf_type
== RF_2T2R_GREEN
&& rf_num
!= 2)) {
1047 pr_err("RF_Type(%x) does not match RF_Num(%x)!!\n",
1048 rtlphy
->rf_type
, rf_num
);
1049 pr_err("path1 0x%x, path2 0x%x, pathmap 0x%x\n",
1050 path1
, path2
, pathmap
);
1056 bool rtl92s_phy_rf_config(struct ieee80211_hw
*hw
)
1058 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1059 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1061 /* Initialize general global value */
1062 if (rtlphy
->rf_type
== RF_1T1R
)
1063 rtlphy
->num_total_rfpath
= 1;
1065 rtlphy
->num_total_rfpath
= 2;
1067 /* Config BB and RF */
1068 return rtl92s_phy_rf6052_config(hw
);
1071 void rtl92s_phy_get_hw_reg_originalvalue(struct ieee80211_hw
*hw
)
1073 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1074 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1076 /* read rx initial gain */
1077 rtlphy
->default_initialgain
[0] = rtl_get_bbreg(hw
,
1078 ROFDM0_XAAGCCORE1
, MASKBYTE0
);
1079 rtlphy
->default_initialgain
[1] = rtl_get_bbreg(hw
,
1080 ROFDM0_XBAGCCORE1
, MASKBYTE0
);
1081 rtlphy
->default_initialgain
[2] = rtl_get_bbreg(hw
,
1082 ROFDM0_XCAGCCORE1
, MASKBYTE0
);
1083 rtlphy
->default_initialgain
[3] = rtl_get_bbreg(hw
,
1084 ROFDM0_XDAGCCORE1
, MASKBYTE0
);
1085 rtl_dbg(rtlpriv
, COMP_INIT
, DBG_LOUD
,
1086 "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x)\n",
1087 rtlphy
->default_initialgain
[0],
1088 rtlphy
->default_initialgain
[1],
1089 rtlphy
->default_initialgain
[2],
1090 rtlphy
->default_initialgain
[3]);
1092 /* read framesync */
1093 rtlphy
->framesync
= rtl_get_bbreg(hw
, ROFDM0_RXDETECTOR3
, MASKBYTE0
);
1094 rtlphy
->framesync_c34
= rtl_get_bbreg(hw
, ROFDM0_RXDETECTOR2
,
1096 rtl_dbg(rtlpriv
, COMP_INIT
, DBG_LOUD
,
1097 "Default framesync (0x%x) = 0x%x\n",
1098 ROFDM0_RXDETECTOR3
, rtlphy
->framesync
);
1102 static void _rtl92s_phy_get_txpower_index(struct ieee80211_hw
*hw
, u8 channel
,
1103 u8
*cckpowerlevel
, u8
*ofdmpowerlevel
)
1105 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1106 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1107 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
1108 u8 index
= (channel
- 1);
1112 cckpowerlevel
[0] = rtlefuse
->txpwrlevel_cck
[0][index
];
1114 cckpowerlevel
[1] = rtlefuse
->txpwrlevel_cck
[1][index
];
1116 /* 2. OFDM for 1T or 2T */
1117 if (rtlphy
->rf_type
== RF_1T2R
|| rtlphy
->rf_type
== RF_1T1R
) {
1118 /* Read HT 40 OFDM TX power */
1119 ofdmpowerlevel
[0] = rtlefuse
->txpwrlevel_ht40_1s
[0][index
];
1120 ofdmpowerlevel
[1] = rtlefuse
->txpwrlevel_ht40_1s
[1][index
];
1121 } else if (rtlphy
->rf_type
== RF_2T2R
) {
1122 /* Read HT 40 OFDM TX power */
1123 ofdmpowerlevel
[0] = rtlefuse
->txpwrlevel_ht40_2s
[0][index
];
1124 ofdmpowerlevel
[1] = rtlefuse
->txpwrlevel_ht40_2s
[1][index
];
1126 ofdmpowerlevel
[0] = 0;
1127 ofdmpowerlevel
[1] = 0;
1131 static void _rtl92s_phy_ccxpower_indexcheck(struct ieee80211_hw
*hw
,
1132 u8 channel
, u8
*cckpowerlevel
, u8
*ofdmpowerlevel
)
1134 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1135 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1137 rtlphy
->cur_cck_txpwridx
= cckpowerlevel
[0];
1138 rtlphy
->cur_ofdm24g_txpwridx
= ofdmpowerlevel
[0];
1141 void rtl92s_phy_set_txpower(struct ieee80211_hw
*hw
, u8 channel
)
1143 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1144 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
1145 /* [0]:RF-A, [1]:RF-B */
1146 u8 cckpowerlevel
[2], ofdmpowerlevel
[2];
1148 if (!rtlefuse
->txpwr_fromeprom
)
1151 /* Mainly we use RF-A Tx Power to write the Tx Power registers,
1152 * but the RF-B Tx Power must be calculated by the antenna diff.
1153 * So we have to rewrite Antenna gain offset register here.
1154 * Please refer to BB register 0x80c
1156 * 2. For OFDM 1T or 2T */
1157 _rtl92s_phy_get_txpower_index(hw
, channel
, &cckpowerlevel
[0],
1158 &ofdmpowerlevel
[0]);
1160 rtl_dbg(rtlpriv
, COMP_POWER
, DBG_LOUD
,
1161 "Channel-%d, cckPowerLevel (A / B) = 0x%x / 0x%x, ofdmPowerLevel (A / B) = 0x%x / 0x%x\n",
1162 channel
, cckpowerlevel
[0], cckpowerlevel
[1],
1163 ofdmpowerlevel
[0], ofdmpowerlevel
[1]);
1165 _rtl92s_phy_ccxpower_indexcheck(hw
, channel
, &cckpowerlevel
[0],
1166 &ofdmpowerlevel
[0]);
1168 rtl92s_phy_rf6052_set_ccktxpower(hw
, cckpowerlevel
[0]);
1169 rtl92s_phy_rf6052_set_ofdmtxpower(hw
, &ofdmpowerlevel
[0], channel
);
1173 void rtl92s_phy_chk_fwcmd_iodone(struct ieee80211_hw
*hw
)
1175 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1176 u16 pollingcnt
= 10000;
1179 /* Make sure that CMD IO has be accepted by FW. */
1183 tmpvalue
= rtl_read_dword(rtlpriv
, WFM5
);
1186 } while (--pollingcnt
);
1188 if (pollingcnt
== 0)
1189 pr_err("Set FW Cmd fail!!\n");
1193 static void _rtl92s_phy_set_fwcmd_io(struct ieee80211_hw
*hw
)
1195 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1196 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1197 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1198 u32 input
, current_aid
= 0;
1200 if (is_hal_stop(rtlhal
))
1203 if (hal_get_firmwareversion(rtlpriv
) < 0x34)
1205 /* We re-map RA related CMD IO to combinational ones */
1206 /* if FW version is v.52 or later. */
1207 switch (rtlhal
->current_fwcmd_io
) {
1208 case FW_CMD_RA_REFRESH_N
:
1209 rtlhal
->current_fwcmd_io
= FW_CMD_RA_REFRESH_N_COMB
;
1211 case FW_CMD_RA_REFRESH_BG
:
1212 rtlhal
->current_fwcmd_io
= FW_CMD_RA_REFRESH_BG_COMB
;
1219 switch (rtlhal
->current_fwcmd_io
) {
1220 case FW_CMD_RA_RESET
:
1221 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_DMESG
, "FW_CMD_RA_RESET\n");
1222 rtl_write_dword(rtlpriv
, WFM5
, FW_RA_RESET
);
1223 rtl92s_phy_chk_fwcmd_iodone(hw
);
1225 case FW_CMD_RA_ACTIVE
:
1226 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_DMESG
, "FW_CMD_RA_ACTIVE\n");
1227 rtl_write_dword(rtlpriv
, WFM5
, FW_RA_ACTIVE
);
1228 rtl92s_phy_chk_fwcmd_iodone(hw
);
1230 case FW_CMD_RA_REFRESH_N
:
1231 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_DMESG
, "FW_CMD_RA_REFRESH_N\n");
1232 input
= FW_RA_REFRESH
;
1233 rtl_write_dword(rtlpriv
, WFM5
, input
);
1234 rtl92s_phy_chk_fwcmd_iodone(hw
);
1235 rtl_write_dword(rtlpriv
, WFM5
, FW_RA_ENABLE_RSSI_MASK
);
1236 rtl92s_phy_chk_fwcmd_iodone(hw
);
1238 case FW_CMD_RA_REFRESH_BG
:
1239 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_DMESG
,
1240 "FW_CMD_RA_REFRESH_BG\n");
1241 rtl_write_dword(rtlpriv
, WFM5
, FW_RA_REFRESH
);
1242 rtl92s_phy_chk_fwcmd_iodone(hw
);
1243 rtl_write_dword(rtlpriv
, WFM5
, FW_RA_DISABLE_RSSI_MASK
);
1244 rtl92s_phy_chk_fwcmd_iodone(hw
);
1246 case FW_CMD_RA_REFRESH_N_COMB
:
1247 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_DMESG
,
1248 "FW_CMD_RA_REFRESH_N_COMB\n");
1249 input
= FW_RA_IOT_N_COMB
;
1250 rtl_write_dword(rtlpriv
, WFM5
, input
);
1251 rtl92s_phy_chk_fwcmd_iodone(hw
);
1253 case FW_CMD_RA_REFRESH_BG_COMB
:
1254 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_DMESG
,
1255 "FW_CMD_RA_REFRESH_BG_COMB\n");
1256 input
= FW_RA_IOT_BG_COMB
;
1257 rtl_write_dword(rtlpriv
, WFM5
, input
);
1258 rtl92s_phy_chk_fwcmd_iodone(hw
);
1260 case FW_CMD_IQK_ENABLE
:
1261 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_DMESG
, "FW_CMD_IQK_ENABLE\n");
1262 rtl_write_dword(rtlpriv
, WFM5
, FW_IQK_ENABLE
);
1263 rtl92s_phy_chk_fwcmd_iodone(hw
);
1265 case FW_CMD_PAUSE_DM_BY_SCAN
:
1266 /* Lower initial gain */
1267 rtl_set_bbreg(hw
, ROFDM0_XAAGCCORE1
, MASKBYTE0
, 0x17);
1268 rtl_set_bbreg(hw
, ROFDM0_XBAGCCORE1
, MASKBYTE0
, 0x17);
1270 rtl_set_bbreg(hw
, RCCK0_CCA
, MASKBYTE2
, 0x40);
1272 case FW_CMD_RESUME_DM_BY_SCAN
:
1274 rtl_set_bbreg(hw
, RCCK0_CCA
, MASKBYTE2
, 0xcd);
1275 rtl92s_phy_set_txpower(hw
, rtlphy
->current_channel
);
1277 case FW_CMD_HIGH_PWR_DISABLE
:
1278 if (rtlpriv
->dm
.dm_flag
& HAL_DM_HIPWR_DISABLE
)
1281 /* Lower initial gain */
1282 rtl_set_bbreg(hw
, ROFDM0_XAAGCCORE1
, MASKBYTE0
, 0x17);
1283 rtl_set_bbreg(hw
, ROFDM0_XBAGCCORE1
, MASKBYTE0
, 0x17);
1285 rtl_set_bbreg(hw
, RCCK0_CCA
, MASKBYTE2
, 0x40);
1287 case FW_CMD_HIGH_PWR_ENABLE
:
1288 if ((rtlpriv
->dm
.dm_flag
& HAL_DM_HIPWR_DISABLE
) ||
1289 rtlpriv
->dm
.dynamic_txpower_enable
)
1293 rtl_set_bbreg(hw
, RCCK0_CCA
, MASKBYTE2
, 0xcd);
1295 case FW_CMD_LPS_ENTER
:
1296 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_DMESG
, "FW_CMD_LPS_ENTER\n");
1297 current_aid
= rtlpriv
->mac80211
.assoc_id
;
1298 rtl_write_dword(rtlpriv
, WFM5
, (FW_LPS_ENTER
|
1299 ((current_aid
| 0xc000) << 8)));
1300 rtl92s_phy_chk_fwcmd_iodone(hw
);
1301 /* FW set TXOP disable here, so disable EDCA
1302 * turbo mode until driver leave LPS */
1304 case FW_CMD_LPS_LEAVE
:
1305 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_DMESG
, "FW_CMD_LPS_LEAVE\n");
1306 rtl_write_dword(rtlpriv
, WFM5
, FW_LPS_LEAVE
);
1307 rtl92s_phy_chk_fwcmd_iodone(hw
);
1309 case FW_CMD_ADD_A2_ENTRY
:
1310 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_DMESG
, "FW_CMD_ADD_A2_ENTRY\n");
1311 rtl_write_dword(rtlpriv
, WFM5
, FW_ADD_A2_ENTRY
);
1312 rtl92s_phy_chk_fwcmd_iodone(hw
);
1314 case FW_CMD_CTRL_DM_BY_DRIVER
:
1315 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_LOUD
,
1316 "FW_CMD_CTRL_DM_BY_DRIVER\n");
1317 rtl_write_dword(rtlpriv
, WFM5
, FW_CTRL_DM_BY_DRIVER
);
1318 rtl92s_phy_chk_fwcmd_iodone(hw
);
1325 rtl92s_phy_chk_fwcmd_iodone(hw
);
1327 /* Clear FW CMD operation flag. */
1328 rtlhal
->set_fwcmd_inprogress
= false;
1331 bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw
*hw
, enum fwcmd_iotype fw_cmdio
)
1333 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1334 struct dig_t
*digtable
= &rtlpriv
->dm_digtable
;
1335 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1336 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
1337 u32 fw_param
= FW_CMD_IO_PARA_QUERY(rtlpriv
);
1338 u16 fw_cmdmap
= FW_CMD_IO_QUERY(rtlpriv
);
1339 bool postprocessing
= false;
1341 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_LOUD
,
1342 "Set FW Cmd(%#x), set_fwcmd_inprogress(%d)\n",
1343 fw_cmdio
, rtlhal
->set_fwcmd_inprogress
);
1346 /* We re-map to combined FW CMD ones if firmware version */
1347 /* is v.53 or later. */
1348 if (hal_get_firmwareversion(rtlpriv
) >= 0x35) {
1350 case FW_CMD_RA_REFRESH_N
:
1351 fw_cmdio
= FW_CMD_RA_REFRESH_N_COMB
;
1353 case FW_CMD_RA_REFRESH_BG
:
1354 fw_cmdio
= FW_CMD_RA_REFRESH_BG_COMB
;
1360 if ((fw_cmdio
== FW_CMD_IQK_ENABLE
) ||
1361 (fw_cmdio
== FW_CMD_RA_REFRESH_N
) ||
1362 (fw_cmdio
== FW_CMD_RA_REFRESH_BG
)) {
1363 postprocessing
= true;
1368 /* If firmware version is v.62 or later,
1369 * use FW_CMD_IO_SET for FW_CMD_CTRL_DM_BY_DRIVER */
1370 if (hal_get_firmwareversion(rtlpriv
) >= 0x3E) {
1371 if (fw_cmdio
== FW_CMD_CTRL_DM_BY_DRIVER
)
1372 fw_cmdio
= FW_CMD_CTRL_DM_BY_DRIVER_NEW
;
1376 /* We shall revise all FW Cmd IO into Reg0x364
1377 * DM map table in the future. */
1379 case FW_CMD_RA_INIT
:
1380 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_LOUD
, "RA init!!\n");
1381 fw_cmdmap
|= FW_RA_INIT_CTL
;
1382 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1383 /* Clear control flag to sync with FW. */
1384 FW_CMD_IO_CLR(rtlpriv
, FW_RA_INIT_CTL
);
1386 case FW_CMD_DIG_DISABLE
:
1387 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_LOUD
,
1388 "Set DIG disable!!\n");
1389 fw_cmdmap
&= ~FW_DIG_ENABLE_CTL
;
1390 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1392 case FW_CMD_DIG_ENABLE
:
1393 case FW_CMD_DIG_RESUME
:
1394 if (!(rtlpriv
->dm
.dm_flag
& HAL_DM_DIG_DISABLE
)) {
1395 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_LOUD
,
1396 "Set DIG enable or resume!!\n");
1397 fw_cmdmap
|= (FW_DIG_ENABLE_CTL
| FW_SS_CTL
);
1398 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1401 case FW_CMD_DIG_HALT
:
1402 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_LOUD
,
1403 "Set DIG halt!!\n");
1404 fw_cmdmap
&= ~(FW_DIG_ENABLE_CTL
| FW_SS_CTL
);
1405 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1407 case FW_CMD_TXPWR_TRACK_THERMAL
: {
1409 fw_cmdmap
|= FW_PWR_TRK_CTL
;
1411 /* Clear FW parameter in terms of thermal parts. */
1412 fw_param
&= FW_PWR_TRK_PARAM_CLR
;
1414 thermalval
= rtlpriv
->dm
.thermalvalue
;
1415 fw_param
|= ((thermalval
<< 24) |
1416 (rtlefuse
->thermalmeter
[0] << 16));
1418 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_LOUD
,
1419 "Set TxPwr tracking!! FwCmdMap(%#x), FwParam(%#x)\n",
1420 fw_cmdmap
, fw_param
);
1422 FW_CMD_PARA_SET(rtlpriv
, fw_param
);
1423 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1425 /* Clear control flag to sync with FW. */
1426 FW_CMD_IO_CLR(rtlpriv
, FW_PWR_TRK_CTL
);
1429 /* The following FW CMDs are only compatible to
1431 case FW_CMD_RA_REFRESH_N_COMB
:
1432 fw_cmdmap
|= FW_RA_N_CTL
;
1434 /* Clear RA BG mode control. */
1435 fw_cmdmap
&= ~(FW_RA_BG_CTL
| FW_RA_INIT_CTL
);
1437 /* Clear FW parameter in terms of RA parts. */
1438 fw_param
&= FW_RA_PARAM_CLR
;
1440 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_LOUD
,
1441 "[FW CMD] [New Version] Set RA/IOT Comb in n mode!! FwCmdMap(%#x), FwParam(%#x)\n",
1442 fw_cmdmap
, fw_param
);
1444 FW_CMD_PARA_SET(rtlpriv
, fw_param
);
1445 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1447 /* Clear control flag to sync with FW. */
1448 FW_CMD_IO_CLR(rtlpriv
, FW_RA_N_CTL
);
1450 case FW_CMD_RA_REFRESH_BG_COMB
:
1451 fw_cmdmap
|= FW_RA_BG_CTL
;
1453 /* Clear RA n-mode control. */
1454 fw_cmdmap
&= ~(FW_RA_N_CTL
| FW_RA_INIT_CTL
);
1455 /* Clear FW parameter in terms of RA parts. */
1456 fw_param
&= FW_RA_PARAM_CLR
;
1458 FW_CMD_PARA_SET(rtlpriv
, fw_param
);
1459 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1461 /* Clear control flag to sync with FW. */
1462 FW_CMD_IO_CLR(rtlpriv
, FW_RA_BG_CTL
);
1464 case FW_CMD_IQK_ENABLE
:
1465 fw_cmdmap
|= FW_IQK_CTL
;
1466 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1467 /* Clear control flag to sync with FW. */
1468 FW_CMD_IO_CLR(rtlpriv
, FW_IQK_CTL
);
1470 /* The following FW CMD is compatible to v.62 or later. */
1471 case FW_CMD_CTRL_DM_BY_DRIVER_NEW
:
1472 fw_cmdmap
|= FW_DRIVER_CTRL_DM_CTL
;
1473 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1475 /* The followed FW Cmds needs post-processing later. */
1476 case FW_CMD_RESUME_DM_BY_SCAN
:
1477 fw_cmdmap
|= (FW_DIG_ENABLE_CTL
|
1478 FW_HIGH_PWR_ENABLE_CTL
|
1481 if (rtlpriv
->dm
.dm_flag
& HAL_DM_DIG_DISABLE
||
1482 !digtable
->dig_enable_flag
)
1483 fw_cmdmap
&= ~FW_DIG_ENABLE_CTL
;
1485 if ((rtlpriv
->dm
.dm_flag
& HAL_DM_HIPWR_DISABLE
) ||
1486 rtlpriv
->dm
.dynamic_txpower_enable
)
1487 fw_cmdmap
&= ~FW_HIGH_PWR_ENABLE_CTL
;
1489 if ((digtable
->dig_ext_port_stage
==
1490 DIG_EXT_PORT_STAGE_0
) ||
1491 (digtable
->dig_ext_port_stage
==
1492 DIG_EXT_PORT_STAGE_1
))
1493 fw_cmdmap
&= ~FW_DIG_ENABLE_CTL
;
1495 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1496 postprocessing
= true;
1498 case FW_CMD_PAUSE_DM_BY_SCAN
:
1499 fw_cmdmap
&= ~(FW_DIG_ENABLE_CTL
|
1500 FW_HIGH_PWR_ENABLE_CTL
|
1502 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1503 postprocessing
= true;
1505 case FW_CMD_HIGH_PWR_DISABLE
:
1506 fw_cmdmap
&= ~FW_HIGH_PWR_ENABLE_CTL
;
1507 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1508 postprocessing
= true;
1510 case FW_CMD_HIGH_PWR_ENABLE
:
1511 if (!(rtlpriv
->dm
.dm_flag
& HAL_DM_HIPWR_DISABLE
) &&
1512 !rtlpriv
->dm
.dynamic_txpower_enable
) {
1513 fw_cmdmap
|= (FW_HIGH_PWR_ENABLE_CTL
|
1515 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1516 postprocessing
= true;
1519 case FW_CMD_DIG_MODE_FA
:
1520 fw_cmdmap
|= FW_FA_CTL
;
1521 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1523 case FW_CMD_DIG_MODE_SS
:
1524 fw_cmdmap
&= ~FW_FA_CTL
;
1525 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1527 case FW_CMD_PAPE_CONTROL
:
1528 rtl_dbg(rtlpriv
, COMP_CMD
, DBG_LOUD
,
1529 "[FW CMD] Set PAPE Control\n");
1530 fw_cmdmap
&= ~FW_PAPE_CTL_BY_SW_HW
;
1532 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1535 /* Pass to original FW CMD processing callback
1537 postprocessing
= true;
1542 /* We shall post processing these FW CMD if
1543 * variable postprocessing is set.
1545 if (postprocessing
&& !rtlhal
->set_fwcmd_inprogress
) {
1546 rtlhal
->set_fwcmd_inprogress
= true;
1547 /* Update current FW Cmd for callback use. */
1548 rtlhal
->current_fwcmd_io
= fw_cmdio
;
1553 _rtl92s_phy_set_fwcmd_io(hw
);
1557 static void _rtl92s_phy_check_ephy_switchready(struct ieee80211_hw
*hw
)
1559 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1563 regu1
= rtl_read_byte(rtlpriv
, 0x554);
1564 while ((regu1
& BIT(5)) && (delay
> 0)) {
1565 regu1
= rtl_read_byte(rtlpriv
, 0x554);
1567 /* We delay only 50us to prevent
1568 * being scheduled out. */
1573 void rtl92s_phy_switch_ephy_parameter(struct ieee80211_hw
*hw
)
1575 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1576 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
1578 /* The way to be capable to switch clock request
1579 * when the PG setting does not support clock request.
1580 * This is the backdoor solution to switch clock
1581 * request before ASPM or D3. */
1582 rtl_write_dword(rtlpriv
, 0x540, 0x73c11);
1583 rtl_write_dword(rtlpriv
, 0x548, 0x2407c);
1585 /* Switch EPHY parameter!!!! */
1586 rtl_write_word(rtlpriv
, 0x550, 0x1000);
1587 rtl_write_byte(rtlpriv
, 0x554, 0x20);
1588 _rtl92s_phy_check_ephy_switchready(hw
);
1590 rtl_write_word(rtlpriv
, 0x550, 0xa0eb);
1591 rtl_write_byte(rtlpriv
, 0x554, 0x3e);
1592 _rtl92s_phy_check_ephy_switchready(hw
);
1594 rtl_write_word(rtlpriv
, 0x550, 0xff80);
1595 rtl_write_byte(rtlpriv
, 0x554, 0x39);
1596 _rtl92s_phy_check_ephy_switchready(hw
);
1598 /* Delay L1 enter time */
1599 if (ppsc
->support_aspm
&& !ppsc
->support_backdoor
)
1600 rtl_write_byte(rtlpriv
, 0x560, 0x40);
1602 rtl_write_byte(rtlpriv
, 0x560, 0x00);
1606 void rtl92s_phy_set_beacon_hwreg(struct ieee80211_hw
*hw
, u16 beaconinterval
)
1608 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1609 u32 new_bcn_num
= 0;
1611 if (hal_get_firmwareversion(rtlpriv
) >= 0x33) {
1612 /* Fw v.51 and later. */
1613 rtl_write_dword(rtlpriv
, WFM5
, 0xF1000000 |
1614 (beaconinterval
<< 8));
1616 new_bcn_num
= beaconinterval
* 32 - 64;
1617 rtl_write_dword(rtlpriv
, WFM3
+ 4, new_bcn_num
);
1618 rtl_write_dword(rtlpriv
, WFM3
, 0xB026007C);