1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2009-2012 Realtek Corporation.*/
4 #ifndef __REALTEK_FIRMWARE92S_H__
5 #define __REALTEK_FIRMWARE92S_H__
7 #define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000
8 #define RTL8190_MAX_RAW_FIRMWARE_CODE_SIZE 90000
9 #define RTL8190_CPU_START_OFFSET 0x80
10 /* Firmware Local buffer size. 64k */
11 #define MAX_FIRMWARE_CODE_SIZE 0xFF00
13 #define RT_8192S_FIRMWARE_HDR_SIZE 80
14 #define RT_8192S_FIRMWARE_HDR_EXCLUDE_PRI_SIZE 32
16 /* support till 64 bit bus width OS */
17 #define MAX_DEV_ADDR_SIZE 8
18 #define MAX_FIRMWARE_INFORMATION_SIZE 32
19 #define MAX_802_11_HEADER_LENGTH (40 + \
20 MAX_FIRMWARE_INFORMATION_SIZE)
21 #define ENCRYPTION_MAX_OVERHEAD 128
22 #define MAX_FRAGMENT_COUNT 8
23 #define MAX_TRANSMIT_BUFFER_SIZE (1600 + \
24 (MAX_802_11_HEADER_LENGTH + \
25 ENCRYPTION_MAX_OVERHEAD) *\
28 #define H2C_TX_CMD_HDR_LEN 8
30 /* The following DM control code are for Reg0x364, */
31 #define FW_DIG_ENABLE_CTL BIT(0)
32 #define FW_HIGH_PWR_ENABLE_CTL BIT(1)
33 #define FW_SS_CTL BIT(2)
34 #define FW_RA_INIT_CTL BIT(3)
35 #define FW_RA_BG_CTL BIT(4)
36 #define FW_RA_N_CTL BIT(5)
37 #define FW_PWR_TRK_CTL BIT(6)
38 #define FW_IQK_CTL BIT(7)
39 #define FW_FA_CTL BIT(8)
40 #define FW_DRIVER_CTRL_DM_CTL BIT(9)
41 #define FW_PAPE_CTL_BY_SW_HW BIT(10)
42 #define FW_DISABLE_ALL_DM 0
43 #define FW_PWR_TRK_PARAM_CLR 0x0000ffff
44 #define FW_RA_PARAM_CLR 0xffff0000
46 enum desc_packet_type
{
47 DESC_PACKET_TYPE_INIT
= 0,
48 DESC_PACKET_TYPE_NORMAL
= 1,
51 /* 8-bytes alignment required */
53 /* --- long word 0 ---- */
54 /* 0x12: CE product, 0x92: IT product */
56 /* 0x87: CE product, 0x81: IT product */
58 /* 0x81: PCI-AP, 01:PCIe, 02: 92S-U,
59 * 0x82: USB-AP, 0x12: 72S-U, 03:SDIO */
61 /* the same value as reigster value */
63 /* customer ID low byte */
65 /* customer ID high byte */
67 /* 0x11: 1T1R, 0x12: 1T2R,
68 * 0x92: 1T2R turbo, 0x22: 2T2R */
70 /* 4: 4EP, 6: 6EP, 11: 11EP */
73 /* --- long word 1 ---- */
74 /* regulatory class bit map 0 */
75 u8 regulatory_class_0
;
76 /* regulatory class bit map 1 */
77 u8 regulatory_class_1
;
78 /* regulatory class bit map 2 */
79 u8 regulatory_class_2
;
80 /* regulatory class bit map 3 */
81 u8 regulatory_class_3
;
82 /* 0:SWSI, 1:HWSI, 2:HWPI */
88 /* --- long word 2 ---- */
89 /* 0x00: normal, 0x03: MACLBK, 0x01: PHYLBK */
91 /* 1: for MP use, 0: for normal
92 * driver (to be discussed) */
101 /* --- long word 3 ---- */
104 /* 40MHz BW enable */
105 /* 4181 convert AMSDU to AMPDU, 0: disable */
108 /* 11n AMPDU enable */
110 /* FW offloads, 0: driver handles */
111 u8 rate_control_offload
;
112 /* FW offloads, 0: driver handles */
113 u8 aggregation_offload
;
117 /* --- long word 4 ---- */
118 /* 1. FW offloads, 0: driver handles */
120 /* 2. FW offloads, 0: driver handles */
122 /* 3. FW offloads, 0: driver handles */
124 /* 4. FW offloads, 0: driver handles */
125 u8 tcp_checksum_offload
;
126 /* 5. FW offloads, 0: driver handles */
128 /* 6. FW offloads, 0: driver handles */
129 u8 ps_control_offload
;
130 /* 7. FW offloads, 0: driver handles */
134 /* --- long word 5 ---- */
135 /* tcp tx packet length low byte */
136 u8 tcp_tx_frame_len_L
;
137 /* tcp tx packet length high byte */
138 u8 tcp_tx_frame_len_H
;
139 /* tcp rx packet length low byte */
140 u8 tcp_rx_frame_len_L
;
141 /* tcp rx packet length high byte */
142 u8 tcp_rx_frame_len_H
;
149 /* 8-byte alinment required */
152 /* --- LONG WORD 0 ---- */
154 /* 0x8000 ~ 0x8FFF for FPGA version,
155 * 0x0000 ~ 0x7FFF for ASIC version, */
157 /* define the size of boot loader */
161 /* --- LONG WORD 1 ---- */
162 /* define the size of FW in IMEM */
164 /* define the size of FW in SRAM */
167 /* --- LONG WORD 2 ---- */
168 /* define the size of DMEM variable */
172 /* --- LONG WORD 3 ---- */
176 struct fw_priv fwpriv
;
182 FW_STATUS_LOAD_IMEM
= 1,
183 FW_STATUS_LOAD_EMEM
= 2,
184 FW_STATUS_LOAD_DMEM
= 3,
189 struct fw_hdr
*pfwheader
;
190 enum fw_status fwstatus
;
192 u8 fw_imem
[RTL8190_MAX_FIRMWARE_CODE_SIZE
];
193 u8 fw_emem
[RTL8190_MAX_FIRMWARE_CODE_SIZE
];
196 u8 sz_fw_tmpbuffer
[RTL8190_MAX_RAW_FIRMWARE_CODE_SIZE
];
197 u32 sz_fw_tmpbufferlen
;
198 u16 cmdpacket_fragthresold
;
201 struct h2c_set_pwrmode_parm
{
203 u8 flag_low_traffic_en
;
205 u8 flag_rf_low_snr_en
;
210 /* beacon TO (ms). ¡§=0¡¨ no limit. */
213 /* only for VOIP mode. */
221 struct h2c_joinbss_rpt_parm
{
230 /* EAPOL-Key Key Confirmation Key (KCK) */
232 /* EAPOL-Key Key Encryption Key (KEK) */
234 /* Temporal Key 1 (TK1) */
237 /* Temporal Key 2 (TK2) */
246 struct h2c_wpa_two_way_parm
{
247 /* algorithm TKIP or AES */
250 struct h2c_wpa_ptk wpa_ptk_value
;
254 FW_H2C_SETPWRMODE
= 0,
255 FW_H2C_JOINBSSRPT
= 1,
256 FW_H2C_WOWLAN_UPDATE_GTK
= 2,
257 FW_H2C_WOWLAN_UPDATE_IV
= 3,
258 FW_H2C_WOWLAN_OFFLOAD
= 4,
262 H2C_READ_MACREG_CMD
, /*0*/
263 H2C_WRITE_MACREG_CMD
,
267 H2C_WRITERF_CMD
, /*5*/
269 H2C_WRITE_EEPROM_CMD
,
272 H2C_READ_CAM_CMD
, /*10*/
277 H2C_DISCONNECT_CMD
, /*15*/
282 H2C_SETKEY_CMD
, /*20*/
286 H2C_SETSTAPWRSTATE_CMD
,
287 H2C_SETBASICRATE_CMD
, /*25*/
288 H2C_GETBASICRATE_CMD
,
292 H2C_GETPHYINFO_CMD
, /*30*/
297 H2C_SETATIM_CMD
, /*35*/
302 H2C_GETCCXREPORT_CMD
, /*40*/
303 H2C_GETDTMREPORT_CMD
,
304 H2C_GETTXRATESTATICS_CMD
,
305 H2C_SETUSBSUSPEND_CMD
,
308 H2C_WOWLAN_UPDATE_GTK_CMD
,
309 H2C_WOWLAN_FW_OFFLOAD
,
312 H2C_WOWLAN_UPDATE_IV_CMD
, /*50*/
316 /* The following macros are used for FW
317 * CMD map and parameter updated. */
318 #define FW_CMD_IO_CLR(rtlpriv, _bit) \
321 rtlpriv->rtlhal.fwcmd_iomap &= (~_bit); \
324 #define FW_CMD_IO_UPDATE(rtlpriv, _val) \
325 rtlpriv->rtlhal.fwcmd_iomap = _val;
327 #define FW_CMD_IO_SET(rtlpriv, _val) \
329 rtl_write_word(rtlpriv, LBUS_MON_ADDR, (u16)_val); \
330 FW_CMD_IO_UPDATE(rtlpriv, _val); \
333 #define FW_CMD_PARA_SET(rtlpriv, _val) \
335 rtl_write_dword(rtlpriv, LBUS_ADDR_MASK, _val); \
336 rtlpriv->rtlhal.fwcmd_ioparam = _val; \
339 #define FW_CMD_IO_QUERY(rtlpriv) \
340 (u16)(rtlpriv->rtlhal.fwcmd_iomap)
341 #define FW_CMD_IO_PARA_QUERY(rtlpriv) \
342 ((u32)(rtlpriv->rtlhal.fwcmd_ioparam))
344 int rtl92s_download_fw(struct ieee80211_hw
*hw
);
345 void rtl92s_set_fw_pwrmode_cmd(struct ieee80211_hw
*hw
, u8 mode
);
346 void rtl92s_set_fw_joinbss_report_cmd(struct ieee80211_hw
*hw
,
347 u8 mstatus
, u8 ps_qosinfo
);