[go: nahoru, domu]

1985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li/******************************************************************************
2985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li *
36a57b08e222f4e054a7e7160ef7426c5614c0cc0Larry Finger * Copyright(c) 2009-2012  Realtek Corporation.
4985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li *
5985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * This program is free software; you can redistribute it and/or modify it
6985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * under the terms of version 2 of the GNU General Public License as
7985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * published by the Free Software Foundation.
8985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li *
9985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * This program is distributed in the hope that it will be useful, but WITHOUT
10985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * more details.
13985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li *
14985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * You should have received a copy of the GNU General Public License along with
15985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * this program; if not, write to the Free Software Foundation, Inc.,
16985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li *
18985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * The full GNU General Public License is included in this distribution in the
19985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * file called LICENSE.
20985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li *
21985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * Contact Information:
22985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * wlanfae <wlanfae@realtek.com>
23985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
24985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * Hsinchu 300, Taiwan.
25985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li *
26985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * Larry Finger <Larry.Finger@lwfinger.net>
27985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li *
28985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li *****************************************************************************/
29985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li
30985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#ifndef __RTL92D__FW__H__
31985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define __RTL92D__FW__H__
32985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li
33985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define FW_8192D_START_ADDRESS			0x1000
34985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define FW_8192D_PAGE_SIZE				4096
35985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define FW_8192D_POLLING_TIMEOUT_COUNT	1000
36985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li
37985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define IS_FW_HEADER_EXIST(_pfwhdr)	\
38985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li		((GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFF0) == 0x92C0 || \
39985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li		(GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFF0) == 0x88C0 ||  \
40985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li		(GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFFF) == 0x92D0 ||  \
41985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li		(GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFFF) == 0x92D1 ||  \
42985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li		(GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFFF) == 0x92D2 ||  \
43985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li		(GET_FIRMWARE_HDR_SIGNATURE(_pfwhdr) & 0xFFFF) == 0x92D3)
44985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li
45985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li/* Define a macro that takes an le32 word, converts it to host ordering,
46985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * right shifts by a specified count, creates a mask of the specified
47985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li * bit count, and extracts that number of bits.
48985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li */
49985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li
50985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define SHIFT_AND_MASK_LE(__pdesc, __shift, __mask)		\
51985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	((le32_to_cpu(*(((__le32 *)(__pdesc)))) >> (__shift)) &	\
52985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	BIT_LEN_MASK_32(__mask))
53985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li
54985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li/* Firmware Header(8-byte alinment required) */
55985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li/* --- LONG WORD 0 ---- */
56985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define GET_FIRMWARE_HDR_SIGNATURE(__fwhdr)		\
57985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SHIFT_AND_MASK_LE(__fwhdr, 0, 16)
58985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define GET_FIRMWARE_HDR_CATEGORY(__fwhdr)		\
59985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SHIFT_AND_MASK_LE(__fwhdr, 16, 8)
60985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define GET_FIRMWARE_HDR_FUNCTION(__fwhdr)		\
61985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SHIFT_AND_MASK_LE(__fwhdr, 24, 8)
62985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define GET_FIRMWARE_HDR_VERSION(__fwhdr)		\
63985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SHIFT_AND_MASK_LE(__fwhdr + 4, 0, 16)
64985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define GET_FIRMWARE_HDR_SUB_VER(__fwhdr)		\
65985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SHIFT_AND_MASK_LE(__fwhdr + 4, 16, 8)
66985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define GET_FIRMWARE_HDR_RSVD1(__fwhdr)			\
67985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SHIFT_AND_MASK_LE(__fwhdr + 4, 24, 8)
68985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li
69985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li/* --- LONG WORD 1 ---- */
70985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define GET_FIRMWARE_HDR_MONTH(__fwhdr)			\
71985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SHIFT_AND_MASK_LE(__fwhdr + 8, 0, 8)
72985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define GET_FIRMWARE_HDR_DATE(__fwhdr)			\
73985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SHIFT_AND_MASK_LE(__fwhdr + 8, 8, 8)
74985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define GET_FIRMWARE_HDR_HOUR(__fwhdr)			\
75985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SHIFT_AND_MASK_LE(__fwhdr + 8, 16, 8)
76985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define GET_FIRMWARE_HDR_MINUTE(__fwhdr)		\
77985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SHIFT_AND_MASK_LE(__fwhdr + 8, 24, 8)
78985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define GET_FIRMWARE_HDR_ROMCODE_SIZE(__fwhdr)		\
79985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SHIFT_AND_MASK_LE(__fwhdr + 12, 0, 16)
80985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define GET_FIRMWARE_HDR_RSVD2(__fwhdr)			\
81985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SHIFT_AND_MASK_LE(__fwhdr + 12, 16, 16)
82985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li
83985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li/* --- LONG WORD 2 ---- */
84985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define GET_FIRMWARE_HDR_SVN_IDX(__fwhdr)		\
85985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SHIFT_AND_MASK_LE(__fwhdr + 16, 0, 32)
86985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define GET_FIRMWARE_HDR_RSVD3(__fwhdr)			\
87985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SHIFT_AND_MASK_LE(__fwhdr + 20, 0, 32)
88985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li
89985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li/* --- LONG WORD 3 ---- */
90985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define GET_FIRMWARE_HDR_RSVD4(__fwhdr)			\
91985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SHIFT_AND_MASK_LE(__fwhdr + 24, 0, 32)
92985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define GET_FIRMWARE_HDR_RSVD5(__fwhdr)			\
93985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SHIFT_AND_MASK_LE(__fwhdr + 28, 0, 32)
94985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li
95985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define pagenum_128(_len) \
96985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	(u32)(((_len) >> 7) + ((_len) & 0x7F ? 1 : 0))
97985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li
98985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define SET_H2CCMD_PWRMODE_PARM_MODE(__ph2ccmd, __val)		\
99985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val)
100985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define SET_H2CCMD_PWRMODE_PARM_SMART_PS(__ph2ccmd, __val)	\
101985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 1, 0, 8, __val)
102985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define SET_H2CCMD_PWRMODE_PARM_BCN_PASS_TIME(__ph2ccmd, __val)	\
103985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 2, 0, 8, __val)
104985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define SET_H2CCMD_JOINBSSRPT_PARM_OPMODE(__ph2ccmd, __val)	\
105985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val)
106985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(__ph2ccmd, __val)	\
107985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val)
108985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(__ph2ccmd, __val)	\
109985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 1, 0, 8, __val)
110985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#define SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(__ph2ccmd, __val)	\
111985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 2, 0, 8, __val)
112985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li
113985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Listruct rtl92d_firmware_header {
114985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	u16 signature;
115985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	u8 category;
116985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	u8 function;
117985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	u16 version;
118985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	u8 subversion;
119985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	u8 rsvd1;
120985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li
121985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	u8 month;
122985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	u8 date;
123985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	u8 hour;
124985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	u8 minute;
125985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	u16 ramcodeSize;
126985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	u16 rsvd2;
127985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li
128985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	u32 svnindex;
129985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	u32 rsvd3;
130985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li
131985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	u32 rsvd4;
132985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li	u32 rsvd5;
133985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li};
134985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li
135985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Liint rtl92d_download_fw(struct ieee80211_hw *hw);
136985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Livoid rtl92d_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id,
137985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li			 u32 cmd_len, u8 *p_cmdbuffer);
138985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Livoid rtl92d_firmware_selfreset(struct ieee80211_hw *hw);
139985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Livoid rtl92d_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode);
140985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Livoid rtl92d_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished);
141985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Livoid rtl92d_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus);
142985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li
143985d4d3f6dced76f37c8c8d2528fcfe7773cc5f0Chaoming Li#endif
144