162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci/* Copyright(c) 2009-2014  Realtek Corporation.*/
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci#include "../wifi.h"
562306a36Sopenharmony_ci#include "../core.h"
662306a36Sopenharmony_ci#include "../pci.h"
762306a36Sopenharmony_ci#include "reg.h"
862306a36Sopenharmony_ci#include "def.h"
962306a36Sopenharmony_ci#include "phy.h"
1062306a36Sopenharmony_ci#include "../rtl8723com/phy_common.h"
1162306a36Sopenharmony_ci#include "dm.h"
1262306a36Sopenharmony_ci#include "../rtl8723com/dm_common.h"
1362306a36Sopenharmony_ci#include "hw.h"
1462306a36Sopenharmony_ci#include "fw.h"
1562306a36Sopenharmony_ci#include "../rtl8723com/fw_common.h"
1662306a36Sopenharmony_ci#include "trx.h"
1762306a36Sopenharmony_ci#include "led.h"
1862306a36Sopenharmony_ci#include "table.h"
1962306a36Sopenharmony_ci#include "../btcoexist/rtl_btc.h"
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci#include <linux/vmalloc.h>
2262306a36Sopenharmony_ci#include <linux/module.h>
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_cistatic void rtl8723be_init_aspm_vars(struct ieee80211_hw *hw)
2562306a36Sopenharmony_ci{
2662306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = rtl_priv(hw);
2762306a36Sopenharmony_ci	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci	/*close ASPM for AMD defaultly */
3062306a36Sopenharmony_ci	rtlpci->const_amdpci_aspm = 0;
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci	/* ASPM PS mode.
3362306a36Sopenharmony_ci	 * 0 - Disable ASPM,
3462306a36Sopenharmony_ci	 * 1 - Enable ASPM without Clock Req,
3562306a36Sopenharmony_ci	 * 2 - Enable ASPM with Clock Req,
3662306a36Sopenharmony_ci	 * 3 - Alwyas Enable ASPM with Clock Req,
3762306a36Sopenharmony_ci	 * 4 - Always Enable ASPM without Clock Req.
3862306a36Sopenharmony_ci	 * set defult to RTL8192CE:3 RTL8192E:2
3962306a36Sopenharmony_ci	 */
4062306a36Sopenharmony_ci	rtlpci->const_pci_aspm = 3;
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci	/*Setting for PCI-E device */
4362306a36Sopenharmony_ci	rtlpci->const_devicepci_aspm_setting = 0x03;
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci	/*Setting for PCI-E bridge */
4662306a36Sopenharmony_ci	rtlpci->const_hostpci_aspm_setting = 0x02;
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci	/* In Hw/Sw Radio Off situation.
4962306a36Sopenharmony_ci	 * 0 - Default,
5062306a36Sopenharmony_ci	 * 1 - From ASPM setting without low Mac Pwr,
5162306a36Sopenharmony_ci	 * 2 - From ASPM setting with low Mac Pwr,
5262306a36Sopenharmony_ci	 * 3 - Bus D3
5362306a36Sopenharmony_ci	 * set default to RTL8192CE:0 RTL8192SE:2
5462306a36Sopenharmony_ci	 */
5562306a36Sopenharmony_ci	rtlpci->const_hwsw_rfoff_d3 = 0;
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci	/* This setting works for those device with
5862306a36Sopenharmony_ci	 * backdoor ASPM setting such as EPHY setting.
5962306a36Sopenharmony_ci	 * 0 - Not support ASPM,
6062306a36Sopenharmony_ci	 * 1 - Support ASPM,
6162306a36Sopenharmony_ci	 * 2 - According to chipset.
6262306a36Sopenharmony_ci	 */
6362306a36Sopenharmony_ci	rtlpci->const_support_pciaspm = rtlpriv->cfg->mod_params->aspm_support;
6462306a36Sopenharmony_ci}
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_cistatic int rtl8723be_init_sw_vars(struct ieee80211_hw *hw)
6762306a36Sopenharmony_ci{
6862306a36Sopenharmony_ci	int err = 0;
6962306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = rtl_priv(hw);
7062306a36Sopenharmony_ci	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
7162306a36Sopenharmony_ci	struct rtl_mac *mac = rtl_mac(rtl_priv(hw));
7262306a36Sopenharmony_ci	char *fw_name = "rtlwifi/rtl8723befw_36.bin";
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci	rtl8723be_bt_reg_init(hw);
7562306a36Sopenharmony_ci	rtlpriv->btcoexist.btc_ops = rtl_btc_get_ops_pointer();
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci	rtlpriv->dm.dm_initialgain_enable = true;
7862306a36Sopenharmony_ci	rtlpriv->dm.dm_flag = 0;
7962306a36Sopenharmony_ci	rtlpriv->dm.disable_framebursting = false;
8062306a36Sopenharmony_ci	rtlpriv->dm.thermalvalue = 0;
8162306a36Sopenharmony_ci	rtlpci->transmit_config = CFENDFORM | BIT(15) | BIT(24) | BIT(25);
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci	rtlpriv->phy.lck_inprogress = false;
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci	mac->ht_enable = true;
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci	/* compatible 5G band 88ce just 2.4G band & smsp */
8862306a36Sopenharmony_ci	rtlpriv->rtlhal.current_bandtype = BAND_ON_2_4G;
8962306a36Sopenharmony_ci	rtlpriv->rtlhal.bandset = BAND_ON_2_4G;
9062306a36Sopenharmony_ci	rtlpriv->rtlhal.macphymode = SINGLEMAC_SINGLEPHY;
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci	rtlpci->receive_config = (RCR_APPFCS		|
9362306a36Sopenharmony_ci				  RCR_APP_MIC		|
9462306a36Sopenharmony_ci				  RCR_APP_ICV		|
9562306a36Sopenharmony_ci				  RCR_APP_PHYST_RXFF	|
9662306a36Sopenharmony_ci				  RCR_HTC_LOC_CTRL	|
9762306a36Sopenharmony_ci				  RCR_AMF		|
9862306a36Sopenharmony_ci				  RCR_ACF		|
9962306a36Sopenharmony_ci				  RCR_ADF		|
10062306a36Sopenharmony_ci				  RCR_AICV		|
10162306a36Sopenharmony_ci				  RCR_AB		|
10262306a36Sopenharmony_ci				  RCR_AM		|
10362306a36Sopenharmony_ci				  RCR_APM		|
10462306a36Sopenharmony_ci				  0);
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci	rtlpci->irq_mask[0] = (u32) (IMR_PSTIMEOUT	|
10762306a36Sopenharmony_ci				     IMR_HSISR_IND_ON_INT	|
10862306a36Sopenharmony_ci				     IMR_C2HCMD		|
10962306a36Sopenharmony_ci				     IMR_HIGHDOK	|
11062306a36Sopenharmony_ci				     IMR_MGNTDOK	|
11162306a36Sopenharmony_ci				     IMR_BKDOK		|
11262306a36Sopenharmony_ci				     IMR_BEDOK		|
11362306a36Sopenharmony_ci				     IMR_VIDOK		|
11462306a36Sopenharmony_ci				     IMR_VODOK		|
11562306a36Sopenharmony_ci				     IMR_RDU		|
11662306a36Sopenharmony_ci				     IMR_ROK		|
11762306a36Sopenharmony_ci				     0);
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci	rtlpci->irq_mask[1] = (u32)(IMR_RXFOVW | 0);
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci	rtlpci->sys_irq_mask = (u32)(HSIMR_PDN_INT_EN	|
12262306a36Sopenharmony_ci				     HSIMR_RON_INT_EN	|
12362306a36Sopenharmony_ci				     0);
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci	/* for LPS & IPS */
12662306a36Sopenharmony_ci	rtlpriv->psc.inactiveps = rtlpriv->cfg->mod_params->inactiveps;
12762306a36Sopenharmony_ci	rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps;
12862306a36Sopenharmony_ci	rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps;
12962306a36Sopenharmony_ci	rtlpci->msi_support = rtlpriv->cfg->mod_params->msi_support;
13062306a36Sopenharmony_ci	if (rtlpriv->cfg->mod_params->disable_watchdog)
13162306a36Sopenharmony_ci		pr_info("watchdog disabled\n");
13262306a36Sopenharmony_ci	rtlpriv->psc.reg_fwctrl_lps = 2;
13362306a36Sopenharmony_ci	rtlpriv->psc.reg_max_lps_awakeintvl = 2;
13462306a36Sopenharmony_ci	/* for ASPM, you can close aspm through
13562306a36Sopenharmony_ci	 * set const_support_pciaspm = 0
13662306a36Sopenharmony_ci	 */
13762306a36Sopenharmony_ci	rtl8723be_init_aspm_vars(hw);
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci	if (rtlpriv->psc.reg_fwctrl_lps == 1)
14062306a36Sopenharmony_ci		rtlpriv->psc.fwctrl_psmode = FW_PS_MIN_MODE;
14162306a36Sopenharmony_ci	else if (rtlpriv->psc.reg_fwctrl_lps == 2)
14262306a36Sopenharmony_ci		rtlpriv->psc.fwctrl_psmode = FW_PS_MAX_MODE;
14362306a36Sopenharmony_ci	else if (rtlpriv->psc.reg_fwctrl_lps == 3)
14462306a36Sopenharmony_ci		rtlpriv->psc.fwctrl_psmode = FW_PS_DTIM_MODE;
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci	/*low power: Disable 32k */
14762306a36Sopenharmony_ci	rtlpriv->psc.low_power_enable = false;
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci	rtlpriv->rtlhal.earlymode_enable = false;
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci	/* for firmware buf */
15262306a36Sopenharmony_ci	rtlpriv->rtlhal.pfirmware = vzalloc(0x8000);
15362306a36Sopenharmony_ci	if (!rtlpriv->rtlhal.pfirmware) {
15462306a36Sopenharmony_ci		pr_err("Can't alloc buffer for fw.\n");
15562306a36Sopenharmony_ci		return 1;
15662306a36Sopenharmony_ci	}
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci	rtlpriv->max_fw_size = 0x8000;
15962306a36Sopenharmony_ci	pr_info("Using firmware %s\n", fw_name);
16062306a36Sopenharmony_ci	err = request_firmware_nowait(THIS_MODULE, 1, fw_name,
16162306a36Sopenharmony_ci				      rtlpriv->io.dev, GFP_KERNEL, hw,
16262306a36Sopenharmony_ci				      rtl_fw_cb);
16362306a36Sopenharmony_ci	if (err) {
16462306a36Sopenharmony_ci		pr_err("Failed to request firmware!\n");
16562306a36Sopenharmony_ci		vfree(rtlpriv->rtlhal.pfirmware);
16662306a36Sopenharmony_ci		rtlpriv->rtlhal.pfirmware = NULL;
16762306a36Sopenharmony_ci		return 1;
16862306a36Sopenharmony_ci	}
16962306a36Sopenharmony_ci	return 0;
17062306a36Sopenharmony_ci}
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_cistatic void rtl8723be_deinit_sw_vars(struct ieee80211_hw *hw)
17362306a36Sopenharmony_ci{
17462306a36Sopenharmony_ci	struct rtl_priv *rtlpriv = rtl_priv(hw);
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_ci	if (rtlpriv->rtlhal.pfirmware) {
17762306a36Sopenharmony_ci		vfree(rtlpriv->rtlhal.pfirmware);
17862306a36Sopenharmony_ci		rtlpriv->rtlhal.pfirmware = NULL;
17962306a36Sopenharmony_ci	}
18062306a36Sopenharmony_ci}
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ci/* get bt coexist status */
18362306a36Sopenharmony_cistatic bool rtl8723be_get_btc_status(void)
18462306a36Sopenharmony_ci{
18562306a36Sopenharmony_ci	return true;
18662306a36Sopenharmony_ci}
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_cistatic bool is_fw_header(struct rtlwifi_firmware_header *hdr)
18962306a36Sopenharmony_ci{
19062306a36Sopenharmony_ci	return (le16_to_cpu(hdr->signature) & 0xfff0) == 0x5300;
19162306a36Sopenharmony_ci}
19262306a36Sopenharmony_ci
19362306a36Sopenharmony_cistatic struct rtl_hal_ops rtl8723be_hal_ops = {
19462306a36Sopenharmony_ci	.init_sw_vars = rtl8723be_init_sw_vars,
19562306a36Sopenharmony_ci	.deinit_sw_vars = rtl8723be_deinit_sw_vars,
19662306a36Sopenharmony_ci	.read_eeprom_info = rtl8723be_read_eeprom_info,
19762306a36Sopenharmony_ci	.interrupt_recognized = rtl8723be_interrupt_recognized,
19862306a36Sopenharmony_ci	.hw_init = rtl8723be_hw_init,
19962306a36Sopenharmony_ci	.hw_disable = rtl8723be_card_disable,
20062306a36Sopenharmony_ci	.hw_suspend = rtl8723be_suspend,
20162306a36Sopenharmony_ci	.hw_resume = rtl8723be_resume,
20262306a36Sopenharmony_ci	.enable_interrupt = rtl8723be_enable_interrupt,
20362306a36Sopenharmony_ci	.disable_interrupt = rtl8723be_disable_interrupt,
20462306a36Sopenharmony_ci	.set_network_type = rtl8723be_set_network_type,
20562306a36Sopenharmony_ci	.set_chk_bssid = rtl8723be_set_check_bssid,
20662306a36Sopenharmony_ci	.set_qos = rtl8723be_set_qos,
20762306a36Sopenharmony_ci	.set_bcn_reg = rtl8723be_set_beacon_related_registers,
20862306a36Sopenharmony_ci	.set_bcn_intv = rtl8723be_set_beacon_interval,
20962306a36Sopenharmony_ci	.update_interrupt_mask = rtl8723be_update_interrupt_mask,
21062306a36Sopenharmony_ci	.get_hw_reg = rtl8723be_get_hw_reg,
21162306a36Sopenharmony_ci	.set_hw_reg = rtl8723be_set_hw_reg,
21262306a36Sopenharmony_ci	.update_rate_tbl = rtl8723be_update_hal_rate_tbl,
21362306a36Sopenharmony_ci	.fill_tx_desc = rtl8723be_tx_fill_desc,
21462306a36Sopenharmony_ci	.fill_tx_cmddesc = rtl8723be_tx_fill_cmddesc,
21562306a36Sopenharmony_ci	.query_rx_desc = rtl8723be_rx_query_desc,
21662306a36Sopenharmony_ci	.set_channel_access = rtl8723be_update_channel_access_setting,
21762306a36Sopenharmony_ci	.radio_onoff_checking = rtl8723be_gpio_radio_on_off_checking,
21862306a36Sopenharmony_ci	.set_bw_mode = rtl8723be_phy_set_bw_mode,
21962306a36Sopenharmony_ci	.switch_channel = rtl8723be_phy_sw_chnl,
22062306a36Sopenharmony_ci	.dm_watchdog = rtl8723be_dm_watchdog,
22162306a36Sopenharmony_ci	.scan_operation_backup = rtl8723be_phy_scan_operation_backup,
22262306a36Sopenharmony_ci	.set_rf_power_state = rtl8723be_phy_set_rf_power_state,
22362306a36Sopenharmony_ci	.led_control = rtl8723be_led_control,
22462306a36Sopenharmony_ci	.set_desc = rtl8723be_set_desc,
22562306a36Sopenharmony_ci	.get_desc = rtl8723be_get_desc,
22662306a36Sopenharmony_ci	.is_tx_desc_closed = rtl8723be_is_tx_desc_closed,
22762306a36Sopenharmony_ci	.tx_polling = rtl8723be_tx_polling,
22862306a36Sopenharmony_ci	.enable_hw_sec = rtl8723be_enable_hw_security_config,
22962306a36Sopenharmony_ci	.set_key = rtl8723be_set_key,
23062306a36Sopenharmony_ci	.get_bbreg = rtl8723_phy_query_bb_reg,
23162306a36Sopenharmony_ci	.set_bbreg = rtl8723_phy_set_bb_reg,
23262306a36Sopenharmony_ci	.get_rfreg = rtl8723be_phy_query_rf_reg,
23362306a36Sopenharmony_ci	.set_rfreg = rtl8723be_phy_set_rf_reg,
23462306a36Sopenharmony_ci	.fill_h2c_cmd = rtl8723be_fill_h2c_cmd,
23562306a36Sopenharmony_ci	.get_btc_status = rtl8723be_get_btc_status,
23662306a36Sopenharmony_ci	.is_fw_header = is_fw_header,
23762306a36Sopenharmony_ci};
23862306a36Sopenharmony_ci
23962306a36Sopenharmony_cistatic struct rtl_mod_params rtl8723be_mod_params = {
24062306a36Sopenharmony_ci	.sw_crypto = false,
24162306a36Sopenharmony_ci	.inactiveps = true,
24262306a36Sopenharmony_ci	.swctrl_lps = false,
24362306a36Sopenharmony_ci	.fwctrl_lps = true,
24462306a36Sopenharmony_ci	.msi_support = false,
24562306a36Sopenharmony_ci	.aspm_support = 1,
24662306a36Sopenharmony_ci	.disable_watchdog = false,
24762306a36Sopenharmony_ci	.debug_level = 0,
24862306a36Sopenharmony_ci	.debug_mask = 0,
24962306a36Sopenharmony_ci	.ant_sel = 0,
25062306a36Sopenharmony_ci};
25162306a36Sopenharmony_ci
25262306a36Sopenharmony_cistatic const struct rtl_hal_cfg rtl8723be_hal_cfg = {
25362306a36Sopenharmony_ci	.bar_id = 2,
25462306a36Sopenharmony_ci	.write_readback = true,
25562306a36Sopenharmony_ci	.name = "rtl8723be_pci",
25662306a36Sopenharmony_ci	.alt_fw_name = "rtlwifi/rtl8723befw.bin",
25762306a36Sopenharmony_ci	.ops = &rtl8723be_hal_ops,
25862306a36Sopenharmony_ci	.mod_params = &rtl8723be_mod_params,
25962306a36Sopenharmony_ci	.maps[SYS_ISO_CTRL] = REG_SYS_ISO_CTRL,
26062306a36Sopenharmony_ci	.maps[SYS_FUNC_EN] = REG_SYS_FUNC_EN,
26162306a36Sopenharmony_ci	.maps[SYS_CLK] = REG_SYS_CLKR,
26262306a36Sopenharmony_ci	.maps[MAC_RCR_AM] = AM,
26362306a36Sopenharmony_ci	.maps[MAC_RCR_AB] = AB,
26462306a36Sopenharmony_ci	.maps[MAC_RCR_ACRC32] = ACRC32,
26562306a36Sopenharmony_ci	.maps[MAC_RCR_ACF] = ACF,
26662306a36Sopenharmony_ci	.maps[MAC_RCR_AAP] = AAP,
26762306a36Sopenharmony_ci	.maps[MAC_HIMR] = REG_HIMR,
26862306a36Sopenharmony_ci	.maps[MAC_HIMRE] = REG_HIMRE,
26962306a36Sopenharmony_ci	.maps[MAC_HSISR] = REG_HSISR,
27062306a36Sopenharmony_ci
27162306a36Sopenharmony_ci	.maps[EFUSE_ACCESS] = REG_EFUSE_ACCESS,
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_ci	.maps[EFUSE_TEST] = REG_EFUSE_TEST,
27462306a36Sopenharmony_ci	.maps[EFUSE_CTRL] = REG_EFUSE_CTRL,
27562306a36Sopenharmony_ci	.maps[EFUSE_CLK] = 0,
27662306a36Sopenharmony_ci	.maps[EFUSE_CLK_CTRL] = REG_EFUSE_CTRL,
27762306a36Sopenharmony_ci	.maps[EFUSE_PWC_EV12V] = PWC_EV12V,
27862306a36Sopenharmony_ci	.maps[EFUSE_FEN_ELDR] = FEN_ELDR,
27962306a36Sopenharmony_ci	.maps[EFUSE_LOADER_CLK_EN] = LOADER_CLK_EN,
28062306a36Sopenharmony_ci	.maps[EFUSE_ANA8M] = ANA8M,
28162306a36Sopenharmony_ci	.maps[EFUSE_HWSET_MAX_SIZE] = HWSET_MAX_SIZE,
28262306a36Sopenharmony_ci	.maps[EFUSE_MAX_SECTION_MAP] = EFUSE_MAX_SECTION,
28362306a36Sopenharmony_ci	.maps[EFUSE_REAL_CONTENT_SIZE] = EFUSE_REAL_CONTENT_LEN,
28462306a36Sopenharmony_ci	.maps[EFUSE_OOB_PROTECT_BYTES_LEN] = EFUSE_OOB_PROTECT_BYTES,
28562306a36Sopenharmony_ci
28662306a36Sopenharmony_ci	.maps[RWCAM] = REG_CAMCMD,
28762306a36Sopenharmony_ci	.maps[WCAMI] = REG_CAMWRITE,
28862306a36Sopenharmony_ci	.maps[RCAMO] = REG_CAMREAD,
28962306a36Sopenharmony_ci	.maps[CAMDBG] = REG_CAMDBG,
29062306a36Sopenharmony_ci	.maps[SECR] = REG_SECCFG,
29162306a36Sopenharmony_ci	.maps[SEC_CAM_NONE] = CAM_NONE,
29262306a36Sopenharmony_ci	.maps[SEC_CAM_WEP40] = CAM_WEP40,
29362306a36Sopenharmony_ci	.maps[SEC_CAM_TKIP] = CAM_TKIP,
29462306a36Sopenharmony_ci	.maps[SEC_CAM_AES] = CAM_AES,
29562306a36Sopenharmony_ci	.maps[SEC_CAM_WEP104] = CAM_WEP104,
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_ci	.maps[RTL_IMR_BCNDMAINT6] = IMR_BCNDMAINT6,
29862306a36Sopenharmony_ci	.maps[RTL_IMR_BCNDMAINT5] = IMR_BCNDMAINT5,
29962306a36Sopenharmony_ci	.maps[RTL_IMR_BCNDMAINT4] = IMR_BCNDMAINT4,
30062306a36Sopenharmony_ci	.maps[RTL_IMR_BCNDMAINT3] = IMR_BCNDMAINT3,
30162306a36Sopenharmony_ci	.maps[RTL_IMR_BCNDMAINT2] = IMR_BCNDMAINT2,
30262306a36Sopenharmony_ci	.maps[RTL_IMR_BCNDMAINT1] = IMR_BCNDMAINT1,
30362306a36Sopenharmony_ci/*	.maps[RTL_IMR_BCNDOK8] = IMR_BCNDOK8,     */   /*need check*/
30462306a36Sopenharmony_ci	.maps[RTL_IMR_BCNDOK7] = IMR_BCNDOK7,
30562306a36Sopenharmony_ci	.maps[RTL_IMR_BCNDOK6] = IMR_BCNDOK6,
30662306a36Sopenharmony_ci	.maps[RTL_IMR_BCNDOK5] = IMR_BCNDOK5,
30762306a36Sopenharmony_ci	.maps[RTL_IMR_BCNDOK4] = IMR_BCNDOK4,
30862306a36Sopenharmony_ci	.maps[RTL_IMR_BCNDOK3] = IMR_BCNDOK3,
30962306a36Sopenharmony_ci	.maps[RTL_IMR_BCNDOK2] = IMR_BCNDOK2,
31062306a36Sopenharmony_ci	.maps[RTL_IMR_BCNDOK1] = IMR_BCNDOK1,
31162306a36Sopenharmony_ci/*	.maps[RTL_IMR_TIMEOUT2] = IMR_TIMEOUT2,*/
31262306a36Sopenharmony_ci/*	.maps[RTL_IMR_TIMEOUT1] = IMR_TIMEOUT1,*/
31362306a36Sopenharmony_ci
31462306a36Sopenharmony_ci	.maps[RTL_IMR_TXFOVW] = IMR_TXFOVW,
31562306a36Sopenharmony_ci	.maps[RTL_IMR_PSTIMEOUT] = IMR_PSTIMEOUT,
31662306a36Sopenharmony_ci	.maps[RTL_IMR_BCNINT] = IMR_BCNDMAINT0,
31762306a36Sopenharmony_ci	.maps[RTL_IMR_RXFOVW] = IMR_RXFOVW,
31862306a36Sopenharmony_ci	.maps[RTL_IMR_RDU] = IMR_RDU,
31962306a36Sopenharmony_ci	.maps[RTL_IMR_ATIMEND] = IMR_ATIMEND,
32062306a36Sopenharmony_ci	.maps[RTL_IMR_BDOK] = IMR_BCNDOK0,
32162306a36Sopenharmony_ci	.maps[RTL_IMR_MGNTDOK] = IMR_MGNTDOK,
32262306a36Sopenharmony_ci	.maps[RTL_IMR_TBDER] = IMR_TBDER,
32362306a36Sopenharmony_ci	.maps[RTL_IMR_HIGHDOK] = IMR_HIGHDOK,
32462306a36Sopenharmony_ci	.maps[RTL_IMR_TBDOK] = IMR_TBDOK,
32562306a36Sopenharmony_ci	.maps[RTL_IMR_BKDOK] = IMR_BKDOK,
32662306a36Sopenharmony_ci	.maps[RTL_IMR_BEDOK] = IMR_BEDOK,
32762306a36Sopenharmony_ci	.maps[RTL_IMR_VIDOK] = IMR_VIDOK,
32862306a36Sopenharmony_ci	.maps[RTL_IMR_VODOK] = IMR_VODOK,
32962306a36Sopenharmony_ci	.maps[RTL_IMR_ROK] = IMR_ROK,
33062306a36Sopenharmony_ci	.maps[RTL_IMR_HSISR_IND] = IMR_HSISR_IND_ON_INT,
33162306a36Sopenharmony_ci	.maps[RTL_IBSS_INT_MASKS] = (IMR_BCNDMAINT0 | IMR_TBDOK | IMR_TBDER),
33262306a36Sopenharmony_ci
33362306a36Sopenharmony_ci	.maps[RTL_RC_CCK_RATE1M] = DESC92C_RATE1M,
33462306a36Sopenharmony_ci	.maps[RTL_RC_CCK_RATE2M] = DESC92C_RATE2M,
33562306a36Sopenharmony_ci	.maps[RTL_RC_CCK_RATE5_5M] = DESC92C_RATE5_5M,
33662306a36Sopenharmony_ci	.maps[RTL_RC_CCK_RATE11M] = DESC92C_RATE11M,
33762306a36Sopenharmony_ci	.maps[RTL_RC_OFDM_RATE6M] = DESC92C_RATE6M,
33862306a36Sopenharmony_ci	.maps[RTL_RC_OFDM_RATE9M] = DESC92C_RATE9M,
33962306a36Sopenharmony_ci	.maps[RTL_RC_OFDM_RATE12M] = DESC92C_RATE12M,
34062306a36Sopenharmony_ci	.maps[RTL_RC_OFDM_RATE18M] = DESC92C_RATE18M,
34162306a36Sopenharmony_ci	.maps[RTL_RC_OFDM_RATE24M] = DESC92C_RATE24M,
34262306a36Sopenharmony_ci	.maps[RTL_RC_OFDM_RATE36M] = DESC92C_RATE36M,
34362306a36Sopenharmony_ci	.maps[RTL_RC_OFDM_RATE48M] = DESC92C_RATE48M,
34462306a36Sopenharmony_ci	.maps[RTL_RC_OFDM_RATE54M] = DESC92C_RATE54M,
34562306a36Sopenharmony_ci
34662306a36Sopenharmony_ci	.maps[RTL_RC_HT_RATEMCS7] = DESC92C_RATEMCS7,
34762306a36Sopenharmony_ci	.maps[RTL_RC_HT_RATEMCS15] = DESC92C_RATEMCS15,
34862306a36Sopenharmony_ci};
34962306a36Sopenharmony_ci
35062306a36Sopenharmony_cistatic const struct pci_device_id rtl8723be_pci_ids[] = {
35162306a36Sopenharmony_ci	{RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0xB723, rtl8723be_hal_cfg)},
35262306a36Sopenharmony_ci	{},
35362306a36Sopenharmony_ci};
35462306a36Sopenharmony_ci
35562306a36Sopenharmony_ciMODULE_DEVICE_TABLE(pci, rtl8723be_pci_ids);
35662306a36Sopenharmony_ci
35762306a36Sopenharmony_ciMODULE_AUTHOR("PageHe	<page_he@realsil.com.cn>");
35862306a36Sopenharmony_ciMODULE_AUTHOR("Realtek WlanFAE	<wlanfae@realtek.com>");
35962306a36Sopenharmony_ciMODULE_LICENSE("GPL");
36062306a36Sopenharmony_ciMODULE_DESCRIPTION("Realtek 8723BE 802.11n PCI wireless");
36162306a36Sopenharmony_ciMODULE_FIRMWARE("rtlwifi/rtl8723befw.bin");
36262306a36Sopenharmony_ciMODULE_FIRMWARE("rtlwifi/rtl8723befw_36.bin");
36362306a36Sopenharmony_ci
36462306a36Sopenharmony_cimodule_param_named(swenc, rtl8723be_mod_params.sw_crypto, bool, 0444);
36562306a36Sopenharmony_cimodule_param_named(debug_level, rtl8723be_mod_params.debug_level, int, 0644);
36662306a36Sopenharmony_cimodule_param_named(debug_mask, rtl8723be_mod_params.debug_mask, ullong, 0644);
36762306a36Sopenharmony_cimodule_param_named(ips, rtl8723be_mod_params.inactiveps, bool, 0444);
36862306a36Sopenharmony_cimodule_param_named(swlps, rtl8723be_mod_params.swctrl_lps, bool, 0444);
36962306a36Sopenharmony_cimodule_param_named(fwlps, rtl8723be_mod_params.fwctrl_lps, bool, 0444);
37062306a36Sopenharmony_cimodule_param_named(msi, rtl8723be_mod_params.msi_support, bool, 0444);
37162306a36Sopenharmony_cimodule_param_named(aspm, rtl8723be_mod_params.aspm_support, int, 0444);
37262306a36Sopenharmony_cimodule_param_named(disable_watchdog, rtl8723be_mod_params.disable_watchdog,
37362306a36Sopenharmony_ci		   bool, 0444);
37462306a36Sopenharmony_cimodule_param_named(ant_sel, rtl8723be_mod_params.ant_sel, int, 0444);
37562306a36Sopenharmony_ciMODULE_PARM_DESC(swenc, "Set to 1 for software crypto (default 0)\n");
37662306a36Sopenharmony_ciMODULE_PARM_DESC(ips, "Set to 0 to not use link power save (default 1)\n");
37762306a36Sopenharmony_ciMODULE_PARM_DESC(swlps, "Set to 1 to use SW control power save (default 0)\n");
37862306a36Sopenharmony_ciMODULE_PARM_DESC(fwlps, "Set to 1 to use FW control power save (default 1)\n");
37962306a36Sopenharmony_ciMODULE_PARM_DESC(msi, "Set to 1 to use MSI interrupts mode (default 0)\n");
38062306a36Sopenharmony_ciMODULE_PARM_DESC(aspm, "Set to 1 to enable ASPM (default 1)\n");
38162306a36Sopenharmony_ciMODULE_PARM_DESC(debug_level, "Set debug level (0-5) (default 0)");
38262306a36Sopenharmony_ciMODULE_PARM_DESC(debug_mask, "Set debug mask (default 0)");
38362306a36Sopenharmony_ciMODULE_PARM_DESC(disable_watchdog,
38462306a36Sopenharmony_ci		 "Set to 1 to disable the watchdog (default 0)\n");
38562306a36Sopenharmony_ciMODULE_PARM_DESC(ant_sel, "Set to 1 or 2 to force antenna number (default 0)\n");
38662306a36Sopenharmony_ci
38762306a36Sopenharmony_cistatic SIMPLE_DEV_PM_OPS(rtlwifi_pm_ops, rtl_pci_suspend, rtl_pci_resume);
38862306a36Sopenharmony_ci
38962306a36Sopenharmony_cistatic struct pci_driver rtl8723be_driver = {
39062306a36Sopenharmony_ci	.name = KBUILD_MODNAME,
39162306a36Sopenharmony_ci	.id_table = rtl8723be_pci_ids,
39262306a36Sopenharmony_ci	.probe = rtl_pci_probe,
39362306a36Sopenharmony_ci	.remove = rtl_pci_disconnect,
39462306a36Sopenharmony_ci	.driver.pm = &rtlwifi_pm_ops,
39562306a36Sopenharmony_ci};
39662306a36Sopenharmony_ci
39762306a36Sopenharmony_cimodule_pci_driver(rtl8723be_driver);
398