1 /******************************************************************************
3 * Copyright(c) 2009-2014 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 * The full GNU General Public License is included in this distribution in the
15 * file called LICENSE.
17 * Contact Information:
18 * wlanfae <wlanfae@realtek.com>
19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20 * Hsinchu 300, Taiwan.
22 * Larry Finger <Larry.Finger@lwfinger.net>
24 *****************************************************************************/
33 static bool _rtl92ee_phy_rf6052_config_parafile(struct ieee80211_hw
*hw
);
35 void rtl92ee_phy_rf6052_set_bandwidth(struct ieee80211_hw
*hw
, u8 bandwidth
)
37 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
38 struct rtl_phy
*rtlphy
= &rtlpriv
->phy
;
41 case HT_CHANNEL_WIDTH_20
:
42 rtlphy
->rfreg_chnlval
[0] = ((rtlphy
->rfreg_chnlval
[0] &
43 0xfffff3ff) | BIT(10) | BIT(11));
44 rtl_set_rfreg(hw
, RF90_PATH_A
, RF_CHNLBW
, RFREG_OFFSET_MASK
,
45 rtlphy
->rfreg_chnlval
[0]);
46 rtl_set_rfreg(hw
, RF90_PATH_B
, RF_CHNLBW
, RFREG_OFFSET_MASK
,
47 rtlphy
->rfreg_chnlval
[0]);
49 case HT_CHANNEL_WIDTH_20_40
:
50 rtlphy
->rfreg_chnlval
[0] = ((rtlphy
->rfreg_chnlval
[0] &
51 0xfffff3ff) | BIT(10));
52 rtl_set_rfreg(hw
, RF90_PATH_A
, RF_CHNLBW
, RFREG_OFFSET_MASK
,
53 rtlphy
->rfreg_chnlval
[0]);
54 rtl_set_rfreg(hw
, RF90_PATH_B
, RF_CHNLBW
, RFREG_OFFSET_MASK
,
55 rtlphy
->rfreg_chnlval
[0]);
58 pr_err("unknown bandwidth: %#X\n", bandwidth
);
63 bool rtl92ee_phy_rf6052_config(struct ieee80211_hw
*hw
)
65 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
66 struct rtl_phy
*rtlphy
= &rtlpriv
->phy
;
68 if (rtlphy
->rf_type
== RF_1T1R
)
69 rtlphy
->num_total_rfpath
= 1;
71 rtlphy
->num_total_rfpath
= 2;
73 return _rtl92ee_phy_rf6052_config_parafile(hw
);
76 static bool _rtl92ee_phy_rf6052_config_parafile(struct ieee80211_hw
*hw
)
78 struct rtl_priv
*rtlpriv
= rtl_priv(hw
);
79 struct rtl_phy
*rtlphy
= &rtlpriv
->phy
;
83 struct bb_reg_def
*pphyreg
;
85 for (rfpath
= 0; rfpath
< rtlphy
->num_total_rfpath
; rfpath
++) {
86 pphyreg
= &rtlphy
->phyreg_def
[rfpath
];
91 u4_regvalue
= rtl_get_bbreg(hw
, pphyreg
->rfintfs
,
96 u4_regvalue
= rtl_get_bbreg(hw
, pphyreg
->rfintfs
,
101 rtl_set_bbreg(hw
, pphyreg
->rfintfe
, BRFSI_RFENV
<< 16, 0x1);
104 rtl_set_bbreg(hw
, pphyreg
->rfintfo
, BRFSI_RFENV
, 0x1);
107 rtl_set_bbreg(hw
, pphyreg
->rfhssi_para2
,
108 B3WIREADDREAALENGTH
, 0x0);
111 rtl_set_bbreg(hw
, pphyreg
->rfhssi_para2
, B3WIREDATALENGTH
, 0x0);
116 rtstatus
= rtl92ee_phy_config_rf_with_headerfile(hw
,
117 (enum radio_path
)rfpath
);
120 rtstatus
= rtl92ee_phy_config_rf_with_headerfile(hw
,
121 (enum radio_path
)rfpath
);
132 rtl_set_bbreg(hw
, pphyreg
->rfintfs
,
133 BRFSI_RFENV
, u4_regvalue
);
137 rtl_set_bbreg(hw
, pphyreg
->rfintfs
,
138 BRFSI_RFENV
<< 16, u4_regvalue
);
143 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
,
144 "Radio[%d] Fail!!\n", rfpath
);
149 RT_TRACE(rtlpriv
, COMP_INIT
, DBG_TRACE
, "\n");