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 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
59 "unknown bandwidth: %#X\n", bandwidth);
64 bool rtl92ee_phy_rf6052_config(struct ieee80211_hw *hw)
66 struct rtl_priv *rtlpriv = rtl_priv(hw);
67 struct rtl_phy *rtlphy = &rtlpriv->phy;
69 if (rtlphy->rf_type == RF_1T1R)
70 rtlphy->num_total_rfpath = 1;
72 rtlphy->num_total_rfpath = 2;
74 return _rtl92ee_phy_rf6052_config_parafile(hw);
77 static bool _rtl92ee_phy_rf6052_config_parafile(struct ieee80211_hw *hw)
79 struct rtl_priv *rtlpriv = rtl_priv(hw);
80 struct rtl_phy *rtlphy = &rtlpriv->phy;
84 struct bb_reg_def *pphyreg;
86 for (rfpath = 0; rfpath < rtlphy->num_total_rfpath; rfpath++) {
87 pphyreg = &rtlphy->phyreg_def[rfpath];
92 u4_regvalue = rtl_get_bbreg(hw, pphyreg->rfintfs,
97 u4_regvalue = rtl_get_bbreg(hw, pphyreg->rfintfs,
102 rtl_set_bbreg(hw, pphyreg->rfintfe, BRFSI_RFENV << 16, 0x1);
105 rtl_set_bbreg(hw, pphyreg->rfintfo, BRFSI_RFENV, 0x1);
108 rtl_set_bbreg(hw, pphyreg->rfhssi_para2,
109 B3WIREADDREAALENGTH, 0x0);
112 rtl_set_bbreg(hw, pphyreg->rfhssi_para2, B3WIREDATALENGTH, 0x0);
117 rtstatus = rtl92ee_phy_config_rf_with_headerfile(hw,
118 (enum radio_path)rfpath);
121 rtstatus = rtl92ee_phy_config_rf_with_headerfile(hw,
122 (enum radio_path)rfpath);
133 rtl_set_bbreg(hw, pphyreg->rfintfs,
134 BRFSI_RFENV, u4_regvalue);
138 rtl_set_bbreg(hw, pphyreg->rfintfs,
139 BRFSI_RFENV << 16, u4_regvalue);
144 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE,
145 "Radio[%d] Fail!!", rfpath);
150 RT_TRACE(rtlpriv, COMP_INIT, DBG_TRACE, "\n");