18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
28c2ecf20Sopenharmony_ci/* Copyright(c) 2018-2019  Realtek Corporation
38c2ecf20Sopenharmony_ci */
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include "main.h"
68c2ecf20Sopenharmony_ci#include "coex.h"
78c2ecf20Sopenharmony_ci#include "fw.h"
88c2ecf20Sopenharmony_ci#include "tx.h"
98c2ecf20Sopenharmony_ci#include "rx.h"
108c2ecf20Sopenharmony_ci#include "phy.h"
118c2ecf20Sopenharmony_ci#include "rtw8821c.h"
128c2ecf20Sopenharmony_ci#include "rtw8821c_table.h"
138c2ecf20Sopenharmony_ci#include "mac.h"
148c2ecf20Sopenharmony_ci#include "reg.h"
158c2ecf20Sopenharmony_ci#include "debug.h"
168c2ecf20Sopenharmony_ci#include "bf.h"
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_cistatic void rtw8821ce_efuse_parsing(struct rtw_efuse *efuse,
198c2ecf20Sopenharmony_ci				    struct rtw8821c_efuse *map)
208c2ecf20Sopenharmony_ci{
218c2ecf20Sopenharmony_ci	ether_addr_copy(efuse->addr, map->e.mac_addr);
228c2ecf20Sopenharmony_ci}
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cistatic int rtw8821c_read_efuse(struct rtw_dev *rtwdev, u8 *log_map)
258c2ecf20Sopenharmony_ci{
268c2ecf20Sopenharmony_ci	struct rtw_efuse *efuse = &rtwdev->efuse;
278c2ecf20Sopenharmony_ci	struct rtw8821c_efuse *map;
288c2ecf20Sopenharmony_ci	int i;
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci	map = (struct rtw8821c_efuse *)log_map;
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci	efuse->rfe_option = map->rfe_option;
338c2ecf20Sopenharmony_ci	efuse->rf_board_option = map->rf_board_option;
348c2ecf20Sopenharmony_ci	efuse->crystal_cap = map->xtal_k;
358c2ecf20Sopenharmony_ci	efuse->pa_type_2g = map->pa_type;
368c2ecf20Sopenharmony_ci	efuse->pa_type_5g = map->pa_type;
378c2ecf20Sopenharmony_ci	efuse->lna_type_2g = map->lna_type_2g[0];
388c2ecf20Sopenharmony_ci	efuse->lna_type_5g = map->lna_type_5g[0];
398c2ecf20Sopenharmony_ci	efuse->channel_plan = map->channel_plan;
408c2ecf20Sopenharmony_ci	efuse->country_code[0] = map->country_code[0];
418c2ecf20Sopenharmony_ci	efuse->country_code[1] = map->country_code[1];
428c2ecf20Sopenharmony_ci	efuse->bt_setting = map->rf_bt_setting;
438c2ecf20Sopenharmony_ci	efuse->regd = map->rf_board_option & 0x7;
448c2ecf20Sopenharmony_ci	efuse->thermal_meter[0] = map->thermal_meter;
458c2ecf20Sopenharmony_ci	efuse->thermal_meter_k = map->thermal_meter;
468c2ecf20Sopenharmony_ci	efuse->tx_bb_swing_setting_2g = map->tx_bb_swing_setting_2g;
478c2ecf20Sopenharmony_ci	efuse->tx_bb_swing_setting_5g = map->tx_bb_swing_setting_5g;
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci	for (i = 0; i < 4; i++)
508c2ecf20Sopenharmony_ci		efuse->txpwr_idx_table[i] = map->txpwr_idx_table[i];
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci	switch (rtw_hci_type(rtwdev)) {
538c2ecf20Sopenharmony_ci	case RTW_HCI_TYPE_PCIE:
548c2ecf20Sopenharmony_ci		rtw8821ce_efuse_parsing(efuse, map);
558c2ecf20Sopenharmony_ci		break;
568c2ecf20Sopenharmony_ci	default:
578c2ecf20Sopenharmony_ci		/* unsupported now */
588c2ecf20Sopenharmony_ci		return -ENOTSUPP;
598c2ecf20Sopenharmony_ci	}
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci	return 0;
628c2ecf20Sopenharmony_ci}
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_cistatic const u32 rtw8821c_txscale_tbl[] = {
658c2ecf20Sopenharmony_ci	0x081, 0x088, 0x090, 0x099, 0x0a2, 0x0ac, 0x0b6, 0x0c0, 0x0cc, 0x0d8,
668c2ecf20Sopenharmony_ci	0x0e5, 0x0f2, 0x101, 0x110, 0x120, 0x131, 0x143, 0x156, 0x16a, 0x180,
678c2ecf20Sopenharmony_ci	0x197, 0x1af, 0x1c8, 0x1e3, 0x200, 0x21e, 0x23e, 0x261, 0x285, 0x2ab,
688c2ecf20Sopenharmony_ci	0x2d3, 0x2fe, 0x32b, 0x35c, 0x38e, 0x3c4, 0x3fe
698c2ecf20Sopenharmony_ci};
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_cistatic u8 rtw8821c_get_swing_index(struct rtw_dev *rtwdev)
728c2ecf20Sopenharmony_ci{
738c2ecf20Sopenharmony_ci	u8 i = 0;
748c2ecf20Sopenharmony_ci	u32 swing, table_value;
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci	swing = rtw_read32_mask(rtwdev, REG_TXSCALE_A, 0xffe00000);
778c2ecf20Sopenharmony_ci	for (i = 0; i < ARRAY_SIZE(rtw8821c_txscale_tbl); i++) {
788c2ecf20Sopenharmony_ci		table_value = rtw8821c_txscale_tbl[i];
798c2ecf20Sopenharmony_ci		if (swing == table_value)
808c2ecf20Sopenharmony_ci			break;
818c2ecf20Sopenharmony_ci	}
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci	return i;
848c2ecf20Sopenharmony_ci}
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_cistatic void rtw8821c_pwrtrack_init(struct rtw_dev *rtwdev)
878c2ecf20Sopenharmony_ci{
888c2ecf20Sopenharmony_ci	struct rtw_dm_info *dm_info = &rtwdev->dm_info;
898c2ecf20Sopenharmony_ci	u8 swing_idx = rtw8821c_get_swing_index(rtwdev);
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci	if (swing_idx >= ARRAY_SIZE(rtw8821c_txscale_tbl))
928c2ecf20Sopenharmony_ci		dm_info->default_ofdm_index = 24;
938c2ecf20Sopenharmony_ci	else
948c2ecf20Sopenharmony_ci		dm_info->default_ofdm_index = swing_idx;
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci	ewma_thermal_init(&dm_info->avg_thermal[RF_PATH_A]);
978c2ecf20Sopenharmony_ci	dm_info->delta_power_index[RF_PATH_A] = 0;
988c2ecf20Sopenharmony_ci	dm_info->delta_power_index_last[RF_PATH_A] = 0;
998c2ecf20Sopenharmony_ci	dm_info->pwr_trk_triggered = false;
1008c2ecf20Sopenharmony_ci	dm_info->pwr_trk_init_trigger = true;
1018c2ecf20Sopenharmony_ci	dm_info->thermal_meter_k = rtwdev->efuse.thermal_meter_k;
1028c2ecf20Sopenharmony_ci}
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_cistatic void rtw8821c_phy_bf_init(struct rtw_dev *rtwdev)
1058c2ecf20Sopenharmony_ci{
1068c2ecf20Sopenharmony_ci	rtw_bf_phy_init(rtwdev);
1078c2ecf20Sopenharmony_ci	/* Grouping bitmap parameters */
1088c2ecf20Sopenharmony_ci	rtw_write32(rtwdev, 0x1C94, 0xAFFFAFFF);
1098c2ecf20Sopenharmony_ci}
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_cistatic void rtw8821c_phy_set_param(struct rtw_dev *rtwdev)
1128c2ecf20Sopenharmony_ci{
1138c2ecf20Sopenharmony_ci	u8 crystal_cap, val;
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci	/* power on BB/RF domain */
1168c2ecf20Sopenharmony_ci	val = rtw_read8(rtwdev, REG_SYS_FUNC_EN);
1178c2ecf20Sopenharmony_ci	val |= BIT_FEN_PCIEA;
1188c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_SYS_FUNC_EN, val);
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci	/* toggle BB reset */
1218c2ecf20Sopenharmony_ci	val |= BIT_FEN_BB_RSTB | BIT_FEN_BB_GLB_RST;
1228c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_SYS_FUNC_EN, val);
1238c2ecf20Sopenharmony_ci	val &= ~(BIT_FEN_BB_RSTB | BIT_FEN_BB_GLB_RST);
1248c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_SYS_FUNC_EN, val);
1258c2ecf20Sopenharmony_ci	val |= BIT_FEN_BB_RSTB | BIT_FEN_BB_GLB_RST;
1268c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_SYS_FUNC_EN, val);
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_RF_CTRL,
1298c2ecf20Sopenharmony_ci		   BIT_RF_EN | BIT_RF_RSTB | BIT_RF_SDM_RSTB);
1308c2ecf20Sopenharmony_ci	usleep_range(10, 11);
1318c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_WLRF1 + 3,
1328c2ecf20Sopenharmony_ci		   BIT_RF_EN | BIT_RF_RSTB | BIT_RF_SDM_RSTB);
1338c2ecf20Sopenharmony_ci	usleep_range(10, 11);
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci	/* pre init before header files config */
1368c2ecf20Sopenharmony_ci	rtw_write32_clr(rtwdev, REG_RXPSEL, BIT_RX_PSEL_RST);
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci	rtw_phy_load_tables(rtwdev);
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci	crystal_cap = rtwdev->efuse.crystal_cap & 0x3F;
1418c2ecf20Sopenharmony_ci	rtw_write32_mask(rtwdev, REG_AFE_XTAL_CTRL, 0x7e000000, crystal_cap);
1428c2ecf20Sopenharmony_ci	rtw_write32_mask(rtwdev, REG_AFE_PLL_CTRL, 0x7e, crystal_cap);
1438c2ecf20Sopenharmony_ci	rtw_write32_mask(rtwdev, REG_CCK0_FAREPORT, BIT(18) | BIT(22), 0);
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci	/* post init after header files config */
1468c2ecf20Sopenharmony_ci	rtw_write32_set(rtwdev, REG_RXPSEL, BIT_RX_PSEL_RST);
1478c2ecf20Sopenharmony_ci	rtwdev->chip->ch_param[0] = rtw_read32_mask(rtwdev, REG_TXSF2, MASKDWORD);
1488c2ecf20Sopenharmony_ci	rtwdev->chip->ch_param[1] = rtw_read32_mask(rtwdev, REG_TXSF6, MASKDWORD);
1498c2ecf20Sopenharmony_ci	rtwdev->chip->ch_param[2] = rtw_read32_mask(rtwdev, REG_TXFILTER, MASKDWORD);
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci	rtw_phy_init(rtwdev);
1528c2ecf20Sopenharmony_ci	rtwdev->dm_info.cck_pd_default = rtw_read8(rtwdev, REG_CSRATIO) & 0x1f;
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci	rtw8821c_pwrtrack_init(rtwdev);
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci	rtw8821c_phy_bf_init(rtwdev);
1578c2ecf20Sopenharmony_ci}
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_cistatic int rtw8821c_mac_init(struct rtw_dev *rtwdev)
1608c2ecf20Sopenharmony_ci{
1618c2ecf20Sopenharmony_ci	u32 value32;
1628c2ecf20Sopenharmony_ci	u16 pre_txcnt;
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci	/* protocol configuration */
1658c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_AMPDU_MAX_TIME_V1, WLAN_AMPDU_MAX_TIME);
1668c2ecf20Sopenharmony_ci	rtw_write8_set(rtwdev, REG_TX_HANG_CTRL, BIT_EN_EOF_V1);
1678c2ecf20Sopenharmony_ci	pre_txcnt = WLAN_PRE_TXCNT_TIME_TH | BIT_EN_PRECNT;
1688c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_PRECNT_CTRL, (u8)(pre_txcnt & 0xFF));
1698c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_PRECNT_CTRL + 1, (u8)(pre_txcnt >> 8));
1708c2ecf20Sopenharmony_ci	value32 = WLAN_RTS_LEN_TH | (WLAN_RTS_TX_TIME_TH << 8) |
1718c2ecf20Sopenharmony_ci		  (WLAN_MAX_AGG_PKT_LIMIT << 16) |
1728c2ecf20Sopenharmony_ci		  (WLAN_RTS_MAX_AGG_PKT_LIMIT << 24);
1738c2ecf20Sopenharmony_ci	rtw_write32(rtwdev, REG_PROT_MODE_CTRL, value32);
1748c2ecf20Sopenharmony_ci	rtw_write16(rtwdev, REG_BAR_MODE_CTRL + 2,
1758c2ecf20Sopenharmony_ci		    WLAN_BAR_RETRY_LIMIT | WLAN_RA_TRY_RATE_AGG_LIMIT << 8);
1768c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_FAST_EDCA_VOVI_SETTING, FAST_EDCA_VO_TH);
1778c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_FAST_EDCA_VOVI_SETTING + 2, FAST_EDCA_VI_TH);
1788c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_FAST_EDCA_BEBK_SETTING, FAST_EDCA_BE_TH);
1798c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_FAST_EDCA_BEBK_SETTING + 2, FAST_EDCA_BK_TH);
1808c2ecf20Sopenharmony_ci	rtw_write8_set(rtwdev, REG_INIRTS_RATE_SEL, BIT(5));
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci	/* EDCA configuration */
1838c2ecf20Sopenharmony_ci	rtw_write8_clr(rtwdev, REG_TIMER0_SRC_SEL, BIT_TSFT_SEL_TIMER0);
1848c2ecf20Sopenharmony_ci	rtw_write16(rtwdev, REG_TXPAUSE, 0);
1858c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_SLOT, WLAN_SLOT_TIME);
1868c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_PIFS, WLAN_PIFS_TIME);
1878c2ecf20Sopenharmony_ci	rtw_write32(rtwdev, REG_SIFS, WLAN_SIFS_CFG);
1888c2ecf20Sopenharmony_ci	rtw_write16(rtwdev, REG_EDCA_VO_PARAM + 2, WLAN_VO_TXOP_LIMIT);
1898c2ecf20Sopenharmony_ci	rtw_write16(rtwdev, REG_EDCA_VI_PARAM + 2, WLAN_VI_TXOP_LIMIT);
1908c2ecf20Sopenharmony_ci	rtw_write32(rtwdev, REG_RD_NAV_NXT, WLAN_NAV_CFG);
1918c2ecf20Sopenharmony_ci	rtw_write16(rtwdev, REG_RXTSF_OFFSET_CCK, WLAN_RX_TSF_CFG);
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci	/* Set beacon cotnrol - enable TSF and other related functions */
1948c2ecf20Sopenharmony_ci	rtw_write8_set(rtwdev, REG_BCN_CTRL, BIT_EN_BCN_FUNCTION);
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci	/* Set send beacon related registers */
1978c2ecf20Sopenharmony_ci	rtw_write32(rtwdev, REG_TBTT_PROHIBIT, WLAN_TBTT_TIME);
1988c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_DRVERLYINT, WLAN_DRV_EARLY_INT);
1998c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_BCNDMATIM, WLAN_BCN_DMA_TIME);
2008c2ecf20Sopenharmony_ci	rtw_write8_clr(rtwdev, REG_TX_PTCL_CTRL + 1, BIT_SIFS_BK_EN >> 8);
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_ci	/* WMAC configuration */
2038c2ecf20Sopenharmony_ci	rtw_write32(rtwdev, REG_RXFLTMAP0, WLAN_RX_FILTER0);
2048c2ecf20Sopenharmony_ci	rtw_write16(rtwdev, REG_RXFLTMAP2, WLAN_RX_FILTER2);
2058c2ecf20Sopenharmony_ci	rtw_write32(rtwdev, REG_RCR, WLAN_RCR_CFG);
2068c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_RX_PKT_LIMIT, WLAN_RXPKT_MAX_SZ_512);
2078c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_TCR + 2, WLAN_TX_FUNC_CFG2);
2088c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_TCR + 1, WLAN_TX_FUNC_CFG1);
2098c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_ACKTO_CCK, 0x40);
2108c2ecf20Sopenharmony_ci	rtw_write8_set(rtwdev, REG_WMAC_TRXPTCL_CTL_H, BIT(1));
2118c2ecf20Sopenharmony_ci	rtw_write8_set(rtwdev, REG_SND_PTCL_CTRL, BIT(6));
2128c2ecf20Sopenharmony_ci	rtw_write32(rtwdev, REG_WMAC_OPTION_FUNCTION + 8, WLAN_MAC_OPT_FUNC2);
2138c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_WMAC_OPTION_FUNCTION + 4, WLAN_MAC_OPT_NORM_FUNC1);
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_ci	return 0;
2168c2ecf20Sopenharmony_ci}
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_cistatic void rtw8821c_cfg_ldo25(struct rtw_dev *rtwdev, bool enable)
2198c2ecf20Sopenharmony_ci{
2208c2ecf20Sopenharmony_ci	u8 ldo_pwr;
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci	ldo_pwr = rtw_read8(rtwdev, REG_LDO_EFUSE_CTRL + 3);
2238c2ecf20Sopenharmony_ci	ldo_pwr = enable ? ldo_pwr | BIT(7) : ldo_pwr & ~BIT(7);
2248c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_LDO_EFUSE_CTRL + 3, ldo_pwr);
2258c2ecf20Sopenharmony_ci}
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_cistatic void rtw8821c_set_channel_rf(struct rtw_dev *rtwdev, u8 channel, u8 bw)
2288c2ecf20Sopenharmony_ci{
2298c2ecf20Sopenharmony_ci	u32 rf_reg18;
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci	rf_reg18 = rtw_read_rf(rtwdev, RF_PATH_A, 0x18, RFREG_MASK);
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ci	rf_reg18 &= ~(RF18_BAND_MASK | RF18_CHANNEL_MASK | RF18_RFSI_MASK |
2348c2ecf20Sopenharmony_ci		      RF18_BW_MASK);
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ci	rf_reg18 |= (channel <= 14 ? RF18_BAND_2G : RF18_BAND_5G);
2378c2ecf20Sopenharmony_ci	rf_reg18 |= (channel & RF18_CHANNEL_MASK);
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ci	if (channel >= 100 && channel <= 140)
2408c2ecf20Sopenharmony_ci		rf_reg18 |= RF18_RFSI_GE;
2418c2ecf20Sopenharmony_ci	else if (channel > 140)
2428c2ecf20Sopenharmony_ci		rf_reg18 |= RF18_RFSI_GT;
2438c2ecf20Sopenharmony_ci
2448c2ecf20Sopenharmony_ci	switch (bw) {
2458c2ecf20Sopenharmony_ci	case RTW_CHANNEL_WIDTH_5:
2468c2ecf20Sopenharmony_ci	case RTW_CHANNEL_WIDTH_10:
2478c2ecf20Sopenharmony_ci	case RTW_CHANNEL_WIDTH_20:
2488c2ecf20Sopenharmony_ci	default:
2498c2ecf20Sopenharmony_ci		rf_reg18 |= RF18_BW_20M;
2508c2ecf20Sopenharmony_ci		break;
2518c2ecf20Sopenharmony_ci	case RTW_CHANNEL_WIDTH_40:
2528c2ecf20Sopenharmony_ci		rf_reg18 |= RF18_BW_40M;
2538c2ecf20Sopenharmony_ci		break;
2548c2ecf20Sopenharmony_ci	case RTW_CHANNEL_WIDTH_80:
2558c2ecf20Sopenharmony_ci		rf_reg18 |= RF18_BW_80M;
2568c2ecf20Sopenharmony_ci		break;
2578c2ecf20Sopenharmony_ci	}
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci	if (channel <= 14) {
2608c2ecf20Sopenharmony_ci		rtw_write_rf(rtwdev, RF_PATH_A, RF_LUTDBG, BIT(6), 0x1);
2618c2ecf20Sopenharmony_ci		rtw_write_rf(rtwdev, RF_PATH_A, 0x64, 0xf, 0xf);
2628c2ecf20Sopenharmony_ci	} else {
2638c2ecf20Sopenharmony_ci		rtw_write_rf(rtwdev, RF_PATH_A, RF_LUTDBG, BIT(6), 0x0);
2648c2ecf20Sopenharmony_ci	}
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ci	rtw_write_rf(rtwdev, RF_PATH_A, 0x18, RFREG_MASK, rf_reg18);
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_ci	rtw_write_rf(rtwdev, RF_PATH_A, RF_XTALX2, BIT(19), 0);
2698c2ecf20Sopenharmony_ci	rtw_write_rf(rtwdev, RF_PATH_A, RF_XTALX2, BIT(19), 1);
2708c2ecf20Sopenharmony_ci}
2718c2ecf20Sopenharmony_ci
2728c2ecf20Sopenharmony_cistatic void rtw8821c_set_channel_rxdfir(struct rtw_dev *rtwdev, u8 bw)
2738c2ecf20Sopenharmony_ci{
2748c2ecf20Sopenharmony_ci	if (bw == RTW_CHANNEL_WIDTH_40) {
2758c2ecf20Sopenharmony_ci		/* RX DFIR for BW40 */
2768c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ACBB0, BIT(29) | BIT(28), 0x2);
2778c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ACBBRXFIR, BIT(29) | BIT(28), 0x2);
2788c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_TXDFIR, BIT(31), 0x0);
2798c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_CHFIR, BIT(31), 0x0);
2808c2ecf20Sopenharmony_ci	} else if (bw == RTW_CHANNEL_WIDTH_80) {
2818c2ecf20Sopenharmony_ci		/* RX DFIR for BW80 */
2828c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ACBB0, BIT(29) | BIT(28), 0x2);
2838c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ACBBRXFIR, BIT(29) | BIT(28), 0x1);
2848c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_TXDFIR, BIT(31), 0x0);
2858c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_CHFIR, BIT(31), 0x1);
2868c2ecf20Sopenharmony_ci	} else {
2878c2ecf20Sopenharmony_ci		/* RX DFIR for BW20, BW10 and BW5 */
2888c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ACBB0, BIT(29) | BIT(28), 0x2);
2898c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ACBBRXFIR, BIT(29) | BIT(28), 0x2);
2908c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_TXDFIR, BIT(31), 0x1);
2918c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_CHFIR, BIT(31), 0x0);
2928c2ecf20Sopenharmony_ci	}
2938c2ecf20Sopenharmony_ci}
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_cistatic void rtw8821c_set_channel_bb(struct rtw_dev *rtwdev, u8 channel, u8 bw,
2968c2ecf20Sopenharmony_ci				    u8 primary_ch_idx)
2978c2ecf20Sopenharmony_ci{
2988c2ecf20Sopenharmony_ci	u32 val32;
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_ci	if (channel <= 14) {
3018c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_RXPSEL, BIT(28), 0x1);
3028c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_CCK_CHECK, BIT(7), 0x0);
3038c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ENTXCCK, BIT(18), 0x0);
3048c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_RXCCAMSK, 0x0000FC00, 15);
3058c2ecf20Sopenharmony_ci
3068c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_TXSCALE_A, 0xf00, 0x0);
3078c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_CLKTRK, 0x1ffe0000, 0x96a);
3088c2ecf20Sopenharmony_ci		if (channel == 14) {
3098c2ecf20Sopenharmony_ci			rtw_write32_mask(rtwdev, REG_TXSF2, MASKDWORD, 0x0000b81c);
3108c2ecf20Sopenharmony_ci			rtw_write32_mask(rtwdev, REG_TXSF6, MASKLWORD, 0x0000);
3118c2ecf20Sopenharmony_ci			rtw_write32_mask(rtwdev, REG_TXFILTER, MASKDWORD, 0x00003667);
3128c2ecf20Sopenharmony_ci		} else {
3138c2ecf20Sopenharmony_ci			rtw_write32_mask(rtwdev, REG_TXSF2, MASKDWORD,
3148c2ecf20Sopenharmony_ci					 rtwdev->chip->ch_param[0]);
3158c2ecf20Sopenharmony_ci			rtw_write32_mask(rtwdev, REG_TXSF6, MASKLWORD,
3168c2ecf20Sopenharmony_ci					 rtwdev->chip->ch_param[1] & MASKLWORD);
3178c2ecf20Sopenharmony_ci			rtw_write32_mask(rtwdev, REG_TXFILTER, MASKDWORD,
3188c2ecf20Sopenharmony_ci					 rtwdev->chip->ch_param[2]);
3198c2ecf20Sopenharmony_ci		}
3208c2ecf20Sopenharmony_ci	} else if (channel > 35) {
3218c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ENTXCCK, BIT(18), 0x1);
3228c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_CCK_CHECK, BIT(7), 0x1);
3238c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_RXPSEL, BIT(28), 0x0);
3248c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_RXCCAMSK, 0x0000FC00, 15);
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci		if (channel >= 36 && channel <= 64)
3278c2ecf20Sopenharmony_ci			rtw_write32_mask(rtwdev, REG_TXSCALE_A, 0xf00, 0x1);
3288c2ecf20Sopenharmony_ci		else if (channel >= 100 && channel <= 144)
3298c2ecf20Sopenharmony_ci			rtw_write32_mask(rtwdev, REG_TXSCALE_A, 0xf00, 0x2);
3308c2ecf20Sopenharmony_ci		else if (channel >= 149)
3318c2ecf20Sopenharmony_ci			rtw_write32_mask(rtwdev, REG_TXSCALE_A, 0xf00, 0x3);
3328c2ecf20Sopenharmony_ci
3338c2ecf20Sopenharmony_ci		if (channel >= 36 && channel <= 48)
3348c2ecf20Sopenharmony_ci			rtw_write32_mask(rtwdev, REG_CLKTRK, 0x1ffe0000, 0x494);
3358c2ecf20Sopenharmony_ci		else if (channel >= 52 && channel <= 64)
3368c2ecf20Sopenharmony_ci			rtw_write32_mask(rtwdev, REG_CLKTRK, 0x1ffe0000, 0x453);
3378c2ecf20Sopenharmony_ci		else if (channel >= 100 && channel <= 116)
3388c2ecf20Sopenharmony_ci			rtw_write32_mask(rtwdev, REG_CLKTRK, 0x1ffe0000, 0x452);
3398c2ecf20Sopenharmony_ci		else if (channel >= 118 && channel <= 177)
3408c2ecf20Sopenharmony_ci			rtw_write32_mask(rtwdev, REG_CLKTRK, 0x1ffe0000, 0x412);
3418c2ecf20Sopenharmony_ci	}
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci	switch (bw) {
3448c2ecf20Sopenharmony_ci	case RTW_CHANNEL_WIDTH_20:
3458c2ecf20Sopenharmony_ci	default:
3468c2ecf20Sopenharmony_ci		val32 = rtw_read32_mask(rtwdev, REG_ADCCLK, MASKDWORD);
3478c2ecf20Sopenharmony_ci		val32 &= 0xffcffc00;
3488c2ecf20Sopenharmony_ci		val32 |= 0x10010000;
3498c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ADCCLK, MASKDWORD, val32);
3508c2ecf20Sopenharmony_ci
3518c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ADC160, BIT(30), 0x1);
3528c2ecf20Sopenharmony_ci		break;
3538c2ecf20Sopenharmony_ci	case RTW_CHANNEL_WIDTH_40:
3548c2ecf20Sopenharmony_ci		if (primary_ch_idx == 1)
3558c2ecf20Sopenharmony_ci			rtw_write32_set(rtwdev, REG_RXSB, BIT(4));
3568c2ecf20Sopenharmony_ci		else
3578c2ecf20Sopenharmony_ci			rtw_write32_clr(rtwdev, REG_RXSB, BIT(4));
3588c2ecf20Sopenharmony_ci
3598c2ecf20Sopenharmony_ci		val32 = rtw_read32_mask(rtwdev, REG_ADCCLK, MASKDWORD);
3608c2ecf20Sopenharmony_ci		val32 &= 0xff3ff300;
3618c2ecf20Sopenharmony_ci		val32 |= 0x20020000 | ((primary_ch_idx & 0xf) << 2) |
3628c2ecf20Sopenharmony_ci			 RTW_CHANNEL_WIDTH_40;
3638c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ADCCLK, MASKDWORD, val32);
3648c2ecf20Sopenharmony_ci
3658c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ADC160, BIT(30), 0x1);
3668c2ecf20Sopenharmony_ci		break;
3678c2ecf20Sopenharmony_ci	case RTW_CHANNEL_WIDTH_80:
3688c2ecf20Sopenharmony_ci		val32 = rtw_read32_mask(rtwdev, REG_ADCCLK, MASKDWORD);
3698c2ecf20Sopenharmony_ci		val32 &= 0xfcffcf00;
3708c2ecf20Sopenharmony_ci		val32 |= 0x40040000 | ((primary_ch_idx & 0xf) << 2) |
3718c2ecf20Sopenharmony_ci			 RTW_CHANNEL_WIDTH_80;
3728c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ADCCLK, MASKDWORD, val32);
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ADC160, BIT(30), 0x1);
3758c2ecf20Sopenharmony_ci		break;
3768c2ecf20Sopenharmony_ci	case RTW_CHANNEL_WIDTH_5:
3778c2ecf20Sopenharmony_ci		val32 = rtw_read32_mask(rtwdev, REG_ADCCLK, MASKDWORD);
3788c2ecf20Sopenharmony_ci		val32 &= 0xefcefc00;
3798c2ecf20Sopenharmony_ci		val32 |= 0x200240;
3808c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ADCCLK, MASKDWORD, val32);
3818c2ecf20Sopenharmony_ci
3828c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ADC160, BIT(30), 0x0);
3838c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ADC40, BIT(31), 0x1);
3848c2ecf20Sopenharmony_ci		break;
3858c2ecf20Sopenharmony_ci	case RTW_CHANNEL_WIDTH_10:
3868c2ecf20Sopenharmony_ci		val32 = rtw_read32_mask(rtwdev, REG_ADCCLK, MASKDWORD);
3878c2ecf20Sopenharmony_ci		val32 &= 0xefcefc00;
3888c2ecf20Sopenharmony_ci		val32 |= 0x300380;
3898c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ADCCLK, MASKDWORD, val32);
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ADC160, BIT(30), 0x0);
3928c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_ADC40, BIT(31), 0x1);
3938c2ecf20Sopenharmony_ci		break;
3948c2ecf20Sopenharmony_ci	}
3958c2ecf20Sopenharmony_ci}
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_cistatic u32 rtw8821c_get_bb_swing(struct rtw_dev *rtwdev, u8 channel)
3988c2ecf20Sopenharmony_ci{
3998c2ecf20Sopenharmony_ci	struct rtw_efuse efuse = rtwdev->efuse;
4008c2ecf20Sopenharmony_ci	u8 tx_bb_swing;
4018c2ecf20Sopenharmony_ci	u32 swing2setting[4] = {0x200, 0x16a, 0x101, 0x0b6};
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_ci	tx_bb_swing = channel <= 14 ? efuse.tx_bb_swing_setting_2g :
4048c2ecf20Sopenharmony_ci				      efuse.tx_bb_swing_setting_5g;
4058c2ecf20Sopenharmony_ci	if (tx_bb_swing > 9)
4068c2ecf20Sopenharmony_ci		tx_bb_swing = 0;
4078c2ecf20Sopenharmony_ci
4088c2ecf20Sopenharmony_ci	return swing2setting[(tx_bb_swing / 3)];
4098c2ecf20Sopenharmony_ci}
4108c2ecf20Sopenharmony_ci
4118c2ecf20Sopenharmony_cistatic void rtw8821c_set_channel_bb_swing(struct rtw_dev *rtwdev, u8 channel,
4128c2ecf20Sopenharmony_ci					  u8 bw, u8 primary_ch_idx)
4138c2ecf20Sopenharmony_ci{
4148c2ecf20Sopenharmony_ci	rtw_write32_mask(rtwdev, REG_TXSCALE_A, GENMASK(31, 21),
4158c2ecf20Sopenharmony_ci			 rtw8821c_get_bb_swing(rtwdev, channel));
4168c2ecf20Sopenharmony_ci	rtw8821c_pwrtrack_init(rtwdev);
4178c2ecf20Sopenharmony_ci}
4188c2ecf20Sopenharmony_ci
4198c2ecf20Sopenharmony_cistatic void rtw8821c_set_channel(struct rtw_dev *rtwdev, u8 channel, u8 bw,
4208c2ecf20Sopenharmony_ci				 u8 primary_chan_idx)
4218c2ecf20Sopenharmony_ci{
4228c2ecf20Sopenharmony_ci	rtw8821c_set_channel_bb(rtwdev, channel, bw, primary_chan_idx);
4238c2ecf20Sopenharmony_ci	rtw8821c_set_channel_bb_swing(rtwdev, channel, bw, primary_chan_idx);
4248c2ecf20Sopenharmony_ci	rtw_set_channel_mac(rtwdev, channel, bw, primary_chan_idx);
4258c2ecf20Sopenharmony_ci	rtw8821c_set_channel_rf(rtwdev, channel, bw);
4268c2ecf20Sopenharmony_ci	rtw8821c_set_channel_rxdfir(rtwdev, bw);
4278c2ecf20Sopenharmony_ci}
4288c2ecf20Sopenharmony_ci
4298c2ecf20Sopenharmony_cistatic void query_phy_status_page0(struct rtw_dev *rtwdev, u8 *phy_status,
4308c2ecf20Sopenharmony_ci				   struct rtw_rx_pkt_stat *pkt_stat)
4318c2ecf20Sopenharmony_ci{
4328c2ecf20Sopenharmony_ci	s8 min_rx_power = -120;
4338c2ecf20Sopenharmony_ci	u8 pwdb = GET_PHY_STAT_P0_PWDB(phy_status);
4348c2ecf20Sopenharmony_ci
4358c2ecf20Sopenharmony_ci	pkt_stat->rx_power[RF_PATH_A] = pwdb - 100;
4368c2ecf20Sopenharmony_ci	pkt_stat->rssi = rtw_phy_rf_power_2_rssi(pkt_stat->rx_power, 1);
4378c2ecf20Sopenharmony_ci	pkt_stat->bw = RTW_CHANNEL_WIDTH_20;
4388c2ecf20Sopenharmony_ci	pkt_stat->signal_power = max(pkt_stat->rx_power[RF_PATH_A],
4398c2ecf20Sopenharmony_ci				     min_rx_power);
4408c2ecf20Sopenharmony_ci}
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_cistatic void query_phy_status_page1(struct rtw_dev *rtwdev, u8 *phy_status,
4438c2ecf20Sopenharmony_ci				   struct rtw_rx_pkt_stat *pkt_stat)
4448c2ecf20Sopenharmony_ci{
4458c2ecf20Sopenharmony_ci	u8 rxsc, bw;
4468c2ecf20Sopenharmony_ci	s8 min_rx_power = -120;
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_ci	if (pkt_stat->rate > DESC_RATE11M && pkt_stat->rate < DESC_RATEMCS0)
4498c2ecf20Sopenharmony_ci		rxsc = GET_PHY_STAT_P1_L_RXSC(phy_status);
4508c2ecf20Sopenharmony_ci	else
4518c2ecf20Sopenharmony_ci		rxsc = GET_PHY_STAT_P1_HT_RXSC(phy_status);
4528c2ecf20Sopenharmony_ci
4538c2ecf20Sopenharmony_ci	if (rxsc >= 1 && rxsc <= 8)
4548c2ecf20Sopenharmony_ci		bw = RTW_CHANNEL_WIDTH_20;
4558c2ecf20Sopenharmony_ci	else if (rxsc >= 9 && rxsc <= 12)
4568c2ecf20Sopenharmony_ci		bw = RTW_CHANNEL_WIDTH_40;
4578c2ecf20Sopenharmony_ci	else if (rxsc >= 13)
4588c2ecf20Sopenharmony_ci		bw = RTW_CHANNEL_WIDTH_80;
4598c2ecf20Sopenharmony_ci	else
4608c2ecf20Sopenharmony_ci		bw = GET_PHY_STAT_P1_RF_MODE(phy_status);
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_ci	pkt_stat->rx_power[RF_PATH_A] = GET_PHY_STAT_P1_PWDB_A(phy_status) - 110;
4638c2ecf20Sopenharmony_ci	pkt_stat->rssi = rtw_phy_rf_power_2_rssi(pkt_stat->rx_power, 1);
4648c2ecf20Sopenharmony_ci	pkt_stat->bw = bw;
4658c2ecf20Sopenharmony_ci	pkt_stat->signal_power = max(pkt_stat->rx_power[RF_PATH_A],
4668c2ecf20Sopenharmony_ci				     min_rx_power);
4678c2ecf20Sopenharmony_ci}
4688c2ecf20Sopenharmony_ci
4698c2ecf20Sopenharmony_cistatic void query_phy_status(struct rtw_dev *rtwdev, u8 *phy_status,
4708c2ecf20Sopenharmony_ci			     struct rtw_rx_pkt_stat *pkt_stat)
4718c2ecf20Sopenharmony_ci{
4728c2ecf20Sopenharmony_ci	u8 page;
4738c2ecf20Sopenharmony_ci
4748c2ecf20Sopenharmony_ci	page = *phy_status & 0xf;
4758c2ecf20Sopenharmony_ci
4768c2ecf20Sopenharmony_ci	switch (page) {
4778c2ecf20Sopenharmony_ci	case 0:
4788c2ecf20Sopenharmony_ci		query_phy_status_page0(rtwdev, phy_status, pkt_stat);
4798c2ecf20Sopenharmony_ci		break;
4808c2ecf20Sopenharmony_ci	case 1:
4818c2ecf20Sopenharmony_ci		query_phy_status_page1(rtwdev, phy_status, pkt_stat);
4828c2ecf20Sopenharmony_ci		break;
4838c2ecf20Sopenharmony_ci	default:
4848c2ecf20Sopenharmony_ci		rtw_warn(rtwdev, "unused phy status page (%d)\n", page);
4858c2ecf20Sopenharmony_ci		return;
4868c2ecf20Sopenharmony_ci	}
4878c2ecf20Sopenharmony_ci}
4888c2ecf20Sopenharmony_ci
4898c2ecf20Sopenharmony_cistatic void rtw8821c_query_rx_desc(struct rtw_dev *rtwdev, u8 *rx_desc,
4908c2ecf20Sopenharmony_ci				   struct rtw_rx_pkt_stat *pkt_stat,
4918c2ecf20Sopenharmony_ci				   struct ieee80211_rx_status *rx_status)
4928c2ecf20Sopenharmony_ci{
4938c2ecf20Sopenharmony_ci	struct ieee80211_hdr *hdr;
4948c2ecf20Sopenharmony_ci	u32 desc_sz = rtwdev->chip->rx_pkt_desc_sz;
4958c2ecf20Sopenharmony_ci	u8 *phy_status = NULL;
4968c2ecf20Sopenharmony_ci
4978c2ecf20Sopenharmony_ci	memset(pkt_stat, 0, sizeof(*pkt_stat));
4988c2ecf20Sopenharmony_ci
4998c2ecf20Sopenharmony_ci	pkt_stat->phy_status = GET_RX_DESC_PHYST(rx_desc);
5008c2ecf20Sopenharmony_ci	pkt_stat->icv_err = GET_RX_DESC_ICV_ERR(rx_desc);
5018c2ecf20Sopenharmony_ci	pkt_stat->crc_err = GET_RX_DESC_CRC32(rx_desc);
5028c2ecf20Sopenharmony_ci	pkt_stat->decrypted = !GET_RX_DESC_SWDEC(rx_desc);
5038c2ecf20Sopenharmony_ci	pkt_stat->is_c2h = GET_RX_DESC_C2H(rx_desc);
5048c2ecf20Sopenharmony_ci	pkt_stat->pkt_len = GET_RX_DESC_PKT_LEN(rx_desc);
5058c2ecf20Sopenharmony_ci	pkt_stat->drv_info_sz = GET_RX_DESC_DRV_INFO_SIZE(rx_desc);
5068c2ecf20Sopenharmony_ci	pkt_stat->shift = GET_RX_DESC_SHIFT(rx_desc);
5078c2ecf20Sopenharmony_ci	pkt_stat->rate = GET_RX_DESC_RX_RATE(rx_desc);
5088c2ecf20Sopenharmony_ci	pkt_stat->cam_id = GET_RX_DESC_MACID(rx_desc);
5098c2ecf20Sopenharmony_ci	pkt_stat->ppdu_cnt = GET_RX_DESC_PPDU_CNT(rx_desc);
5108c2ecf20Sopenharmony_ci	pkt_stat->tsf_low = GET_RX_DESC_TSFL(rx_desc);
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_ci	/* drv_info_sz is in unit of 8-bytes */
5138c2ecf20Sopenharmony_ci	pkt_stat->drv_info_sz *= 8;
5148c2ecf20Sopenharmony_ci
5158c2ecf20Sopenharmony_ci	/* c2h cmd pkt's rx/phy status is not interested */
5168c2ecf20Sopenharmony_ci	if (pkt_stat->is_c2h)
5178c2ecf20Sopenharmony_ci		return;
5188c2ecf20Sopenharmony_ci
5198c2ecf20Sopenharmony_ci	hdr = (struct ieee80211_hdr *)(rx_desc + desc_sz + pkt_stat->shift +
5208c2ecf20Sopenharmony_ci				       pkt_stat->drv_info_sz);
5218c2ecf20Sopenharmony_ci	if (pkt_stat->phy_status) {
5228c2ecf20Sopenharmony_ci		phy_status = rx_desc + desc_sz + pkt_stat->shift;
5238c2ecf20Sopenharmony_ci		query_phy_status(rtwdev, phy_status, pkt_stat);
5248c2ecf20Sopenharmony_ci	}
5258c2ecf20Sopenharmony_ci
5268c2ecf20Sopenharmony_ci	rtw_rx_fill_rx_status(rtwdev, pkt_stat, hdr, rx_status, phy_status);
5278c2ecf20Sopenharmony_ci}
5288c2ecf20Sopenharmony_ci
5298c2ecf20Sopenharmony_cistatic void
5308c2ecf20Sopenharmony_cirtw8821c_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path, u8 rs)
5318c2ecf20Sopenharmony_ci{
5328c2ecf20Sopenharmony_ci	struct rtw_hal *hal = &rtwdev->hal;
5338c2ecf20Sopenharmony_ci	static const u32 offset_txagc[2] = {0x1d00, 0x1d80};
5348c2ecf20Sopenharmony_ci	static u32 phy_pwr_idx;
5358c2ecf20Sopenharmony_ci	u8 rate, rate_idx, pwr_index, shift;
5368c2ecf20Sopenharmony_ci	int j;
5378c2ecf20Sopenharmony_ci
5388c2ecf20Sopenharmony_ci	for (j = 0; j < rtw_rate_size[rs]; j++) {
5398c2ecf20Sopenharmony_ci		rate = rtw_rate_section[rs][j];
5408c2ecf20Sopenharmony_ci		pwr_index = hal->tx_pwr_tbl[path][rate];
5418c2ecf20Sopenharmony_ci		shift = rate & 0x3;
5428c2ecf20Sopenharmony_ci		phy_pwr_idx |= ((u32)pwr_index << (shift * 8));
5438c2ecf20Sopenharmony_ci		if (shift == 0x3 || rate == DESC_RATEVHT1SS_MCS9) {
5448c2ecf20Sopenharmony_ci			rate_idx = rate & 0xfc;
5458c2ecf20Sopenharmony_ci			rtw_write32(rtwdev, offset_txagc[path] + rate_idx,
5468c2ecf20Sopenharmony_ci				    phy_pwr_idx);
5478c2ecf20Sopenharmony_ci			phy_pwr_idx = 0;
5488c2ecf20Sopenharmony_ci		}
5498c2ecf20Sopenharmony_ci	}
5508c2ecf20Sopenharmony_ci}
5518c2ecf20Sopenharmony_ci
5528c2ecf20Sopenharmony_cistatic void rtw8821c_set_tx_power_index(struct rtw_dev *rtwdev)
5538c2ecf20Sopenharmony_ci{
5548c2ecf20Sopenharmony_ci	struct rtw_hal *hal = &rtwdev->hal;
5558c2ecf20Sopenharmony_ci	int rs, path;
5568c2ecf20Sopenharmony_ci
5578c2ecf20Sopenharmony_ci	for (path = 0; path < hal->rf_path_num; path++) {
5588c2ecf20Sopenharmony_ci		for (rs = 0; rs < RTW_RATE_SECTION_MAX; rs++) {
5598c2ecf20Sopenharmony_ci			if (rs == RTW_RATE_SECTION_HT_2S ||
5608c2ecf20Sopenharmony_ci			    rs == RTW_RATE_SECTION_VHT_2S)
5618c2ecf20Sopenharmony_ci				continue;
5628c2ecf20Sopenharmony_ci			rtw8821c_set_tx_power_index_by_rate(rtwdev, path, rs);
5638c2ecf20Sopenharmony_ci		}
5648c2ecf20Sopenharmony_ci	}
5658c2ecf20Sopenharmony_ci}
5668c2ecf20Sopenharmony_ci
5678c2ecf20Sopenharmony_cistatic void rtw8821c_false_alarm_statistics(struct rtw_dev *rtwdev)
5688c2ecf20Sopenharmony_ci{
5698c2ecf20Sopenharmony_ci	struct rtw_dm_info *dm_info = &rtwdev->dm_info;
5708c2ecf20Sopenharmony_ci	u32 cck_enable;
5718c2ecf20Sopenharmony_ci	u32 cck_fa_cnt;
5728c2ecf20Sopenharmony_ci	u32 ofdm_fa_cnt;
5738c2ecf20Sopenharmony_ci	u32 crc32_cnt;
5748c2ecf20Sopenharmony_ci	u32 cca32_cnt;
5758c2ecf20Sopenharmony_ci
5768c2ecf20Sopenharmony_ci	cck_enable = rtw_read32(rtwdev, REG_RXPSEL) & BIT(28);
5778c2ecf20Sopenharmony_ci	cck_fa_cnt = rtw_read16(rtwdev, REG_FA_CCK);
5788c2ecf20Sopenharmony_ci	ofdm_fa_cnt = rtw_read16(rtwdev, REG_FA_OFDM);
5798c2ecf20Sopenharmony_ci
5808c2ecf20Sopenharmony_ci	dm_info->cck_fa_cnt = cck_fa_cnt;
5818c2ecf20Sopenharmony_ci	dm_info->ofdm_fa_cnt = ofdm_fa_cnt;
5828c2ecf20Sopenharmony_ci	if (cck_enable)
5838c2ecf20Sopenharmony_ci		dm_info->total_fa_cnt += cck_fa_cnt;
5848c2ecf20Sopenharmony_ci	dm_info->total_fa_cnt = ofdm_fa_cnt;
5858c2ecf20Sopenharmony_ci
5868c2ecf20Sopenharmony_ci	crc32_cnt = rtw_read32(rtwdev, REG_CRC_CCK);
5878c2ecf20Sopenharmony_ci	dm_info->cck_ok_cnt = FIELD_GET(GENMASK(15, 0), crc32_cnt);
5888c2ecf20Sopenharmony_ci	dm_info->cck_err_cnt = FIELD_GET(GENMASK(31, 16), crc32_cnt);
5898c2ecf20Sopenharmony_ci
5908c2ecf20Sopenharmony_ci	crc32_cnt = rtw_read32(rtwdev, REG_CRC_OFDM);
5918c2ecf20Sopenharmony_ci	dm_info->ofdm_ok_cnt = FIELD_GET(GENMASK(15, 0), crc32_cnt);
5928c2ecf20Sopenharmony_ci	dm_info->ofdm_err_cnt = FIELD_GET(GENMASK(31, 16), crc32_cnt);
5938c2ecf20Sopenharmony_ci
5948c2ecf20Sopenharmony_ci	crc32_cnt = rtw_read32(rtwdev, REG_CRC_HT);
5958c2ecf20Sopenharmony_ci	dm_info->ht_ok_cnt = FIELD_GET(GENMASK(15, 0), crc32_cnt);
5968c2ecf20Sopenharmony_ci	dm_info->ht_err_cnt = FIELD_GET(GENMASK(31, 16), crc32_cnt);
5978c2ecf20Sopenharmony_ci
5988c2ecf20Sopenharmony_ci	crc32_cnt = rtw_read32(rtwdev, REG_CRC_VHT);
5998c2ecf20Sopenharmony_ci	dm_info->vht_ok_cnt = FIELD_GET(GENMASK(15, 0), crc32_cnt);
6008c2ecf20Sopenharmony_ci	dm_info->vht_err_cnt = FIELD_GET(GENMASK(31, 16), crc32_cnt);
6018c2ecf20Sopenharmony_ci
6028c2ecf20Sopenharmony_ci	cca32_cnt = rtw_read32(rtwdev, REG_CCA_OFDM);
6038c2ecf20Sopenharmony_ci	dm_info->ofdm_cca_cnt = FIELD_GET(GENMASK(31, 16), cca32_cnt);
6048c2ecf20Sopenharmony_ci	dm_info->total_cca_cnt = dm_info->ofdm_cca_cnt;
6058c2ecf20Sopenharmony_ci	if (cck_enable) {
6068c2ecf20Sopenharmony_ci		cca32_cnt = rtw_read32(rtwdev, REG_CCA_CCK);
6078c2ecf20Sopenharmony_ci		dm_info->cck_cca_cnt = FIELD_GET(GENMASK(15, 0), cca32_cnt);
6088c2ecf20Sopenharmony_ci		dm_info->total_cca_cnt += dm_info->cck_cca_cnt;
6098c2ecf20Sopenharmony_ci	}
6108c2ecf20Sopenharmony_ci
6118c2ecf20Sopenharmony_ci	rtw_write32_set(rtwdev, REG_FAS, BIT(17));
6128c2ecf20Sopenharmony_ci	rtw_write32_clr(rtwdev, REG_FAS, BIT(17));
6138c2ecf20Sopenharmony_ci	rtw_write32_clr(rtwdev, REG_RXDESC, BIT(15));
6148c2ecf20Sopenharmony_ci	rtw_write32_set(rtwdev, REG_RXDESC, BIT(15));
6158c2ecf20Sopenharmony_ci	rtw_write32_set(rtwdev, REG_CNTRST, BIT(0));
6168c2ecf20Sopenharmony_ci	rtw_write32_clr(rtwdev, REG_CNTRST, BIT(0));
6178c2ecf20Sopenharmony_ci}
6188c2ecf20Sopenharmony_ci
6198c2ecf20Sopenharmony_cistatic void rtw8821c_do_iqk(struct rtw_dev *rtwdev)
6208c2ecf20Sopenharmony_ci{
6218c2ecf20Sopenharmony_ci	static int do_iqk_cnt;
6228c2ecf20Sopenharmony_ci	struct rtw_iqk_para para = {.clear = 0, .segment_iqk = 0};
6238c2ecf20Sopenharmony_ci	u32 rf_reg, iqk_fail_mask;
6248c2ecf20Sopenharmony_ci	int counter;
6258c2ecf20Sopenharmony_ci	bool reload;
6268c2ecf20Sopenharmony_ci
6278c2ecf20Sopenharmony_ci	if (rtw_is_assoc(rtwdev))
6288c2ecf20Sopenharmony_ci		para.segment_iqk = 1;
6298c2ecf20Sopenharmony_ci
6308c2ecf20Sopenharmony_ci	rtw_fw_do_iqk(rtwdev, &para);
6318c2ecf20Sopenharmony_ci
6328c2ecf20Sopenharmony_ci	for (counter = 0; counter < 300; counter++) {
6338c2ecf20Sopenharmony_ci		rf_reg = rtw_read_rf(rtwdev, RF_PATH_A, RF_DTXLOK, RFREG_MASK);
6348c2ecf20Sopenharmony_ci		if (rf_reg == 0xabcde)
6358c2ecf20Sopenharmony_ci			break;
6368c2ecf20Sopenharmony_ci		msleep(20);
6378c2ecf20Sopenharmony_ci	}
6388c2ecf20Sopenharmony_ci	rtw_write_rf(rtwdev, RF_PATH_A, RF_DTXLOK, RFREG_MASK, 0x0);
6398c2ecf20Sopenharmony_ci
6408c2ecf20Sopenharmony_ci	reload = !!rtw_read32_mask(rtwdev, REG_IQKFAILMSK, BIT(16));
6418c2ecf20Sopenharmony_ci	iqk_fail_mask = rtw_read32_mask(rtwdev, REG_IQKFAILMSK, GENMASK(7, 0));
6428c2ecf20Sopenharmony_ci	rtw_dbg(rtwdev, RTW_DBG_PHY,
6438c2ecf20Sopenharmony_ci		"iqk counter=%d reload=%d do_iqk_cnt=%d n_iqk_fail(mask)=0x%02x\n",
6448c2ecf20Sopenharmony_ci		counter, reload, ++do_iqk_cnt, iqk_fail_mask);
6458c2ecf20Sopenharmony_ci}
6468c2ecf20Sopenharmony_ci
6478c2ecf20Sopenharmony_cistatic void rtw8821c_phy_calibration(struct rtw_dev *rtwdev)
6488c2ecf20Sopenharmony_ci{
6498c2ecf20Sopenharmony_ci	rtw8821c_do_iqk(rtwdev);
6508c2ecf20Sopenharmony_ci}
6518c2ecf20Sopenharmony_ci
6528c2ecf20Sopenharmony_ci/* for coex */
6538c2ecf20Sopenharmony_cistatic void rtw8821c_coex_cfg_init(struct rtw_dev *rtwdev)
6548c2ecf20Sopenharmony_ci{
6558c2ecf20Sopenharmony_ci	/* enable TBTT nterrupt */
6568c2ecf20Sopenharmony_ci	rtw_write8_set(rtwdev, REG_BCN_CTRL, BIT_EN_BCN_FUNCTION);
6578c2ecf20Sopenharmony_ci
6588c2ecf20Sopenharmony_ci	/* BT report packet sample rate */
6598c2ecf20Sopenharmony_ci	rtw_write8_mask(rtwdev, REG_BT_TDMA_TIME, SAMPLE_RATE_MASK,
6608c2ecf20Sopenharmony_ci			SAMPLE_RATE);
6618c2ecf20Sopenharmony_ci
6628c2ecf20Sopenharmony_ci	/* enable BT counter statistics */
6638c2ecf20Sopenharmony_ci	rtw_write8(rtwdev, REG_BT_STAT_CTRL, BT_CNT_ENABLE);
6648c2ecf20Sopenharmony_ci
6658c2ecf20Sopenharmony_ci	/* enable PTA (3-wire function form BT side) */
6668c2ecf20Sopenharmony_ci	rtw_write32_set(rtwdev, REG_GPIO_MUXCFG, BIT_BT_PTA_EN);
6678c2ecf20Sopenharmony_ci	rtw_write32_set(rtwdev, REG_GPIO_MUXCFG, BIT_PO_BT_PTA_PINS);
6688c2ecf20Sopenharmony_ci
6698c2ecf20Sopenharmony_ci	/* enable PTA (tx/rx signal form WiFi side) */
6708c2ecf20Sopenharmony_ci	rtw_write8_set(rtwdev, REG_QUEUE_CTRL, BIT_PTA_WL_TX_EN);
6718c2ecf20Sopenharmony_ci	/* wl tx signal to PTA not case EDCCA */
6728c2ecf20Sopenharmony_ci	rtw_write8_clr(rtwdev, REG_QUEUE_CTRL, BIT_PTA_EDCCA_EN);
6738c2ecf20Sopenharmony_ci	/* GNT_BT=1 while select both */
6748c2ecf20Sopenharmony_ci	rtw_write16_set(rtwdev, REG_BT_COEX_V2, BIT_GNT_BT_POLARITY);
6758c2ecf20Sopenharmony_ci
6768c2ecf20Sopenharmony_ci	/* beacon queue always hi-pri  */
6778c2ecf20Sopenharmony_ci	rtw_write8_mask(rtwdev, REG_BT_COEX_TABLE_H + 3, BIT_BCN_QUEUE,
6788c2ecf20Sopenharmony_ci			BCN_PRI_EN);
6798c2ecf20Sopenharmony_ci}
6808c2ecf20Sopenharmony_ci
6818c2ecf20Sopenharmony_cistatic void rtw8821c_coex_cfg_ant_switch(struct rtw_dev *rtwdev, u8 ctrl_type,
6828c2ecf20Sopenharmony_ci					 u8 pos_type)
6838c2ecf20Sopenharmony_ci{
6848c2ecf20Sopenharmony_ci	struct rtw_coex *coex = &rtwdev->coex;
6858c2ecf20Sopenharmony_ci	struct rtw_coex_dm *coex_dm = &coex->dm;
6868c2ecf20Sopenharmony_ci	struct rtw_coex_rfe *coex_rfe = &coex->rfe;
6878c2ecf20Sopenharmony_ci	u32 switch_status = FIELD_PREP(CTRL_TYPE_MASK, ctrl_type) | pos_type;
6888c2ecf20Sopenharmony_ci	bool polarity_inverse;
6898c2ecf20Sopenharmony_ci	u8 regval = 0;
6908c2ecf20Sopenharmony_ci
6918c2ecf20Sopenharmony_ci	if (switch_status == coex_dm->cur_switch_status)
6928c2ecf20Sopenharmony_ci		return;
6938c2ecf20Sopenharmony_ci
6948c2ecf20Sopenharmony_ci	coex_dm->cur_switch_status = switch_status;
6958c2ecf20Sopenharmony_ci
6968c2ecf20Sopenharmony_ci	if (coex_rfe->ant_switch_diversity &&
6978c2ecf20Sopenharmony_ci	    ctrl_type == COEX_SWITCH_CTRL_BY_BBSW)
6988c2ecf20Sopenharmony_ci		ctrl_type = COEX_SWITCH_CTRL_BY_ANTDIV;
6998c2ecf20Sopenharmony_ci
7008c2ecf20Sopenharmony_ci	polarity_inverse = (coex_rfe->ant_switch_polarity == 1);
7018c2ecf20Sopenharmony_ci
7028c2ecf20Sopenharmony_ci	switch (ctrl_type) {
7038c2ecf20Sopenharmony_ci	default:
7048c2ecf20Sopenharmony_ci	case COEX_SWITCH_CTRL_BY_BBSW:
7058c2ecf20Sopenharmony_ci		rtw_write32_clr(rtwdev, REG_LED_CFG, BIT_DPDT_SEL_EN);
7068c2ecf20Sopenharmony_ci		rtw_write32_set(rtwdev, REG_LED_CFG, BIT_DPDT_WL_SEL);
7078c2ecf20Sopenharmony_ci		/* BB SW, DPDT use RFE_ctrl8 and RFE_ctrl9 as ctrl pin */
7088c2ecf20Sopenharmony_ci		rtw_write8_mask(rtwdev, REG_RFE_CTRL8, BIT_MASK_RFE_SEL89,
7098c2ecf20Sopenharmony_ci				DPDT_CTRL_PIN);
7108c2ecf20Sopenharmony_ci
7118c2ecf20Sopenharmony_ci		if (pos_type == COEX_SWITCH_TO_WLG_BT) {
7128c2ecf20Sopenharmony_ci			if (coex_rfe->rfe_module_type != 0x4 &&
7138c2ecf20Sopenharmony_ci			    coex_rfe->rfe_module_type != 0x2)
7148c2ecf20Sopenharmony_ci				regval = 0x3;
7158c2ecf20Sopenharmony_ci			else
7168c2ecf20Sopenharmony_ci				regval = (!polarity_inverse ? 0x2 : 0x1);
7178c2ecf20Sopenharmony_ci		} else if (pos_type == COEX_SWITCH_TO_WLG) {
7188c2ecf20Sopenharmony_ci			regval = (!polarity_inverse ? 0x2 : 0x1);
7198c2ecf20Sopenharmony_ci		} else {
7208c2ecf20Sopenharmony_ci			regval = (!polarity_inverse ? 0x1 : 0x2);
7218c2ecf20Sopenharmony_ci		}
7228c2ecf20Sopenharmony_ci
7238c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_RFE_CTRL8, BIT_MASK_R_RFE_SEL_15,
7248c2ecf20Sopenharmony_ci				 regval);
7258c2ecf20Sopenharmony_ci		break;
7268c2ecf20Sopenharmony_ci	case COEX_SWITCH_CTRL_BY_PTA:
7278c2ecf20Sopenharmony_ci		rtw_write32_clr(rtwdev, REG_LED_CFG, BIT_DPDT_SEL_EN);
7288c2ecf20Sopenharmony_ci		rtw_write32_set(rtwdev, REG_LED_CFG, BIT_DPDT_WL_SEL);
7298c2ecf20Sopenharmony_ci		/* PTA,  DPDT use RFE_ctrl8 and RFE_ctrl9 as ctrl pin */
7308c2ecf20Sopenharmony_ci		rtw_write8_mask(rtwdev, REG_RFE_CTRL8, BIT_MASK_RFE_SEL89,
7318c2ecf20Sopenharmony_ci				PTA_CTRL_PIN);
7328c2ecf20Sopenharmony_ci
7338c2ecf20Sopenharmony_ci		regval = (!polarity_inverse ? 0x2 : 0x1);
7348c2ecf20Sopenharmony_ci		rtw_write32_mask(rtwdev, REG_RFE_CTRL8, BIT_MASK_R_RFE_SEL_15,
7358c2ecf20Sopenharmony_ci				 regval);
7368c2ecf20Sopenharmony_ci		break;
7378c2ecf20Sopenharmony_ci	case COEX_SWITCH_CTRL_BY_ANTDIV:
7388c2ecf20Sopenharmony_ci		rtw_write32_clr(rtwdev, REG_LED_CFG, BIT_DPDT_SEL_EN);
7398c2ecf20Sopenharmony_ci		rtw_write32_set(rtwdev, REG_LED_CFG, BIT_DPDT_WL_SEL);
7408c2ecf20Sopenharmony_ci		rtw_write8_mask(rtwdev, REG_RFE_CTRL8, BIT_MASK_RFE_SEL89,
7418c2ecf20Sopenharmony_ci				ANTDIC_CTRL_PIN);
7428c2ecf20Sopenharmony_ci		break;
7438c2ecf20Sopenharmony_ci	case COEX_SWITCH_CTRL_BY_MAC:
7448c2ecf20Sopenharmony_ci		rtw_write32_set(rtwdev, REG_LED_CFG, BIT_DPDT_SEL_EN);
7458c2ecf20Sopenharmony_ci
7468c2ecf20Sopenharmony_ci		regval = (!polarity_inverse ? 0x0 : 0x1);
7478c2ecf20Sopenharmony_ci		rtw_write8_mask(rtwdev, REG_PAD_CTRL1, BIT_SW_DPDT_SEL_DATA,
7488c2ecf20Sopenharmony_ci				regval);
7498c2ecf20Sopenharmony_ci		break;
7508c2ecf20Sopenharmony_ci	case COEX_SWITCH_CTRL_BY_FW:
7518c2ecf20Sopenharmony_ci		rtw_write32_clr(rtwdev, REG_LED_CFG, BIT_DPDT_SEL_EN);
7528c2ecf20Sopenharmony_ci		rtw_write32_set(rtwdev, REG_LED_CFG, BIT_DPDT_WL_SEL);
7538c2ecf20Sopenharmony_ci		break;
7548c2ecf20Sopenharmony_ci	case COEX_SWITCH_CTRL_BY_BT:
7558c2ecf20Sopenharmony_ci		rtw_write32_clr(rtwdev, REG_LED_CFG, BIT_DPDT_SEL_EN);
7568c2ecf20Sopenharmony_ci		rtw_write32_clr(rtwdev, REG_LED_CFG, BIT_DPDT_WL_SEL);
7578c2ecf20Sopenharmony_ci		break;
7588c2ecf20Sopenharmony_ci	}
7598c2ecf20Sopenharmony_ci
7608c2ecf20Sopenharmony_ci	if (ctrl_type == COEX_SWITCH_CTRL_BY_BT) {
7618c2ecf20Sopenharmony_ci		rtw_write8_clr(rtwdev, REG_CTRL_TYPE, BIT_CTRL_TYPE1);
7628c2ecf20Sopenharmony_ci		rtw_write8_clr(rtwdev, REG_CTRL_TYPE, BIT_CTRL_TYPE2);
7638c2ecf20Sopenharmony_ci	} else {
7648c2ecf20Sopenharmony_ci		rtw_write8_set(rtwdev, REG_CTRL_TYPE, BIT_CTRL_TYPE1);
7658c2ecf20Sopenharmony_ci		rtw_write8_set(rtwdev, REG_CTRL_TYPE, BIT_CTRL_TYPE2);
7668c2ecf20Sopenharmony_ci	}
7678c2ecf20Sopenharmony_ci}
7688c2ecf20Sopenharmony_ci
7698c2ecf20Sopenharmony_cistatic void rtw8821c_coex_cfg_gnt_fix(struct rtw_dev *rtwdev)
7708c2ecf20Sopenharmony_ci{}
7718c2ecf20Sopenharmony_ci
7728c2ecf20Sopenharmony_cistatic void rtw8821c_coex_cfg_gnt_debug(struct rtw_dev *rtwdev)
7738c2ecf20Sopenharmony_ci{
7748c2ecf20Sopenharmony_ci	rtw_write32_clr(rtwdev, REG_PAD_CTRL1, BIT_BTGP_SPI_EN);
7758c2ecf20Sopenharmony_ci	rtw_write32_clr(rtwdev, REG_PAD_CTRL1, BIT_BTGP_JTAG_EN);
7768c2ecf20Sopenharmony_ci	rtw_write32_clr(rtwdev, REG_GPIO_MUXCFG, BIT_FSPI_EN);
7778c2ecf20Sopenharmony_ci	rtw_write32_clr(rtwdev, REG_PAD_CTRL1, BIT_LED1DIS);
7788c2ecf20Sopenharmony_ci	rtw_write32_clr(rtwdev, REG_SYS_SDIO_CTRL, BIT_SDIO_INT);
7798c2ecf20Sopenharmony_ci	rtw_write32_clr(rtwdev, REG_SYS_SDIO_CTRL, BIT_DBG_GNT_WL_BT);
7808c2ecf20Sopenharmony_ci}
7818c2ecf20Sopenharmony_ci
7828c2ecf20Sopenharmony_cistatic void rtw8821c_coex_cfg_rfe_type(struct rtw_dev *rtwdev)
7838c2ecf20Sopenharmony_ci{
7848c2ecf20Sopenharmony_ci	struct rtw_coex *coex = &rtwdev->coex;
7858c2ecf20Sopenharmony_ci	struct rtw_coex_rfe *coex_rfe = &coex->rfe;
7868c2ecf20Sopenharmony_ci	struct rtw_efuse *efuse = &rtwdev->efuse;
7878c2ecf20Sopenharmony_ci
7888c2ecf20Sopenharmony_ci	coex_rfe->rfe_module_type = efuse->rfe_option;
7898c2ecf20Sopenharmony_ci	coex_rfe->ant_switch_polarity = 0;
7908c2ecf20Sopenharmony_ci	coex_rfe->ant_switch_exist = true;
7918c2ecf20Sopenharmony_ci	coex_rfe->wlg_at_btg = false;
7928c2ecf20Sopenharmony_ci
7938c2ecf20Sopenharmony_ci	switch (coex_rfe->rfe_module_type) {
7948c2ecf20Sopenharmony_ci	case 0:
7958c2ecf20Sopenharmony_ci	case 8:
7968c2ecf20Sopenharmony_ci	case 1:
7978c2ecf20Sopenharmony_ci	case 9:  /* 1-Ant, Main, WLG */
7988c2ecf20Sopenharmony_ci	default: /* 2-Ant, DPDT, WLG */
7998c2ecf20Sopenharmony_ci		break;
8008c2ecf20Sopenharmony_ci	case 2:
8018c2ecf20Sopenharmony_ci	case 10: /* 1-Ant, Main, BTG */
8028c2ecf20Sopenharmony_ci	case 7:
8038c2ecf20Sopenharmony_ci	case 15: /* 2-Ant, DPDT, BTG */
8048c2ecf20Sopenharmony_ci		coex_rfe->wlg_at_btg = true;
8058c2ecf20Sopenharmony_ci		break;
8068c2ecf20Sopenharmony_ci	case 3:
8078c2ecf20Sopenharmony_ci	case 11: /* 1-Ant, Aux, WLG */
8088c2ecf20Sopenharmony_ci		coex_rfe->ant_switch_polarity = 1;
8098c2ecf20Sopenharmony_ci		break;
8108c2ecf20Sopenharmony_ci	case 4:
8118c2ecf20Sopenharmony_ci	case 12: /* 1-Ant, Aux, BTG */
8128c2ecf20Sopenharmony_ci		coex_rfe->wlg_at_btg = true;
8138c2ecf20Sopenharmony_ci		coex_rfe->ant_switch_polarity = 1;
8148c2ecf20Sopenharmony_ci		break;
8158c2ecf20Sopenharmony_ci	case 5:
8168c2ecf20Sopenharmony_ci	case 13: /* 2-Ant, no switch, WLG */
8178c2ecf20Sopenharmony_ci	case 6:
8188c2ecf20Sopenharmony_ci	case 14: /* 2-Ant, no antenna switch, WLG */
8198c2ecf20Sopenharmony_ci		coex_rfe->ant_switch_exist = false;
8208c2ecf20Sopenharmony_ci		break;
8218c2ecf20Sopenharmony_ci	}
8228c2ecf20Sopenharmony_ci}
8238c2ecf20Sopenharmony_ci
8248c2ecf20Sopenharmony_cistatic void rtw8821c_coex_cfg_wl_tx_power(struct rtw_dev *rtwdev, u8 wl_pwr)
8258c2ecf20Sopenharmony_ci{
8268c2ecf20Sopenharmony_ci	struct rtw_coex *coex = &rtwdev->coex;
8278c2ecf20Sopenharmony_ci	struct rtw_coex_dm *coex_dm = &coex->dm;
8288c2ecf20Sopenharmony_ci	struct rtw_efuse *efuse = &rtwdev->efuse;
8298c2ecf20Sopenharmony_ci	bool share_ant = efuse->share_ant;
8308c2ecf20Sopenharmony_ci
8318c2ecf20Sopenharmony_ci	if (share_ant)
8328c2ecf20Sopenharmony_ci		return;
8338c2ecf20Sopenharmony_ci
8348c2ecf20Sopenharmony_ci	if (wl_pwr == coex_dm->cur_wl_pwr_lvl)
8358c2ecf20Sopenharmony_ci		return;
8368c2ecf20Sopenharmony_ci
8378c2ecf20Sopenharmony_ci	coex_dm->cur_wl_pwr_lvl = wl_pwr;
8388c2ecf20Sopenharmony_ci}
8398c2ecf20Sopenharmony_ci
8408c2ecf20Sopenharmony_cistatic void rtw8821c_coex_cfg_wl_rx_gain(struct rtw_dev *rtwdev, bool low_gain)
8418c2ecf20Sopenharmony_ci{}
8428c2ecf20Sopenharmony_ci
8438c2ecf20Sopenharmony_cistatic void
8448c2ecf20Sopenharmony_cirtw8821c_txagc_swing_offset(struct rtw_dev *rtwdev, u8 pwr_idx_offset,
8458c2ecf20Sopenharmony_ci			    s8 pwr_idx_offset_lower,
8468c2ecf20Sopenharmony_ci			    s8 *txagc_idx, u8 *swing_idx)
8478c2ecf20Sopenharmony_ci{
8488c2ecf20Sopenharmony_ci	struct rtw_dm_info *dm_info = &rtwdev->dm_info;
8498c2ecf20Sopenharmony_ci	s8 delta_pwr_idx = dm_info->delta_power_index[RF_PATH_A];
8508c2ecf20Sopenharmony_ci	u8 swing_upper_bound = dm_info->default_ofdm_index + 10;
8518c2ecf20Sopenharmony_ci	u8 swing_lower_bound = 0;
8528c2ecf20Sopenharmony_ci	u8 max_pwr_idx_offset = 0xf;
8538c2ecf20Sopenharmony_ci	s8 agc_index = 0;
8548c2ecf20Sopenharmony_ci	u8 swing_index = dm_info->default_ofdm_index;
8558c2ecf20Sopenharmony_ci
8568c2ecf20Sopenharmony_ci	pwr_idx_offset = min_t(u8, pwr_idx_offset, max_pwr_idx_offset);
8578c2ecf20Sopenharmony_ci	pwr_idx_offset_lower = max_t(s8, pwr_idx_offset_lower, -15);
8588c2ecf20Sopenharmony_ci
8598c2ecf20Sopenharmony_ci	if (delta_pwr_idx >= 0) {
8608c2ecf20Sopenharmony_ci		if (delta_pwr_idx <= pwr_idx_offset) {
8618c2ecf20Sopenharmony_ci			agc_index = delta_pwr_idx;
8628c2ecf20Sopenharmony_ci			swing_index = dm_info->default_ofdm_index;
8638c2ecf20Sopenharmony_ci		} else if (delta_pwr_idx > pwr_idx_offset) {
8648c2ecf20Sopenharmony_ci			agc_index = pwr_idx_offset;
8658c2ecf20Sopenharmony_ci			swing_index = dm_info->default_ofdm_index +
8668c2ecf20Sopenharmony_ci					delta_pwr_idx - pwr_idx_offset;
8678c2ecf20Sopenharmony_ci			swing_index = min_t(u8, swing_index, swing_upper_bound);
8688c2ecf20Sopenharmony_ci		}
8698c2ecf20Sopenharmony_ci	} else if (delta_pwr_idx < 0) {
8708c2ecf20Sopenharmony_ci		if (delta_pwr_idx >= pwr_idx_offset_lower) {
8718c2ecf20Sopenharmony_ci			agc_index = delta_pwr_idx;
8728c2ecf20Sopenharmony_ci			swing_index = dm_info->default_ofdm_index;
8738c2ecf20Sopenharmony_ci		} else if (delta_pwr_idx < pwr_idx_offset_lower) {
8748c2ecf20Sopenharmony_ci			if (dm_info->default_ofdm_index >
8758c2ecf20Sopenharmony_ci				(pwr_idx_offset_lower - delta_pwr_idx))
8768c2ecf20Sopenharmony_ci				swing_index = dm_info->default_ofdm_index +
8778c2ecf20Sopenharmony_ci					delta_pwr_idx - pwr_idx_offset_lower;
8788c2ecf20Sopenharmony_ci			else
8798c2ecf20Sopenharmony_ci				swing_index = swing_lower_bound;
8808c2ecf20Sopenharmony_ci
8818c2ecf20Sopenharmony_ci			agc_index = pwr_idx_offset_lower;
8828c2ecf20Sopenharmony_ci		}
8838c2ecf20Sopenharmony_ci	}
8848c2ecf20Sopenharmony_ci
8858c2ecf20Sopenharmony_ci	if (swing_index >= ARRAY_SIZE(rtw8821c_txscale_tbl)) {
8868c2ecf20Sopenharmony_ci		rtw_warn(rtwdev, "swing index overflow\n");
8878c2ecf20Sopenharmony_ci		swing_index = ARRAY_SIZE(rtw8821c_txscale_tbl) - 1;
8888c2ecf20Sopenharmony_ci	}
8898c2ecf20Sopenharmony_ci
8908c2ecf20Sopenharmony_ci	*txagc_idx = agc_index;
8918c2ecf20Sopenharmony_ci	*swing_idx = swing_index;
8928c2ecf20Sopenharmony_ci}
8938c2ecf20Sopenharmony_ci
8948c2ecf20Sopenharmony_cistatic void rtw8821c_pwrtrack_set_pwr(struct rtw_dev *rtwdev, u8 pwr_idx_offset,
8958c2ecf20Sopenharmony_ci				      s8 pwr_idx_offset_lower)
8968c2ecf20Sopenharmony_ci{
8978c2ecf20Sopenharmony_ci	s8 txagc_idx;
8988c2ecf20Sopenharmony_ci	u8 swing_idx;
8998c2ecf20Sopenharmony_ci
9008c2ecf20Sopenharmony_ci	rtw8821c_txagc_swing_offset(rtwdev, pwr_idx_offset, pwr_idx_offset_lower,
9018c2ecf20Sopenharmony_ci				    &txagc_idx, &swing_idx);
9028c2ecf20Sopenharmony_ci	rtw_write32_mask(rtwdev, REG_TXAGCIDX, GENMASK(6, 1), txagc_idx);
9038c2ecf20Sopenharmony_ci	rtw_write32_mask(rtwdev, REG_TXSCALE_A, GENMASK(31, 21),
9048c2ecf20Sopenharmony_ci			 rtw8821c_txscale_tbl[swing_idx]);
9058c2ecf20Sopenharmony_ci}
9068c2ecf20Sopenharmony_ci
9078c2ecf20Sopenharmony_cistatic void rtw8821c_pwrtrack_set(struct rtw_dev *rtwdev)
9088c2ecf20Sopenharmony_ci{
9098c2ecf20Sopenharmony_ci	struct rtw_dm_info *dm_info = &rtwdev->dm_info;
9108c2ecf20Sopenharmony_ci	u8 pwr_idx_offset, tx_pwr_idx;
9118c2ecf20Sopenharmony_ci	s8 pwr_idx_offset_lower;
9128c2ecf20Sopenharmony_ci	u8 channel = rtwdev->hal.current_channel;
9138c2ecf20Sopenharmony_ci	u8 band_width = rtwdev->hal.current_band_width;
9148c2ecf20Sopenharmony_ci	u8 regd = rtwdev->regd.txpwr_regd;
9158c2ecf20Sopenharmony_ci	u8 tx_rate = dm_info->tx_rate;
9168c2ecf20Sopenharmony_ci	u8 max_pwr_idx = rtwdev->chip->max_power_index;
9178c2ecf20Sopenharmony_ci
9188c2ecf20Sopenharmony_ci	tx_pwr_idx = rtw_phy_get_tx_power_index(rtwdev, RF_PATH_A, tx_rate,
9198c2ecf20Sopenharmony_ci						band_width, channel, regd);
9208c2ecf20Sopenharmony_ci
9218c2ecf20Sopenharmony_ci	tx_pwr_idx = min_t(u8, tx_pwr_idx, max_pwr_idx);
9228c2ecf20Sopenharmony_ci
9238c2ecf20Sopenharmony_ci	pwr_idx_offset = max_pwr_idx - tx_pwr_idx;
9248c2ecf20Sopenharmony_ci	pwr_idx_offset_lower = 0 - tx_pwr_idx;
9258c2ecf20Sopenharmony_ci
9268c2ecf20Sopenharmony_ci	rtw8821c_pwrtrack_set_pwr(rtwdev, pwr_idx_offset, pwr_idx_offset_lower);
9278c2ecf20Sopenharmony_ci}
9288c2ecf20Sopenharmony_ci
9298c2ecf20Sopenharmony_cistatic void rtw8821c_phy_pwrtrack(struct rtw_dev *rtwdev)
9308c2ecf20Sopenharmony_ci{
9318c2ecf20Sopenharmony_ci	struct rtw_dm_info *dm_info = &rtwdev->dm_info;
9328c2ecf20Sopenharmony_ci	struct rtw_swing_table swing_table;
9338c2ecf20Sopenharmony_ci	u8 thermal_value, delta;
9348c2ecf20Sopenharmony_ci
9358c2ecf20Sopenharmony_ci	rtw_phy_config_swing_table(rtwdev, &swing_table);
9368c2ecf20Sopenharmony_ci
9378c2ecf20Sopenharmony_ci	if (rtwdev->efuse.thermal_meter[0] == 0xff)
9388c2ecf20Sopenharmony_ci		return;
9398c2ecf20Sopenharmony_ci
9408c2ecf20Sopenharmony_ci	thermal_value = rtw_read_rf(rtwdev, RF_PATH_A, RF_T_METER, 0xfc00);
9418c2ecf20Sopenharmony_ci
9428c2ecf20Sopenharmony_ci	rtw_phy_pwrtrack_avg(rtwdev, thermal_value, RF_PATH_A);
9438c2ecf20Sopenharmony_ci
9448c2ecf20Sopenharmony_ci	if (dm_info->pwr_trk_init_trigger)
9458c2ecf20Sopenharmony_ci		dm_info->pwr_trk_init_trigger = false;
9468c2ecf20Sopenharmony_ci	else if (!rtw_phy_pwrtrack_thermal_changed(rtwdev, thermal_value,
9478c2ecf20Sopenharmony_ci						   RF_PATH_A))
9488c2ecf20Sopenharmony_ci		goto iqk;
9498c2ecf20Sopenharmony_ci
9508c2ecf20Sopenharmony_ci	delta = rtw_phy_pwrtrack_get_delta(rtwdev, RF_PATH_A);
9518c2ecf20Sopenharmony_ci
9528c2ecf20Sopenharmony_ci	delta = min_t(u8, delta, RTW_PWR_TRK_TBL_SZ - 1);
9538c2ecf20Sopenharmony_ci
9548c2ecf20Sopenharmony_ci	dm_info->delta_power_index[RF_PATH_A] =
9558c2ecf20Sopenharmony_ci		rtw_phy_pwrtrack_get_pwridx(rtwdev, &swing_table, RF_PATH_A,
9568c2ecf20Sopenharmony_ci					    RF_PATH_A, delta);
9578c2ecf20Sopenharmony_ci	if (dm_info->delta_power_index[RF_PATH_A] ==
9588c2ecf20Sopenharmony_ci			dm_info->delta_power_index_last[RF_PATH_A])
9598c2ecf20Sopenharmony_ci		goto iqk;
9608c2ecf20Sopenharmony_ci	else
9618c2ecf20Sopenharmony_ci		dm_info->delta_power_index_last[RF_PATH_A] =
9628c2ecf20Sopenharmony_ci			dm_info->delta_power_index[RF_PATH_A];
9638c2ecf20Sopenharmony_ci	rtw8821c_pwrtrack_set(rtwdev);
9648c2ecf20Sopenharmony_ci
9658c2ecf20Sopenharmony_ciiqk:
9668c2ecf20Sopenharmony_ci	if (rtw_phy_pwrtrack_need_iqk(rtwdev))
9678c2ecf20Sopenharmony_ci		rtw8821c_do_iqk(rtwdev);
9688c2ecf20Sopenharmony_ci}
9698c2ecf20Sopenharmony_ci
9708c2ecf20Sopenharmony_cistatic void rtw8821c_pwr_track(struct rtw_dev *rtwdev)
9718c2ecf20Sopenharmony_ci{
9728c2ecf20Sopenharmony_ci	struct rtw_efuse *efuse = &rtwdev->efuse;
9738c2ecf20Sopenharmony_ci	struct rtw_dm_info *dm_info = &rtwdev->dm_info;
9748c2ecf20Sopenharmony_ci
9758c2ecf20Sopenharmony_ci	if (efuse->power_track_type != 0)
9768c2ecf20Sopenharmony_ci		return;
9778c2ecf20Sopenharmony_ci
9788c2ecf20Sopenharmony_ci	if (!dm_info->pwr_trk_triggered) {
9798c2ecf20Sopenharmony_ci		rtw_write_rf(rtwdev, RF_PATH_A, RF_T_METER,
9808c2ecf20Sopenharmony_ci			     GENMASK(17, 16), 0x03);
9818c2ecf20Sopenharmony_ci		dm_info->pwr_trk_triggered = true;
9828c2ecf20Sopenharmony_ci		return;
9838c2ecf20Sopenharmony_ci	}
9848c2ecf20Sopenharmony_ci
9858c2ecf20Sopenharmony_ci	rtw8821c_phy_pwrtrack(rtwdev);
9868c2ecf20Sopenharmony_ci	dm_info->pwr_trk_triggered = false;
9878c2ecf20Sopenharmony_ci}
9888c2ecf20Sopenharmony_ci
9898c2ecf20Sopenharmony_cistatic void rtw8821c_bf_config_bfee_su(struct rtw_dev *rtwdev,
9908c2ecf20Sopenharmony_ci				       struct rtw_vif *vif,
9918c2ecf20Sopenharmony_ci				       struct rtw_bfee *bfee, bool enable)
9928c2ecf20Sopenharmony_ci{
9938c2ecf20Sopenharmony_ci	if (enable)
9948c2ecf20Sopenharmony_ci		rtw_bf_enable_bfee_su(rtwdev, vif, bfee);
9958c2ecf20Sopenharmony_ci	else
9968c2ecf20Sopenharmony_ci		rtw_bf_remove_bfee_su(rtwdev, bfee);
9978c2ecf20Sopenharmony_ci}
9988c2ecf20Sopenharmony_ci
9998c2ecf20Sopenharmony_cistatic void rtw8821c_bf_config_bfee_mu(struct rtw_dev *rtwdev,
10008c2ecf20Sopenharmony_ci				       struct rtw_vif *vif,
10018c2ecf20Sopenharmony_ci				       struct rtw_bfee *bfee, bool enable)
10028c2ecf20Sopenharmony_ci{
10038c2ecf20Sopenharmony_ci	if (enable)
10048c2ecf20Sopenharmony_ci		rtw_bf_enable_bfee_mu(rtwdev, vif, bfee);
10058c2ecf20Sopenharmony_ci	else
10068c2ecf20Sopenharmony_ci		rtw_bf_remove_bfee_mu(rtwdev, bfee);
10078c2ecf20Sopenharmony_ci}
10088c2ecf20Sopenharmony_ci
10098c2ecf20Sopenharmony_cistatic void rtw8821c_bf_config_bfee(struct rtw_dev *rtwdev, struct rtw_vif *vif,
10108c2ecf20Sopenharmony_ci				    struct rtw_bfee *bfee, bool enable)
10118c2ecf20Sopenharmony_ci{
10128c2ecf20Sopenharmony_ci	if (bfee->role == RTW_BFEE_SU)
10138c2ecf20Sopenharmony_ci		rtw8821c_bf_config_bfee_su(rtwdev, vif, bfee, enable);
10148c2ecf20Sopenharmony_ci	else if (bfee->role == RTW_BFEE_MU)
10158c2ecf20Sopenharmony_ci		rtw8821c_bf_config_bfee_mu(rtwdev, vif, bfee, enable);
10168c2ecf20Sopenharmony_ci	else
10178c2ecf20Sopenharmony_ci		rtw_warn(rtwdev, "wrong bfee role\n");
10188c2ecf20Sopenharmony_ci}
10198c2ecf20Sopenharmony_ci
10208c2ecf20Sopenharmony_cistatic void rtw8821c_phy_cck_pd_set(struct rtw_dev *rtwdev, u8 new_lvl)
10218c2ecf20Sopenharmony_ci{
10228c2ecf20Sopenharmony_ci	struct rtw_dm_info *dm_info = &rtwdev->dm_info;
10238c2ecf20Sopenharmony_ci	u8 pd[CCK_PD_LV_MAX] = {3, 7, 13, 13, 13};
10248c2ecf20Sopenharmony_ci
10258c2ecf20Sopenharmony_ci	if (dm_info->min_rssi > 60) {
10268c2ecf20Sopenharmony_ci		new_lvl = 4;
10278c2ecf20Sopenharmony_ci		pd[4] = 0x1d;
10288c2ecf20Sopenharmony_ci		goto set_cck_pd;
10298c2ecf20Sopenharmony_ci	}
10308c2ecf20Sopenharmony_ci
10318c2ecf20Sopenharmony_ci	if (dm_info->cck_pd_lv[RTW_CHANNEL_WIDTH_20][RF_PATH_A] == new_lvl)
10328c2ecf20Sopenharmony_ci		return;
10338c2ecf20Sopenharmony_ci
10348c2ecf20Sopenharmony_ci	dm_info->cck_fa_avg = CCK_FA_AVG_RESET;
10358c2ecf20Sopenharmony_ci
10368c2ecf20Sopenharmony_ciset_cck_pd:
10378c2ecf20Sopenharmony_ci	dm_info->cck_pd_lv[RTW_CHANNEL_WIDTH_20][RF_PATH_A] = new_lvl;
10388c2ecf20Sopenharmony_ci	rtw_write32_mask(rtwdev, REG_PWRTH, 0x3f0000, pd[new_lvl]);
10398c2ecf20Sopenharmony_ci	rtw_write32_mask(rtwdev, REG_PWRTH2, 0x1f0000,
10408c2ecf20Sopenharmony_ci			 dm_info->cck_pd_default + new_lvl * 2);
10418c2ecf20Sopenharmony_ci}
10428c2ecf20Sopenharmony_ci
10438c2ecf20Sopenharmony_cistatic struct rtw_pwr_seq_cmd trans_carddis_to_cardemu_8821c[] = {
10448c2ecf20Sopenharmony_ci	{0x0086,
10458c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
10468c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_SDIO_MSK,
10478c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_SDIO,
10488c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(0), 0},
10498c2ecf20Sopenharmony_ci	{0x0086,
10508c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
10518c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_SDIO_MSK,
10528c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_SDIO,
10538c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_POLLING, BIT(1), BIT(1)},
10548c2ecf20Sopenharmony_ci	{0x004A,
10558c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
10568c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_USB_MSK,
10578c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
10588c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(0), 0},
10598c2ecf20Sopenharmony_ci	{0x0005,
10608c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
10618c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
10628c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
10638c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(3) | BIT(4) | BIT(7), 0},
10648c2ecf20Sopenharmony_ci	{0x0300,
10658c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
10668c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_PCI_MSK,
10678c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
10688c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, 0xFF, 0},
10698c2ecf20Sopenharmony_ci	{0x0301,
10708c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
10718c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_PCI_MSK,
10728c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
10738c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, 0xFF, 0},
10748c2ecf20Sopenharmony_ci	{0xFFFF,
10758c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
10768c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
10778c2ecf20Sopenharmony_ci	 0,
10788c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_END, 0, 0},
10798c2ecf20Sopenharmony_ci};
10808c2ecf20Sopenharmony_ci
10818c2ecf20Sopenharmony_cistatic struct rtw_pwr_seq_cmd trans_cardemu_to_act_8821c[] = {
10828c2ecf20Sopenharmony_ci	{0x0020,
10838c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
10848c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK,
10858c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
10868c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(0), BIT(0)},
10878c2ecf20Sopenharmony_ci	{0x0001,
10888c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
10898c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK,
10908c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
10918c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_DELAY, 1, RTW_PWR_DELAY_MS},
10928c2ecf20Sopenharmony_ci	{0x0000,
10938c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
10948c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK,
10958c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
10968c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(5), 0},
10978c2ecf20Sopenharmony_ci	{0x0005,
10988c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
10998c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
11008c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11018c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, (BIT(4) | BIT(3) | BIT(2)), 0},
11028c2ecf20Sopenharmony_ci	{0x0075,
11038c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11048c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_PCI_MSK,
11058c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11068c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(0), BIT(0)},
11078c2ecf20Sopenharmony_ci	{0x0006,
11088c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11098c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
11108c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11118c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_POLLING, BIT(1), BIT(1)},
11128c2ecf20Sopenharmony_ci	{0x0075,
11138c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11148c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_PCI_MSK,
11158c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11168c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(0), 0},
11178c2ecf20Sopenharmony_ci	{0x0006,
11188c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11198c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
11208c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11218c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(0), BIT(0)},
11228c2ecf20Sopenharmony_ci	{0x0005,
11238c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11248c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
11258c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11268c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(7), 0},
11278c2ecf20Sopenharmony_ci	{0x0005,
11288c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11298c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
11308c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11318c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, (BIT(4) | BIT(3)), 0},
11328c2ecf20Sopenharmony_ci	{0x10C3,
11338c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11348c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_USB_MSK,
11358c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11368c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(0), BIT(0)},
11378c2ecf20Sopenharmony_ci	{0x0005,
11388c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11398c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
11408c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11418c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(0), BIT(0)},
11428c2ecf20Sopenharmony_ci	{0x0005,
11438c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11448c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
11458c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11468c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_POLLING, BIT(0), 0},
11478c2ecf20Sopenharmony_ci	{0x0020,
11488c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11498c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
11508c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11518c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(3), BIT(3)},
11528c2ecf20Sopenharmony_ci	{0x0074,
11538c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11548c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_PCI_MSK,
11558c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11568c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(5), BIT(5)},
11578c2ecf20Sopenharmony_ci	{0x0022,
11588c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11598c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_PCI_MSK,
11608c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11618c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(1), 0},
11628c2ecf20Sopenharmony_ci	{0x0062,
11638c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11648c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_PCI_MSK,
11658c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11668c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, (BIT(7) | BIT(6) | BIT(5)),
11678c2ecf20Sopenharmony_ci	 (BIT(7) | BIT(6) | BIT(5))},
11688c2ecf20Sopenharmony_ci	{0x0061,
11698c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11708c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_PCI_MSK,
11718c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11728c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, (BIT(7) | BIT(6) | BIT(5)), 0},
11738c2ecf20Sopenharmony_ci	{0x007C,
11748c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11758c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
11768c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11778c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(1), 0},
11788c2ecf20Sopenharmony_ci	{0xFFFF,
11798c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11808c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
11818c2ecf20Sopenharmony_ci	 0,
11828c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_END, 0, 0},
11838c2ecf20Sopenharmony_ci};
11848c2ecf20Sopenharmony_ci
11858c2ecf20Sopenharmony_cistatic struct rtw_pwr_seq_cmd trans_act_to_cardemu_8821c[] = {
11868c2ecf20Sopenharmony_ci	{0x0093,
11878c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11888c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
11898c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11908c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(3), 0},
11918c2ecf20Sopenharmony_ci	{0x001F,
11928c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11938c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
11948c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
11958c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, 0xFF, 0},
11968c2ecf20Sopenharmony_ci	{0x0049,
11978c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
11988c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
11998c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12008c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(1), 0},
12018c2ecf20Sopenharmony_ci	{0x0006,
12028c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12038c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
12048c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12058c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(0), BIT(0)},
12068c2ecf20Sopenharmony_ci	{0x0002,
12078c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12088c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
12098c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12108c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(1), 0},
12118c2ecf20Sopenharmony_ci	{0x10C3,
12128c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12138c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_USB_MSK,
12148c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12158c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(0), 0},
12168c2ecf20Sopenharmony_ci	{0x0005,
12178c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12188c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
12198c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12208c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(1), BIT(1)},
12218c2ecf20Sopenharmony_ci	{0x0005,
12228c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12238c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
12248c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12258c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_POLLING, BIT(1), 0},
12268c2ecf20Sopenharmony_ci	{0x0020,
12278c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12288c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
12298c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12308c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(3), 0},
12318c2ecf20Sopenharmony_ci	{0x0000,
12328c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12338c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK,
12348c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12358c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(5), BIT(5)},
12368c2ecf20Sopenharmony_ci	{0xFFFF,
12378c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12388c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
12398c2ecf20Sopenharmony_ci	 0,
12408c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_END, 0, 0},
12418c2ecf20Sopenharmony_ci};
12428c2ecf20Sopenharmony_ci
12438c2ecf20Sopenharmony_cistatic struct rtw_pwr_seq_cmd trans_cardemu_to_carddis_8821c[] = {
12448c2ecf20Sopenharmony_ci	{0x0007,
12458c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12468c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK,
12478c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12488c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, 0xFF, 0x20},
12498c2ecf20Sopenharmony_ci	{0x0067,
12508c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12518c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
12528c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12538c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(5), 0},
12548c2ecf20Sopenharmony_ci	{0x0005,
12558c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12568c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_PCI_MSK,
12578c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12588c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(2), BIT(2)},
12598c2ecf20Sopenharmony_ci	{0x004A,
12608c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12618c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_USB_MSK,
12628c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12638c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(0), 0},
12648c2ecf20Sopenharmony_ci	{0x0067,
12658c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12668c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_SDIO_MSK,
12678c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12688c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(5), 0},
12698c2ecf20Sopenharmony_ci	{0x0067,
12708c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12718c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_SDIO_MSK,
12728c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12738c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(4), 0},
12748c2ecf20Sopenharmony_ci	{0x004F,
12758c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12768c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_SDIO_MSK,
12778c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12788c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(0), 0},
12798c2ecf20Sopenharmony_ci	{0x0067,
12808c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12818c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_SDIO_MSK,
12828c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12838c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(1), 0},
12848c2ecf20Sopenharmony_ci	{0x0046,
12858c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12868c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_SDIO_MSK,
12878c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12888c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(6), BIT(6)},
12898c2ecf20Sopenharmony_ci	{0x0067,
12908c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12918c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_SDIO_MSK,
12928c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12938c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(2), 0},
12948c2ecf20Sopenharmony_ci	{0x0046,
12958c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
12968c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_SDIO_MSK,
12978c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
12988c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(7), BIT(7)},
12998c2ecf20Sopenharmony_ci	{0x0062,
13008c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
13018c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_SDIO_MSK,
13028c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
13038c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(4), BIT(4)},
13048c2ecf20Sopenharmony_ci	{0x0081,
13058c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
13068c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
13078c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
13088c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(7) | BIT(6), 0},
13098c2ecf20Sopenharmony_ci	{0x0005,
13108c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
13118c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK,
13128c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
13138c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(3) | BIT(4), BIT(3)},
13148c2ecf20Sopenharmony_ci	{0x0086,
13158c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
13168c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_SDIO_MSK,
13178c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_SDIO,
13188c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(0), BIT(0)},
13198c2ecf20Sopenharmony_ci	{0x0086,
13208c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
13218c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_SDIO_MSK,
13228c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_SDIO,
13238c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_POLLING, BIT(1), 0},
13248c2ecf20Sopenharmony_ci	{0x0090,
13258c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
13268c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_PCI_MSK,
13278c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_MAC,
13288c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, BIT(1), 0},
13298c2ecf20Sopenharmony_ci	{0x0044,
13308c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
13318c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_SDIO_MSK,
13328c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_SDIO,
13338c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, 0xFF, 0},
13348c2ecf20Sopenharmony_ci	{0x0040,
13358c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
13368c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_SDIO_MSK,
13378c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_SDIO,
13388c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, 0xFF, 0x90},
13398c2ecf20Sopenharmony_ci	{0x0041,
13408c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
13418c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_SDIO_MSK,
13428c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_SDIO,
13438c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, 0xFF, 0x00},
13448c2ecf20Sopenharmony_ci	{0x0042,
13458c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
13468c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_SDIO_MSK,
13478c2ecf20Sopenharmony_ci	 RTW_PWR_ADDR_SDIO,
13488c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_WRITE, 0xFF, 0x04},
13498c2ecf20Sopenharmony_ci	{0xFFFF,
13508c2ecf20Sopenharmony_ci	 RTW_PWR_CUT_ALL_MSK,
13518c2ecf20Sopenharmony_ci	 RTW_PWR_INTF_ALL_MSK,
13528c2ecf20Sopenharmony_ci	 0,
13538c2ecf20Sopenharmony_ci	 RTW_PWR_CMD_END, 0, 0},
13548c2ecf20Sopenharmony_ci};
13558c2ecf20Sopenharmony_ci
13568c2ecf20Sopenharmony_cistatic const struct rtw_pwr_seq_cmd *card_enable_flow_8821c[] = {
13578c2ecf20Sopenharmony_ci	trans_carddis_to_cardemu_8821c,
13588c2ecf20Sopenharmony_ci	trans_cardemu_to_act_8821c,
13598c2ecf20Sopenharmony_ci	NULL
13608c2ecf20Sopenharmony_ci};
13618c2ecf20Sopenharmony_ci
13628c2ecf20Sopenharmony_cistatic const struct rtw_pwr_seq_cmd *card_disable_flow_8821c[] = {
13638c2ecf20Sopenharmony_ci	trans_act_to_cardemu_8821c,
13648c2ecf20Sopenharmony_ci	trans_cardemu_to_carddis_8821c,
13658c2ecf20Sopenharmony_ci	NULL
13668c2ecf20Sopenharmony_ci};
13678c2ecf20Sopenharmony_ci
13688c2ecf20Sopenharmony_cistatic const struct rtw_intf_phy_para usb2_param_8821c[] = {
13698c2ecf20Sopenharmony_ci	{0xFFFF, 0x00,
13708c2ecf20Sopenharmony_ci	 RTW_IP_SEL_PHY,
13718c2ecf20Sopenharmony_ci	 RTW_INTF_PHY_CUT_ALL,
13728c2ecf20Sopenharmony_ci	 RTW_INTF_PHY_PLATFORM_ALL},
13738c2ecf20Sopenharmony_ci};
13748c2ecf20Sopenharmony_ci
13758c2ecf20Sopenharmony_cistatic const struct rtw_intf_phy_para usb3_param_8821c[] = {
13768c2ecf20Sopenharmony_ci	{0xFFFF, 0x0000,
13778c2ecf20Sopenharmony_ci	 RTW_IP_SEL_PHY,
13788c2ecf20Sopenharmony_ci	 RTW_INTF_PHY_CUT_ALL,
13798c2ecf20Sopenharmony_ci	 RTW_INTF_PHY_PLATFORM_ALL},
13808c2ecf20Sopenharmony_ci};
13818c2ecf20Sopenharmony_ci
13828c2ecf20Sopenharmony_cistatic const struct rtw_intf_phy_para pcie_gen1_param_8821c[] = {
13838c2ecf20Sopenharmony_ci	{0x0009, 0x6380,
13848c2ecf20Sopenharmony_ci	 RTW_IP_SEL_PHY,
13858c2ecf20Sopenharmony_ci	 RTW_INTF_PHY_CUT_ALL,
13868c2ecf20Sopenharmony_ci	 RTW_INTF_PHY_PLATFORM_ALL},
13878c2ecf20Sopenharmony_ci	{0xFFFF, 0x0000,
13888c2ecf20Sopenharmony_ci	 RTW_IP_SEL_PHY,
13898c2ecf20Sopenharmony_ci	 RTW_INTF_PHY_CUT_ALL,
13908c2ecf20Sopenharmony_ci	 RTW_INTF_PHY_PLATFORM_ALL},
13918c2ecf20Sopenharmony_ci};
13928c2ecf20Sopenharmony_ci
13938c2ecf20Sopenharmony_cistatic const struct rtw_intf_phy_para pcie_gen2_param_8821c[] = {
13948c2ecf20Sopenharmony_ci	{0xFFFF, 0x0000,
13958c2ecf20Sopenharmony_ci	 RTW_IP_SEL_PHY,
13968c2ecf20Sopenharmony_ci	 RTW_INTF_PHY_CUT_ALL,
13978c2ecf20Sopenharmony_ci	 RTW_INTF_PHY_PLATFORM_ALL},
13988c2ecf20Sopenharmony_ci};
13998c2ecf20Sopenharmony_ci
14008c2ecf20Sopenharmony_cistatic const struct rtw_intf_phy_para_table phy_para_table_8821c = {
14018c2ecf20Sopenharmony_ci	.usb2_para	= usb2_param_8821c,
14028c2ecf20Sopenharmony_ci	.usb3_para	= usb3_param_8821c,
14038c2ecf20Sopenharmony_ci	.gen1_para	= pcie_gen1_param_8821c,
14048c2ecf20Sopenharmony_ci	.gen2_para	= pcie_gen2_param_8821c,
14058c2ecf20Sopenharmony_ci	.n_usb2_para	= ARRAY_SIZE(usb2_param_8821c),
14068c2ecf20Sopenharmony_ci	.n_usb3_para	= ARRAY_SIZE(usb2_param_8821c),
14078c2ecf20Sopenharmony_ci	.n_gen1_para	= ARRAY_SIZE(pcie_gen1_param_8821c),
14088c2ecf20Sopenharmony_ci	.n_gen2_para	= ARRAY_SIZE(pcie_gen2_param_8821c),
14098c2ecf20Sopenharmony_ci};
14108c2ecf20Sopenharmony_ci
14118c2ecf20Sopenharmony_cistatic const struct rtw_rfe_def rtw8821c_rfe_defs[] = {
14128c2ecf20Sopenharmony_ci	[0] = RTW_DEF_RFE(8821c, 0, 0),
14138c2ecf20Sopenharmony_ci};
14148c2ecf20Sopenharmony_ci
14158c2ecf20Sopenharmony_cistatic struct rtw_hw_reg rtw8821c_dig[] = {
14168c2ecf20Sopenharmony_ci	[0] = { .addr = 0xc50, .mask = 0x7f },
14178c2ecf20Sopenharmony_ci};
14188c2ecf20Sopenharmony_ci
14198c2ecf20Sopenharmony_cistatic const struct rtw_ltecoex_addr rtw8821c_ltecoex_addr = {
14208c2ecf20Sopenharmony_ci	.ctrl = LTECOEX_ACCESS_CTRL,
14218c2ecf20Sopenharmony_ci	.wdata = LTECOEX_WRITE_DATA,
14228c2ecf20Sopenharmony_ci	.rdata = LTECOEX_READ_DATA,
14238c2ecf20Sopenharmony_ci};
14248c2ecf20Sopenharmony_ci
14258c2ecf20Sopenharmony_cistatic struct rtw_page_table page_table_8821c[] = {
14268c2ecf20Sopenharmony_ci	/* not sure what [0] stands for */
14278c2ecf20Sopenharmony_ci	{16, 16, 16, 14, 1},
14288c2ecf20Sopenharmony_ci	{16, 16, 16, 14, 1},
14298c2ecf20Sopenharmony_ci	{16, 16, 0, 0, 1},
14308c2ecf20Sopenharmony_ci	{16, 16, 16, 0, 1},
14318c2ecf20Sopenharmony_ci	{16, 16, 16, 14, 1},
14328c2ecf20Sopenharmony_ci};
14338c2ecf20Sopenharmony_ci
14348c2ecf20Sopenharmony_cistatic struct rtw_rqpn rqpn_table_8821c[] = {
14358c2ecf20Sopenharmony_ci	/* not sure what [0] stands for */
14368c2ecf20Sopenharmony_ci	{RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_NORMAL,
14378c2ecf20Sopenharmony_ci	 RTW_DMA_MAPPING_LOW, RTW_DMA_MAPPING_LOW,
14388c2ecf20Sopenharmony_ci	 RTW_DMA_MAPPING_EXTRA, RTW_DMA_MAPPING_HIGH},
14398c2ecf20Sopenharmony_ci	{RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_NORMAL,
14408c2ecf20Sopenharmony_ci	 RTW_DMA_MAPPING_LOW, RTW_DMA_MAPPING_LOW,
14418c2ecf20Sopenharmony_ci	 RTW_DMA_MAPPING_EXTRA, RTW_DMA_MAPPING_HIGH},
14428c2ecf20Sopenharmony_ci	{RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_NORMAL,
14438c2ecf20Sopenharmony_ci	 RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_HIGH,
14448c2ecf20Sopenharmony_ci	 RTW_DMA_MAPPING_HIGH, RTW_DMA_MAPPING_HIGH},
14458c2ecf20Sopenharmony_ci	{RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_NORMAL,
14468c2ecf20Sopenharmony_ci	 RTW_DMA_MAPPING_LOW, RTW_DMA_MAPPING_LOW,
14478c2ecf20Sopenharmony_ci	 RTW_DMA_MAPPING_HIGH, RTW_DMA_MAPPING_HIGH},
14488c2ecf20Sopenharmony_ci	{RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_NORMAL,
14498c2ecf20Sopenharmony_ci	 RTW_DMA_MAPPING_LOW, RTW_DMA_MAPPING_LOW,
14508c2ecf20Sopenharmony_ci	 RTW_DMA_MAPPING_EXTRA, RTW_DMA_MAPPING_HIGH},
14518c2ecf20Sopenharmony_ci};
14528c2ecf20Sopenharmony_ci
14538c2ecf20Sopenharmony_cistatic struct rtw_prioq_addrs prioq_addrs_8821c = {
14548c2ecf20Sopenharmony_ci	.prio[RTW_DMA_MAPPING_EXTRA] = {
14558c2ecf20Sopenharmony_ci		.rsvd = REG_FIFOPAGE_INFO_4, .avail = REG_FIFOPAGE_INFO_4 + 2,
14568c2ecf20Sopenharmony_ci	},
14578c2ecf20Sopenharmony_ci	.prio[RTW_DMA_MAPPING_LOW] = {
14588c2ecf20Sopenharmony_ci		.rsvd = REG_FIFOPAGE_INFO_2, .avail = REG_FIFOPAGE_INFO_2 + 2,
14598c2ecf20Sopenharmony_ci	},
14608c2ecf20Sopenharmony_ci	.prio[RTW_DMA_MAPPING_NORMAL] = {
14618c2ecf20Sopenharmony_ci		.rsvd = REG_FIFOPAGE_INFO_3, .avail = REG_FIFOPAGE_INFO_3 + 2,
14628c2ecf20Sopenharmony_ci	},
14638c2ecf20Sopenharmony_ci	.prio[RTW_DMA_MAPPING_HIGH] = {
14648c2ecf20Sopenharmony_ci		.rsvd = REG_FIFOPAGE_INFO_1, .avail = REG_FIFOPAGE_INFO_1 + 2,
14658c2ecf20Sopenharmony_ci	},
14668c2ecf20Sopenharmony_ci	.wsize = true,
14678c2ecf20Sopenharmony_ci};
14688c2ecf20Sopenharmony_ci
14698c2ecf20Sopenharmony_cistatic struct rtw_chip_ops rtw8821c_ops = {
14708c2ecf20Sopenharmony_ci	.phy_set_param		= rtw8821c_phy_set_param,
14718c2ecf20Sopenharmony_ci	.read_efuse		= rtw8821c_read_efuse,
14728c2ecf20Sopenharmony_ci	.query_rx_desc		= rtw8821c_query_rx_desc,
14738c2ecf20Sopenharmony_ci	.set_channel		= rtw8821c_set_channel,
14748c2ecf20Sopenharmony_ci	.mac_init		= rtw8821c_mac_init,
14758c2ecf20Sopenharmony_ci	.read_rf		= rtw_phy_read_rf,
14768c2ecf20Sopenharmony_ci	.write_rf		= rtw_phy_write_rf_reg_sipi,
14778c2ecf20Sopenharmony_ci	.set_antenna		= NULL,
14788c2ecf20Sopenharmony_ci	.set_tx_power_index	= rtw8821c_set_tx_power_index,
14798c2ecf20Sopenharmony_ci	.cfg_ldo25		= rtw8821c_cfg_ldo25,
14808c2ecf20Sopenharmony_ci	.false_alarm_statistics	= rtw8821c_false_alarm_statistics,
14818c2ecf20Sopenharmony_ci	.phy_calibration	= rtw8821c_phy_calibration,
14828c2ecf20Sopenharmony_ci	.cck_pd_set		= rtw8821c_phy_cck_pd_set,
14838c2ecf20Sopenharmony_ci	.pwr_track		= rtw8821c_pwr_track,
14848c2ecf20Sopenharmony_ci	.config_bfee		= rtw8821c_bf_config_bfee,
14858c2ecf20Sopenharmony_ci	.set_gid_table		= rtw_bf_set_gid_table,
14868c2ecf20Sopenharmony_ci	.cfg_csi_rate		= rtw_bf_cfg_csi_rate,
14878c2ecf20Sopenharmony_ci
14888c2ecf20Sopenharmony_ci	.coex_set_init		= rtw8821c_coex_cfg_init,
14898c2ecf20Sopenharmony_ci	.coex_set_ant_switch	= rtw8821c_coex_cfg_ant_switch,
14908c2ecf20Sopenharmony_ci	.coex_set_gnt_fix	= rtw8821c_coex_cfg_gnt_fix,
14918c2ecf20Sopenharmony_ci	.coex_set_gnt_debug	= rtw8821c_coex_cfg_gnt_debug,
14928c2ecf20Sopenharmony_ci	.coex_set_rfe_type	= rtw8821c_coex_cfg_rfe_type,
14938c2ecf20Sopenharmony_ci	.coex_set_wl_tx_power	= rtw8821c_coex_cfg_wl_tx_power,
14948c2ecf20Sopenharmony_ci	.coex_set_wl_rx_gain	= rtw8821c_coex_cfg_wl_rx_gain,
14958c2ecf20Sopenharmony_ci};
14968c2ecf20Sopenharmony_ci
14978c2ecf20Sopenharmony_ci/* rssi in percentage % (dbm = % - 100) */
14988c2ecf20Sopenharmony_cistatic const u8 wl_rssi_step_8821c[] = {101, 45, 101, 40};
14998c2ecf20Sopenharmony_cistatic const u8 bt_rssi_step_8821c[] = {101, 101, 101, 101};
15008c2ecf20Sopenharmony_ci
15018c2ecf20Sopenharmony_ci/* Shared-Antenna Coex Table */
15028c2ecf20Sopenharmony_cistatic const struct coex_table_para table_sant_8821c[] = {
15038c2ecf20Sopenharmony_ci	{0x55555555, 0x55555555}, /* case-0 */
15048c2ecf20Sopenharmony_ci	{0x55555555, 0x55555555},
15058c2ecf20Sopenharmony_ci	{0x66555555, 0x66555555},
15068c2ecf20Sopenharmony_ci	{0xaaaaaaaa, 0xaaaaaaaa},
15078c2ecf20Sopenharmony_ci	{0x5a5a5a5a, 0x5a5a5a5a},
15088c2ecf20Sopenharmony_ci	{0xfafafafa, 0xfafafafa}, /* case-5 */
15098c2ecf20Sopenharmony_ci	{0x6a5a5555, 0xaaaaaaaa},
15108c2ecf20Sopenharmony_ci	{0x6a5a56aa, 0x6a5a56aa},
15118c2ecf20Sopenharmony_ci	{0x6a5a5a5a, 0x6a5a5a5a},
15128c2ecf20Sopenharmony_ci	{0x66555555, 0x5a5a5a5a},
15138c2ecf20Sopenharmony_ci	{0x66555555, 0x6a5a5a5a}, /* case-10 */
15148c2ecf20Sopenharmony_ci	{0x66555555, 0xaaaaaaaa},
15158c2ecf20Sopenharmony_ci	{0x66555555, 0x6a5a5aaa},
15168c2ecf20Sopenharmony_ci	{0x66555555, 0x6aaa6aaa},
15178c2ecf20Sopenharmony_ci	{0x66555555, 0x6a5a5aaa},
15188c2ecf20Sopenharmony_ci	{0x66555555, 0xaaaaaaaa}, /* case-15 */
15198c2ecf20Sopenharmony_ci	{0xffff55ff, 0xfafafafa},
15208c2ecf20Sopenharmony_ci	{0xffff55ff, 0x6afa5afa},
15218c2ecf20Sopenharmony_ci	{0xaaffffaa, 0xfafafafa},
15228c2ecf20Sopenharmony_ci	{0xaa5555aa, 0x5a5a5a5a},
15238c2ecf20Sopenharmony_ci	{0xaa5555aa, 0x6a5a5a5a}, /* case-20 */
15248c2ecf20Sopenharmony_ci	{0xaa5555aa, 0xaaaaaaaa},
15258c2ecf20Sopenharmony_ci	{0xffffffff, 0x55555555},
15268c2ecf20Sopenharmony_ci	{0xffffffff, 0x5a5a5a5a},
15278c2ecf20Sopenharmony_ci	{0xffffffff, 0x5a5a5a5a},
15288c2ecf20Sopenharmony_ci	{0xffffffff, 0x5a5a5aaa}, /* case-25 */
15298c2ecf20Sopenharmony_ci	{0x55555555, 0x5a5a5a5a},
15308c2ecf20Sopenharmony_ci	{0x55555555, 0xaaaaaaaa},
15318c2ecf20Sopenharmony_ci	{0x66555555, 0x6a5a6a5a},
15328c2ecf20Sopenharmony_ci	{0x66556655, 0x66556655},
15338c2ecf20Sopenharmony_ci	{0x66556aaa, 0x6a5a6aaa}, /* case-30 */
15348c2ecf20Sopenharmony_ci	{0xffffffff, 0x5aaa5aaa},
15358c2ecf20Sopenharmony_ci	{0x56555555, 0x5a5a5aaa}
15368c2ecf20Sopenharmony_ci};
15378c2ecf20Sopenharmony_ci
15388c2ecf20Sopenharmony_ci/* Non-Shared-Antenna Coex Table */
15398c2ecf20Sopenharmony_cistatic const struct coex_table_para table_nsant_8821c[] = {
15408c2ecf20Sopenharmony_ci	{0xffffffff, 0xffffffff}, /* case-100 */
15418c2ecf20Sopenharmony_ci	{0xffff55ff, 0xfafafafa},
15428c2ecf20Sopenharmony_ci	{0x66555555, 0x66555555},
15438c2ecf20Sopenharmony_ci	{0xaaaaaaaa, 0xaaaaaaaa},
15448c2ecf20Sopenharmony_ci	{0x5a5a5a5a, 0x5a5a5a5a},
15458c2ecf20Sopenharmony_ci	{0xffffffff, 0xffffffff}, /* case-105 */
15468c2ecf20Sopenharmony_ci	{0x5afa5afa, 0x5afa5afa},
15478c2ecf20Sopenharmony_ci	{0x55555555, 0xfafafafa},
15488c2ecf20Sopenharmony_ci	{0x66555555, 0xfafafafa},
15498c2ecf20Sopenharmony_ci	{0x66555555, 0x5a5a5a5a},
15508c2ecf20Sopenharmony_ci	{0x66555555, 0x6a5a5a5a}, /* case-110 */
15518c2ecf20Sopenharmony_ci	{0x66555555, 0xaaaaaaaa},
15528c2ecf20Sopenharmony_ci	{0xffff55ff, 0xfafafafa},
15538c2ecf20Sopenharmony_ci	{0xffff55ff, 0x5afa5afa},
15548c2ecf20Sopenharmony_ci	{0xffff55ff, 0xaaaaaaaa},
15558c2ecf20Sopenharmony_ci	{0xffff55ff, 0xffff55ff}, /* case-115 */
15568c2ecf20Sopenharmony_ci	{0xaaffffaa, 0x5afa5afa},
15578c2ecf20Sopenharmony_ci	{0xaaffffaa, 0xaaaaaaaa},
15588c2ecf20Sopenharmony_ci	{0xffffffff, 0xfafafafa},
15598c2ecf20Sopenharmony_ci	{0xffff55ff, 0xfafafafa},
15608c2ecf20Sopenharmony_ci	{0xffffffff, 0xaaaaaaaa}, /* case-120 */
15618c2ecf20Sopenharmony_ci	{0xffff55ff, 0x5afa5afa},
15628c2ecf20Sopenharmony_ci	{0xffff55ff, 0x5afa5afa},
15638c2ecf20Sopenharmony_ci	{0x55ff55ff, 0x55ff55ff}
15648c2ecf20Sopenharmony_ci};
15658c2ecf20Sopenharmony_ci
15668c2ecf20Sopenharmony_ci/* Shared-Antenna TDMA */
15678c2ecf20Sopenharmony_cistatic const struct coex_tdma_para tdma_sant_8821c[] = {
15688c2ecf20Sopenharmony_ci	{ {0x00, 0x00, 0x00, 0x00, 0x00} }, /* case-0 */
15698c2ecf20Sopenharmony_ci	{ {0x61, 0x45, 0x03, 0x11, 0x11} }, /* case-1 */
15708c2ecf20Sopenharmony_ci	{ {0x61, 0x3a, 0x03, 0x11, 0x11} },
15718c2ecf20Sopenharmony_ci	{ {0x61, 0x35, 0x03, 0x11, 0x11} },
15728c2ecf20Sopenharmony_ci	{ {0x61, 0x20, 0x03, 0x11, 0x11} },
15738c2ecf20Sopenharmony_ci	{ {0x61, 0x3a, 0x03, 0x11, 0x11} }, /* case-5 */
15748c2ecf20Sopenharmony_ci	{ {0x61, 0x45, 0x03, 0x11, 0x10} },
15758c2ecf20Sopenharmony_ci	{ {0x61, 0x35, 0x03, 0x11, 0x10} },
15768c2ecf20Sopenharmony_ci	{ {0x61, 0x30, 0x03, 0x11, 0x10} },
15778c2ecf20Sopenharmony_ci	{ {0x61, 0x20, 0x03, 0x11, 0x10} },
15788c2ecf20Sopenharmony_ci	{ {0x61, 0x10, 0x03, 0x11, 0x10} }, /* case-10 */
15798c2ecf20Sopenharmony_ci	{ {0x61, 0x08, 0x03, 0x11, 0x15} },
15808c2ecf20Sopenharmony_ci	{ {0x61, 0x08, 0x03, 0x10, 0x14} },
15818c2ecf20Sopenharmony_ci	{ {0x51, 0x08, 0x03, 0x10, 0x54} },
15828c2ecf20Sopenharmony_ci	{ {0x51, 0x08, 0x03, 0x10, 0x55} },
15838c2ecf20Sopenharmony_ci	{ {0x51, 0x08, 0x07, 0x10, 0x54} }, /* case-15 */
15848c2ecf20Sopenharmony_ci	{ {0x51, 0x45, 0x03, 0x10, 0x50} },
15858c2ecf20Sopenharmony_ci	{ {0x51, 0x3a, 0x03, 0x11, 0x50} },
15868c2ecf20Sopenharmony_ci	{ {0x51, 0x30, 0x03, 0x10, 0x50} },
15878c2ecf20Sopenharmony_ci	{ {0x51, 0x21, 0x03, 0x10, 0x50} },
15888c2ecf20Sopenharmony_ci	{ {0x51, 0x10, 0x03, 0x10, 0x50} }, /* case-20 */
15898c2ecf20Sopenharmony_ci	{ {0x51, 0x4a, 0x03, 0x10, 0x50} },
15908c2ecf20Sopenharmony_ci	{ {0x51, 0x08, 0x03, 0x30, 0x54} },
15918c2ecf20Sopenharmony_ci	{ {0x55, 0x08, 0x03, 0x10, 0x54} },
15928c2ecf20Sopenharmony_ci	{ {0x65, 0x10, 0x03, 0x11, 0x10} },
15938c2ecf20Sopenharmony_ci	{ {0x51, 0x10, 0x03, 0x10, 0x51} }, /* case-25 */
15948c2ecf20Sopenharmony_ci	{ {0x51, 0x21, 0x03, 0x10, 0x50} },
15958c2ecf20Sopenharmony_ci	{ {0x61, 0x08, 0x03, 0x11, 0x11} }
15968c2ecf20Sopenharmony_ci};
15978c2ecf20Sopenharmony_ci
15988c2ecf20Sopenharmony_ci/* Non-Shared-Antenna TDMA */
15998c2ecf20Sopenharmony_cistatic const struct coex_tdma_para tdma_nsant_8821c[] = {
16008c2ecf20Sopenharmony_ci	{ {0x00, 0x00, 0x00, 0x40, 0x00} }, /* case-100 */
16018c2ecf20Sopenharmony_ci	{ {0x61, 0x45, 0x03, 0x11, 0x11} },
16028c2ecf20Sopenharmony_ci	{ {0x61, 0x25, 0x03, 0x11, 0x11} },
16038c2ecf20Sopenharmony_ci	{ {0x61, 0x35, 0x03, 0x11, 0x11} },
16048c2ecf20Sopenharmony_ci	{ {0x61, 0x20, 0x03, 0x11, 0x11} },
16058c2ecf20Sopenharmony_ci	{ {0x61, 0x10, 0x03, 0x11, 0x11} }, /* case-105 */
16068c2ecf20Sopenharmony_ci	{ {0x61, 0x45, 0x03, 0x11, 0x10} },
16078c2ecf20Sopenharmony_ci	{ {0x61, 0x30, 0x03, 0x11, 0x10} },
16088c2ecf20Sopenharmony_ci	{ {0x61, 0x30, 0x03, 0x11, 0x10} },
16098c2ecf20Sopenharmony_ci	{ {0x61, 0x20, 0x03, 0x11, 0x10} },
16108c2ecf20Sopenharmony_ci	{ {0x61, 0x10, 0x03, 0x11, 0x10} }, /* case-110 */
16118c2ecf20Sopenharmony_ci	{ {0x61, 0x10, 0x03, 0x11, 0x11} },
16128c2ecf20Sopenharmony_ci	{ {0x61, 0x08, 0x03, 0x10, 0x14} },
16138c2ecf20Sopenharmony_ci	{ {0x51, 0x08, 0x03, 0x10, 0x54} },
16148c2ecf20Sopenharmony_ci	{ {0x51, 0x08, 0x03, 0x10, 0x55} },
16158c2ecf20Sopenharmony_ci	{ {0x51, 0x08, 0x07, 0x10, 0x54} }, /* case-115 */
16168c2ecf20Sopenharmony_ci	{ {0x51, 0x45, 0x03, 0x10, 0x50} },
16178c2ecf20Sopenharmony_ci	{ {0x51, 0x3a, 0x03, 0x10, 0x50} },
16188c2ecf20Sopenharmony_ci	{ {0x51, 0x30, 0x03, 0x10, 0x50} },
16198c2ecf20Sopenharmony_ci	{ {0x51, 0x21, 0x03, 0x10, 0x50} },
16208c2ecf20Sopenharmony_ci	{ {0x51, 0x21, 0x03, 0x10, 0x50} }, /* case-120 */
16218c2ecf20Sopenharmony_ci	{ {0x51, 0x10, 0x03, 0x10, 0x50} }
16228c2ecf20Sopenharmony_ci};
16238c2ecf20Sopenharmony_ci
16248c2ecf20Sopenharmony_cistatic const struct coex_5g_afh_map afh_5g_8821c[] = { {0, 0, 0} };
16258c2ecf20Sopenharmony_ci
16268c2ecf20Sopenharmony_ci/* wl_tx_dec_power, bt_tx_dec_power, wl_rx_gain, bt_rx_lna_constrain */
16278c2ecf20Sopenharmony_cistatic const struct coex_rf_para rf_para_tx_8821c[] = {
16288c2ecf20Sopenharmony_ci	{0, 0, false, 7},  /* for normal */
16298c2ecf20Sopenharmony_ci	{0, 20, false, 7}, /* for WL-CPT */
16308c2ecf20Sopenharmony_ci	{8, 17, true, 4},
16318c2ecf20Sopenharmony_ci	{7, 18, true, 4},
16328c2ecf20Sopenharmony_ci	{6, 19, true, 4},
16338c2ecf20Sopenharmony_ci	{5, 20, true, 4}
16348c2ecf20Sopenharmony_ci};
16358c2ecf20Sopenharmony_ci
16368c2ecf20Sopenharmony_cistatic const struct coex_rf_para rf_para_rx_8821c[] = {
16378c2ecf20Sopenharmony_ci	{0, 0, false, 7},  /* for normal */
16388c2ecf20Sopenharmony_ci	{0, 20, false, 7}, /* for WL-CPT */
16398c2ecf20Sopenharmony_ci	{3, 24, true, 5},
16408c2ecf20Sopenharmony_ci	{2, 26, true, 5},
16418c2ecf20Sopenharmony_ci	{1, 27, true, 5},
16428c2ecf20Sopenharmony_ci	{0, 28, true, 5}
16438c2ecf20Sopenharmony_ci};
16448c2ecf20Sopenharmony_ci
16458c2ecf20Sopenharmony_cistatic_assert(ARRAY_SIZE(rf_para_tx_8821c) == ARRAY_SIZE(rf_para_rx_8821c));
16468c2ecf20Sopenharmony_ci
16478c2ecf20Sopenharmony_cistatic const u8 rtw8821c_pwrtrk_5gb_n[][RTW_PWR_TRK_TBL_SZ] = {
16488c2ecf20Sopenharmony_ci	{0, 1, 1, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 8, 8, 8, 9, 9, 9, 10, 10,
16498c2ecf20Sopenharmony_ci	 11, 11, 12, 12, 12, 12, 12},
16508c2ecf20Sopenharmony_ci	{0, 1, 1, 1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 8, 8, 9, 9, 10, 10, 11,
16518c2ecf20Sopenharmony_ci	 11, 12, 12, 12, 12, 12, 12, 12},
16528c2ecf20Sopenharmony_ci	{0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 9, 10, 10, 11,
16538c2ecf20Sopenharmony_ci	 11, 12, 12, 12, 12, 12, 12},
16548c2ecf20Sopenharmony_ci};
16558c2ecf20Sopenharmony_ci
16568c2ecf20Sopenharmony_cistatic const u8 rtw8821c_pwrtrk_5gb_p[][RTW_PWR_TRK_TBL_SZ] = {
16578c2ecf20Sopenharmony_ci	{0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 11,
16588c2ecf20Sopenharmony_ci	 12, 12, 12, 12, 12, 12, 12},
16598c2ecf20Sopenharmony_ci	{0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 7, 7, 8, 8, 9, 10, 10, 11, 11,
16608c2ecf20Sopenharmony_ci	 12, 12, 12, 12, 12, 12, 12, 12},
16618c2ecf20Sopenharmony_ci	{0, 1, 1, 1, 2, 3, 3, 3, 4, 4, 4, 5, 6, 6, 7, 7, 8, 8, 9, 10, 10, 11,
16628c2ecf20Sopenharmony_ci	 11, 12, 12, 12, 12, 12, 12, 12},
16638c2ecf20Sopenharmony_ci};
16648c2ecf20Sopenharmony_ci
16658c2ecf20Sopenharmony_cistatic const u8 rtw8821c_pwrtrk_5ga_n[][RTW_PWR_TRK_TBL_SZ] = {
16668c2ecf20Sopenharmony_ci	{0, 1, 1, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 8, 8, 8, 9, 9, 9, 10, 10,
16678c2ecf20Sopenharmony_ci	 11, 11, 12, 12, 12, 12, 12},
16688c2ecf20Sopenharmony_ci	{0, 1, 1, 1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 7, 8, 8, 9, 9, 10, 10, 11,
16698c2ecf20Sopenharmony_ci	 11, 12, 12, 12, 12, 12, 12, 12},
16708c2ecf20Sopenharmony_ci	{0, 1, 2, 2, 3, 4, 4, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 9, 10, 10, 11,
16718c2ecf20Sopenharmony_ci	 11, 12, 12, 12, 12, 12, 12},
16728c2ecf20Sopenharmony_ci};
16738c2ecf20Sopenharmony_ci
16748c2ecf20Sopenharmony_cistatic const u8 rtw8821c_pwrtrk_5ga_p[][RTW_PWR_TRK_TBL_SZ] = {
16758c2ecf20Sopenharmony_ci	{0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 11,
16768c2ecf20Sopenharmony_ci	 12, 12, 12, 12, 12, 12, 12},
16778c2ecf20Sopenharmony_ci	{0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 7, 7, 8, 8, 9, 10, 10, 11, 11,
16788c2ecf20Sopenharmony_ci	 12, 12, 12, 12, 12, 12, 12, 12},
16798c2ecf20Sopenharmony_ci	{0, 1, 1, 1, 2, 3, 3, 3, 4, 4, 4, 5, 6, 6, 7, 7, 8, 8, 9, 10, 10, 11,
16808c2ecf20Sopenharmony_ci	 11, 12, 12, 12, 12, 12, 12, 12},
16818c2ecf20Sopenharmony_ci};
16828c2ecf20Sopenharmony_ci
16838c2ecf20Sopenharmony_cistatic const u8 rtw8821c_pwrtrk_2gb_n[] = {
16848c2ecf20Sopenharmony_ci	0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4,
16858c2ecf20Sopenharmony_ci	4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9
16868c2ecf20Sopenharmony_ci};
16878c2ecf20Sopenharmony_ci
16888c2ecf20Sopenharmony_cistatic const u8 rtw8821c_pwrtrk_2gb_p[] = {
16898c2ecf20Sopenharmony_ci	0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5,
16908c2ecf20Sopenharmony_ci	5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 9
16918c2ecf20Sopenharmony_ci};
16928c2ecf20Sopenharmony_ci
16938c2ecf20Sopenharmony_cistatic const u8 rtw8821c_pwrtrk_2ga_n[] = {
16948c2ecf20Sopenharmony_ci	0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 4, 4,
16958c2ecf20Sopenharmony_ci	4, 4, 5, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9
16968c2ecf20Sopenharmony_ci};
16978c2ecf20Sopenharmony_ci
16988c2ecf20Sopenharmony_cistatic const u8 rtw8821c_pwrtrk_2ga_p[] = {
16998c2ecf20Sopenharmony_ci	0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5,
17008c2ecf20Sopenharmony_ci	5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 9
17018c2ecf20Sopenharmony_ci};
17028c2ecf20Sopenharmony_ci
17038c2ecf20Sopenharmony_cistatic const u8 rtw8821c_pwrtrk_2g_cck_b_n[] = {
17048c2ecf20Sopenharmony_ci	0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4,
17058c2ecf20Sopenharmony_ci	4, 5, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 9
17068c2ecf20Sopenharmony_ci};
17078c2ecf20Sopenharmony_ci
17088c2ecf20Sopenharmony_cistatic const u8 rtw8821c_pwrtrk_2g_cck_b_p[] = {
17098c2ecf20Sopenharmony_ci	0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5,
17108c2ecf20Sopenharmony_ci	5, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9
17118c2ecf20Sopenharmony_ci};
17128c2ecf20Sopenharmony_ci
17138c2ecf20Sopenharmony_cistatic const u8 rtw8821c_pwrtrk_2g_cck_a_n[] = {
17148c2ecf20Sopenharmony_ci	0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4,
17158c2ecf20Sopenharmony_ci	4, 5, 5, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 9
17168c2ecf20Sopenharmony_ci};
17178c2ecf20Sopenharmony_ci
17188c2ecf20Sopenharmony_cistatic const u8 rtw8821c_pwrtrk_2g_cck_a_p[] = {
17198c2ecf20Sopenharmony_ci	0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5,
17208c2ecf20Sopenharmony_ci	5, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 9, 9, 9
17218c2ecf20Sopenharmony_ci};
17228c2ecf20Sopenharmony_ci
17238c2ecf20Sopenharmony_cistatic const struct rtw_pwr_track_tbl rtw8821c_rtw_pwr_track_tbl = {
17248c2ecf20Sopenharmony_ci	.pwrtrk_5gb_n[0] = rtw8821c_pwrtrk_5gb_n[0],
17258c2ecf20Sopenharmony_ci	.pwrtrk_5gb_n[1] = rtw8821c_pwrtrk_5gb_n[1],
17268c2ecf20Sopenharmony_ci	.pwrtrk_5gb_n[2] = rtw8821c_pwrtrk_5gb_n[2],
17278c2ecf20Sopenharmony_ci	.pwrtrk_5gb_p[0] = rtw8821c_pwrtrk_5gb_p[0],
17288c2ecf20Sopenharmony_ci	.pwrtrk_5gb_p[1] = rtw8821c_pwrtrk_5gb_p[1],
17298c2ecf20Sopenharmony_ci	.pwrtrk_5gb_p[2] = rtw8821c_pwrtrk_5gb_p[2],
17308c2ecf20Sopenharmony_ci	.pwrtrk_5ga_n[0] = rtw8821c_pwrtrk_5ga_n[0],
17318c2ecf20Sopenharmony_ci	.pwrtrk_5ga_n[1] = rtw8821c_pwrtrk_5ga_n[1],
17328c2ecf20Sopenharmony_ci	.pwrtrk_5ga_n[2] = rtw8821c_pwrtrk_5ga_n[2],
17338c2ecf20Sopenharmony_ci	.pwrtrk_5ga_p[0] = rtw8821c_pwrtrk_5ga_p[0],
17348c2ecf20Sopenharmony_ci	.pwrtrk_5ga_p[1] = rtw8821c_pwrtrk_5ga_p[1],
17358c2ecf20Sopenharmony_ci	.pwrtrk_5ga_p[2] = rtw8821c_pwrtrk_5ga_p[2],
17368c2ecf20Sopenharmony_ci	.pwrtrk_2gb_n = rtw8821c_pwrtrk_2gb_n,
17378c2ecf20Sopenharmony_ci	.pwrtrk_2gb_p = rtw8821c_pwrtrk_2gb_p,
17388c2ecf20Sopenharmony_ci	.pwrtrk_2ga_n = rtw8821c_pwrtrk_2ga_n,
17398c2ecf20Sopenharmony_ci	.pwrtrk_2ga_p = rtw8821c_pwrtrk_2ga_p,
17408c2ecf20Sopenharmony_ci	.pwrtrk_2g_cckb_n = rtw8821c_pwrtrk_2g_cck_b_n,
17418c2ecf20Sopenharmony_ci	.pwrtrk_2g_cckb_p = rtw8821c_pwrtrk_2g_cck_b_p,
17428c2ecf20Sopenharmony_ci	.pwrtrk_2g_ccka_n = rtw8821c_pwrtrk_2g_cck_a_n,
17438c2ecf20Sopenharmony_ci	.pwrtrk_2g_ccka_p = rtw8821c_pwrtrk_2g_cck_a_p,
17448c2ecf20Sopenharmony_ci};
17458c2ecf20Sopenharmony_ci
17468c2ecf20Sopenharmony_cistatic const struct rtw_reg_domain coex_info_hw_regs_8821c[] = {
17478c2ecf20Sopenharmony_ci	{0xCB0, MASKDWORD, RTW_REG_DOMAIN_MAC32},
17488c2ecf20Sopenharmony_ci	{0xCB4, MASKDWORD, RTW_REG_DOMAIN_MAC32},
17498c2ecf20Sopenharmony_ci	{0xCBA, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
17508c2ecf20Sopenharmony_ci	{0, 0, RTW_REG_DOMAIN_NL},
17518c2ecf20Sopenharmony_ci	{0x430, MASKDWORD, RTW_REG_DOMAIN_MAC32},
17528c2ecf20Sopenharmony_ci	{0x434, MASKDWORD, RTW_REG_DOMAIN_MAC32},
17538c2ecf20Sopenharmony_ci	{0x42a, MASKLWORD, RTW_REG_DOMAIN_MAC16},
17548c2ecf20Sopenharmony_ci	{0x426, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
17558c2ecf20Sopenharmony_ci	{0x45e, BIT(3), RTW_REG_DOMAIN_MAC8},
17568c2ecf20Sopenharmony_ci	{0x454, MASKLWORD, RTW_REG_DOMAIN_MAC16},
17578c2ecf20Sopenharmony_ci	{0, 0, RTW_REG_DOMAIN_NL},
17588c2ecf20Sopenharmony_ci	{0x4c, BIT(24) | BIT(23), RTW_REG_DOMAIN_MAC32},
17598c2ecf20Sopenharmony_ci	{0x64, BIT(0), RTW_REG_DOMAIN_MAC8},
17608c2ecf20Sopenharmony_ci	{0x4c6, BIT(4), RTW_REG_DOMAIN_MAC8},
17618c2ecf20Sopenharmony_ci	{0x40, BIT(5), RTW_REG_DOMAIN_MAC8},
17628c2ecf20Sopenharmony_ci	{0x1, RFREG_MASK, RTW_REG_DOMAIN_RF_A},
17638c2ecf20Sopenharmony_ci	{0, 0, RTW_REG_DOMAIN_NL},
17648c2ecf20Sopenharmony_ci	{0x550, MASKDWORD, RTW_REG_DOMAIN_MAC32},
17658c2ecf20Sopenharmony_ci	{0x522, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
17668c2ecf20Sopenharmony_ci	{0x953, BIT(1), RTW_REG_DOMAIN_MAC8},
17678c2ecf20Sopenharmony_ci	{0xc50,  MASKBYTE0, RTW_REG_DOMAIN_MAC8},
17688c2ecf20Sopenharmony_ci	{0x60A, MASKBYTE0, RTW_REG_DOMAIN_MAC8},
17698c2ecf20Sopenharmony_ci};
17708c2ecf20Sopenharmony_ci
17718c2ecf20Sopenharmony_cistruct rtw_chip_info rtw8821c_hw_spec = {
17728c2ecf20Sopenharmony_ci	.ops = &rtw8821c_ops,
17738c2ecf20Sopenharmony_ci	.id = RTW_CHIP_TYPE_8821C,
17748c2ecf20Sopenharmony_ci	.fw_name = "rtw88/rtw8821c_fw.bin",
17758c2ecf20Sopenharmony_ci	.wlan_cpu = RTW_WCPU_11AC,
17768c2ecf20Sopenharmony_ci	.tx_pkt_desc_sz = 48,
17778c2ecf20Sopenharmony_ci	.tx_buf_desc_sz = 16,
17788c2ecf20Sopenharmony_ci	.rx_pkt_desc_sz = 24,
17798c2ecf20Sopenharmony_ci	.rx_buf_desc_sz = 8,
17808c2ecf20Sopenharmony_ci	.phy_efuse_size = 512,
17818c2ecf20Sopenharmony_ci	.log_efuse_size = 512,
17828c2ecf20Sopenharmony_ci	.ptct_efuse_size = 96,
17838c2ecf20Sopenharmony_ci	.txff_size = 65536,
17848c2ecf20Sopenharmony_ci	.rxff_size = 16384,
17858c2ecf20Sopenharmony_ci	.txgi_factor = 1,
17868c2ecf20Sopenharmony_ci	.is_pwr_by_rate_dec = true,
17878c2ecf20Sopenharmony_ci	.max_power_index = 0x3f,
17888c2ecf20Sopenharmony_ci	.csi_buf_pg_num = 0,
17898c2ecf20Sopenharmony_ci	.band = RTW_BAND_2G | RTW_BAND_5G,
17908c2ecf20Sopenharmony_ci	.page_size = 128,
17918c2ecf20Sopenharmony_ci	.dig_min = 0x1c,
17928c2ecf20Sopenharmony_ci	.ht_supported = true,
17938c2ecf20Sopenharmony_ci	.vht_supported = true,
17948c2ecf20Sopenharmony_ci	.lps_deep_mode_supported = BIT(LPS_DEEP_MODE_LCLK),
17958c2ecf20Sopenharmony_ci	.sys_func_en = 0xD8,
17968c2ecf20Sopenharmony_ci	.pwr_on_seq = card_enable_flow_8821c,
17978c2ecf20Sopenharmony_ci	.pwr_off_seq = card_disable_flow_8821c,
17988c2ecf20Sopenharmony_ci	.page_table = page_table_8821c,
17998c2ecf20Sopenharmony_ci	.rqpn_table = rqpn_table_8821c,
18008c2ecf20Sopenharmony_ci	.prioq_addrs = &prioq_addrs_8821c,
18018c2ecf20Sopenharmony_ci	.intf_table = &phy_para_table_8821c,
18028c2ecf20Sopenharmony_ci	.dig = rtw8821c_dig,
18038c2ecf20Sopenharmony_ci	.rf_base_addr = {0x2800, 0x2c00},
18048c2ecf20Sopenharmony_ci	.rf_sipi_addr = {0xc90, 0xe90},
18058c2ecf20Sopenharmony_ci	.ltecoex_addr = &rtw8821c_ltecoex_addr,
18068c2ecf20Sopenharmony_ci	.mac_tbl = &rtw8821c_mac_tbl,
18078c2ecf20Sopenharmony_ci	.agc_tbl = &rtw8821c_agc_tbl,
18088c2ecf20Sopenharmony_ci	.bb_tbl = &rtw8821c_bb_tbl,
18098c2ecf20Sopenharmony_ci	.rf_tbl = {&rtw8821c_rf_a_tbl},
18108c2ecf20Sopenharmony_ci	.rfe_defs = rtw8821c_rfe_defs,
18118c2ecf20Sopenharmony_ci	.rfe_defs_size = ARRAY_SIZE(rtw8821c_rfe_defs),
18128c2ecf20Sopenharmony_ci	.rx_ldpc = false,
18138c2ecf20Sopenharmony_ci	.pwr_track_tbl = &rtw8821c_rtw_pwr_track_tbl,
18148c2ecf20Sopenharmony_ci	.iqk_threshold = 8,
18158c2ecf20Sopenharmony_ci	.bfer_su_max_num = 2,
18168c2ecf20Sopenharmony_ci	.bfer_mu_max_num = 1,
18178c2ecf20Sopenharmony_ci
18188c2ecf20Sopenharmony_ci	.coex_para_ver = 0x19092746,
18198c2ecf20Sopenharmony_ci	.bt_desired_ver = 0x46,
18208c2ecf20Sopenharmony_ci	.scbd_support = true,
18218c2ecf20Sopenharmony_ci	.new_scbd10_def = false,
18228c2ecf20Sopenharmony_ci	.pstdma_type = COEX_PSTDMA_FORCE_LPSOFF,
18238c2ecf20Sopenharmony_ci	.bt_rssi_type = COEX_BTRSSI_RATIO,
18248c2ecf20Sopenharmony_ci	.ant_isolation = 15,
18258c2ecf20Sopenharmony_ci	.rssi_tolerance = 2,
18268c2ecf20Sopenharmony_ci	.wl_rssi_step = wl_rssi_step_8821c,
18278c2ecf20Sopenharmony_ci	.bt_rssi_step = bt_rssi_step_8821c,
18288c2ecf20Sopenharmony_ci	.table_sant_num = ARRAY_SIZE(table_sant_8821c),
18298c2ecf20Sopenharmony_ci	.table_sant = table_sant_8821c,
18308c2ecf20Sopenharmony_ci	.table_nsant_num = ARRAY_SIZE(table_nsant_8821c),
18318c2ecf20Sopenharmony_ci	.table_nsant = table_nsant_8821c,
18328c2ecf20Sopenharmony_ci	.tdma_sant_num = ARRAY_SIZE(tdma_sant_8821c),
18338c2ecf20Sopenharmony_ci	.tdma_sant = tdma_sant_8821c,
18348c2ecf20Sopenharmony_ci	.tdma_nsant_num = ARRAY_SIZE(tdma_nsant_8821c),
18358c2ecf20Sopenharmony_ci	.tdma_nsant = tdma_nsant_8821c,
18368c2ecf20Sopenharmony_ci	.wl_rf_para_num = ARRAY_SIZE(rf_para_tx_8821c),
18378c2ecf20Sopenharmony_ci	.wl_rf_para_tx = rf_para_tx_8821c,
18388c2ecf20Sopenharmony_ci	.wl_rf_para_rx = rf_para_rx_8821c,
18398c2ecf20Sopenharmony_ci	.bt_afh_span_bw20 = 0x24,
18408c2ecf20Sopenharmony_ci	.bt_afh_span_bw40 = 0x36,
18418c2ecf20Sopenharmony_ci	.afh_5g_num = ARRAY_SIZE(afh_5g_8821c),
18428c2ecf20Sopenharmony_ci	.afh_5g = afh_5g_8821c,
18438c2ecf20Sopenharmony_ci
18448c2ecf20Sopenharmony_ci	.coex_info_hw_regs_num = ARRAY_SIZE(coex_info_hw_regs_8821c),
18458c2ecf20Sopenharmony_ci	.coex_info_hw_regs = coex_info_hw_regs_8821c,
18468c2ecf20Sopenharmony_ci};
18478c2ecf20Sopenharmony_ciEXPORT_SYMBOL(rtw8821c_hw_spec);
18488c2ecf20Sopenharmony_ci
18498c2ecf20Sopenharmony_ciMODULE_FIRMWARE("rtw88/rtw8821c_fw.bin");
18508c2ecf20Sopenharmony_ci
18518c2ecf20Sopenharmony_ciMODULE_AUTHOR("Realtek Corporation");
18528c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Realtek 802.11ac wireless 8821c driver");
18538c2ecf20Sopenharmony_ciMODULE_LICENSE("Dual BSD/GPL");
1854