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 <linux/module.h> 68c2ecf20Sopenharmony_ci#include "main.h" 78c2ecf20Sopenharmony_ci#include "coex.h" 88c2ecf20Sopenharmony_ci#include "fw.h" 98c2ecf20Sopenharmony_ci#include "tx.h" 108c2ecf20Sopenharmony_ci#include "rx.h" 118c2ecf20Sopenharmony_ci#include "phy.h" 128c2ecf20Sopenharmony_ci#include "rtw8822b.h" 138c2ecf20Sopenharmony_ci#include "rtw8822b_table.h" 148c2ecf20Sopenharmony_ci#include "mac.h" 158c2ecf20Sopenharmony_ci#include "reg.h" 168c2ecf20Sopenharmony_ci#include "debug.h" 178c2ecf20Sopenharmony_ci#include "bf.h" 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_cistatic void rtw8822b_config_trx_mode(struct rtw_dev *rtwdev, u8 tx_path, 208c2ecf20Sopenharmony_ci u8 rx_path, bool is_tx2_path); 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cistatic void rtw8822be_efuse_parsing(struct rtw_efuse *efuse, 238c2ecf20Sopenharmony_ci struct rtw8822b_efuse *map) 248c2ecf20Sopenharmony_ci{ 258c2ecf20Sopenharmony_ci ether_addr_copy(efuse->addr, map->e.mac_addr); 268c2ecf20Sopenharmony_ci} 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_cistatic int rtw8822b_read_efuse(struct rtw_dev *rtwdev, u8 *log_map) 298c2ecf20Sopenharmony_ci{ 308c2ecf20Sopenharmony_ci struct rtw_efuse *efuse = &rtwdev->efuse; 318c2ecf20Sopenharmony_ci struct rtw8822b_efuse *map; 328c2ecf20Sopenharmony_ci int i; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci map = (struct rtw8822b_efuse *)log_map; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci efuse->rfe_option = map->rfe_option; 378c2ecf20Sopenharmony_ci efuse->rf_board_option = map->rf_board_option; 388c2ecf20Sopenharmony_ci efuse->crystal_cap = map->xtal_k; 398c2ecf20Sopenharmony_ci efuse->pa_type_2g = map->pa_type; 408c2ecf20Sopenharmony_ci efuse->pa_type_5g = map->pa_type; 418c2ecf20Sopenharmony_ci efuse->lna_type_2g = map->lna_type_2g[0]; 428c2ecf20Sopenharmony_ci efuse->lna_type_5g = map->lna_type_5g[0]; 438c2ecf20Sopenharmony_ci efuse->channel_plan = map->channel_plan; 448c2ecf20Sopenharmony_ci efuse->country_code[0] = map->country_code[0]; 458c2ecf20Sopenharmony_ci efuse->country_code[1] = map->country_code[1]; 468c2ecf20Sopenharmony_ci efuse->bt_setting = map->rf_bt_setting; 478c2ecf20Sopenharmony_ci efuse->regd = map->rf_board_option & 0x7; 488c2ecf20Sopenharmony_ci efuse->thermal_meter[RF_PATH_A] = map->thermal_meter; 498c2ecf20Sopenharmony_ci efuse->thermal_meter_k = map->thermal_meter; 508c2ecf20Sopenharmony_ci 518c2ecf20Sopenharmony_ci for (i = 0; i < 4; i++) 528c2ecf20Sopenharmony_ci efuse->txpwr_idx_table[i] = map->txpwr_idx_table[i]; 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci switch (rtw_hci_type(rtwdev)) { 558c2ecf20Sopenharmony_ci case RTW_HCI_TYPE_PCIE: 568c2ecf20Sopenharmony_ci rtw8822be_efuse_parsing(efuse, map); 578c2ecf20Sopenharmony_ci break; 588c2ecf20Sopenharmony_ci default: 598c2ecf20Sopenharmony_ci /* unsupported now */ 608c2ecf20Sopenharmony_ci return -ENOTSUPP; 618c2ecf20Sopenharmony_ci } 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci return 0; 648c2ecf20Sopenharmony_ci} 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_cistatic void rtw8822b_phy_rfe_init(struct rtw_dev *rtwdev) 678c2ecf20Sopenharmony_ci{ 688c2ecf20Sopenharmony_ci /* chip top mux */ 698c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, 0x64, BIT(29) | BIT(28), 0x3); 708c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, 0x4c, BIT(26) | BIT(25), 0x0); 718c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, 0x40, BIT(2), 0x1); 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci /* from s0 or s1 */ 748c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, 0x1990, 0x3f, 0x30); 758c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, 0x1990, (BIT(11) | BIT(10)), 0x3); 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci /* input or output */ 788c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, 0x974, 0x3f, 0x3f); 798c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, 0x974, (BIT(11) | BIT(10)), 0x3); 808c2ecf20Sopenharmony_ci} 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci#define RTW_TXSCALE_SIZE 37 838c2ecf20Sopenharmony_cistatic const u32 rtw8822b_txscale_tbl[RTW_TXSCALE_SIZE] = { 848c2ecf20Sopenharmony_ci 0x081, 0x088, 0x090, 0x099, 0x0a2, 0x0ac, 0x0b6, 0x0c0, 0x0cc, 0x0d8, 858c2ecf20Sopenharmony_ci 0x0e5, 0x0f2, 0x101, 0x110, 0x120, 0x131, 0x143, 0x156, 0x16a, 0x180, 868c2ecf20Sopenharmony_ci 0x197, 0x1af, 0x1c8, 0x1e3, 0x200, 0x21e, 0x23e, 0x261, 0x285, 0x2ab, 878c2ecf20Sopenharmony_ci 0x2d3, 0x2fe, 0x32b, 0x35c, 0x38e, 0x3c4, 0x3fe 888c2ecf20Sopenharmony_ci}; 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_cistatic const u8 rtw8822b_get_swing_index(struct rtw_dev *rtwdev) 918c2ecf20Sopenharmony_ci{ 928c2ecf20Sopenharmony_ci u8 i = 0; 938c2ecf20Sopenharmony_ci u32 swing, table_value; 948c2ecf20Sopenharmony_ci 958c2ecf20Sopenharmony_ci swing = rtw_read32_mask(rtwdev, 0xc1c, 0xffe00000); 968c2ecf20Sopenharmony_ci for (i = 0; i < RTW_TXSCALE_SIZE; i++) { 978c2ecf20Sopenharmony_ci table_value = rtw8822b_txscale_tbl[i]; 988c2ecf20Sopenharmony_ci if (swing == table_value) 998c2ecf20Sopenharmony_ci break; 1008c2ecf20Sopenharmony_ci } 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ci return i; 1038c2ecf20Sopenharmony_ci} 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_cistatic void rtw8822b_pwrtrack_init(struct rtw_dev *rtwdev) 1068c2ecf20Sopenharmony_ci{ 1078c2ecf20Sopenharmony_ci struct rtw_dm_info *dm_info = &rtwdev->dm_info; 1088c2ecf20Sopenharmony_ci u8 swing_idx = rtw8822b_get_swing_index(rtwdev); 1098c2ecf20Sopenharmony_ci u8 path; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci if (swing_idx >= RTW_TXSCALE_SIZE) 1128c2ecf20Sopenharmony_ci dm_info->default_ofdm_index = 24; 1138c2ecf20Sopenharmony_ci else 1148c2ecf20Sopenharmony_ci dm_info->default_ofdm_index = swing_idx; 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci for (path = RF_PATH_A; path < rtwdev->hal.rf_path_num; path++) { 1178c2ecf20Sopenharmony_ci ewma_thermal_init(&dm_info->avg_thermal[path]); 1188c2ecf20Sopenharmony_ci dm_info->delta_power_index[path] = 0; 1198c2ecf20Sopenharmony_ci } 1208c2ecf20Sopenharmony_ci dm_info->pwr_trk_triggered = false; 1218c2ecf20Sopenharmony_ci dm_info->pwr_trk_init_trigger = true; 1228c2ecf20Sopenharmony_ci dm_info->thermal_meter_k = rtwdev->efuse.thermal_meter_k; 1238c2ecf20Sopenharmony_ci} 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_cistatic void rtw8822b_phy_bf_init(struct rtw_dev *rtwdev) 1268c2ecf20Sopenharmony_ci{ 1278c2ecf20Sopenharmony_ci rtw_bf_phy_init(rtwdev); 1288c2ecf20Sopenharmony_ci /* Grouping bitmap parameters */ 1298c2ecf20Sopenharmony_ci rtw_write32(rtwdev, 0x1C94, 0xAFFFAFFF); 1308c2ecf20Sopenharmony_ci} 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_cistatic void rtw8822b_phy_set_param(struct rtw_dev *rtwdev) 1338c2ecf20Sopenharmony_ci{ 1348c2ecf20Sopenharmony_ci struct rtw_hal *hal = &rtwdev->hal; 1358c2ecf20Sopenharmony_ci u8 crystal_cap; 1368c2ecf20Sopenharmony_ci bool is_tx2_path; 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ci /* power on BB/RF domain */ 1398c2ecf20Sopenharmony_ci rtw_write8_set(rtwdev, REG_SYS_FUNC_EN, 1408c2ecf20Sopenharmony_ci BIT_FEN_BB_RSTB | BIT_FEN_BB_GLB_RST); 1418c2ecf20Sopenharmony_ci rtw_write8_set(rtwdev, REG_RF_CTRL, 1428c2ecf20Sopenharmony_ci BIT_RF_EN | BIT_RF_RSTB | BIT_RF_SDM_RSTB); 1438c2ecf20Sopenharmony_ci rtw_write32_set(rtwdev, REG_WLRF1, BIT_WLRF1_BBRF_EN); 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_ci /* pre init before header files config */ 1468c2ecf20Sopenharmony_ci rtw_write32_clr(rtwdev, REG_RXPSEL, BIT_RX_PSEL_RST); 1478c2ecf20Sopenharmony_ci 1488c2ecf20Sopenharmony_ci rtw_phy_load_tables(rtwdev); 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_ci crystal_cap = rtwdev->efuse.crystal_cap & 0x3F; 1518c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, 0x24, 0x7e000000, crystal_cap); 1528c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, 0x28, 0x7e, crystal_cap); 1538c2ecf20Sopenharmony_ci 1548c2ecf20Sopenharmony_ci /* post init after header files config */ 1558c2ecf20Sopenharmony_ci rtw_write32_set(rtwdev, REG_RXPSEL, BIT_RX_PSEL_RST); 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci is_tx2_path = false; 1588c2ecf20Sopenharmony_ci rtw8822b_config_trx_mode(rtwdev, hal->antenna_tx, hal->antenna_rx, 1598c2ecf20Sopenharmony_ci is_tx2_path); 1608c2ecf20Sopenharmony_ci rtw_phy_init(rtwdev); 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci rtw8822b_phy_rfe_init(rtwdev); 1638c2ecf20Sopenharmony_ci rtw8822b_pwrtrack_init(rtwdev); 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci rtw8822b_phy_bf_init(rtwdev); 1668c2ecf20Sopenharmony_ci} 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci#define WLAN_SLOT_TIME 0x09 1698c2ecf20Sopenharmony_ci#define WLAN_PIFS_TIME 0x19 1708c2ecf20Sopenharmony_ci#define WLAN_SIFS_CCK_CONT_TX 0xA 1718c2ecf20Sopenharmony_ci#define WLAN_SIFS_OFDM_CONT_TX 0xE 1728c2ecf20Sopenharmony_ci#define WLAN_SIFS_CCK_TRX 0x10 1738c2ecf20Sopenharmony_ci#define WLAN_SIFS_OFDM_TRX 0x10 1748c2ecf20Sopenharmony_ci#define WLAN_VO_TXOP_LIMIT 0x186 /* unit : 32us */ 1758c2ecf20Sopenharmony_ci#define WLAN_VI_TXOP_LIMIT 0x3BC /* unit : 32us */ 1768c2ecf20Sopenharmony_ci#define WLAN_RDG_NAV 0x05 1778c2ecf20Sopenharmony_ci#define WLAN_TXOP_NAV 0x1B 1788c2ecf20Sopenharmony_ci#define WLAN_CCK_RX_TSF 0x30 1798c2ecf20Sopenharmony_ci#define WLAN_OFDM_RX_TSF 0x30 1808c2ecf20Sopenharmony_ci#define WLAN_TBTT_PROHIBIT 0x04 /* unit : 32us */ 1818c2ecf20Sopenharmony_ci#define WLAN_TBTT_HOLD_TIME 0x064 /* unit : 32us */ 1828c2ecf20Sopenharmony_ci#define WLAN_DRV_EARLY_INT 0x04 1838c2ecf20Sopenharmony_ci#define WLAN_BCN_DMA_TIME 0x02 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci#define WLAN_RX_FILTER0 0x0FFFFFFF 1868c2ecf20Sopenharmony_ci#define WLAN_RX_FILTER2 0xFFFF 1878c2ecf20Sopenharmony_ci#define WLAN_RCR_CFG 0xE400220E 1888c2ecf20Sopenharmony_ci#define WLAN_RXPKT_MAX_SZ 12288 1898c2ecf20Sopenharmony_ci#define WLAN_RXPKT_MAX_SZ_512 (WLAN_RXPKT_MAX_SZ >> 9) 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci#define WLAN_AMPDU_MAX_TIME 0x70 1928c2ecf20Sopenharmony_ci#define WLAN_RTS_LEN_TH 0xFF 1938c2ecf20Sopenharmony_ci#define WLAN_RTS_TX_TIME_TH 0x08 1948c2ecf20Sopenharmony_ci#define WLAN_MAX_AGG_PKT_LIMIT 0x20 1958c2ecf20Sopenharmony_ci#define WLAN_RTS_MAX_AGG_PKT_LIMIT 0x20 1968c2ecf20Sopenharmony_ci#define FAST_EDCA_VO_TH 0x06 1978c2ecf20Sopenharmony_ci#define FAST_EDCA_VI_TH 0x06 1988c2ecf20Sopenharmony_ci#define FAST_EDCA_BE_TH 0x06 1998c2ecf20Sopenharmony_ci#define FAST_EDCA_BK_TH 0x06 2008c2ecf20Sopenharmony_ci#define WLAN_BAR_RETRY_LIMIT 0x01 2018c2ecf20Sopenharmony_ci#define WLAN_RA_TRY_RATE_AGG_LIMIT 0x08 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ci#define WLAN_TX_FUNC_CFG1 0x30 2048c2ecf20Sopenharmony_ci#define WLAN_TX_FUNC_CFG2 0x30 2058c2ecf20Sopenharmony_ci#define WLAN_MAC_OPT_NORM_FUNC1 0x98 2068c2ecf20Sopenharmony_ci#define WLAN_MAC_OPT_LB_FUNC1 0x80 2078c2ecf20Sopenharmony_ci#define WLAN_MAC_OPT_FUNC2 0xb0810041 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci#define WLAN_SIFS_CFG (WLAN_SIFS_CCK_CONT_TX | \ 2108c2ecf20Sopenharmony_ci (WLAN_SIFS_OFDM_CONT_TX << BIT_SHIFT_SIFS_OFDM_CTX) | \ 2118c2ecf20Sopenharmony_ci (WLAN_SIFS_CCK_TRX << BIT_SHIFT_SIFS_CCK_TRX) | \ 2128c2ecf20Sopenharmony_ci (WLAN_SIFS_OFDM_TRX << BIT_SHIFT_SIFS_OFDM_TRX)) 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci#define WLAN_TBTT_TIME (WLAN_TBTT_PROHIBIT |\ 2158c2ecf20Sopenharmony_ci (WLAN_TBTT_HOLD_TIME << BIT_SHIFT_TBTT_HOLD_TIME_AP)) 2168c2ecf20Sopenharmony_ci 2178c2ecf20Sopenharmony_ci#define WLAN_NAV_CFG (WLAN_RDG_NAV | (WLAN_TXOP_NAV << 16)) 2188c2ecf20Sopenharmony_ci#define WLAN_RX_TSF_CFG (WLAN_CCK_RX_TSF | (WLAN_OFDM_RX_TSF) << 8) 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_cistatic int rtw8822b_mac_init(struct rtw_dev *rtwdev) 2218c2ecf20Sopenharmony_ci{ 2228c2ecf20Sopenharmony_ci u32 value32; 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci /* protocol configuration */ 2258c2ecf20Sopenharmony_ci rtw_write8_clr(rtwdev, REG_SW_AMPDU_BURST_MODE_CTRL, BIT_PRE_TX_CMD); 2268c2ecf20Sopenharmony_ci rtw_write8(rtwdev, REG_AMPDU_MAX_TIME_V1, WLAN_AMPDU_MAX_TIME); 2278c2ecf20Sopenharmony_ci rtw_write8_set(rtwdev, REG_TX_HANG_CTRL, BIT_EN_EOF_V1); 2288c2ecf20Sopenharmony_ci value32 = WLAN_RTS_LEN_TH | (WLAN_RTS_TX_TIME_TH << 8) | 2298c2ecf20Sopenharmony_ci (WLAN_MAX_AGG_PKT_LIMIT << 16) | 2308c2ecf20Sopenharmony_ci (WLAN_RTS_MAX_AGG_PKT_LIMIT << 24); 2318c2ecf20Sopenharmony_ci rtw_write32(rtwdev, REG_PROT_MODE_CTRL, value32); 2328c2ecf20Sopenharmony_ci rtw_write16(rtwdev, REG_BAR_MODE_CTRL + 2, 2338c2ecf20Sopenharmony_ci WLAN_BAR_RETRY_LIMIT | WLAN_RA_TRY_RATE_AGG_LIMIT << 8); 2348c2ecf20Sopenharmony_ci rtw_write8(rtwdev, REG_FAST_EDCA_VOVI_SETTING, FAST_EDCA_VO_TH); 2358c2ecf20Sopenharmony_ci rtw_write8(rtwdev, REG_FAST_EDCA_VOVI_SETTING + 2, FAST_EDCA_VI_TH); 2368c2ecf20Sopenharmony_ci rtw_write8(rtwdev, REG_FAST_EDCA_BEBK_SETTING, FAST_EDCA_BE_TH); 2378c2ecf20Sopenharmony_ci rtw_write8(rtwdev, REG_FAST_EDCA_BEBK_SETTING + 2, FAST_EDCA_BK_TH); 2388c2ecf20Sopenharmony_ci /* EDCA configuration */ 2398c2ecf20Sopenharmony_ci rtw_write8_clr(rtwdev, REG_TIMER0_SRC_SEL, BIT_TSFT_SEL_TIMER0); 2408c2ecf20Sopenharmony_ci rtw_write16(rtwdev, REG_TXPAUSE, 0x0000); 2418c2ecf20Sopenharmony_ci rtw_write8(rtwdev, REG_SLOT, WLAN_SLOT_TIME); 2428c2ecf20Sopenharmony_ci rtw_write8(rtwdev, REG_PIFS, WLAN_PIFS_TIME); 2438c2ecf20Sopenharmony_ci rtw_write32(rtwdev, REG_SIFS, WLAN_SIFS_CFG); 2448c2ecf20Sopenharmony_ci rtw_write16(rtwdev, REG_EDCA_VO_PARAM + 2, WLAN_VO_TXOP_LIMIT); 2458c2ecf20Sopenharmony_ci rtw_write16(rtwdev, REG_EDCA_VI_PARAM + 2, WLAN_VI_TXOP_LIMIT); 2468c2ecf20Sopenharmony_ci rtw_write32(rtwdev, REG_RD_NAV_NXT, WLAN_NAV_CFG); 2478c2ecf20Sopenharmony_ci rtw_write16(rtwdev, REG_RXTSF_OFFSET_CCK, WLAN_RX_TSF_CFG); 2488c2ecf20Sopenharmony_ci /* Set beacon cotnrol - enable TSF and other related functions */ 2498c2ecf20Sopenharmony_ci rtw_write8_set(rtwdev, REG_BCN_CTRL, BIT_EN_BCN_FUNCTION); 2508c2ecf20Sopenharmony_ci /* Set send beacon related registers */ 2518c2ecf20Sopenharmony_ci rtw_write32(rtwdev, REG_TBTT_PROHIBIT, WLAN_TBTT_TIME); 2528c2ecf20Sopenharmony_ci rtw_write8(rtwdev, REG_DRVERLYINT, WLAN_DRV_EARLY_INT); 2538c2ecf20Sopenharmony_ci rtw_write8(rtwdev, REG_BCNDMATIM, WLAN_BCN_DMA_TIME); 2548c2ecf20Sopenharmony_ci rtw_write8_clr(rtwdev, REG_TX_PTCL_CTRL + 1, BIT_SIFS_BK_EN >> 8); 2558c2ecf20Sopenharmony_ci /* WMAC configuration */ 2568c2ecf20Sopenharmony_ci rtw_write32(rtwdev, REG_RXFLTMAP0, WLAN_RX_FILTER0); 2578c2ecf20Sopenharmony_ci rtw_write16(rtwdev, REG_RXFLTMAP2, WLAN_RX_FILTER2); 2588c2ecf20Sopenharmony_ci rtw_write32(rtwdev, REG_RCR, WLAN_RCR_CFG); 2598c2ecf20Sopenharmony_ci rtw_write8(rtwdev, REG_RX_PKT_LIMIT, WLAN_RXPKT_MAX_SZ_512); 2608c2ecf20Sopenharmony_ci rtw_write8(rtwdev, REG_TCR + 2, WLAN_TX_FUNC_CFG2); 2618c2ecf20Sopenharmony_ci rtw_write8(rtwdev, REG_TCR + 1, WLAN_TX_FUNC_CFG1); 2628c2ecf20Sopenharmony_ci rtw_write32(rtwdev, REG_WMAC_OPTION_FUNCTION + 8, WLAN_MAC_OPT_FUNC2); 2638c2ecf20Sopenharmony_ci rtw_write8(rtwdev, REG_WMAC_OPTION_FUNCTION + 4, WLAN_MAC_OPT_NORM_FUNC1); 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci return 0; 2668c2ecf20Sopenharmony_ci} 2678c2ecf20Sopenharmony_ci 2688c2ecf20Sopenharmony_cistatic void rtw8822b_set_channel_rfe_efem(struct rtw_dev *rtwdev, u8 channel) 2698c2ecf20Sopenharmony_ci{ 2708c2ecf20Sopenharmony_ci struct rtw_hal *hal = &rtwdev->hal; 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci if (IS_CH_2G_BAND(channel)) { 2738c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_RFESEL0, 0xffffff, 0x705770); 2748c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_RFESEL8, MASKBYTE1, 0x57); 2758c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_RFECTL, BIT(4), 0); 2768c2ecf20Sopenharmony_ci } else { 2778c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_RFESEL0, 0xffffff, 0x177517); 2788c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_RFESEL8, MASKBYTE1, 0x75); 2798c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_RFECTL, BIT(5), 0); 2808c2ecf20Sopenharmony_ci } 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_RFEINV, BIT(11) | BIT(10) | 0x3f, 0x0); 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci if (hal->antenna_rx == BB_PATH_AB || 2858c2ecf20Sopenharmony_ci hal->antenna_tx == BB_PATH_AB) { 2868c2ecf20Sopenharmony_ci /* 2TX or 2RX */ 2878c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_TRSW, MASKLWORD, 0xa501); 2888c2ecf20Sopenharmony_ci } else if (hal->antenna_rx == hal->antenna_tx) { 2898c2ecf20Sopenharmony_ci /* TXA+RXA or TXB+RXB */ 2908c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_TRSW, MASKLWORD, 0xa500); 2918c2ecf20Sopenharmony_ci } else { 2928c2ecf20Sopenharmony_ci /* TXB+RXA or TXA+RXB */ 2938c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_TRSW, MASKLWORD, 0xa005); 2948c2ecf20Sopenharmony_ci } 2958c2ecf20Sopenharmony_ci} 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_cistatic void rtw8822b_set_channel_rfe_ifem(struct rtw_dev *rtwdev, u8 channel) 2988c2ecf20Sopenharmony_ci{ 2998c2ecf20Sopenharmony_ci struct rtw_hal *hal = &rtwdev->hal; 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci if (IS_CH_2G_BAND(channel)) { 3028c2ecf20Sopenharmony_ci /* signal source */ 3038c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_RFESEL0, 0xffffff, 0x745774); 3048c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_RFESEL8, MASKBYTE1, 0x57); 3058c2ecf20Sopenharmony_ci } else { 3068c2ecf20Sopenharmony_ci /* signal source */ 3078c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_RFESEL0, 0xffffff, 0x477547); 3088c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_RFESEL8, MASKBYTE1, 0x75); 3098c2ecf20Sopenharmony_ci } 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_RFEINV, BIT(11) | BIT(10) | 0x3f, 0x0); 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci if (IS_CH_2G_BAND(channel)) { 3148c2ecf20Sopenharmony_ci if (hal->antenna_rx == BB_PATH_AB || 3158c2ecf20Sopenharmony_ci hal->antenna_tx == BB_PATH_AB) { 3168c2ecf20Sopenharmony_ci /* 2TX or 2RX */ 3178c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_TRSW, MASKLWORD, 0xa501); 3188c2ecf20Sopenharmony_ci } else if (hal->antenna_rx == hal->antenna_tx) { 3198c2ecf20Sopenharmony_ci /* TXA+RXA or TXB+RXB */ 3208c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_TRSW, MASKLWORD, 0xa500); 3218c2ecf20Sopenharmony_ci } else { 3228c2ecf20Sopenharmony_ci /* TXB+RXA or TXA+RXB */ 3238c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_TRSW, MASKLWORD, 0xa005); 3248c2ecf20Sopenharmony_ci } 3258c2ecf20Sopenharmony_ci } else { 3268c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_TRSW, MASKLWORD, 0xa5a5); 3278c2ecf20Sopenharmony_ci } 3288c2ecf20Sopenharmony_ci} 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_cienum { 3318c2ecf20Sopenharmony_ci CCUT_IDX_1R_2G, 3328c2ecf20Sopenharmony_ci CCUT_IDX_2R_2G, 3338c2ecf20Sopenharmony_ci CCUT_IDX_1R_5G, 3348c2ecf20Sopenharmony_ci CCUT_IDX_2R_5G, 3358c2ecf20Sopenharmony_ci CCUT_IDX_NR, 3368c2ecf20Sopenharmony_ci}; 3378c2ecf20Sopenharmony_ci 3388c2ecf20Sopenharmony_cistruct cca_ccut { 3398c2ecf20Sopenharmony_ci u32 reg82c[CCUT_IDX_NR]; 3408c2ecf20Sopenharmony_ci u32 reg830[CCUT_IDX_NR]; 3418c2ecf20Sopenharmony_ci u32 reg838[CCUT_IDX_NR]; 3428c2ecf20Sopenharmony_ci}; 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_cistatic const struct cca_ccut cca_ifem_ccut = { 3458c2ecf20Sopenharmony_ci {0x75C97010, 0x75C97010, 0x75C97010, 0x75C97010}, /*Reg82C*/ 3468c2ecf20Sopenharmony_ci {0x79a0eaaa, 0x79A0EAAC, 0x79a0eaaa, 0x79a0eaaa}, /*Reg830*/ 3478c2ecf20Sopenharmony_ci {0x87765541, 0x87746341, 0x87765541, 0x87746341}, /*Reg838*/ 3488c2ecf20Sopenharmony_ci}; 3498c2ecf20Sopenharmony_ci 3508c2ecf20Sopenharmony_cistatic const struct cca_ccut cca_efem_ccut = { 3518c2ecf20Sopenharmony_ci {0x75B86010, 0x75B76010, 0x75B86010, 0x75B76010}, /*Reg82C*/ 3528c2ecf20Sopenharmony_ci {0x79A0EAA8, 0x79A0EAAC, 0x79A0EAA8, 0x79a0eaaa}, /*Reg830*/ 3538c2ecf20Sopenharmony_ci {0x87766451, 0x87766431, 0x87766451, 0x87766431}, /*Reg838*/ 3548c2ecf20Sopenharmony_ci}; 3558c2ecf20Sopenharmony_ci 3568c2ecf20Sopenharmony_cistatic const struct cca_ccut cca_ifem_ccut_ext = { 3578c2ecf20Sopenharmony_ci {0x75da8010, 0x75da8010, 0x75da8010, 0x75da8010}, /*Reg82C*/ 3588c2ecf20Sopenharmony_ci {0x79a0eaaa, 0x97A0EAAC, 0x79a0eaaa, 0x79a0eaaa}, /*Reg830*/ 3598c2ecf20Sopenharmony_ci {0x87765541, 0x86666341, 0x87765561, 0x86666361}, /*Reg838*/ 3608c2ecf20Sopenharmony_ci}; 3618c2ecf20Sopenharmony_ci 3628c2ecf20Sopenharmony_cistatic void rtw8822b_get_cca_val(const struct cca_ccut *cca_ccut, u8 col, 3638c2ecf20Sopenharmony_ci u32 *reg82c, u32 *reg830, u32 *reg838) 3648c2ecf20Sopenharmony_ci{ 3658c2ecf20Sopenharmony_ci *reg82c = cca_ccut->reg82c[col]; 3668c2ecf20Sopenharmony_ci *reg830 = cca_ccut->reg830[col]; 3678c2ecf20Sopenharmony_ci *reg838 = cca_ccut->reg838[col]; 3688c2ecf20Sopenharmony_ci} 3698c2ecf20Sopenharmony_ci 3708c2ecf20Sopenharmony_cistruct rtw8822b_rfe_info { 3718c2ecf20Sopenharmony_ci const struct cca_ccut *cca_ccut_2g; 3728c2ecf20Sopenharmony_ci const struct cca_ccut *cca_ccut_5g; 3738c2ecf20Sopenharmony_ci enum rtw_rfe_fem fem; 3748c2ecf20Sopenharmony_ci bool ifem_ext; 3758c2ecf20Sopenharmony_ci void (*rtw_set_channel_rfe)(struct rtw_dev *rtwdev, u8 channel); 3768c2ecf20Sopenharmony_ci}; 3778c2ecf20Sopenharmony_ci 3788c2ecf20Sopenharmony_ci#define I2GE5G_CCUT(set_ch) { \ 3798c2ecf20Sopenharmony_ci .cca_ccut_2g = &cca_ifem_ccut, \ 3808c2ecf20Sopenharmony_ci .cca_ccut_5g = &cca_efem_ccut, \ 3818c2ecf20Sopenharmony_ci .fem = RTW_RFE_IFEM2G_EFEM5G, \ 3828c2ecf20Sopenharmony_ci .ifem_ext = false, \ 3838c2ecf20Sopenharmony_ci .rtw_set_channel_rfe = &rtw8822b_set_channel_rfe_ ## set_ch, \ 3848c2ecf20Sopenharmony_ci } 3858c2ecf20Sopenharmony_ci#define IFEM_EXT_CCUT(set_ch) { \ 3868c2ecf20Sopenharmony_ci .cca_ccut_2g = &cca_ifem_ccut_ext, \ 3878c2ecf20Sopenharmony_ci .cca_ccut_5g = &cca_ifem_ccut_ext, \ 3888c2ecf20Sopenharmony_ci .fem = RTW_RFE_IFEM, \ 3898c2ecf20Sopenharmony_ci .ifem_ext = true, \ 3908c2ecf20Sopenharmony_ci .rtw_set_channel_rfe = &rtw8822b_set_channel_rfe_ ## set_ch, \ 3918c2ecf20Sopenharmony_ci } 3928c2ecf20Sopenharmony_ci 3938c2ecf20Sopenharmony_cistatic const struct rtw8822b_rfe_info rtw8822b_rfe_info[] = { 3948c2ecf20Sopenharmony_ci [2] = I2GE5G_CCUT(efem), 3958c2ecf20Sopenharmony_ci [3] = IFEM_EXT_CCUT(ifem), 3968c2ecf20Sopenharmony_ci [5] = IFEM_EXT_CCUT(ifem), 3978c2ecf20Sopenharmony_ci}; 3988c2ecf20Sopenharmony_ci 3998c2ecf20Sopenharmony_cistatic void rtw8822b_set_channel_cca(struct rtw_dev *rtwdev, u8 channel, u8 bw, 4008c2ecf20Sopenharmony_ci const struct rtw8822b_rfe_info *rfe_info) 4018c2ecf20Sopenharmony_ci{ 4028c2ecf20Sopenharmony_ci struct rtw_hal *hal = &rtwdev->hal; 4038c2ecf20Sopenharmony_ci struct rtw_efuse *efuse = &rtwdev->efuse; 4048c2ecf20Sopenharmony_ci const struct cca_ccut *cca_ccut; 4058c2ecf20Sopenharmony_ci u8 col; 4068c2ecf20Sopenharmony_ci u32 reg82c, reg830, reg838; 4078c2ecf20Sopenharmony_ci bool is_efem_cca = false, is_ifem_cca = false, is_rfe_type = false; 4088c2ecf20Sopenharmony_ci 4098c2ecf20Sopenharmony_ci if (IS_CH_2G_BAND(channel)) { 4108c2ecf20Sopenharmony_ci cca_ccut = rfe_info->cca_ccut_2g; 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ci if (hal->antenna_rx == BB_PATH_A || 4138c2ecf20Sopenharmony_ci hal->antenna_rx == BB_PATH_B) 4148c2ecf20Sopenharmony_ci col = CCUT_IDX_1R_2G; 4158c2ecf20Sopenharmony_ci else 4168c2ecf20Sopenharmony_ci col = CCUT_IDX_2R_2G; 4178c2ecf20Sopenharmony_ci } else { 4188c2ecf20Sopenharmony_ci cca_ccut = rfe_info->cca_ccut_5g; 4198c2ecf20Sopenharmony_ci 4208c2ecf20Sopenharmony_ci if (hal->antenna_rx == BB_PATH_A || 4218c2ecf20Sopenharmony_ci hal->antenna_rx == BB_PATH_B) 4228c2ecf20Sopenharmony_ci col = CCUT_IDX_1R_5G; 4238c2ecf20Sopenharmony_ci else 4248c2ecf20Sopenharmony_ci col = CCUT_IDX_2R_5G; 4258c2ecf20Sopenharmony_ci } 4268c2ecf20Sopenharmony_ci 4278c2ecf20Sopenharmony_ci rtw8822b_get_cca_val(cca_ccut, col, ®82c, ®830, ®838); 4288c2ecf20Sopenharmony_ci 4298c2ecf20Sopenharmony_ci switch (rfe_info->fem) { 4308c2ecf20Sopenharmony_ci case RTW_RFE_IFEM: 4318c2ecf20Sopenharmony_ci default: 4328c2ecf20Sopenharmony_ci is_ifem_cca = true; 4338c2ecf20Sopenharmony_ci if (rfe_info->ifem_ext) 4348c2ecf20Sopenharmony_ci is_rfe_type = true; 4358c2ecf20Sopenharmony_ci break; 4368c2ecf20Sopenharmony_ci case RTW_RFE_EFEM: 4378c2ecf20Sopenharmony_ci is_efem_cca = true; 4388c2ecf20Sopenharmony_ci break; 4398c2ecf20Sopenharmony_ci case RTW_RFE_IFEM2G_EFEM5G: 4408c2ecf20Sopenharmony_ci if (IS_CH_2G_BAND(channel)) 4418c2ecf20Sopenharmony_ci is_ifem_cca = true; 4428c2ecf20Sopenharmony_ci else 4438c2ecf20Sopenharmony_ci is_efem_cca = true; 4448c2ecf20Sopenharmony_ci break; 4458c2ecf20Sopenharmony_ci } 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_ci if (is_ifem_cca) { 4488c2ecf20Sopenharmony_ci if ((hal->cut_version == RTW_CHIP_VER_CUT_B && 4498c2ecf20Sopenharmony_ci (col == CCUT_IDX_2R_2G || col == CCUT_IDX_2R_5G) && 4508c2ecf20Sopenharmony_ci bw == RTW_CHANNEL_WIDTH_40) || 4518c2ecf20Sopenharmony_ci (!is_rfe_type && col == CCUT_IDX_2R_5G && 4528c2ecf20Sopenharmony_ci bw == RTW_CHANNEL_WIDTH_40) || 4538c2ecf20Sopenharmony_ci (efuse->rfe_option == 5 && col == CCUT_IDX_2R_5G)) 4548c2ecf20Sopenharmony_ci reg830 = 0x79a0ea28; 4558c2ecf20Sopenharmony_ci } 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_CCASEL, MASKDWORD, reg82c); 4588c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_PDMFTH, MASKDWORD, reg830); 4598c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_CCA2ND, MASKDWORD, reg838); 4608c2ecf20Sopenharmony_ci 4618c2ecf20Sopenharmony_ci if (is_efem_cca && !(hal->cut_version == RTW_CHIP_VER_CUT_B)) 4628c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_L1WT, MASKDWORD, 0x9194b2b9); 4638c2ecf20Sopenharmony_ci 4648c2ecf20Sopenharmony_ci if (bw == RTW_CHANNEL_WIDTH_20 && IS_CH_5G_BAND_MID(channel)) 4658c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_CCA2ND, 0xf0, 0x4); 4668c2ecf20Sopenharmony_ci} 4678c2ecf20Sopenharmony_ci 4688c2ecf20Sopenharmony_cistatic const u8 low_band[15] = {0x7, 0x6, 0x6, 0x5, 0x0, 0x0, 0x7, 0xff, 0x6, 4698c2ecf20Sopenharmony_ci 0x5, 0x0, 0x0, 0x7, 0x6, 0x6}; 4708c2ecf20Sopenharmony_cistatic const u8 middle_band[23] = {0x6, 0x5, 0x0, 0x0, 0x7, 0x6, 0x6, 0xff, 0x0, 4718c2ecf20Sopenharmony_ci 0x0, 0x7, 0x6, 0x6, 0x5, 0x0, 0xff, 0x7, 0x6, 4728c2ecf20Sopenharmony_ci 0x6, 0x5, 0x0, 0x0, 0x7}; 4738c2ecf20Sopenharmony_cistatic const u8 high_band[15] = {0x5, 0x5, 0x0, 0x7, 0x7, 0x6, 0x5, 0xff, 0x0, 4748c2ecf20Sopenharmony_ci 0x7, 0x7, 0x6, 0x5, 0x5, 0x0}; 4758c2ecf20Sopenharmony_ci 4768c2ecf20Sopenharmony_cistatic void rtw8822b_set_channel_rf(struct rtw_dev *rtwdev, u8 channel, u8 bw) 4778c2ecf20Sopenharmony_ci{ 4788c2ecf20Sopenharmony_ci#define RF18_BAND_MASK (BIT(16) | BIT(9) | BIT(8)) 4798c2ecf20Sopenharmony_ci#define RF18_BAND_2G (0) 4808c2ecf20Sopenharmony_ci#define RF18_BAND_5G (BIT(16) | BIT(8)) 4818c2ecf20Sopenharmony_ci#define RF18_CHANNEL_MASK (MASKBYTE0) 4828c2ecf20Sopenharmony_ci#define RF18_RFSI_MASK (BIT(18) | BIT(17)) 4838c2ecf20Sopenharmony_ci#define RF18_RFSI_GE_CH80 (BIT(17)) 4848c2ecf20Sopenharmony_ci#define RF18_RFSI_GT_CH144 (BIT(18)) 4858c2ecf20Sopenharmony_ci#define RF18_BW_MASK (BIT(11) | BIT(10)) 4868c2ecf20Sopenharmony_ci#define RF18_BW_20M (BIT(11) | BIT(10)) 4878c2ecf20Sopenharmony_ci#define RF18_BW_40M (BIT(11)) 4888c2ecf20Sopenharmony_ci#define RF18_BW_80M (BIT(10)) 4898c2ecf20Sopenharmony_ci#define RFBE_MASK (BIT(17) | BIT(16) | BIT(15)) 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ci struct rtw_hal *hal = &rtwdev->hal; 4928c2ecf20Sopenharmony_ci u32 rf_reg18, rf_reg_be; 4938c2ecf20Sopenharmony_ci 4948c2ecf20Sopenharmony_ci rf_reg18 = rtw_read_rf(rtwdev, RF_PATH_A, 0x18, RFREG_MASK); 4958c2ecf20Sopenharmony_ci 4968c2ecf20Sopenharmony_ci rf_reg18 &= ~(RF18_BAND_MASK | RF18_CHANNEL_MASK | RF18_RFSI_MASK | 4978c2ecf20Sopenharmony_ci RF18_BW_MASK); 4988c2ecf20Sopenharmony_ci 4998c2ecf20Sopenharmony_ci rf_reg18 |= (IS_CH_2G_BAND(channel) ? RF18_BAND_2G : RF18_BAND_5G); 5008c2ecf20Sopenharmony_ci rf_reg18 |= (channel & RF18_CHANNEL_MASK); 5018c2ecf20Sopenharmony_ci if (channel > 144) 5028c2ecf20Sopenharmony_ci rf_reg18 |= RF18_RFSI_GT_CH144; 5038c2ecf20Sopenharmony_ci else if (channel >= 80) 5048c2ecf20Sopenharmony_ci rf_reg18 |= RF18_RFSI_GE_CH80; 5058c2ecf20Sopenharmony_ci 5068c2ecf20Sopenharmony_ci switch (bw) { 5078c2ecf20Sopenharmony_ci case RTW_CHANNEL_WIDTH_5: 5088c2ecf20Sopenharmony_ci case RTW_CHANNEL_WIDTH_10: 5098c2ecf20Sopenharmony_ci case RTW_CHANNEL_WIDTH_20: 5108c2ecf20Sopenharmony_ci default: 5118c2ecf20Sopenharmony_ci rf_reg18 |= RF18_BW_20M; 5128c2ecf20Sopenharmony_ci break; 5138c2ecf20Sopenharmony_ci case RTW_CHANNEL_WIDTH_40: 5148c2ecf20Sopenharmony_ci rf_reg18 |= RF18_BW_40M; 5158c2ecf20Sopenharmony_ci break; 5168c2ecf20Sopenharmony_ci case RTW_CHANNEL_WIDTH_80: 5178c2ecf20Sopenharmony_ci rf_reg18 |= RF18_BW_80M; 5188c2ecf20Sopenharmony_ci break; 5198c2ecf20Sopenharmony_ci } 5208c2ecf20Sopenharmony_ci 5218c2ecf20Sopenharmony_ci if (IS_CH_2G_BAND(channel)) 5228c2ecf20Sopenharmony_ci rf_reg_be = 0x0; 5238c2ecf20Sopenharmony_ci else if (IS_CH_5G_BAND_1(channel) || IS_CH_5G_BAND_2(channel)) 5248c2ecf20Sopenharmony_ci rf_reg_be = low_band[(channel - 36) >> 1]; 5258c2ecf20Sopenharmony_ci else if (IS_CH_5G_BAND_3(channel)) 5268c2ecf20Sopenharmony_ci rf_reg_be = middle_band[(channel - 100) >> 1]; 5278c2ecf20Sopenharmony_ci else if (IS_CH_5G_BAND_4(channel)) 5288c2ecf20Sopenharmony_ci rf_reg_be = high_band[(channel - 149) >> 1]; 5298c2ecf20Sopenharmony_ci else 5308c2ecf20Sopenharmony_ci goto err; 5318c2ecf20Sopenharmony_ci 5328c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_MALSEL, RFBE_MASK, rf_reg_be); 5338c2ecf20Sopenharmony_ci 5348c2ecf20Sopenharmony_ci /* need to set 0xdf[18]=1 before writing RF18 when channel 144 */ 5358c2ecf20Sopenharmony_ci if (channel == 144) 5368c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_LUTDBG, BIT(18), 0x1); 5378c2ecf20Sopenharmony_ci else 5388c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_LUTDBG, BIT(18), 0x0); 5398c2ecf20Sopenharmony_ci 5408c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, 0x18, RFREG_MASK, rf_reg18); 5418c2ecf20Sopenharmony_ci if (hal->rf_type > RF_1T1R) 5428c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_B, 0x18, RFREG_MASK, rf_reg18); 5438c2ecf20Sopenharmony_ci 5448c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_XTALX2, BIT(19), 0); 5458c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_XTALX2, BIT(19), 1); 5468c2ecf20Sopenharmony_ci 5478c2ecf20Sopenharmony_ci return; 5488c2ecf20Sopenharmony_ci 5498c2ecf20Sopenharmony_cierr: 5508c2ecf20Sopenharmony_ci WARN_ON(1); 5518c2ecf20Sopenharmony_ci} 5528c2ecf20Sopenharmony_ci 5538c2ecf20Sopenharmony_cistatic void rtw8822b_toggle_igi(struct rtw_dev *rtwdev) 5548c2ecf20Sopenharmony_ci{ 5558c2ecf20Sopenharmony_ci struct rtw_hal *hal = &rtwdev->hal; 5568c2ecf20Sopenharmony_ci u32 igi; 5578c2ecf20Sopenharmony_ci 5588c2ecf20Sopenharmony_ci igi = rtw_read32_mask(rtwdev, REG_RXIGI_A, 0x7f); 5598c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_RXIGI_A, 0x7f, igi - 2); 5608c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_RXIGI_A, 0x7f, igi); 5618c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_RXIGI_B, 0x7f, igi - 2); 5628c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_RXIGI_B, 0x7f, igi); 5638c2ecf20Sopenharmony_ci 5648c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_RXPSEL, MASKBYTE0, 0x0); 5658c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_RXPSEL, MASKBYTE0, 5668c2ecf20Sopenharmony_ci hal->antenna_rx | (hal->antenna_rx << 4)); 5678c2ecf20Sopenharmony_ci} 5688c2ecf20Sopenharmony_ci 5698c2ecf20Sopenharmony_cistatic void rtw8822b_set_channel_rxdfir(struct rtw_dev *rtwdev, u8 bw) 5708c2ecf20Sopenharmony_ci{ 5718c2ecf20Sopenharmony_ci if (bw == RTW_CHANNEL_WIDTH_40) { 5728c2ecf20Sopenharmony_ci /* RX DFIR for BW40 */ 5738c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ACBB0, BIT(29) | BIT(28), 0x1); 5748c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ACBBRXFIR, BIT(29) | BIT(28), 0x0); 5758c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_TXDFIR, BIT(31), 0x0); 5768c2ecf20Sopenharmony_ci } else if (bw == RTW_CHANNEL_WIDTH_80) { 5778c2ecf20Sopenharmony_ci /* RX DFIR for BW80 */ 5788c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ACBB0, BIT(29) | BIT(28), 0x2); 5798c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ACBBRXFIR, BIT(29) | BIT(28), 0x1); 5808c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_TXDFIR, BIT(31), 0x0); 5818c2ecf20Sopenharmony_ci } else { 5828c2ecf20Sopenharmony_ci /* RX DFIR for BW20, BW10 and BW5*/ 5838c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ACBB0, BIT(29) | BIT(28), 0x2); 5848c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ACBBRXFIR, BIT(29) | BIT(28), 0x2); 5858c2ecf20Sopenharmony_ci rtw_write32s_mask(rtwdev, REG_TXDFIR, BIT(31), 0x1); 5868c2ecf20Sopenharmony_ci } 5878c2ecf20Sopenharmony_ci} 5888c2ecf20Sopenharmony_ci 5898c2ecf20Sopenharmony_cistatic void rtw8822b_set_channel_bb(struct rtw_dev *rtwdev, u8 channel, u8 bw, 5908c2ecf20Sopenharmony_ci u8 primary_ch_idx) 5918c2ecf20Sopenharmony_ci{ 5928c2ecf20Sopenharmony_ci struct rtw_efuse *efuse = &rtwdev->efuse; 5938c2ecf20Sopenharmony_ci u8 rfe_option = efuse->rfe_option; 5948c2ecf20Sopenharmony_ci u32 val32; 5958c2ecf20Sopenharmony_ci 5968c2ecf20Sopenharmony_ci if (IS_CH_2G_BAND(channel)) { 5978c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_RXPSEL, BIT(28), 0x1); 5988c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_CCK_CHECK, BIT(7), 0x0); 5998c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ENTXCCK, BIT(18), 0x0); 6008c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_RXCCAMSK, 0x0000FC00, 15); 6018c2ecf20Sopenharmony_ci 6028c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ACGG2TBL, 0x1f, 0x0); 6038c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_CLKTRK, 0x1ffe0000, 0x96a); 6048c2ecf20Sopenharmony_ci if (channel == 14) { 6058c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_TXSF2, MASKDWORD, 0x00006577); 6068c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_TXSF6, MASKLWORD, 0x0000); 6078c2ecf20Sopenharmony_ci } else { 6088c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_TXSF2, MASKDWORD, 0x384f6577); 6098c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_TXSF6, MASKLWORD, 0x1525); 6108c2ecf20Sopenharmony_ci } 6118c2ecf20Sopenharmony_ci 6128c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_RFEINV, 0x300, 0x2); 6138c2ecf20Sopenharmony_ci } else if (IS_CH_5G_BAND(channel)) { 6148c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ENTXCCK, BIT(18), 0x1); 6158c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_CCK_CHECK, BIT(7), 0x1); 6168c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_RXPSEL, BIT(28), 0x0); 6178c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_RXCCAMSK, 0x0000FC00, 34); 6188c2ecf20Sopenharmony_ci 6198c2ecf20Sopenharmony_ci if (IS_CH_5G_BAND_1(channel) || IS_CH_5G_BAND_2(channel)) 6208c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ACGG2TBL, 0x1f, 0x1); 6218c2ecf20Sopenharmony_ci else if (IS_CH_5G_BAND_3(channel)) 6228c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ACGG2TBL, 0x1f, 0x2); 6238c2ecf20Sopenharmony_ci else if (IS_CH_5G_BAND_4(channel)) 6248c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ACGG2TBL, 0x1f, 0x3); 6258c2ecf20Sopenharmony_ci 6268c2ecf20Sopenharmony_ci if (IS_CH_5G_BAND_1(channel)) 6278c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_CLKTRK, 0x1ffe0000, 0x494); 6288c2ecf20Sopenharmony_ci else if (IS_CH_5G_BAND_2(channel)) 6298c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_CLKTRK, 0x1ffe0000, 0x453); 6308c2ecf20Sopenharmony_ci else if (channel >= 100 && channel <= 116) 6318c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_CLKTRK, 0x1ffe0000, 0x452); 6328c2ecf20Sopenharmony_ci else if (channel >= 118 && channel <= 177) 6338c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_CLKTRK, 0x1ffe0000, 0x412); 6348c2ecf20Sopenharmony_ci 6358c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, 0xcbc, 0x300, 0x1); 6368c2ecf20Sopenharmony_ci } 6378c2ecf20Sopenharmony_ci 6388c2ecf20Sopenharmony_ci switch (bw) { 6398c2ecf20Sopenharmony_ci case RTW_CHANNEL_WIDTH_20: 6408c2ecf20Sopenharmony_ci default: 6418c2ecf20Sopenharmony_ci val32 = rtw_read32_mask(rtwdev, REG_ADCCLK, MASKDWORD); 6428c2ecf20Sopenharmony_ci val32 &= 0xFFCFFC00; 6438c2ecf20Sopenharmony_ci val32 |= (RTW_CHANNEL_WIDTH_20); 6448c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADCCLK, MASKDWORD, val32); 6458c2ecf20Sopenharmony_ci 6468c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADC160, BIT(30), 0x1); 6478c2ecf20Sopenharmony_ci break; 6488c2ecf20Sopenharmony_ci case RTW_CHANNEL_WIDTH_40: 6498c2ecf20Sopenharmony_ci if (primary_ch_idx == RTW_SC_20_UPPER) 6508c2ecf20Sopenharmony_ci rtw_write32_set(rtwdev, REG_RXSB, BIT(4)); 6518c2ecf20Sopenharmony_ci else 6528c2ecf20Sopenharmony_ci rtw_write32_clr(rtwdev, REG_RXSB, BIT(4)); 6538c2ecf20Sopenharmony_ci 6548c2ecf20Sopenharmony_ci val32 = rtw_read32_mask(rtwdev, REG_ADCCLK, MASKDWORD); 6558c2ecf20Sopenharmony_ci val32 &= 0xFF3FF300; 6568c2ecf20Sopenharmony_ci val32 |= (((primary_ch_idx & 0xf) << 2) | RTW_CHANNEL_WIDTH_40); 6578c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADCCLK, MASKDWORD, val32); 6588c2ecf20Sopenharmony_ci 6598c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADC160, BIT(30), 0x1); 6608c2ecf20Sopenharmony_ci break; 6618c2ecf20Sopenharmony_ci case RTW_CHANNEL_WIDTH_80: 6628c2ecf20Sopenharmony_ci val32 = rtw_read32_mask(rtwdev, REG_ADCCLK, MASKDWORD); 6638c2ecf20Sopenharmony_ci val32 &= 0xFCEFCF00; 6648c2ecf20Sopenharmony_ci val32 |= (((primary_ch_idx & 0xf) << 2) | RTW_CHANNEL_WIDTH_80); 6658c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADCCLK, MASKDWORD, val32); 6668c2ecf20Sopenharmony_ci 6678c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADC160, BIT(30), 0x1); 6688c2ecf20Sopenharmony_ci 6698c2ecf20Sopenharmony_ci if (rfe_option == 2 || rfe_option == 3) { 6708c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_L1PKWT, 0x0000f000, 0x6); 6718c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADC40, BIT(10), 0x1); 6728c2ecf20Sopenharmony_ci } 6738c2ecf20Sopenharmony_ci break; 6748c2ecf20Sopenharmony_ci case RTW_CHANNEL_WIDTH_5: 6758c2ecf20Sopenharmony_ci val32 = rtw_read32_mask(rtwdev, REG_ADCCLK, MASKDWORD); 6768c2ecf20Sopenharmony_ci val32 &= 0xEFEEFE00; 6778c2ecf20Sopenharmony_ci val32 |= ((BIT(6) | RTW_CHANNEL_WIDTH_20)); 6788c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADCCLK, MASKDWORD, val32); 6798c2ecf20Sopenharmony_ci 6808c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADC160, BIT(30), 0x0); 6818c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADC40, BIT(31), 0x1); 6828c2ecf20Sopenharmony_ci break; 6838c2ecf20Sopenharmony_ci case RTW_CHANNEL_WIDTH_10: 6848c2ecf20Sopenharmony_ci val32 = rtw_read32_mask(rtwdev, REG_ADCCLK, MASKDWORD); 6858c2ecf20Sopenharmony_ci val32 &= 0xEFFEFF00; 6868c2ecf20Sopenharmony_ci val32 |= ((BIT(7) | RTW_CHANNEL_WIDTH_20)); 6878c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADCCLK, MASKDWORD, val32); 6888c2ecf20Sopenharmony_ci 6898c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADC160, BIT(30), 0x0); 6908c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADC40, BIT(31), 0x1); 6918c2ecf20Sopenharmony_ci break; 6928c2ecf20Sopenharmony_ci } 6938c2ecf20Sopenharmony_ci} 6948c2ecf20Sopenharmony_ci 6958c2ecf20Sopenharmony_cistatic void rtw8822b_set_channel(struct rtw_dev *rtwdev, u8 channel, u8 bw, 6968c2ecf20Sopenharmony_ci u8 primary_chan_idx) 6978c2ecf20Sopenharmony_ci{ 6988c2ecf20Sopenharmony_ci struct rtw_efuse *efuse = &rtwdev->efuse; 6998c2ecf20Sopenharmony_ci const struct rtw8822b_rfe_info *rfe_info; 7008c2ecf20Sopenharmony_ci 7018c2ecf20Sopenharmony_ci if (WARN(efuse->rfe_option >= ARRAY_SIZE(rtw8822b_rfe_info), 7028c2ecf20Sopenharmony_ci "rfe_option %d is out of boundary\n", efuse->rfe_option)) 7038c2ecf20Sopenharmony_ci return; 7048c2ecf20Sopenharmony_ci 7058c2ecf20Sopenharmony_ci rfe_info = &rtw8822b_rfe_info[efuse->rfe_option]; 7068c2ecf20Sopenharmony_ci 7078c2ecf20Sopenharmony_ci rtw8822b_set_channel_bb(rtwdev, channel, bw, primary_chan_idx); 7088c2ecf20Sopenharmony_ci rtw_set_channel_mac(rtwdev, channel, bw, primary_chan_idx); 7098c2ecf20Sopenharmony_ci rtw8822b_set_channel_rf(rtwdev, channel, bw); 7108c2ecf20Sopenharmony_ci rtw8822b_set_channel_rxdfir(rtwdev, bw); 7118c2ecf20Sopenharmony_ci rtw8822b_toggle_igi(rtwdev); 7128c2ecf20Sopenharmony_ci rtw8822b_set_channel_cca(rtwdev, channel, bw, rfe_info); 7138c2ecf20Sopenharmony_ci (*rfe_info->rtw_set_channel_rfe)(rtwdev, channel); 7148c2ecf20Sopenharmony_ci} 7158c2ecf20Sopenharmony_ci 7168c2ecf20Sopenharmony_cistatic void rtw8822b_config_trx_mode(struct rtw_dev *rtwdev, u8 tx_path, 7178c2ecf20Sopenharmony_ci u8 rx_path, bool is_tx2_path) 7188c2ecf20Sopenharmony_ci{ 7198c2ecf20Sopenharmony_ci struct rtw_efuse *efuse = &rtwdev->efuse; 7208c2ecf20Sopenharmony_ci const struct rtw8822b_rfe_info *rfe_info; 7218c2ecf20Sopenharmony_ci u8 ch = rtwdev->hal.current_channel; 7228c2ecf20Sopenharmony_ci u8 tx_path_sel, rx_path_sel; 7238c2ecf20Sopenharmony_ci int counter; 7248c2ecf20Sopenharmony_ci 7258c2ecf20Sopenharmony_ci if (WARN(efuse->rfe_option >= ARRAY_SIZE(rtw8822b_rfe_info), 7268c2ecf20Sopenharmony_ci "rfe_option %d is out of boundary\n", efuse->rfe_option)) 7278c2ecf20Sopenharmony_ci return; 7288c2ecf20Sopenharmony_ci 7298c2ecf20Sopenharmony_ci rfe_info = &rtw8822b_rfe_info[efuse->rfe_option]; 7308c2ecf20Sopenharmony_ci 7318c2ecf20Sopenharmony_ci if ((tx_path | rx_path) & BB_PATH_A) 7328c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_AGCTR_A, MASKLWORD, 0x3231); 7338c2ecf20Sopenharmony_ci else 7348c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_AGCTR_A, MASKLWORD, 0x1111); 7358c2ecf20Sopenharmony_ci 7368c2ecf20Sopenharmony_ci if ((tx_path | rx_path) & BB_PATH_B) 7378c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_AGCTR_B, MASKLWORD, 0x3231); 7388c2ecf20Sopenharmony_ci else 7398c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_AGCTR_B, MASKLWORD, 0x1111); 7408c2ecf20Sopenharmony_ci 7418c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_CDDTXP, (BIT(19) | BIT(18)), 0x3); 7428c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_TXPSEL, (BIT(29) | BIT(28)), 0x1); 7438c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_TXPSEL, BIT(30), 0x1); 7448c2ecf20Sopenharmony_ci 7458c2ecf20Sopenharmony_ci if (tx_path & BB_PATH_A) { 7468c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_CDDTXP, 0xfff00000, 0x001); 7478c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADCINI, 0xf0000000, 0x8); 7488c2ecf20Sopenharmony_ci } else if (tx_path & BB_PATH_B) { 7498c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_CDDTXP, 0xfff00000, 0x002); 7508c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADCINI, 0xf0000000, 0x4); 7518c2ecf20Sopenharmony_ci } 7528c2ecf20Sopenharmony_ci 7538c2ecf20Sopenharmony_ci if (tx_path == BB_PATH_A || tx_path == BB_PATH_B) 7548c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_TXPSEL1, 0xfff0, 0x01); 7558c2ecf20Sopenharmony_ci else 7568c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_TXPSEL1, 0xfff0, 0x43); 7578c2ecf20Sopenharmony_ci 7588c2ecf20Sopenharmony_ci tx_path_sel = (tx_path << 4) | tx_path; 7598c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_TXPSEL, MASKBYTE0, tx_path_sel); 7608c2ecf20Sopenharmony_ci 7618c2ecf20Sopenharmony_ci if (tx_path != BB_PATH_A && tx_path != BB_PATH_B) { 7628c2ecf20Sopenharmony_ci if (is_tx2_path || rtwdev->mp_mode) { 7638c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_CDDTXP, 0xfff00000, 0x043); 7648c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADCINI, 0xf0000000, 0xc); 7658c2ecf20Sopenharmony_ci } 7668c2ecf20Sopenharmony_ci } 7678c2ecf20Sopenharmony_ci 7688c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_RXDESC, BIT(22), 0x0); 7698c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_RXDESC, BIT(18), 0x0); 7708c2ecf20Sopenharmony_ci 7718c2ecf20Sopenharmony_ci if (rx_path & BB_PATH_A) 7728c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADCINI, 0x0f000000, 0x0); 7738c2ecf20Sopenharmony_ci else if (rx_path & BB_PATH_B) 7748c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ADCINI, 0x0f000000, 0x5); 7758c2ecf20Sopenharmony_ci 7768c2ecf20Sopenharmony_ci rx_path_sel = (rx_path << 4) | rx_path; 7778c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_RXPSEL, MASKBYTE0, rx_path_sel); 7788c2ecf20Sopenharmony_ci 7798c2ecf20Sopenharmony_ci if (rx_path == BB_PATH_A || rx_path == BB_PATH_B) { 7808c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ANTWT, BIT(16), 0x0); 7818c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_HTSTFWT, BIT(28), 0x0); 7828c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_MRC, BIT(23), 0x0); 7838c2ecf20Sopenharmony_ci } else { 7848c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_ANTWT, BIT(16), 0x1); 7858c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_HTSTFWT, BIT(28), 0x1); 7868c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, REG_MRC, BIT(23), 0x1); 7878c2ecf20Sopenharmony_ci } 7888c2ecf20Sopenharmony_ci 7898c2ecf20Sopenharmony_ci for (counter = 100; counter > 0; counter--) { 7908c2ecf20Sopenharmony_ci u32 rf_reg33; 7918c2ecf20Sopenharmony_ci 7928c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_LUTWE, RFREG_MASK, 0x80000); 7938c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_LUTWA, RFREG_MASK, 0x00001); 7948c2ecf20Sopenharmony_ci 7958c2ecf20Sopenharmony_ci udelay(2); 7968c2ecf20Sopenharmony_ci rf_reg33 = rtw_read_rf(rtwdev, RF_PATH_A, 0x33, RFREG_MASK); 7978c2ecf20Sopenharmony_ci 7988c2ecf20Sopenharmony_ci if (rf_reg33 == 0x00001) 7998c2ecf20Sopenharmony_ci break; 8008c2ecf20Sopenharmony_ci } 8018c2ecf20Sopenharmony_ci 8028c2ecf20Sopenharmony_ci if (WARN(counter <= 0, "write RF mode table fail\n")) 8038c2ecf20Sopenharmony_ci return; 8048c2ecf20Sopenharmony_ci 8058c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_LUTWE, RFREG_MASK, 0x80000); 8068c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_LUTWA, RFREG_MASK, 0x00001); 8078c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_LUTWD1, RFREG_MASK, 0x00034); 8088c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_LUTWD0, RFREG_MASK, 0x4080c); 8098c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_LUTWE, RFREG_MASK, 0x00000); 8108c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_LUTWE, RFREG_MASK, 0x00000); 8118c2ecf20Sopenharmony_ci 8128c2ecf20Sopenharmony_ci rtw8822b_toggle_igi(rtwdev); 8138c2ecf20Sopenharmony_ci rtw8822b_set_channel_cca(rtwdev, 1, RTW_CHANNEL_WIDTH_20, rfe_info); 8148c2ecf20Sopenharmony_ci (*rfe_info->rtw_set_channel_rfe)(rtwdev, ch); 8158c2ecf20Sopenharmony_ci} 8168c2ecf20Sopenharmony_ci 8178c2ecf20Sopenharmony_cistatic void query_phy_status_page0(struct rtw_dev *rtwdev, u8 *phy_status, 8188c2ecf20Sopenharmony_ci struct rtw_rx_pkt_stat *pkt_stat) 8198c2ecf20Sopenharmony_ci{ 8208c2ecf20Sopenharmony_ci struct rtw_dm_info *dm_info = &rtwdev->dm_info; 8218c2ecf20Sopenharmony_ci s8 min_rx_power = -120; 8228c2ecf20Sopenharmony_ci u8 pwdb = GET_PHY_STAT_P0_PWDB(phy_status); 8238c2ecf20Sopenharmony_ci 8248c2ecf20Sopenharmony_ci /* 8822B uses only 1 antenna to RX CCK rates */ 8258c2ecf20Sopenharmony_ci pkt_stat->rx_power[RF_PATH_A] = pwdb - 110; 8268c2ecf20Sopenharmony_ci pkt_stat->rssi = rtw_phy_rf_power_2_rssi(pkt_stat->rx_power, 1); 8278c2ecf20Sopenharmony_ci pkt_stat->bw = RTW_CHANNEL_WIDTH_20; 8288c2ecf20Sopenharmony_ci pkt_stat->signal_power = max(pkt_stat->rx_power[RF_PATH_A], 8298c2ecf20Sopenharmony_ci min_rx_power); 8308c2ecf20Sopenharmony_ci dm_info->rssi[RF_PATH_A] = pkt_stat->rssi; 8318c2ecf20Sopenharmony_ci} 8328c2ecf20Sopenharmony_ci 8338c2ecf20Sopenharmony_cistatic void query_phy_status_page1(struct rtw_dev *rtwdev, u8 *phy_status, 8348c2ecf20Sopenharmony_ci struct rtw_rx_pkt_stat *pkt_stat) 8358c2ecf20Sopenharmony_ci{ 8368c2ecf20Sopenharmony_ci struct rtw_dm_info *dm_info = &rtwdev->dm_info; 8378c2ecf20Sopenharmony_ci u8 rxsc, bw; 8388c2ecf20Sopenharmony_ci s8 min_rx_power = -120; 8398c2ecf20Sopenharmony_ci s8 rx_evm; 8408c2ecf20Sopenharmony_ci u8 evm_dbm = 0; 8418c2ecf20Sopenharmony_ci u8 rssi; 8428c2ecf20Sopenharmony_ci int path; 8438c2ecf20Sopenharmony_ci 8448c2ecf20Sopenharmony_ci if (pkt_stat->rate > DESC_RATE11M && pkt_stat->rate < DESC_RATEMCS0) 8458c2ecf20Sopenharmony_ci rxsc = GET_PHY_STAT_P1_L_RXSC(phy_status); 8468c2ecf20Sopenharmony_ci else 8478c2ecf20Sopenharmony_ci rxsc = GET_PHY_STAT_P1_HT_RXSC(phy_status); 8488c2ecf20Sopenharmony_ci 8498c2ecf20Sopenharmony_ci if (rxsc >= 1 && rxsc <= 8) 8508c2ecf20Sopenharmony_ci bw = RTW_CHANNEL_WIDTH_20; 8518c2ecf20Sopenharmony_ci else if (rxsc >= 9 && rxsc <= 12) 8528c2ecf20Sopenharmony_ci bw = RTW_CHANNEL_WIDTH_40; 8538c2ecf20Sopenharmony_ci else if (rxsc >= 13) 8548c2ecf20Sopenharmony_ci bw = RTW_CHANNEL_WIDTH_80; 8558c2ecf20Sopenharmony_ci else 8568c2ecf20Sopenharmony_ci bw = GET_PHY_STAT_P1_RF_MODE(phy_status); 8578c2ecf20Sopenharmony_ci 8588c2ecf20Sopenharmony_ci pkt_stat->rx_power[RF_PATH_A] = GET_PHY_STAT_P1_PWDB_A(phy_status) - 110; 8598c2ecf20Sopenharmony_ci pkt_stat->rx_power[RF_PATH_B] = GET_PHY_STAT_P1_PWDB_B(phy_status) - 110; 8608c2ecf20Sopenharmony_ci pkt_stat->rssi = rtw_phy_rf_power_2_rssi(pkt_stat->rx_power, 2); 8618c2ecf20Sopenharmony_ci pkt_stat->bw = bw; 8628c2ecf20Sopenharmony_ci pkt_stat->signal_power = max3(pkt_stat->rx_power[RF_PATH_A], 8638c2ecf20Sopenharmony_ci pkt_stat->rx_power[RF_PATH_B], 8648c2ecf20Sopenharmony_ci min_rx_power); 8658c2ecf20Sopenharmony_ci 8668c2ecf20Sopenharmony_ci dm_info->curr_rx_rate = pkt_stat->rate; 8678c2ecf20Sopenharmony_ci 8688c2ecf20Sopenharmony_ci pkt_stat->rx_evm[RF_PATH_A] = GET_PHY_STAT_P1_RXEVM_A(phy_status); 8698c2ecf20Sopenharmony_ci pkt_stat->rx_evm[RF_PATH_B] = GET_PHY_STAT_P1_RXEVM_B(phy_status); 8708c2ecf20Sopenharmony_ci 8718c2ecf20Sopenharmony_ci pkt_stat->rx_snr[RF_PATH_A] = GET_PHY_STAT_P1_RXSNR_A(phy_status); 8728c2ecf20Sopenharmony_ci pkt_stat->rx_snr[RF_PATH_B] = GET_PHY_STAT_P1_RXSNR_B(phy_status); 8738c2ecf20Sopenharmony_ci 8748c2ecf20Sopenharmony_ci pkt_stat->cfo_tail[RF_PATH_A] = GET_PHY_STAT_P1_CFO_TAIL_A(phy_status); 8758c2ecf20Sopenharmony_ci pkt_stat->cfo_tail[RF_PATH_B] = GET_PHY_STAT_P1_CFO_TAIL_B(phy_status); 8768c2ecf20Sopenharmony_ci 8778c2ecf20Sopenharmony_ci for (path = 0; path <= rtwdev->hal.rf_path_num; path++) { 8788c2ecf20Sopenharmony_ci rssi = rtw_phy_rf_power_2_rssi(&pkt_stat->rx_power[path], 1); 8798c2ecf20Sopenharmony_ci dm_info->rssi[path] = rssi; 8808c2ecf20Sopenharmony_ci dm_info->rx_snr[path] = pkt_stat->rx_snr[path] >> 1; 8818c2ecf20Sopenharmony_ci dm_info->cfo_tail[path] = (pkt_stat->cfo_tail[path] * 5) >> 1; 8828c2ecf20Sopenharmony_ci 8838c2ecf20Sopenharmony_ci rx_evm = pkt_stat->rx_evm[path]; 8848c2ecf20Sopenharmony_ci 8858c2ecf20Sopenharmony_ci if (rx_evm < 0) { 8868c2ecf20Sopenharmony_ci if (rx_evm == S8_MIN) 8878c2ecf20Sopenharmony_ci evm_dbm = 0; 8888c2ecf20Sopenharmony_ci else 8898c2ecf20Sopenharmony_ci evm_dbm = ((u8)-rx_evm >> 1); 8908c2ecf20Sopenharmony_ci } 8918c2ecf20Sopenharmony_ci dm_info->rx_evm_dbm[path] = evm_dbm; 8928c2ecf20Sopenharmony_ci } 8938c2ecf20Sopenharmony_ci} 8948c2ecf20Sopenharmony_ci 8958c2ecf20Sopenharmony_cistatic void query_phy_status(struct rtw_dev *rtwdev, u8 *phy_status, 8968c2ecf20Sopenharmony_ci struct rtw_rx_pkt_stat *pkt_stat) 8978c2ecf20Sopenharmony_ci{ 8988c2ecf20Sopenharmony_ci u8 page; 8998c2ecf20Sopenharmony_ci 9008c2ecf20Sopenharmony_ci page = *phy_status & 0xf; 9018c2ecf20Sopenharmony_ci 9028c2ecf20Sopenharmony_ci switch (page) { 9038c2ecf20Sopenharmony_ci case 0: 9048c2ecf20Sopenharmony_ci query_phy_status_page0(rtwdev, phy_status, pkt_stat); 9058c2ecf20Sopenharmony_ci break; 9068c2ecf20Sopenharmony_ci case 1: 9078c2ecf20Sopenharmony_ci query_phy_status_page1(rtwdev, phy_status, pkt_stat); 9088c2ecf20Sopenharmony_ci break; 9098c2ecf20Sopenharmony_ci default: 9108c2ecf20Sopenharmony_ci rtw_warn(rtwdev, "unused phy status page (%d)\n", page); 9118c2ecf20Sopenharmony_ci return; 9128c2ecf20Sopenharmony_ci } 9138c2ecf20Sopenharmony_ci} 9148c2ecf20Sopenharmony_ci 9158c2ecf20Sopenharmony_cistatic void rtw8822b_query_rx_desc(struct rtw_dev *rtwdev, u8 *rx_desc, 9168c2ecf20Sopenharmony_ci struct rtw_rx_pkt_stat *pkt_stat, 9178c2ecf20Sopenharmony_ci struct ieee80211_rx_status *rx_status) 9188c2ecf20Sopenharmony_ci{ 9198c2ecf20Sopenharmony_ci struct ieee80211_hdr *hdr; 9208c2ecf20Sopenharmony_ci u32 desc_sz = rtwdev->chip->rx_pkt_desc_sz; 9218c2ecf20Sopenharmony_ci u8 *phy_status = NULL; 9228c2ecf20Sopenharmony_ci 9238c2ecf20Sopenharmony_ci memset(pkt_stat, 0, sizeof(*pkt_stat)); 9248c2ecf20Sopenharmony_ci 9258c2ecf20Sopenharmony_ci pkt_stat->phy_status = GET_RX_DESC_PHYST(rx_desc); 9268c2ecf20Sopenharmony_ci pkt_stat->icv_err = GET_RX_DESC_ICV_ERR(rx_desc); 9278c2ecf20Sopenharmony_ci pkt_stat->crc_err = GET_RX_DESC_CRC32(rx_desc); 9288c2ecf20Sopenharmony_ci pkt_stat->decrypted = !GET_RX_DESC_SWDEC(rx_desc) && 9298c2ecf20Sopenharmony_ci GET_RX_DESC_ENC_TYPE(rx_desc) != RX_DESC_ENC_NONE; 9308c2ecf20Sopenharmony_ci pkt_stat->is_c2h = GET_RX_DESC_C2H(rx_desc); 9318c2ecf20Sopenharmony_ci pkt_stat->pkt_len = GET_RX_DESC_PKT_LEN(rx_desc); 9328c2ecf20Sopenharmony_ci pkt_stat->drv_info_sz = GET_RX_DESC_DRV_INFO_SIZE(rx_desc); 9338c2ecf20Sopenharmony_ci pkt_stat->shift = GET_RX_DESC_SHIFT(rx_desc); 9348c2ecf20Sopenharmony_ci pkt_stat->rate = GET_RX_DESC_RX_RATE(rx_desc); 9358c2ecf20Sopenharmony_ci pkt_stat->cam_id = GET_RX_DESC_MACID(rx_desc); 9368c2ecf20Sopenharmony_ci pkt_stat->ppdu_cnt = GET_RX_DESC_PPDU_CNT(rx_desc); 9378c2ecf20Sopenharmony_ci pkt_stat->tsf_low = GET_RX_DESC_TSFL(rx_desc); 9388c2ecf20Sopenharmony_ci 9398c2ecf20Sopenharmony_ci /* drv_info_sz is in unit of 8-bytes */ 9408c2ecf20Sopenharmony_ci pkt_stat->drv_info_sz *= 8; 9418c2ecf20Sopenharmony_ci 9428c2ecf20Sopenharmony_ci /* c2h cmd pkt's rx/phy status is not interested */ 9438c2ecf20Sopenharmony_ci if (pkt_stat->is_c2h) 9448c2ecf20Sopenharmony_ci return; 9458c2ecf20Sopenharmony_ci 9468c2ecf20Sopenharmony_ci hdr = (struct ieee80211_hdr *)(rx_desc + desc_sz + pkt_stat->shift + 9478c2ecf20Sopenharmony_ci pkt_stat->drv_info_sz); 9488c2ecf20Sopenharmony_ci if (pkt_stat->phy_status) { 9498c2ecf20Sopenharmony_ci phy_status = rx_desc + desc_sz + pkt_stat->shift; 9508c2ecf20Sopenharmony_ci query_phy_status(rtwdev, phy_status, pkt_stat); 9518c2ecf20Sopenharmony_ci } 9528c2ecf20Sopenharmony_ci 9538c2ecf20Sopenharmony_ci rtw_rx_fill_rx_status(rtwdev, pkt_stat, hdr, rx_status, phy_status); 9548c2ecf20Sopenharmony_ci} 9558c2ecf20Sopenharmony_ci 9568c2ecf20Sopenharmony_cistatic void 9578c2ecf20Sopenharmony_cirtw8822b_set_tx_power_index_by_rate(struct rtw_dev *rtwdev, u8 path, u8 rs) 9588c2ecf20Sopenharmony_ci{ 9598c2ecf20Sopenharmony_ci struct rtw_hal *hal = &rtwdev->hal; 9608c2ecf20Sopenharmony_ci static const u32 offset_txagc[2] = {0x1d00, 0x1d80}; 9618c2ecf20Sopenharmony_ci static u32 phy_pwr_idx; 9628c2ecf20Sopenharmony_ci u8 rate, rate_idx, pwr_index, shift; 9638c2ecf20Sopenharmony_ci int j; 9648c2ecf20Sopenharmony_ci 9658c2ecf20Sopenharmony_ci for (j = 0; j < rtw_rate_size[rs]; j++) { 9668c2ecf20Sopenharmony_ci rate = rtw_rate_section[rs][j]; 9678c2ecf20Sopenharmony_ci pwr_index = hal->tx_pwr_tbl[path][rate]; 9688c2ecf20Sopenharmony_ci shift = rate & 0x3; 9698c2ecf20Sopenharmony_ci phy_pwr_idx |= ((u32)pwr_index << (shift * 8)); 9708c2ecf20Sopenharmony_ci if (shift == 0x3) { 9718c2ecf20Sopenharmony_ci rate_idx = rate & 0xfc; 9728c2ecf20Sopenharmony_ci rtw_write32(rtwdev, offset_txagc[path] + rate_idx, 9738c2ecf20Sopenharmony_ci phy_pwr_idx); 9748c2ecf20Sopenharmony_ci phy_pwr_idx = 0; 9758c2ecf20Sopenharmony_ci } 9768c2ecf20Sopenharmony_ci } 9778c2ecf20Sopenharmony_ci} 9788c2ecf20Sopenharmony_ci 9798c2ecf20Sopenharmony_cistatic void rtw8822b_set_tx_power_index(struct rtw_dev *rtwdev) 9808c2ecf20Sopenharmony_ci{ 9818c2ecf20Sopenharmony_ci struct rtw_hal *hal = &rtwdev->hal; 9828c2ecf20Sopenharmony_ci int rs, path; 9838c2ecf20Sopenharmony_ci 9848c2ecf20Sopenharmony_ci for (path = 0; path < hal->rf_path_num; path++) { 9858c2ecf20Sopenharmony_ci for (rs = 0; rs < RTW_RATE_SECTION_MAX; rs++) 9868c2ecf20Sopenharmony_ci rtw8822b_set_tx_power_index_by_rate(rtwdev, path, rs); 9878c2ecf20Sopenharmony_ci } 9888c2ecf20Sopenharmony_ci} 9898c2ecf20Sopenharmony_ci 9908c2ecf20Sopenharmony_cistatic bool rtw8822b_check_rf_path(u8 antenna) 9918c2ecf20Sopenharmony_ci{ 9928c2ecf20Sopenharmony_ci switch (antenna) { 9938c2ecf20Sopenharmony_ci case BB_PATH_A: 9948c2ecf20Sopenharmony_ci case BB_PATH_B: 9958c2ecf20Sopenharmony_ci case BB_PATH_AB: 9968c2ecf20Sopenharmony_ci return true; 9978c2ecf20Sopenharmony_ci default: 9988c2ecf20Sopenharmony_ci return false; 9998c2ecf20Sopenharmony_ci } 10008c2ecf20Sopenharmony_ci} 10018c2ecf20Sopenharmony_ci 10028c2ecf20Sopenharmony_cistatic int rtw8822b_set_antenna(struct rtw_dev *rtwdev, 10038c2ecf20Sopenharmony_ci u32 antenna_tx, 10048c2ecf20Sopenharmony_ci u32 antenna_rx) 10058c2ecf20Sopenharmony_ci{ 10068c2ecf20Sopenharmony_ci struct rtw_hal *hal = &rtwdev->hal; 10078c2ecf20Sopenharmony_ci 10088c2ecf20Sopenharmony_ci rtw_dbg(rtwdev, RTW_DBG_PHY, "config RF path, tx=0x%x rx=0x%x\n", 10098c2ecf20Sopenharmony_ci antenna_tx, antenna_rx); 10108c2ecf20Sopenharmony_ci 10118c2ecf20Sopenharmony_ci if (!rtw8822b_check_rf_path(antenna_tx)) { 10128c2ecf20Sopenharmony_ci rtw_info(rtwdev, "unsupported tx path 0x%x\n", antenna_tx); 10138c2ecf20Sopenharmony_ci return -EINVAL; 10148c2ecf20Sopenharmony_ci } 10158c2ecf20Sopenharmony_ci 10168c2ecf20Sopenharmony_ci if (!rtw8822b_check_rf_path(antenna_rx)) { 10178c2ecf20Sopenharmony_ci rtw_info(rtwdev, "unsupported rx path 0x%x\n", antenna_rx); 10188c2ecf20Sopenharmony_ci return -EINVAL; 10198c2ecf20Sopenharmony_ci } 10208c2ecf20Sopenharmony_ci 10218c2ecf20Sopenharmony_ci hal->antenna_tx = antenna_tx; 10228c2ecf20Sopenharmony_ci hal->antenna_rx = antenna_rx; 10238c2ecf20Sopenharmony_ci 10248c2ecf20Sopenharmony_ci rtw8822b_config_trx_mode(rtwdev, antenna_tx, antenna_rx, false); 10258c2ecf20Sopenharmony_ci 10268c2ecf20Sopenharmony_ci return 0; 10278c2ecf20Sopenharmony_ci} 10288c2ecf20Sopenharmony_ci 10298c2ecf20Sopenharmony_cistatic void rtw8822b_cfg_ldo25(struct rtw_dev *rtwdev, bool enable) 10308c2ecf20Sopenharmony_ci{ 10318c2ecf20Sopenharmony_ci u8 ldo_pwr; 10328c2ecf20Sopenharmony_ci 10338c2ecf20Sopenharmony_ci ldo_pwr = rtw_read8(rtwdev, REG_LDO_EFUSE_CTRL + 3); 10348c2ecf20Sopenharmony_ci ldo_pwr = enable ? ldo_pwr | BIT_LDO25_EN : ldo_pwr & ~BIT_LDO25_EN; 10358c2ecf20Sopenharmony_ci rtw_write8(rtwdev, REG_LDO_EFUSE_CTRL + 3, ldo_pwr); 10368c2ecf20Sopenharmony_ci} 10378c2ecf20Sopenharmony_ci 10388c2ecf20Sopenharmony_cistatic void rtw8822b_false_alarm_statistics(struct rtw_dev *rtwdev) 10398c2ecf20Sopenharmony_ci{ 10408c2ecf20Sopenharmony_ci struct rtw_dm_info *dm_info = &rtwdev->dm_info; 10418c2ecf20Sopenharmony_ci u32 cck_enable; 10428c2ecf20Sopenharmony_ci u32 cck_fa_cnt; 10438c2ecf20Sopenharmony_ci u32 ofdm_fa_cnt; 10448c2ecf20Sopenharmony_ci u32 crc32_cnt; 10458c2ecf20Sopenharmony_ci u32 cca32_cnt; 10468c2ecf20Sopenharmony_ci 10478c2ecf20Sopenharmony_ci cck_enable = rtw_read32(rtwdev, 0x808) & BIT(28); 10488c2ecf20Sopenharmony_ci cck_fa_cnt = rtw_read16(rtwdev, 0xa5c); 10498c2ecf20Sopenharmony_ci ofdm_fa_cnt = rtw_read16(rtwdev, 0xf48); 10508c2ecf20Sopenharmony_ci 10518c2ecf20Sopenharmony_ci dm_info->cck_fa_cnt = cck_fa_cnt; 10528c2ecf20Sopenharmony_ci dm_info->ofdm_fa_cnt = ofdm_fa_cnt; 10538c2ecf20Sopenharmony_ci dm_info->total_fa_cnt = ofdm_fa_cnt; 10548c2ecf20Sopenharmony_ci dm_info->total_fa_cnt += cck_enable ? cck_fa_cnt : 0; 10558c2ecf20Sopenharmony_ci 10568c2ecf20Sopenharmony_ci crc32_cnt = rtw_read32(rtwdev, 0xf04); 10578c2ecf20Sopenharmony_ci dm_info->cck_ok_cnt = crc32_cnt & 0xffff; 10588c2ecf20Sopenharmony_ci dm_info->cck_err_cnt = (crc32_cnt & 0xffff0000) >> 16; 10598c2ecf20Sopenharmony_ci crc32_cnt = rtw_read32(rtwdev, 0xf14); 10608c2ecf20Sopenharmony_ci dm_info->ofdm_ok_cnt = crc32_cnt & 0xffff; 10618c2ecf20Sopenharmony_ci dm_info->ofdm_err_cnt = (crc32_cnt & 0xffff0000) >> 16; 10628c2ecf20Sopenharmony_ci crc32_cnt = rtw_read32(rtwdev, 0xf10); 10638c2ecf20Sopenharmony_ci dm_info->ht_ok_cnt = crc32_cnt & 0xffff; 10648c2ecf20Sopenharmony_ci dm_info->ht_err_cnt = (crc32_cnt & 0xffff0000) >> 16; 10658c2ecf20Sopenharmony_ci crc32_cnt = rtw_read32(rtwdev, 0xf0c); 10668c2ecf20Sopenharmony_ci dm_info->vht_ok_cnt = crc32_cnt & 0xffff; 10678c2ecf20Sopenharmony_ci dm_info->vht_err_cnt = (crc32_cnt & 0xffff0000) >> 16; 10688c2ecf20Sopenharmony_ci 10698c2ecf20Sopenharmony_ci cca32_cnt = rtw_read32(rtwdev, 0xf08); 10708c2ecf20Sopenharmony_ci dm_info->ofdm_cca_cnt = ((cca32_cnt & 0xffff0000) >> 16); 10718c2ecf20Sopenharmony_ci dm_info->total_cca_cnt = dm_info->ofdm_cca_cnt; 10728c2ecf20Sopenharmony_ci if (cck_enable) { 10738c2ecf20Sopenharmony_ci cca32_cnt = rtw_read32(rtwdev, 0xfcc); 10748c2ecf20Sopenharmony_ci dm_info->cck_cca_cnt = cca32_cnt & 0xffff; 10758c2ecf20Sopenharmony_ci dm_info->total_cca_cnt += dm_info->cck_cca_cnt; 10768c2ecf20Sopenharmony_ci } 10778c2ecf20Sopenharmony_ci 10788c2ecf20Sopenharmony_ci rtw_write32_set(rtwdev, 0x9a4, BIT(17)); 10798c2ecf20Sopenharmony_ci rtw_write32_clr(rtwdev, 0x9a4, BIT(17)); 10808c2ecf20Sopenharmony_ci rtw_write32_clr(rtwdev, 0xa2c, BIT(15)); 10818c2ecf20Sopenharmony_ci rtw_write32_set(rtwdev, 0xa2c, BIT(15)); 10828c2ecf20Sopenharmony_ci rtw_write32_set(rtwdev, 0xb58, BIT(0)); 10838c2ecf20Sopenharmony_ci rtw_write32_clr(rtwdev, 0xb58, BIT(0)); 10848c2ecf20Sopenharmony_ci} 10858c2ecf20Sopenharmony_ci 10868c2ecf20Sopenharmony_cistatic void rtw8822b_do_iqk(struct rtw_dev *rtwdev) 10878c2ecf20Sopenharmony_ci{ 10888c2ecf20Sopenharmony_ci static int do_iqk_cnt; 10898c2ecf20Sopenharmony_ci struct rtw_iqk_para para = {.clear = 0, .segment_iqk = 0}; 10908c2ecf20Sopenharmony_ci u32 rf_reg, iqk_fail_mask; 10918c2ecf20Sopenharmony_ci int counter; 10928c2ecf20Sopenharmony_ci bool reload; 10938c2ecf20Sopenharmony_ci 10948c2ecf20Sopenharmony_ci rtw_fw_do_iqk(rtwdev, ¶); 10958c2ecf20Sopenharmony_ci 10968c2ecf20Sopenharmony_ci for (counter = 0; counter < 300; counter++) { 10978c2ecf20Sopenharmony_ci rf_reg = rtw_read_rf(rtwdev, RF_PATH_A, RF_DTXLOK, RFREG_MASK); 10988c2ecf20Sopenharmony_ci if (rf_reg == 0xabcde) 10998c2ecf20Sopenharmony_ci break; 11008c2ecf20Sopenharmony_ci msleep(20); 11018c2ecf20Sopenharmony_ci } 11028c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_DTXLOK, RFREG_MASK, 0x0); 11038c2ecf20Sopenharmony_ci 11048c2ecf20Sopenharmony_ci reload = !!rtw_read32_mask(rtwdev, REG_IQKFAILMSK, BIT(16)); 11058c2ecf20Sopenharmony_ci iqk_fail_mask = rtw_read32_mask(rtwdev, REG_IQKFAILMSK, GENMASK(7, 0)); 11068c2ecf20Sopenharmony_ci rtw_dbg(rtwdev, RTW_DBG_PHY, 11078c2ecf20Sopenharmony_ci "iqk counter=%d reload=%d do_iqk_cnt=%d n_iqk_fail(mask)=0x%02x\n", 11088c2ecf20Sopenharmony_ci counter, reload, ++do_iqk_cnt, iqk_fail_mask); 11098c2ecf20Sopenharmony_ci} 11108c2ecf20Sopenharmony_ci 11118c2ecf20Sopenharmony_cistatic void rtw8822b_phy_calibration(struct rtw_dev *rtwdev) 11128c2ecf20Sopenharmony_ci{ 11138c2ecf20Sopenharmony_ci rtw8822b_do_iqk(rtwdev); 11148c2ecf20Sopenharmony_ci} 11158c2ecf20Sopenharmony_ci 11168c2ecf20Sopenharmony_cistatic void rtw8822b_coex_cfg_init(struct rtw_dev *rtwdev) 11178c2ecf20Sopenharmony_ci{ 11188c2ecf20Sopenharmony_ci /* enable TBTT nterrupt */ 11198c2ecf20Sopenharmony_ci rtw_write8_set(rtwdev, REG_BCN_CTRL, BIT_EN_BCN_FUNCTION); 11208c2ecf20Sopenharmony_ci 11218c2ecf20Sopenharmony_ci /* BT report packet sample rate */ 11228c2ecf20Sopenharmony_ci /* 0x790[5:0]=0x5 */ 11238c2ecf20Sopenharmony_ci rtw_write8_set(rtwdev, REG_BT_TDMA_TIME, 0x05); 11248c2ecf20Sopenharmony_ci 11258c2ecf20Sopenharmony_ci /* enable BT counter statistics */ 11268c2ecf20Sopenharmony_ci rtw_write8(rtwdev, REG_BT_STAT_CTRL, 0x1); 11278c2ecf20Sopenharmony_ci 11288c2ecf20Sopenharmony_ci /* enable PTA (3-wire function form BT side) */ 11298c2ecf20Sopenharmony_ci rtw_write32_set(rtwdev, REG_GPIO_MUXCFG, BIT_BT_PTA_EN); 11308c2ecf20Sopenharmony_ci rtw_write32_set(rtwdev, REG_GPIO_MUXCFG, BIT_BT_AOD_GPIO3); 11318c2ecf20Sopenharmony_ci 11328c2ecf20Sopenharmony_ci /* enable PTA (tx/rx signal form WiFi side) */ 11338c2ecf20Sopenharmony_ci rtw_write8_set(rtwdev, REG_QUEUE_CTRL, BIT_PTA_WL_TX_EN); 11348c2ecf20Sopenharmony_ci /* wl tx signal to PTA not case EDCCA */ 11358c2ecf20Sopenharmony_ci rtw_write8_clr(rtwdev, REG_QUEUE_CTRL, BIT_PTA_EDCCA_EN); 11368c2ecf20Sopenharmony_ci /* GNT_BT=1 while select both */ 11378c2ecf20Sopenharmony_ci rtw_write8_set(rtwdev, REG_BT_COEX_V2, BIT_GNT_BT_POLARITY); 11388c2ecf20Sopenharmony_ci} 11398c2ecf20Sopenharmony_ci 11408c2ecf20Sopenharmony_cistatic void rtw8822b_coex_cfg_ant_switch(struct rtw_dev *rtwdev, 11418c2ecf20Sopenharmony_ci u8 ctrl_type, u8 pos_type) 11428c2ecf20Sopenharmony_ci{ 11438c2ecf20Sopenharmony_ci struct rtw_coex *coex = &rtwdev->coex; 11448c2ecf20Sopenharmony_ci struct rtw_coex_dm *coex_dm = &coex->dm; 11458c2ecf20Sopenharmony_ci struct rtw_coex_rfe *coex_rfe = &coex->rfe; 11468c2ecf20Sopenharmony_ci bool polarity_inverse; 11478c2ecf20Sopenharmony_ci u8 regval = 0; 11488c2ecf20Sopenharmony_ci 11498c2ecf20Sopenharmony_ci if (((ctrl_type << 8) + pos_type) == coex_dm->cur_switch_status) 11508c2ecf20Sopenharmony_ci return; 11518c2ecf20Sopenharmony_ci 11528c2ecf20Sopenharmony_ci coex_dm->cur_switch_status = (ctrl_type << 8) + pos_type; 11538c2ecf20Sopenharmony_ci 11548c2ecf20Sopenharmony_ci if (coex_rfe->ant_switch_diversity && 11558c2ecf20Sopenharmony_ci ctrl_type == COEX_SWITCH_CTRL_BY_BBSW) 11568c2ecf20Sopenharmony_ci ctrl_type = COEX_SWITCH_CTRL_BY_ANTDIV; 11578c2ecf20Sopenharmony_ci 11588c2ecf20Sopenharmony_ci polarity_inverse = (coex_rfe->ant_switch_polarity == 1); 11598c2ecf20Sopenharmony_ci 11608c2ecf20Sopenharmony_ci switch (ctrl_type) { 11618c2ecf20Sopenharmony_ci default: 11628c2ecf20Sopenharmony_ci case COEX_SWITCH_CTRL_BY_BBSW: 11638c2ecf20Sopenharmony_ci /* 0x4c[23] = 0 */ 11648c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_LED_CFG + 2, BIT_DPDT_SEL_EN >> 16, 0x0); 11658c2ecf20Sopenharmony_ci /* 0x4c[24] = 1 */ 11668c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_LED_CFG + 3, BIT_DPDT_WL_SEL >> 24, 0x1); 11678c2ecf20Sopenharmony_ci /* BB SW, DPDT use RFE_ctrl8 and RFE_ctrl9 as ctrl pin */ 11688c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_RFE_CTRL8, BIT_MASK_RFE_SEL89, 0x77); 11698c2ecf20Sopenharmony_ci 11708c2ecf20Sopenharmony_ci if (pos_type == COEX_SWITCH_TO_WLG_BT) { 11718c2ecf20Sopenharmony_ci if (coex_rfe->rfe_module_type != 0x4 && 11728c2ecf20Sopenharmony_ci coex_rfe->rfe_module_type != 0x2) 11738c2ecf20Sopenharmony_ci regval = 0x3; 11748c2ecf20Sopenharmony_ci else 11758c2ecf20Sopenharmony_ci regval = (!polarity_inverse ? 0x2 : 0x1); 11768c2ecf20Sopenharmony_ci } else if (pos_type == COEX_SWITCH_TO_WLG) { 11778c2ecf20Sopenharmony_ci regval = (!polarity_inverse ? 0x2 : 0x1); 11788c2ecf20Sopenharmony_ci } else { 11798c2ecf20Sopenharmony_ci regval = (!polarity_inverse ? 0x1 : 0x2); 11808c2ecf20Sopenharmony_ci } 11818c2ecf20Sopenharmony_ci 11828c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_RFE_INV8, BIT_MASK_RFE_INV89, regval); 11838c2ecf20Sopenharmony_ci break; 11848c2ecf20Sopenharmony_ci case COEX_SWITCH_CTRL_BY_PTA: 11858c2ecf20Sopenharmony_ci /* 0x4c[23] = 0 */ 11868c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_LED_CFG + 2, BIT_DPDT_SEL_EN >> 16, 0x0); 11878c2ecf20Sopenharmony_ci /* 0x4c[24] = 1 */ 11888c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_LED_CFG + 3, BIT_DPDT_WL_SEL >> 24, 0x1); 11898c2ecf20Sopenharmony_ci /* PTA, DPDT use RFE_ctrl8 and RFE_ctrl9 as ctrl pin */ 11908c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_RFE_CTRL8, BIT_MASK_RFE_SEL89, 0x66); 11918c2ecf20Sopenharmony_ci 11928c2ecf20Sopenharmony_ci regval = (!polarity_inverse ? 0x2 : 0x1); 11938c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_RFE_INV8, BIT_MASK_RFE_INV89, regval); 11948c2ecf20Sopenharmony_ci break; 11958c2ecf20Sopenharmony_ci case COEX_SWITCH_CTRL_BY_ANTDIV: 11968c2ecf20Sopenharmony_ci /* 0x4c[23] = 0 */ 11978c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_LED_CFG + 2, BIT_DPDT_SEL_EN >> 16, 0x0); 11988c2ecf20Sopenharmony_ci /* 0x4c[24] = 1 */ 11998c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_LED_CFG + 3, BIT_DPDT_WL_SEL >> 24, 0x1); 12008c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_RFE_CTRL8, BIT_MASK_RFE_SEL89, 0x88); 12018c2ecf20Sopenharmony_ci break; 12028c2ecf20Sopenharmony_ci case COEX_SWITCH_CTRL_BY_MAC: 12038c2ecf20Sopenharmony_ci /* 0x4c[23] = 1 */ 12048c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_LED_CFG + 2, BIT_DPDT_SEL_EN >> 16, 0x1); 12058c2ecf20Sopenharmony_ci 12068c2ecf20Sopenharmony_ci regval = (!polarity_inverse ? 0x0 : 0x1); 12078c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_PAD_CTRL1, BIT_SW_DPDT_SEL_DATA, regval); 12088c2ecf20Sopenharmony_ci break; 12098c2ecf20Sopenharmony_ci case COEX_SWITCH_CTRL_BY_FW: 12108c2ecf20Sopenharmony_ci /* 0x4c[23] = 0 */ 12118c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_LED_CFG + 2, BIT_DPDT_SEL_EN >> 16, 0x0); 12128c2ecf20Sopenharmony_ci /* 0x4c[24] = 1 */ 12138c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_LED_CFG + 3, BIT_DPDT_WL_SEL >> 24, 0x1); 12148c2ecf20Sopenharmony_ci break; 12158c2ecf20Sopenharmony_ci case COEX_SWITCH_CTRL_BY_BT: 12168c2ecf20Sopenharmony_ci /* 0x4c[23] = 0 */ 12178c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_LED_CFG + 2, BIT_DPDT_SEL_EN >> 16, 0x0); 12188c2ecf20Sopenharmony_ci /* 0x4c[24] = 0 */ 12198c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_LED_CFG + 3, BIT_DPDT_WL_SEL >> 24, 0x0); 12208c2ecf20Sopenharmony_ci break; 12218c2ecf20Sopenharmony_ci } 12228c2ecf20Sopenharmony_ci} 12238c2ecf20Sopenharmony_ci 12248c2ecf20Sopenharmony_cistatic void rtw8822b_coex_cfg_gnt_fix(struct rtw_dev *rtwdev) 12258c2ecf20Sopenharmony_ci{ 12268c2ecf20Sopenharmony_ci} 12278c2ecf20Sopenharmony_ci 12288c2ecf20Sopenharmony_cistatic void rtw8822b_coex_cfg_gnt_debug(struct rtw_dev *rtwdev) 12298c2ecf20Sopenharmony_ci{ 12308c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_PAD_CTRL1 + 2, BIT_BTGP_SPI_EN >> 16, 0); 12318c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_PAD_CTRL1 + 3, BIT_BTGP_JTAG_EN >> 24, 0); 12328c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_GPIO_MUXCFG + 2, BIT_FSPI_EN >> 16, 0); 12338c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_PAD_CTRL1 + 1, BIT_LED1DIS >> 8, 0); 12348c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_SYS_SDIO_CTRL + 3, BIT_DBG_GNT_WL_BT >> 24, 0); 12358c2ecf20Sopenharmony_ci} 12368c2ecf20Sopenharmony_ci 12378c2ecf20Sopenharmony_cistatic void rtw8822b_coex_cfg_rfe_type(struct rtw_dev *rtwdev) 12388c2ecf20Sopenharmony_ci{ 12398c2ecf20Sopenharmony_ci struct rtw_coex *coex = &rtwdev->coex; 12408c2ecf20Sopenharmony_ci struct rtw_coex_rfe *coex_rfe = &coex->rfe; 12418c2ecf20Sopenharmony_ci struct rtw_efuse *efuse = &rtwdev->efuse; 12428c2ecf20Sopenharmony_ci bool is_ext_fem = false; 12438c2ecf20Sopenharmony_ci 12448c2ecf20Sopenharmony_ci coex_rfe->rfe_module_type = rtwdev->efuse.rfe_option; 12458c2ecf20Sopenharmony_ci coex_rfe->ant_switch_polarity = 0; 12468c2ecf20Sopenharmony_ci coex_rfe->ant_switch_diversity = false; 12478c2ecf20Sopenharmony_ci if (coex_rfe->rfe_module_type == 0x12 || 12488c2ecf20Sopenharmony_ci coex_rfe->rfe_module_type == 0x15 || 12498c2ecf20Sopenharmony_ci coex_rfe->rfe_module_type == 0x16) 12508c2ecf20Sopenharmony_ci coex_rfe->ant_switch_exist = false; 12518c2ecf20Sopenharmony_ci else 12528c2ecf20Sopenharmony_ci coex_rfe->ant_switch_exist = true; 12538c2ecf20Sopenharmony_ci 12548c2ecf20Sopenharmony_ci if (coex_rfe->rfe_module_type == 2 || 12558c2ecf20Sopenharmony_ci coex_rfe->rfe_module_type == 4) { 12568c2ecf20Sopenharmony_ci rtw_coex_write_scbd(rtwdev, COEX_SCBD_EXTFEM, true); 12578c2ecf20Sopenharmony_ci is_ext_fem = true; 12588c2ecf20Sopenharmony_ci } else { 12598c2ecf20Sopenharmony_ci rtw_coex_write_scbd(rtwdev, COEX_SCBD_EXTFEM, false); 12608c2ecf20Sopenharmony_ci } 12618c2ecf20Sopenharmony_ci 12628c2ecf20Sopenharmony_ci coex_rfe->wlg_at_btg = false; 12638c2ecf20Sopenharmony_ci 12648c2ecf20Sopenharmony_ci if (efuse->share_ant && 12658c2ecf20Sopenharmony_ci coex_rfe->ant_switch_exist && !is_ext_fem) 12668c2ecf20Sopenharmony_ci coex_rfe->ant_switch_with_bt = true; 12678c2ecf20Sopenharmony_ci else 12688c2ecf20Sopenharmony_ci coex_rfe->ant_switch_with_bt = false; 12698c2ecf20Sopenharmony_ci 12708c2ecf20Sopenharmony_ci /* Ext switch buffer mux */ 12718c2ecf20Sopenharmony_ci rtw_write8(rtwdev, REG_RFE_CTRL_E, 0xff); 12728c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_RFESEL_CTRL + 1, 0x3, 0x0); 12738c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, REG_RFE_INV16, BIT_RFE_BUF_EN, 0x0); 12748c2ecf20Sopenharmony_ci 12758c2ecf20Sopenharmony_ci /* Disable LTE Coex Function in WiFi side */ 12768c2ecf20Sopenharmony_ci rtw_coex_write_indirect_reg(rtwdev, LTE_COEX_CTRL, BIT_LTE_COEX_EN, 0); 12778c2ecf20Sopenharmony_ci 12788c2ecf20Sopenharmony_ci /* BTC_CTT_WL_VS_LTE */ 12798c2ecf20Sopenharmony_ci rtw_coex_write_indirect_reg(rtwdev, LTE_WL_TRX_CTRL, MASKLWORD, 0xffff); 12808c2ecf20Sopenharmony_ci 12818c2ecf20Sopenharmony_ci /* BTC_CTT_BT_VS_LTE */ 12828c2ecf20Sopenharmony_ci rtw_coex_write_indirect_reg(rtwdev, LTE_BT_TRX_CTRL, MASKLWORD, 0xffff); 12838c2ecf20Sopenharmony_ci} 12848c2ecf20Sopenharmony_ci 12858c2ecf20Sopenharmony_cistatic void rtw8822b_coex_cfg_wl_tx_power(struct rtw_dev *rtwdev, u8 wl_pwr) 12868c2ecf20Sopenharmony_ci{ 12878c2ecf20Sopenharmony_ci struct rtw_coex *coex = &rtwdev->coex; 12888c2ecf20Sopenharmony_ci struct rtw_coex_dm *coex_dm = &coex->dm; 12898c2ecf20Sopenharmony_ci static const u16 reg_addr[] = {0xc58, 0xe58}; 12908c2ecf20Sopenharmony_ci static const u8 wl_tx_power[] = {0xd8, 0xd4, 0xd0, 0xcc, 0xc8}; 12918c2ecf20Sopenharmony_ci u8 i, pwr; 12928c2ecf20Sopenharmony_ci 12938c2ecf20Sopenharmony_ci if (wl_pwr == coex_dm->cur_wl_pwr_lvl) 12948c2ecf20Sopenharmony_ci return; 12958c2ecf20Sopenharmony_ci 12968c2ecf20Sopenharmony_ci coex_dm->cur_wl_pwr_lvl = wl_pwr; 12978c2ecf20Sopenharmony_ci 12988c2ecf20Sopenharmony_ci if (coex_dm->cur_wl_pwr_lvl >= ARRAY_SIZE(wl_tx_power)) 12998c2ecf20Sopenharmony_ci coex_dm->cur_wl_pwr_lvl = ARRAY_SIZE(wl_tx_power) - 1; 13008c2ecf20Sopenharmony_ci 13018c2ecf20Sopenharmony_ci pwr = wl_tx_power[coex_dm->cur_wl_pwr_lvl]; 13028c2ecf20Sopenharmony_ci 13038c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(reg_addr); i++) 13048c2ecf20Sopenharmony_ci rtw_write8_mask(rtwdev, reg_addr[i], 0xff, pwr); 13058c2ecf20Sopenharmony_ci} 13068c2ecf20Sopenharmony_ci 13078c2ecf20Sopenharmony_cistatic void rtw8822b_coex_cfg_wl_rx_gain(struct rtw_dev *rtwdev, bool low_gain) 13088c2ecf20Sopenharmony_ci{ 13098c2ecf20Sopenharmony_ci struct rtw_coex *coex = &rtwdev->coex; 13108c2ecf20Sopenharmony_ci struct rtw_coex_dm *coex_dm = &coex->dm; 13118c2ecf20Sopenharmony_ci /* WL Rx Low gain on */ 13128c2ecf20Sopenharmony_ci static const u32 wl_rx_low_gain_on[] = { 13138c2ecf20Sopenharmony_ci 0xff000003, 0xbd120003, 0xbe100003, 0xbf080003, 0xbf060003, 13148c2ecf20Sopenharmony_ci 0xbf050003, 0xbc140003, 0xbb160003, 0xba180003, 0xb91a0003, 13158c2ecf20Sopenharmony_ci 0xb81c0003, 0xb71e0003, 0xb4200003, 0xb5220003, 0xb4240003, 13168c2ecf20Sopenharmony_ci 0xb3260003, 0xb2280003, 0xb12a0003, 0xb02c0003, 0xaf2e0003, 13178c2ecf20Sopenharmony_ci 0xae300003, 0xad320003, 0xac340003, 0xab360003, 0x8d380003, 13188c2ecf20Sopenharmony_ci 0x8c3a0003, 0x8b3c0003, 0x8a3e0003, 0x6e400003, 0x6d420003, 13198c2ecf20Sopenharmony_ci 0x6c440003, 0x6b460003, 0x6a480003, 0x694a0003, 0x684c0003, 13208c2ecf20Sopenharmony_ci 0x674e0003, 0x66500003, 0x65520003, 0x64540003, 0x64560003, 13218c2ecf20Sopenharmony_ci 0x007e0403 13228c2ecf20Sopenharmony_ci }; 13238c2ecf20Sopenharmony_ci 13248c2ecf20Sopenharmony_ci /* WL Rx Low gain off */ 13258c2ecf20Sopenharmony_ci static const u32 wl_rx_low_gain_off[] = { 13268c2ecf20Sopenharmony_ci 0xff000003, 0xf4120003, 0xf5100003, 0xf60e0003, 0xf70c0003, 13278c2ecf20Sopenharmony_ci 0xf80a0003, 0xf3140003, 0xf2160003, 0xf1180003, 0xf01a0003, 13288c2ecf20Sopenharmony_ci 0xef1c0003, 0xee1e0003, 0xed200003, 0xec220003, 0xeb240003, 13298c2ecf20Sopenharmony_ci 0xea260003, 0xe9280003, 0xe82a0003, 0xe72c0003, 0xe62e0003, 13308c2ecf20Sopenharmony_ci 0xe5300003, 0xc8320003, 0xc7340003, 0xc6360003, 0xc5380003, 13318c2ecf20Sopenharmony_ci 0xc43a0003, 0xc33c0003, 0xc23e0003, 0xc1400003, 0xc0420003, 13328c2ecf20Sopenharmony_ci 0xa5440003, 0xa4460003, 0xa3480003, 0xa24a0003, 0xa14c0003, 13338c2ecf20Sopenharmony_ci 0x834e0003, 0x82500003, 0x81520003, 0x80540003, 0x65560003, 13348c2ecf20Sopenharmony_ci 0x007e0403 13358c2ecf20Sopenharmony_ci }; 13368c2ecf20Sopenharmony_ci u8 i; 13378c2ecf20Sopenharmony_ci 13388c2ecf20Sopenharmony_ci if (low_gain == coex_dm->cur_wl_rx_low_gain_en) 13398c2ecf20Sopenharmony_ci return; 13408c2ecf20Sopenharmony_ci 13418c2ecf20Sopenharmony_ci coex_dm->cur_wl_rx_low_gain_en = low_gain; 13428c2ecf20Sopenharmony_ci 13438c2ecf20Sopenharmony_ci if (coex_dm->cur_wl_rx_low_gain_en) { 13448c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(wl_rx_low_gain_on); i++) 13458c2ecf20Sopenharmony_ci rtw_write32(rtwdev, REG_RX_GAIN_EN, wl_rx_low_gain_on[i]); 13468c2ecf20Sopenharmony_ci 13478c2ecf20Sopenharmony_ci /* set Rx filter corner RCK offset */ 13488c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_RCKD, 0x2, 0x1); 13498c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_RCK, 0x3f, 0x3f); 13508c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_B, RF_RCKD, 0x2, 0x1); 13518c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_B, RF_RCK, 0x3f, 0x3f); 13528c2ecf20Sopenharmony_ci } else { 13538c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(wl_rx_low_gain_off); i++) 13548c2ecf20Sopenharmony_ci rtw_write32(rtwdev, 0x81c, wl_rx_low_gain_off[i]); 13558c2ecf20Sopenharmony_ci 13568c2ecf20Sopenharmony_ci /* set Rx filter corner RCK offset */ 13578c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_RCK, 0x3f, 0x4); 13588c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_RCKD, 0x2, 0x0); 13598c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_B, RF_RCK, 0x3f, 0x4); 13608c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_B, RF_RCKD, 0x2, 0x0); 13618c2ecf20Sopenharmony_ci } 13628c2ecf20Sopenharmony_ci} 13638c2ecf20Sopenharmony_ci 13648c2ecf20Sopenharmony_cistatic void rtw8822b_txagc_swing_offset(struct rtw_dev *rtwdev, u8 path, 13658c2ecf20Sopenharmony_ci u8 tx_pwr_idx_offset, 13668c2ecf20Sopenharmony_ci s8 *txagc_idx, u8 *swing_idx) 13678c2ecf20Sopenharmony_ci{ 13688c2ecf20Sopenharmony_ci struct rtw_dm_info *dm_info = &rtwdev->dm_info; 13698c2ecf20Sopenharmony_ci s8 delta_pwr_idx = dm_info->delta_power_index[path]; 13708c2ecf20Sopenharmony_ci u8 swing_upper_bound = dm_info->default_ofdm_index + 10; 13718c2ecf20Sopenharmony_ci u8 swing_lower_bound = 0; 13728c2ecf20Sopenharmony_ci u8 max_tx_pwr_idx_offset = 0xf; 13738c2ecf20Sopenharmony_ci s8 agc_index = 0; 13748c2ecf20Sopenharmony_ci u8 swing_index = dm_info->default_ofdm_index; 13758c2ecf20Sopenharmony_ci 13768c2ecf20Sopenharmony_ci tx_pwr_idx_offset = min_t(u8, tx_pwr_idx_offset, max_tx_pwr_idx_offset); 13778c2ecf20Sopenharmony_ci 13788c2ecf20Sopenharmony_ci if (delta_pwr_idx >= 0) { 13798c2ecf20Sopenharmony_ci if (delta_pwr_idx <= tx_pwr_idx_offset) { 13808c2ecf20Sopenharmony_ci agc_index = delta_pwr_idx; 13818c2ecf20Sopenharmony_ci swing_index = dm_info->default_ofdm_index; 13828c2ecf20Sopenharmony_ci } else if (delta_pwr_idx > tx_pwr_idx_offset) { 13838c2ecf20Sopenharmony_ci agc_index = tx_pwr_idx_offset; 13848c2ecf20Sopenharmony_ci swing_index = dm_info->default_ofdm_index + 13858c2ecf20Sopenharmony_ci delta_pwr_idx - tx_pwr_idx_offset; 13868c2ecf20Sopenharmony_ci swing_index = min_t(u8, swing_index, swing_upper_bound); 13878c2ecf20Sopenharmony_ci } 13888c2ecf20Sopenharmony_ci } else { 13898c2ecf20Sopenharmony_ci if (dm_info->default_ofdm_index > abs(delta_pwr_idx)) 13908c2ecf20Sopenharmony_ci swing_index = 13918c2ecf20Sopenharmony_ci dm_info->default_ofdm_index + delta_pwr_idx; 13928c2ecf20Sopenharmony_ci else 13938c2ecf20Sopenharmony_ci swing_index = swing_lower_bound; 13948c2ecf20Sopenharmony_ci swing_index = max_t(u8, swing_index, swing_lower_bound); 13958c2ecf20Sopenharmony_ci 13968c2ecf20Sopenharmony_ci agc_index = 0; 13978c2ecf20Sopenharmony_ci } 13988c2ecf20Sopenharmony_ci 13998c2ecf20Sopenharmony_ci if (swing_index >= RTW_TXSCALE_SIZE) { 14008c2ecf20Sopenharmony_ci rtw_warn(rtwdev, "swing index overflow\n"); 14018c2ecf20Sopenharmony_ci swing_index = RTW_TXSCALE_SIZE - 1; 14028c2ecf20Sopenharmony_ci } 14038c2ecf20Sopenharmony_ci *txagc_idx = agc_index; 14048c2ecf20Sopenharmony_ci *swing_idx = swing_index; 14058c2ecf20Sopenharmony_ci} 14068c2ecf20Sopenharmony_ci 14078c2ecf20Sopenharmony_cistatic void rtw8822b_pwrtrack_set_pwr(struct rtw_dev *rtwdev, u8 path, 14088c2ecf20Sopenharmony_ci u8 pwr_idx_offset) 14098c2ecf20Sopenharmony_ci{ 14108c2ecf20Sopenharmony_ci s8 txagc_idx; 14118c2ecf20Sopenharmony_ci u8 swing_idx; 14128c2ecf20Sopenharmony_ci u32 reg1, reg2; 14138c2ecf20Sopenharmony_ci 14148c2ecf20Sopenharmony_ci if (path == RF_PATH_A) { 14158c2ecf20Sopenharmony_ci reg1 = 0xc94; 14168c2ecf20Sopenharmony_ci reg2 = 0xc1c; 14178c2ecf20Sopenharmony_ci } else if (path == RF_PATH_B) { 14188c2ecf20Sopenharmony_ci reg1 = 0xe94; 14198c2ecf20Sopenharmony_ci reg2 = 0xe1c; 14208c2ecf20Sopenharmony_ci } else { 14218c2ecf20Sopenharmony_ci return; 14228c2ecf20Sopenharmony_ci } 14238c2ecf20Sopenharmony_ci 14248c2ecf20Sopenharmony_ci rtw8822b_txagc_swing_offset(rtwdev, path, pwr_idx_offset, 14258c2ecf20Sopenharmony_ci &txagc_idx, &swing_idx); 14268c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, reg1, GENMASK(29, 25), txagc_idx); 14278c2ecf20Sopenharmony_ci rtw_write32_mask(rtwdev, reg2, GENMASK(31, 21), 14288c2ecf20Sopenharmony_ci rtw8822b_txscale_tbl[swing_idx]); 14298c2ecf20Sopenharmony_ci} 14308c2ecf20Sopenharmony_ci 14318c2ecf20Sopenharmony_cistatic void rtw8822b_pwrtrack_set(struct rtw_dev *rtwdev, u8 path) 14328c2ecf20Sopenharmony_ci{ 14338c2ecf20Sopenharmony_ci struct rtw_dm_info *dm_info = &rtwdev->dm_info; 14348c2ecf20Sopenharmony_ci u8 pwr_idx_offset, tx_pwr_idx; 14358c2ecf20Sopenharmony_ci u8 channel = rtwdev->hal.current_channel; 14368c2ecf20Sopenharmony_ci u8 band_width = rtwdev->hal.current_band_width; 14378c2ecf20Sopenharmony_ci u8 regd = rtwdev->regd.txpwr_regd; 14388c2ecf20Sopenharmony_ci u8 tx_rate = dm_info->tx_rate; 14398c2ecf20Sopenharmony_ci u8 max_pwr_idx = rtwdev->chip->max_power_index; 14408c2ecf20Sopenharmony_ci 14418c2ecf20Sopenharmony_ci tx_pwr_idx = rtw_phy_get_tx_power_index(rtwdev, path, tx_rate, 14428c2ecf20Sopenharmony_ci band_width, channel, regd); 14438c2ecf20Sopenharmony_ci 14448c2ecf20Sopenharmony_ci tx_pwr_idx = min_t(u8, tx_pwr_idx, max_pwr_idx); 14458c2ecf20Sopenharmony_ci 14468c2ecf20Sopenharmony_ci pwr_idx_offset = max_pwr_idx - tx_pwr_idx; 14478c2ecf20Sopenharmony_ci 14488c2ecf20Sopenharmony_ci rtw8822b_pwrtrack_set_pwr(rtwdev, path, pwr_idx_offset); 14498c2ecf20Sopenharmony_ci} 14508c2ecf20Sopenharmony_ci 14518c2ecf20Sopenharmony_cistatic void rtw8822b_phy_pwrtrack_path(struct rtw_dev *rtwdev, 14528c2ecf20Sopenharmony_ci struct rtw_swing_table *swing_table, 14538c2ecf20Sopenharmony_ci u8 path) 14548c2ecf20Sopenharmony_ci{ 14558c2ecf20Sopenharmony_ci struct rtw_dm_info *dm_info = &rtwdev->dm_info; 14568c2ecf20Sopenharmony_ci u8 power_idx_cur, power_idx_last; 14578c2ecf20Sopenharmony_ci u8 delta; 14588c2ecf20Sopenharmony_ci 14598c2ecf20Sopenharmony_ci /* 8822B only has one thermal meter at PATH A */ 14608c2ecf20Sopenharmony_ci delta = rtw_phy_pwrtrack_get_delta(rtwdev, RF_PATH_A); 14618c2ecf20Sopenharmony_ci 14628c2ecf20Sopenharmony_ci power_idx_last = dm_info->delta_power_index[path]; 14638c2ecf20Sopenharmony_ci power_idx_cur = rtw_phy_pwrtrack_get_pwridx(rtwdev, swing_table, 14648c2ecf20Sopenharmony_ci path, RF_PATH_A, delta); 14658c2ecf20Sopenharmony_ci 14668c2ecf20Sopenharmony_ci /* if delta of power indexes are the same, just skip */ 14678c2ecf20Sopenharmony_ci if (power_idx_cur == power_idx_last) 14688c2ecf20Sopenharmony_ci return; 14698c2ecf20Sopenharmony_ci 14708c2ecf20Sopenharmony_ci dm_info->delta_power_index[path] = power_idx_cur; 14718c2ecf20Sopenharmony_ci rtw8822b_pwrtrack_set(rtwdev, path); 14728c2ecf20Sopenharmony_ci} 14738c2ecf20Sopenharmony_ci 14748c2ecf20Sopenharmony_cistatic void rtw8822b_phy_pwrtrack(struct rtw_dev *rtwdev) 14758c2ecf20Sopenharmony_ci{ 14768c2ecf20Sopenharmony_ci struct rtw_dm_info *dm_info = &rtwdev->dm_info; 14778c2ecf20Sopenharmony_ci struct rtw_swing_table swing_table; 14788c2ecf20Sopenharmony_ci u8 thermal_value, path; 14798c2ecf20Sopenharmony_ci 14808c2ecf20Sopenharmony_ci rtw_phy_config_swing_table(rtwdev, &swing_table); 14818c2ecf20Sopenharmony_ci 14828c2ecf20Sopenharmony_ci if (rtwdev->efuse.thermal_meter[RF_PATH_A] == 0xff) 14838c2ecf20Sopenharmony_ci return; 14848c2ecf20Sopenharmony_ci 14858c2ecf20Sopenharmony_ci thermal_value = rtw_read_rf(rtwdev, RF_PATH_A, RF_T_METER, 0xfc00); 14868c2ecf20Sopenharmony_ci 14878c2ecf20Sopenharmony_ci rtw_phy_pwrtrack_avg(rtwdev, thermal_value, RF_PATH_A); 14888c2ecf20Sopenharmony_ci 14898c2ecf20Sopenharmony_ci if (dm_info->pwr_trk_init_trigger) 14908c2ecf20Sopenharmony_ci dm_info->pwr_trk_init_trigger = false; 14918c2ecf20Sopenharmony_ci else if (!rtw_phy_pwrtrack_thermal_changed(rtwdev, thermal_value, 14928c2ecf20Sopenharmony_ci RF_PATH_A)) 14938c2ecf20Sopenharmony_ci goto iqk; 14948c2ecf20Sopenharmony_ci 14958c2ecf20Sopenharmony_ci for (path = 0; path < rtwdev->hal.rf_path_num; path++) 14968c2ecf20Sopenharmony_ci rtw8822b_phy_pwrtrack_path(rtwdev, &swing_table, path); 14978c2ecf20Sopenharmony_ci 14988c2ecf20Sopenharmony_ciiqk: 14998c2ecf20Sopenharmony_ci if (rtw_phy_pwrtrack_need_iqk(rtwdev)) 15008c2ecf20Sopenharmony_ci rtw8822b_do_iqk(rtwdev); 15018c2ecf20Sopenharmony_ci} 15028c2ecf20Sopenharmony_ci 15038c2ecf20Sopenharmony_cistatic void rtw8822b_pwr_track(struct rtw_dev *rtwdev) 15048c2ecf20Sopenharmony_ci{ 15058c2ecf20Sopenharmony_ci struct rtw_efuse *efuse = &rtwdev->efuse; 15068c2ecf20Sopenharmony_ci struct rtw_dm_info *dm_info = &rtwdev->dm_info; 15078c2ecf20Sopenharmony_ci 15088c2ecf20Sopenharmony_ci if (efuse->power_track_type != 0) 15098c2ecf20Sopenharmony_ci return; 15108c2ecf20Sopenharmony_ci 15118c2ecf20Sopenharmony_ci if (!dm_info->pwr_trk_triggered) { 15128c2ecf20Sopenharmony_ci rtw_write_rf(rtwdev, RF_PATH_A, RF_T_METER, 15138c2ecf20Sopenharmony_ci GENMASK(17, 16), 0x03); 15148c2ecf20Sopenharmony_ci dm_info->pwr_trk_triggered = true; 15158c2ecf20Sopenharmony_ci return; 15168c2ecf20Sopenharmony_ci } 15178c2ecf20Sopenharmony_ci 15188c2ecf20Sopenharmony_ci rtw8822b_phy_pwrtrack(rtwdev); 15198c2ecf20Sopenharmony_ci dm_info->pwr_trk_triggered = false; 15208c2ecf20Sopenharmony_ci} 15218c2ecf20Sopenharmony_ci 15228c2ecf20Sopenharmony_cistatic void rtw8822b_bf_config_bfee_su(struct rtw_dev *rtwdev, 15238c2ecf20Sopenharmony_ci struct rtw_vif *vif, 15248c2ecf20Sopenharmony_ci struct rtw_bfee *bfee, bool enable) 15258c2ecf20Sopenharmony_ci{ 15268c2ecf20Sopenharmony_ci if (enable) 15278c2ecf20Sopenharmony_ci rtw_bf_enable_bfee_su(rtwdev, vif, bfee); 15288c2ecf20Sopenharmony_ci else 15298c2ecf20Sopenharmony_ci rtw_bf_remove_bfee_su(rtwdev, bfee); 15308c2ecf20Sopenharmony_ci} 15318c2ecf20Sopenharmony_ci 15328c2ecf20Sopenharmony_cistatic void rtw8822b_bf_config_bfee_mu(struct rtw_dev *rtwdev, 15338c2ecf20Sopenharmony_ci struct rtw_vif *vif, 15348c2ecf20Sopenharmony_ci struct rtw_bfee *bfee, bool enable) 15358c2ecf20Sopenharmony_ci{ 15368c2ecf20Sopenharmony_ci if (enable) 15378c2ecf20Sopenharmony_ci rtw_bf_enable_bfee_mu(rtwdev, vif, bfee); 15388c2ecf20Sopenharmony_ci else 15398c2ecf20Sopenharmony_ci rtw_bf_remove_bfee_mu(rtwdev, bfee); 15408c2ecf20Sopenharmony_ci} 15418c2ecf20Sopenharmony_ci 15428c2ecf20Sopenharmony_cistatic void rtw8822b_bf_config_bfee(struct rtw_dev *rtwdev, struct rtw_vif *vif, 15438c2ecf20Sopenharmony_ci struct rtw_bfee *bfee, bool enable) 15448c2ecf20Sopenharmony_ci{ 15458c2ecf20Sopenharmony_ci if (bfee->role == RTW_BFEE_SU) 15468c2ecf20Sopenharmony_ci rtw8822b_bf_config_bfee_su(rtwdev, vif, bfee, enable); 15478c2ecf20Sopenharmony_ci else if (bfee->role == RTW_BFEE_MU) 15488c2ecf20Sopenharmony_ci rtw8822b_bf_config_bfee_mu(rtwdev, vif, bfee, enable); 15498c2ecf20Sopenharmony_ci else 15508c2ecf20Sopenharmony_ci rtw_warn(rtwdev, "wrong bfee role\n"); 15518c2ecf20Sopenharmony_ci} 15528c2ecf20Sopenharmony_ci 15538c2ecf20Sopenharmony_cistatic const struct rtw_pwr_seq_cmd trans_carddis_to_cardemu_8822b[] = { 15548c2ecf20Sopenharmony_ci {0x0086, 15558c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 15568c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 15578c2ecf20Sopenharmony_ci RTW_PWR_ADDR_SDIO, 15588c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(0), 0}, 15598c2ecf20Sopenharmony_ci {0x0086, 15608c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 15618c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 15628c2ecf20Sopenharmony_ci RTW_PWR_ADDR_SDIO, 15638c2ecf20Sopenharmony_ci RTW_PWR_CMD_POLLING, BIT(1), BIT(1)}, 15648c2ecf20Sopenharmony_ci {0x004A, 15658c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 15668c2ecf20Sopenharmony_ci RTW_PWR_INTF_USB_MSK, 15678c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 15688c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(0), 0}, 15698c2ecf20Sopenharmony_ci {0x0005, 15708c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 15718c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 15728c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 15738c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(3) | BIT(4) | BIT(7), 0}, 15748c2ecf20Sopenharmony_ci {0x0300, 15758c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 15768c2ecf20Sopenharmony_ci RTW_PWR_INTF_PCI_MSK, 15778c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 15788c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, 0xFF, 0}, 15798c2ecf20Sopenharmony_ci {0x0301, 15808c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 15818c2ecf20Sopenharmony_ci RTW_PWR_INTF_PCI_MSK, 15828c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 15838c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, 0xFF, 0}, 15848c2ecf20Sopenharmony_ci {0xFFFF, 15858c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 15868c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 15878c2ecf20Sopenharmony_ci 0, 15888c2ecf20Sopenharmony_ci RTW_PWR_CMD_END, 0, 0}, 15898c2ecf20Sopenharmony_ci}; 15908c2ecf20Sopenharmony_ci 15918c2ecf20Sopenharmony_cistatic const struct rtw_pwr_seq_cmd trans_cardemu_to_act_8822b[] = { 15928c2ecf20Sopenharmony_ci {0x0012, 15938c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 15948c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 15958c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 15968c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(1), 0}, 15978c2ecf20Sopenharmony_ci {0x0012, 15988c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 15998c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 16008c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16018c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(0), BIT(0)}, 16028c2ecf20Sopenharmony_ci {0x0020, 16038c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 16048c2ecf20Sopenharmony_ci RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK, 16058c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16068c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(0), BIT(0)}, 16078c2ecf20Sopenharmony_ci {0x0001, 16088c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 16098c2ecf20Sopenharmony_ci RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK, 16108c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16118c2ecf20Sopenharmony_ci RTW_PWR_CMD_DELAY, 1, RTW_PWR_DELAY_MS}, 16128c2ecf20Sopenharmony_ci {0x0000, 16138c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 16148c2ecf20Sopenharmony_ci RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK, 16158c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16168c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(5), 0}, 16178c2ecf20Sopenharmony_ci {0x0005, 16188c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 16198c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 16208c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16218c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, (BIT(4) | BIT(3) | BIT(2)), 0}, 16228c2ecf20Sopenharmony_ci {0x0075, 16238c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 16248c2ecf20Sopenharmony_ci RTW_PWR_INTF_PCI_MSK, 16258c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16268c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(0), BIT(0)}, 16278c2ecf20Sopenharmony_ci {0x0006, 16288c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 16298c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 16308c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16318c2ecf20Sopenharmony_ci RTW_PWR_CMD_POLLING, BIT(1), BIT(1)}, 16328c2ecf20Sopenharmony_ci {0x0075, 16338c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 16348c2ecf20Sopenharmony_ci RTW_PWR_INTF_PCI_MSK, 16358c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16368c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(0), 0}, 16378c2ecf20Sopenharmony_ci {0xFF1A, 16388c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 16398c2ecf20Sopenharmony_ci RTW_PWR_INTF_USB_MSK, 16408c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16418c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, 0xFF, 0}, 16428c2ecf20Sopenharmony_ci {0x0006, 16438c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 16448c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 16458c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16468c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(0), BIT(0)}, 16478c2ecf20Sopenharmony_ci {0x0005, 16488c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 16498c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 16508c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16518c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(7), 0}, 16528c2ecf20Sopenharmony_ci {0x0005, 16538c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 16548c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 16558c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16568c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, (BIT(4) | BIT(3)), 0}, 16578c2ecf20Sopenharmony_ci {0x10C3, 16588c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 16598c2ecf20Sopenharmony_ci RTW_PWR_INTF_USB_MSK, 16608c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16618c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(0), BIT(0)}, 16628c2ecf20Sopenharmony_ci {0x0005, 16638c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 16648c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 16658c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16668c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(0), BIT(0)}, 16678c2ecf20Sopenharmony_ci {0x0005, 16688c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 16698c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 16708c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16718c2ecf20Sopenharmony_ci RTW_PWR_CMD_POLLING, BIT(0), 0}, 16728c2ecf20Sopenharmony_ci {0x0020, 16738c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 16748c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 16758c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16768c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(3), BIT(3)}, 16778c2ecf20Sopenharmony_ci {0x10A8, 16788c2ecf20Sopenharmony_ci RTW_PWR_CUT_C_MSK, 16798c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 16808c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16818c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, 0xFF, 0}, 16828c2ecf20Sopenharmony_ci {0x10A9, 16838c2ecf20Sopenharmony_ci RTW_PWR_CUT_C_MSK, 16848c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 16858c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16868c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, 0xFF, 0xef}, 16878c2ecf20Sopenharmony_ci {0x10AA, 16888c2ecf20Sopenharmony_ci RTW_PWR_CUT_C_MSK, 16898c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 16908c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16918c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, 0xFF, 0x0c}, 16928c2ecf20Sopenharmony_ci {0x0068, 16938c2ecf20Sopenharmony_ci RTW_PWR_CUT_C_MSK, 16948c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 16958c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 16968c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(4), BIT(4)}, 16978c2ecf20Sopenharmony_ci {0x0029, 16988c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 16998c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 17008c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 17018c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, 0xFF, 0xF9}, 17028c2ecf20Sopenharmony_ci {0x0024, 17038c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17048c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 17058c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 17068c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(2), 0}, 17078c2ecf20Sopenharmony_ci {0x0074, 17088c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17098c2ecf20Sopenharmony_ci RTW_PWR_INTF_PCI_MSK, 17108c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 17118c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(5), BIT(5)}, 17128c2ecf20Sopenharmony_ci {0x00AF, 17138c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17148c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 17158c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 17168c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(5), BIT(5)}, 17178c2ecf20Sopenharmony_ci {0xFFFF, 17188c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17198c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 17208c2ecf20Sopenharmony_ci 0, 17218c2ecf20Sopenharmony_ci RTW_PWR_CMD_END, 0, 0}, 17228c2ecf20Sopenharmony_ci}; 17238c2ecf20Sopenharmony_ci 17248c2ecf20Sopenharmony_cistatic const struct rtw_pwr_seq_cmd trans_act_to_cardemu_8822b[] = { 17258c2ecf20Sopenharmony_ci {0x0003, 17268c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17278c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 17288c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 17298c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(2), 0}, 17308c2ecf20Sopenharmony_ci {0x0093, 17318c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17328c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 17338c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 17348c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(3), 0}, 17358c2ecf20Sopenharmony_ci {0x001F, 17368c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17378c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 17388c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 17398c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, 0xFF, 0}, 17408c2ecf20Sopenharmony_ci {0x00EF, 17418c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17428c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 17438c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 17448c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, 0xFF, 0}, 17458c2ecf20Sopenharmony_ci {0xFF1A, 17468c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17478c2ecf20Sopenharmony_ci RTW_PWR_INTF_USB_MSK, 17488c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 17498c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, 0xFF, 0x30}, 17508c2ecf20Sopenharmony_ci {0x0049, 17518c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17528c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 17538c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 17548c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(1), 0}, 17558c2ecf20Sopenharmony_ci {0x0006, 17568c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17578c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 17588c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 17598c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(0), BIT(0)}, 17608c2ecf20Sopenharmony_ci {0x0002, 17618c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17628c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 17638c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 17648c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(1), 0}, 17658c2ecf20Sopenharmony_ci {0x10C3, 17668c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17678c2ecf20Sopenharmony_ci RTW_PWR_INTF_USB_MSK, 17688c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 17698c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(0), 0}, 17708c2ecf20Sopenharmony_ci {0x0005, 17718c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17728c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 17738c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 17748c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(1), BIT(1)}, 17758c2ecf20Sopenharmony_ci {0x0005, 17768c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17778c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 17788c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 17798c2ecf20Sopenharmony_ci RTW_PWR_CMD_POLLING, BIT(1), 0}, 17808c2ecf20Sopenharmony_ci {0x0020, 17818c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17828c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 17838c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 17848c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(3), 0}, 17858c2ecf20Sopenharmony_ci {0x0000, 17868c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17878c2ecf20Sopenharmony_ci RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK, 17888c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 17898c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(5), BIT(5)}, 17908c2ecf20Sopenharmony_ci {0xFFFF, 17918c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 17928c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 17938c2ecf20Sopenharmony_ci 0, 17948c2ecf20Sopenharmony_ci RTW_PWR_CMD_END, 0, 0}, 17958c2ecf20Sopenharmony_ci}; 17968c2ecf20Sopenharmony_ci 17978c2ecf20Sopenharmony_cistatic const struct rtw_pwr_seq_cmd trans_cardemu_to_carddis_8822b[] = { 17988c2ecf20Sopenharmony_ci {0x0005, 17998c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18008c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 18018c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 18028c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(7), BIT(7)}, 18038c2ecf20Sopenharmony_ci {0x0007, 18048c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18058c2ecf20Sopenharmony_ci RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK, 18068c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 18078c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, 0xFF, 0x20}, 18088c2ecf20Sopenharmony_ci {0x0067, 18098c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18108c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 18118c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 18128c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(5), 0}, 18138c2ecf20Sopenharmony_ci {0x0005, 18148c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18158c2ecf20Sopenharmony_ci RTW_PWR_INTF_PCI_MSK, 18168c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 18178c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(2), BIT(2)}, 18188c2ecf20Sopenharmony_ci {0x004A, 18198c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18208c2ecf20Sopenharmony_ci RTW_PWR_INTF_USB_MSK, 18218c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 18228c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(0), 0}, 18238c2ecf20Sopenharmony_ci {0x0067, 18248c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18258c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 18268c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 18278c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(5), 0}, 18288c2ecf20Sopenharmony_ci {0x0067, 18298c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18308c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 18318c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 18328c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(4), 0}, 18338c2ecf20Sopenharmony_ci {0x004F, 18348c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18358c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 18368c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 18378c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(0), 0}, 18388c2ecf20Sopenharmony_ci {0x0067, 18398c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18408c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 18418c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 18428c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(1), 0}, 18438c2ecf20Sopenharmony_ci {0x0046, 18448c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18458c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 18468c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 18478c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(6), BIT(6)}, 18488c2ecf20Sopenharmony_ci {0x0067, 18498c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18508c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 18518c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 18528c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(2), 0}, 18538c2ecf20Sopenharmony_ci {0x0046, 18548c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18558c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 18568c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 18578c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(7), BIT(7)}, 18588c2ecf20Sopenharmony_ci {0x0062, 18598c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18608c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 18618c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 18628c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(4), BIT(4)}, 18638c2ecf20Sopenharmony_ci {0x0081, 18648c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18658c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 18668c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 18678c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(7) | BIT(6), 0}, 18688c2ecf20Sopenharmony_ci {0x0005, 18698c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18708c2ecf20Sopenharmony_ci RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_SDIO_MSK, 18718c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 18728c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(3) | BIT(4), BIT(3)}, 18738c2ecf20Sopenharmony_ci {0x0086, 18748c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18758c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 18768c2ecf20Sopenharmony_ci RTW_PWR_ADDR_SDIO, 18778c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(0), BIT(0)}, 18788c2ecf20Sopenharmony_ci {0x0086, 18798c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18808c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 18818c2ecf20Sopenharmony_ci RTW_PWR_ADDR_SDIO, 18828c2ecf20Sopenharmony_ci RTW_PWR_CMD_POLLING, BIT(1), 0}, 18838c2ecf20Sopenharmony_ci {0x0090, 18848c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18858c2ecf20Sopenharmony_ci RTW_PWR_INTF_USB_MSK | RTW_PWR_INTF_PCI_MSK, 18868c2ecf20Sopenharmony_ci RTW_PWR_ADDR_MAC, 18878c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, BIT(1), 0}, 18888c2ecf20Sopenharmony_ci {0x0044, 18898c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18908c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 18918c2ecf20Sopenharmony_ci RTW_PWR_ADDR_SDIO, 18928c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, 0xFF, 0}, 18938c2ecf20Sopenharmony_ci {0x0040, 18948c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 18958c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 18968c2ecf20Sopenharmony_ci RTW_PWR_ADDR_SDIO, 18978c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, 0xFF, 0x90}, 18988c2ecf20Sopenharmony_ci {0x0041, 18998c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 19008c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 19018c2ecf20Sopenharmony_ci RTW_PWR_ADDR_SDIO, 19028c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, 0xFF, 0x00}, 19038c2ecf20Sopenharmony_ci {0x0042, 19048c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 19058c2ecf20Sopenharmony_ci RTW_PWR_INTF_SDIO_MSK, 19068c2ecf20Sopenharmony_ci RTW_PWR_ADDR_SDIO, 19078c2ecf20Sopenharmony_ci RTW_PWR_CMD_WRITE, 0xFF, 0x04}, 19088c2ecf20Sopenharmony_ci {0xFFFF, 19098c2ecf20Sopenharmony_ci RTW_PWR_CUT_ALL_MSK, 19108c2ecf20Sopenharmony_ci RTW_PWR_INTF_ALL_MSK, 19118c2ecf20Sopenharmony_ci 0, 19128c2ecf20Sopenharmony_ci RTW_PWR_CMD_END, 0, 0}, 19138c2ecf20Sopenharmony_ci}; 19148c2ecf20Sopenharmony_ci 19158c2ecf20Sopenharmony_cistatic const struct rtw_pwr_seq_cmd *card_enable_flow_8822b[] = { 19168c2ecf20Sopenharmony_ci trans_carddis_to_cardemu_8822b, 19178c2ecf20Sopenharmony_ci trans_cardemu_to_act_8822b, 19188c2ecf20Sopenharmony_ci NULL 19198c2ecf20Sopenharmony_ci}; 19208c2ecf20Sopenharmony_ci 19218c2ecf20Sopenharmony_cistatic const struct rtw_pwr_seq_cmd *card_disable_flow_8822b[] = { 19228c2ecf20Sopenharmony_ci trans_act_to_cardemu_8822b, 19238c2ecf20Sopenharmony_ci trans_cardemu_to_carddis_8822b, 19248c2ecf20Sopenharmony_ci NULL 19258c2ecf20Sopenharmony_ci}; 19268c2ecf20Sopenharmony_ci 19278c2ecf20Sopenharmony_cistatic const struct rtw_intf_phy_para usb2_param_8822b[] = { 19288c2ecf20Sopenharmony_ci {0xFFFF, 0x00, 19298c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 19308c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_ALL, 19318c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 19328c2ecf20Sopenharmony_ci}; 19338c2ecf20Sopenharmony_ci 19348c2ecf20Sopenharmony_cistatic const struct rtw_intf_phy_para usb3_param_8822b[] = { 19358c2ecf20Sopenharmony_ci {0x0001, 0xA841, 19368c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 19378c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_D, 19388c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 19398c2ecf20Sopenharmony_ci {0xFFFF, 0x0000, 19408c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 19418c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_ALL, 19428c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 19438c2ecf20Sopenharmony_ci}; 19448c2ecf20Sopenharmony_ci 19458c2ecf20Sopenharmony_cistatic const struct rtw_intf_phy_para pcie_gen1_param_8822b[] = { 19468c2ecf20Sopenharmony_ci {0x0001, 0xA841, 19478c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 19488c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 19498c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 19508c2ecf20Sopenharmony_ci {0x0002, 0x60C6, 19518c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 19528c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 19538c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 19548c2ecf20Sopenharmony_ci {0x0008, 0x3596, 19558c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 19568c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 19578c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 19588c2ecf20Sopenharmony_ci {0x0009, 0x321C, 19598c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 19608c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 19618c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 19628c2ecf20Sopenharmony_ci {0x000A, 0x9623, 19638c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 19648c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 19658c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 19668c2ecf20Sopenharmony_ci {0x0020, 0x94FF, 19678c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 19688c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 19698c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 19708c2ecf20Sopenharmony_ci {0x0021, 0xFFCF, 19718c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 19728c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 19738c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 19748c2ecf20Sopenharmony_ci {0x0026, 0xC006, 19758c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 19768c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 19778c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 19788c2ecf20Sopenharmony_ci {0x0029, 0xFF0E, 19798c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 19808c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 19818c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 19828c2ecf20Sopenharmony_ci {0x002A, 0x1840, 19838c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 19848c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 19858c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 19868c2ecf20Sopenharmony_ci {0xFFFF, 0x0000, 19878c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 19888c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_ALL, 19898c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 19908c2ecf20Sopenharmony_ci}; 19918c2ecf20Sopenharmony_ci 19928c2ecf20Sopenharmony_cistatic const struct rtw_intf_phy_para pcie_gen2_param_8822b[] = { 19938c2ecf20Sopenharmony_ci {0x0001, 0xA841, 19948c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 19958c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 19968c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 19978c2ecf20Sopenharmony_ci {0x0002, 0x60C6, 19988c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 19998c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 20008c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 20018c2ecf20Sopenharmony_ci {0x0008, 0x3597, 20028c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 20038c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 20048c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 20058c2ecf20Sopenharmony_ci {0x0009, 0x321C, 20068c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 20078c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 20088c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 20098c2ecf20Sopenharmony_ci {0x000A, 0x9623, 20108c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 20118c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 20128c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 20138c2ecf20Sopenharmony_ci {0x0020, 0x94FF, 20148c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 20158c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 20168c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 20178c2ecf20Sopenharmony_ci {0x0021, 0xFFCF, 20188c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 20198c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 20208c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 20218c2ecf20Sopenharmony_ci {0x0026, 0xC006, 20228c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 20238c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 20248c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 20258c2ecf20Sopenharmony_ci {0x0029, 0xFF0E, 20268c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 20278c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 20288c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 20298c2ecf20Sopenharmony_ci {0x002A, 0x3040, 20308c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 20318c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_C, 20328c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 20338c2ecf20Sopenharmony_ci {0xFFFF, 0x0000, 20348c2ecf20Sopenharmony_ci RTW_IP_SEL_PHY, 20358c2ecf20Sopenharmony_ci RTW_INTF_PHY_CUT_ALL, 20368c2ecf20Sopenharmony_ci RTW_INTF_PHY_PLATFORM_ALL}, 20378c2ecf20Sopenharmony_ci}; 20388c2ecf20Sopenharmony_ci 20398c2ecf20Sopenharmony_cistatic const struct rtw_intf_phy_para_table phy_para_table_8822b = { 20408c2ecf20Sopenharmony_ci .usb2_para = usb2_param_8822b, 20418c2ecf20Sopenharmony_ci .usb3_para = usb3_param_8822b, 20428c2ecf20Sopenharmony_ci .gen1_para = pcie_gen1_param_8822b, 20438c2ecf20Sopenharmony_ci .gen2_para = pcie_gen2_param_8822b, 20448c2ecf20Sopenharmony_ci .n_usb2_para = ARRAY_SIZE(usb2_param_8822b), 20458c2ecf20Sopenharmony_ci .n_usb3_para = ARRAY_SIZE(usb2_param_8822b), 20468c2ecf20Sopenharmony_ci .n_gen1_para = ARRAY_SIZE(pcie_gen1_param_8822b), 20478c2ecf20Sopenharmony_ci .n_gen2_para = ARRAY_SIZE(pcie_gen2_param_8822b), 20488c2ecf20Sopenharmony_ci}; 20498c2ecf20Sopenharmony_ci 20508c2ecf20Sopenharmony_cistatic const struct rtw_rfe_def rtw8822b_rfe_defs[] = { 20518c2ecf20Sopenharmony_ci [2] = RTW_DEF_RFE(8822b, 2, 2), 20528c2ecf20Sopenharmony_ci [3] = RTW_DEF_RFE(8822b, 3, 0), 20538c2ecf20Sopenharmony_ci [5] = RTW_DEF_RFE(8822b, 5, 5), 20548c2ecf20Sopenharmony_ci}; 20558c2ecf20Sopenharmony_ci 20568c2ecf20Sopenharmony_cistatic const struct rtw_hw_reg rtw8822b_dig[] = { 20578c2ecf20Sopenharmony_ci [0] = { .addr = 0xc50, .mask = 0x7f }, 20588c2ecf20Sopenharmony_ci [1] = { .addr = 0xe50, .mask = 0x7f }, 20598c2ecf20Sopenharmony_ci}; 20608c2ecf20Sopenharmony_ci 20618c2ecf20Sopenharmony_cistatic const struct rtw_ltecoex_addr rtw8822b_ltecoex_addr = { 20628c2ecf20Sopenharmony_ci .ctrl = LTECOEX_ACCESS_CTRL, 20638c2ecf20Sopenharmony_ci .wdata = LTECOEX_WRITE_DATA, 20648c2ecf20Sopenharmony_ci .rdata = LTECOEX_READ_DATA, 20658c2ecf20Sopenharmony_ci}; 20668c2ecf20Sopenharmony_ci 20678c2ecf20Sopenharmony_cistatic const struct rtw_page_table page_table_8822b[] = { 20688c2ecf20Sopenharmony_ci {64, 64, 64, 64, 1}, 20698c2ecf20Sopenharmony_ci {64, 64, 64, 64, 1}, 20708c2ecf20Sopenharmony_ci {64, 64, 0, 0, 1}, 20718c2ecf20Sopenharmony_ci {64, 64, 64, 0, 1}, 20728c2ecf20Sopenharmony_ci {64, 64, 64, 64, 1}, 20738c2ecf20Sopenharmony_ci}; 20748c2ecf20Sopenharmony_ci 20758c2ecf20Sopenharmony_cistatic const struct rtw_rqpn rqpn_table_8822b[] = { 20768c2ecf20Sopenharmony_ci {RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_NORMAL, 20778c2ecf20Sopenharmony_ci RTW_DMA_MAPPING_LOW, RTW_DMA_MAPPING_LOW, 20788c2ecf20Sopenharmony_ci RTW_DMA_MAPPING_EXTRA, RTW_DMA_MAPPING_HIGH}, 20798c2ecf20Sopenharmony_ci {RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_NORMAL, 20808c2ecf20Sopenharmony_ci RTW_DMA_MAPPING_LOW, RTW_DMA_MAPPING_LOW, 20818c2ecf20Sopenharmony_ci RTW_DMA_MAPPING_EXTRA, RTW_DMA_MAPPING_HIGH}, 20828c2ecf20Sopenharmony_ci {RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_NORMAL, 20838c2ecf20Sopenharmony_ci RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_HIGH, 20848c2ecf20Sopenharmony_ci RTW_DMA_MAPPING_HIGH, RTW_DMA_MAPPING_HIGH}, 20858c2ecf20Sopenharmony_ci {RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_NORMAL, 20868c2ecf20Sopenharmony_ci RTW_DMA_MAPPING_LOW, RTW_DMA_MAPPING_LOW, 20878c2ecf20Sopenharmony_ci RTW_DMA_MAPPING_HIGH, RTW_DMA_MAPPING_HIGH}, 20888c2ecf20Sopenharmony_ci {RTW_DMA_MAPPING_NORMAL, RTW_DMA_MAPPING_NORMAL, 20898c2ecf20Sopenharmony_ci RTW_DMA_MAPPING_LOW, RTW_DMA_MAPPING_LOW, 20908c2ecf20Sopenharmony_ci RTW_DMA_MAPPING_EXTRA, RTW_DMA_MAPPING_HIGH}, 20918c2ecf20Sopenharmony_ci}; 20928c2ecf20Sopenharmony_ci 20938c2ecf20Sopenharmony_cistatic struct rtw_prioq_addrs prioq_addrs_8822b = { 20948c2ecf20Sopenharmony_ci .prio[RTW_DMA_MAPPING_EXTRA] = { 20958c2ecf20Sopenharmony_ci .rsvd = REG_FIFOPAGE_INFO_4, .avail = REG_FIFOPAGE_INFO_4 + 2, 20968c2ecf20Sopenharmony_ci }, 20978c2ecf20Sopenharmony_ci .prio[RTW_DMA_MAPPING_LOW] = { 20988c2ecf20Sopenharmony_ci .rsvd = REG_FIFOPAGE_INFO_2, .avail = REG_FIFOPAGE_INFO_2 + 2, 20998c2ecf20Sopenharmony_ci }, 21008c2ecf20Sopenharmony_ci .prio[RTW_DMA_MAPPING_NORMAL] = { 21018c2ecf20Sopenharmony_ci .rsvd = REG_FIFOPAGE_INFO_3, .avail = REG_FIFOPAGE_INFO_3 + 2, 21028c2ecf20Sopenharmony_ci }, 21038c2ecf20Sopenharmony_ci .prio[RTW_DMA_MAPPING_HIGH] = { 21048c2ecf20Sopenharmony_ci .rsvd = REG_FIFOPAGE_INFO_1, .avail = REG_FIFOPAGE_INFO_1 + 2, 21058c2ecf20Sopenharmony_ci }, 21068c2ecf20Sopenharmony_ci .wsize = true, 21078c2ecf20Sopenharmony_ci}; 21088c2ecf20Sopenharmony_ci 21098c2ecf20Sopenharmony_cistatic struct rtw_chip_ops rtw8822b_ops = { 21108c2ecf20Sopenharmony_ci .phy_set_param = rtw8822b_phy_set_param, 21118c2ecf20Sopenharmony_ci .read_efuse = rtw8822b_read_efuse, 21128c2ecf20Sopenharmony_ci .query_rx_desc = rtw8822b_query_rx_desc, 21138c2ecf20Sopenharmony_ci .set_channel = rtw8822b_set_channel, 21148c2ecf20Sopenharmony_ci .mac_init = rtw8822b_mac_init, 21158c2ecf20Sopenharmony_ci .read_rf = rtw_phy_read_rf, 21168c2ecf20Sopenharmony_ci .write_rf = rtw_phy_write_rf_reg_sipi, 21178c2ecf20Sopenharmony_ci .set_tx_power_index = rtw8822b_set_tx_power_index, 21188c2ecf20Sopenharmony_ci .set_antenna = rtw8822b_set_antenna, 21198c2ecf20Sopenharmony_ci .cfg_ldo25 = rtw8822b_cfg_ldo25, 21208c2ecf20Sopenharmony_ci .false_alarm_statistics = rtw8822b_false_alarm_statistics, 21218c2ecf20Sopenharmony_ci .phy_calibration = rtw8822b_phy_calibration, 21228c2ecf20Sopenharmony_ci .pwr_track = rtw8822b_pwr_track, 21238c2ecf20Sopenharmony_ci .config_bfee = rtw8822b_bf_config_bfee, 21248c2ecf20Sopenharmony_ci .set_gid_table = rtw_bf_set_gid_table, 21258c2ecf20Sopenharmony_ci .cfg_csi_rate = rtw_bf_cfg_csi_rate, 21268c2ecf20Sopenharmony_ci 21278c2ecf20Sopenharmony_ci .coex_set_init = rtw8822b_coex_cfg_init, 21288c2ecf20Sopenharmony_ci .coex_set_ant_switch = rtw8822b_coex_cfg_ant_switch, 21298c2ecf20Sopenharmony_ci .coex_set_gnt_fix = rtw8822b_coex_cfg_gnt_fix, 21308c2ecf20Sopenharmony_ci .coex_set_gnt_debug = rtw8822b_coex_cfg_gnt_debug, 21318c2ecf20Sopenharmony_ci .coex_set_rfe_type = rtw8822b_coex_cfg_rfe_type, 21328c2ecf20Sopenharmony_ci .coex_set_wl_tx_power = rtw8822b_coex_cfg_wl_tx_power, 21338c2ecf20Sopenharmony_ci .coex_set_wl_rx_gain = rtw8822b_coex_cfg_wl_rx_gain, 21348c2ecf20Sopenharmony_ci}; 21358c2ecf20Sopenharmony_ci 21368c2ecf20Sopenharmony_ci/* Shared-Antenna Coex Table */ 21378c2ecf20Sopenharmony_cistatic const struct coex_table_para table_sant_8822b[] = { 21388c2ecf20Sopenharmony_ci {0xffffffff, 0xffffffff}, /* case-0 */ 21398c2ecf20Sopenharmony_ci {0x55555555, 0x55555555}, 21408c2ecf20Sopenharmony_ci {0x66555555, 0x66555555}, 21418c2ecf20Sopenharmony_ci {0xaaaaaaaa, 0xaaaaaaaa}, 21428c2ecf20Sopenharmony_ci {0x5a5a5a5a, 0x5a5a5a5a}, 21438c2ecf20Sopenharmony_ci {0xfafafafa, 0xfafafafa}, /* case-5 */ 21448c2ecf20Sopenharmony_ci {0x6a5a6a5a, 0xaaaaaaaa}, 21458c2ecf20Sopenharmony_ci {0x6a5a56aa, 0x6a5a56aa}, 21468c2ecf20Sopenharmony_ci {0x6a5a5a5a, 0x6a5a5a5a}, 21478c2ecf20Sopenharmony_ci {0x66555555, 0x5a5a5a5a}, 21488c2ecf20Sopenharmony_ci {0x66555555, 0x6a5a5a5a}, /* case-10 */ 21498c2ecf20Sopenharmony_ci {0x66555555, 0xfafafafa}, 21508c2ecf20Sopenharmony_ci {0x66555555, 0x5a5a5aaa}, 21518c2ecf20Sopenharmony_ci {0x66555555, 0x5aaa5aaa}, 21528c2ecf20Sopenharmony_ci {0x66555555, 0xaaaa5aaa}, 21538c2ecf20Sopenharmony_ci {0x66555555, 0xaaaaaaaa}, /* case-15 */ 21548c2ecf20Sopenharmony_ci {0xffff55ff, 0xfafafafa}, 21558c2ecf20Sopenharmony_ci {0xffff55ff, 0x6afa5afa}, 21568c2ecf20Sopenharmony_ci {0xaaffffaa, 0xfafafafa}, 21578c2ecf20Sopenharmony_ci {0xaa5555aa, 0x5a5a5a5a}, 21588c2ecf20Sopenharmony_ci {0xaa5555aa, 0x6a5a5a5a}, /* case-20 */ 21598c2ecf20Sopenharmony_ci {0xaa5555aa, 0xaaaaaaaa}, 21608c2ecf20Sopenharmony_ci {0xffffffff, 0x5a5a5a5a}, 21618c2ecf20Sopenharmony_ci {0xffffffff, 0x6a5a5a5a}, 21628c2ecf20Sopenharmony_ci {0xffffffff, 0x55555555}, 21638c2ecf20Sopenharmony_ci {0xffffffff, 0x6a5a5aaa}, /* case-25 */ 21648c2ecf20Sopenharmony_ci {0x55555555, 0x5a5a5a5a}, 21658c2ecf20Sopenharmony_ci {0x55555555, 0xaaaaaaaa}, 21668c2ecf20Sopenharmony_ci {0x55555555, 0x6a5a6a5a}, 21678c2ecf20Sopenharmony_ci {0x66556655, 0x66556655} 21688c2ecf20Sopenharmony_ci}; 21698c2ecf20Sopenharmony_ci 21708c2ecf20Sopenharmony_ci/* Non-Shared-Antenna Coex Table */ 21718c2ecf20Sopenharmony_cistatic const struct coex_table_para table_nsant_8822b[] = { 21728c2ecf20Sopenharmony_ci {0xffffffff, 0xffffffff}, /* case-100 */ 21738c2ecf20Sopenharmony_ci {0x55555555, 0x55555555}, 21748c2ecf20Sopenharmony_ci {0x66555555, 0x66555555}, 21758c2ecf20Sopenharmony_ci {0xaaaaaaaa, 0xaaaaaaaa}, 21768c2ecf20Sopenharmony_ci {0x5a5a5a5a, 0x5a5a5a5a}, 21778c2ecf20Sopenharmony_ci {0xfafafafa, 0xfafafafa}, /* case-105 */ 21788c2ecf20Sopenharmony_ci {0x5afa5afa, 0x5afa5afa}, 21798c2ecf20Sopenharmony_ci {0x55555555, 0xfafafafa}, 21808c2ecf20Sopenharmony_ci {0x66555555, 0xfafafafa}, 21818c2ecf20Sopenharmony_ci {0x66555555, 0x5a5a5a5a}, 21828c2ecf20Sopenharmony_ci {0x66555555, 0x6a5a5a5a}, /* case-110 */ 21838c2ecf20Sopenharmony_ci {0x66555555, 0xaaaaaaaa}, 21848c2ecf20Sopenharmony_ci {0xffff55ff, 0xfafafafa}, 21858c2ecf20Sopenharmony_ci {0xffff55ff, 0x5afa5afa}, 21868c2ecf20Sopenharmony_ci {0xffff55ff, 0xaaaaaaaa}, 21878c2ecf20Sopenharmony_ci {0xaaffffaa, 0xfafafafa}, /* case-115 */ 21888c2ecf20Sopenharmony_ci {0xaaffffaa, 0x5afa5afa}, 21898c2ecf20Sopenharmony_ci {0xaaffffaa, 0xaaaaaaaa}, 21908c2ecf20Sopenharmony_ci {0xffffffff, 0xfafafafa}, 21918c2ecf20Sopenharmony_ci {0xffffffff, 0x5afa5afa}, 21928c2ecf20Sopenharmony_ci {0xffffffff, 0xaaaaaaaa}, /* case-120 */ 21938c2ecf20Sopenharmony_ci {0x55ff55ff, 0x5afa5afa}, 21948c2ecf20Sopenharmony_ci {0x55ff55ff, 0xaaaaaaaa}, 21958c2ecf20Sopenharmony_ci {0x55ff55ff, 0x55ff55ff} 21968c2ecf20Sopenharmony_ci}; 21978c2ecf20Sopenharmony_ci 21988c2ecf20Sopenharmony_ci/* Shared-Antenna TDMA */ 21998c2ecf20Sopenharmony_cistatic const struct coex_tdma_para tdma_sant_8822b[] = { 22008c2ecf20Sopenharmony_ci { {0x00, 0x00, 0x00, 0x00, 0x00} }, /* case-0 */ 22018c2ecf20Sopenharmony_ci { {0x61, 0x45, 0x03, 0x11, 0x11} }, 22028c2ecf20Sopenharmony_ci { {0x61, 0x3a, 0x03, 0x11, 0x11} }, 22038c2ecf20Sopenharmony_ci { {0x61, 0x30, 0x03, 0x11, 0x11} }, 22048c2ecf20Sopenharmony_ci { {0x61, 0x20, 0x03, 0x11, 0x11} }, 22058c2ecf20Sopenharmony_ci { {0x61, 0x10, 0x03, 0x11, 0x11} }, /* case-5 */ 22068c2ecf20Sopenharmony_ci { {0x61, 0x45, 0x03, 0x11, 0x10} }, 22078c2ecf20Sopenharmony_ci { {0x61, 0x3a, 0x03, 0x11, 0x10} }, 22088c2ecf20Sopenharmony_ci { {0x61, 0x30, 0x03, 0x11, 0x10} }, 22098c2ecf20Sopenharmony_ci { {0x61, 0x20, 0x03, 0x11, 0x10} }, 22108c2ecf20Sopenharmony_ci { {0x61, 0x10, 0x03, 0x11, 0x10} }, /* case-10 */ 22118c2ecf20Sopenharmony_ci { {0x61, 0x08, 0x03, 0x11, 0x14} }, 22128c2ecf20Sopenharmony_ci { {0x61, 0x08, 0x03, 0x10, 0x14} }, 22138c2ecf20Sopenharmony_ci { {0x51, 0x08, 0x03, 0x10, 0x54} }, 22148c2ecf20Sopenharmony_ci { {0x51, 0x08, 0x03, 0x10, 0x55} }, 22158c2ecf20Sopenharmony_ci { {0x51, 0x08, 0x07, 0x10, 0x54} }, /* case-15 */ 22168c2ecf20Sopenharmony_ci { {0x51, 0x45, 0x03, 0x10, 0x10} }, 22178c2ecf20Sopenharmony_ci { {0x51, 0x3a, 0x03, 0x10, 0x50} }, 22188c2ecf20Sopenharmony_ci { {0x51, 0x30, 0x03, 0x10, 0x50} }, 22198c2ecf20Sopenharmony_ci { {0x51, 0x20, 0x03, 0x10, 0x50} }, 22208c2ecf20Sopenharmony_ci { {0x51, 0x10, 0x03, 0x10, 0x50} }, /* case-20 */ 22218c2ecf20Sopenharmony_ci { {0x51, 0x4a, 0x03, 0x10, 0x50} }, 22228c2ecf20Sopenharmony_ci { {0x51, 0x0c, 0x03, 0x10, 0x54} }, 22238c2ecf20Sopenharmony_ci { {0x55, 0x08, 0x03, 0x10, 0x54} }, 22248c2ecf20Sopenharmony_ci { {0x65, 0x10, 0x03, 0x11, 0x11} }, 22258c2ecf20Sopenharmony_ci { {0x51, 0x10, 0x03, 0x10, 0x51} }, /* case-25 */ 22268c2ecf20Sopenharmony_ci { {0x51, 0x08, 0x03, 0x10, 0x50} }, 22278c2ecf20Sopenharmony_ci { {0x61, 0x08, 0x03, 0x11, 0x11} } 22288c2ecf20Sopenharmony_ci}; 22298c2ecf20Sopenharmony_ci 22308c2ecf20Sopenharmony_ci/* Non-Shared-Antenna TDMA */ 22318c2ecf20Sopenharmony_cistatic const struct coex_tdma_para tdma_nsant_8822b[] = { 22328c2ecf20Sopenharmony_ci { {0x00, 0x00, 0x00, 0x00, 0x00} }, /* case-100 */ 22338c2ecf20Sopenharmony_ci { {0x61, 0x45, 0x03, 0x11, 0x11} }, 22348c2ecf20Sopenharmony_ci { {0x61, 0x3a, 0x03, 0x11, 0x11} }, 22358c2ecf20Sopenharmony_ci { {0x61, 0x30, 0x03, 0x11, 0x11} }, 22368c2ecf20Sopenharmony_ci { {0x61, 0x20, 0x03, 0x11, 0x11} }, 22378c2ecf20Sopenharmony_ci { {0x61, 0x10, 0x03, 0x11, 0x11} }, /* case-105 */ 22388c2ecf20Sopenharmony_ci { {0x61, 0x45, 0x03, 0x11, 0x10} }, 22398c2ecf20Sopenharmony_ci { {0x61, 0x3a, 0x03, 0x11, 0x10} }, 22408c2ecf20Sopenharmony_ci { {0x61, 0x30, 0x03, 0x11, 0x10} }, 22418c2ecf20Sopenharmony_ci { {0x61, 0x20, 0x03, 0x11, 0x10} }, 22428c2ecf20Sopenharmony_ci { {0x61, 0x10, 0x03, 0x11, 0x10} }, /* case-110 */ 22438c2ecf20Sopenharmony_ci { {0x61, 0x08, 0x03, 0x11, 0x14} }, 22448c2ecf20Sopenharmony_ci { {0x61, 0x08, 0x03, 0x10, 0x14} }, 22458c2ecf20Sopenharmony_ci { {0x51, 0x08, 0x03, 0x10, 0x54} }, 22468c2ecf20Sopenharmony_ci { {0x51, 0x08, 0x03, 0x10, 0x55} }, 22478c2ecf20Sopenharmony_ci { {0x51, 0x08, 0x07, 0x10, 0x54} }, /* case-115 */ 22488c2ecf20Sopenharmony_ci { {0x51, 0x45, 0x03, 0x10, 0x50} }, 22498c2ecf20Sopenharmony_ci { {0x51, 0x3a, 0x03, 0x10, 0x50} }, 22508c2ecf20Sopenharmony_ci { {0x51, 0x30, 0x03, 0x10, 0x50} }, 22518c2ecf20Sopenharmony_ci { {0x51, 0x20, 0x03, 0x10, 0x50} }, 22528c2ecf20Sopenharmony_ci { {0x51, 0x10, 0x03, 0x10, 0x50} } /* case-120 */ 22538c2ecf20Sopenharmony_ci}; 22548c2ecf20Sopenharmony_ci 22558c2ecf20Sopenharmony_ci/* rssi in percentage % (dbm = % - 100) */ 22568c2ecf20Sopenharmony_cistatic const u8 wl_rssi_step_8822b[] = {60, 50, 44, 30}; 22578c2ecf20Sopenharmony_cistatic const u8 bt_rssi_step_8822b[] = {30, 30, 30, 30}; 22588c2ecf20Sopenharmony_cistatic const struct coex_5g_afh_map afh_5g_8822b[] = { {0, 0, 0} }; 22598c2ecf20Sopenharmony_ci 22608c2ecf20Sopenharmony_ci/* wl_tx_dec_power, bt_tx_dec_power, wl_rx_gain, bt_rx_lna_constrain */ 22618c2ecf20Sopenharmony_cistatic const struct coex_rf_para rf_para_tx_8822b[] = { 22628c2ecf20Sopenharmony_ci {0, 0, false, 7}, /* for normal */ 22638c2ecf20Sopenharmony_ci {0, 16, false, 7}, /* for WL-CPT */ 22648c2ecf20Sopenharmony_ci {4, 0, true, 1}, 22658c2ecf20Sopenharmony_ci {3, 6, true, 1}, 22668c2ecf20Sopenharmony_ci {2, 9, true, 1}, 22678c2ecf20Sopenharmony_ci {1, 13, true, 1} 22688c2ecf20Sopenharmony_ci}; 22698c2ecf20Sopenharmony_ci 22708c2ecf20Sopenharmony_cistatic const struct coex_rf_para rf_para_rx_8822b[] = { 22718c2ecf20Sopenharmony_ci {0, 0, false, 7}, /* for normal */ 22728c2ecf20Sopenharmony_ci {0, 16, false, 7}, /* for WL-CPT */ 22738c2ecf20Sopenharmony_ci {4, 0, true, 1}, 22748c2ecf20Sopenharmony_ci {3, 6, true, 1}, 22758c2ecf20Sopenharmony_ci {2, 9, true, 1}, 22768c2ecf20Sopenharmony_ci {1, 13, true, 1} 22778c2ecf20Sopenharmony_ci}; 22788c2ecf20Sopenharmony_ci 22798c2ecf20Sopenharmony_cistatic_assert(ARRAY_SIZE(rf_para_tx_8822b) == ARRAY_SIZE(rf_para_rx_8822b)); 22808c2ecf20Sopenharmony_ci 22818c2ecf20Sopenharmony_cistatic const u8 22828c2ecf20Sopenharmony_cirtw8822b_pwrtrk_5gb_n[RTW_PWR_TRK_5G_NUM][RTW_PWR_TRK_TBL_SZ] = { 22838c2ecf20Sopenharmony_ci { 0, 1, 2, 2, 3, 4, 5, 5, 6, 7, 22848c2ecf20Sopenharmony_ci 8, 8, 9, 10, 11, 11, 12, 13, 14, 14, 22858c2ecf20Sopenharmony_ci 15, 16, 17, 17, 18, 19, 20, 20, 21, 22 }, 22868c2ecf20Sopenharmony_ci { 0, 1, 2, 2, 3, 4, 5, 5, 6, 7, 22878c2ecf20Sopenharmony_ci 8, 8, 9, 10, 11, 11, 12, 13, 14, 14, 22888c2ecf20Sopenharmony_ci 15, 16, 17, 17, 18, 19, 20, 20, 21, 22 }, 22898c2ecf20Sopenharmony_ci { 0, 1, 2, 2, 3, 4, 5, 5, 6, 7, 22908c2ecf20Sopenharmony_ci 8, 8, 9, 10, 11, 11, 12, 13, 14, 14, 22918c2ecf20Sopenharmony_ci 15, 16, 17, 17, 18, 19, 20, 20, 21, 22 }, 22928c2ecf20Sopenharmony_ci}; 22938c2ecf20Sopenharmony_ci 22948c2ecf20Sopenharmony_cistatic const u8 22958c2ecf20Sopenharmony_cirtw8822b_pwrtrk_5gb_p[RTW_PWR_TRK_5G_NUM][RTW_PWR_TRK_TBL_SZ] = { 22968c2ecf20Sopenharmony_ci { 0, 1, 2, 2, 3, 4, 5, 5, 6, 7, 22978c2ecf20Sopenharmony_ci 8, 9, 9, 10, 11, 12, 13, 14, 14, 15, 22988c2ecf20Sopenharmony_ci 16, 17, 18, 19, 19, 20, 21, 22, 22, 23 }, 22998c2ecf20Sopenharmony_ci { 0, 1, 2, 2, 3, 4, 5, 5, 6, 7, 23008c2ecf20Sopenharmony_ci 8, 9, 9, 10, 11, 12, 13, 14, 14, 15, 23018c2ecf20Sopenharmony_ci 16, 17, 18, 19, 19, 20, 21, 22, 22, 23 }, 23028c2ecf20Sopenharmony_ci { 0, 1, 2, 2, 3, 4, 5, 5, 6, 7, 23038c2ecf20Sopenharmony_ci 8, 9, 9, 10, 11, 12, 13, 14, 14, 15, 23048c2ecf20Sopenharmony_ci 16, 17, 18, 19, 19, 20, 21, 22, 22, 23 }, 23058c2ecf20Sopenharmony_ci}; 23068c2ecf20Sopenharmony_ci 23078c2ecf20Sopenharmony_cistatic const u8 23088c2ecf20Sopenharmony_cirtw8822b_pwrtrk_5ga_n[RTW_PWR_TRK_5G_NUM][RTW_PWR_TRK_TBL_SZ] = { 23098c2ecf20Sopenharmony_ci { 0, 1, 2, 2, 3, 4, 5, 5, 6, 7, 23108c2ecf20Sopenharmony_ci 8, 8, 9, 10, 11, 11, 12, 13, 14, 14, 23118c2ecf20Sopenharmony_ci 15, 16, 17, 17, 18, 19, 20, 20, 21, 22 }, 23128c2ecf20Sopenharmony_ci { 0, 1, 2, 2, 3, 4, 5, 5, 6, 7, 23138c2ecf20Sopenharmony_ci 8, 8, 9, 10, 11, 11, 12, 13, 14, 14, 23148c2ecf20Sopenharmony_ci 15, 16, 17, 17, 18, 19, 20, 20, 21, 22 }, 23158c2ecf20Sopenharmony_ci { 0, 1, 2, 2, 3, 4, 5, 5, 6, 7, 23168c2ecf20Sopenharmony_ci 8, 8, 9, 10, 11, 11, 12, 13, 14, 14, 23178c2ecf20Sopenharmony_ci 15, 16, 17, 17, 18, 19, 20, 20, 21, 22 }, 23188c2ecf20Sopenharmony_ci}; 23198c2ecf20Sopenharmony_ci 23208c2ecf20Sopenharmony_cistatic const u8 23218c2ecf20Sopenharmony_cirtw8822b_pwrtrk_5ga_p[RTW_PWR_TRK_5G_NUM][RTW_PWR_TRK_TBL_SZ] = { 23228c2ecf20Sopenharmony_ci { 0, 1, 2, 2, 3, 4, 5, 5, 6, 7, 23238c2ecf20Sopenharmony_ci 8, 9, 9, 10, 11, 12, 13, 14, 14, 15, 23248c2ecf20Sopenharmony_ci 16, 17, 18, 19, 19, 20, 21, 22, 22, 23}, 23258c2ecf20Sopenharmony_ci { 0, 1, 2, 2, 3, 4, 5, 5, 6, 7, 23268c2ecf20Sopenharmony_ci 8, 9, 9, 10, 11, 12, 13, 14, 14, 15, 23278c2ecf20Sopenharmony_ci 16, 17, 18, 19, 19, 20, 21, 22, 22, 23}, 23288c2ecf20Sopenharmony_ci { 0, 1, 2, 2, 3, 4, 5, 5, 6, 7, 23298c2ecf20Sopenharmony_ci 8, 9, 9, 10, 11, 12, 13, 14, 14, 15, 23308c2ecf20Sopenharmony_ci 16, 17, 18, 19, 19, 20, 21, 22, 22, 23}, 23318c2ecf20Sopenharmony_ci}; 23328c2ecf20Sopenharmony_ci 23338c2ecf20Sopenharmony_cistatic const u8 rtw8822b_pwrtrk_2gb_n[RTW_PWR_TRK_TBL_SZ] = { 23348c2ecf20Sopenharmony_ci 0, 1, 1, 1, 2, 2, 3, 3, 3, 4, 23358c2ecf20Sopenharmony_ci 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 23368c2ecf20Sopenharmony_ci 8, 9, 9, 9, 10, 10, 11, 11, 11, 12 23378c2ecf20Sopenharmony_ci}; 23388c2ecf20Sopenharmony_ci 23398c2ecf20Sopenharmony_cistatic const u8 rtw8822b_pwrtrk_2gb_p[RTW_PWR_TRK_TBL_SZ] = { 23408c2ecf20Sopenharmony_ci 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 23418c2ecf20Sopenharmony_ci 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 23428c2ecf20Sopenharmony_ci 9, 10, 10, 11, 11, 12, 12, 12, 13, 13 23438c2ecf20Sopenharmony_ci}; 23448c2ecf20Sopenharmony_ci 23458c2ecf20Sopenharmony_cistatic const u8 rtw8822b_pwrtrk_2ga_n[RTW_PWR_TRK_TBL_SZ] = { 23468c2ecf20Sopenharmony_ci 0, 1, 1, 1, 2, 2, 3, 3, 3, 4, 23478c2ecf20Sopenharmony_ci 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 23488c2ecf20Sopenharmony_ci 8, 9, 9, 9, 10, 10, 11, 11, 11, 12 23498c2ecf20Sopenharmony_ci}; 23508c2ecf20Sopenharmony_ci 23518c2ecf20Sopenharmony_cistatic const u8 rtw8822b_pwrtrk_2ga_p[RTW_PWR_TRK_TBL_SZ] = { 23528c2ecf20Sopenharmony_ci 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 23538c2ecf20Sopenharmony_ci 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 23548c2ecf20Sopenharmony_ci 10, 11, 11, 12, 12, 13, 13, 14, 14, 15 23558c2ecf20Sopenharmony_ci}; 23568c2ecf20Sopenharmony_ci 23578c2ecf20Sopenharmony_cistatic const u8 rtw8822b_pwrtrk_2g_cck_b_n[RTW_PWR_TRK_TBL_SZ] = { 23588c2ecf20Sopenharmony_ci 0, 1, 1, 1, 2, 2, 3, 3, 3, 4, 23598c2ecf20Sopenharmony_ci 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 23608c2ecf20Sopenharmony_ci 8, 9, 9, 9, 10, 10, 11, 11, 11, 12 23618c2ecf20Sopenharmony_ci}; 23628c2ecf20Sopenharmony_ci 23638c2ecf20Sopenharmony_cistatic const u8 rtw8822b_pwrtrk_2g_cck_b_p[RTW_PWR_TRK_TBL_SZ] = { 23648c2ecf20Sopenharmony_ci 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 23658c2ecf20Sopenharmony_ci 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 23668c2ecf20Sopenharmony_ci 9, 10, 10, 11, 11, 12, 12, 12, 13, 13 23678c2ecf20Sopenharmony_ci}; 23688c2ecf20Sopenharmony_ci 23698c2ecf20Sopenharmony_cistatic const u8 rtw8822b_pwrtrk_2g_cck_a_n[RTW_PWR_TRK_TBL_SZ] = { 23708c2ecf20Sopenharmony_ci 0, 1, 1, 1, 2, 2, 3, 3, 3, 4, 23718c2ecf20Sopenharmony_ci 4, 5, 5, 5, 6, 6, 7, 7, 7, 8, 23728c2ecf20Sopenharmony_ci 8, 9, 9, 9, 10, 10, 11, 11, 11, 12 23738c2ecf20Sopenharmony_ci}; 23748c2ecf20Sopenharmony_ci 23758c2ecf20Sopenharmony_cistatic const u8 rtw8822b_pwrtrk_2g_cck_a_p[RTW_PWR_TRK_TBL_SZ] = { 23768c2ecf20Sopenharmony_ci 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 23778c2ecf20Sopenharmony_ci 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 23788c2ecf20Sopenharmony_ci 10, 11, 11, 12, 12, 13, 13, 14, 14, 15 23798c2ecf20Sopenharmony_ci}; 23808c2ecf20Sopenharmony_ci 23818c2ecf20Sopenharmony_cistatic const struct rtw_pwr_track_tbl rtw8822b_rtw_pwr_track_tbl = { 23828c2ecf20Sopenharmony_ci .pwrtrk_5gb_n[RTW_PWR_TRK_5G_1] = rtw8822b_pwrtrk_5gb_n[RTW_PWR_TRK_5G_1], 23838c2ecf20Sopenharmony_ci .pwrtrk_5gb_n[RTW_PWR_TRK_5G_2] = rtw8822b_pwrtrk_5gb_n[RTW_PWR_TRK_5G_2], 23848c2ecf20Sopenharmony_ci .pwrtrk_5gb_n[RTW_PWR_TRK_5G_3] = rtw8822b_pwrtrk_5gb_n[RTW_PWR_TRK_5G_3], 23858c2ecf20Sopenharmony_ci .pwrtrk_5gb_p[RTW_PWR_TRK_5G_1] = rtw8822b_pwrtrk_5gb_p[RTW_PWR_TRK_5G_1], 23868c2ecf20Sopenharmony_ci .pwrtrk_5gb_p[RTW_PWR_TRK_5G_2] = rtw8822b_pwrtrk_5gb_p[RTW_PWR_TRK_5G_2], 23878c2ecf20Sopenharmony_ci .pwrtrk_5gb_p[RTW_PWR_TRK_5G_3] = rtw8822b_pwrtrk_5gb_p[RTW_PWR_TRK_5G_3], 23888c2ecf20Sopenharmony_ci .pwrtrk_5ga_n[RTW_PWR_TRK_5G_1] = rtw8822b_pwrtrk_5ga_n[RTW_PWR_TRK_5G_1], 23898c2ecf20Sopenharmony_ci .pwrtrk_5ga_n[RTW_PWR_TRK_5G_2] = rtw8822b_pwrtrk_5ga_n[RTW_PWR_TRK_5G_2], 23908c2ecf20Sopenharmony_ci .pwrtrk_5ga_n[RTW_PWR_TRK_5G_3] = rtw8822b_pwrtrk_5ga_n[RTW_PWR_TRK_5G_3], 23918c2ecf20Sopenharmony_ci .pwrtrk_5ga_p[RTW_PWR_TRK_5G_1] = rtw8822b_pwrtrk_5ga_p[RTW_PWR_TRK_5G_1], 23928c2ecf20Sopenharmony_ci .pwrtrk_5ga_p[RTW_PWR_TRK_5G_2] = rtw8822b_pwrtrk_5ga_p[RTW_PWR_TRK_5G_2], 23938c2ecf20Sopenharmony_ci .pwrtrk_5ga_p[RTW_PWR_TRK_5G_3] = rtw8822b_pwrtrk_5ga_p[RTW_PWR_TRK_5G_3], 23948c2ecf20Sopenharmony_ci .pwrtrk_2gb_n = rtw8822b_pwrtrk_2gb_n, 23958c2ecf20Sopenharmony_ci .pwrtrk_2gb_p = rtw8822b_pwrtrk_2gb_p, 23968c2ecf20Sopenharmony_ci .pwrtrk_2ga_n = rtw8822b_pwrtrk_2ga_n, 23978c2ecf20Sopenharmony_ci .pwrtrk_2ga_p = rtw8822b_pwrtrk_2ga_p, 23988c2ecf20Sopenharmony_ci .pwrtrk_2g_cckb_n = rtw8822b_pwrtrk_2g_cck_b_n, 23998c2ecf20Sopenharmony_ci .pwrtrk_2g_cckb_p = rtw8822b_pwrtrk_2g_cck_b_p, 24008c2ecf20Sopenharmony_ci .pwrtrk_2g_ccka_n = rtw8822b_pwrtrk_2g_cck_a_n, 24018c2ecf20Sopenharmony_ci .pwrtrk_2g_ccka_p = rtw8822b_pwrtrk_2g_cck_a_p, 24028c2ecf20Sopenharmony_ci}; 24038c2ecf20Sopenharmony_ci 24048c2ecf20Sopenharmony_cistatic const struct rtw_reg_domain coex_info_hw_regs_8822b[] = { 24058c2ecf20Sopenharmony_ci {0xcb0, MASKDWORD, RTW_REG_DOMAIN_MAC32}, 24068c2ecf20Sopenharmony_ci {0xcb4, MASKDWORD, RTW_REG_DOMAIN_MAC32}, 24078c2ecf20Sopenharmony_ci {0xcba, MASKBYTE0, RTW_REG_DOMAIN_MAC8}, 24088c2ecf20Sopenharmony_ci {0xcbd, MASKBYTE0, RTW_REG_DOMAIN_MAC8}, 24098c2ecf20Sopenharmony_ci {0xc58, MASKBYTE0, RTW_REG_DOMAIN_MAC8}, 24108c2ecf20Sopenharmony_ci {0xcbd, BIT(0), RTW_REG_DOMAIN_MAC8}, 24118c2ecf20Sopenharmony_ci {0, 0, RTW_REG_DOMAIN_NL}, 24128c2ecf20Sopenharmony_ci {0x430, MASKDWORD, RTW_REG_DOMAIN_MAC32}, 24138c2ecf20Sopenharmony_ci {0x434, MASKDWORD, RTW_REG_DOMAIN_MAC32}, 24148c2ecf20Sopenharmony_ci {0x42a, MASKLWORD, RTW_REG_DOMAIN_MAC16}, 24158c2ecf20Sopenharmony_ci {0x426, MASKBYTE0, RTW_REG_DOMAIN_MAC8}, 24168c2ecf20Sopenharmony_ci {0x45e, BIT(3), RTW_REG_DOMAIN_MAC8}, 24178c2ecf20Sopenharmony_ci {0x454, MASKLWORD, RTW_REG_DOMAIN_MAC16}, 24188c2ecf20Sopenharmony_ci {0, 0, RTW_REG_DOMAIN_NL}, 24198c2ecf20Sopenharmony_ci {0x4c, BIT(24) | BIT(23), RTW_REG_DOMAIN_MAC32}, 24208c2ecf20Sopenharmony_ci {0x64, BIT(0), RTW_REG_DOMAIN_MAC8}, 24218c2ecf20Sopenharmony_ci {0x4c6, BIT(4), RTW_REG_DOMAIN_MAC8}, 24228c2ecf20Sopenharmony_ci {0x40, BIT(5), RTW_REG_DOMAIN_MAC8}, 24238c2ecf20Sopenharmony_ci {0x1, RFREG_MASK, RTW_REG_DOMAIN_RF_B}, 24248c2ecf20Sopenharmony_ci {0, 0, RTW_REG_DOMAIN_NL}, 24258c2ecf20Sopenharmony_ci {0x550, MASKDWORD, RTW_REG_DOMAIN_MAC32}, 24268c2ecf20Sopenharmony_ci {0x522, MASKBYTE0, RTW_REG_DOMAIN_MAC8}, 24278c2ecf20Sopenharmony_ci {0x953, BIT(1), RTW_REG_DOMAIN_MAC8}, 24288c2ecf20Sopenharmony_ci {0xc50, MASKBYTE0, RTW_REG_DOMAIN_MAC8}, 24298c2ecf20Sopenharmony_ci}; 24308c2ecf20Sopenharmony_ci 24318c2ecf20Sopenharmony_cistruct rtw_chip_info rtw8822b_hw_spec = { 24328c2ecf20Sopenharmony_ci .ops = &rtw8822b_ops, 24338c2ecf20Sopenharmony_ci .id = RTW_CHIP_TYPE_8822B, 24348c2ecf20Sopenharmony_ci .fw_name = "rtw88/rtw8822b_fw.bin", 24358c2ecf20Sopenharmony_ci .wlan_cpu = RTW_WCPU_11AC, 24368c2ecf20Sopenharmony_ci .tx_pkt_desc_sz = 48, 24378c2ecf20Sopenharmony_ci .tx_buf_desc_sz = 16, 24388c2ecf20Sopenharmony_ci .rx_pkt_desc_sz = 24, 24398c2ecf20Sopenharmony_ci .rx_buf_desc_sz = 8, 24408c2ecf20Sopenharmony_ci .phy_efuse_size = 1024, 24418c2ecf20Sopenharmony_ci .log_efuse_size = 768, 24428c2ecf20Sopenharmony_ci .ptct_efuse_size = 96, 24438c2ecf20Sopenharmony_ci .txff_size = 262144, 24448c2ecf20Sopenharmony_ci .rxff_size = 24576, 24458c2ecf20Sopenharmony_ci .fw_rxff_size = 12288, 24468c2ecf20Sopenharmony_ci .txgi_factor = 1, 24478c2ecf20Sopenharmony_ci .is_pwr_by_rate_dec = true, 24488c2ecf20Sopenharmony_ci .max_power_index = 0x3f, 24498c2ecf20Sopenharmony_ci .csi_buf_pg_num = 0, 24508c2ecf20Sopenharmony_ci .band = RTW_BAND_2G | RTW_BAND_5G, 24518c2ecf20Sopenharmony_ci .page_size = 128, 24528c2ecf20Sopenharmony_ci .dig_min = 0x1c, 24538c2ecf20Sopenharmony_ci .ht_supported = true, 24548c2ecf20Sopenharmony_ci .vht_supported = true, 24558c2ecf20Sopenharmony_ci .lps_deep_mode_supported = BIT(LPS_DEEP_MODE_LCLK), 24568c2ecf20Sopenharmony_ci .sys_func_en = 0xDC, 24578c2ecf20Sopenharmony_ci .pwr_on_seq = card_enable_flow_8822b, 24588c2ecf20Sopenharmony_ci .pwr_off_seq = card_disable_flow_8822b, 24598c2ecf20Sopenharmony_ci .page_table = page_table_8822b, 24608c2ecf20Sopenharmony_ci .rqpn_table = rqpn_table_8822b, 24618c2ecf20Sopenharmony_ci .prioq_addrs = &prioq_addrs_8822b, 24628c2ecf20Sopenharmony_ci .intf_table = &phy_para_table_8822b, 24638c2ecf20Sopenharmony_ci .dig = rtw8822b_dig, 24648c2ecf20Sopenharmony_ci .dig_cck = NULL, 24658c2ecf20Sopenharmony_ci .rf_base_addr = {0x2800, 0x2c00}, 24668c2ecf20Sopenharmony_ci .rf_sipi_addr = {0xc90, 0xe90}, 24678c2ecf20Sopenharmony_ci .ltecoex_addr = &rtw8822b_ltecoex_addr, 24688c2ecf20Sopenharmony_ci .mac_tbl = &rtw8822b_mac_tbl, 24698c2ecf20Sopenharmony_ci .agc_tbl = &rtw8822b_agc_tbl, 24708c2ecf20Sopenharmony_ci .bb_tbl = &rtw8822b_bb_tbl, 24718c2ecf20Sopenharmony_ci .rf_tbl = {&rtw8822b_rf_a_tbl, &rtw8822b_rf_b_tbl}, 24728c2ecf20Sopenharmony_ci .rfe_defs = rtw8822b_rfe_defs, 24738c2ecf20Sopenharmony_ci .rfe_defs_size = ARRAY_SIZE(rtw8822b_rfe_defs), 24748c2ecf20Sopenharmony_ci .pwr_track_tbl = &rtw8822b_rtw_pwr_track_tbl, 24758c2ecf20Sopenharmony_ci .iqk_threshold = 8, 24768c2ecf20Sopenharmony_ci .bfer_su_max_num = 2, 24778c2ecf20Sopenharmony_ci .bfer_mu_max_num = 1, 24788c2ecf20Sopenharmony_ci .rx_ldpc = true, 24798c2ecf20Sopenharmony_ci 24808c2ecf20Sopenharmony_ci .coex_para_ver = 0x20070206, 24818c2ecf20Sopenharmony_ci .bt_desired_ver = 0x6, 24828c2ecf20Sopenharmony_ci .scbd_support = true, 24838c2ecf20Sopenharmony_ci .new_scbd10_def = false, 24848c2ecf20Sopenharmony_ci .pstdma_type = COEX_PSTDMA_FORCE_LPSOFF, 24858c2ecf20Sopenharmony_ci .bt_rssi_type = COEX_BTRSSI_RATIO, 24868c2ecf20Sopenharmony_ci .ant_isolation = 15, 24878c2ecf20Sopenharmony_ci .rssi_tolerance = 2, 24888c2ecf20Sopenharmony_ci .wl_rssi_step = wl_rssi_step_8822b, 24898c2ecf20Sopenharmony_ci .bt_rssi_step = bt_rssi_step_8822b, 24908c2ecf20Sopenharmony_ci .table_sant_num = ARRAY_SIZE(table_sant_8822b), 24918c2ecf20Sopenharmony_ci .table_sant = table_sant_8822b, 24928c2ecf20Sopenharmony_ci .table_nsant_num = ARRAY_SIZE(table_nsant_8822b), 24938c2ecf20Sopenharmony_ci .table_nsant = table_nsant_8822b, 24948c2ecf20Sopenharmony_ci .tdma_sant_num = ARRAY_SIZE(tdma_sant_8822b), 24958c2ecf20Sopenharmony_ci .tdma_sant = tdma_sant_8822b, 24968c2ecf20Sopenharmony_ci .tdma_nsant_num = ARRAY_SIZE(tdma_nsant_8822b), 24978c2ecf20Sopenharmony_ci .tdma_nsant = tdma_nsant_8822b, 24988c2ecf20Sopenharmony_ci .wl_rf_para_num = ARRAY_SIZE(rf_para_tx_8822b), 24998c2ecf20Sopenharmony_ci .wl_rf_para_tx = rf_para_tx_8822b, 25008c2ecf20Sopenharmony_ci .wl_rf_para_rx = rf_para_rx_8822b, 25018c2ecf20Sopenharmony_ci .bt_afh_span_bw20 = 0x24, 25028c2ecf20Sopenharmony_ci .bt_afh_span_bw40 = 0x36, 25038c2ecf20Sopenharmony_ci .afh_5g_num = ARRAY_SIZE(afh_5g_8822b), 25048c2ecf20Sopenharmony_ci .afh_5g = afh_5g_8822b, 25058c2ecf20Sopenharmony_ci 25068c2ecf20Sopenharmony_ci .coex_info_hw_regs_num = ARRAY_SIZE(coex_info_hw_regs_8822b), 25078c2ecf20Sopenharmony_ci .coex_info_hw_regs = coex_info_hw_regs_8822b, 25088c2ecf20Sopenharmony_ci 25098c2ecf20Sopenharmony_ci .fw_fifo_addr = {0x780, 0x700, 0x780, 0x660, 0x650, 0x680}, 25108c2ecf20Sopenharmony_ci}; 25118c2ecf20Sopenharmony_ciEXPORT_SYMBOL(rtw8822b_hw_spec); 25128c2ecf20Sopenharmony_ci 25138c2ecf20Sopenharmony_ciMODULE_FIRMWARE("rtw88/rtw8822b_fw.bin"); 25148c2ecf20Sopenharmony_ci 25158c2ecf20Sopenharmony_ciMODULE_AUTHOR("Realtek Corporation"); 25168c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Realtek 802.11ac wireless 8822b driver"); 25178c2ecf20Sopenharmony_ciMODULE_LICENSE("Dual BSD/GPL"); 2518