1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _R819XU_PHY_H
3 #define _R819XU_PHY_H
4 
5 /* Channel switch: The size of command tables for switch channel */
6 #define MAX_PRECMD_CNT 16
7 #define MAX_RFDEPENDCMD_CNT 16
8 #define MAX_POSTCMD_CNT 16
9 
10 enum switch_chan_cmd_id {
11 	CMD_ID_END,
12 	CMD_ID_SET_TX_PWR_LEVEL,
13 	CMD_ID_WRITE_PORT_ULONG,
14 	CMD_ID_WRITE_PORT_USHORT,
15 	CMD_ID_WRITE_PORT_UCHAR,
16 	CMD_ID_RF_WRITE_REG,
17 };
18 
19 /* -----------------------Define structure---------------------- */
20 /* 1. Switch channel related */
21 struct sw_chnl_cmd {
22 	enum switch_chan_cmd_id	cmd_id;
23 	u32		        para_1;
24 	u32		        para_2;
25 	u32		        ms_delay;
26 } __packed;
27 
28 enum hw90_block_e {
29 	HW90_BLOCK_MAC = 0,
30 	HW90_BLOCK_PHY0 = 1,
31 	HW90_BLOCK_PHY1 = 2,
32 	HW90_BLOCK_RF = 3,
33 	HW90_BLOCK_MAXIMUM = 4, /* Never use this */
34 };
35 
36 enum rf90_radio_path_e {
37 	RF90_PATH_A = 0,			/* Radio Path A */
38 	RF90_PATH_B = 1,			/* Radio Path B */
39 	RF90_PATH_C = 2,			/* Radio Path C */
40 	RF90_PATH_D = 3,			/* Radio Path D */
41 	RF90_PATH_MAX				/* Max RF number 92 support */
42 };
43 
44 u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device *dev, u32 e_rfpath);
45 void rtl8192_setBBreg(struct net_device *dev, u32 reg_addr,
46 		      u32 bitmask, u32 data);
47 u32 rtl8192_QueryBBReg(struct net_device *dev, u32 reg_addr, u32 bitmask);
48 void rtl8192_phy_SetRFReg(struct net_device *dev,
49 			  enum rf90_radio_path_e e_rfpath,
50 			  u32 reg_addr, u32 bitmask, u32 data);
51 u32 rtl8192_phy_QueryRFReg(struct net_device *dev,
52 			   enum rf90_radio_path_e e_rfpath,
53 			   u32 reg_addr, u32 bitmask);
54 void rtl8192_phy_configmac(struct net_device *dev);
55 void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType);
56 u8 rtl8192_phy_checkBBAndRF(struct net_device *dev,
57 			    enum hw90_block_e CheckBlock,
58 			    enum rf90_radio_path_e e_rfpath);
59 void rtl8192_BBConfig(struct net_device *dev);
60 void rtl8192_phy_getTxPower(struct net_device *dev);
61 void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel);
62 void rtl8192_phy_RFConfig(struct net_device *dev);
63 void rtl8192_phy_updateInitGain(struct net_device *dev);
64 u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev,
65 				      enum rf90_radio_path_e e_rfpath);
66 
67 u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel);
68 void rtl8192_SetBWMode(struct net_device *dev,
69 		       enum ht_channel_width bandwidth,
70 		       enum ht_extension_chan_offset offset);
71 void rtl8192_SwChnl_WorkItem(struct net_device *dev);
72 void rtl8192_SetBWModeWorkItem(struct net_device *dev);
73 bool rtl8192_SetRFPowerState(struct net_device *dev,
74 			     RT_RF_POWER_STATE eRFPowerState);
75 void InitialGain819xUsb(struct net_device *dev, u8 Operation);
76 
77 void InitialGainOperateWorkItemCallBack(struct work_struct *work);
78 
79 #endif
80