Release 4.11 drivers/staging/rtl8712/rtl871x_pwrctrl.c
/******************************************************************************
* rtl871x_pwrctrl.c
*
* Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
* Linux device driver for RTL8192SU
*
* 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
*
* Modifications for inclusion into the Linux staging tree are
* Copyright(c) 2010 Larry Finger. All rights reserved.
*
* Contact information:
* WLAN FAE <wlanfae@realtek.com>
* Larry Finger <Larry.Finger@lwfinger.net>
*
******************************************************************************/
#define _RTL871X_PWRCTRL_C_
#include "osdep_service.h"
#include "drv_types.h"
#include "osdep_intf.h"
#define RTL8712_SDIO_LOCAL_BASE 0X10100000
#define SDIO_HCPWM (RTL8712_SDIO_LOCAL_BASE + 0x0081)
void r8712_set_rpwm(struct _adapter *padapter, u8 val8)
{
u8 rpwm;
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
if (pwrpriv->rpwm == val8) {
if (pwrpriv->rpwm_retry == 0)
return;
}
if (padapter->bDriverStopped || padapter->bSurpriseRemoved)
return;
rpwm = val8 | pwrpriv->tog;
switch (val8) {
case PS_STATE_S1:
pwrpriv->cpwm = val8;
break;
case PS_STATE_S2:/* only for USB normal powersave mode use,
* temp mark some code.
*/
case PS_STATE_S3:
case PS_STATE_S4:
pwrpriv->cpwm = val8;
break;
default:
break;
}
pwrpriv->rpwm_retry = 0;
pwrpriv->rpwm = val8;
r8712_write8(padapter, 0x1025FE58, rpwm);
pwrpriv->tog += 0x80;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Larry Finger | 125 | 99.21% | 1 | 50.00% |
Raphaël Beamonte | 1 | 0.79% | 1 | 50.00% |
Total | 126 | 100.00% | 2 | 100.00% |
void r8712_set_ps_mode(struct _adapter *padapter, uint ps_mode, uint smart_ps)
{
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
if (ps_mode > PM_Card_Disable)
return;
/* if driver is in active state, we dont need set smart_ps.*/
if (ps_mode == PS_MODE_ACTIVE)
smart_ps = 0;
if ((pwrpriv->pwr_mode != ps_mode) || (pwrpriv->smart_ps != smart_ps)) {
if (pwrpriv->pwr_mode == PS_MODE_ACTIVE)
pwrpriv->bSleep = true;
else
pwrpriv->bSleep = false;
pwrpriv->pwr_mode = ps_mode;
pwrpriv->smart_ps = smart_ps;
schedule_work(&pwrpriv->SetPSModeWorkItem);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Larry Finger | 104 | 99.05% | 1 | 50.00% |
James A Shackleford | 1 | 0.95% | 1 | 50.00% |
Total | 105 | 100.00% | 2 | 100.00% |
/*
* Caller:ISR handler...
*
* This will be called when CPWM interrupt is up.
*
* using to update cpwn of drv; and drv will make a decision to up or
* down pwr level
*/
void r8712_cpwm_int_hdl(struct _adapter *padapter,
struct reportpwrstate_parm *preportpwrstate)
{
struct pwrctrl_priv *pwrpriv = &(padapter->pwrctrlpriv);
struct cmd_priv *pcmdpriv = &(padapter->cmdpriv);
if (pwrpriv->cpwm_tog == ((preportpwrstate->state) & 0x80))
return;
del_timer(&padapter->pwrctrlpriv.rpwm_check_timer);
mutex_lock(&pwrpriv->mutex_lock);
pwrpriv->cpwm = (preportpwrstate->state) & 0xf;
if (pwrpriv->cpwm >= PS_STATE_S2) {
if (pwrpriv->alives & CMD_ALIVE)
complete(&(pcmdpriv->cmd_queue_comp));
}
pwrpriv->cpwm_tog = (preportpwrstate->state) & 0x80;
mutex_unlock(&pwrpriv->mutex_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Larry Finger | 127 | 94.78% | 1 | 25.00% |
Binoy Jayan | 6 | 4.48% | 2 | 50.00% |
Sudip Mukherjee | 1 | 0.75% | 1 | 25.00% |
Total | 134 | 100.00% | 4 | 100.00% |
static inline void register_task_alive(struct pwrctrl_priv *pwrctrl, uint tag)
{
pwrctrl->alives |= tag;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Larry Finger | 21 | 100.00% | 1 | 100.00% |
Total | 21 | 100.00% | 1 | 100.00% |
static inline void unregister_task_alive(struct pwrctrl_priv *pwrctrl, uint tag)
{
if (pwrctrl->alives & tag)
pwrctrl->alives ^= tag;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Larry Finger | 29 | 100.00% | 1 | 100.00% |
Total | 29 | 100.00% | 1 | 100.00% |
static void _rpwm_check_handler (struct _adapter *padapter)
{
struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv;
if (padapter->bDriverStopped || padapter->bSurpriseRemoved)
return;
if (pwrpriv->cpwm != pwrpriv->rpwm)
schedule_work(&pwrpriv->rpwm_workitem);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Larry Finger | 49 | 98.00% | 1 | 50.00% |
James A Shackleford | 1 | 2.00% | 1 | 50.00% |
Total | 50 | 100.00% | 2 | 100.00% |
static void SetPSModeWorkItemCallback(struct work_struct *work)
{
struct pwrctrl_priv *pwrpriv = container_of(work,
struct pwrctrl_priv, SetPSModeWorkItem);
struct _adapter *padapter = container_of(pwrpriv,
struct _adapter, pwrctrlpriv);
if (!pwrpriv->bSleep) {
mutex_lock(&pwrpriv->mutex_lock);
if (pwrpriv->pwr_mode == PS_MODE_ACTIVE)
r8712_set_rpwm(padapter, PS_STATE_S4);
mutex_unlock(&pwrpriv->mutex_lock);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Larry Finger | 77 | 95.06% | 2 | 50.00% |
Binoy Jayan | 3 | 3.70% | 1 | 25.00% |
Wei Yongjun | 1 | 1.23% | 1 | 25.00% |
Total | 81 | 100.00% | 4 | 100.00% |
static void rpwm_workitem_callback(struct work_struct *work)
{
struct pwrctrl_priv *pwrpriv = container_of(work,
struct pwrctrl_priv, rpwm_workitem);
struct _adapter *padapter = container_of(pwrpriv,
struct _adapter, pwrctrlpriv);
if (pwrpriv->cpwm != pwrpriv->rpwm) {
mutex_lock(&pwrpriv->mutex_lock);
r8712_read8(padapter, SDIO_HCPWM);
pwrpriv->rpwm_retry = 1;
r8712_set_rpwm(padapter, pwrpriv->rpwm);
mutex_unlock(&pwrpriv->mutex_lock);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Larry Finger | 87 | 95.60% | 2 | 66.67% |
Binoy Jayan | 4 | 4.40% | 1 | 33.33% |
Total | 91 | 100.00% | 3 | 100.00% |
static void rpwm_check_handler (unsigned long data)
{
struct _adapter *adapter = (struct _adapter *)data;
_rpwm_check_handler(adapter);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Larry Finger | 23 | 85.19% | 1 | 50.00% |
Vaishali Thakkar | 4 | 14.81% | 1 | 50.00% |
Total | 27 | 100.00% | 2 | 100.00% |
void r8712_init_pwrctrl_priv(struct _adapter *padapter)
{
struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
memset((unsigned char *)pwrctrlpriv, 0, sizeof(struct pwrctrl_priv));
mutex_init(&pwrctrlpriv->mutex_lock);
pwrctrlpriv->cpwm = PS_STATE_S4;
pwrctrlpriv->pwr_mode = PS_MODE_ACTIVE;
pwrctrlpriv->smart_ps = 0;
pwrctrlpriv->tog = 0x80;
/* clear RPWM to ensure driver and fw back to initial state. */
r8712_write8(padapter, 0x1025FE58, 0);
INIT_WORK(&pwrctrlpriv->SetPSModeWorkItem, SetPSModeWorkItemCallback);
INIT_WORK(&pwrctrlpriv->rpwm_workitem, rpwm_workitem_callback);
setup_timer(&pwrctrlpriv->rpwm_check_timer, rpwm_check_handler,
(unsigned long)padapter);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Larry Finger | 109 | 93.97% | 1 | 25.00% |
Vaishali Thakkar | 3 | 2.59% | 1 | 25.00% |
James A Shackleford | 2 | 1.72% | 1 | 25.00% |
Binoy Jayan | 2 | 1.72% | 1 | 25.00% |
Total | 116 | 100.00% | 4 | 100.00% |
/*
* Caller: r8712_cmd_thread
* Check if the fw_pwrstate is okay for issuing cmd.
* If not (cpwm should be is less than P2 state), then the sub-routine
* will raise the cpwm to be greater than or equal to P2.
* Calling Context: Passive
* Return Value:
* _SUCCESS: r8712_cmd_thread can issue cmds to firmware afterwards.
* _FAIL: r8712_cmd_thread can not do anything.
*/
sint r8712_register_cmd_alive(struct _adapter *padapter)
{
uint res = _SUCCESS;
struct pwrctrl_priv *pwrctrl = &padapter->pwrctrlpriv;
mutex_lock(&pwrctrl->mutex_lock);
register_task_alive(pwrctrl, CMD_ALIVE);
if (pwrctrl->cpwm < PS_STATE_S2) {
r8712_set_rpwm(padapter, PS_STATE_S3);
res = _FAIL;
}
mutex_unlock(&pwrctrl->mutex_lock);
return res;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Larry Finger | 68 | 94.44% | 1 | 50.00% |
Binoy Jayan | 4 | 5.56% | 1 | 50.00% |
Total | 72 | 100.00% | 2 | 100.00% |
/*
* Caller: ISR
* If ISR's txdone,
* No more pkts for TX,
* Then driver shall call this fun. to power down firmware again.
*/
void r8712_unregister_cmd_alive(struct _adapter *padapter)
{
struct pwrctrl_priv *pwrctrl = &padapter->pwrctrlpriv;
mutex_lock(&pwrctrl->mutex_lock);
unregister_task_alive(pwrctrl, CMD_ALIVE);
if ((pwrctrl->cpwm > PS_STATE_S2) &&
(pwrctrl->pwr_mode > PS_MODE_ACTIVE)) {
if ((pwrctrl->alives == 0) &&
(check_fwstate(&padapter->mlmepriv,
_FW_UNDER_LINKING) != true)) {
r8712_set_rpwm(padapter, PS_STATE_S0);
}
}
mutex_unlock(&pwrctrl->mutex_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Larry Finger | 92 | 95.83% | 1 | 50.00% |
Binoy Jayan | 4 | 4.17% | 1 | 50.00% |
Total | 96 | 100.00% | 2 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Larry Finger | 932 | 95.88% | 2 | 16.67% |
Binoy Jayan | 23 | 2.37% | 2 | 16.67% |
Vaishali Thakkar | 7 | 0.72% | 1 | 8.33% |
James A Shackleford | 4 | 0.41% | 2 | 16.67% |
Vijai Kumar K | 2 | 0.21% | 1 | 8.33% |
Sudip Mukherjee | 1 | 0.10% | 1 | 8.33% |
Wei Yongjun | 1 | 0.10% | 1 | 8.33% |
Justin P. Mattock | 1 | 0.10% | 1 | 8.33% |
Raphaël Beamonte | 1 | 0.10% | 1 | 8.33% |
Total | 972 | 100.00% | 12 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.