xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/nxp/mlan/mlan_init.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /** @file mlan_init.h
2  *
3  *  @brief This file defines the FW initialization data
4  *  structures.
5  *
6  *
7  *  Copyright 2008-2021 NXP
8  *
9  *  This software file (the File) is distributed by NXP
10  *  under the terms of the GNU General Public License Version 2, June 1991
11  *  (the License).  You may use, redistribute and/or modify the File in
12  *  accordance with the terms and conditions of the License, a copy of which
13  *  is available by writing to the Free Software Foundation, Inc.,
14  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
15  *  worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
16  *
17  *  THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
18  *  IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
19  *  ARE EXPRESSLY DISCLAIMED.  The License provides additional details about
20  *  this warranty disclaimer.
21  *
22  */
23 
24 /******************************************************
25 Change log:
26     10/13/2008: initial version
27 ******************************************************/
28 
29 #ifndef _MLAN_INIT_H_
30 #define _MLAN_INIT_H_
31 
32 /** Tx buffer size for firmware download*/
33 #define FW_DNLD_TX_BUF_SIZE 2312
34 /** Rx buffer size for firmware download*/
35 #define FW_DNLD_RX_BUF_SIZE 2048
36 /** Max firmware retry */
37 #define MAX_FW_RETRY 3
38 
39 /** Firmware has last block */
40 #define FW_HAS_LAST_BLOCK 0x00000004
41 /** CMD id for CMD4 */
42 #define FW_CMD_4 0x00000004
43 /** CMD id for CMD6 */
44 #define FW_CMD_6 0x00000006
45 /** CMD id for CMD7 */
46 #define FW_CMD_7 0x00000007
47 /** CMD id for CMD10 */
48 #define FW_CMD_10 0x0000000a
49 
50 /** Firmware data transmit size */
51 #define FW_DATA_XMIT_SIZE (sizeof(FWHeader) + DataLength + sizeof(t_u32))
52 
53 /** FWHeader */
54 typedef MLAN_PACK_START struct _FWHeader {
55 	/** FW download command */
56 	t_u32 dnld_cmd;
57 	/** FW base address */
58 	t_u32 base_addr;
59 	/** FW data length */
60 	t_u32 data_length;
61 	/** FW CRC */
62 	t_u32 crc;
63 } MLAN_PACK_END FWHeader;
64 
65 /** FWData */
66 typedef MLAN_PACK_START struct _FWData {
67 	/** FW data header */
68 	FWHeader fw_header;
69 	/** FW data sequence number */
70 	t_u32 seq_num;
71 	/** FW data buffer */
72 	t_u8 data[1];
73 } MLAN_PACK_END FWData;
74 
75 /** FWSyncHeader */
76 typedef MLAN_PACK_START struct _FWSyncHeader {
77 	/** FW sync header command */
78 	t_u32 cmd;
79 	/** FW sync header sequence number */
80 	t_u32 seq_num;
81 	/** Extended header */
82 	t_u32 magic;
83 	/** Chip rev */
84 	t_u32 chip_rev;
85 	/** Strap */
86 	t_u32 strap;
87 	/** Status */
88 	t_u32 status;
89 	/** Offset */
90 	t_u32 offset;
91 } MLAN_PACK_END FWSyncHeader;
92 
93 /** FW Sync pkt */
94 typedef MLAN_PACK_START struct _FWSyncPkt {
95 	/** pkt type */
96 	t_u32 pkt_type;
97 	/** FW sync header command */
98 	t_u32 cmd;
99 	/** FW sync header sequence number */
100 	t_u32 seq_num;
101 	/** chip rev */
102 	t_u32 chip_rev;
103 	/** fw status */
104 	t_u32 fw_ready;
105 } MLAN_PACK_END FWSyncPkt;
106 
107 #ifdef BIG_ENDIAN_SUPPORT
108 /** Convert sequence number and command fields
109  *  of fwheader to correct endian format
110  */
111 #define endian_convert_syncfwheader(x)                                         \
112 	{                                                                      \
113 		(x)->cmd = wlan_le32_to_cpu((x)->cmd);                         \
114 		(x)->seq_num = wlan_le32_to_cpu((x)->seq_num);                 \
115 		(x)->status = wlan_le32_to_cpu((x)->status);                   \
116 		(x)->offset = wlan_le32_to_cpu((x)->offset);                   \
117 	}
118 #else
119 /** Convert sequence number and command fields
120  *  of fwheader to correct endian format
121  */
122 #define endian_convert_syncfwheader(x)
123 #endif /* BIG_ENDIAN_SUPPORT */
124 
125 #endif /* _MLAN_INIT_H_ */
126