1 /******************************************************************************
3 * Copyright(c) 2009-2012 Realtek Corporation.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * The full GNU General Public License is included in this distribution in the
15 * file called LICENSE.
17 * Contact Information:
18 * wlanfae <wlanfae@realtek.com>
19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park,
20 * Hsinchu 300, Taiwan.
22 * Larry Finger <Larry.Finger@lwfinger.net>
24 *****************************************************************************/
25 #ifndef __REALTEK_FIRMWARE92S_H__
26 #define __REALTEK_FIRMWARE92S_H__
28 #define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000
29 #define RTL8190_MAX_RAW_FIRMWARE_CODE_SIZE 90000
30 #define RTL8190_CPU_START_OFFSET 0x80
31 /* Firmware Local buffer size. 64k */
32 #define MAX_FIRMWARE_CODE_SIZE 0xFF00
34 #define RT_8192S_FIRMWARE_HDR_SIZE 80
35 #define RT_8192S_FIRMWARE_HDR_EXCLUDE_PRI_SIZE 32
37 /* support till 64 bit bus width OS */
38 #define MAX_DEV_ADDR_SIZE 8
39 #define MAX_FIRMWARE_INFORMATION_SIZE 32
40 #define MAX_802_11_HEADER_LENGTH (40 + \
41 MAX_FIRMWARE_INFORMATION_SIZE)
42 #define ENCRYPTION_MAX_OVERHEAD 128
43 #define MAX_FRAGMENT_COUNT 8
44 #define MAX_TRANSMIT_BUFFER_SIZE (1600 + \
45 (MAX_802_11_HEADER_LENGTH + \
46 ENCRYPTION_MAX_OVERHEAD) *\
49 #define H2C_TX_CMD_HDR_LEN 8
51 /* The following DM control code are for Reg0x364, */
52 #define FW_DIG_ENABLE_CTL BIT(0)
53 #define FW_HIGH_PWR_ENABLE_CTL BIT(1)
54 #define FW_SS_CTL BIT(2)
55 #define FW_RA_INIT_CTL BIT(3)
56 #define FW_RA_BG_CTL BIT(4)
57 #define FW_RA_N_CTL BIT(5)
58 #define FW_PWR_TRK_CTL BIT(6)
59 #define FW_IQK_CTL BIT(7)
60 #define FW_FA_CTL BIT(8)
61 #define FW_DRIVER_CTRL_DM_CTL BIT(9)
62 #define FW_PAPE_CTL_BY_SW_HW BIT(10)
63 #define FW_DISABLE_ALL_DM 0
64 #define FW_PWR_TRK_PARAM_CLR 0x0000ffff
65 #define FW_RA_PARAM_CLR 0xffff0000
67 enum desc_packet_type {
68 DESC_PACKET_TYPE_INIT = 0,
69 DESC_PACKET_TYPE_NORMAL = 1,
72 /* 8-bytes alignment required */
74 /* --- long word 0 ---- */
75 /* 0x12: CE product, 0x92: IT product */
77 /* 0x87: CE product, 0x81: IT product */
79 /* 0x81: PCI-AP, 01:PCIe, 02: 92S-U,
80 * 0x82: USB-AP, 0x12: 72S-U, 03:SDIO */
82 /* the same value as reigster value */
84 /* customer ID low byte */
86 /* customer ID high byte */
88 /* 0x11: 1T1R, 0x12: 1T2R,
89 * 0x92: 1T2R turbo, 0x22: 2T2R */
91 /* 4: 4EP, 6: 6EP, 11: 11EP */
94 /* --- long word 1 ---- */
95 /* regulatory class bit map 0 */
96 u8 regulatory_class_0;
97 /* regulatory class bit map 1 */
98 u8 regulatory_class_1;
99 /* regulatory class bit map 2 */
100 u8 regulatory_class_2;
101 /* regulatory class bit map 3 */
102 u8 regulatory_class_3;
103 /* 0:SWSI, 1:HWSI, 2:HWPI */
109 /* --- long word 2 ---- */
110 /* 0x00: normal, 0x03: MACLBK, 0x01: PHYLBK */
112 /* 1: for MP use, 0: for normal
113 * driver (to be discussed) */
122 /* --- long word 3 ---- */
125 /* 40MHz BW enable */
126 /* 4181 convert AMSDU to AMPDU, 0: disable */
129 /* 11n AMPDU enable */
131 /* FW offloads, 0: driver handles */
132 u8 rate_control_offload;
133 /* FW offloads, 0: driver handles */
134 u8 aggregation_offload;
138 /* --- long word 4 ---- */
139 /* 1. FW offloads, 0: driver handles */
141 /* 2. FW offloads, 0: driver handles */
143 /* 3. FW offloads, 0: driver handles */
145 /* 4. FW offloads, 0: driver handles */
146 u8 tcp_checksum_offload;
147 /* 5. FW offloads, 0: driver handles */
149 /* 6. FW offloads, 0: driver handles */
150 u8 ps_control_offload;
151 /* 7. FW offloads, 0: driver handles */
155 /* --- long word 5 ---- */
156 /* tcp tx packet length low byte */
157 u8 tcp_tx_frame_len_L;
158 /* tcp tx packet length high byte */
159 u8 tcp_tx_frame_len_H;
160 /* tcp rx packet length low byte */
161 u8 tcp_rx_frame_len_L;
162 /* tcp rx packet length high byte */
163 u8 tcp_rx_frame_len_H;
170 /* 8-byte alinment required */
173 /* --- LONG WORD 0 ---- */
175 /* 0x8000 ~ 0x8FFF for FPGA version,
176 * 0x0000 ~ 0x7FFF for ASIC version, */
178 /* define the size of boot loader */
182 /* --- LONG WORD 1 ---- */
183 /* define the size of FW in IMEM */
185 /* define the size of FW in SRAM */
188 /* --- LONG WORD 2 ---- */
189 /* define the size of DMEM variable */
193 /* --- LONG WORD 3 ---- */
197 struct fw_priv fwpriv;
203 FW_STATUS_LOAD_IMEM = 1,
204 FW_STATUS_LOAD_EMEM = 2,
205 FW_STATUS_LOAD_DMEM = 3,
210 struct fw_hdr *pfwheader;
211 enum fw_status fwstatus;
213 u8 fw_imem[RTL8190_MAX_FIRMWARE_CODE_SIZE];
214 u8 fw_emem[RTL8190_MAX_FIRMWARE_CODE_SIZE];
217 u8 sz_fw_tmpbuffer[RTL8190_MAX_RAW_FIRMWARE_CODE_SIZE];
218 u32 sz_fw_tmpbufferlen;
219 u16 cmdpacket_fragthresold;
222 struct h2c_set_pwrmode_parm {
224 u8 flag_low_traffic_en;
226 u8 flag_rf_low_snr_en;
231 /* beacon TO (ms). ¡§=0¡¨ no limit. */
234 /* only for VOIP mode. */
242 struct h2c_joinbss_rpt_parm {
251 /* EAPOL-Key Key Confirmation Key (KCK) */
253 /* EAPOL-Key Key Encryption Key (KEK) */
255 /* Temporal Key 1 (TK1) */
258 /* Temporal Key 2 (TK2) */
267 struct h2c_wpa_two_way_parm {
268 /* algorithm TKIP or AES */
271 struct h2c_wpa_ptk wpa_ptk_value;
275 FW_H2C_SETPWRMODE = 0,
276 FW_H2C_JOINBSSRPT = 1,
277 FW_H2C_WOWLAN_UPDATE_GTK = 2,
278 FW_H2C_WOWLAN_UPDATE_IV = 3,
279 FW_H2C_WOWLAN_OFFLOAD = 4,
283 H2C_READ_MACREG_CMD, /*0*/
284 H2C_WRITE_MACREG_CMD,
288 H2C_WRITERF_CMD, /*5*/
290 H2C_WRITE_EEPROM_CMD,
293 H2C_READ_CAM_CMD, /*10*/
298 H2C_DISCONNECT_CMD, /*15*/
303 H2C_SETKEY_CMD, /*20*/
307 H2C_SETSTAPWRSTATE_CMD,
308 H2C_SETBASICRATE_CMD, /*25*/
309 H2C_GETBASICRATE_CMD,
313 H2C_GETPHYINFO_CMD, /*30*/
318 H2C_SETATIM_CMD, /*35*/
323 H2C_GETCCXREPORT_CMD, /*40*/
324 H2C_GETDTMREPORT_CMD,
325 H2C_GETTXRATESTATICS_CMD,
326 H2C_SETUSBSUSPEND_CMD,
329 H2C_WOWLAN_UPDATE_GTK_CMD,
330 H2C_WOWLAN_FW_OFFLOAD,
333 H2C_WOWLAN_UPDATE_IV_CMD, /*50*/
337 /* The following macros are used for FW
338 * CMD map and parameter updated. */
339 #define FW_CMD_IO_CLR(rtlpriv, _Bit) \
342 rtlpriv->rtlhal.fwcmd_iomap &= (~_Bit); \
345 #define FW_CMD_IO_UPDATE(rtlpriv, _val) \
346 rtlpriv->rtlhal.fwcmd_iomap = _val;
348 #define FW_CMD_IO_SET(rtlpriv, _val) \
350 rtl_write_word(rtlpriv, LBUS_MON_ADDR, (u16)_val); \
351 FW_CMD_IO_UPDATE(rtlpriv, _val); \
354 #define FW_CMD_PARA_SET(rtlpriv, _val) \
356 rtl_write_dword(rtlpriv, LBUS_ADDR_MASK, _val); \
357 rtlpriv->rtlhal.fwcmd_ioparam = _val; \
360 #define FW_CMD_IO_QUERY(rtlpriv) \
361 (u16)(rtlpriv->rtlhal.fwcmd_iomap)
362 #define FW_CMD_IO_PARA_QUERY(rtlpriv) \
363 ((u32)(rtlpriv->rtlhal.fwcmd_ioparam))
365 int rtl92s_download_fw(struct ieee80211_hw *hw);
366 void rtl92s_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode);
367 void rtl92s_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw,
368 u8 mstatus, u8 ps_qosinfo);