2022-06-08 23:46:35 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
|
|
|
/* Copyright(c) 2007 - 2012 Realtek Corporation. */
|
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
#ifndef __RTW_PWRCTRL_H_
|
|
|
|
#define __RTW_PWRCTRL_H_
|
|
|
|
|
2022-06-08 23:46:35 +00:00
|
|
|
#include "osdep_service.h"
|
|
|
|
#include "drv_types.h"
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
#define XMIT_ALIVE BIT(0)
|
|
|
|
#define RECV_ALIVE BIT(1)
|
|
|
|
#define CMD_ALIVE BIT(2)
|
|
|
|
#define EVT_ALIVE BIT(3)
|
|
|
|
|
2013-08-14 02:01:38 +00:00
|
|
|
enum power_mgnt {
|
|
|
|
PS_MODE_ACTIVE = 0,
|
2013-05-25 20:45:50 +00:00
|
|
|
PS_MODE_MIN,
|
|
|
|
PS_MODE_MAX,
|
|
|
|
PS_MODE_DTIM,
|
|
|
|
PS_MODE_VOIP,
|
|
|
|
PS_MODE_UAPSD_WMM,
|
2013-08-14 02:01:38 +00:00
|
|
|
PM_Card_Disable,
|
2013-05-08 21:45:39 +00:00
|
|
|
PS_MODE_NUM
|
|
|
|
};
|
|
|
|
|
2013-08-12 04:36:23 +00:00
|
|
|
#define LPS_DELAY_TIME 1*HZ /* 1 sec */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 04:36:23 +00:00
|
|
|
/* RF state. */
|
2013-07-26 23:15:45 +00:00
|
|
|
enum rt_rf_power_state {
|
2013-08-12 04:36:23 +00:00
|
|
|
rf_on, /* RF is on after RFSleep or RFOff */
|
|
|
|
rf_sleep, /* 802.11 Power Save mode */
|
|
|
|
rf_off, /* HW/SW Radio OFF or Inactive Power Save */
|
|
|
|
/* Add the new RF state above this line===== */
|
2013-05-08 21:45:39 +00:00
|
|
|
rf_max
|
2013-07-26 23:15:45 +00:00
|
|
|
};
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 04:36:23 +00:00
|
|
|
enum { /* for ips_mode */
|
2013-08-14 02:01:38 +00:00
|
|
|
IPS_NONE = 0,
|
2013-05-08 21:45:39 +00:00
|
|
|
IPS_NORMAL,
|
2013-05-19 04:28:07 +00:00
|
|
|
IPS_LEVEL_2,
|
2013-05-08 21:45:39 +00:00
|
|
|
};
|
|
|
|
|
2013-08-14 02:01:38 +00:00
|
|
|
struct pwrctrl_priv {
|
2022-06-08 23:46:35 +00:00
|
|
|
struct mutex lock; /* Mutex used to protect struct pwrctrl_priv */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
u8 pwr_mode;
|
|
|
|
u8 smart_ps;
|
|
|
|
u8 bcn_ant_mode;
|
|
|
|
|
|
|
|
u32 alives;
|
2013-07-25 16:02:03 +00:00
|
|
|
struct work_struct cpwm_event;
|
2022-06-08 23:46:35 +00:00
|
|
|
bool bpower_saving;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
u8 reg_rfoff;
|
2013-08-12 04:36:23 +00:00
|
|
|
u8 reg_pdnmode; /* powerdown mode */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 04:36:23 +00:00
|
|
|
/* RF OFF Level */
|
2013-05-08 21:45:39 +00:00
|
|
|
u32 cur_ps_level;
|
|
|
|
u32 reg_rfps_level;
|
2013-05-19 04:28:07 +00:00
|
|
|
uint ips_enter_cnts;
|
|
|
|
uint ips_leave_cnts;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
u8 ips_mode;
|
2013-08-14 02:01:38 +00:00
|
|
|
u8 ips_mode_req; /* used to accept the mode setting request,
|
|
|
|
* will update to ipsmode later */
|
2013-05-08 21:45:39 +00:00
|
|
|
uint bips_processing;
|
2013-08-14 02:01:38 +00:00
|
|
|
u32 ips_deny_time; /* will deny IPS when system time less than this */
|
|
|
|
u8 ps_processing; /* temp used to mark whether in rtw_ps_processor */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
u8 bLeisurePs;
|
|
|
|
u8 LpsIdleCount;
|
|
|
|
u8 power_mgnt;
|
|
|
|
u8 bFwCurrentInPSMode;
|
|
|
|
u32 DelayLPSLastTimeStamp;
|
|
|
|
s32 pnp_current_pwr_state;
|
|
|
|
u8 pnp_bstop_trx;
|
|
|
|
|
|
|
|
u8 bInSuspend;
|
2013-05-19 04:28:07 +00:00
|
|
|
u8 bSupportRemoteWakeup;
|
2013-07-24 20:10:50 +00:00
|
|
|
struct timer_list pwr_state_check_timer;
|
2013-05-08 21:45:39 +00:00
|
|
|
int pwr_state_check_interval;
|
|
|
|
u8 pwr_state_check_cnts;
|
|
|
|
|
2013-05-19 04:28:07 +00:00
|
|
|
int ps_flag;
|
|
|
|
|
2013-08-12 04:36:23 +00:00
|
|
|
enum rt_rf_power_state rf_pwrstate;/* cur power state */
|
2013-07-26 23:15:45 +00:00
|
|
|
enum rt_rf_power_state change_rfpwrstate;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
u8 wepkeymask;
|
2013-05-19 04:28:07 +00:00
|
|
|
u8 bkeepfwalive;
|
2013-05-08 21:45:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define rtw_get_ips_mode_req(pwrctrlpriv) \
|
|
|
|
(pwrctrlpriv)->ips_mode_req
|
|
|
|
|
|
|
|
#define rtw_ips_mode_req(pwrctrlpriv, ips_mode) \
|
2013-08-14 02:01:38 +00:00
|
|
|
((pwrctrlpriv)->ips_mode_req = (ips_mode))
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
#define RTW_PWR_STATE_CHK_INTERVAL 2000
|
|
|
|
|
|
|
|
#define _rtw_set_pwr_state_check_timer(pwrctrlpriv, ms) \
|
|
|
|
do { \
|
|
|
|
_set_timer(&(pwrctrlpriv)->pwr_state_check_timer, (ms)); \
|
2013-05-09 04:04:25 +00:00
|
|
|
} while (0)
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-14 02:01:38 +00:00
|
|
|
#define rtw_set_pwr_state_check_timer(pwrctrl) \
|
|
|
|
_rtw_set_pwr_state_check_timer((pwrctrl), \
|
|
|
|
(pwrctrl)->pwr_state_check_interval)
|
|
|
|
|
|
|
|
void rtw_init_pwrctrl_priv(struct adapter *adapter);
|
|
|
|
|
|
|
|
void rtw_set_ps_mode(struct adapter *adapter, u8 ps_mode, u8 smart_ps,
|
|
|
|
u8 bcn_ant_mode);
|
|
|
|
void LeaveAllPowerSaveMode(struct adapter *adapter);
|
|
|
|
void ips_enter(struct adapter *padapter);
|
|
|
|
int ips_leave(struct adapter *padapter);
|
|
|
|
|
|
|
|
void rtw_ps_processor(struct adapter *padapter);
|
|
|
|
|
|
|
|
s32 LPS_RF_ON_check(struct adapter *adapter, u32 delay_ms);
|
|
|
|
void LPS_Enter(struct adapter *adapter);
|
|
|
|
void LPS_Leave(struct adapter *adapter);
|
|
|
|
|
|
|
|
int _rtw_pwr_wakeup(struct adapter *adapter, u32 ips_defer_ms,
|
|
|
|
const char *caller);
|
|
|
|
#define rtw_pwr_wakeup(adapter) \
|
|
|
|
_rtw_pwr_wakeup(adapter, RTW_PWR_STATE_CHK_INTERVAL, __func__)
|
|
|
|
int rtw_pm_set_ips(struct adapter *adapter, u8 mode);
|
|
|
|
int rtw_pm_set_lps(struct adapter *adapter, u8 mode);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-08-12 04:36:23 +00:00
|
|
|
#endif /* __RTL871X_PWRCTRL_H_ */
|