162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* Copyright(c) 2009-2013 Realtek Corporation.*/ 362306a36Sopenharmony_ci 462306a36Sopenharmony_ci#ifndef __RTL92C_PHY_H__ 562306a36Sopenharmony_ci#define __RTL92C_PHY_H__ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci/* MAX_TX_COUNT must always set to 4, otherwise read efuse 862306a36Sopenharmony_ci * table secquence will be wrong. 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci#define MAX_TX_COUNT 4 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#define MAX_PRECMD_CNT 16 1362306a36Sopenharmony_ci#define MAX_RFDEPENDCMD_CNT 16 1462306a36Sopenharmony_ci#define MAX_POSTCMD_CNT 16 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci#define MAX_DOZE_WAITING_TIMES_9x 64 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci#define RT_CANNOT_IO(hw) false 1962306a36Sopenharmony_ci#define HIGHPOWER_RADIOA_ARRAYLEN 22 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci#define IQK_ADDA_REG_NUM 16 2262306a36Sopenharmony_ci#define IQK_BB_REG_NUM 9 2362306a36Sopenharmony_ci#define MAX_TOLERANCE 5 2462306a36Sopenharmony_ci#define IQK_DELAY_TIME 10 2562306a36Sopenharmony_ci#define INDEX_MAPPING_NUM 15 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#define APK_BB_REG_NUM 5 2862306a36Sopenharmony_ci#define APK_AFE_REG_NUM 16 2962306a36Sopenharmony_ci#define APK_CURVE_REG_NUM 4 3062306a36Sopenharmony_ci#define PATH_NUM 2 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci#define LOOP_LIMIT 5 3362306a36Sopenharmony_ci#define MAX_STALL_TIME 50 3462306a36Sopenharmony_ci#define ANTENNADIVERSITYVALUE 0x80 3562306a36Sopenharmony_ci#define MAX_TXPWR_IDX_NMODE_92S 63 3662306a36Sopenharmony_ci#define RESET_CNT_LIMIT 3 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci#define IQK_ADDA_REG_NUM 16 3962306a36Sopenharmony_ci#define IQK_MAC_REG_NUM 4 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci#define RF6052_MAX_PATH 2 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_ci#define CT_OFFSET_MAC_ADDR 0X16 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci#define CT_OFFSET_CCK_TX_PWR_IDX 0x5A 4662306a36Sopenharmony_ci#define CT_OFFSET_HT401S_TX_PWR_IDX 0x60 4762306a36Sopenharmony_ci#define CT_OFFSET_HT402S_TX_PWR_IDX_DIFF 0x66 4862306a36Sopenharmony_ci#define CT_OFFSET_HT20_TX_PWR_IDX_DIFF 0x69 4962306a36Sopenharmony_ci#define CT_OFFSET_OFDM_TX_PWR_IDX_DIFF 0x6C 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci#define CT_OFFSET_HT40_MAX_PWR_OFFSET 0x6F 5262306a36Sopenharmony_ci#define CT_OFFSET_HT20_MAX_PWR_OFFSET 0x72 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci#define CT_OFFSET_CHANNEL_PLAH 0x75 5562306a36Sopenharmony_ci#define CT_OFFSET_THERMAL_METER 0x78 5662306a36Sopenharmony_ci#define CT_OFFSET_RF_OPTION 0x79 5762306a36Sopenharmony_ci#define CT_OFFSET_VERSION 0x7E 5862306a36Sopenharmony_ci#define CT_OFFSET_CUSTOMER_ID 0x7F 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci#define RTL92C_MAX_PATH_NUM 2 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_cienum swchnlcmd_id { 6362306a36Sopenharmony_ci CMDID_END, 6462306a36Sopenharmony_ci CMDID_SET_TXPOWEROWER_LEVEL, 6562306a36Sopenharmony_ci CMDID_BBREGWRITE10, 6662306a36Sopenharmony_ci CMDID_WRITEPORT_ULONG, 6762306a36Sopenharmony_ci CMDID_WRITEPORT_USHORT, 6862306a36Sopenharmony_ci CMDID_WRITEPORT_UCHAR, 6962306a36Sopenharmony_ci CMDID_RF_WRITEREG, 7062306a36Sopenharmony_ci}; 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_cistruct swchnlcmd { 7362306a36Sopenharmony_ci enum swchnlcmd_id cmdid; 7462306a36Sopenharmony_ci u32 para1; 7562306a36Sopenharmony_ci u32 para2; 7662306a36Sopenharmony_ci u32 msdelay; 7762306a36Sopenharmony_ci}; 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_cienum hw90_block_e { 8062306a36Sopenharmony_ci HW90_BLOCK_MAC = 0, 8162306a36Sopenharmony_ci HW90_BLOCK_PHY0 = 1, 8262306a36Sopenharmony_ci HW90_BLOCK_PHY1 = 2, 8362306a36Sopenharmony_ci HW90_BLOCK_RF = 3, 8462306a36Sopenharmony_ci HW90_BLOCK_MAXIMUM = 4, 8562306a36Sopenharmony_ci}; 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_cienum baseband_config_type { 8862306a36Sopenharmony_ci BASEBAND_CONFIG_PHY_REG = 0, 8962306a36Sopenharmony_ci BASEBAND_CONFIG_AGC_TAB = 1, 9062306a36Sopenharmony_ci}; 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_cienum ra_offset_area { 9362306a36Sopenharmony_ci RA_OFFSET_LEGACY_OFDM1, 9462306a36Sopenharmony_ci RA_OFFSET_LEGACY_OFDM2, 9562306a36Sopenharmony_ci RA_OFFSET_HT_OFDM1, 9662306a36Sopenharmony_ci RA_OFFSET_HT_OFDM2, 9762306a36Sopenharmony_ci RA_OFFSET_HT_OFDM3, 9862306a36Sopenharmony_ci RA_OFFSET_HT_OFDM4, 9962306a36Sopenharmony_ci RA_OFFSET_HT_CCK, 10062306a36Sopenharmony_ci}; 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_cienum antenna_path { 10362306a36Sopenharmony_ci ANTENNA_NONE, 10462306a36Sopenharmony_ci ANTENNA_D, 10562306a36Sopenharmony_ci ANTENNA_C, 10662306a36Sopenharmony_ci ANTENNA_CD, 10762306a36Sopenharmony_ci ANTENNA_B, 10862306a36Sopenharmony_ci ANTENNA_BD, 10962306a36Sopenharmony_ci ANTENNA_BC, 11062306a36Sopenharmony_ci ANTENNA_BCD, 11162306a36Sopenharmony_ci ANTENNA_A, 11262306a36Sopenharmony_ci ANTENNA_AD, 11362306a36Sopenharmony_ci ANTENNA_AC, 11462306a36Sopenharmony_ci ANTENNA_ACD, 11562306a36Sopenharmony_ci ANTENNA_AB, 11662306a36Sopenharmony_ci ANTENNA_ABD, 11762306a36Sopenharmony_ci ANTENNA_ABC, 11862306a36Sopenharmony_ci ANTENNA_ABCD 11962306a36Sopenharmony_ci}; 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_cistruct r_antenna_select_ofdm { 12262306a36Sopenharmony_ci u32 r_tx_antenna:4; 12362306a36Sopenharmony_ci u32 r_ant_l:4; 12462306a36Sopenharmony_ci u32 r_ant_non_ht:4; 12562306a36Sopenharmony_ci u32 r_ant_ht1:4; 12662306a36Sopenharmony_ci u32 r_ant_ht2:4; 12762306a36Sopenharmony_ci u32 r_ant_ht_s1:4; 12862306a36Sopenharmony_ci u32 r_ant_non_ht_s1:4; 12962306a36Sopenharmony_ci u32 ofdm_txsc:2; 13062306a36Sopenharmony_ci u32 reserved:2; 13162306a36Sopenharmony_ci}; 13262306a36Sopenharmony_ci 13362306a36Sopenharmony_cistruct r_antenna_select_cck { 13462306a36Sopenharmony_ci u8 r_cckrx_enable_2:2; 13562306a36Sopenharmony_ci u8 r_cckrx_enable:2; 13662306a36Sopenharmony_ci u8 r_ccktx_enable:4; 13762306a36Sopenharmony_ci}; 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_cistruct efuse_contents { 14062306a36Sopenharmony_ci u8 mac_addr[ETH_ALEN]; 14162306a36Sopenharmony_ci u8 cck_tx_power_idx[6]; 14262306a36Sopenharmony_ci u8 ht40_1s_tx_power_idx[6]; 14362306a36Sopenharmony_ci u8 ht40_2s_tx_power_idx_diff[3]; 14462306a36Sopenharmony_ci u8 ht20_tx_power_idx_diff[3]; 14562306a36Sopenharmony_ci u8 ofdm_tx_power_idx_diff[3]; 14662306a36Sopenharmony_ci u8 ht40_max_power_offset[3]; 14762306a36Sopenharmony_ci u8 ht20_max_power_offset[3]; 14862306a36Sopenharmony_ci u8 channel_plan; 14962306a36Sopenharmony_ci u8 thermal_meter; 15062306a36Sopenharmony_ci u8 rf_option[5]; 15162306a36Sopenharmony_ci u8 version; 15262306a36Sopenharmony_ci u8 oem_id; 15362306a36Sopenharmony_ci u8 regulatory; 15462306a36Sopenharmony_ci}; 15562306a36Sopenharmony_ci 15662306a36Sopenharmony_cistruct tx_power_struct { 15762306a36Sopenharmony_ci u8 cck[RTL92C_MAX_PATH_NUM][CHANNEL_MAX_NUMBER]; 15862306a36Sopenharmony_ci u8 ht40_1s[RTL92C_MAX_PATH_NUM][CHANNEL_MAX_NUMBER]; 15962306a36Sopenharmony_ci u8 ht40_2s[RTL92C_MAX_PATH_NUM][CHANNEL_MAX_NUMBER]; 16062306a36Sopenharmony_ci u8 ht20_diff[RTL92C_MAX_PATH_NUM][CHANNEL_MAX_NUMBER]; 16162306a36Sopenharmony_ci u8 legacy_ht_diff[RTL92C_MAX_PATH_NUM][CHANNEL_MAX_NUMBER]; 16262306a36Sopenharmony_ci u8 legacy_ht_txpowerdiff; 16362306a36Sopenharmony_ci u8 groupht20[RTL92C_MAX_PATH_NUM][CHANNEL_MAX_NUMBER]; 16462306a36Sopenharmony_ci u8 groupht40[RTL92C_MAX_PATH_NUM][CHANNEL_MAX_NUMBER]; 16562306a36Sopenharmony_ci u8 pwrgroup_cnt; 16662306a36Sopenharmony_ci u32 mcs_original_offset[4][16]; 16762306a36Sopenharmony_ci}; 16862306a36Sopenharmony_ci 16962306a36Sopenharmony_cienum _ANT_DIV_TYPE { 17062306a36Sopenharmony_ci NO_ANTDIV = 0xFF, 17162306a36Sopenharmony_ci CG_TRX_HW_ANTDIV = 0x01, 17262306a36Sopenharmony_ci CGCS_RX_HW_ANTDIV = 0x02, 17362306a36Sopenharmony_ci FIXED_HW_ANTDIV = 0x03, 17462306a36Sopenharmony_ci CG_TRX_SMART_ANTDIV = 0x04, 17562306a36Sopenharmony_ci CGCS_RX_SW_ANTDIV = 0x05, 17662306a36Sopenharmony_ci}; 17762306a36Sopenharmony_ci 17862306a36Sopenharmony_ciu32 rtl88e_phy_query_bb_reg(struct ieee80211_hw *hw, 17962306a36Sopenharmony_ci u32 regaddr, u32 bitmask); 18062306a36Sopenharmony_civoid rtl88e_phy_set_bb_reg(struct ieee80211_hw *hw, 18162306a36Sopenharmony_ci u32 regaddr, u32 bitmask, u32 data); 18262306a36Sopenharmony_ciu32 rtl88e_phy_query_rf_reg(struct ieee80211_hw *hw, 18362306a36Sopenharmony_ci enum radio_path rfpath, u32 regaddr, 18462306a36Sopenharmony_ci u32 bitmask); 18562306a36Sopenharmony_civoid rtl88e_phy_set_rf_reg(struct ieee80211_hw *hw, 18662306a36Sopenharmony_ci enum radio_path rfpath, u32 regaddr, 18762306a36Sopenharmony_ci u32 bitmask, u32 data); 18862306a36Sopenharmony_cibool rtl88e_phy_mac_config(struct ieee80211_hw *hw); 18962306a36Sopenharmony_cibool rtl88e_phy_bb_config(struct ieee80211_hw *hw); 19062306a36Sopenharmony_cibool rtl88e_phy_rf_config(struct ieee80211_hw *hw); 19162306a36Sopenharmony_civoid rtl88e_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw); 19262306a36Sopenharmony_civoid rtl88e_phy_get_txpower_level(struct ieee80211_hw *hw, 19362306a36Sopenharmony_ci long *powerlevel); 19462306a36Sopenharmony_civoid rtl88e_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel); 19562306a36Sopenharmony_civoid rtl88e_phy_scan_operation_backup(struct ieee80211_hw *hw, 19662306a36Sopenharmony_ci u8 operation); 19762306a36Sopenharmony_civoid rtl88e_phy_set_bw_mode_callback(struct ieee80211_hw *hw); 19862306a36Sopenharmony_civoid rtl88e_phy_set_bw_mode(struct ieee80211_hw *hw, 19962306a36Sopenharmony_ci enum nl80211_channel_type ch_type); 20062306a36Sopenharmony_civoid rtl88e_phy_sw_chnl_callback(struct ieee80211_hw *hw); 20162306a36Sopenharmony_ciu8 rtl88e_phy_sw_chnl(struct ieee80211_hw *hw); 20262306a36Sopenharmony_civoid rtl88e_phy_iq_calibrate(struct ieee80211_hw *hw, bool b_recovery); 20362306a36Sopenharmony_civoid rtl88e_phy_lc_calibrate(struct ieee80211_hw *hw); 20462306a36Sopenharmony_civoid rtl88e_phy_set_rfpath_switch(struct ieee80211_hw *hw, bool bmain); 20562306a36Sopenharmony_cibool rtl88e_phy_config_rf_with_headerfile(struct ieee80211_hw *hw, 20662306a36Sopenharmony_ci enum radio_path rfpath); 20762306a36Sopenharmony_cibool rtl88e_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype); 20862306a36Sopenharmony_cibool rtl88e_phy_set_rf_power_state(struct ieee80211_hw *hw, 20962306a36Sopenharmony_ci enum rf_pwrstate rfpwr_state); 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_ci#endif 212