linux/drivers/staging/rtlwifi/rtl8822be/fw.h
<<
>>
Prefs
   1/******************************************************************************
   2 *
   3 * Copyright(c) 2016  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 *
  22 * Larry Finger <Larry.Finger@lwfinger.net>
  23 *
  24 *****************************************************************************/
  25
  26#ifndef __RTL8822B__FW__H__
  27#define __RTL8822B__FW__H__
  28
  29#define USE_OLD_WOWLAN_DEBUG_FW 0
  30
  31#define H2C_8822B_RSVDPAGE_LOC_LEN      5
  32#define H2C_8822B_PWEMODE_LENGTH        7
  33#define H2C_8822B_JOINBSSRPT_LENGTH     1
  34#define H2C_8822B_AP_OFFLOAD_LENGTH     3
  35#define H2C_8822B_WOWLAN_LENGTH 3
  36#define H2C_8822B_KEEP_ALIVE_CTRL_LENGTH        3
  37#if (USE_OLD_WOWLAN_DEBUG_FW == 0)
  38#define H2C_8822B_REMOTE_WAKE_CTRL_LEN  1
  39#else
  40#define H2C_8822B_REMOTE_WAKE_CTRL_LEN  3
  41#endif
  42#define H2C_8822B_AOAC_GLOBAL_INFO_LEN  2
  43#define H2C_8822B_AOAC_RSVDPAGE_LOC_LEN 7
  44#define H2C_DEFAULT_PORT_ID_LEN 2
  45
  46/* Fw PS state for RPWM.
  47 *BIT[2:0] = HW state
  48 *BIT[3] = Protocol PS state,  1: register active state, 0: register sleep state
  49 *BIT[4] = sub-state
  50 */
  51#define FW_PS_RF_ON     BIT(2)
  52#define FW_PS_REGISTER_ACTIVE   BIT(3)
  53
  54#define FW_PS_ACK       BIT(6)
  55#define FW_PS_TOGGLE    BIT(7)
  56
  57/* 8822B RPWM value*/
  58/* BIT[0] = 1: 32k, 0: 40M*/
  59#define FW_PS_CLOCK_OFF BIT(0) /* 32k */
  60#define FW_PS_CLOCK_ON  0 /* 40M */
  61
  62#define FW_PS_STATE_MASK        (0x0F)
  63#define FW_PS_STATE_HW_MASK     (0x07)
  64#define FW_PS_STATE_INT_MASK    (0x3F)
  65
  66#define FW_PS_STATE(x) (FW_PS_STATE_MASK & (x))
  67
  68#define FW_PS_STATE_ALL_ON_8822B        (FW_PS_CLOCK_ON)
  69#define FW_PS_STATE_RF_ON_8822B (FW_PS_CLOCK_ON)
  70#define FW_PS_STATE_RF_OFF_8822B        (FW_PS_CLOCK_ON)
  71#define FW_PS_STATE_RF_OFF_LOW_PWR      (FW_PS_CLOCK_OFF)
  72
  73/* For 8822B H2C PwrMode Cmd ID 5.*/
  74#define FW_PWR_STATE_ACTIVE ((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE))
  75#define FW_PWR_STATE_RF_OFF     0
  76
  77#define FW_PS_IS_ACK(x) ((x) & FW_PS_ACK)
  78
  79#define IS_IN_LOW_POWER_STATE_8822B(fw_ps_state)                               \
  80        (FW_PS_STATE(fw_ps_state) == FW_PS_CLOCK_OFF)
  81
  82#define FW_PWR_STATE_ACTIVE ((FW_PS_RF_ON) | (FW_PS_REGISTER_ACTIVE))
  83#define FW_PWR_STATE_RF_OFF     0
  84
  85enum rtl8822b_h2c_cmd {
  86        H2C_8822B_RSVDPAGE      = 0,
  87        H2C_8822B_MSRRPT        = 1,
  88        H2C_8822B_SCAN  = 2,
  89        H2C_8822B_KEEP_ALIVE_CTRL       = 3,
  90        H2C_8822B_DISCONNECT_DECISION   = 4,
  91#if (USE_OLD_WOWLAN_DEBUG_FW == 1)
  92        H2C_8822B_WO_WLAN       = 5,
  93#endif
  94        H2C_8822B_INIT_OFFLOAD  = 6,
  95#if (USE_OLD_WOWLAN_DEBUG_FW == 1)
  96        H2C_8822B_REMOTE_WAKE_CTRL      = 7,
  97#endif
  98        H2C_8822B_AP_OFFLOAD    = 8,
  99        H2C_8822B_BCN_RSVDPAGE  = 9,
 100        H2C_8822B_PROBERSP_RSVDPAGE     = 10,
 101
 102        H2C_8822B_SETPWRMODE    = 0x20,
 103        H2C_8822B_PS_TUNING_PARA        = 0x21,
 104        H2C_8822B_PS_TUNING_PARA2       = 0x22,
 105        H2C_8822B_PS_LPS_PARA   = 0x23,
 106        H2C_8822B_P2P_PS_OFFLOAD        = 024,
 107        H2C_8822B_DEFAULT_PORT_ID       = 0x2C,
 108
 109#if (USE_OLD_WOWLAN_DEBUG_FW == 0)
 110        H2C_8822B_WO_WLAN       = 0x80,
 111        H2C_8822B_REMOTE_WAKE_CTRL      = 0x81,
 112        H2C_8822B_AOAC_GLOBAL_INFO      = 0x82,
 113        H2C_8822B_AOAC_RSVDPAGE = 0x83,
 114#endif
 115        H2C_8822B_MACID_CFG     = 0x40,
 116        H2C_8822B_RSSI_REPORT   = 0x42,
 117        H2C_8822B_MACID_CFG_3SS = 0x46,
 118        /*Not defined CTW CMD for P2P yet*/
 119        H2C_8822B_P2P_PS_CTW_CMD        = 0x99,
 120        MAX_8822B_H2CCMD
 121};
 122
 123enum rtl8822b_c2h_evt {
 124        C2H_8822B_DBG   = 0x00,
 125        C2H_8822B_LB    = 0x01,
 126        C2H_8822B_TXBF  = 0x02,
 127        C2H_8822B_TX_REPORT     = 0x03,
 128        C2H_8822B_BT_INFO       = 0x09,
 129        C2H_8822B_BT_MP = 0x0B,
 130        C2H_8822B_RA_RPT        = 0x0C,
 131        MAX_8822B_C2HEVENT
 132};
 133
 134/* H2C: 0x20 */
 135#define SET_H2CCMD_PWRMODE_PARM_MODE(__ph2ccmd, __val)                         \
 136        SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 7, __val)
 137#define SET_H2CCMD_PWRMODE_PARM_CLK_REQ(__ph2ccmd, __val)                      \
 138        SET_BITS_TO_LE_1BYTE(__ph2ccmd, 7, 1, __val)
 139#define SET_H2CCMD_PWRMODE_PARM_RLBM(__ph2ccmd, __val)                         \
 140        SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 1, 0, 4, __val)
 141#define SET_H2CCMD_PWRMODE_PARM_SMART_PS(__ph2ccmd, __val)                     \
 142        SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 1, 4, 4, __val)
 143#define SET_H2CCMD_PWRMODE_PARM_AWAKE_INTERVAL(__ph2ccmd, __val)               \
 144        SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 2, 0, 8, __val)
 145#define SET_H2CCMD_PWRMODE_PARM_ALL_QUEUE_UAPSD(__ph2ccmd, __val)              \
 146        SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 3, 0, 1, __val)
 147#define SET_H2CCMD_PWRMODE_PARM_BCN_EARLY_RPT(__ph2ccmd, __val)                \
 148        SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 3, 2, 1, __val)
 149#define SET_H2CCMD_PWRMODE_PARM_PORT_ID(__ph2ccmd, __val)                      \
 150        SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 3, 5, 3, __val)
 151#define SET_H2CCMD_PWRMODE_PARM_PWR_STATE(__ph2ccmd, __val)                    \
 152        SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 4, 0, 8, __val)
 153#define SET_H2CCMD_PWRMODE_PARM_BYTE5(__ph2ccmd, __val)                        \
 154        SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 5, 0, 8, __val)
 155
 156/* H2C: 0x00 */
 157#define SET_H2CCMD_RSVDPAGE_LOC_PROBE_RSP(__ph2ccmd, __val)                    \
 158        SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 8, __val)
 159#define SET_H2CCMD_RSVDPAGE_LOC_PSPOLL(__ph2ccmd, __val)                       \
 160        SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 1, 0, 8, __val)
 161#define SET_H2CCMD_RSVDPAGE_LOC_NULL_DATA(__ph2ccmd, __val)                    \
 162        SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 2, 0, 8, __val)
 163#define SET_H2CCMD_RSVDPAGE_LOC_QOS_NULL_DATA(__ph2ccmd, __val)                \
 164        SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 3, 0, 8, __val)
 165#define SET_H2CCMD_RSVDPAGE_LOC_BT_QOS_NULL_DATA(__ph2ccmd, __val)             \
 166        SET_BITS_TO_LE_1BYTE((__ph2ccmd) + 4, 0, 8, __val)
 167
 168/* H2C: 0x01 */
 169#define SET_H2CCMD_MSRRPT_PARM_OPMODE(__ph2ccmd, __val)                        \
 170        SET_BITS_TO_LE_1BYTE(__ph2ccmd, 0, 1, __val)
 171#define SET_H2CCMD_MSRRPT_PARM_MACID_IND(__ph2ccmd, __val)                     \
 172        SET_BITS_TO_LE_1BYTE(__ph2ccmd, 1, 1, __val)
 173#define SET_H2CCMD_MSRRPT_PARM_MACID(__ph2ccmd, __val)                         \
 174        SET_BITS_TO_LE_1BYTE(__ph2ccmd + 1, 0, 8, __val)
 175#define SET_H2CCMD_MSRRPT_PARM_MACID_END(__ph2ccmd, __val)                     \
 176        SET_BITS_TO_LE_1BYTE(__ph2ccmd + 2, 0, 8, __val)
 177
 178/* H2C: 0x2C */
 179#define SET_H2CCMD_DFTPID_PORT_ID(__ph2ccmd, __val)                            \
 180        SET_BITS_TO_LE_1BYTE(((u8 *)(__ph2ccmd)), 0, 8, (__val))
 181#define SET_H2CCMD_DFTPID_MAC_ID(__ph2ccmd, __val)                             \
 182        SET_BITS_TO_LE_1BYTE(((u8 *)(__ph2ccmd)) + 1, 0, 8, (__val))
 183
 184void rtl8822be_fill_h2c_cmd(struct ieee80211_hw *hw, u8 element_id, u32 cmd_len,
 185                            u8 *cmdbuffer);
 186void rtl8822be_set_default_port_id_cmd(struct ieee80211_hw *hw);
 187void rtl8822be_set_fw_pwrmode_cmd(struct ieee80211_hw *hw, u8 mode);
 188void rtl8822be_set_fw_media_status_rpt_cmd(struct ieee80211_hw *hw, u8 mstatus);
 189void rtl8822be_set_fw_rsvdpagepkt(struct ieee80211_hw *hw, bool b_dl_finished);
 190void rtl8822be_set_p2p_ps_offload_cmd(struct ieee80211_hw *hw, u8 p2p_ps_state);
 191void rtl8822be_c2h_packet_handler(struct ieee80211_hw *hw, u8 *buffer, u8 len);
 192void rtl8822be_c2h_content_parsing(struct ieee80211_hw *hw, u8 c2h_cmd_id,
 193                                   u8 c2h_cmd_len, u8 *tmp_buf);
 194bool rtl8822b_halmac_cb_write_data_rsvd_page(struct rtl_priv *rtlpriv, u8 *buf,
 195                                             u32 size);
 196bool rtl8822b_halmac_cb_write_data_h2c(struct rtl_priv *rtlpriv, u8 *buf,
 197                                       u32 size);
 198#endif
 199