1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2009-2014  Realtek Corporation.*/
3 
4 #ifndef __FW_COMMON_H__
5 #define __FW_COMMON_H__
6 
7 #define REG_SYS_FUNC_EN				0x0002
8 #define REG_MCUFWDL				0x0080
9 #define FW_8192C_PAGE_SIZE			4096
10 #define FW_8723A_POLLING_TIMEOUT_COUNT		1000
11 #define FW_8723B_POLLING_TIMEOUT_COUNT		6000
12 #define FW_8192C_POLLING_DELAY			5
13 
14 #define MCUFWDL_RDY				BIT(1)
15 #define FWDL_CHKSUM_RPT				BIT(2)
16 #define WINTINI_RDY				BIT(6)
17 
18 #define REG_RSV_CTRL				0x001C
19 #define REG_HMETFR				0x01CC
20 
21 enum version_8723e {
22 	VERSION_TEST_UMC_CHIP_8723 = 0x0081,
23 	VERSION_NORMAL_UMC_CHIP_8723_1T1R_A_CUT = 0x0089,
24 	VERSION_NORMAL_UMC_CHIP_8723_1T1R_B_CUT = 0x1089,
25 	VERSION_TEST_CHIP_1T1R_8723B = 0x0106,
26 	VERSION_NORMAL_SMIC_CHIP_1T1R_8723B = 0x010E,
27 	VERSION_UNKNOWN = 0xFF,
28 };
29 
30 enum rtl8723be_cmd {
31 	H2C_8723BE_RSVDPAGE = 0,
32 	H2C_8723BE_JOINBSSRPT = 1,
33 	H2C_8723BE_SCAN = 2,
34 	H2C_8723BE_KEEP_ALIVE_CTRL = 3,
35 	H2C_8723BE_DISCONNECT_DECISION = 4,
36 	H2C_8723BE_INIT_OFFLOAD = 6,
37 	H2C_8723BE_AP_OFFLOAD = 8,
38 	H2C_8723BE_BCN_RSVDPAGE = 9,
39 	H2C_8723BE_PROBERSP_RSVDPAGE = 10,
40 
41 	H2C_8723BE_SETPWRMODE = 0x20,
42 	H2C_8723BE_PS_TUNING_PARA = 0x21,
43 	H2C_8723BE_PS_TUNING_PARA2 = 0x22,
44 	H2C_8723BE_PS_LPS_PARA = 0x23,
45 	H2C_8723BE_P2P_PS_OFFLOAD = 0x24,
46 
47 	H2C_8723BE_WO_WLAN = 0x80,
48 	H2C_8723BE_REMOTE_WAKE_CTRL = 0x81,
49 	H2C_8723BE_AOAC_GLOBAL_INFO = 0x82,
50 	H2C_8723BE_AOAC_RSVDPAGE = 0x83,
51 	H2C_8723BE_RSSI_REPORT = 0x42,
52 	H2C_8723BE_RA_MASK = 0x40,
53 	H2C_8723BE_SELECTIVE_SUSPEND_ROF_CMD,
54 	H2C_8723BE_P2P_PS_MODE,
55 	H2C_8723BE_PSD_RESULT,
56 	/*Not defined CTW CMD for P2P yet*/
57 	H2C_8723BE_P2P_PS_CTW_CMD,
58 	MAX_8723BE_H2CCMD
59 };
60 
61 void rtl8723ae_firmware_selfreset(struct ieee80211_hw *hw);
62 void rtl8723be_firmware_selfreset(struct ieee80211_hw *hw);
63 void rtl8723_enable_fw_download(struct ieee80211_hw *hw, bool enable);
64 void rtl8723_write_fw(struct ieee80211_hw *hw,
65 		      enum version_8723e version,
66 		      u8 *buffer, u32 size, u8 max_page);
67 int rtl8723_fw_free_to_go(struct ieee80211_hw *hw, bool is_8723be, int count);
68 int rtl8723_download_fw(struct ieee80211_hw *hw, bool is_8723be, int count);
69 
70 #endif
71