1 /* SPDX-License-Identifier: GPL-2.0 */
2 /******************************************************************************
4 * Copyright(c) 2016 Realtek Corporation.
8 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
13 *****************************************************************************/
15 #ifndef __RTL8822BE_PHY_H__
16 #define __RTL8822BE_PHY_H__
18 /* It must always set to 4, otherwise read
19 * efuse table sequence will be wrong.
21 #define MAX_TX_COUNT 4
27 #define MAX_POWER_INDEX 0x3F
29 #define MAX_PRECMD_CNT 16
30 #define MAX_RFDEPENDCMD_CNT 16
31 #define MAX_POSTCMD_CNT 16
33 #define MAX_DOZE_WAITING_TIMES_9x 64
35 #define RT_CANNOT_IO(hw) false
36 #define HIGHPOWER_RADIOA_ARRAYLEN 22
38 #define IQK_ADDA_REG_NUM 16
39 #define IQK_BB_REG_NUM 9
40 #define MAX_TOLERANCE 5
41 #define IQK_DELAY_TIME 10
42 #define index_mapping_NUM 15
44 #define APK_BB_REG_NUM 5
45 #define APK_AFE_REG_NUM 16
46 #define APK_CURVE_REG_NUM 4
50 #define MAX_STALL_TIME 50
51 #define ANTENNA_DIVERSITY_VALUE 0x80
52 #define MAX_TXPWR_IDX_NMODE_92S 63
53 #define RESET_CNT_LIMIT 3
55 #define IQK_ADDA_REG_NUM 16
56 #define IQK_MAC_REG_NUM 4
58 #define RF6052_MAX_PATH 2
60 #define CT_OFFSET_MAC_ADDR 0X16
62 #define CT_OFFSET_CCK_TX_PWR_IDX 0x5A
63 #define CT_OFFSET_HT401S_TX_PWR_IDX 0x60
64 #define CT_OFFSET_HT402S_TX_PWR_IDX_DIFF 0x66
65 #define CT_OFFSET_HT20_TX_PWR_IDX_DIFF 0x69
66 #define CT_OFFSET_OFDM_TX_PWR_IDX_DIFF 0x6C
68 #define CT_OFFSET_HT40_MAX_PWR_OFFSET 0x6F
69 #define CT_OFFSET_HT20_MAX_PWR_OFFSET 0x72
71 #define CT_OFFSET_CHANNEL_PLAH 0x75
72 #define CT_OFFSET_THERMAL_METER 0x78
73 #define CT_OFFSET_RF_OPTION 0x79
74 #define CT_OFFSET_VERSION 0x7E
75 #define CT_OFFSET_CUSTOMER_ID 0x7F
77 #define RTL8822BE_MAX_PATH_NUM 2
79 #define TARGET_CHNL_NUM_2G_5G_8822B 59
81 u32 rtl8822be_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr,
83 void rtl8822be_phy_set_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask,
85 u32 rtl8822be_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
86 u32 regaddr, u32 bitmask);
87 void rtl8822be_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
88 u32 regaddr, u32 bitmask, u32 data);
89 bool rtl8822be_phy_bb_config(struct ieee80211_hw *hw);
90 bool rtl8822be_phy_rf_config(struct ieee80211_hw *hw);
91 bool rtl8822be_halmac_cb_init_mac_register(struct rtl_priv *rtlpriv);
92 bool rtl8822be_halmac_cb_init_bb_rf_register(struct rtl_priv *rtlpriv);
93 void rtl8822be_phy_get_txpower_level(struct ieee80211_hw *hw, long *powerlevel);
94 void rtl8822be_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel);
95 void rtl8822be_phy_scan_operation_backup(struct ieee80211_hw *hw, u8 operation);
96 void rtl8822be_phy_set_bw_mode_callback(struct ieee80211_hw *hw);
97 void rtl8822be_phy_set_bw_mode(struct ieee80211_hw *hw,
98 enum nl80211_channel_type ch_type);
99 u8 rtl8822be_phy_sw_chnl(struct ieee80211_hw *hw);
100 void rtl8822be_phy_iq_calibrate(struct ieee80211_hw *hw, bool b_recovery);
101 void rtl8822be_phy_iq_calibrate(struct ieee80211_hw *hw, bool b_recovery);
102 void rtl8822be_phy_ap_calibrate(struct ieee80211_hw *hw, char delta);
103 void rtl8822be_phy_lc_calibrate(struct ieee80211_hw *hw);
104 void rtl8822be_phy_set_rfpath_switch(struct ieee80211_hw *hw, bool bmain);
105 bool rtl8822be_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
106 enum radio_path rfpath);
107 bool rtl8822be_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
108 enum radio_path rfpath);
109 bool rtl8822be_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype);
110 bool rtl8822be_phy_set_rf_power_state(struct ieee80211_hw *hw,
111 enum rf_pwrstate rfpwr_state);
112 void rtl8822be_phy_set_txpower_level_by_path(struct ieee80211_hw *hw,
113 u8 channel, u8 path);
114 void rtl8822be_do_iqk(struct ieee80211_hw *hw, u8 delta_thermal_index,
115 u8 thermal_value, u8 threshold);
116 void rtl8822be_do_iqk(struct ieee80211_hw *hw, u8 delta_thermal_index,
117 u8 thermal_value, u8 threshold);
118 void rtl8822be_reset_iqk_result(struct ieee80211_hw *hw);
120 u8 rtl8822be_get_txpower_index(struct ieee80211_hw *hw, u8 path, u8 rate,
121 u8 bandwidth, u8 channel);
122 void rtl8822be_phy_set_tx_power_index_by_rs(struct ieee80211_hw *hw, u8 channel,
123 u8 path, enum rate_section rs);
124 void rtl8822be_store_tx_power_by_rate(struct ieee80211_hw *hw, u32 band,
125 u32 rfpath, u32 txnum, u32 regaddr,
126 u32 bitmask, u32 data);
127 void rtl8822be_phy_set_txpower_limit(struct ieee80211_hw *hw, u8 *pregulation,
128 u8 *pband, u8 *pbandwidth,
129 u8 *prate_section, u8 *prf_path,
130 u8 *pchannel, u8 *ppower_limit);
131 bool rtl8822be_load_txpower_by_rate(struct ieee80211_hw *hw);
132 bool rtl8822be_load_txpower_limit(struct ieee80211_hw *hw);