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 *****************************************************************************/
43 static u32
_rtl92s_phy_calculate_bit_shift(u32 bitmask
)
47 for (i
= 0; i
<= 31; i
++) {
48 if (((bitmask
>> i
) & 0x1) == 1)
55 u32
rtl92s_phy_query_bb_reg(struct ieee80211_hw
*hw
, u32 regaddr
, u32 bitmask
)
57 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
58 u32 returnvalue
= 0, originalvalue
, bitshift
;
60 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
, "regaddr(%#x), bitmask(%#x)\n",
63 originalvalue
= rtl_read_dword(rtlpriv
, regaddr
);
64 bitshift
= _rtl92s_phy_calculate_bit_shift(bitmask
);
65 returnvalue
= (originalvalue
& bitmask
) >> bitshift
;
67 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
, "BBR MASK=0x%x Addr[0x%x]=0x%x\n",
68 bitmask
, regaddr
, originalvalue
);
74 void rtl92s_phy_set_bb_reg(struct ieee80211_hw
*hw
, u32 regaddr
, u32 bitmask
,
77 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
78 u32 originalvalue
, bitshift
;
80 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
,
81 "regaddr(%#x), bitmask(%#x), data(%#x)\n",
82 regaddr
, bitmask
, data
);
84 if (bitmask
!= MASKDWORD
) {
85 originalvalue
= rtl_read_dword(rtlpriv
, regaddr
);
86 bitshift
= _rtl92s_phy_calculate_bit_shift(bitmask
);
87 data
= ((originalvalue
& (~bitmask
)) | (data
<< bitshift
));
90 rtl_write_dword(rtlpriv
, regaddr
, data
);
92 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
,
93 "regaddr(%#x), bitmask(%#x), data(%#x)\n",
94 regaddr
, bitmask
, data
);
98 static u32
_rtl92s_phy_rf_serial_read(struct ieee80211_hw
*hw
,
99 enum radio_path rfpath
, u32 offset
)
102 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
103 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
104 struct bb_reg_def
*pphyreg
= &rtlphy
->phyreg_def
[rfpath
];
106 u32 tmplong
, tmplong2
;
113 tmplong
= rtl_get_bbreg(hw
, RFPGA0_XA_HSSIPARAMETER2
, MASKDWORD
);
115 if (rfpath
== RF90_PATH_A
)
118 tmplong2
= rtl_get_bbreg(hw
, pphyreg
->rfhssi_para2
, MASKDWORD
);
120 tmplong2
= (tmplong2
& (~BLSSI_READADDRESS
)) | (newoffset
<< 23) |
123 rtl_set_bbreg(hw
, RFPGA0_XA_HSSIPARAMETER2
, MASKDWORD
,
124 tmplong
& (~BLSSI_READEDGE
));
128 rtl_set_bbreg(hw
, pphyreg
->rfhssi_para2
, MASKDWORD
, tmplong2
);
131 rtl_set_bbreg(hw
, RFPGA0_XA_HSSIPARAMETER2
, MASKDWORD
, tmplong
|
135 if (rfpath
== RF90_PATH_A
)
136 rfpi_enable
= (u8
)rtl_get_bbreg(hw
, RFPGA0_XA_HSSIPARAMETER1
,
138 else if (rfpath
== RF90_PATH_B
)
139 rfpi_enable
= (u8
)rtl_get_bbreg(hw
, RFPGA0_XB_HSSIPARAMETER1
,
143 retvalue
= rtl_get_bbreg(hw
, pphyreg
->rf_rbpi
,
144 BLSSI_READBACK_DATA
);
146 retvalue
= rtl_get_bbreg(hw
, pphyreg
->rf_rb
,
147 BLSSI_READBACK_DATA
);
149 retvalue
= rtl_get_bbreg(hw
, pphyreg
->rf_rb
,
150 BLSSI_READBACK_DATA
);
152 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
, "RFR-%d Addr[0x%x]=0x%x\n",
153 rfpath
, pphyreg
->rf_rb
, retvalue
);
159 static void _rtl92s_phy_rf_serial_write(struct ieee80211_hw
*hw
,
160 enum radio_path rfpath
, u32 offset
,
163 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
164 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
165 struct bb_reg_def
*pphyreg
= &rtlphy
->phyreg_def
[rfpath
];
166 u32 data_and_addr
= 0;
172 data_and_addr
= ((newoffset
<< 20) | (data
& 0x000fffff)) & 0x0fffffff;
173 rtl_set_bbreg(hw
, pphyreg
->rf3wire_offset
, MASKDWORD
, data_and_addr
);
175 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
, "RFW-%d Addr[0x%x]=0x%x\n",
176 rfpath
, pphyreg
->rf3wire_offset
, data_and_addr
);
180 u32
rtl92s_phy_query_rf_reg(struct ieee80211_hw
*hw
, enum radio_path rfpath
,
181 u32 regaddr
, u32 bitmask
)
183 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
184 u32 original_value
, readback_value
, bitshift
;
186 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
,
187 "regaddr(%#x), rfpath(%#x), bitmask(%#x)\n",
188 regaddr
, rfpath
, bitmask
);
190 spin_lock(&rtlpriv
->locks
.rf_lock
);
192 original_value
= _rtl92s_phy_rf_serial_read(hw
, rfpath
, regaddr
);
194 bitshift
= _rtl92s_phy_calculate_bit_shift(bitmask
);
195 readback_value
= (original_value
& bitmask
) >> bitshift
;
197 spin_unlock(&rtlpriv
->locks
.rf_lock
);
199 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
,
200 "regaddr(%#x), rfpath(%#x), bitmask(%#x), original_value(%#x)\n",
201 regaddr
, rfpath
, bitmask
, original_value
);
203 return readback_value
;
206 void rtl92s_phy_set_rf_reg(struct ieee80211_hw
*hw
, enum radio_path rfpath
,
207 u32 regaddr
, u32 bitmask
, u32 data
)
209 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
210 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
211 u32 original_value
, bitshift
;
213 if (!((rtlphy
->rf_pathmap
>> rfpath
) & 0x1))
216 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
,
217 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
218 regaddr
, bitmask
, data
, rfpath
);
220 spin_lock(&rtlpriv
->locks
.rf_lock
);
222 if (bitmask
!= RFREG_OFFSET_MASK
) {
223 original_value
= _rtl92s_phy_rf_serial_read(hw
, rfpath
,
225 bitshift
= _rtl92s_phy_calculate_bit_shift(bitmask
);
226 data
= ((original_value
& (~bitmask
)) | (data
<< bitshift
));
229 _rtl92s_phy_rf_serial_write(hw
, rfpath
, regaddr
, data
);
231 spin_unlock(&rtlpriv
->locks
.rf_lock
);
233 RT_TRACE(rtlpriv
, COMP_RF
, DBG_TRACE
,
234 "regaddr(%#x), bitmask(%#x), data(%#x), rfpath(%#x)\n",
235 regaddr
, bitmask
, data
, rfpath
);
239 void rtl92s_phy_scan_operation_backup(struct ieee80211_hw
*hw
,
242 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
243 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
245 if (!is_hal_stop(rtlhal
)) {
247 case SCAN_OPT_BACKUP
:
248 rtl92s_phy_set_fw_cmd(hw
, FW_CMD_PAUSE_DM_BY_SCAN
);
250 case SCAN_OPT_RESTORE
:
251 rtl92s_phy_set_fw_cmd(hw
, FW_CMD_RESUME_DM_BY_SCAN
);
254 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
255 "Unknown operation\n");
261 void rtl92s_phy_set_bw_mode(struct ieee80211_hw
*hw
,
262 enum nl80211_channel_type ch_type
)
264 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
265 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
266 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
267 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
270 RT_TRACE(rtlpriv
, COMP_SCAN
, DBG_TRACE
, "Switch to %s bandwidth\n",
271 rtlphy
->current_chan_bw
== HT_CHANNEL_WIDTH_20
?
274 if (rtlphy
->set_bwmode_inprogress
)
276 if (is_hal_stop(rtlhal
))
279 rtlphy
->set_bwmode_inprogress
= true;
281 reg_bw_opmode
= rtl_read_byte(rtlpriv
, BW_OPMODE
);
283 rtl_read_byte(rtlpriv
, RRSR
+ 2);
285 switch (rtlphy
->current_chan_bw
) {
286 case HT_CHANNEL_WIDTH_20
:
287 reg_bw_opmode
|= BW_OPMODE_20MHZ
;
288 rtl_write_byte(rtlpriv
, BW_OPMODE
, reg_bw_opmode
);
290 case HT_CHANNEL_WIDTH_20_40
:
291 reg_bw_opmode
&= ~BW_OPMODE_20MHZ
;
292 rtl_write_byte(rtlpriv
, BW_OPMODE
, reg_bw_opmode
);
295 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
296 "unknown bandwidth: %#X\n", rtlphy
->current_chan_bw
);
300 switch (rtlphy
->current_chan_bw
) {
301 case HT_CHANNEL_WIDTH_20
:
302 rtl_set_bbreg(hw
, RFPGA0_RFMOD
, BRFMOD
, 0x0);
303 rtl_set_bbreg(hw
, RFPGA1_RFMOD
, BRFMOD
, 0x0);
305 if (rtlhal
->version
>= VERSION_8192S_BCUT
)
306 rtl_write_byte(rtlpriv
, RFPGA0_ANALOGPARAMETER2
, 0x58);
308 case HT_CHANNEL_WIDTH_20_40
:
309 rtl_set_bbreg(hw
, RFPGA0_RFMOD
, BRFMOD
, 0x1);
310 rtl_set_bbreg(hw
, RFPGA1_RFMOD
, BRFMOD
, 0x1);
312 rtl_set_bbreg(hw
, RCCK0_SYSTEM
, BCCK_SIDEBAND
,
313 (mac
->cur_40_prime_sc
>> 1));
314 rtl_set_bbreg(hw
, ROFDM1_LSTF
, 0xC00, mac
->cur_40_prime_sc
);
316 if (rtlhal
->version
>= VERSION_8192S_BCUT
)
317 rtl_write_byte(rtlpriv
, RFPGA0_ANALOGPARAMETER2
, 0x18);
320 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
321 "unknown bandwidth: %#X\n", rtlphy
->current_chan_bw
);
325 rtl92s_phy_rf6052_set_bandwidth(hw
, rtlphy
->current_chan_bw
);
326 rtlphy
->set_bwmode_inprogress
= false;
327 RT_TRACE(rtlpriv
, COMP_SCAN
, DBG_TRACE
, "<==\n");
330 static bool _rtl92s_phy_set_sw_chnl_cmdarray(struct swchnlcmd
*cmdtable
,
331 u32 cmdtableidx
, u32 cmdtablesz
, enum swchnlcmd_id cmdid
,
332 u32 para1
, u32 para2
, u32 msdelay
)
334 struct swchnlcmd
*pcmd
;
336 if (cmdtable
== NULL
) {
337 RT_ASSERT(false, "cmdtable cannot be NULL\n");
341 if (cmdtableidx
>= cmdtablesz
)
344 pcmd
= cmdtable
+ cmdtableidx
;
348 pcmd
->msdelay
= msdelay
;
353 static bool _rtl92s_phy_sw_chnl_step_by_step(struct ieee80211_hw
*hw
,
354 u8 channel
, u8
*stage
, u8
*step
, u32
*delay
)
356 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
357 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
358 struct swchnlcmd precommoncmd
[MAX_PRECMD_CNT
];
360 struct swchnlcmd postcommoncmd
[MAX_POSTCMD_CNT
];
361 u32 postcommoncmdcnt
;
362 struct swchnlcmd rfdependcmd
[MAX_RFDEPENDCMD_CNT
];
364 struct swchnlcmd
*currentcmd
= NULL
;
366 u8 num_total_rfpath
= rtlphy
->num_total_rfpath
;
369 _rtl92s_phy_set_sw_chnl_cmdarray(precommoncmd
, precommoncmdcnt
++,
370 MAX_PRECMD_CNT
, CMDID_SET_TXPOWEROWER_LEVEL
, 0, 0, 0);
371 _rtl92s_phy_set_sw_chnl_cmdarray(precommoncmd
, precommoncmdcnt
++,
372 MAX_PRECMD_CNT
, CMDID_END
, 0, 0, 0);
374 postcommoncmdcnt
= 0;
376 _rtl92s_phy_set_sw_chnl_cmdarray(postcommoncmd
, postcommoncmdcnt
++,
377 MAX_POSTCMD_CNT
, CMDID_END
, 0, 0, 0);
381 RT_ASSERT((channel
>= 1 && channel
<= 14),
382 "invalid channel for Zebra: %d\n", channel
);
384 _rtl92s_phy_set_sw_chnl_cmdarray(rfdependcmd
, rfdependcmdcnt
++,
385 MAX_RFDEPENDCMD_CNT
, CMDID_RF_WRITEREG
,
386 RF_CHNLBW
, channel
, 10);
388 _rtl92s_phy_set_sw_chnl_cmdarray(rfdependcmd
, rfdependcmdcnt
++,
389 MAX_RFDEPENDCMD_CNT
, CMDID_END
, 0, 0, 0);
394 currentcmd
= &precommoncmd
[*step
];
397 currentcmd
= &rfdependcmd
[*step
];
400 currentcmd
= &postcommoncmd
[*step
];
406 if (currentcmd
->cmdid
== CMDID_END
) {
416 switch (currentcmd
->cmdid
) {
417 case CMDID_SET_TXPOWEROWER_LEVEL
:
418 rtl92s_phy_set_txpower(hw
, channel
);
420 case CMDID_WRITEPORT_ULONG
:
421 rtl_write_dword(rtlpriv
, currentcmd
->para1
,
424 case CMDID_WRITEPORT_USHORT
:
425 rtl_write_word(rtlpriv
, currentcmd
->para1
,
426 (u16
)currentcmd
->para2
);
428 case CMDID_WRITEPORT_UCHAR
:
429 rtl_write_byte(rtlpriv
, currentcmd
->para1
,
430 (u8
)currentcmd
->para2
);
432 case CMDID_RF_WRITEREG
:
433 for (rfpath
= 0; rfpath
< num_total_rfpath
; rfpath
++) {
434 rtlphy
->rfreg_chnlval
[rfpath
] =
435 ((rtlphy
->rfreg_chnlval
[rfpath
] &
436 0xfffffc00) | currentcmd
->para2
);
437 rtl_set_rfreg(hw
, (enum radio_path
)rfpath
,
440 rtlphy
->rfreg_chnlval
[rfpath
]);
444 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
445 "switch case not processed\n");
452 (*delay
) = currentcmd
->msdelay
;
457 u8
rtl92s_phy_sw_chnl(struct ieee80211_hw
*hw
)
459 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
460 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
461 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
465 RT_TRACE(rtlpriv
, COMP_SCAN
, DBG_TRACE
, "switch to channel%d\n",
466 rtlphy
->current_channel
);
468 if (rtlphy
->sw_chnl_inprogress
)
471 if (rtlphy
->set_bwmode_inprogress
)
474 if (is_hal_stop(rtlhal
))
477 rtlphy
->sw_chnl_inprogress
= true;
478 rtlphy
->sw_chnl_stage
= 0;
479 rtlphy
->sw_chnl_step
= 0;
482 if (!rtlphy
->sw_chnl_inprogress
)
485 ret
= _rtl92s_phy_sw_chnl_step_by_step(hw
,
486 rtlphy
->current_channel
,
487 &rtlphy
->sw_chnl_stage
,
488 &rtlphy
->sw_chnl_step
, &delay
);
495 rtlphy
->sw_chnl_inprogress
= false;
500 rtlphy
->sw_chnl_inprogress
= false;
502 RT_TRACE(rtlpriv
, COMP_SCAN
, DBG_TRACE
, "<==\n");
507 static void _rtl92se_phy_set_rf_sleep(struct ieee80211_hw
*hw
)
509 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
512 u1btmp
= rtl_read_byte(rtlpriv
, LDOV12D_CTRL
);
515 rtl_write_byte(rtlpriv
, LDOV12D_CTRL
, u1btmp
);
516 rtl_write_byte(rtlpriv
, SPS1_CTRL
, 0x0);
517 rtl_write_byte(rtlpriv
, TXPAUSE
, 0xFF);
518 rtl_write_word(rtlpriv
, CMDR
, 0x57FC);
521 rtl_write_word(rtlpriv
, CMDR
, 0x77FC);
522 rtl_write_byte(rtlpriv
, PHY_CCA
, 0x0);
525 rtl_write_word(rtlpriv
, CMDR
, 0x37FC);
528 rtl_write_word(rtlpriv
, CMDR
, 0x77FC);
531 rtl_write_word(rtlpriv
, CMDR
, 0x57FC);
533 /* we should chnge GPIO to input mode
534 * this will drop away current about 25mA*/
535 rtl8192se_gpiobit3_cfg_inputmode(hw
);
538 bool rtl92s_phy_set_rf_power_state(struct ieee80211_hw
*hw
,
539 enum rf_pwrstate rfpwr_state
)
541 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
542 struct rtl_pci_priv
*pcipriv
= rtl_pcipriv(hw
);
543 struct rtl_mac
*mac
= rtl_mac(rtl_priv(hw
));
544 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
547 struct rtl8192_tx_ring
*ring
= NULL
;
549 if (rfpwr_state
== ppsc
->rfpwr_state
)
552 switch (rfpwr_state
) {
554 if ((ppsc
->rfpwr_state
== ERFOFF
) &&
555 RT_IN_PS_LEVEL(ppsc
, RT_RF_OFF_LEVL_HALT_NIC
)) {
558 u32 InitializeCount
= 0;
561 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
562 "IPS Set eRf nic enable\n");
563 rtstatus
= rtl_ps_enable_nic(hw
);
564 } while (!rtstatus
&& (InitializeCount
< 10));
566 RT_CLEAR_PS_LEVEL(ppsc
,
567 RT_RF_OFF_LEVL_HALT_NIC
);
569 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_DMESG
,
570 "awake, sleeped:%d ms state_inap:%x\n",
571 jiffies_to_msecs(jiffies
-
574 rtlpriv
->psc
.state_inap
);
575 ppsc
->last_awake_jiffies
= jiffies
;
576 rtl_write_word(rtlpriv
, CMDR
, 0x37FC);
577 rtl_write_byte(rtlpriv
, TXPAUSE
, 0x00);
578 rtl_write_byte(rtlpriv
, PHY_CCA
, 0x3);
581 if (mac
->link_state
== MAC80211_LINKED
)
582 rtlpriv
->cfg
->ops
->led_control(hw
,
585 rtlpriv
->cfg
->ops
->led_control(hw
,
590 if (ppsc
->reg_rfps_level
& RT_RF_OFF_LEVL_HALT_NIC
) {
591 RT_TRACE(rtlpriv
, COMP_RF
, DBG_DMESG
,
592 "IPS Set eRf nic disable\n");
593 rtl_ps_disable_nic(hw
);
594 RT_SET_PS_LEVEL(ppsc
, RT_RF_OFF_LEVL_HALT_NIC
);
596 if (ppsc
->rfoff_reason
== RF_CHANGE_BY_IPS
)
597 rtlpriv
->cfg
->ops
->led_control(hw
,
600 rtlpriv
->cfg
->ops
->led_control(hw
,
606 if (ppsc
->rfpwr_state
== ERFOFF
)
609 for (queue_id
= 0, i
= 0;
610 queue_id
< RTL_PCI_MAX_TX_QUEUE_COUNT
;) {
611 ring
= &pcipriv
->dev
.tx_ring
[queue_id
];
612 if (skb_queue_len(&ring
->queue
) == 0 ||
613 queue_id
== BEACON_QUEUE
) {
617 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
618 "eRf Off/Sleep: %d times TcbBusyQueue[%d] = %d before doze!\n",
620 skb_queue_len(&ring
->queue
));
626 if (i
>= MAX_DOZE_WAITING_TIMES_9x
) {
627 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_WARNING
,
628 "ERFOFF: %d times TcbBusyQueue[%d] = %d !\n",
629 MAX_DOZE_WAITING_TIMES_9x
,
631 skb_queue_len(&ring
->queue
));
636 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_DMESG
,
637 "Set ERFSLEEP awaked:%d ms\n",
638 jiffies_to_msecs(jiffies
-
639 ppsc
->last_awake_jiffies
));
641 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_DMESG
,
642 "sleep awaked:%d ms state_inap:%x\n",
643 jiffies_to_msecs(jiffies
-
644 ppsc
->last_awake_jiffies
),
645 rtlpriv
->psc
.state_inap
);
646 ppsc
->last_sleep_jiffies
= jiffies
;
647 _rtl92se_phy_set_rf_sleep(hw
);
650 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
,
651 "switch case not processed\n");
657 ppsc
->rfpwr_state
= rfpwr_state
;
662 static bool _rtl92s_phy_config_rfpa_bias_current(struct ieee80211_hw
*hw
,
663 enum radio_path rfpath
)
665 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
666 bool rtstatus
= true;
669 /* If inferiority IC, we have to increase the PA bias current */
670 if (rtlhal
->ic_class
!= IC_INFERIORITY_A
) {
671 tmpval
= rtl92s_phy_query_rf_reg(hw
, rfpath
, RF_IPA
, 0xf);
672 rtl92s_phy_set_rf_reg(hw
, rfpath
, RF_IPA
, 0xf, tmpval
+ 1);
678 static void _rtl92s_store_pwrindex_diffrate_offset(struct ieee80211_hw
*hw
,
679 u32 reg_addr
, u32 bitmask
, u32 data
)
681 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
682 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
685 if (reg_addr
== RTXAGC_RATE18_06
)
687 else if (reg_addr
== RTXAGC_RATE54_24
)
689 else if (reg_addr
== RTXAGC_CCK_MCS32
)
691 else if (reg_addr
== RTXAGC_MCS03_MCS00
)
693 else if (reg_addr
== RTXAGC_MCS07_MCS04
)
695 else if (reg_addr
== RTXAGC_MCS11_MCS08
)
697 else if (reg_addr
== RTXAGC_MCS15_MCS12
)
702 rtlphy
->mcs_offset
[rtlphy
->pwrgroup_cnt
][index
] = data
;
704 rtlphy
->pwrgroup_cnt
++;
707 static void _rtl92s_phy_init_register_definition(struct ieee80211_hw
*hw
)
709 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
710 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
712 /*RF Interface Sowrtware Control */
713 rtlphy
->phyreg_def
[RF90_PATH_A
].rfintfs
= RFPGA0_XAB_RFINTERFACESW
;
714 rtlphy
->phyreg_def
[RF90_PATH_B
].rfintfs
= RFPGA0_XAB_RFINTERFACESW
;
715 rtlphy
->phyreg_def
[RF90_PATH_C
].rfintfs
= RFPGA0_XCD_RFINTERFACESW
;
716 rtlphy
->phyreg_def
[RF90_PATH_D
].rfintfs
= RFPGA0_XCD_RFINTERFACESW
;
718 /* RF Interface Readback Value */
719 rtlphy
->phyreg_def
[RF90_PATH_A
].rfintfi
= RFPGA0_XAB_RFINTERFACERB
;
720 rtlphy
->phyreg_def
[RF90_PATH_B
].rfintfi
= RFPGA0_XAB_RFINTERFACERB
;
721 rtlphy
->phyreg_def
[RF90_PATH_C
].rfintfi
= RFPGA0_XCD_RFINTERFACERB
;
722 rtlphy
->phyreg_def
[RF90_PATH_D
].rfintfi
= RFPGA0_XCD_RFINTERFACERB
;
724 /* RF Interface Output (and Enable) */
725 rtlphy
->phyreg_def
[RF90_PATH_A
].rfintfo
= RFPGA0_XA_RFINTERFACEOE
;
726 rtlphy
->phyreg_def
[RF90_PATH_B
].rfintfo
= RFPGA0_XB_RFINTERFACEOE
;
727 rtlphy
->phyreg_def
[RF90_PATH_C
].rfintfo
= RFPGA0_XC_RFINTERFACEOE
;
728 rtlphy
->phyreg_def
[RF90_PATH_D
].rfintfo
= RFPGA0_XD_RFINTERFACEOE
;
730 /* RF Interface (Output and) Enable */
731 rtlphy
->phyreg_def
[RF90_PATH_A
].rfintfe
= RFPGA0_XA_RFINTERFACEOE
;
732 rtlphy
->phyreg_def
[RF90_PATH_B
].rfintfe
= RFPGA0_XB_RFINTERFACEOE
;
733 rtlphy
->phyreg_def
[RF90_PATH_C
].rfintfe
= RFPGA0_XC_RFINTERFACEOE
;
734 rtlphy
->phyreg_def
[RF90_PATH_D
].rfintfe
= RFPGA0_XD_RFINTERFACEOE
;
736 /* Addr of LSSI. Wirte RF register by driver */
737 rtlphy
->phyreg_def
[RF90_PATH_A
].rf3wire_offset
=
738 RFPGA0_XA_LSSIPARAMETER
;
739 rtlphy
->phyreg_def
[RF90_PATH_B
].rf3wire_offset
=
740 RFPGA0_XB_LSSIPARAMETER
;
741 rtlphy
->phyreg_def
[RF90_PATH_C
].rf3wire_offset
=
742 RFPGA0_XC_LSSIPARAMETER
;
743 rtlphy
->phyreg_def
[RF90_PATH_D
].rf3wire_offset
=
744 RFPGA0_XD_LSSIPARAMETER
;
747 rtlphy
->phyreg_def
[RF90_PATH_A
].rflssi_select
= RFPGA0_XAB_RFPARAMETER
;
748 rtlphy
->phyreg_def
[RF90_PATH_B
].rflssi_select
= RFPGA0_XAB_RFPARAMETER
;
749 rtlphy
->phyreg_def
[RF90_PATH_C
].rflssi_select
= RFPGA0_XCD_RFPARAMETER
;
750 rtlphy
->phyreg_def
[RF90_PATH_D
].rflssi_select
= RFPGA0_XCD_RFPARAMETER
;
752 /* Tx AGC Gain Stage (same for all path. Should we remove this?) */
753 rtlphy
->phyreg_def
[RF90_PATH_A
].rftxgain_stage
= RFPGA0_TXGAINSTAGE
;
754 rtlphy
->phyreg_def
[RF90_PATH_B
].rftxgain_stage
= RFPGA0_TXGAINSTAGE
;
755 rtlphy
->phyreg_def
[RF90_PATH_C
].rftxgain_stage
= RFPGA0_TXGAINSTAGE
;
756 rtlphy
->phyreg_def
[RF90_PATH_D
].rftxgain_stage
= RFPGA0_TXGAINSTAGE
;
758 /* Tranceiver A~D HSSI Parameter-1 */
759 rtlphy
->phyreg_def
[RF90_PATH_A
].rfhssi_para1
= RFPGA0_XA_HSSIPARAMETER1
;
760 rtlphy
->phyreg_def
[RF90_PATH_B
].rfhssi_para1
= RFPGA0_XB_HSSIPARAMETER1
;
761 rtlphy
->phyreg_def
[RF90_PATH_C
].rfhssi_para1
= RFPGA0_XC_HSSIPARAMETER1
;
762 rtlphy
->phyreg_def
[RF90_PATH_D
].rfhssi_para1
= RFPGA0_XD_HSSIPARAMETER1
;
764 /* Tranceiver A~D HSSI Parameter-2 */
765 rtlphy
->phyreg_def
[RF90_PATH_A
].rfhssi_para2
= RFPGA0_XA_HSSIPARAMETER2
;
766 rtlphy
->phyreg_def
[RF90_PATH_B
].rfhssi_para2
= RFPGA0_XB_HSSIPARAMETER2
;
767 rtlphy
->phyreg_def
[RF90_PATH_C
].rfhssi_para2
= RFPGA0_XC_HSSIPARAMETER2
;
768 rtlphy
->phyreg_def
[RF90_PATH_D
].rfhssi_para2
= RFPGA0_XD_HSSIPARAMETER2
;
770 /* RF switch Control */
771 rtlphy
->phyreg_def
[RF90_PATH_A
].rfsw_ctrl
= RFPGA0_XAB_SWITCHCONTROL
;
772 rtlphy
->phyreg_def
[RF90_PATH_B
].rfsw_ctrl
= RFPGA0_XAB_SWITCHCONTROL
;
773 rtlphy
->phyreg_def
[RF90_PATH_C
].rfsw_ctrl
= RFPGA0_XCD_SWITCHCONTROL
;
774 rtlphy
->phyreg_def
[RF90_PATH_D
].rfsw_ctrl
= RFPGA0_XCD_SWITCHCONTROL
;
777 rtlphy
->phyreg_def
[RF90_PATH_A
].rfagc_control1
= ROFDM0_XAAGCCORE1
;
778 rtlphy
->phyreg_def
[RF90_PATH_B
].rfagc_control1
= ROFDM0_XBAGCCORE1
;
779 rtlphy
->phyreg_def
[RF90_PATH_C
].rfagc_control1
= ROFDM0_XCAGCCORE1
;
780 rtlphy
->phyreg_def
[RF90_PATH_D
].rfagc_control1
= ROFDM0_XDAGCCORE1
;
783 rtlphy
->phyreg_def
[RF90_PATH_A
].rfagc_control2
= ROFDM0_XAAGCCORE2
;
784 rtlphy
->phyreg_def
[RF90_PATH_B
].rfagc_control2
= ROFDM0_XBAGCCORE2
;
785 rtlphy
->phyreg_def
[RF90_PATH_C
].rfagc_control2
= ROFDM0_XCAGCCORE2
;
786 rtlphy
->phyreg_def
[RF90_PATH_D
].rfagc_control2
= ROFDM0_XDAGCCORE2
;
788 /* RX AFE control 1 */
789 rtlphy
->phyreg_def
[RF90_PATH_A
].rfrxiq_imbal
= ROFDM0_XARXIQIMBALANCE
;
790 rtlphy
->phyreg_def
[RF90_PATH_B
].rfrxiq_imbal
= ROFDM0_XBRXIQIMBALANCE
;
791 rtlphy
->phyreg_def
[RF90_PATH_C
].rfrxiq_imbal
= ROFDM0_XCRXIQIMBALANCE
;
792 rtlphy
->phyreg_def
[RF90_PATH_D
].rfrxiq_imbal
= ROFDM0_XDRXIQIMBALANCE
;
794 /* RX AFE control 1 */
795 rtlphy
->phyreg_def
[RF90_PATH_A
].rfrx_afe
= ROFDM0_XARXAFE
;
796 rtlphy
->phyreg_def
[RF90_PATH_B
].rfrx_afe
= ROFDM0_XBRXAFE
;
797 rtlphy
->phyreg_def
[RF90_PATH_C
].rfrx_afe
= ROFDM0_XCRXAFE
;
798 rtlphy
->phyreg_def
[RF90_PATH_D
].rfrx_afe
= ROFDM0_XDRXAFE
;
800 /* Tx AFE control 1 */
801 rtlphy
->phyreg_def
[RF90_PATH_A
].rftxiq_imbal
= ROFDM0_XATXIQIMBALANCE
;
802 rtlphy
->phyreg_def
[RF90_PATH_B
].rftxiq_imbal
= ROFDM0_XBTXIQIMBALANCE
;
803 rtlphy
->phyreg_def
[RF90_PATH_C
].rftxiq_imbal
= ROFDM0_XCTXIQIMBALANCE
;
804 rtlphy
->phyreg_def
[RF90_PATH_D
].rftxiq_imbal
= ROFDM0_XDTXIQIMBALANCE
;
806 /* Tx AFE control 2 */
807 rtlphy
->phyreg_def
[RF90_PATH_A
].rftx_afe
= ROFDM0_XATXAFE
;
808 rtlphy
->phyreg_def
[RF90_PATH_B
].rftx_afe
= ROFDM0_XBTXAFE
;
809 rtlphy
->phyreg_def
[RF90_PATH_C
].rftx_afe
= ROFDM0_XCTXAFE
;
810 rtlphy
->phyreg_def
[RF90_PATH_D
].rftx_afe
= ROFDM0_XDTXAFE
;
812 /* Tranceiver LSSI Readback */
813 rtlphy
->phyreg_def
[RF90_PATH_A
].rf_rb
= RFPGA0_XA_LSSIREADBACK
;
814 rtlphy
->phyreg_def
[RF90_PATH_B
].rf_rb
= RFPGA0_XB_LSSIREADBACK
;
815 rtlphy
->phyreg_def
[RF90_PATH_C
].rf_rb
= RFPGA0_XC_LSSIREADBACK
;
816 rtlphy
->phyreg_def
[RF90_PATH_D
].rf_rb
= RFPGA0_XD_LSSIREADBACK
;
818 /* Tranceiver LSSI Readback PI mode */
819 rtlphy
->phyreg_def
[RF90_PATH_A
].rf_rbpi
= TRANSCEIVERA_HSPI_READBACK
;
820 rtlphy
->phyreg_def
[RF90_PATH_B
].rf_rbpi
= TRANSCEIVERB_HSPI_READBACK
;
824 static bool _rtl92s_phy_config_bb(struct ieee80211_hw
*hw
, u8 configtype
)
829 u16 phy_reg_len
, agc_len
;
831 agc_len
= AGCTAB_ARRAYLENGTH
;
832 agc_table
= rtl8192seagctab_array
;
833 /* Default RF_type: 2T2R */
834 phy_reg_len
= PHY_REG_2T2RARRAYLENGTH
;
835 phy_reg_table
= rtl8192sephy_reg_2t2rarray
;
837 if (configtype
== BASEBAND_CONFIG_PHY_REG
) {
838 for (i
= 0; i
< phy_reg_len
; i
= i
+ 2) {
839 rtl_addr_delay(phy_reg_table
[i
]);
841 /* Add delay for ECS T20 & LG malow platform, */
844 rtl92s_phy_set_bb_reg(hw
, phy_reg_table
[i
], MASKDWORD
,
845 phy_reg_table
[i
+ 1]);
847 } else if (configtype
== BASEBAND_CONFIG_AGC_TAB
) {
848 for (i
= 0; i
< agc_len
; i
= i
+ 2) {
849 rtl92s_phy_set_bb_reg(hw
, agc_table
[i
], MASKDWORD
,
852 /* Add delay for ECS T20 & LG malow platform */
860 static bool _rtl92s_phy_set_bb_to_diff_rf(struct ieee80211_hw
*hw
,
863 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
864 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
865 u32
*phy_regarray2xtxr_table
;
866 u16 phy_regarray2xtxr_len
;
869 if (rtlphy
->rf_type
== RF_1T1R
) {
870 phy_regarray2xtxr_table
= rtl8192sephy_changeto_1t1rarray
;
871 phy_regarray2xtxr_len
= PHY_CHANGETO_1T1RARRAYLENGTH
;
872 } else if (rtlphy
->rf_type
== RF_1T2R
) {
873 phy_regarray2xtxr_table
= rtl8192sephy_changeto_1t2rarray
;
874 phy_regarray2xtxr_len
= PHY_CHANGETO_1T2RARRAYLENGTH
;
879 if (configtype
== BASEBAND_CONFIG_PHY_REG
) {
880 for (i
= 0; i
< phy_regarray2xtxr_len
; i
= i
+ 3) {
881 rtl_addr_delay(phy_regarray2xtxr_table
[i
]);
883 rtl92s_phy_set_bb_reg(hw
, phy_regarray2xtxr_table
[i
],
884 phy_regarray2xtxr_table
[i
+ 1],
885 phy_regarray2xtxr_table
[i
+ 2]);
892 static bool _rtl92s_phy_config_bb_with_pg(struct ieee80211_hw
*hw
,
899 phy_pg_len
= PHY_REG_ARRAY_PGLENGTH
;
900 phy_table_pg
= rtl8192sephy_reg_array_pg
;
902 if (configtype
== BASEBAND_CONFIG_PHY_REG
) {
903 for (i
= 0; i
< phy_pg_len
; i
= i
+ 3) {
904 rtl_addr_delay(phy_table_pg
[i
]);
906 _rtl92s_store_pwrindex_diffrate_offset(hw
,
909 phy_table_pg
[i
+ 2]);
910 rtl92s_phy_set_bb_reg(hw
, phy_table_pg
[i
],
912 phy_table_pg
[i
+ 2]);
919 static bool _rtl92s_phy_bb_config_parafile(struct ieee80211_hw
*hw
)
921 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
922 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
923 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
924 bool rtstatus
= true;
926 /* 1. Read PHY_REG.TXT BB INIT!! */
927 /* We will separate as 1T1R/1T2R/1T2R_GREEN/2T2R */
928 if (rtlphy
->rf_type
== RF_1T2R
|| rtlphy
->rf_type
== RF_2T2R
||
929 rtlphy
->rf_type
== RF_1T1R
|| rtlphy
->rf_type
== RF_2T2R_GREEN
) {
930 rtstatus
= _rtl92s_phy_config_bb(hw
, BASEBAND_CONFIG_PHY_REG
);
932 if (rtlphy
->rf_type
!= RF_2T2R
&&
933 rtlphy
->rf_type
!= RF_2T2R_GREEN
)
934 /* so we should reconfig BB reg with the right
936 rtstatus
= _rtl92s_phy_set_bb_to_diff_rf(hw
,
937 BASEBAND_CONFIG_PHY_REG
);
943 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_EMERG
,
944 "Write BB Reg Fail!!\n");
945 goto phy_BB8190_Config_ParaFile_Fail
;
948 /* 2. If EEPROM or EFUSE autoload OK, We must config by
950 if (rtlefuse
->autoload_failflag
== false) {
951 rtlphy
->pwrgroup_cnt
= 0;
953 rtstatus
= _rtl92s_phy_config_bb_with_pg(hw
,
954 BASEBAND_CONFIG_PHY_REG
);
957 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_EMERG
,
958 "_rtl92s_phy_bb_config_parafile(): BB_PG Reg Fail!!\n");
959 goto phy_BB8190_Config_ParaFile_Fail
;
962 /* 3. BB AGC table Initialization */
963 rtstatus
= _rtl92s_phy_config_bb(hw
, BASEBAND_CONFIG_AGC_TAB
);
966 pr_err("%s(): AGC Table Fail\n", __func__
);
967 goto phy_BB8190_Config_ParaFile_Fail
;
970 /* Check if the CCK HighPower is turned ON. */
971 /* This is used to calculate PWDB. */
972 rtlphy
->cck_high_power
= (bool)(rtl92s_phy_query_bb_reg(hw
,
973 RFPGA0_XA_HSSIPARAMETER2
, 0x200));
975 phy_BB8190_Config_ParaFile_Fail
:
979 u8
rtl92s_phy_config_rf(struct ieee80211_hw
*hw
, enum radio_path rfpath
)
981 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
982 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
984 bool rtstatus
= true;
987 u16 radio_a_tblen
, radio_b_tblen
;
989 radio_a_tblen
= RADIOA_1T_ARRAYLENGTH
;
990 radio_a_table
= rtl8192seradioa_1t_array
;
992 /* Using Green mode array table for RF_2T2R_GREEN */
993 if (rtlphy
->rf_type
== RF_2T2R_GREEN
) {
994 radio_b_table
= rtl8192seradiob_gm_array
;
995 radio_b_tblen
= RADIOB_GM_ARRAYLENGTH
;
997 radio_b_table
= rtl8192seradiob_array
;
998 radio_b_tblen
= RADIOB_ARRAYLENGTH
;
1001 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
, "Radio No %x\n", rfpath
);
1006 for (i
= 0; i
< radio_a_tblen
; i
= i
+ 2) {
1007 rtl_rfreg_delay(hw
, rfpath
, radio_a_table
[i
],
1008 MASK20BITS
, radio_a_table
[i
+ 1]);
1012 /* PA Bias current for inferiority IC */
1013 _rtl92s_phy_config_rfpa_bias_current(hw
, rfpath
);
1016 for (i
= 0; i
< radio_b_tblen
; i
= i
+ 2) {
1017 rtl_rfreg_delay(hw
, rfpath
, radio_b_table
[i
],
1018 MASK20BITS
, radio_b_table
[i
+ 1]);
1035 bool rtl92s_phy_mac_config(struct ieee80211_hw
*hw
)
1037 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1042 arraylength
= MAC_2T_ARRAYLENGTH
;
1043 ptraArray
= rtl8192semac_2t_array
;
1045 for (i
= 0; i
< arraylength
; i
= i
+ 2)
1046 rtl_write_byte(rtlpriv
, ptraArray
[i
], (u8
)ptraArray
[i
+ 1]);
1052 bool rtl92s_phy_bb_config(struct ieee80211_hw
*hw
)
1054 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1055 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1056 bool rtstatus
= true;
1057 u8 pathmap
, index
, rf_num
= 0;
1060 _rtl92s_phy_init_register_definition(hw
);
1062 /* Config BB and AGC */
1063 rtstatus
= _rtl92s_phy_bb_config_parafile(hw
);
1066 /* Check BB/RF confiuration setting. */
1067 /* We only need to configure RF which is turned on. */
1068 path1
= (u8
)(rtl92s_phy_query_bb_reg(hw
, RFPGA0_TXINFO
, 0xf));
1070 path2
= (u8
)(rtl92s_phy_query_bb_reg(hw
, ROFDM0_TRXPATHENABLE
, 0xf));
1071 pathmap
= path1
| path2
;
1073 rtlphy
->rf_pathmap
= pathmap
;
1074 for (index
= 0; index
< 4; index
++) {
1075 if ((pathmap
>> index
) & 0x1)
1079 if ((rtlphy
->rf_type
== RF_1T1R
&& rf_num
!= 1) ||
1080 (rtlphy
->rf_type
== RF_1T2R
&& rf_num
!= 2) ||
1081 (rtlphy
->rf_type
== RF_2T2R
&& rf_num
!= 2) ||
1082 (rtlphy
->rf_type
== RF_2T2R_GREEN
&& rf_num
!= 2)) {
1083 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_EMERG
,
1084 "RF_Type(%x) does not match RF_Num(%x)!!\n",
1085 rtlphy
->rf_type
, rf_num
);
1086 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_EMERG
,
1087 "path1 0x%x, path2 0x%x, pathmap 0x%x\n",
1088 path1
, path2
, pathmap
);
1094 bool rtl92s_phy_rf_config(struct ieee80211_hw
*hw
)
1096 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1097 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1099 /* Initialize general global value */
1100 if (rtlphy
->rf_type
== RF_1T1R
)
1101 rtlphy
->num_total_rfpath
= 1;
1103 rtlphy
->num_total_rfpath
= 2;
1105 /* Config BB and RF */
1106 return rtl92s_phy_rf6052_config(hw
);
1109 void rtl92s_phy_get_hw_reg_originalvalue(struct ieee80211_hw
*hw
)
1111 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1112 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1114 /* read rx initial gain */
1115 rtlphy
->default_initialgain
[0] = rtl_get_bbreg(hw
,
1116 ROFDM0_XAAGCCORE1
, MASKBYTE0
);
1117 rtlphy
->default_initialgain
[1] = rtl_get_bbreg(hw
,
1118 ROFDM0_XBAGCCORE1
, MASKBYTE0
);
1119 rtlphy
->default_initialgain
[2] = rtl_get_bbreg(hw
,
1120 ROFDM0_XCAGCCORE1
, MASKBYTE0
);
1121 rtlphy
->default_initialgain
[3] = rtl_get_bbreg(hw
,
1122 ROFDM0_XDAGCCORE1
, MASKBYTE0
);
1123 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
,
1124 "Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x)\n",
1125 rtlphy
->default_initialgain
[0],
1126 rtlphy
->default_initialgain
[1],
1127 rtlphy
->default_initialgain
[2],
1128 rtlphy
->default_initialgain
[3]);
1130 /* read framesync */
1131 rtlphy
->framesync
= rtl_get_bbreg(hw
, ROFDM0_RXDETECTOR3
, MASKBYTE0
);
1132 rtlphy
->framesync_c34
= rtl_get_bbreg(hw
, ROFDM0_RXDETECTOR2
,
1134 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_LOUD
,
1135 "Default framesync (0x%x) = 0x%x\n",
1136 ROFDM0_RXDETECTOR3
, rtlphy
->framesync
);
1140 static void _rtl92s_phy_get_txpower_index(struct ieee80211_hw
*hw
, u8 channel
,
1141 u8
*cckpowerlevel
, u8
*ofdmpowerLevel
)
1143 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1144 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1145 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
1146 u8 index
= (channel
- 1);
1150 cckpowerlevel
[0] = rtlefuse
->txpwrlevel_cck
[0][index
];
1152 cckpowerlevel
[1] = rtlefuse
->txpwrlevel_cck
[1][index
];
1154 /* 2. OFDM for 1T or 2T */
1155 if (rtlphy
->rf_type
== RF_1T2R
|| rtlphy
->rf_type
== RF_1T1R
) {
1156 /* Read HT 40 OFDM TX power */
1157 ofdmpowerLevel
[0] = rtlefuse
->txpwrlevel_ht40_1s
[0][index
];
1158 ofdmpowerLevel
[1] = rtlefuse
->txpwrlevel_ht40_1s
[1][index
];
1159 } else if (rtlphy
->rf_type
== RF_2T2R
) {
1160 /* Read HT 40 OFDM TX power */
1161 ofdmpowerLevel
[0] = rtlefuse
->txpwrlevel_ht40_2s
[0][index
];
1162 ofdmpowerLevel
[1] = rtlefuse
->txpwrlevel_ht40_2s
[1][index
];
1164 ofdmpowerLevel
[0] = 0;
1165 ofdmpowerLevel
[1] = 0;
1169 static void _rtl92s_phy_ccxpower_indexcheck(struct ieee80211_hw
*hw
,
1170 u8 channel
, u8
*cckpowerlevel
, u8
*ofdmpowerlevel
)
1172 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1173 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1175 rtlphy
->cur_cck_txpwridx
= cckpowerlevel
[0];
1176 rtlphy
->cur_ofdm24g_txpwridx
= ofdmpowerlevel
[0];
1179 void rtl92s_phy_set_txpower(struct ieee80211_hw
*hw
, u8 channel
)
1181 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1182 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
1183 /* [0]:RF-A, [1]:RF-B */
1184 u8 cckpowerlevel
[2], ofdmpowerLevel
[2];
1186 if (!rtlefuse
->txpwr_fromeprom
)
1189 /* Mainly we use RF-A Tx Power to write the Tx Power registers,
1190 * but the RF-B Tx Power must be calculated by the antenna diff.
1191 * So we have to rewrite Antenna gain offset register here.
1192 * Please refer to BB register 0x80c
1194 * 2. For OFDM 1T or 2T */
1195 _rtl92s_phy_get_txpower_index(hw
, channel
, &cckpowerlevel
[0],
1196 &ofdmpowerLevel
[0]);
1198 RT_TRACE(rtlpriv
, COMP_POWER
, DBG_LOUD
,
1199 "Channel-%d, cckPowerLevel (A / B) = 0x%x / 0x%x, ofdmPowerLevel (A / B) = 0x%x / 0x%x\n",
1200 channel
, cckpowerlevel
[0], cckpowerlevel
[1],
1201 ofdmpowerLevel
[0], ofdmpowerLevel
[1]);
1203 _rtl92s_phy_ccxpower_indexcheck(hw
, channel
, &cckpowerlevel
[0],
1204 &ofdmpowerLevel
[0]);
1206 rtl92s_phy_rf6052_set_ccktxpower(hw
, cckpowerlevel
[0]);
1207 rtl92s_phy_rf6052_set_ofdmtxpower(hw
, &ofdmpowerLevel
[0], channel
);
1211 void rtl92s_phy_chk_fwcmd_iodone(struct ieee80211_hw
*hw
)
1213 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1214 u16 pollingcnt
= 10000;
1217 /* Make sure that CMD IO has be accepted by FW. */
1221 tmpvalue
= rtl_read_dword(rtlpriv
, WFM5
);
1224 } while (--pollingcnt
);
1226 if (pollingcnt
== 0)
1227 RT_TRACE(rtlpriv
, COMP_ERR
, DBG_EMERG
, "Set FW Cmd fail!!\n");
1231 static void _rtl92s_phy_set_fwcmd_io(struct ieee80211_hw
*hw
)
1233 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1234 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1235 struct rtl_phy
*rtlphy
= &(rtlpriv
->phy
);
1236 u32 input
, current_aid
= 0;
1238 if (is_hal_stop(rtlhal
))
1241 if (hal_get_firmwareversion(rtlpriv
) < 0x34)
1243 /* We re-map RA related CMD IO to combinational ones */
1244 /* if FW version is v.52 or later. */
1245 switch (rtlhal
->current_fwcmd_io
) {
1246 case FW_CMD_RA_REFRESH_N
:
1247 rtlhal
->current_fwcmd_io
= FW_CMD_RA_REFRESH_N_COMB
;
1249 case FW_CMD_RA_REFRESH_BG
:
1250 rtlhal
->current_fwcmd_io
= FW_CMD_RA_REFRESH_BG_COMB
;
1257 switch (rtlhal
->current_fwcmd_io
) {
1258 case FW_CMD_RA_RESET
:
1259 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_DMESG
, "FW_CMD_RA_RESET\n");
1260 rtl_write_dword(rtlpriv
, WFM5
, FW_RA_RESET
);
1261 rtl92s_phy_chk_fwcmd_iodone(hw
);
1263 case FW_CMD_RA_ACTIVE
:
1264 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_DMESG
, "FW_CMD_RA_ACTIVE\n");
1265 rtl_write_dword(rtlpriv
, WFM5
, FW_RA_ACTIVE
);
1266 rtl92s_phy_chk_fwcmd_iodone(hw
);
1268 case FW_CMD_RA_REFRESH_N
:
1269 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_DMESG
, "FW_CMD_RA_REFRESH_N\n");
1270 input
= FW_RA_REFRESH
;
1271 rtl_write_dword(rtlpriv
, WFM5
, input
);
1272 rtl92s_phy_chk_fwcmd_iodone(hw
);
1273 rtl_write_dword(rtlpriv
, WFM5
, FW_RA_ENABLE_RSSI_MASK
);
1274 rtl92s_phy_chk_fwcmd_iodone(hw
);
1276 case FW_CMD_RA_REFRESH_BG
:
1277 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_DMESG
,
1278 "FW_CMD_RA_REFRESH_BG\n");
1279 rtl_write_dword(rtlpriv
, WFM5
, FW_RA_REFRESH
);
1280 rtl92s_phy_chk_fwcmd_iodone(hw
);
1281 rtl_write_dword(rtlpriv
, WFM5
, FW_RA_DISABLE_RSSI_MASK
);
1282 rtl92s_phy_chk_fwcmd_iodone(hw
);
1284 case FW_CMD_RA_REFRESH_N_COMB
:
1285 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_DMESG
,
1286 "FW_CMD_RA_REFRESH_N_COMB\n");
1287 input
= FW_RA_IOT_N_COMB
;
1288 rtl_write_dword(rtlpriv
, WFM5
, input
);
1289 rtl92s_phy_chk_fwcmd_iodone(hw
);
1291 case FW_CMD_RA_REFRESH_BG_COMB
:
1292 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_DMESG
,
1293 "FW_CMD_RA_REFRESH_BG_COMB\n");
1294 input
= FW_RA_IOT_BG_COMB
;
1295 rtl_write_dword(rtlpriv
, WFM5
, input
);
1296 rtl92s_phy_chk_fwcmd_iodone(hw
);
1298 case FW_CMD_IQK_ENABLE
:
1299 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_DMESG
, "FW_CMD_IQK_ENABLE\n");
1300 rtl_write_dword(rtlpriv
, WFM5
, FW_IQK_ENABLE
);
1301 rtl92s_phy_chk_fwcmd_iodone(hw
);
1303 case FW_CMD_PAUSE_DM_BY_SCAN
:
1304 /* Lower initial gain */
1305 rtl_set_bbreg(hw
, ROFDM0_XAAGCCORE1
, MASKBYTE0
, 0x17);
1306 rtl_set_bbreg(hw
, ROFDM0_XBAGCCORE1
, MASKBYTE0
, 0x17);
1308 rtl_set_bbreg(hw
, RCCK0_CCA
, MASKBYTE2
, 0x40);
1310 case FW_CMD_RESUME_DM_BY_SCAN
:
1312 rtl_set_bbreg(hw
, RCCK0_CCA
, MASKBYTE2
, 0xcd);
1313 rtl92s_phy_set_txpower(hw
, rtlphy
->current_channel
);
1315 case FW_CMD_HIGH_PWR_DISABLE
:
1316 if (rtlpriv
->dm
.dm_flag
& HAL_DM_HIPWR_DISABLE
)
1319 /* Lower initial gain */
1320 rtl_set_bbreg(hw
, ROFDM0_XAAGCCORE1
, MASKBYTE0
, 0x17);
1321 rtl_set_bbreg(hw
, ROFDM0_XBAGCCORE1
, MASKBYTE0
, 0x17);
1323 rtl_set_bbreg(hw
, RCCK0_CCA
, MASKBYTE2
, 0x40);
1325 case FW_CMD_HIGH_PWR_ENABLE
:
1326 if ((rtlpriv
->dm
.dm_flag
& HAL_DM_HIPWR_DISABLE
) ||
1327 rtlpriv
->dm
.dynamic_txpower_enable
)
1331 rtl_set_bbreg(hw
, RCCK0_CCA
, MASKBYTE2
, 0xcd);
1333 case FW_CMD_LPS_ENTER
:
1334 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_DMESG
, "FW_CMD_LPS_ENTER\n");
1335 current_aid
= rtlpriv
->mac80211
.assoc_id
;
1336 rtl_write_dword(rtlpriv
, WFM5
, (FW_LPS_ENTER
|
1337 ((current_aid
| 0xc000) << 8)));
1338 rtl92s_phy_chk_fwcmd_iodone(hw
);
1339 /* FW set TXOP disable here, so disable EDCA
1340 * turbo mode until driver leave LPS */
1342 case FW_CMD_LPS_LEAVE
:
1343 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_DMESG
, "FW_CMD_LPS_LEAVE\n");
1344 rtl_write_dword(rtlpriv
, WFM5
, FW_LPS_LEAVE
);
1345 rtl92s_phy_chk_fwcmd_iodone(hw
);
1347 case FW_CMD_ADD_A2_ENTRY
:
1348 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_DMESG
, "FW_CMD_ADD_A2_ENTRY\n");
1349 rtl_write_dword(rtlpriv
, WFM5
, FW_ADD_A2_ENTRY
);
1350 rtl92s_phy_chk_fwcmd_iodone(hw
);
1352 case FW_CMD_CTRL_DM_BY_DRIVER
:
1353 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_LOUD
,
1354 "FW_CMD_CTRL_DM_BY_DRIVER\n");
1355 rtl_write_dword(rtlpriv
, WFM5
, FW_CTRL_DM_BY_DRIVER
);
1356 rtl92s_phy_chk_fwcmd_iodone(hw
);
1363 rtl92s_phy_chk_fwcmd_iodone(hw
);
1365 /* Clear FW CMD operation flag. */
1366 rtlhal
->set_fwcmd_inprogress
= false;
1369 bool rtl92s_phy_set_fw_cmd(struct ieee80211_hw
*hw
, enum fwcmd_iotype fw_cmdio
)
1371 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1372 struct dig_t
*digtable
= &rtlpriv
->dm_digtable
;
1373 struct rtl_hal
*rtlhal
= rtl_hal(rtl_priv(hw
));
1374 struct rtl_efuse
*rtlefuse
= rtl_efuse(rtl_priv(hw
));
1375 u32 fw_param
= FW_CMD_IO_PARA_QUERY(rtlpriv
);
1376 u16 fw_cmdmap
= FW_CMD_IO_QUERY(rtlpriv
);
1377 bool postprocessing
= false;
1379 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_LOUD
,
1380 "Set FW Cmd(%#x), set_fwcmd_inprogress(%d)\n",
1381 fw_cmdio
, rtlhal
->set_fwcmd_inprogress
);
1384 /* We re-map to combined FW CMD ones if firmware version */
1385 /* is v.53 or later. */
1386 if (hal_get_firmwareversion(rtlpriv
) >= 0x35) {
1388 case FW_CMD_RA_REFRESH_N
:
1389 fw_cmdio
= FW_CMD_RA_REFRESH_N_COMB
;
1391 case FW_CMD_RA_REFRESH_BG
:
1392 fw_cmdio
= FW_CMD_RA_REFRESH_BG_COMB
;
1398 if ((fw_cmdio
== FW_CMD_IQK_ENABLE
) ||
1399 (fw_cmdio
== FW_CMD_RA_REFRESH_N
) ||
1400 (fw_cmdio
== FW_CMD_RA_REFRESH_BG
)) {
1401 postprocessing
= true;
1406 /* If firmware version is v.62 or later,
1407 * use FW_CMD_IO_SET for FW_CMD_CTRL_DM_BY_DRIVER */
1408 if (hal_get_firmwareversion(rtlpriv
) >= 0x3E) {
1409 if (fw_cmdio
== FW_CMD_CTRL_DM_BY_DRIVER
)
1410 fw_cmdio
= FW_CMD_CTRL_DM_BY_DRIVER_NEW
;
1414 /* We shall revise all FW Cmd IO into Reg0x364
1415 * DM map table in the future. */
1417 case FW_CMD_RA_INIT
:
1418 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_LOUD
, "RA init!!\n");
1419 fw_cmdmap
|= FW_RA_INIT_CTL
;
1420 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1421 /* Clear control flag to sync with FW. */
1422 FW_CMD_IO_CLR(rtlpriv
, FW_RA_INIT_CTL
);
1424 case FW_CMD_DIG_DISABLE
:
1425 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_LOUD
,
1426 "Set DIG disable!!\n");
1427 fw_cmdmap
&= ~FW_DIG_ENABLE_CTL
;
1428 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1430 case FW_CMD_DIG_ENABLE
:
1431 case FW_CMD_DIG_RESUME
:
1432 if (!(rtlpriv
->dm
.dm_flag
& HAL_DM_DIG_DISABLE
)) {
1433 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_LOUD
,
1434 "Set DIG enable or resume!!\n");
1435 fw_cmdmap
|= (FW_DIG_ENABLE_CTL
| FW_SS_CTL
);
1436 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1439 case FW_CMD_DIG_HALT
:
1440 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_LOUD
,
1441 "Set DIG halt!!\n");
1442 fw_cmdmap
&= ~(FW_DIG_ENABLE_CTL
| FW_SS_CTL
);
1443 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1445 case FW_CMD_TXPWR_TRACK_THERMAL
: {
1447 fw_cmdmap
|= FW_PWR_TRK_CTL
;
1449 /* Clear FW parameter in terms of thermal parts. */
1450 fw_param
&= FW_PWR_TRK_PARAM_CLR
;
1452 thermalval
= rtlpriv
->dm
.thermalvalue
;
1453 fw_param
|= ((thermalval
<< 24) |
1454 (rtlefuse
->thermalmeter
[0] << 16));
1456 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_LOUD
,
1457 "Set TxPwr tracking!! FwCmdMap(%#x), FwParam(%#x)\n",
1458 fw_cmdmap
, fw_param
);
1460 FW_CMD_PARA_SET(rtlpriv
, fw_param
);
1461 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1463 /* Clear control flag to sync with FW. */
1464 FW_CMD_IO_CLR(rtlpriv
, FW_PWR_TRK_CTL
);
1467 /* The following FW CMDs are only compatible to
1469 case FW_CMD_RA_REFRESH_N_COMB
:
1470 fw_cmdmap
|= FW_RA_N_CTL
;
1472 /* Clear RA BG mode control. */
1473 fw_cmdmap
&= ~(FW_RA_BG_CTL
| FW_RA_INIT_CTL
);
1475 /* Clear FW parameter in terms of RA parts. */
1476 fw_param
&= FW_RA_PARAM_CLR
;
1478 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_LOUD
,
1479 "[FW CMD] [New Version] Set RA/IOT Comb in n mode!! FwCmdMap(%#x), FwParam(%#x)\n",
1480 fw_cmdmap
, fw_param
);
1482 FW_CMD_PARA_SET(rtlpriv
, fw_param
);
1483 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1485 /* Clear control flag to sync with FW. */
1486 FW_CMD_IO_CLR(rtlpriv
, FW_RA_N_CTL
);
1488 case FW_CMD_RA_REFRESH_BG_COMB
:
1489 fw_cmdmap
|= FW_RA_BG_CTL
;
1491 /* Clear RA n-mode control. */
1492 fw_cmdmap
&= ~(FW_RA_N_CTL
| FW_RA_INIT_CTL
);
1493 /* Clear FW parameter in terms of RA parts. */
1494 fw_param
&= FW_RA_PARAM_CLR
;
1496 FW_CMD_PARA_SET(rtlpriv
, fw_param
);
1497 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1499 /* Clear control flag to sync with FW. */
1500 FW_CMD_IO_CLR(rtlpriv
, FW_RA_BG_CTL
);
1502 case FW_CMD_IQK_ENABLE
:
1503 fw_cmdmap
|= FW_IQK_CTL
;
1504 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1505 /* Clear control flag to sync with FW. */
1506 FW_CMD_IO_CLR(rtlpriv
, FW_IQK_CTL
);
1508 /* The following FW CMD is compatible to v.62 or later. */
1509 case FW_CMD_CTRL_DM_BY_DRIVER_NEW
:
1510 fw_cmdmap
|= FW_DRIVER_CTRL_DM_CTL
;
1511 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1513 /* The followed FW Cmds needs post-processing later. */
1514 case FW_CMD_RESUME_DM_BY_SCAN
:
1515 fw_cmdmap
|= (FW_DIG_ENABLE_CTL
|
1516 FW_HIGH_PWR_ENABLE_CTL
|
1519 if (rtlpriv
->dm
.dm_flag
& HAL_DM_DIG_DISABLE
||
1520 !digtable
->dig_enable_flag
)
1521 fw_cmdmap
&= ~FW_DIG_ENABLE_CTL
;
1523 if ((rtlpriv
->dm
.dm_flag
& HAL_DM_HIPWR_DISABLE
) ||
1524 rtlpriv
->dm
.dynamic_txpower_enable
)
1525 fw_cmdmap
&= ~FW_HIGH_PWR_ENABLE_CTL
;
1527 if ((digtable
->dig_ext_port_stage
==
1528 DIG_EXT_PORT_STAGE_0
) ||
1529 (digtable
->dig_ext_port_stage
==
1530 DIG_EXT_PORT_STAGE_1
))
1531 fw_cmdmap
&= ~FW_DIG_ENABLE_CTL
;
1533 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1534 postprocessing
= true;
1536 case FW_CMD_PAUSE_DM_BY_SCAN
:
1537 fw_cmdmap
&= ~(FW_DIG_ENABLE_CTL
|
1538 FW_HIGH_PWR_ENABLE_CTL
|
1540 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1541 postprocessing
= true;
1543 case FW_CMD_HIGH_PWR_DISABLE
:
1544 fw_cmdmap
&= ~FW_HIGH_PWR_ENABLE_CTL
;
1545 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1546 postprocessing
= true;
1548 case FW_CMD_HIGH_PWR_ENABLE
:
1549 if (!(rtlpriv
->dm
.dm_flag
& HAL_DM_HIPWR_DISABLE
) &&
1550 !rtlpriv
->dm
.dynamic_txpower_enable
) {
1551 fw_cmdmap
|= (FW_HIGH_PWR_ENABLE_CTL
|
1553 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1554 postprocessing
= true;
1557 case FW_CMD_DIG_MODE_FA
:
1558 fw_cmdmap
|= FW_FA_CTL
;
1559 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1561 case FW_CMD_DIG_MODE_SS
:
1562 fw_cmdmap
&= ~FW_FA_CTL
;
1563 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1565 case FW_CMD_PAPE_CONTROL
:
1566 RT_TRACE(rtlpriv
, COMP_CMD
, DBG_LOUD
,
1567 "[FW CMD] Set PAPE Control\n");
1568 fw_cmdmap
&= ~FW_PAPE_CTL_BY_SW_HW
;
1570 FW_CMD_IO_SET(rtlpriv
, fw_cmdmap
);
1573 /* Pass to original FW CMD processing callback
1575 postprocessing
= true;
1580 /* We shall post processing these FW CMD if
1581 * variable postprocessing is set.
1583 if (postprocessing
&& !rtlhal
->set_fwcmd_inprogress
) {
1584 rtlhal
->set_fwcmd_inprogress
= true;
1585 /* Update current FW Cmd for callback use. */
1586 rtlhal
->current_fwcmd_io
= fw_cmdio
;
1591 _rtl92s_phy_set_fwcmd_io(hw
);
1595 static void _rtl92s_phy_check_ephy_switchready(struct ieee80211_hw
*hw
)
1597 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1601 regu1
= rtl_read_byte(rtlpriv
, 0x554);
1602 while ((regu1
& BIT(5)) && (delay
> 0)) {
1603 regu1
= rtl_read_byte(rtlpriv
, 0x554);
1605 /* We delay only 50us to prevent
1606 * being scheduled out. */
1611 void rtl92s_phy_switch_ephy_parameter(struct ieee80211_hw
*hw
)
1613 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1614 struct rtl_ps_ctl
*ppsc
= rtl_psc(rtl_priv(hw
));
1616 /* The way to be capable to switch clock request
1617 * when the PG setting does not support clock request.
1618 * This is the backdoor solution to switch clock
1619 * request before ASPM or D3. */
1620 rtl_write_dword(rtlpriv
, 0x540, 0x73c11);
1621 rtl_write_dword(rtlpriv
, 0x548, 0x2407c);
1623 /* Switch EPHY parameter!!!! */
1624 rtl_write_word(rtlpriv
, 0x550, 0x1000);
1625 rtl_write_byte(rtlpriv
, 0x554, 0x20);
1626 _rtl92s_phy_check_ephy_switchready(hw
);
1628 rtl_write_word(rtlpriv
, 0x550, 0xa0eb);
1629 rtl_write_byte(rtlpriv
, 0x554, 0x3e);
1630 _rtl92s_phy_check_ephy_switchready(hw
);
1632 rtl_write_word(rtlpriv
, 0x550, 0xff80);
1633 rtl_write_byte(rtlpriv
, 0x554, 0x39);
1634 _rtl92s_phy_check_ephy_switchready(hw
);
1636 /* Delay L1 enter time */
1637 if (ppsc
->support_aspm
&& !ppsc
->support_backdoor
)
1638 rtl_write_byte(rtlpriv
, 0x560, 0x40);
1640 rtl_write_byte(rtlpriv
, 0x560, 0x00);
1644 void rtl92s_phy_set_beacon_hwreg(struct ieee80211_hw
*hw
, u16 beaconinterval
)
1646 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
1647 u32 new_bcn_num
= 0;
1649 if (hal_get_firmwareversion(rtlpriv
) >= 0x33) {
1650 /* Fw v.51 and later. */
1651 rtl_write_dword(rtlpriv
, WFM5
, 0xF1000000 |
1652 (beaconinterval
<< 8));
1654 new_bcn_num
= beaconinterval
* 32 - 64;
1655 rtl_write_dword(rtlpriv
, WFM3
+ 4, new_bcn_num
);
1656 rtl_write_dword(rtlpriv
, WFM3
, 0xB026007C);