1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2009-2012  Realtek Corporation.*/
3 
4 #ifndef __RTL92C__FW__COMMON__H__
5 #define __RTL92C__FW__COMMON__H__
6 
7 #define FW_8192C_SIZE				0x3000
8 #define FW_8192C_START_ADDRESS			0x1000
9 #define FW_8192C_END_ADDRESS			0x1FFF
10 #define FW_8192C_PAGE_SIZE			4096
11 #define FW_8192C_POLLING_DELAY			5
12 #define FW_8192C_POLLING_TIMEOUT_COUNT		100
13 #define NORMAL_CHIP				BIT(4)
14 #define H2C_92C_KEEP_ALIVE_CTRL			48
15 
16 #define IS_FW_HEADER_EXIST(_pfwhdr)	\
17 	((le16_to_cpu(_pfwhdr->signature)&0xFFF0) == 0x92C0 ||\
18 	(le16_to_cpu(_pfwhdr->signature)&0xFFF0) == 0x88C0)
19 
20 #define CUT_VERSION_MASK		(BIT(6)|BIT(7))
21 #define CHIP_VENDOR_UMC			BIT(5)
22 #define CHIP_VENDOR_UMC_B_CUT		BIT(6) /* Chip version for ECO */
23 #define IS_CHIP_VER_B(version)  ((version & CHIP_VER_B) ? true : false)
24 #define RF_TYPE_MASK			(BIT(0)|BIT(1))
25 #define GET_CVID_RF_TYPE(version)	\
26 	((version) & RF_TYPE_MASK)
27 #define GET_CVID_CUT_VERSION(version) \
28 	((version) & CUT_VERSION_MASK)
29 #define IS_NORMAL_CHIP(version)	\
30 	((version & NORMAL_CHIP) ? true : false)
31 #define IS_2T2R(version) \
32 	(((GET_CVID_RF_TYPE(version)) == \
33 	CHIP_92C_BITMASK) ? true : false)
34 #define IS_92C_SERIAL(version) \
35 	((IS_2T2R(version)) ? true : false)
36 #define IS_CHIP_VENDOR_UMC(version)	\
37 	((version & CHIP_VENDOR_UMC) ? true : false)
38 #define IS_VENDOR_UMC_A_CUT(version) \
39 	((IS_CHIP_VENDOR_UMC(version)) ? \
40 	((GET_CVID_CUT_VERSION(version)) ? false : true) : false)
41 #define IS_81XXC_VENDOR_UMC_B_CUT(version)	\
42 	((IS_CHIP_VENDOR_UMC(version)) ? \
43 	((GET_CVID_CUT_VERSION(version) == \
44 		CHIP_VENDOR_UMC_B_CUT) ? true : false) : false)
45 
46 #define pagenum_128(_len)	(u32)(((_len)>>7) + ((_len)&0x7F ? 1 : 0))
47 
48 #define SET_H2CCMD_PWRMODE_PARM_MODE(__ph2ccmd, __val)			\
49 	*(u8 *)(__ph2ccmd) = __val
50 #define SET_H2CCMD_PWRMODE_PARM_SMART_PS(__ph2ccmd, __val)		\
51 	*(u8 *)(__ph2ccmd + 1) = __val
52 #define SET_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(__ph2ccmd, __val)	\
53 	*(u8 *)(__ph2ccmd + 2) = __val
54 #define SET_H2CCMD_JOINBSSRPT_PARM_OPMODE(__ph2ccmd, __val)		\
55 	*(u8 *)(__ph2ccmd) = __val
56 #define SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(__ph2ccmd, __val)		\
57 	*(u8 *)(__ph2ccmd) = __val
58 #define SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(__ph2ccmd, __val)		\
59 	*(u8 *)(__ph2ccmd + 1) = __val
60 #define SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(__ph2ccmd, __val)		\
61 	*(u8 *)(__ph2ccmd + 2) = __val
62 
63 int rtl92c_download_fw(struct ieee80211_hw *hw);
64 void rtl92c_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id,
65 			 u32 cmd_len, u8 *p_cmdbuffer);
66 void rtl92c_firmware_selfreset(struct ieee80211_hw *hw);
67 void rtl92c_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode);
68 void rtl92c_set_fw_rsvdpagepkt
69 	(struct ieee80211_hw *hw,
70 	 bool (*cmd_send_packet)(struct ieee80211_hw *, struct sk_buff *));
71 void rtl92c_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus);
72 void usb_writeN_async(struct rtl_priv *rtlpriv, u32 addr, void *data, u16 len);
73 void rtl92c_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state);
74 
75 #endif
76