1 /******************************************************************************
2  * Copyright(c) 2008 - 2010 Realtek Corporation. All rights reserved.
3  *
4  * This program is distributed in the hope that it will be useful, but WITHOUT
5  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
7  * more details.
8  *
9  * You should have received a copy of the GNU General Public License along with
10  * this program; if not, write to the Free Software Foundation, Inc.,
11  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
12  *
13  * The full GNU General Public License is included in this distribution in the
14  * file called LICENSE.
15  *
16  * Contact Information:
17  * wlanfae <wlanfae@realtek.com>
18 ******************************************************************************/
19 #ifndef __INC_FIRMWARE_H
20 #define __INC_FIRMWARE_H
21 
22 #define RTL8190_CPU_START_OFFSET	0x80
23 
24 #define GET_COMMAND_PACKET_FRAG_THRESHOLD(v)	(4*(v/4) - 8)
25 
26 enum firmware_init_step {
27 	FW_INIT_STEP0_BOOT = 0,
28 	FW_INIT_STEP1_MAIN = 1,
29 	FW_INIT_STEP2_DATA = 2,
30 };
31 
32 enum opt_rst_type {
33 	OPT_SYSTEM_RESET = 0,
34 	OPT_FIRMWARE_RESET = 1,
35 };
36 
37 enum desc_packet_type {
38 	DESC_PACKET_TYPE_INIT = 0,
39 	DESC_PACKET_TYPE_NORMAL = 1,
40 };
41 
42 enum firmware_source {
43 	FW_SOURCE_IMG_FILE = 0,
44 	FW_SOURCE_HEADER_FILE = 1,
45 };
46 
47 enum firmware_status {
48 	FW_STATUS_0_INIT = 0,
49 	FW_STATUS_1_MOVE_BOOT_CODE = 1,
50 	FW_STATUS_2_MOVE_MAIN_CODE = 2,
51 	FW_STATUS_3_TURNON_CPU = 3,
52 	FW_STATUS_4_MOVE_DATA_CODE = 4,
53 	FW_STATUS_5_READY = 5,
54 };
55 
56 struct fw_seg_container {
57 	u16	seg_size;
58 	u8	*seg_ptr;
59 };
60 
61 struct rt_firmware {
62 	enum firmware_status firmware_status;
63 	u16		  cmdpacket_frag_thresold;
64 #define RTL8190_MAX_FIRMWARE_CODE_SIZE	64000
65 #define MAX_FW_INIT_STEP		3
66 	u8 firmware_buf[MAX_FW_INIT_STEP][RTL8190_MAX_FIRMWARE_CODE_SIZE];
67 	u16		  firmware_buf_size[MAX_FW_INIT_STEP];
68 };
69 
70 bool init_firmware(struct net_device *dev);
71 extern void firmware_init_param(struct net_device *dev);
72 
73 #endif
74