1 /****************************************************************************** 2 * 3 * Copyright(c) 2009-2013 Realtek Corporation. 4 * 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. 8 * 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 12 * more details. 13 * 14 * The full GNU General Public License is included in this distribution in the 15 * file called LICENSE. 16 * 17 * Contact Information: 18 * wlanfae <wlanfae@realtek.com> 19 * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, 20 * Hsinchu 300, Taiwan. 21 * Larry Finger <Larry.Finger@lwfinger.net> 22 * 23 *****************************************************************************/ 24 25 #ifndef __RTL92C__FW__H__ 26 #define __RTL92C__FW__H__ 27 28 #define FW_8192C_SIZE 0x8000 29 #define FW_8192C_START_ADDRESS 0x1000 30 #define FW_8192C_END_ADDRESS 0x5FFF 31 #define FW_8192C_PAGE_SIZE 4096 32 #define FW_8192C_POLLING_DELAY 5 33 #define FW_8192C_POLLING_TIMEOUT_COUNT 3000 34 35 #define IS_FW_HEADER_EXIST(_pfwhdr) \ 36 ((le16_to_cpu(_pfwhdr->signature) & 0xFFFF) == 0x88E1) 37 #define USE_OLD_WOWLAN_DEBUG_FW 0 38 39 #define H2C_88E_RSVDPAGE_LOC_LEN 5 40 #define H2C_88E_PWEMODE_LENGTH 5 41 #define H2C_88E_JOINBSSRPT_LENGTH 1 42 #define H2C_88E_AP_OFFLOAD_LENGTH 3 43 #define H2C_88E_WOWLAN_LENGTH 3 44 #define H2C_88E_KEEP_ALIVE_CTRL_LENGTH 3 45 #if (USE_OLD_WOWLAN_DEBUG_FW == 0) 46 #define H2C_88E_REMOTE_WAKE_CTRL_LEN 1 47 #else 48 #define H2C_88E_REMOTE_WAKE_CTRL_LEN 3 49 #endif 50 #define H2C_88E_AOAC_GLOBAL_INFO_LEN 2 51 #define H2C_88E_AOAC_RSVDPAGE_LOC_LEN 7 52 53 /* Fw PS state for RPWM. 54 *BIT[2:0] = HW state 55 *BIT[3] = Protocol PS state, 56 *1: register active state , 0: register sleep state 57 *BIT[4] = sub-state 58 */ 59 #define FW_PS_GO_ON BIT(0) 60 #define FW_PS_TX_NULL BIT(1) 61 #define FW_PS_RF_ON BIT(2) 62 #define FW_PS_REGISTER_ACTIVE BIT(3) 63 64 #define FW_PS_DPS BIT(0) 65 #define FW_PS_LCLK (FW_PS_DPS) 66 #define FW_PS_RF_OFF BIT(1) 67 #define FW_PS_ALL_ON BIT(2) 68 #define FW_PS_ST_ACTIVE BIT(3) 69 #define FW_PS_ISR_ENABLE BIT(4) 70 #define FW_PS_IMR_ENABLE BIT(5) 71 72 73 #define FW_PS_ACK BIT(6) 74 #define FW_PS_TOGGLE BIT(7) 75 76 /* 88E RPWM value*/ 77 /* BIT[0] = 1: 32k, 0: 40M*/ 78 #define FW_PS_CLOCK_OFF BIT(0) /* 32k*/ 79 #define FW_PS_CLOCK_ON 0 /*40M*/ 80 81 #define FW_PS_STATE_MASK (0x0F) 82 #define FW_PS_STATE_HW_MASK (0x07) 83 /*ISR_ENABLE, IMR_ENABLE, and PS mode should be inherited.*/ 84 #define FW_PS_STATE_INT_MASK (0x3F) 85 86 #define FW_PS_STATE(x) (FW_PS_STATE_MASK & (x)) 87 #define FW_PS_STATE_HW(x) (FW_PS_STATE_HW_MASK & (x)) 88 #define FW_PS_STATE_INT(x) (FW_PS_STATE_INT_MASK & (x)) 89 #define FW_PS_ISR_VAL(x) ((x) & 0x70) 90 #define FW_PS_IMR_MASK(x) ((x) & 0xDF) 91 #define FW_PS_KEEP_IMR(x) ((x) & 0x20) 92 93 #define FW_PS_STATE_S0 (FW_PS_DPS) 94 #define FW_PS_STATE_S1 (FW_PS_LCLK) 95 #define FW_PS_STATE_S2 (FW_PS_RF_OFF) 96 #define FW_PS_STATE_S3 (FW_PS_ALL_ON) 97 #define FW_PS_STATE_S4 ((FW_PS_ST_ACTIVE) | (FW_PS_ALL_ON)) 98 /* ((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE))*/ 99 #define FW_PS_STATE_ALL_ON_88E (FW_PS_CLOCK_ON) 100 /* (FW_PS_RF_ON)*/ 101 #define FW_PS_STATE_RF_ON_88E (FW_PS_CLOCK_ON) 102 /* 0x0*/ 103 #define FW_PS_STATE_RF_OFF_88E (FW_PS_CLOCK_ON) 104 /* (FW_PS_STATE_RF_OFF)*/ 105 #define FW_PS_STATE_RF_OFF_LOW_PWR_88E (FW_PS_CLOCK_OFF) 106 107 #define FW_PS_STATE_ALL_ON_92C (FW_PS_STATE_S4) 108 #define FW_PS_STATE_RF_ON_92C (FW_PS_STATE_S3) 109 #define FW_PS_STATE_RF_OFF_92C (FW_PS_STATE_S2) 110 #define FW_PS_STATE_RF_OFF_LOW_PWR_92C (FW_PS_STATE_S1) 111 112 /* For 88E H2C PwrMode Cmd ID 5.*/ 113 #define FW_PWR_STATE_ACTIVE ((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE)) 114 #define FW_PWR_STATE_RF_OFF 0 115 116 #define FW_PS_IS_ACK(x) ((x) & FW_PS_ACK) 117 #define FW_PS_IS_CLK_ON(x) ((x) & (FW_PS_RF_OFF | FW_PS_ALL_ON)) 118 #define FW_PS_IS_RF_ON(x) ((x) & (FW_PS_ALL_ON)) 119 #define FW_PS_IS_ACTIVE(x) ((x) & (FW_PS_ST_ACTIVE)) 120 #define FW_PS_IS_CPWM_INT(x) ((x) & 0x40) 121 122 #define FW_CLR_PS_STATE(x) ((x) = ((x) & (0xF0))) 123 124 #define IS_IN_LOW_POWER_STATE_88E(fwpsstate) \ 125 (FW_PS_STATE(fwpsstate) == FW_PS_CLOCK_OFF) 126 127 #define FW_PWR_STATE_ACTIVE ((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE)) 128 #define FW_PWR_STATE_RF_OFF 0 129 130 enum rtl8188e_h2c_cmd { 131 H2C_88E_RSVDPAGE = 0, 132 H2C_88E_JOINBSSRPT = 1, 133 H2C_88E_SCAN = 2, 134 H2C_88E_KEEP_ALIVE_CTRL = 3, 135 H2C_88E_DISCONNECT_DECISION = 4, 136 #if (USE_OLD_WOWLAN_DEBUG_FW == 1) 137 H2C_88E_WO_WLAN = 5, 138 #endif 139 H2C_88E_INIT_OFFLOAD = 6, 140 #if (USE_OLD_WOWLAN_DEBUG_FW == 1) 141 H2C_88E_REMOTE_WAKE_CTRL = 7, 142 #endif 143 H2C_88E_AP_OFFLOAD = 8, 144 H2C_88E_BCN_RSVDPAGE = 9, 145 H2C_88E_PROBERSP_RSVDPAGE = 10, 146 147 H2C_88E_SETPWRMODE = 0x20, 148 H2C_88E_PS_TUNING_PARA = 0x21, 149 H2C_88E_PS_TUNING_PARA2 = 0x22, 150 H2C_88E_PS_LPS_PARA = 0x23, 151 H2C_88E_P2P_PS_OFFLOAD = 024, 152 153 #if (USE_OLD_WOWLAN_DEBUG_FW == 0) 154 H2C_88E_WO_WLAN = 0x80, 155 H2C_88E_REMOTE_WAKE_CTRL = 0x81, 156 H2C_88E_AOAC_GLOBAL_INFO = 0x82, 157 H2C_88E_AOAC_RSVDPAGE = 0x83, 158 #endif 159 /*Not defined in new 88E H2C CMD Format*/ 160 H2C_88E_RA_MASK, 161 H2C_88E_SELECTIVE_SUSPEND_ROF_CMD, 162 H2C_88E_P2P_PS_MODE, 163 H2C_88E_PSD_RESULT, 164 /*Not defined CTW CMD for P2P yet*/ 165 H2C_88E_P2P_PS_CTW_CMD, 166 MAX_88E_H2CCMD 167 }; 168 169 #define pagenum_128(_len) (u32)(((_len)>>7) + ((_len)&0x7F ? 1 : 0)) 170 171 #define SET_88E_H2CCMD_WOWLAN_FUNC_ENABLE(__cmd, __value) \ 172 SET_BITS_TO_LE_1BYTE(__cmd, 0, 1, __value) 173 #define SET_88E_H2CCMD_WOWLAN_PATTERN_MATCH_ENABLE(__cmd, __value) \ 174 SET_BITS_TO_LE_1BYTE(__cmd, 1, 1, __value) 175 #define SET_88E_H2CCMD_WOWLAN_MAGIC_PKT_ENABLE(__cmd, __value) \ 176 SET_BITS_TO_LE_1BYTE(__cmd, 2, 1, __value) 177 #define SET_88E_H2CCMD_WOWLAN_UNICAST_PKT_ENABLE(__cmd, __value) \ 178 SET_BITS_TO_LE_1BYTE(__cmd, 3, 1, __value) 179 #define SET_88E_H2CCMD_WOWLAN_ALL_PKT_DROP(__cmd, __value) \ 180 SET_BITS_TO_LE_1BYTE(__cmd, 4, 1, __value) 181 #define SET_88E_H2CCMD_WOWLAN_GPIO_ACTIVE(__cmd, __value) \ 182 SET_BITS_TO_LE_1BYTE(__cmd, 5, 1, __value) 183 #define SET_88E_H2CCMD_WOWLAN_REKEY_WAKE_UP(__cmd, __value) \ 184 SET_BITS_TO_LE_1BYTE(__cmd, 6, 1, __value) 185 #define SET_88E_H2CCMD_WOWLAN_DISCONNECT_WAKE_UP(__cmd, __value) \ 186 SET_BITS_TO_LE_1BYTE(__cmd, 7, 1, __value) 187 #define SET_88E_H2CCMD_WOWLAN_GPIONUM(__cmd, __value) \ 188 SET_BITS_TO_LE_1BYTE((__cmd)+1, 0, 8, __value) 189 #define SET_88E_H2CCMD_WOWLAN_GPIO_DURATION(__cmd, __value) \ 190 SET_BITS_TO_LE_1BYTE((__cmd)+2, 0, 8, __value) 191 192 193 #define SET_H2CCMD_PWRMODE_PARM_MODE(__ph2ccmd, __val) \ 194 SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val) 195 #define SET_H2CCMD_PWRMODE_PARM_RLBM(__cmd, __value) \ 196 SET_BITS_TO_LE_1BYTE((__cmd)+1, 0, 4, __value) 197 #define SET_H2CCMD_PWRMODE_PARM_SMART_PS(__cmd, __value) \ 198 SET_BITS_TO_LE_1BYTE((__cmd)+1, 4, 4, __value) 199 #define SET_H2CCMD_PWRMODE_PARM_AWAKE_INTERVAL(__cmd, __value) \ 200 SET_BITS_TO_LE_1BYTE((__cmd)+2, 0, 8, __value) 201 #define SET_H2CCMD_PWRMODE_PARM_ALL_QUEUE_UAPSD(__cmd, __value) \ 202 SET_BITS_TO_LE_1BYTE((__cmd)+3, 0, 8, __value) 203 #define SET_H2CCMD_PWRMODE_PARM_PWR_STATE(__cmd, __value) \ 204 SET_BITS_TO_LE_1BYTE((__cmd)+4, 0, 8, __value) 205 #define GET_88E_H2CCMD_PWRMODE_PARM_MODE(__cmd) \ 206 LE_BITS_TO_1BYTE(__cmd, 0, 8) 207 208 #define SET_H2CCMD_JOINBSSRPT_PARM_OPMODE(__ph2ccmd, __val) \ 209 SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val) 210 #define SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(__ph2ccmd, __val) \ 211 SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val) 212 #define SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(__ph2ccmd, __val) \ 213 SET_BITS_TO_LE_1BYTE((__ph2ccmd)+1, 0, 8, __val) 214 #define SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(__ph2ccmd, __val) \ 215 SET_BITS_TO_LE_1BYTE((__ph2ccmd)+2, 0, 8, __val) 216 217 /* AP_OFFLOAD */ 218 #define SET_H2CCMD_AP_OFFLOAD_ON(__cmd, __value) \ 219 SET_BITS_TO_LE_1BYTE(__cmd, 0, 8, __value) 220 #define SET_H2CCMD_AP_OFFLOAD_HIDDEN(__cmd, __value) \ 221 SET_BITS_TO_LE_1BYTE((__cmd)+1, 0, 8, __value) 222 #define SET_H2CCMD_AP_OFFLOAD_DENYANY(__cmd, __value) \ 223 SET_BITS_TO_LE_1BYTE((__cmd)+2, 0, 8, __value) 224 #define SET_H2CCMD_AP_OFFLOAD_WAKEUP_EVT_RPT(__cmd, __value) \ 225 SET_BITS_TO_LE_1BYTE((__cmd)+3, 0, 8, __value) 226 227 /* Keep Alive Control*/ 228 #define SET_88E_H2CCMD_KEEP_ALIVE_ENABLE(__cmd, __value) \ 229 SET_BITS_TO_LE_1BYTE(__cmd, 0, 1, __value) 230 #define SET_88E_H2CCMD_KEEP_ALIVE_ACCPEPT_USER_DEFINED(__cmd, __value) \ 231 SET_BITS_TO_LE_1BYTE(__cmd, 1, 1, __value) 232 #define SET_88E_H2CCMD_KEEP_ALIVE_PERIOD(__cmd, __value) \ 233 SET_BITS_TO_LE_1BYTE((__cmd)+1, 0, 8, __value) 234 235 /*REMOTE_WAKE_CTRL */ 236 #define SET_88E_H2CCMD_REMOTE_WAKE_CTRL_EN(__cmd, __value) \ 237 SET_BITS_TO_LE_1BYTE(__cmd, 0, 1, __value) 238 #if (USE_OLD_WOWLAN_DEBUG_FW == 0) 239 #define SET_88E_H2CCMD_REMOTE_WAKE_CTRL_ARP_OFFLOAD_EN(__cmd, __value) \ 240 SET_BITS_TO_LE_1BYTE(__cmd, 1, 1, __value) 241 #define SET_88E_H2CCMD_REMOTE_WAKE_CTRL_NDP_OFFLOAD_EN(__cmd, __value) \ 242 SET_BITS_TO_LE_1BYTE(__cmd, 2, 1, __value) 243 #define SET_88E_H2CCMD_REMOTE_WAKE_CTRL_GTK_OFFLOAD_EN(__cmd, __value) \ 244 SET_BITS_TO_LE_1BYTE(__cmd, 3, 1, __value) 245 #else 246 #define SET_88E_H2_REM_WAKE_ENC_ALG(__cmd, __value) \ 247 SET_BITS_TO_LE_1BYTE((__cmd)+1, 0, 8, __value) 248 #define SET_88E_H2CCMD_REMOTE_WAKE_CTRL_GROUP_ENC_ALG(__cmd, __value) \ 249 SET_BITS_TO_LE_1BYTE((__cmd)+2, 0, 8, __value) 250 #endif 251 252 /* GTK_OFFLOAD */ 253 #define SET_88E_H2CCMD_AOAC_GLOBAL_INFO_PAIRWISE_ENC_ALG(__cmd, __value) \ 254 SET_BITS_TO_LE_1BYTE(__cmd, 0, 8, __value) 255 #define SET_88E_H2CCMD_AOAC_GLOBAL_INFO_GROUP_ENC_ALG(__cmd, __value) \ 256 SET_BITS_TO_LE_1BYTE((__cmd)+1, 0, 8, __value) 257 258 /* AOAC_RSVDPAGE_LOC */ 259 #define SET_88E_H2CCMD_AOAC_RSVD_LOC_REM_WAKE_CTRL_INFO(__cmd, __value) \ 260 SET_BITS_TO_LE_1BYTE((__cmd), 0, 8, __value) 261 #define SET_88E_H2CCMD_AOAC_RSVDPAGE_LOC_ARP_RSP(__cmd, __value) \ 262 SET_BITS_TO_LE_1BYTE((__cmd)+1, 0, 8, __value) 263 #define SET_88E_H2CCMD_AOAC_RSVDPAGE_LOC_NEIGHBOR_ADV(__cmd, __value) \ 264 SET_BITS_TO_LE_1BYTE((__cmd)+2, 0, 8, __value) 265 #define SET_88E_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_RSP(__cmd, __value) \ 266 SET_BITS_TO_LE_1BYTE((__cmd)+3, 0, 8, __value) 267 #define SET_88E_H2CCMD_AOAC_RSVDPAGE_LOC_GTK_INFO(__cmd, __value) \ 268 SET_BITS_TO_LE_1BYTE((__cmd)+4, 0, 8, __value) 269 270 int rtl88e_download_fw(struct ieee80211_hw *hw, 271 bool buse_wake_on_wlan_fw); 272 void rtl88e_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id, 273 u32 cmd_len, u8 *cmdbuffer); 274 void rtl88e_firmware_selfreset(struct ieee80211_hw *hw); 275 void rtl88e_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode); 276 void rtl88e_set_fw_joinbss_report_cmd(struct ieee80211_hw *hw, u8 mstatus); 277 void rtl88e_set_fw_ap_off_load_cmd(struct ieee80211_hw *hw, 278 u8 ap_offload_enable); 279 void rtl88e_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished); 280 void rtl88e_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state); 281 #endif 282