aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rtlwifi/rtl8192ce/sw.c')
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/sw.c122
1 files changed, 112 insertions, 10 deletions
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
index f4e2f3dcccae..390bbb5ee11d 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
@@ -42,10 +42,58 @@
42#include "trx.h" 42#include "trx.h"
43#include "led.h" 43#include "led.h"
44 44
45static void rtl92c_init_aspm_vars(struct ieee80211_hw *hw)
46{
47 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
48
49 /*close ASPM for AMD defaultly */
50 rtlpci->const_amdpci_aspm = 0;
51
52 /*
53 * ASPM PS mode.
54 * 0 - Disable ASPM,
55 * 1 - Enable ASPM without Clock Req,
56 * 2 - Enable ASPM with Clock Req,
57 * 3 - Alwyas Enable ASPM with Clock Req,
58 * 4 - Always Enable ASPM without Clock Req.
59 * set defult to RTL8192CE:3 RTL8192E:2
60 * */
61 rtlpci->const_pci_aspm = 3;
62
63 /*Setting for PCI-E device */
64 rtlpci->const_devicepci_aspm_setting = 0x03;
65
66 /*Setting for PCI-E bridge */
67 rtlpci->const_hostpci_aspm_setting = 0x02;
68
69 /*
70 * In Hw/Sw Radio Off situation.
71 * 0 - Default,
72 * 1 - From ASPM setting without low Mac Pwr,
73 * 2 - From ASPM setting with low Mac Pwr,
74 * 3 - Bus D3
75 * set default to RTL8192CE:0 RTL8192SE:2
76 */
77 rtlpci->const_hwsw_rfoff_d3 = 0;
78
79 /*
80 * This setting works for those device with
81 * backdoor ASPM setting such as EPHY setting.
82 * 0 - Not support ASPM,
83 * 1 - Support ASPM,
84 * 2 - According to chipset.
85 */
86 rtlpci->const_support_pciaspm = 1;
87}
88
45int rtl92c_init_sw_vars(struct ieee80211_hw *hw) 89int rtl92c_init_sw_vars(struct ieee80211_hw *hw)
46{ 90{
91 int err;
47 struct rtl_priv *rtlpriv = rtl_priv(hw); 92 struct rtl_priv *rtlpriv = rtl_priv(hw);
48 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw)); 93 struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
94 const struct firmware *firmware;
95
96 rtl8192ce_bt_reg_init(hw);
49 97
50 rtlpriv->dm.dm_initialgain_enable = 1; 98 rtlpriv->dm.dm_initialgain_enable = 1;
51 rtlpriv->dm.dm_flag = 0; 99 rtlpriv->dm.dm_flag = 0;
@@ -53,7 +101,12 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw)
53 rtlpriv->dm.thermalvalue = 0; 101 rtlpriv->dm.thermalvalue = 0;
54 rtlpci->transmit_config = CFENDFORM | BIT(12) | BIT(13); 102 rtlpci->transmit_config = CFENDFORM | BIT(12) | BIT(13);
55 103
56 rtlpci->receive_config = (RCR_APP_FCS | 104 /* compatible 5G band 88ce just 2.4G band & smsp */
105 rtlpriv->rtlhal.current_bandtype = BAND_ON_2_4G;
106 rtlpriv->rtlhal.bandset = BAND_ON_2_4G;
107 rtlpriv->rtlhal.macphymode = SINGLEMAC_SINGLEPHY;
108
109 rtlpci->receive_config = (RCR_APPFCS |
57 RCR_AMF | 110 RCR_AMF |
58 RCR_ADF | 111 RCR_ADF |
59 RCR_APP_MIC | 112 RCR_APP_MIC |
@@ -76,13 +129,49 @@ int rtl92c_init_sw_vars(struct ieee80211_hw *hw)
76 129
77 rtlpci->irq_mask[1] = (u32) (IMR_CPWM | IMR_C2HCMD | 0); 130 rtlpci->irq_mask[1] = (u32) (IMR_CPWM | IMR_C2HCMD | 0);
78 131
79 rtlpriv->rtlhal.pfirmware = (u8 *) vmalloc(0x4000); 132 /* for LPS & IPS */
133 rtlpriv->psc.inactiveps = rtlpriv->cfg->mod_params->inactiveps;
134 rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps;
135 rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps;
136 rtlpriv->psc.reg_fwctrl_lps = 3;
137 rtlpriv->psc.reg_max_lps_awakeintvl = 5;
138 /* for ASPM, you can close aspm through
139 * set const_support_pciaspm = 0 */
140 rtl92c_init_aspm_vars(hw);
141
142 if (rtlpriv->psc.reg_fwctrl_lps == 1)
143 rtlpriv->psc.fwctrl_psmode = FW_PS_MIN_MODE;
144 else if (rtlpriv->psc.reg_fwctrl_lps == 2)
145 rtlpriv->psc.fwctrl_psmode = FW_PS_MAX_MODE;
146 else if (rtlpriv->psc.reg_fwctrl_lps == 3)
147 rtlpriv->psc.fwctrl_psmode = FW_PS_DTIM_MODE;
148
149 /* for firmware buf */
150 rtlpriv->rtlhal.pfirmware = vzalloc(0x4000);
80 if (!rtlpriv->rtlhal.pfirmware) { 151 if (!rtlpriv->rtlhal.pfirmware) {
81 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 152 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
82 ("Can't alloc buffer for fw.\n")); 153 ("Can't alloc buffer for fw.\n"));
83 return 1; 154 return 1;
84 } 155 }
85 156
157 /* request fw */
158 err = request_firmware(&firmware, rtlpriv->cfg->fw_name,
159 rtlpriv->io.dev);
160 if (err) {
161 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
162 ("Failed to request firmware!\n"));
163 return 1;
164 }
165 if (firmware->size > 0x4000) {
166 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
167 ("Firmware is too big!\n"));
168 release_firmware(firmware);
169 return 1;
170 }
171 memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size);
172 rtlpriv->rtlhal.fwsize = firmware->size;
173 release_firmware(firmware);
174
86 return 0; 175 return 0;
87} 176}
88 177
@@ -103,17 +192,19 @@ static struct rtl_hal_ops rtl8192ce_hal_ops = {
103 .interrupt_recognized = rtl92ce_interrupt_recognized, 192 .interrupt_recognized = rtl92ce_interrupt_recognized,
104 .hw_init = rtl92ce_hw_init, 193 .hw_init = rtl92ce_hw_init,
105 .hw_disable = rtl92ce_card_disable, 194 .hw_disable = rtl92ce_card_disable,
195 .hw_suspend = rtl92ce_suspend,
196 .hw_resume = rtl92ce_resume,
106 .enable_interrupt = rtl92ce_enable_interrupt, 197 .enable_interrupt = rtl92ce_enable_interrupt,
107 .disable_interrupt = rtl92ce_disable_interrupt, 198 .disable_interrupt = rtl92ce_disable_interrupt,
108 .set_network_type = rtl92ce_set_network_type, 199 .set_network_type = rtl92ce_set_network_type,
200 .set_chk_bssid = rtl92ce_set_check_bssid,
109 .set_qos = rtl92ce_set_qos, 201 .set_qos = rtl92ce_set_qos,
110 .set_bcn_reg = rtl92ce_set_beacon_related_registers, 202 .set_bcn_reg = rtl92ce_set_beacon_related_registers,
111 .set_bcn_intv = rtl92ce_set_beacon_interval, 203 .set_bcn_intv = rtl92ce_set_beacon_interval,
112 .update_interrupt_mask = rtl92ce_update_interrupt_mask, 204 .update_interrupt_mask = rtl92ce_update_interrupt_mask,
113 .get_hw_reg = rtl92ce_get_hw_reg, 205 .get_hw_reg = rtl92ce_get_hw_reg,
114 .set_hw_reg = rtl92ce_set_hw_reg, 206 .set_hw_reg = rtl92ce_set_hw_reg,
115 .update_rate_table = rtl92ce_update_hal_rate_table, 207 .update_rate_tbl = rtl92ce_update_hal_rate_tbl,
116 .update_rate_mask = rtl92ce_update_hal_rate_mask,
117 .fill_tx_desc = rtl92ce_tx_fill_desc, 208 .fill_tx_desc = rtl92ce_tx_fill_desc,
118 .fill_tx_cmddesc = rtl92ce_tx_fill_cmddesc, 209 .fill_tx_cmddesc = rtl92ce_tx_fill_cmddesc,
119 .query_rx_desc = rtl92ce_rx_query_desc, 210 .query_rx_desc = rtl92ce_rx_query_desc,
@@ -123,7 +214,7 @@ static struct rtl_hal_ops rtl8192ce_hal_ops = {
123 .switch_channel = rtl92c_phy_sw_chnl, 214 .switch_channel = rtl92c_phy_sw_chnl,
124 .dm_watchdog = rtl92c_dm_watchdog, 215 .dm_watchdog = rtl92c_dm_watchdog,
125 .scan_operation_backup = rtl92c_phy_scan_operation_backup, 216 .scan_operation_backup = rtl92c_phy_scan_operation_backup,
126 .set_rf_power_state = rtl92ce_phy_set_rf_power_state, 217 .set_rf_power_state = rtl92c_phy_set_rf_power_state,
127 .led_control = rtl92ce_led_control, 218 .led_control = rtl92ce_led_control,
128 .set_desc = rtl92ce_set_desc, 219 .set_desc = rtl92ce_set_desc,
129 .get_desc = rtl92ce_get_desc, 220 .get_desc = rtl92ce_get_desc,
@@ -133,24 +224,27 @@ static struct rtl_hal_ops rtl8192ce_hal_ops = {
133 .init_sw_leds = rtl92ce_init_sw_leds, 224 .init_sw_leds = rtl92ce_init_sw_leds,
134 .get_bbreg = rtl92c_phy_query_bb_reg, 225 .get_bbreg = rtl92c_phy_query_bb_reg,
135 .set_bbreg = rtl92c_phy_set_bb_reg, 226 .set_bbreg = rtl92c_phy_set_bb_reg,
136 .get_rfreg = rtl92ce_phy_query_rf_reg,
137 .set_rfreg = rtl92ce_phy_set_rf_reg, 227 .set_rfreg = rtl92ce_phy_set_rf_reg,
138 .cmd_send_packet = _rtl92c_cmd_send_packet, 228 .get_rfreg = rtl92c_phy_query_rf_reg,
139 .phy_rf6052_config = rtl92ce_phy_rf6052_config, 229 .phy_rf6052_config = rtl92ce_phy_rf6052_config,
140 .phy_rf6052_set_cck_txpower = rtl92ce_phy_rf6052_set_cck_txpower, 230 .phy_rf6052_set_cck_txpower = rtl92ce_phy_rf6052_set_cck_txpower,
141 .phy_rf6052_set_ofdm_txpower = rtl92ce_phy_rf6052_set_ofdm_txpower, 231 .phy_rf6052_set_ofdm_txpower = rtl92ce_phy_rf6052_set_ofdm_txpower,
142 .config_bb_with_headerfile = _rtl92ce_phy_config_bb_with_headerfile, 232 .config_bb_with_headerfile = _rtl92ce_phy_config_bb_with_headerfile,
143 .config_bb_with_pgheaderfile = _rtl92ce_phy_config_bb_with_pgheaderfile, 233 .config_bb_with_pgheaderfile = _rtl92ce_phy_config_bb_with_pgheaderfile,
144 .phy_lc_calibrate = _rtl92ce_phy_lc_calibrate, 234 .phy_lc_calibrate = _rtl92ce_phy_lc_calibrate,
145 .phy_set_bw_mode_callback = rtl92ce_phy_set_bw_mode_callback,
146 .dm_dynamic_txpower = rtl92ce_dm_dynamic_txpower, 235 .dm_dynamic_txpower = rtl92ce_dm_dynamic_txpower,
147}; 236};
148 237
149static struct rtl_mod_params rtl92ce_mod_params = { 238static struct rtl_mod_params rtl92ce_mod_params = {
150 .sw_crypto = 0, 239 .sw_crypto = false,
240 .inactiveps = true,
241 .swctrl_lps = false,
242 .fwctrl_lps = true,
151}; 243};
152 244
153static struct rtl_hal_cfg rtl92ce_hal_cfg = { 245static struct rtl_hal_cfg rtl92ce_hal_cfg = {
246 .bar_id = 2,
247 .write_readback = true,
154 .name = "rtl92c_pci", 248 .name = "rtl92c_pci",
155 .fw_name = "rtlwifi/rtl8192cfw.bin", 249 .fw_name = "rtlwifi/rtl8192cfw.bin",
156 .ops = &rtl8192ce_hal_ops, 250 .ops = &rtl8192ce_hal_ops,
@@ -174,6 +268,8 @@ static struct rtl_hal_cfg rtl92ce_hal_cfg = {
174 .maps[EFUSE_LOADER_CLK_EN] = LOADER_CLK_EN, 268 .maps[EFUSE_LOADER_CLK_EN] = LOADER_CLK_EN,
175 .maps[EFUSE_ANA8M] = EFUSE_ANA8M, 269 .maps[EFUSE_ANA8M] = EFUSE_ANA8M,
176 .maps[EFUSE_HWSET_MAX_SIZE] = HWSET_MAX_SIZE, 270 .maps[EFUSE_HWSET_MAX_SIZE] = HWSET_MAX_SIZE,
271 .maps[EFUSE_MAX_SECTION_MAP] = EFUSE_MAX_SECTION,
272 .maps[EFUSE_REAL_CONTENT_SIZE] = EFUSE_REAL_CONTENT_LEN,
177 273
178 .maps[RWCAM] = REG_CAMCMD, 274 .maps[RWCAM] = REG_CAMCMD,
179 .maps[WCAMI] = REG_CAMWRITE, 275 .maps[WCAMI] = REG_CAMWRITE,
@@ -238,7 +334,7 @@ static struct rtl_hal_cfg rtl92ce_hal_cfg = {
238 .maps[RTL_RC_HT_RATEMCS15] = DESC92C_RATEMCS15, 334 .maps[RTL_RC_HT_RATEMCS15] = DESC92C_RATEMCS15,
239}; 335};
240 336
241static struct pci_device_id rtl92ce_pci_ids[] __devinitdata = { 337DEFINE_PCI_DEVICE_TABLE(rtl92ce_pci_ids) = {
242 {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8191, rtl92ce_hal_cfg)}, 338 {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8191, rtl92ce_hal_cfg)},
243 {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8178, rtl92ce_hal_cfg)}, 339 {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8178, rtl92ce_hal_cfg)},
244 {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8177, rtl92ce_hal_cfg)}, 340 {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8177, rtl92ce_hal_cfg)},
@@ -256,7 +352,13 @@ MODULE_DESCRIPTION("Realtek 8192C/8188C 802.11n PCI wireless");
256MODULE_FIRMWARE("rtlwifi/rtl8192cfw.bin"); 352MODULE_FIRMWARE("rtlwifi/rtl8192cfw.bin");
257 353
258module_param_named(swenc, rtl92ce_mod_params.sw_crypto, bool, 0444); 354module_param_named(swenc, rtl92ce_mod_params.sw_crypto, bool, 0444);
355module_param_named(ips, rtl92ce_mod_params.inactiveps, bool, 0444);
356module_param_named(swlps, rtl92ce_mod_params.swctrl_lps, bool, 0444);
357module_param_named(fwlps, rtl92ce_mod_params.fwctrl_lps, bool, 0444);
259MODULE_PARM_DESC(swenc, "using hardware crypto (default 0 [hardware])\n"); 358MODULE_PARM_DESC(swenc, "using hardware crypto (default 0 [hardware])\n");
359MODULE_PARM_DESC(ips, "using no link power save (default 1 is open)\n");
360MODULE_PARM_DESC(fwlps, "using linked fw control power save "
361 "(default 1 is open)\n");
260 362
261static struct pci_driver rtl92ce_driver = { 363static struct pci_driver rtl92ce_driver = {
262 .name = KBUILD_MODNAME, 364 .name = KBUILD_MODNAME,