2013-05-08 21:45:39 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
|
2013-05-19 04:28:07 +00:00
|
|
|
*
|
2013-05-08 21:45:39 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
******************************************************************************/
|
|
|
|
#define _RTW_PWRCTRL_C_
|
|
|
|
|
|
|
|
#include <osdep_service.h>
|
|
|
|
#include <drv_types.h>
|
|
|
|
#include <osdep_intf.h>
|
2013-05-25 20:45:50 +00:00
|
|
|
#include <linux/usb.h>
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
void ips_enter(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
|
|
|
|
struct xmit_priv *pxmit_priv = &padapter->xmitpriv;
|
|
|
|
|
|
|
|
if (padapter->registrypriv.mp_mode == 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (pxmit_priv->free_xmitbuf_cnt != NR_XMITBUFF ||
|
2013-07-31 06:27:28 +00:00
|
|
|
pxmit_priv->free_xmit_extbuf_cnt != NR_XMIT_EXTBUFF) {
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E_LEVEL(_drv_info_, "There are some pkts to transmit\n");
|
|
|
|
DBG_88E_LEVEL(_drv_info_, "free_xmitbuf_cnt: %d, free_xmit_extbuf_cnt: %d\n",
|
2013-07-31 06:27:28 +00:00
|
|
|
pxmit_priv->free_xmitbuf_cnt, pxmit_priv->free_xmit_extbuf_cnt);
|
2013-05-08 21:45:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_enter_pwrlock(&pwrpriv->lock);
|
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrpriv->bips_processing = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* syn ips_mode with request */
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrpriv->ips_mode = pwrpriv->ips_mode_req;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
pwrpriv->ips_enter_cnts++;
|
2013-07-31 06:27:28 +00:00
|
|
|
DBG_88E("==>ips_enter cnts:%d\n", pwrpriv->ips_enter_cnts);
|
|
|
|
if (rf_off == pwrpriv->change_rfpwrstate) {
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrpriv->bpower_saving = true;
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E_LEVEL(_drv_info_, "nolinked power save enter\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pwrpriv->ips_mode == IPS_LEVEL_2)
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrpriv->bkeepfwalive = true;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_ips_pwr_down(padapter);
|
|
|
|
pwrpriv->rf_pwrstate = rf_off;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrpriv->bips_processing = false;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
_exit_pwrlock(&pwrpriv->lock);
|
|
|
|
}
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
int ips_leave(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
|
2013-07-31 06:27:28 +00:00
|
|
|
struct security_priv *psecuritypriv = &(padapter->securitypriv);
|
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2013-05-08 21:45:39 +00:00
|
|
|
int result = _SUCCESS;
|
2013-07-26 22:56:14 +00:00
|
|
|
int keyid;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
_enter_pwrlock(&pwrpriv->lock);
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if ((pwrpriv->rf_pwrstate == rf_off) && (!pwrpriv->bips_processing)) {
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrpriv->bips_processing = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrpriv->change_rfpwrstate = rf_on;
|
|
|
|
pwrpriv->ips_leave_cnts++;
|
2013-07-31 06:27:28 +00:00
|
|
|
DBG_88E("==>ips_leave cnts:%d\n", pwrpriv->ips_leave_cnts);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
result = rtw_ips_pwr_up(padapter);
|
|
|
|
if (result == _SUCCESS) {
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrpriv->rf_pwrstate = rf_on;
|
|
|
|
}
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E_LEVEL(_drv_info_, "nolinked power save leave\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if ((_WEP40_ == psecuritypriv->dot11PrivacyAlgrthm) || (_WEP104_ == psecuritypriv->dot11PrivacyAlgrthm)) {
|
|
|
|
DBG_88E("==>%s, channel(%d), processing(%x)\n", __func__, padapter->mlmeextpriv.cur_channel, pwrpriv->bips_processing);
|
2013-05-19 04:28:07 +00:00
|
|
|
set_channel_bwmode(padapter, padapter->mlmeextpriv.cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20);
|
2013-07-31 06:27:28 +00:00
|
|
|
for (keyid = 0; keyid < 4; keyid++) {
|
|
|
|
if (pmlmepriv->key_mask & BIT(keyid)) {
|
2013-05-09 04:04:25 +00:00
|
|
|
if (keyid == psecuritypriv->dot11PrivacyKeyIndex)
|
2013-07-31 06:27:28 +00:00
|
|
|
result = rtw_set_key(padapter, psecuritypriv, keyid, 1);
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2013-07-31 06:27:28 +00:00
|
|
|
result = rtw_set_key(padapter, psecuritypriv, keyid, 0);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
DBG_88E("==> ips_leave.....LED(0x%08x)...\n", rtw_read32(padapter, 0x4c));
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrpriv->bips_processing = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrpriv->bkeepfwalive = false;
|
|
|
|
pwrpriv->bpower_saving = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_exit_pwrlock(&pwrpriv->lock);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
static bool rtw_pwr_unassociated_idle(struct adapter *adapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-27 01:08:39 +00:00
|
|
|
struct adapter *buddy = adapter->pbuddy_adapter;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &(adapter->mlmepriv);
|
2013-10-19 17:45:47 +00:00
|
|
|
#ifdef CONFIG_88EU_P2P
|
2013-05-08 21:45:39 +00:00
|
|
|
struct wifidirect_info *pwdinfo = &(adapter->wdinfo);
|
|
|
|
#endif
|
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
bool ret = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:18:54 +00:00
|
|
|
if (adapter->pwrctrlpriv.ips_deny_time >= jiffies)
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) ||
|
|
|
|
check_fwstate(pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) ||
|
2014-11-20 06:12:27 +00:00
|
|
|
check_fwstate(pmlmepriv, WIFI_UNDER_WPS) ||
|
2013-07-31 06:27:28 +00:00
|
|
|
check_fwstate(pmlmepriv, WIFI_AP_STATE) ||
|
|
|
|
check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) ||
|
2013-10-19 17:45:47 +00:00
|
|
|
#if defined(CONFIG_88EU_P2P)
|
2013-07-31 06:27:28 +00:00
|
|
|
!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE))
|
|
|
|
#else
|
|
|
|
0)
|
|
|
|
#endif
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
|
|
|
|
/* consider buddy, if exist */
|
|
|
|
if (buddy) {
|
|
|
|
struct mlme_priv *b_pmlmepriv = &(buddy->mlmepriv);
|
2013-10-19 17:45:47 +00:00
|
|
|
#ifdef CONFIG_88EU_P2P
|
2013-05-08 21:45:39 +00:00
|
|
|
struct wifidirect_info *b_pwdinfo = &(buddy->wdinfo);
|
|
|
|
#endif
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if (check_fwstate(b_pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) ||
|
|
|
|
check_fwstate(b_pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) ||
|
|
|
|
check_fwstate(b_pmlmepriv, WIFI_AP_STATE) ||
|
|
|
|
check_fwstate(b_pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) ||
|
2013-10-19 17:45:47 +00:00
|
|
|
#if defined(CONFIG_88EU_P2P)
|
2013-07-31 06:27:28 +00:00
|
|
|
!rtw_p2p_chk_state(b_pwdinfo, P2P_STATE_NONE))
|
|
|
|
#else
|
|
|
|
0)
|
|
|
|
#endif
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
2013-05-26 03:02:10 +00:00
|
|
|
ret = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
exit:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
void rtw_ps_processor(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
|
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
2013-07-26 23:15:45 +00:00
|
|
|
enum rt_rf_power_state rfpwrstate;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrpriv->ps_processing = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if (pwrpriv->bips_processing)
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if (padapter->pwrctrlpriv.bHWPwrPindetect) {
|
2013-07-22 01:55:51 +00:00
|
|
|
rfpwrstate = RfOnOffDetect(padapter);
|
2013-07-31 06:27:28 +00:00
|
|
|
DBG_88E("@@@@- #2 %s==> rfstate:%s\n", __func__, (rfpwrstate == rf_on) ? "rf_on" : "rf_off");
|
2013-07-22 01:55:51 +00:00
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if (rfpwrstate != pwrpriv->rf_pwrstate) {
|
|
|
|
if (rfpwrstate == rf_off) {
|
2013-07-22 01:55:51 +00:00
|
|
|
pwrpriv->change_rfpwrstate = rf_off;
|
|
|
|
pwrpriv->brfoffbyhw = true;
|
|
|
|
padapter->bCardDisableWOHSM = true;
|
2013-07-31 06:27:28 +00:00
|
|
|
rtw_hw_suspend(padapter);
|
|
|
|
} else {
|
2013-07-22 01:55:51 +00:00
|
|
|
pwrpriv->change_rfpwrstate = rf_on;
|
2013-07-31 06:27:28 +00:00
|
|
|
rtw_hw_resume(padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-07-31 06:27:28 +00:00
|
|
|
DBG_88E("current rf_pwrstate(%s)\n", (pwrpriv->rf_pwrstate == rf_off) ? "rf_off" : "rf_on");
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-07-31 06:27:28 +00:00
|
|
|
pwrpriv->pwr_state_check_cnts++;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-12 03:50:49 +00:00
|
|
|
if (pwrpriv->ips_mode_req == IPS_NONE)
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
|
2013-11-29 22:10:20 +00:00
|
|
|
if (!rtw_pwr_unassociated_idle(padapter))
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if ((pwrpriv->rf_pwrstate == rf_on) && ((pwrpriv->pwr_state_check_cnts%4) == 0)) {
|
|
|
|
DBG_88E("==>%s .fw_state(%x)\n", __func__, get_fwstate(pmlmepriv));
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrpriv->change_rfpwrstate = rf_off;
|
|
|
|
|
2013-07-22 01:55:51 +00:00
|
|
|
ips_enter(padapter);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
exit:
|
|
|
|
rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv);
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrpriv->ps_processing = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
static void pwr_state_check_handler(void *FunctionContext)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-07-27 01:08:39 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)FunctionContext;
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_ps_cmd(padapter);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Parameters
|
|
|
|
* padapter
|
|
|
|
* pslv power state level, only could be PS_STATE_S0 ~ PS_STATE_S4
|
|
|
|
*
|
|
|
|
*/
|
2013-07-31 06:27:28 +00:00
|
|
|
void rtw_set_rpwm(struct adapter *padapter, u8 pslv)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u8 rpwm;
|
|
|
|
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
|
|
|
|
|
|
|
|
pslv = PS_STATE(pslv);
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if (pwrpriv->btcoex_rfon) {
|
2013-05-08 21:45:39 +00:00
|
|
|
if (pslv < PS_STATE_S4)
|
|
|
|
pslv = PS_STATE_S3;
|
|
|
|
}
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if ((pwrpriv->rpwm == pslv)) {
|
|
|
|
RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_,
|
|
|
|
("%s: Already set rpwm[0x%02X], new=0x%02X!\n", __func__, pwrpriv->rpwm, pslv));
|
2013-05-08 21:45:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if ((padapter->bSurpriseRemoved) ||
|
|
|
|
(!padapter->hw_init_completed)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_,
|
2013-07-31 06:27:28 +00:00
|
|
|
("%s: SurpriseRemoved(%d) hw_init_completed(%d)\n",
|
|
|
|
__func__, padapter->bSurpriseRemoved, padapter->hw_init_completed));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pwrpriv->cpwm = PS_STATE_S4;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if (padapter->bDriverStopped) {
|
2013-05-08 21:45:39 +00:00
|
|
|
RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_,
|
2013-07-31 06:27:28 +00:00
|
|
|
("%s: change power state(0x%02X) when DriverStopped\n", __func__, pslv));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (pslv < PS_STATE_S2) {
|
|
|
|
RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_,
|
2013-07-31 06:27:28 +00:00
|
|
|
("%s: Reject to enter PS_STATE(0x%02X) lower than S2 when DriverStopped!!\n", __func__, pslv));
|
2013-05-08 21:45:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rpwm = pslv | pwrpriv->tog;
|
|
|
|
RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
|
2013-07-31 06:27:28 +00:00
|
|
|
("rtw_set_rpwm: rpwm=0x%02x cpwm=0x%02x\n", rpwm, pwrpriv->cpwm));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pwrpriv->rpwm = pslv;
|
|
|
|
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_SET_RPWM, (u8 *)(&rpwm));
|
|
|
|
|
|
|
|
pwrpriv->tog += 0x80;
|
2013-07-20 02:12:05 +00:00
|
|
|
pwrpriv->cpwm = pslv;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
static u8 PS_RDY_CHECK(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u32 curr_time, delta_time;
|
|
|
|
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
|
|
|
|
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
|
|
|
|
|
2014-12-13 21:18:54 +00:00
|
|
|
curr_time = jiffies;
|
2013-07-31 06:27:28 +00:00
|
|
|
delta_time = curr_time - pwrpriv->DelayLPSLastTimeStamp;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (delta_time < LPS_DELAY_TIME)
|
2013-05-26 03:02:10 +00:00
|
|
|
return false;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
if ((check_fwstate(pmlmepriv, _FW_LINKED) == false) ||
|
2013-07-31 06:27:28 +00:00
|
|
|
(check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) ||
|
|
|
|
(check_fwstate(pmlmepriv, WIFI_AP_STATE)) ||
|
|
|
|
(check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) ||
|
|
|
|
(check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)))
|
2013-05-26 03:02:10 +00:00
|
|
|
return false;
|
2013-07-31 06:27:28 +00:00
|
|
|
if (pwrpriv->bInSuspend)
|
2013-05-26 03:02:10 +00:00
|
|
|
return false;
|
2013-07-31 06:27:28 +00:00
|
|
|
if ((padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) && (padapter->securitypriv.binstallGrpkey == false)) {
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("Group handshake still in progress !!!\n");
|
2013-05-26 03:02:10 +00:00
|
|
|
return false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-05-26 03:02:10 +00:00
|
|
|
return true;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
|
2013-10-19 17:45:47 +00:00
|
|
|
#ifdef CONFIG_88EU_P2P
|
2013-07-31 06:27:28 +00:00
|
|
|
struct wifidirect_info *pwdinfo = &(padapter->wdinfo);
|
2013-10-19 17:45:47 +00:00
|
|
|
#endif /* CONFIG_88EU_P2P */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_,
|
2013-07-31 06:27:28 +00:00
|
|
|
("%s: PowerMode=%d Smart_PS=%d\n",
|
|
|
|
__func__, ps_mode, smart_ps));
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (ps_mode > PM_Card_Disable) {
|
2013-07-31 06:27:28 +00:00
|
|
|
RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, ("ps_mode:%d error\n", ps_mode));
|
2013-05-08 21:45:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if (pwrpriv->pwr_mode == ps_mode) {
|
|
|
|
if (PS_MODE_ACTIVE == ps_mode)
|
|
|
|
return;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if ((pwrpriv->smart_ps == smart_ps) &&
|
2013-07-31 06:27:28 +00:00
|
|
|
(pwrpriv->bcn_ant_mode == bcn_ant_mode))
|
2013-05-08 21:45:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) */
|
2013-07-20 02:12:05 +00:00
|
|
|
if (ps_mode == PS_MODE_ACTIVE) {
|
2013-10-19 17:45:47 +00:00
|
|
|
#ifdef CONFIG_88EU_P2P
|
2013-07-20 16:25:24 +00:00
|
|
|
if (pwdinfo->opp_ps == 0) {
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("rtw_set_ps_mode: Leave 802.11 power save\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrpriv->pwr_mode = ps_mode;
|
|
|
|
rtw_set_rpwm(padapter, PS_STATE_S4);
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode));
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrpriv->bFwCurrentInPSMode = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-07-31 06:27:28 +00:00
|
|
|
} else {
|
2013-10-19 17:45:47 +00:00
|
|
|
#endif /* CONFIG_88EU_P2P */
|
2013-07-31 06:27:28 +00:00
|
|
|
if (PS_RDY_CHECK(padapter)) {
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("%s: Enter 802.11 power save\n", __func__);
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrpriv->bFwCurrentInPSMode = true;
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrpriv->pwr_mode = ps_mode;
|
|
|
|
pwrpriv->smart_ps = smart_ps;
|
|
|
|
pwrpriv->bcn_ant_mode = bcn_ant_mode;
|
|
|
|
rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode));
|
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
#ifdef CONFIG_88EU_P2P
|
2013-07-09 22:38:46 +00:00
|
|
|
/* Set CTWindow after LPS */
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pwdinfo->opp_ps == 1)
|
2013-05-08 21:45:39 +00:00
|
|
|
p2p_ps_wk_cmd(padapter, P2P_PS_ENABLE, 0);
|
2013-10-19 17:45:47 +00:00
|
|
|
#endif /* CONFIG_88EU_P2P */
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
rtw_set_rpwm(padapter, PS_STATE_S2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return:
|
|
|
|
* 0: Leave OK
|
|
|
|
* -1: Timeout
|
|
|
|
* -2: Other error
|
|
|
|
*/
|
2013-07-31 06:27:28 +00:00
|
|
|
s32 LPS_RF_ON_check(struct adapter *padapter, u32 delay_ms)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
u32 start_time;
|
2013-05-26 03:02:10 +00:00
|
|
|
u8 bAwake = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
s32 err = 0;
|
|
|
|
|
2014-12-13 21:18:54 +00:00
|
|
|
start_time = jiffies;
|
2013-07-31 06:27:28 +00:00
|
|
|
while (1) {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_hal_get_hwreg(padapter, HW_VAR_FWLPS_RF_ON, &bAwake);
|
2013-07-31 06:27:28 +00:00
|
|
|
if (bAwake)
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if (padapter->bSurpriseRemoved) {
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -2;
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("%s: device surprise removed!!\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if (rtw_get_passing_time_ms(start_time) > delay_ms) {
|
2013-05-08 21:45:39 +00:00
|
|
|
err = -1;
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("%s: Wait for FW LPS leave more than %u ms!!!\n", __func__, delay_ms);
|
2013-05-08 21:45:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
rtw_usleep_os(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* */
|
2013-07-31 06:27:28 +00:00
|
|
|
/* Description: */
|
|
|
|
/* Enter the leisure power save mode. */
|
2013-07-09 22:38:46 +00:00
|
|
|
/* */
|
2013-07-31 06:27:28 +00:00
|
|
|
void LPS_Enter(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
|
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
if (PS_RDY_CHECK(padapter) == false)
|
2013-05-08 21:45:39 +00:00
|
|
|
return;
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if (pwrpriv->bLeisurePs) {
|
2013-07-09 22:38:46 +00:00
|
|
|
/* Idle for a while if we connect to AP a while ago. */
|
2013-07-31 06:27:28 +00:00
|
|
|
if (pwrpriv->LpsIdleCount >= 2) { /* 4 Sec */
|
|
|
|
if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) {
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrpriv->bpower_saving = true;
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("%s smart_ps:%d\n", __func__, pwrpriv->smart_ps);
|
2013-07-09 22:38:46 +00:00
|
|
|
/* For Tenda W311R IOT issue */
|
2014-11-20 06:12:27 +00:00
|
|
|
rtw_set_ps_mode(padapter, pwrpriv->power_mgnt,
|
|
|
|
pwrpriv->smart_ps, 0x40);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-07-31 06:27:28 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
pwrpriv->LpsIdleCount++;
|
2013-07-31 06:27:28 +00:00
|
|
|
}
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-10-19 17:45:47 +00:00
|
|
|
#define LPS_LEAVE_TIMEOUT_MS 100
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
/* Description: */
|
|
|
|
/* Leave the leisure power save mode. */
|
|
|
|
void LPS_Leave(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if (pwrpriv->bLeisurePs) {
|
|
|
|
if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) {
|
2014-11-20 06:12:27 +00:00
|
|
|
rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0x40);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-09 04:04:25 +00:00
|
|
|
if (pwrpriv->pwr_mode == PS_MODE_ACTIVE)
|
2013-05-08 21:45:39 +00:00
|
|
|
LPS_RF_ON_check(padapter, LPS_LEAVE_TIMEOUT_MS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrpriv->bpower_saving = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* */
|
|
|
|
/* Description: Leave all power save mode: LPS, FwLPS, IPS if needed. */
|
|
|
|
/* Move code to function by tynli. 2010.03.26. */
|
|
|
|
/* */
|
2013-07-31 06:27:28 +00:00
|
|
|
void LeaveAllPowerSaveMode(struct adapter *Adapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv);
|
|
|
|
u8 enqueue = 0;
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED)) { /* connect */
|
2013-05-08 21:45:39 +00:00
|
|
|
p2p_ps_wk_cmd(Adapter, P2P_PS_DISABLE, enqueue);
|
|
|
|
|
|
|
|
rtw_lps_ctrl_wk_cmd(Adapter, LPS_CTRL_LEAVE, enqueue);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
void rtw_init_pwrctrl_priv(struct adapter *padapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
|
|
|
|
|
|
|
|
_init_pwrlock(&pwrctrlpriv->lock);
|
|
|
|
pwrctrlpriv->rf_pwrstate = rf_on;
|
2013-07-31 06:27:28 +00:00
|
|
|
pwrctrlpriv->ips_enter_cnts = 0;
|
|
|
|
pwrctrlpriv->ips_leave_cnts = 0;
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrctrlpriv->bips_processing = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pwrctrlpriv->ips_mode = padapter->registrypriv.ips_mode;
|
|
|
|
pwrctrlpriv->ips_mode_req = padapter->registrypriv.ips_mode;
|
|
|
|
|
|
|
|
pwrctrlpriv->pwr_state_check_interval = RTW_PWR_STATE_CHK_INTERVAL;
|
|
|
|
pwrctrlpriv->pwr_state_check_cnts = 0;
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrctrlpriv->bInternalAutoSuspend = false;
|
|
|
|
pwrctrlpriv->bInSuspend = false;
|
|
|
|
pwrctrlpriv->bkeepfwalive = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pwrctrlpriv->LpsIdleCount = 0;
|
|
|
|
if (padapter->registrypriv.mp_mode == 1)
|
2013-07-31 06:27:28 +00:00
|
|
|
pwrctrlpriv->power_mgnt = PS_MODE_ACTIVE ;
|
2013-05-19 04:28:07 +00:00
|
|
|
else
|
2013-07-31 06:27:28 +00:00
|
|
|
pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */
|
|
|
|
pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt) ? true : false;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrctrlpriv->bFwCurrentInPSMode = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
pwrctrlpriv->rpwm = 0;
|
|
|
|
pwrctrlpriv->cpwm = PS_STATE_S4;
|
|
|
|
|
|
|
|
pwrctrlpriv->pwr_mode = PS_MODE_ACTIVE;
|
|
|
|
pwrctrlpriv->smart_ps = padapter->registrypriv.smart_ps;
|
|
|
|
pwrctrlpriv->bcn_ant_mode = 0;
|
|
|
|
|
|
|
|
pwrctrlpriv->tog = 0x80;
|
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
pwrctrlpriv->btcoex_rfon = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
_init_timer(&(pwrctrlpriv->pwr_state_check_timer), padapter->pnetdev, pwr_state_check_handler, (u8 *)padapter);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
void rtw_free_pwrctrl_priv(struct adapter *adapter)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct pwrctrl_priv *pwrctrlpriv = &adapter->pwrctrlpriv;
|
|
|
|
|
|
|
|
_free_pwrlock(&pwrctrlpriv->lock);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
u8 rtw_interface_ps_func(struct adapter *padapter, enum hal_intf_ps_func efunc_id, u8 *val)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-05-26 03:02:10 +00:00
|
|
|
u8 bResult = true;
|
2013-07-31 06:27:28 +00:00
|
|
|
rtw_hal_intf_ps_func(padapter, efunc_id, val);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-08 21:45:39 +00:00
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
inline void rtw_set_ips_deny(struct adapter *padapter, u32 ms)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
|
2014-12-13 21:18:54 +00:00
|
|
|
pwrpriv->ips_deny_time = jiffies + rtw_ms_to_systime(ms);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* rtw_pwr_wakeup - Wake the NIC up from: 1)IPS. 2)USB autosuspend
|
2013-07-27 01:08:39 +00:00
|
|
|
* @adapter: pointer to struct adapter structure
|
2013-05-08 21:45:39 +00:00
|
|
|
* @ips_deffer_ms: the ms wiil prevent from falling into IPS after wakeup
|
|
|
|
* Return _SUCCESS or _FAIL
|
|
|
|
*/
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *caller)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
|
2013-05-19 04:28:07 +00:00
|
|
|
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
2013-05-08 21:45:39 +00:00
|
|
|
int ret = _SUCCESS;
|
2014-12-13 21:18:54 +00:00
|
|
|
u32 start = jiffies;
|
2013-05-08 21:45:39 +00:00
|
|
|
|
2014-12-13 21:18:54 +00:00
|
|
|
if (pwrpriv->ips_deny_time < jiffies + rtw_ms_to_systime(ips_deffer_ms))
|
|
|
|
pwrpriv->ips_deny_time = jiffies + rtw_ms_to_systime(ips_deffer_ms);
|
2013-05-08 21:45:39 +00:00
|
|
|
|
|
|
|
if (pwrpriv->ps_processing) {
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("%s wait ps_processing...\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
while (pwrpriv->ps_processing && rtw_get_passing_time_ms(start) <= 3000)
|
|
|
|
rtw_msleep_os(10);
|
|
|
|
if (pwrpriv->ps_processing)
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("%s wait ps_processing timeout\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
else
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("%s wait ps_processing done\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* System suspend is not allowed to wakeup */
|
2014-11-20 06:12:27 +00:00
|
|
|
if ((!pwrpriv->bInternalAutoSuspend) && pwrpriv->bInSuspend) {
|
|
|
|
while (pwrpriv->bInSuspend &&
|
|
|
|
(rtw_get_passing_time_ms(start) <= 3000 ||
|
|
|
|
(rtw_get_passing_time_ms(start) <= 500)))
|
|
|
|
rtw_msleep_os(10);
|
|
|
|
if (pwrpriv->bInSuspend)
|
|
|
|
DBG_88E("%s wait bInSuspend timeout\n", __func__);
|
|
|
|
else
|
|
|
|
DBG_88E("%s wait bInSuspend done\n", __func__);
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* block??? */
|
2013-07-31 06:27:28 +00:00
|
|
|
if ((pwrpriv->bInternalAutoSuspend) && (padapter->net_closed)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* I think this should be check in IPS, LPS, autosuspend functions... */
|
2013-07-31 06:27:28 +00:00
|
|
|
if (check_fwstate(pmlmepriv, _FW_LINKED)) {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = _SUCCESS;
|
|
|
|
goto exit;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
2013-07-31 06:27:28 +00:00
|
|
|
if (rf_off == pwrpriv->rf_pwrstate) {
|
|
|
|
DBG_88E("%s call ips_leave....\n", __func__);
|
|
|
|
if (_FAIL == ips_leave(padapter)) {
|
2013-07-22 01:55:51 +00:00
|
|
|
DBG_88E("======> ips_leave fail.............\n");
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = _FAIL;
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-09 22:38:46 +00:00
|
|
|
/* TODO: the following checking need to be merged... */
|
2013-07-31 06:27:28 +00:00
|
|
|
if (padapter->bDriverStopped || !padapter->bup ||
|
|
|
|
!padapter->hw_init_completed) {
|
|
|
|
DBG_88E("%s: bDriverStopped=%d, bup=%d, hw_init_completed =%u\n"
|
2013-05-08 21:45:39 +00:00
|
|
|
, caller
|
2013-05-19 04:28:07 +00:00
|
|
|
, padapter->bDriverStopped
|
|
|
|
, padapter->bup
|
|
|
|
, padapter->hw_init_completed);
|
2013-07-31 06:27:28 +00:00
|
|
|
ret = false;
|
2013-05-08 21:45:39 +00:00
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit:
|
2014-12-13 21:18:54 +00:00
|
|
|
if (pwrpriv->ips_deny_time < jiffies + rtw_ms_to_systime(ips_deffer_ms))
|
|
|
|
pwrpriv->ips_deny_time = jiffies + rtw_ms_to_systime(ips_deffer_ms);
|
2013-05-08 21:45:39 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
int rtw_pm_set_lps(struct adapter *padapter, u8 mode)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
2013-05-19 04:28:07 +00:00
|
|
|
int ret = 0;
|
2013-05-08 21:45:39 +00:00
|
|
|
struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if (mode < PS_MODE_NUM) {
|
|
|
|
if (pwrctrlpriv->power_mgnt != mode) {
|
2013-05-09 04:04:25 +00:00
|
|
|
if (PS_MODE_ACTIVE == mode)
|
2013-05-08 21:45:39 +00:00
|
|
|
LeaveAllPowerSaveMode(padapter);
|
|
|
|
else
|
|
|
|
pwrctrlpriv->LpsIdleCount = 2;
|
|
|
|
pwrctrlpriv->power_mgnt = mode;
|
2013-07-31 06:27:28 +00:00
|
|
|
pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt) ? true : false;
|
2013-05-08 21:45:39 +00:00
|
|
|
}
|
2013-07-31 06:27:28 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
ret = -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-07-27 01:08:39 +00:00
|
|
|
int rtw_pm_set_ips(struct adapter *padapter, u8 mode)
|
2013-05-08 21:45:39 +00:00
|
|
|
{
|
|
|
|
struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
|
|
|
|
|
2013-07-31 06:27:28 +00:00
|
|
|
if (mode == IPS_NORMAL || mode == IPS_LEVEL_2) {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_ips_mode_req(pwrctrlpriv, mode);
|
2013-07-31 06:27:28 +00:00
|
|
|
DBG_88E("%s %s\n", __func__, mode == IPS_NORMAL ? "IPS_NORMAL" : "IPS_LEVEL_2");
|
2013-05-08 21:45:39 +00:00
|
|
|
return 0;
|
2013-07-31 06:27:28 +00:00
|
|
|
} else if (mode == IPS_NONE) {
|
2013-05-08 21:45:39 +00:00
|
|
|
rtw_ips_mode_req(pwrctrlpriv, mode);
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("%s %s\n", __func__, "IPS_NONE");
|
2013-07-31 06:27:28 +00:00
|
|
|
if ((padapter->bSurpriseRemoved == 0) && (_FAIL == rtw_pwr_wakeup(padapter)))
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EFAULT;
|
2013-07-31 06:27:28 +00:00
|
|
|
} else {
|
2013-05-08 21:45:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|