Exemple #1
0
/*InitializeVariables8812E*/
int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
{
	int err = 0;
	struct rtl_priv *rtlpriv = rtl_priv(hw);
	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
	const struct firmware *firmware;
	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
	char *fw_name = NULL;

	rtl8821ae_bt_reg_init(hw);
	rtlpriv->btcoexist.btc_ops = rtl_btc_get_ops_pointer();

	rtlpriv->dm.b_dm_initialgain_enable = 1;
	rtlpriv->dm.dm_flag = 0;
	rtlpriv->dm.b_disable_framebursting = 0;;
	rtlpriv->dm.thermalvalue = 0;
	rtlpci->transmit_config = CFENDFORM | BIT(15) | BIT(24) | BIT(25);

	mac->ht_enable = true;

	rtlpriv->rtlhal.current_bandtype = BAND_ON_2_4G;
	/*following 2 is for register 5G band, refer to _rtl_init_mac80211()*/
	rtlpriv->rtlhal.bandset = BAND_ON_BOTH;
	rtlpriv->rtlhal.macphymode = SINGLEMAC_SINGLEPHY;

	rtlpci->receive_config = (RCR_APPFCS			|
							  RCR_APP_MIC 			|
							  RCR_APP_ICV 			|
							  RCR_APP_PHYST_RXFF	|
							  RCR_NONQOS_VHT		|
							  RCR_HTC_LOC_CTRL		|
							  RCR_AMF 				|
							  RCR_ACF 				|
							  RCR_ADF 				|	/*This bit controls the PS-Poll packet filter.*/
							  RCR_AICV				|
							  RCR_ACRC32			|
							  RCR_AB				|
							  RCR_AM				|
							  RCR_APM 				|
							  0);


	rtlpci->irq_mask[0] =
	     (u32) (IMR_PSTIMEOUT			|
				IMR_GTINT3 				|
				/*IMR_TBDER				|
				IMR_TBDOK				|
				IMR_BCNDMAINT0 			|*/
				IMR_HSISR_IND_ON_INT	|
				IMR_C2HCMD 				|
				IMR_HIGHDOK				|
				IMR_MGNTDOK				|
				IMR_BKDOK				|
				IMR_BEDOK				|
				IMR_VIDOK				|
				IMR_VODOK				|
				IMR_RDU					|
				IMR_ROK					|
				0);

	rtlpci->irq_mask[1]	=
		 (u32)(	IMR_RXFOVW |
		 		IMR_TXFOVW |
				0);

	/* for LPS & IPS */
	rtlpriv->psc.b_inactiveps = rtlpriv->cfg->mod_params->b_inactiveps;
	rtlpriv->psc.b_swctrl_lps = rtlpriv->cfg->mod_params->b_swctrl_lps;
	rtlpriv->psc.b_fwctrl_lps = rtlpriv->cfg->mod_params->b_fwctrl_lps;
	rtlpriv->psc.b_reg_fwctrl_lps = 3;
	rtlpriv->psc.reg_max_lps_awakeintvl = 5;
	/* for ASPM, you can close aspm through
	 * set const_support_pciaspm = 0 */
	rtl8821ae_init_aspm_vars(hw);

	if (rtlpriv->psc.b_reg_fwctrl_lps == 1)
		rtlpriv->psc.fwctrl_psmode = FW_PS_MIN_MODE;
	else if (rtlpriv->psc.b_reg_fwctrl_lps == 2)
		rtlpriv->psc.fwctrl_psmode = FW_PS_MAX_MODE;
	else if (rtlpriv->psc.b_reg_fwctrl_lps == 3)
		rtlpriv->psc.fwctrl_psmode = FW_PS_DTIM_MODE;

	/* for firmware buf */
	rtlpriv->rtlhal.pfirmware = (u8 *) vmalloc(0x8000);
	if (!rtlpriv->rtlhal.pfirmware) {
		RT_TRACE(COMP_ERR, DBG_EMERG,
			 ("Can't alloc buffer for fw.\n"));
		return 1;
	}

	fw_name = "rtlwifi/rtl8821aefw.bin";
	err = request_firmware(&firmware, fw_name, rtlpriv->io.dev);
	if (err) {
		RT_TRACE(COMP_ERR, DBG_EMERG,
			 ("Failed to request firmware!\n"));
		return 1;
	}

	if (firmware->size > 0x8000) {
		RT_TRACE(COMP_ERR, DBG_EMERG,
			 ("Firmware is too big!\n"));
		release_firmware(firmware);
		return 1;
	}

	memcpy(rtlpriv->rtlhal.pfirmware, firmware->data, firmware->size);
	rtlpriv->rtlhal.fwsize = firmware->size;
	release_firmware(firmware);

	if (rtlpriv->cfg->ops->get_btc_status()){
		rtlpriv->btcoexist.btc_ops->btc_init_variables(rtlpriv);
		rtlpriv->btcoexist.btc_ops->btc_init_hal_vars(rtlpriv);
	}

	RT_TRACE(COMP_INIT, DBG_LOUD, (" FirmwareDownload OK\n"));
	return err;
}
Exemple #2
0
/*InitializeVariables8812E*/
int rtl8821ae_init_sw_vars(struct ieee80211_hw *hw)
{
	int err = 0;
	struct rtl_priv *rtlpriv = rtl_priv(hw);
	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));

	rtl8821ae_bt_reg_init(hw);
	rtlpriv->btcoexist.btc_ops = rtl_btc_get_ops_pointer();

	rtlpriv->dm.dm_initialgain_enable = 1;
	rtlpriv->dm.dm_flag = 0;
	rtlpriv->dm.disable_framebursting = 0;
	rtlpriv->dm.thermalvalue = 0;
	rtlpci->transmit_config = CFENDFORM | BIT(15) | BIT(24) | BIT(25);

	mac->ht_enable = true;
	mac->ht_cur_stbc = mac->ht_stbc_cap = 0;
	mac->vht_cur_ldpc = mac->vht_ldpc_cap = 0;
	mac->vht_cur_stbc = mac->vht_stbc_cap = 0;

	rtlpriv->rtlhal.current_bandtype = BAND_ON_2_4G;
	/*following 2 is for register 5G band, refer to _rtl_init_mac80211()*/
	rtlpriv->rtlhal.bandset = BAND_ON_BOTH;
	rtlpriv->rtlhal.macphymode = SINGLEMAC_SINGLEPHY;

	rtlpci->receive_config = (RCR_APPFCS	|
				RCR_APP_MIC		|
				RCR_APP_ICV		|
				RCR_APP_PHYST_RXFF	|
				RCR_NONQOS_VHT		|
				RCR_HTC_LOC_CTRL	|
				RCR_AMF			|
				RCR_ACF			|
			/*This bit controls the PS-Poll packet filter.*/
				RCR_ADF			|
				RCR_AICV		|
				RCR_ACRC32		|
				RCR_AB			|
				RCR_AM			|
				RCR_APM			|
				0);


	rtlpci->irq_mask[0] =
	     (u32) (IMR_PSTIMEOUT			|
				IMR_GTINT3		|
				/*IMR_TBDER				|
				IMR_TBDOK				|
				IMR_BCNDMAINT0			|*/
				IMR_HSISR_IND_ON_INT	|
				IMR_C2HCMD		|
				IMR_HIGHDOK		|
				IMR_MGNTDOK		|
				IMR_BKDOK		|
				IMR_BEDOK		|
				IMR_VIDOK		|
				IMR_VODOK		|
				IMR_RDU			|
				IMR_ROK			|
				0);

	rtlpci->irq_mask[1]	=
		 (u32)(IMR_RXFOVW |
				IMR_TXFOVW |
				0);
	rtlpci->sys_irq_mask = (u32) (HSIMR_PDN_INT_EN	|
				      HSIMR_RON_INT_EN	|
				      0);
	/* for WOWLAN */
	/* if kernel >= 3.11, revise this var,
	 * remember revise 'rtl_wowlan_support' at the same time */
	rtlpriv->psc.wo_wlan_mode = WAKE_ON_MAGIC_PACKET |
				    WAKE_ON_PATTERN_MATCH;

	/* for debug level */
	rtlpriv->dbg.global_debuglevel = rtlpriv->cfg->mod_params->debug;
	/* for LPS & IPS */
	rtlpriv->psc.inactiveps = rtlpriv->cfg->mod_params->inactiveps;
	rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps;
	rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps;
	rtlpci->msi_support = rtlpriv->cfg->mod_params->msi_support;
	rtlpci->int_clear = rtlpriv->cfg->mod_params->int_clear;
	rtlpriv->cfg->mod_params->sw_crypto =
		rtlpriv->cfg->mod_params->sw_crypto;
	rtlpriv->cfg->mod_params->disable_watchdog =
		rtlpriv->cfg->mod_params->disable_watchdog;
	if (rtlpriv->cfg->mod_params->disable_watchdog)
		pr_info("watchdog disabled\n");
	rtlpriv->psc.reg_fwctrl_lps = 3;
	rtlpriv->psc.reg_max_lps_awakeintvl = 5;

	/* for ASPM, you can close aspm through
	 * set const_support_pciaspm = 0 */
	rtl8821ae_init_aspm_vars(hw);

	if (rtlpriv->psc.reg_fwctrl_lps == 1)
		rtlpriv->psc.fwctrl_psmode = FW_PS_MIN_MODE;
	else if (rtlpriv->psc.reg_fwctrl_lps == 2)
		rtlpriv->psc.fwctrl_psmode = FW_PS_MAX_MODE;
	else if (rtlpriv->psc.reg_fwctrl_lps == 3)
		rtlpriv->psc.fwctrl_psmode = FW_PS_DTIM_MODE;

	rtlpriv->rtl_fw_second_cb = load_wowlan_fw;
	/* for firmware buf */
	rtlpriv->rtlhal.pfirmware = vzalloc(0x8000);
	if (!rtlpriv->rtlhal.pfirmware) {
		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
			 "Can't alloc buffer for fw.\n");
		return 1;
	}

	if (rtlhal->hw_type == HARDWARE_TYPE_RTL8812AE)
		rtlpriv->cfg->fw_name = "rtlwifi/rtl8812aefw.bin";
	else
		rtlpriv->cfg->fw_name = "rtlwifi/rtl8821aefw.bin";

	rtlpriv->max_fw_size = 0x8000;
	pr_info("Using firmware %s\n", rtlpriv->cfg->fw_name);
	err = request_firmware_nowait(THIS_MODULE, 1, rtlpriv->cfg->fw_name,
				      rtlpriv->io.dev, GFP_KERNEL, hw,
				      rtl_fw_cb);
	if (err) {
		RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
			 "Failed to request firmware!\n");
		return 1;
	}
	return 0;
}