1811853daSPing-Ke Shih // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause 2811853daSPing-Ke Shih /* Copyright(c) 2018-2019 Realtek Corporation 3811853daSPing-Ke Shih */ 4811853daSPing-Ke Shih 5811853daSPing-Ke Shih #include "main.h" 6811853daSPing-Ke Shih #include "coex.h" 7811853daSPing-Ke Shih #include "fw.h" 8811853daSPing-Ke Shih #include "tx.h" 9811853daSPing-Ke Shih #include "rx.h" 10811853daSPing-Ke Shih #include "phy.h" 11811853daSPing-Ke Shih #include "rtw8723d.h" 12811853daSPing-Ke Shih #include "rtw8723d_table.h" 13811853daSPing-Ke Shih #include "mac.h" 14811853daSPing-Ke Shih #include "reg.h" 15811853daSPing-Ke Shih #include "debug.h" 16811853daSPing-Ke Shih 17ba9f0d1bSPing-Ke Shih static const struct rtw_hw_reg rtw8723d_txagc[] = { 18ba9f0d1bSPing-Ke Shih [DESC_RATE1M] = { .addr = 0xe08, .mask = 0x0000ff00 }, 19ba9f0d1bSPing-Ke Shih [DESC_RATE2M] = { .addr = 0x86c, .mask = 0x0000ff00 }, 20ba9f0d1bSPing-Ke Shih [DESC_RATE5_5M] = { .addr = 0x86c, .mask = 0x00ff0000 }, 21ba9f0d1bSPing-Ke Shih [DESC_RATE11M] = { .addr = 0x86c, .mask = 0xff000000 }, 22ba9f0d1bSPing-Ke Shih [DESC_RATE6M] = { .addr = 0xe00, .mask = 0x000000ff }, 23ba9f0d1bSPing-Ke Shih [DESC_RATE9M] = { .addr = 0xe00, .mask = 0x0000ff00 }, 24ba9f0d1bSPing-Ke Shih [DESC_RATE12M] = { .addr = 0xe00, .mask = 0x00ff0000 }, 25ba9f0d1bSPing-Ke Shih [DESC_RATE18M] = { .addr = 0xe00, .mask = 0xff000000 }, 26ba9f0d1bSPing-Ke Shih [DESC_RATE24M] = { .addr = 0xe04, .mask = 0x000000ff }, 27ba9f0d1bSPing-Ke Shih [DESC_RATE36M] = { .addr = 0xe04, .mask = 0x0000ff00 }, 28ba9f0d1bSPing-Ke Shih [DESC_RATE48M] = { .addr = 0xe04, .mask = 0x00ff0000 }, 29ba9f0d1bSPing-Ke Shih [DESC_RATE54M] = { .addr = 0xe04, .mask = 0xff000000 }, 30ba9f0d1bSPing-Ke Shih [DESC_RATEMCS0] = { .addr = 0xe10, .mask = 0x000000ff }, 31ba9f0d1bSPing-Ke Shih [DESC_RATEMCS1] = { .addr = 0xe10, .mask = 0x0000ff00 }, 32ba9f0d1bSPing-Ke Shih [DESC_RATEMCS2] = { .addr = 0xe10, .mask = 0x00ff0000 }, 33ba9f0d1bSPing-Ke Shih [DESC_RATEMCS3] = { .addr = 0xe10, .mask = 0xff000000 }, 34ba9f0d1bSPing-Ke Shih [DESC_RATEMCS4] = { .addr = 0xe14, .mask = 0x000000ff }, 35ba9f0d1bSPing-Ke Shih [DESC_RATEMCS5] = { .addr = 0xe14, .mask = 0x0000ff00 }, 36ba9f0d1bSPing-Ke Shih [DESC_RATEMCS6] = { .addr = 0xe14, .mask = 0x00ff0000 }, 37ba9f0d1bSPing-Ke Shih [DESC_RATEMCS7] = { .addr = 0xe14, .mask = 0xff000000 }, 38ba9f0d1bSPing-Ke Shih }; 39ba9f0d1bSPing-Ke Shih 4075e69fb1SPing-Ke Shih #define WLAN_TXQ_RPT_EN 0x1F 4175e69fb1SPing-Ke Shih #define WLAN_SLOT_TIME 0x09 4275e69fb1SPing-Ke Shih #define WLAN_RL_VAL 0x3030 4375e69fb1SPing-Ke Shih #define WLAN_BAR_VAL 0x0201ffff 4475e69fb1SPing-Ke Shih #define BIT_MASK_TBTT_HOLD 0x00000fff 4575e69fb1SPing-Ke Shih #define BIT_SHIFT_TBTT_HOLD 8 4675e69fb1SPing-Ke Shih #define BIT_MASK_TBTT_SETUP 0x000000ff 4775e69fb1SPing-Ke Shih #define BIT_SHIFT_TBTT_SETUP 0 4875e69fb1SPing-Ke Shih #define BIT_MASK_TBTT_MASK ((BIT_MASK_TBTT_HOLD << BIT_SHIFT_TBTT_HOLD) | \ 4975e69fb1SPing-Ke Shih (BIT_MASK_TBTT_SETUP << BIT_SHIFT_TBTT_SETUP)) 5075e69fb1SPing-Ke Shih #define TBTT_TIME(s, h)((((s) & BIT_MASK_TBTT_SETUP) << BIT_SHIFT_TBTT_SETUP) |\ 5175e69fb1SPing-Ke Shih (((h) & BIT_MASK_TBTT_HOLD) << BIT_SHIFT_TBTT_HOLD)) 5275e69fb1SPing-Ke Shih #define WLAN_TBTT_TIME_NORMAL TBTT_TIME(0x04, 0x80) 5375e69fb1SPing-Ke Shih #define WLAN_TBTT_TIME_STOP_BCN TBTT_TIME(0x04, 0x64) 5475e69fb1SPing-Ke Shih #define WLAN_PIFS_VAL 0 5575e69fb1SPing-Ke Shih #define WLAN_AGG_BRK_TIME 0x16 5675e69fb1SPing-Ke Shih #define WLAN_NAV_PROT_LEN 0x0040 5775e69fb1SPing-Ke Shih #define WLAN_SPEC_SIFS 0x100a 5875e69fb1SPing-Ke Shih #define WLAN_RX_PKT_LIMIT 0x17 5975e69fb1SPing-Ke Shih #define WLAN_MAX_AGG_NR 0x0A 6075e69fb1SPing-Ke Shih #define WLAN_AMPDU_MAX_TIME 0x1C 6175e69fb1SPing-Ke Shih #define WLAN_ANT_SEL 0x82 6275e69fb1SPing-Ke Shih #define WLAN_LTR_IDLE_LAT 0x883C883C 6375e69fb1SPing-Ke Shih #define WLAN_LTR_ACT_LAT 0x880B880B 6475e69fb1SPing-Ke Shih #define WLAN_LTR_CTRL1 0xCB004010 6575e69fb1SPing-Ke Shih #define WLAN_LTR_CTRL2 0x01233425 6675e69fb1SPing-Ke Shih 6775e69fb1SPing-Ke Shih static void rtw8723d_phy_set_param(struct rtw_dev *rtwdev) 6875e69fb1SPing-Ke Shih { 6975e69fb1SPing-Ke Shih u8 xtal_cap; 7075e69fb1SPing-Ke Shih u32 val32; 7175e69fb1SPing-Ke Shih 7275e69fb1SPing-Ke Shih /* power on BB/RF domain */ 7375e69fb1SPing-Ke Shih rtw_write16_set(rtwdev, REG_SYS_FUNC_EN, 7475e69fb1SPing-Ke Shih BIT_FEN_EN_25_1 | BIT_FEN_BB_GLB_RST | BIT_FEN_BB_RSTB); 7575e69fb1SPing-Ke Shih rtw_write8_set(rtwdev, REG_RF_CTRL, 7675e69fb1SPing-Ke Shih BIT_RF_EN | BIT_RF_RSTB | BIT_RF_SDM_RSTB); 7775e69fb1SPing-Ke Shih rtw_write8(rtwdev, REG_AFE_CTRL1 + 1, 0x80); 7875e69fb1SPing-Ke Shih 7975e69fb1SPing-Ke Shih rtw_phy_load_tables(rtwdev); 8075e69fb1SPing-Ke Shih 8175e69fb1SPing-Ke Shih /* post init after header files config */ 8275e69fb1SPing-Ke Shih rtw_write32_clr(rtwdev, REG_RCR, BIT_RCR_ADF); 8375e69fb1SPing-Ke Shih rtw_write8_set(rtwdev, REG_HIQ_NO_LMT_EN, BIT_HIQ_NO_LMT_EN_ROOT); 8475e69fb1SPing-Ke Shih rtw_write16_set(rtwdev, REG_AFE_CTRL_4, BIT_CK320M_AFE_EN | BIT_EN_SYN); 8575e69fb1SPing-Ke Shih 8675e69fb1SPing-Ke Shih xtal_cap = rtwdev->efuse.crystal_cap & 0x3F; 8775e69fb1SPing-Ke Shih rtw_write32_mask(rtwdev, REG_AFE_CTRL3, BIT_MASK_XTAL, 8875e69fb1SPing-Ke Shih xtal_cap | (xtal_cap << 6)); 8975e69fb1SPing-Ke Shih rtw_write32_set(rtwdev, REG_FPGA0_RFMOD, BIT_CCKEN | BIT_OFDMEN); 9075e69fb1SPing-Ke Shih if ((rtwdev->efuse.afe >> 4) == 14) { 9175e69fb1SPing-Ke Shih rtw_write32_set(rtwdev, REG_AFE_CTRL3, BIT_XTAL_GMP_BIT4); 9275e69fb1SPing-Ke Shih rtw_write32_clr(rtwdev, REG_AFE_CTRL1, BITS_PLL); 9375e69fb1SPing-Ke Shih rtw_write32_set(rtwdev, REG_LDO_SWR_CTRL, BIT_XTA1); 9475e69fb1SPing-Ke Shih rtw_write32_clr(rtwdev, REG_LDO_SWR_CTRL, BIT_XTA0); 9575e69fb1SPing-Ke Shih } 9675e69fb1SPing-Ke Shih 9775e69fb1SPing-Ke Shih rtw_write8(rtwdev, REG_SLOT, WLAN_SLOT_TIME); 9875e69fb1SPing-Ke Shih rtw_write8(rtwdev, REG_FWHW_TXQ_CTRL + 1, WLAN_TXQ_RPT_EN); 9975e69fb1SPing-Ke Shih rtw_write16(rtwdev, REG_RETRY_LIMIT, WLAN_RL_VAL); 10075e69fb1SPing-Ke Shih rtw_write32(rtwdev, REG_BAR_MODE_CTRL, WLAN_BAR_VAL); 10175e69fb1SPing-Ke Shih rtw_write8(rtwdev, REG_ATIMWND, 0x2); 10275e69fb1SPing-Ke Shih rtw_write8(rtwdev, REG_BCN_CTRL, 10375e69fb1SPing-Ke Shih BIT_DIS_TSF_UDT | BIT_EN_BCN_FUNCTION | BIT_EN_TXBCN_RPT); 10475e69fb1SPing-Ke Shih val32 = rtw_read32(rtwdev, REG_TBTT_PROHIBIT); 10575e69fb1SPing-Ke Shih val32 &= ~BIT_MASK_TBTT_MASK; 10675e69fb1SPing-Ke Shih val32 |= WLAN_TBTT_TIME_STOP_BCN; 10775e69fb1SPing-Ke Shih rtw_write8(rtwdev, REG_TBTT_PROHIBIT, val32); 10875e69fb1SPing-Ke Shih rtw_write8(rtwdev, REG_PIFS, WLAN_PIFS_VAL); 10975e69fb1SPing-Ke Shih rtw_write8(rtwdev, REG_AGGR_BREAK_TIME, WLAN_AGG_BRK_TIME); 11075e69fb1SPing-Ke Shih rtw_write16(rtwdev, REG_NAV_PROT_LEN, WLAN_NAV_PROT_LEN); 11175e69fb1SPing-Ke Shih rtw_write16(rtwdev, REG_MAC_SPEC_SIFS, WLAN_SPEC_SIFS); 11275e69fb1SPing-Ke Shih rtw_write16(rtwdev, REG_SIFS, WLAN_SPEC_SIFS); 11375e69fb1SPing-Ke Shih rtw_write16(rtwdev, REG_SIFS + 2, WLAN_SPEC_SIFS); 11475e69fb1SPing-Ke Shih rtw_write8(rtwdev, REG_SINGLE_AMPDU_CTRL, BIT_EN_SINGLE_APMDU); 11575e69fb1SPing-Ke Shih rtw_write8(rtwdev, REG_RX_PKT_LIMIT, WLAN_RX_PKT_LIMIT); 11675e69fb1SPing-Ke Shih rtw_write8(rtwdev, REG_MAX_AGGR_NUM, WLAN_MAX_AGG_NR); 11775e69fb1SPing-Ke Shih rtw_write8(rtwdev, REG_AMPDU_MAX_TIME, WLAN_AMPDU_MAX_TIME); 11875e69fb1SPing-Ke Shih rtw_write8(rtwdev, REG_LEDCFG2, WLAN_ANT_SEL); 11975e69fb1SPing-Ke Shih 12075e69fb1SPing-Ke Shih rtw_write32(rtwdev, REG_LTR_IDLE_LATENCY, WLAN_LTR_IDLE_LAT); 12175e69fb1SPing-Ke Shih rtw_write32(rtwdev, REG_LTR_ACTIVE_LATENCY, WLAN_LTR_ACT_LAT); 12275e69fb1SPing-Ke Shih rtw_write32(rtwdev, REG_LTR_CTRL_BASIC, WLAN_LTR_CTRL1); 12375e69fb1SPing-Ke Shih rtw_write32(rtwdev, REG_LTR_CTRL_BASIC + 4, WLAN_LTR_CTRL2); 12475e69fb1SPing-Ke Shih 12575e69fb1SPing-Ke Shih rtw_phy_init(rtwdev); 12675e69fb1SPing-Ke Shih 12775e69fb1SPing-Ke Shih rtw_write16_set(rtwdev, REG_TXDMA_OFFSET_CHK, BIT_DROP_DATA_EN); 12875e69fb1SPing-Ke Shih rtw_write32_mask(rtwdev, REG_OFDM0_XAAGC1, MASKBYTE0, 0x50); 12975e69fb1SPing-Ke Shih rtw_write32_mask(rtwdev, REG_OFDM0_XAAGC1, MASKBYTE0, 0x20); 13075e69fb1SPing-Ke Shih } 13175e69fb1SPing-Ke Shih 132ab0a031eSPing-Ke Shih static void rtw8723de_efuse_parsing(struct rtw_efuse *efuse, 133ab0a031eSPing-Ke Shih struct rtw8723d_efuse *map) 134ab0a031eSPing-Ke Shih { 135ab0a031eSPing-Ke Shih ether_addr_copy(efuse->addr, map->e.mac_addr); 136ab0a031eSPing-Ke Shih } 137ab0a031eSPing-Ke Shih 138ab0a031eSPing-Ke Shih static int rtw8723d_read_efuse(struct rtw_dev *rtwdev, u8 *log_map) 139ab0a031eSPing-Ke Shih { 140ab0a031eSPing-Ke Shih struct rtw_efuse *efuse = &rtwdev->efuse; 141ab0a031eSPing-Ke Shih struct rtw8723d_efuse *map; 142ab0a031eSPing-Ke Shih int i; 143ab0a031eSPing-Ke Shih 144ab0a031eSPing-Ke Shih map = (struct rtw8723d_efuse *)log_map; 145ab0a031eSPing-Ke Shih 146ab0a031eSPing-Ke Shih efuse->rfe_option = 0; 147ab0a031eSPing-Ke Shih efuse->rf_board_option = map->rf_board_option; 148ab0a031eSPing-Ke Shih efuse->crystal_cap = map->xtal_k; 149ab0a031eSPing-Ke Shih efuse->pa_type_2g = map->pa_type; 150ab0a031eSPing-Ke Shih efuse->lna_type_2g = map->lna_type_2g[0]; 151ab0a031eSPing-Ke Shih efuse->channel_plan = map->channel_plan; 152ab0a031eSPing-Ke Shih efuse->country_code[0] = map->country_code[0]; 153ab0a031eSPing-Ke Shih efuse->country_code[1] = map->country_code[1]; 154ab0a031eSPing-Ke Shih efuse->bt_setting = map->rf_bt_setting; 155ab0a031eSPing-Ke Shih efuse->regd = map->rf_board_option & 0x7; 156ab0a031eSPing-Ke Shih efuse->thermal_meter[0] = map->thermal_meter; 157ab0a031eSPing-Ke Shih efuse->thermal_meter_k = map->thermal_meter; 15875e69fb1SPing-Ke Shih efuse->afe = map->afe; 159ab0a031eSPing-Ke Shih 160ab0a031eSPing-Ke Shih for (i = 0; i < 4; i++) 161ab0a031eSPing-Ke Shih efuse->txpwr_idx_table[i] = map->txpwr_idx_table[i]; 162ab0a031eSPing-Ke Shih 163ab0a031eSPing-Ke Shih switch (rtw_hci_type(rtwdev)) { 164ab0a031eSPing-Ke Shih case RTW_HCI_TYPE_PCIE: 165ab0a031eSPing-Ke Shih rtw8723de_efuse_parsing(efuse, map); 166ab0a031eSPing-Ke Shih break; 167ab0a031eSPing-Ke Shih default: 168ab0a031eSPing-Ke Shih /* unsupported now */ 169ab0a031eSPing-Ke Shih return -ENOTSUPP; 170ab0a031eSPing-Ke Shih } 171ab0a031eSPing-Ke Shih 172ab0a031eSPing-Ke Shih return 0; 173ab0a031eSPing-Ke Shih } 174ab0a031eSPing-Ke Shih 17575e69fb1SPing-Ke Shih #define BIT_CFENDFORM BIT(9) 17675e69fb1SPing-Ke Shih #define BIT_WMAC_TCR_ERR0 BIT(12) 17775e69fb1SPing-Ke Shih #define BIT_WMAC_TCR_ERR1 BIT(13) 17875e69fb1SPing-Ke Shih #define BIT_TCR_CFG (BIT_CFENDFORM | BIT_WMAC_TCR_ERR0 | \ 17975e69fb1SPing-Ke Shih BIT_WMAC_TCR_ERR1) 18075e69fb1SPing-Ke Shih #define WLAN_RX_FILTER0 0xFFFF 18175e69fb1SPing-Ke Shih #define WLAN_RX_FILTER1 0x400 18275e69fb1SPing-Ke Shih #define WLAN_RX_FILTER2 0xFFFF 18375e69fb1SPing-Ke Shih #define WLAN_RCR_CFG 0x700060CE 18475e69fb1SPing-Ke Shih 18575e69fb1SPing-Ke Shih static int rtw8723d_mac_init(struct rtw_dev *rtwdev) 18675e69fb1SPing-Ke Shih { 18775e69fb1SPing-Ke Shih rtw_write8(rtwdev, REG_FWHW_TXQ_CTRL + 1, WLAN_TXQ_RPT_EN); 18875e69fb1SPing-Ke Shih rtw_write32(rtwdev, REG_TCR, BIT_TCR_CFG); 18975e69fb1SPing-Ke Shih 19075e69fb1SPing-Ke Shih rtw_write16(rtwdev, REG_RXFLTMAP0, WLAN_RX_FILTER0); 19175e69fb1SPing-Ke Shih rtw_write16(rtwdev, REG_RXFLTMAP1, WLAN_RX_FILTER1); 19275e69fb1SPing-Ke Shih rtw_write16(rtwdev, REG_RXFLTMAP2, WLAN_RX_FILTER2); 19375e69fb1SPing-Ke Shih rtw_write32(rtwdev, REG_RCR, WLAN_RCR_CFG); 19475e69fb1SPing-Ke Shih 19575e69fb1SPing-Ke Shih rtw_write32(rtwdev, REG_INT_MIG, 0); 19675e69fb1SPing-Ke Shih rtw_write32(rtwdev, REG_MCUTST_1, 0x0); 19775e69fb1SPing-Ke Shih 19875e69fb1SPing-Ke Shih rtw_write8(rtwdev, REG_MISC_CTRL, BIT_DIS_SECOND_CCA); 19975e69fb1SPing-Ke Shih rtw_write8(rtwdev, REG_2ND_CCA_CTRL, 0); 20075e69fb1SPing-Ke Shih 20175e69fb1SPing-Ke Shih return 0; 20275e69fb1SPing-Ke Shih } 20375e69fb1SPing-Ke Shih 2041afb5eb7SPing-Ke Shih static void rtw8723d_cfg_ldo25(struct rtw_dev *rtwdev, bool enable) 2051afb5eb7SPing-Ke Shih { 2061afb5eb7SPing-Ke Shih u8 ldo_pwr; 2071afb5eb7SPing-Ke Shih 2081afb5eb7SPing-Ke Shih ldo_pwr = rtw_read8(rtwdev, REG_LDO_EFUSE_CTRL + 3); 2091afb5eb7SPing-Ke Shih if (enable) { 2101afb5eb7SPing-Ke Shih ldo_pwr &= ~BIT_MASK_LDO25_VOLTAGE; 2111afb5eb7SPing-Ke Shih ldo_pwr = (BIT_LDO25_VOLTAGE_V25 << 4) | BIT_LDO25_EN; 2121afb5eb7SPing-Ke Shih } else { 2131afb5eb7SPing-Ke Shih ldo_pwr &= ~BIT_LDO25_EN; 2141afb5eb7SPing-Ke Shih } 2151afb5eb7SPing-Ke Shih rtw_write8(rtwdev, REG_LDO_EFUSE_CTRL + 3, ldo_pwr); 2161afb5eb7SPing-Ke Shih } 2171afb5eb7SPing-Ke Shih 218ba9f0d1bSPing-Ke Shih static void 219ba9f0d1bSPing-Ke Shih rtw8723d_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path, u8 rs) 220ba9f0d1bSPing-Ke Shih { 221ba9f0d1bSPing-Ke Shih struct rtw_hal *hal = &rtwdev->hal; 222ba9f0d1bSPing-Ke Shih const struct rtw_hw_reg *txagc; 223ba9f0d1bSPing-Ke Shih u8 rate, pwr_index; 224ba9f0d1bSPing-Ke Shih int j; 225ba9f0d1bSPing-Ke Shih 226ba9f0d1bSPing-Ke Shih for (j = 0; j < rtw_rate_size[rs]; j++) { 227ba9f0d1bSPing-Ke Shih rate = rtw_rate_section[rs][j]; 228ba9f0d1bSPing-Ke Shih pwr_index = hal->tx_pwr_tbl[path][rate]; 229ba9f0d1bSPing-Ke Shih 230ba9f0d1bSPing-Ke Shih if (rate >= ARRAY_SIZE(rtw8723d_txagc)) { 231ba9f0d1bSPing-Ke Shih rtw_warn(rtwdev, "rate 0x%x isn't supported\n", rate); 232ba9f0d1bSPing-Ke Shih continue; 233ba9f0d1bSPing-Ke Shih } 234ba9f0d1bSPing-Ke Shih txagc = &rtw8723d_txagc[rate]; 235ba9f0d1bSPing-Ke Shih if (!txagc->addr) { 236ba9f0d1bSPing-Ke Shih rtw_warn(rtwdev, "rate 0x%x isn't defined\n", rate); 237ba9f0d1bSPing-Ke Shih continue; 238ba9f0d1bSPing-Ke Shih } 239ba9f0d1bSPing-Ke Shih 240ba9f0d1bSPing-Ke Shih rtw_write32_mask(rtwdev, txagc->addr, txagc->mask, pwr_index); 241ba9f0d1bSPing-Ke Shih } 242ba9f0d1bSPing-Ke Shih } 243ba9f0d1bSPing-Ke Shih 244ba9f0d1bSPing-Ke Shih static void rtw8723d_set_tx_power_index(struct rtw_dev *rtwdev) 245ba9f0d1bSPing-Ke Shih { 246ba9f0d1bSPing-Ke Shih struct rtw_hal *hal = &rtwdev->hal; 247ba9f0d1bSPing-Ke Shih int rs, path; 248ba9f0d1bSPing-Ke Shih 249ba9f0d1bSPing-Ke Shih for (path = 0; path < hal->rf_path_num; path++) { 250ba9f0d1bSPing-Ke Shih for (rs = 0; rs <= RTW_RATE_SECTION_HT_1S; rs++) 251ba9f0d1bSPing-Ke Shih rtw8723d_set_tx_power_index_by_rate(rtwdev, path, rs); 252ba9f0d1bSPing-Ke Shih } 253ba9f0d1bSPing-Ke Shih } 254ba9f0d1bSPing-Ke Shih 25544baa97cSPing-Ke Shih static void rtw8723d_efuse_grant(struct rtw_dev *rtwdev, bool on) 25644baa97cSPing-Ke Shih { 25744baa97cSPing-Ke Shih if (on) { 25844baa97cSPing-Ke Shih rtw_write8(rtwdev, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON); 25944baa97cSPing-Ke Shih 26044baa97cSPing-Ke Shih rtw_write16_set(rtwdev, REG_SYS_FUNC_EN, BIT_FEN_ELDR); 26144baa97cSPing-Ke Shih rtw_write16_set(rtwdev, REG_SYS_CLKR, BIT_LOADER_CLK_EN | BIT_ANA8M); 26244baa97cSPing-Ke Shih } else { 26344baa97cSPing-Ke Shih rtw_write8(rtwdev, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); 26444baa97cSPing-Ke Shih } 26544baa97cSPing-Ke Shih } 26644baa97cSPing-Ke Shih 267811853daSPing-Ke Shih static struct rtw_chip_ops rtw8723d_ops = { 26875e69fb1SPing-Ke Shih .phy_set_param = rtw8723d_phy_set_param, 269ab0a031eSPing-Ke Shih .read_efuse = rtw8723d_read_efuse, 27075e69fb1SPing-Ke Shih .mac_init = rtw8723d_mac_init, 271e0c27cdbSPing-Ke Shih .read_rf = rtw_phy_read_rf_sipi, 272e0c27cdbSPing-Ke Shih .write_rf = rtw_phy_write_rf_reg_sipi, 273ba9f0d1bSPing-Ke Shih .set_tx_power_index = rtw8723d_set_tx_power_index, 274811853daSPing-Ke Shih .set_antenna = NULL, 2751afb5eb7SPing-Ke Shih .cfg_ldo25 = rtw8723d_cfg_ldo25, 27644baa97cSPing-Ke Shih .efuse_grant = rtw8723d_efuse_grant, 27793ae973fSPing-Ke Shih .config_bfee = NULL, 27893ae973fSPing-Ke Shih .set_gid_table = NULL, 27993ae973fSPing-Ke Shih .cfg_csi_rate = NULL, 280811853daSPing-Ke Shih }; 281811853daSPing-Ke Shih 282c57bd7c3SPing-Ke Shih static const struct rtw_pwr_seq_cmd trans_carddis_to_cardemu_8723d[] = { 283c57bd7c3SPing-Ke Shih {0x0005, 284c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 285c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 286c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 287c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(3) | BIT(7), 0}, 288c57bd7c3SPing-Ke Shih {0x0086, 289c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 290c57bd7c3SPing-Ke Shih RTW_PWR_INTF_SDIO_MSK, 291c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_SDIO, 292c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(0), 0}, 293c57bd7c3SPing-Ke Shih {0x0086, 294c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 295c57bd7c3SPing-Ke Shih RTW_PWR_INTF_SDIO_MSK, 296c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_SDIO, 297c57bd7c3SPing-Ke Shih RTW_PWR_CMD_POLLING, BIT(1), BIT(1)}, 298c57bd7c3SPing-Ke Shih {0x004A, 299c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 300c57bd7c3SPing-Ke Shih RTW_PWR_INTF_USB_MSK, 301c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 302c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(0), 0}, 303c57bd7c3SPing-Ke Shih {0x0005, 304c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 305c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 306c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 307c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(3) | BIT(4), 0}, 308c57bd7c3SPing-Ke Shih {0x0023, 309c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 310c57bd7c3SPing-Ke Shih RTW_PWR_INTF_SDIO_MSK, 311c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 312c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(4), 0}, 313c57bd7c3SPing-Ke Shih {0x0301, 314c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 315c57bd7c3SPing-Ke Shih RTW_PWR_INTF_PCI_MSK, 316c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 317c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, 0xFF, 0}, 318c57bd7c3SPing-Ke Shih {0xFFFF, 319c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 320c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 321c57bd7c3SPing-Ke Shih 0, 322c57bd7c3SPing-Ke Shih RTW_PWR_CMD_END, 0, 0}, 323c57bd7c3SPing-Ke Shih }; 324c57bd7c3SPing-Ke Shih 325c57bd7c3SPing-Ke Shih static const struct rtw_pwr_seq_cmd trans_cardemu_to_act_8723d[] = { 326c57bd7c3SPing-Ke Shih {0x0020, 327c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 328c57bd7c3SPing-Ke Shih RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK, 329c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 330c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(0), BIT(0)}, 331c57bd7c3SPing-Ke Shih {0x0001, 332c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 333c57bd7c3SPing-Ke Shih RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK, 334c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 335c57bd7c3SPing-Ke Shih RTW_PWR_CMD_DELAY, 1, RTW_PWR_DELAY_MS}, 336c57bd7c3SPing-Ke Shih {0x0000, 337c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 338c57bd7c3SPing-Ke Shih RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK, 339c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 340c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(5), 0}, 341c57bd7c3SPing-Ke Shih {0x0005, 342c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 343c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 344c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 345c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, (BIT(4) | BIT(3) | BIT(2)), 0}, 346c57bd7c3SPing-Ke Shih {0x0075, 347c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 348c57bd7c3SPing-Ke Shih RTW_PWR_INTF_PCI_MSK, 349c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 350c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(0), BIT(0)}, 351c57bd7c3SPing-Ke Shih {0x0006, 352c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 353c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 354c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 355c57bd7c3SPing-Ke Shih RTW_PWR_CMD_POLLING, BIT(1), BIT(1)}, 356c57bd7c3SPing-Ke Shih {0x0075, 357c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 358c57bd7c3SPing-Ke Shih RTW_PWR_INTF_PCI_MSK, 359c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 360c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(0), 0}, 361c57bd7c3SPing-Ke Shih {0x0006, 362c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 363c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 364c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 365c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(0), BIT(0)}, 366c57bd7c3SPing-Ke Shih {0x0005, 367c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 368c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 369c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 370c57bd7c3SPing-Ke Shih RTW_PWR_CMD_POLLING, (BIT(1) | BIT(0)), 0}, 371c57bd7c3SPing-Ke Shih {0x0005, 372c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 373c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 374c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 375c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(7), 0}, 376c57bd7c3SPing-Ke Shih {0x0005, 377c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 378c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 379c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 380c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, (BIT(4) | BIT(3)), 0}, 381c57bd7c3SPing-Ke Shih {0x0005, 382c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 383c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 384c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 385c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(0), BIT(0)}, 386c57bd7c3SPing-Ke Shih {0x0005, 387c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 388c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 389c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 390c57bd7c3SPing-Ke Shih RTW_PWR_CMD_POLLING, BIT(0), 0}, 391c57bd7c3SPing-Ke Shih {0x0010, 392c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 393c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 394c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 395c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(6), BIT(6)}, 396c57bd7c3SPing-Ke Shih {0x0049, 397c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 398c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 399c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 400c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(1), BIT(1)}, 401c57bd7c3SPing-Ke Shih {0x0063, 402c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 403c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 404c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 405c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(1), BIT(1)}, 406c57bd7c3SPing-Ke Shih {0x0062, 407c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 408c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 409c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 410c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(1), 0}, 411c57bd7c3SPing-Ke Shih {0x0058, 412c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 413c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 414c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 415c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(0), BIT(0)}, 416c57bd7c3SPing-Ke Shih {0x005A, 417c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 418c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 419c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 420c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(1), BIT(1)}, 421c57bd7c3SPing-Ke Shih {0x0068, 422c57bd7c3SPing-Ke Shih RTW_PWR_CUT_TEST_MSK, 423c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 424c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 425c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(3), BIT(3)}, 426c57bd7c3SPing-Ke Shih {0x0069, 427c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 428c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 429c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 430c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(6), BIT(6)}, 431c57bd7c3SPing-Ke Shih {0x001f, 432c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 433c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 434c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 435c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, 0xFF, 0x00}, 436c57bd7c3SPing-Ke Shih {0x0077, 437c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 438c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 439c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 440c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, 0xFF, 0x00}, 441c57bd7c3SPing-Ke Shih {0x001f, 442c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 443c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 444c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 445c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, 0xFF, 0x07}, 446c57bd7c3SPing-Ke Shih {0x0077, 447c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 448c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 449c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 450c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, 0xFF, 0x07}, 451c57bd7c3SPing-Ke Shih {0xFFFF, 452c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 453c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 454c57bd7c3SPing-Ke Shih 0, 455c57bd7c3SPing-Ke Shih RTW_PWR_CMD_END, 0, 0}, 456c57bd7c3SPing-Ke Shih }; 457c57bd7c3SPing-Ke Shih 458c57bd7c3SPing-Ke Shih static const struct rtw_pwr_seq_cmd *card_enable_flow_8723d[] = { 459c57bd7c3SPing-Ke Shih trans_carddis_to_cardemu_8723d, 460c57bd7c3SPing-Ke Shih trans_cardemu_to_act_8723d, 461c57bd7c3SPing-Ke Shih NULL 462c57bd7c3SPing-Ke Shih }; 463c57bd7c3SPing-Ke Shih 464c57bd7c3SPing-Ke Shih static const struct rtw_pwr_seq_cmd trans_act_to_lps_8723d[] = { 465c57bd7c3SPing-Ke Shih {0x0301, 466c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 467c57bd7c3SPing-Ke Shih RTW_PWR_INTF_PCI_MSK, 468c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 469c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, 0xFF, 0xFF}, 470c57bd7c3SPing-Ke Shih {0x0522, 471c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 472c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 473c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 474c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, 0xFF, 0xFF}, 475c57bd7c3SPing-Ke Shih {0x05F8, 476c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 477c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 478c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 479c57bd7c3SPing-Ke Shih RTW_PWR_CMD_POLLING, 0xFF, 0}, 480c57bd7c3SPing-Ke Shih {0x05F9, 481c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 482c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 483c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 484c57bd7c3SPing-Ke Shih RTW_PWR_CMD_POLLING, 0xFF, 0}, 485c57bd7c3SPing-Ke Shih {0x05FA, 486c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 487c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 488c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 489c57bd7c3SPing-Ke Shih RTW_PWR_CMD_POLLING, 0xFF, 0}, 490c57bd7c3SPing-Ke Shih {0x05FB, 491c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 492c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 493c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 494c57bd7c3SPing-Ke Shih RTW_PWR_CMD_POLLING, 0xFF, 0}, 495c57bd7c3SPing-Ke Shih {0x0002, 496c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 497c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 498c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 499c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(0), 0}, 500c57bd7c3SPing-Ke Shih {0x0002, 501c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 502c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 503c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 504c57bd7c3SPing-Ke Shih RTW_PWR_CMD_DELAY, 0, RTW_PWR_DELAY_US}, 505c57bd7c3SPing-Ke Shih {0x0002, 506c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 507c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 508c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 509c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(1), 0}, 510c57bd7c3SPing-Ke Shih {0x0100, 511c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 512c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 513c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 514c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, 0xFF, 0x03}, 515c57bd7c3SPing-Ke Shih {0x0101, 516c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 517c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 518c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 519c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(1), 0}, 520c57bd7c3SPing-Ke Shih {0x0093, 521c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 522c57bd7c3SPing-Ke Shih RTW_PWR_INTF_SDIO_MSK, 523c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 524c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, 0xFF, 0x00}, 525c57bd7c3SPing-Ke Shih {0x0553, 526c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 527c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 528c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 529c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(5), BIT(5)}, 530c57bd7c3SPing-Ke Shih {0xFFFF, 531c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 532c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 533c57bd7c3SPing-Ke Shih 0, 534c57bd7c3SPing-Ke Shih RTW_PWR_CMD_END, 0, 0}, 535c57bd7c3SPing-Ke Shih }; 536c57bd7c3SPing-Ke Shih 537c57bd7c3SPing-Ke Shih static const struct rtw_pwr_seq_cmd trans_act_to_pre_carddis_8723d[] = { 538c57bd7c3SPing-Ke Shih {0x0003, 539c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 540c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 541c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 542c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(2), 0}, 543c57bd7c3SPing-Ke Shih {0x0080, 544c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 545c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 546c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 547c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, 0xFF, 0}, 548c57bd7c3SPing-Ke Shih {0xFFFF, 549c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 550c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 551c57bd7c3SPing-Ke Shih 0, 552c57bd7c3SPing-Ke Shih RTW_PWR_CMD_END, 0, 0}, 553c57bd7c3SPing-Ke Shih }; 554c57bd7c3SPing-Ke Shih 555c57bd7c3SPing-Ke Shih static const struct rtw_pwr_seq_cmd trans_act_to_cardemu_8723d[] = { 556c57bd7c3SPing-Ke Shih {0x0002, 557c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 558c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 559c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 560c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(0), 0}, 561c57bd7c3SPing-Ke Shih {0x0049, 562c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 563c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 564c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 565c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(1), 0}, 566c57bd7c3SPing-Ke Shih {0x0006, 567c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 568c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 569c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 570c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(0), BIT(0)}, 571c57bd7c3SPing-Ke Shih {0x0005, 572c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 573c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 574c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 575c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(1), BIT(1)}, 576c57bd7c3SPing-Ke Shih {0x0005, 577c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 578c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 579c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 580c57bd7c3SPing-Ke Shih RTW_PWR_CMD_POLLING, BIT(1), 0}, 581c57bd7c3SPing-Ke Shih {0x0010, 582c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 583c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 584c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 585c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(6), 0}, 586c57bd7c3SPing-Ke Shih {0x0000, 587c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 588c57bd7c3SPing-Ke Shih RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK, 589c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 590c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(5), BIT(5)}, 591c57bd7c3SPing-Ke Shih {0x0020, 592c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 593c57bd7c3SPing-Ke Shih RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK, 594c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 595c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(0), 0}, 596c57bd7c3SPing-Ke Shih {0xFFFF, 597c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 598c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 599c57bd7c3SPing-Ke Shih 0, 600c57bd7c3SPing-Ke Shih RTW_PWR_CMD_END, 0, 0}, 601c57bd7c3SPing-Ke Shih }; 602c57bd7c3SPing-Ke Shih 603c57bd7c3SPing-Ke Shih static const struct rtw_pwr_seq_cmd trans_cardemu_to_carddis_8723d[] = { 604c57bd7c3SPing-Ke Shih {0x0007, 605c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 606c57bd7c3SPing-Ke Shih RTW_PWR_INTF_SDIO_MSK, 607c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 608c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, 0xFF, 0x20}, 609c57bd7c3SPing-Ke Shih {0x0005, 610c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 611c57bd7c3SPing-Ke Shih RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK, 612c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 613c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(3) | BIT(4), BIT(3)}, 614c57bd7c3SPing-Ke Shih {0x0005, 615c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 616c57bd7c3SPing-Ke Shih RTW_PWR_INTF_PCI_MSK, 617c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 618c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(2), BIT(2)}, 619c57bd7c3SPing-Ke Shih {0x0005, 620c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 621c57bd7c3SPing-Ke Shih RTW_PWR_INTF_PCI_MSK, 622c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 623c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(3) | BIT(4), BIT(3) | BIT(4)}, 624c57bd7c3SPing-Ke Shih {0x004A, 625c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 626c57bd7c3SPing-Ke Shih RTW_PWR_INTF_USB_MSK, 627c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 628c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(0), 1}, 629c57bd7c3SPing-Ke Shih {0x0023, 630c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 631c57bd7c3SPing-Ke Shih RTW_PWR_INTF_SDIO_MSK, 632c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 633c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(4), BIT(4)}, 634c57bd7c3SPing-Ke Shih {0x0086, 635c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 636c57bd7c3SPing-Ke Shih RTW_PWR_INTF_SDIO_MSK, 637c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_SDIO, 638c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(0), BIT(0)}, 639c57bd7c3SPing-Ke Shih {0x0086, 640c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 641c57bd7c3SPing-Ke Shih RTW_PWR_INTF_SDIO_MSK, 642c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_SDIO, 643c57bd7c3SPing-Ke Shih RTW_PWR_CMD_POLLING, BIT(1), 0}, 644c57bd7c3SPing-Ke Shih {0xFFFF, 645c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 646c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 647c57bd7c3SPing-Ke Shih 0, 648c57bd7c3SPing-Ke Shih RTW_PWR_CMD_END, 0, 0}, 649c57bd7c3SPing-Ke Shih }; 650c57bd7c3SPing-Ke Shih 651c57bd7c3SPing-Ke Shih static const struct rtw_pwr_seq_cmd trans_act_to_post_carddis_8723d[] = { 652c57bd7c3SPing-Ke Shih {0x001D, 653c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 654c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 655c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 656c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(0), 0}, 657c57bd7c3SPing-Ke Shih {0x001D, 658c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 659c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 660c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 661c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, BIT(0), BIT(0)}, 662c57bd7c3SPing-Ke Shih {0x001C, 663c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 664c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 665c57bd7c3SPing-Ke Shih RTW_PWR_ADDR_MAC, 666c57bd7c3SPing-Ke Shih RTW_PWR_CMD_WRITE, 0xFF, 0x0E}, 667c57bd7c3SPing-Ke Shih {0xFFFF, 668c57bd7c3SPing-Ke Shih RTW_PWR_CUT_ALL_MSK, 669c57bd7c3SPing-Ke Shih RTW_PWR_INTF_ALL_MSK, 670c57bd7c3SPing-Ke Shih 0, 671c57bd7c3SPing-Ke Shih RTW_PWR_CMD_END, 0, 0}, 672c57bd7c3SPing-Ke Shih }; 673c57bd7c3SPing-Ke Shih 674c57bd7c3SPing-Ke Shih static const struct rtw_pwr_seq_cmd *card_disable_flow_8723d[] = { 675c57bd7c3SPing-Ke Shih trans_act_to_lps_8723d, 676c57bd7c3SPing-Ke Shih trans_act_to_pre_carddis_8723d, 677c57bd7c3SPing-Ke Shih trans_act_to_cardemu_8723d, 678c57bd7c3SPing-Ke Shih trans_cardemu_to_carddis_8723d, 679c57bd7c3SPing-Ke Shih trans_act_to_post_carddis_8723d, 680c57bd7c3SPing-Ke Shih NULL 681c57bd7c3SPing-Ke Shih }; 682c57bd7c3SPing-Ke Shih 683d91277deSPing-Ke Shih static const struct rtw_page_table page_table_8723d[] = { 684d91277deSPing-Ke Shih {12, 2, 2, 0, 1}, 685d91277deSPing-Ke Shih {12, 2, 2, 0, 1}, 686d91277deSPing-Ke Shih {12, 2, 2, 0, 1}, 687d91277deSPing-Ke Shih {12, 2, 2, 0, 1}, 688d91277deSPing-Ke Shih {12, 2, 2, 0, 1}, 689d91277deSPing-Ke Shih }; 690d91277deSPing-Ke Shih 691d91277deSPing-Ke Shih static const struct rtw_rqpn rqpn_table_8723d[] = { 692d91277deSPing-Ke Shih {RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_NORMAL, 693d91277deSPing-Ke Shih RTW_DMA_MAPPING_LOW, RTW_DMA_MAPPING_LOW, 694d91277deSPing-Ke Shih RTW_DMA_MAPPING_EXTRA, RTW_DMA_MAPPING_HIGH}, 695d91277deSPing-Ke Shih {RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_NORMAL, 696d91277deSPing-Ke Shih RTW_DMA_MAPPING_LOW, RTW_DMA_MAPPING_LOW, 697d91277deSPing-Ke Shih RTW_DMA_MAPPING_EXTRA, RTW_DMA_MAPPING_HIGH}, 698d91277deSPing-Ke Shih {RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_NORMAL, 699d91277deSPing-Ke Shih RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_HIGH, 700d91277deSPing-Ke Shih RTW_DMA_MAPPING_HIGH, RTW_DMA_MAPPING_HIGH}, 701d91277deSPing-Ke Shih {RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_NORMAL, 702d91277deSPing-Ke Shih RTW_DMA_MAPPING_LOW, RTW_DMA_MAPPING_LOW, 703d91277deSPing-Ke Shih RTW_DMA_MAPPING_HIGH, RTW_DMA_MAPPING_HIGH}, 704d91277deSPing-Ke Shih {RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_NORMAL, 705d91277deSPing-Ke Shih RTW_DMA_MAPPING_LOW, RTW_DMA_MAPPING_LOW, 706d91277deSPing-Ke Shih RTW_DMA_MAPPING_EXTRA, RTW_DMA_MAPPING_HIGH}, 707d91277deSPing-Ke Shih }; 708d91277deSPing-Ke Shih 709db39a9ddSPing-Ke Shih static const struct rtw_hw_reg rtw8723d_dig[] = { 710db39a9ddSPing-Ke Shih [0] = { .addr = 0xc50, .mask = 0x7f }, 711db39a9ddSPing-Ke Shih [1] = { .addr = 0xc50, .mask = 0x7f }, 712db39a9ddSPing-Ke Shih }; 713db39a9ddSPing-Ke Shih 714e0c27cdbSPing-Ke Shih static const struct rtw_rf_sipi_addr rtw8723d_rf_sipi_addr[] = { 715e0c27cdbSPing-Ke Shih [RF_PATH_A] = { .hssi_1 = 0x820, .lssi_read = 0x8a0, 716e0c27cdbSPing-Ke Shih .hssi_2 = 0x824, .lssi_read_pi = 0x8b8}, 717e0c27cdbSPing-Ke Shih [RF_PATH_B] = { .hssi_1 = 0x828, .lssi_read = 0x8a4, 718e0c27cdbSPing-Ke Shih .hssi_2 = 0x82c, .lssi_read_pi = 0x8bc}, 719e0c27cdbSPing-Ke Shih }; 720e0c27cdbSPing-Ke Shih 7219874f685SPing-Ke Shih static const struct rtw_rfe_def rtw8723d_rfe_defs[] = { 7229874f685SPing-Ke Shih [0] = { .phy_pg_tbl = &rtw8723d_bb_pg_tbl, 7239874f685SPing-Ke Shih .txpwr_lmt_tbl = &rtw8723d_txpwr_lmt_tbl,}, 7249874f685SPing-Ke Shih }; 7259874f685SPing-Ke Shih 726811853daSPing-Ke Shih struct rtw_chip_info rtw8723d_hw_spec = { 727811853daSPing-Ke Shih .ops = &rtw8723d_ops, 728811853daSPing-Ke Shih .id = RTW_CHIP_TYPE_8723D, 729811853daSPing-Ke Shih .fw_name = "rtw88/rtw8723d_fw.bin", 73015d2fcc6SPing-Ke Shih .wlan_cpu = RTW_WCPU_11N, 731811853daSPing-Ke Shih .tx_pkt_desc_sz = 40, 732811853daSPing-Ke Shih .tx_buf_desc_sz = 16, 733811853daSPing-Ke Shih .rx_pkt_desc_sz = 24, 734811853daSPing-Ke Shih .rx_buf_desc_sz = 8, 735811853daSPing-Ke Shih .phy_efuse_size = 512, 736811853daSPing-Ke Shih .log_efuse_size = 512, 737811853daSPing-Ke Shih .ptct_efuse_size = 96 + 1, 738d91277deSPing-Ke Shih .txff_size = 32768, 739d91277deSPing-Ke Shih .rxff_size = 16384, 740811853daSPing-Ke Shih .txgi_factor = 1, 741811853daSPing-Ke Shih .is_pwr_by_rate_dec = true, 742811853daSPing-Ke Shih .max_power_index = 0x3f, 743811853daSPing-Ke Shih .csi_buf_pg_num = 0, 744811853daSPing-Ke Shih .band = RTW_BAND_2G, 745d91277deSPing-Ke Shih .page_size = 128, 746db39a9ddSPing-Ke Shih .dig_min = 0x20, 747811853daSPing-Ke Shih .ht_supported = true, 748811853daSPing-Ke Shih .vht_supported = false, 749811853daSPing-Ke Shih .lps_deep_mode_supported = 0, 750811853daSPing-Ke Shih .sys_func_en = 0xFD, 751c57bd7c3SPing-Ke Shih .pwr_on_seq = card_enable_flow_8723d, 752c57bd7c3SPing-Ke Shih .pwr_off_seq = card_disable_flow_8723d, 753d91277deSPing-Ke Shih .page_table = page_table_8723d, 754d91277deSPing-Ke Shih .rqpn_table = rqpn_table_8723d, 755db39a9ddSPing-Ke Shih .dig = rtw8723d_dig, 756e0c27cdbSPing-Ke Shih .rf_sipi_addr = {0x840, 0x844}, 757e0c27cdbSPing-Ke Shih .rf_sipi_read_addr = rtw8723d_rf_sipi_addr, 758e0c27cdbSPing-Ke Shih .fix_rf_phy_num = 2, 7599874f685SPing-Ke Shih .mac_tbl = &rtw8723d_mac_tbl, 7609874f685SPing-Ke Shih .agc_tbl = &rtw8723d_agc_tbl, 7619874f685SPing-Ke Shih .bb_tbl = &rtw8723d_bb_tbl, 7629874f685SPing-Ke Shih .rf_tbl = {&rtw8723d_rf_a_tbl}, 7639874f685SPing-Ke Shih .rfe_defs = rtw8723d_rfe_defs, 7649874f685SPing-Ke Shih .rfe_defs_size = ARRAY_SIZE(rtw8723d_rfe_defs), 765811853daSPing-Ke Shih }; 766811853daSPing-Ke Shih EXPORT_SYMBOL(rtw8723d_hw_spec); 767811853daSPing-Ke Shih 768811853daSPing-Ke Shih MODULE_FIRMWARE("rtw88/rtw8723d_fw.bin"); 769