1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2009-2012  Realtek Corporation.*/
3 
4 #ifndef __RTL92D_FW_COMMON_H__
5 #define __RTL92D_FW_COMMON_H__
6 
7 #define FW_8192D_START_ADDRESS			0x1000
8 #define FW_8192D_PAGE_SIZE			4096
9 #define FW_8192D_POLLING_TIMEOUT_COUNT		1000
10 
11 #define IS_FW_HEADER_EXIST(_pfwhdr)	\
12 		((GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFF0) == 0x92C0 || \
13 		 (GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFF0) == 0x88C0 || \
14 		 (GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFFF) == 0x92D0 || \
15 		 (GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFFF) == 0x92D1 || \
16 		 (GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFFF) == 0x92D2 || \
17 		 (GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFFF) == 0x92D3)
18 
19 /* Firmware Header(8-byte alinment required) */
20 /* --- LONG WORD 0 ---- */
21 #define GET_FIRMWARE_HDR_SIGNATURE(__fwhdr)		\
22 	le32_get_bits(*(__le32 *)__fwhdr, GENMASK(15, 0))
23 #define GET_FIRMWARE_HDR_VERSION(__fwhdr)		\
24 	le32_get_bits(*(__le32 *)((__fwhdr) + 4), GENMASK(15, 0))
25 #define GET_FIRMWARE_HDR_SUB_VER(__fwhdr)		\
26 	le32_get_bits(*(__le32 *)((__fwhdr) + 4), GENMASK(23, 16))
27 
28 #define RAID_MASK               GENMASK(31, 28)
29 #define RATE_MASK_MASK          GENMASK(27, 0)
30 #define SHORT_GI_MASK           BIT(5)
31 #define MACID_MASK              GENMASK(4, 0)
32 
33 struct rtl92d_rate_mask_h2c {
34 	__le32 rate_mask_and_raid;
35 	u8 macid_and_short_gi;
36 } __packed;
37 
38 bool rtl92d_is_fw_downloaded(struct rtl_priv *rtlpriv);
39 void rtl92d_enable_fw_download(struct ieee80211_hw *hw, bool enable);
40 void rtl92d_write_fw(struct ieee80211_hw *hw,
41 		     enum version_8192d version, u8 *buffer, u32 size);
42 int rtl92d_fw_free_to_go(struct ieee80211_hw *hw);
43 void rtl92d_firmware_selfreset(struct ieee80211_hw *hw);
44 int rtl92d_fw_init(struct ieee80211_hw *hw);
45 void rtl92d_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id,
46 			 u32 cmd_len, u8 *p_cmdbuffer);
47 void rtl92d_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus);
48 
49 #endif
50