xref: /openbmc/linux/drivers/net/wireless/realtek/rtlwifi/rtl8192ee/phy.h (revision 597473720f4dc69749542bfcfed4a927a43d935e)
1*647f21b1SLarry Finger /* SPDX-License-Identifier: GPL-2.0 */
2*647f21b1SLarry Finger /* Copyright(c) 2009-2014  Realtek Corporation.*/
3f1d2b4d3SLarry Finger 
4f1d2b4d3SLarry Finger #ifndef __RTL92E_PHY_H__
5f1d2b4d3SLarry Finger #define __RTL92E_PHY_H__
6f1d2b4d3SLarry Finger 
7f1d2b4d3SLarry Finger /* MAX_TX_COUNT must always set to 4, otherwise read efuse table sequence
8f1d2b4d3SLarry Finger  * will be wrong.
9f1d2b4d3SLarry Finger  */
10f1d2b4d3SLarry Finger #define MAX_TX_COUNT				4
11f1d2b4d3SLarry Finger #define TX_1S					0
12f1d2b4d3SLarry Finger #define TX_2S					1
13f1d2b4d3SLarry Finger #define TX_3S					2
14f1d2b4d3SLarry Finger #define TX_4S					3
15f1d2b4d3SLarry Finger 
16f1d2b4d3SLarry Finger #define MAX_POWER_INDEX				0x3f
17f1d2b4d3SLarry Finger 
18f1d2b4d3SLarry Finger #define MAX_PRECMD_CNT				16
19f1d2b4d3SLarry Finger #define MAX_RFDEPENDCMD_CNT			16
20f1d2b4d3SLarry Finger #define MAX_POSTCMD_CNT				16
21f1d2b4d3SLarry Finger 
22f1d2b4d3SLarry Finger #define MAX_DOZE_WAITING_TIMES_9x		64
23f1d2b4d3SLarry Finger 
24f1d2b4d3SLarry Finger #define RT_CANNOT_IO(hw)			false
25f1d2b4d3SLarry Finger #define HIGHPOWER_RADIOA_ARRAYLEN		22
26f1d2b4d3SLarry Finger 
27f1d2b4d3SLarry Finger #define IQK_ADDA_REG_NUM			16
28f1d2b4d3SLarry Finger #define IQK_MAC_REG_NUM				4
29f1d2b4d3SLarry Finger #define IQK_BB_REG_NUM				9
30f1d2b4d3SLarry Finger #define MAX_TOLERANCE				5
31f1d2b4d3SLarry Finger #define	IQK_DELAY_TIME				10
32f1d2b4d3SLarry Finger #define	index_mapping_NUM			15
33f1d2b4d3SLarry Finger 
34f1d2b4d3SLarry Finger #define	APK_BB_REG_NUM				5
35f1d2b4d3SLarry Finger #define	APK_AFE_REG_NUM				16
36f1d2b4d3SLarry Finger #define	APK_CURVE_REG_NUM			4
37f1d2b4d3SLarry Finger #define	PATH_NUM				2
38f1d2b4d3SLarry Finger 
39f1d2b4d3SLarry Finger #define LOOP_LIMIT				5
40f1d2b4d3SLarry Finger #define MAX_STALL_TIME				50
41f1d2b4d3SLarry Finger #define ANTENNADIVERSITYVALUE			0x80
42f1d2b4d3SLarry Finger #define MAX_TXPWR_IDX_NMODE_92S			63
43f1d2b4d3SLarry Finger #define RESET_CNT_LIMIT				3
44f1d2b4d3SLarry Finger 
45f1d2b4d3SLarry Finger #define RF6052_MAX_PATH				2
46f1d2b4d3SLarry Finger 
47f1d2b4d3SLarry Finger #define CT_OFFSET_MAC_ADDR			0X16
48f1d2b4d3SLarry Finger 
49f1d2b4d3SLarry Finger #define CT_OFFSET_CCK_TX_PWR_IDX		0x5A
50f1d2b4d3SLarry Finger #define CT_OFFSET_HT401S_TX_PWR_IDX		0x60
51f1d2b4d3SLarry Finger #define CT_OFFSET_HT402S_TX_PWR_IDX_DIFF	0x66
52f1d2b4d3SLarry Finger #define CT_OFFSET_HT20_TX_PWR_IDX_DIFF		0x69
53f1d2b4d3SLarry Finger #define CT_OFFSET_OFDM_TX_PWR_IDX_DIFF		0x6C
54f1d2b4d3SLarry Finger 
55f1d2b4d3SLarry Finger #define CT_OFFSET_HT40_MAX_PWR_OFFSET		0x6F
56f1d2b4d3SLarry Finger #define CT_OFFSET_HT20_MAX_PWR_OFFSET		0x72
57f1d2b4d3SLarry Finger 
58f1d2b4d3SLarry Finger #define CT_OFFSET_CHANNEL_PLAH			0x75
59f1d2b4d3SLarry Finger #define CT_OFFSET_THERMAL_METER			0x78
60f1d2b4d3SLarry Finger #define CT_OFFSET_RF_OPTION			0x79
61f1d2b4d3SLarry Finger #define CT_OFFSET_VERSION			0x7E
62f1d2b4d3SLarry Finger #define CT_OFFSET_CUSTOMER_ID			0x7F
63f1d2b4d3SLarry Finger 
64f1d2b4d3SLarry Finger #define RTL92C_MAX_PATH_NUM			2
65f1d2b4d3SLarry Finger 
66f1d2b4d3SLarry Finger enum swchnlcmd_id {
67f1d2b4d3SLarry Finger 	CMDID_END,
68f1d2b4d3SLarry Finger 	CMDID_SET_TXPOWEROWER_LEVEL,
69f1d2b4d3SLarry Finger 	CMDID_BBREGWRITE10,
70f1d2b4d3SLarry Finger 	CMDID_WRITEPORT_ULONG,
71f1d2b4d3SLarry Finger 	CMDID_WRITEPORT_USHORT,
72f1d2b4d3SLarry Finger 	CMDID_WRITEPORT_UCHAR,
73f1d2b4d3SLarry Finger 	CMDID_RF_WRITEREG,
74f1d2b4d3SLarry Finger };
75f1d2b4d3SLarry Finger 
76f1d2b4d3SLarry Finger struct swchnlcmd {
77f1d2b4d3SLarry Finger 	enum swchnlcmd_id cmdid;
78f1d2b4d3SLarry Finger 	u32 para1;
79f1d2b4d3SLarry Finger 	u32 para2;
80f1d2b4d3SLarry Finger 	u32 msdelay;
81f1d2b4d3SLarry Finger };
82f1d2b4d3SLarry Finger 
83f1d2b4d3SLarry Finger enum baseband_config_type {
84f1d2b4d3SLarry Finger 	BASEBAND_CONFIG_PHY_REG = 0,
85f1d2b4d3SLarry Finger 	BASEBAND_CONFIG_AGC_TAB = 1,
86f1d2b4d3SLarry Finger };
87f1d2b4d3SLarry Finger 
88f1d2b4d3SLarry Finger enum ant_div_type {
89f1d2b4d3SLarry Finger 	NO_ANTDIV = 0xFF,
90f1d2b4d3SLarry Finger 	CG_TRX_HW_ANTDIV = 0x01,
91f1d2b4d3SLarry Finger 	CGCS_RX_HW_ANTDIV = 0x02,
92f1d2b4d3SLarry Finger 	FIXED_HW_ANTDIV = 0x03,
93f1d2b4d3SLarry Finger 	CG_TRX_SMART_ANTDIV = 0x04,
94f1d2b4d3SLarry Finger 	CGCS_RX_SW_ANTDIV = 0x05,
95f1d2b4d3SLarry Finger };
96f1d2b4d3SLarry Finger 
97f1d2b4d3SLarry Finger u32 rtl92ee_phy_query_bb_reg(struct ieee80211_hw *hw,
98f1d2b4d3SLarry Finger 			     u32 regaddr, u32 bitmask);
99f1d2b4d3SLarry Finger void rtl92ee_phy_set_bb_reg(struct ieee80211_hw *hw,
100f1d2b4d3SLarry Finger 			    u32 regaddr, u32 bitmask, u32 data);
101f1d2b4d3SLarry Finger u32 rtl92ee_phy_query_rf_reg(struct ieee80211_hw *hw,
102f1d2b4d3SLarry Finger 			     enum radio_path rfpath, u32 regaddr,
103f1d2b4d3SLarry Finger 			     u32 bitmask);
104f1d2b4d3SLarry Finger void rtl92ee_phy_set_rf_reg(struct ieee80211_hw *hw,
105f1d2b4d3SLarry Finger 			    enum radio_path rfpath, u32 regaddr,
106f1d2b4d3SLarry Finger 			    u32 bitmask, u32 data);
107f1d2b4d3SLarry Finger bool rtl92ee_phy_mac_config(struct ieee80211_hw *hw);
108f1d2b4d3SLarry Finger bool rtl92ee_phy_bb_config(struct ieee80211_hw *hw);
109f1d2b4d3SLarry Finger bool rtl92ee_phy_rf_config(struct ieee80211_hw *hw);
110f1d2b4d3SLarry Finger void rtl92ee_phy_get_hw_reg_originalvalue(struct ieee80211_hw *hw);
111f1d2b4d3SLarry Finger void rtl92ee_phy_get_txpower_level(struct ieee80211_hw *hw,
112f1d2b4d3SLarry Finger 				   long *powerlevel);
113f1d2b4d3SLarry Finger void rtl92ee_phy_set_txpower_level(struct ieee80211_hw *hw, u8 channel);
114f1d2b4d3SLarry Finger void rtl92ee_phy_scan_operation_backup(struct ieee80211_hw *hw,
115f1d2b4d3SLarry Finger 				       u8 operation);
116f1d2b4d3SLarry Finger void rtl92ee_phy_set_bw_mode_callback(struct ieee80211_hw *hw);
117f1d2b4d3SLarry Finger void rtl92ee_phy_set_bw_mode(struct ieee80211_hw *hw,
118f1d2b4d3SLarry Finger 			     enum nl80211_channel_type ch_type);
119f1d2b4d3SLarry Finger void rtl92ee_phy_sw_chnl_callback(struct ieee80211_hw *hw);
120f1d2b4d3SLarry Finger u8 rtl92ee_phy_sw_chnl(struct ieee80211_hw *hw);
121f1d2b4d3SLarry Finger void rtl92ee_phy_iq_calibrate(struct ieee80211_hw *hw, bool b_recovery);
12208aba42fSArnd Bergmann void rtl92ee_phy_ap_calibrate(struct ieee80211_hw *hw, s8 delta);
123f1d2b4d3SLarry Finger void rtl92ee_phy_lc_calibrate(struct ieee80211_hw *hw);
124f1d2b4d3SLarry Finger void rtl92ee_phy_set_rfpath_switch(struct ieee80211_hw *hw, bool bmain);
125f1d2b4d3SLarry Finger bool rtl92ee_phy_config_rf_with_headerfile(struct ieee80211_hw *hw,
126f1d2b4d3SLarry Finger 					   enum radio_path rfpath);
127f1d2b4d3SLarry Finger bool rtl92ee_phy_set_io_cmd(struct ieee80211_hw *hw, enum io_type iotype);
128f1d2b4d3SLarry Finger bool rtl92ee_phy_set_rf_power_state(struct ieee80211_hw *hw,
129f1d2b4d3SLarry Finger 				    enum rf_pwrstate rfpwr_state);
130f1d2b4d3SLarry Finger 
131f1d2b4d3SLarry Finger #endif
132