2008-04-21 22:41:51 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2013-01-21 20:39:26 +00:00
|
|
|
* Copyright(c) 2007 - 2013 Intel Corporation. All rights reserved.
|
2008-04-21 22:41:51 +00:00
|
|
|
*
|
|
|
|
* Portions of this file are derived from the ipw3945 project, as well
|
|
|
|
* as portions of the ieee80211 subsystem header files.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* The full GNU General Public License is included in this distribution in the
|
|
|
|
* file called LICENSE.
|
|
|
|
*
|
|
|
|
* Contact Information:
|
2008-12-09 19:28:58 +00:00
|
|
|
* Intel Linux Wireless <ilw@linux.intel.com>
|
2008-04-21 22:41:51 +00:00
|
|
|
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2008-04-21 22:41:51 +00:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <net/mac80211.h>
|
iwlwifi: Thermal Throttling Management - Part 1
Part 1 of Thermal Throttling Management -
Thermal Throttling feature is used to put NIC into low power state when
driver detect the Radio temperature reach pre-defined threshold
Two Thermal Throttling Management Methods; this patch introduce the
Legacy Thermal Management:
IWL_TI_0: normal temperature, system power state
IWL_TI_1: high temperature detect, low power state
IWL_TI_2: higher temperature detected, lower power state
IWL_TI_CT_KILL: critical temperature detected, lowest power state
Once get into CT_KILL state, uCode go into sleep, driver will stop all
the active queues, then move to IWL_TI_CT_KILL state; also set up 5
seconds timer to toggle CSR flag, uCode wake up upon CSR flag change,
then measure the temperature.
If temperature is above CT_KILL exit threshold, uCode go backto sleep;
if temperature is below CT_KILL exit threshold, uCode send Card State
Notification response with appropriate CT_KILL status flag, and uCode
remain awake, Driver receive Card State Notification Response and update
the card temperature to the CT_KILL exit threshold.
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
2009-07-24 18:13:02 +00:00
|
|
|
#include "iwl-io.h"
|
2008-04-21 22:41:51 +00:00
|
|
|
#include "iwl-debug.h"
|
2011-07-08 15:46:16 +00:00
|
|
|
#include "iwl-trans.h"
|
2012-04-17 14:36:30 +00:00
|
|
|
#include "iwl-modparams.h"
|
2012-05-15 10:16:34 +00:00
|
|
|
#include "dev.h"
|
|
|
|
#include "agn.h"
|
|
|
|
#include "commands.h"
|
|
|
|
#include "power.h"
|
2008-04-21 22:41:51 +00:00
|
|
|
|
|
|
|
/*
|
2009-08-07 22:41:51 +00:00
|
|
|
* Setting power level allows the card to go to sleep when not busy.
|
2008-04-21 22:41:51 +00:00
|
|
|
*
|
2009-08-07 22:41:51 +00:00
|
|
|
* We calculate a sleep command based on the required latency, which
|
|
|
|
* we get from mac80211. In order to handle thermal throttling, we can
|
|
|
|
* also use pre-defined power levels.
|
2008-04-21 22:41:51 +00:00
|
|
|
*/
|
|
|
|
|
2009-08-07 22:41:51 +00:00
|
|
|
/*
|
|
|
|
* This defines the old power levels. They are still used by default
|
|
|
|
* (level 1) and for thermal throttle (levels 3 through 5)
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct iwl_power_vec_entry {
|
|
|
|
struct iwl_powertable_cmd cmd;
|
2009-10-16 21:25:58 +00:00
|
|
|
u8 no_dtim; /* number of skip dtim */
|
2009-08-07 22:41:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define IWL_DTIM_RANGE_0_MAX 2
|
|
|
|
#define IWL_DTIM_RANGE_1_MAX 10
|
2008-04-21 22:41:51 +00:00
|
|
|
|
2009-05-08 20:44:38 +00:00
|
|
|
#define NOSLP cpu_to_le16(0), 0, 0
|
|
|
|
#define SLP IWL_POWER_DRIVER_ALLOW_SLEEP_MSK, 0, 0
|
2010-11-23 18:58:56 +00:00
|
|
|
#define ASLP (IWL_POWER_POWER_SAVE_ENA_MSK | \
|
|
|
|
IWL_POWER_POWER_MANAGEMENT_ENA_MSK | \
|
|
|
|
IWL_POWER_ADVANCE_PM_ENA_MSK)
|
|
|
|
#define ASLP_TOUT(T) cpu_to_le32(T)
|
2009-05-08 20:44:38 +00:00
|
|
|
#define TU_TO_USEC 1024
|
|
|
|
#define SLP_TOUT(T) cpu_to_le32((T) * TU_TO_USEC)
|
|
|
|
#define SLP_VEC(X0, X1, X2, X3, X4) {cpu_to_le32(X0), \
|
|
|
|
cpu_to_le32(X1), \
|
|
|
|
cpu_to_le32(X2), \
|
|
|
|
cpu_to_le32(X3), \
|
|
|
|
cpu_to_le32(X4)}
|
2008-04-21 22:41:51 +00:00
|
|
|
/* default power management (not Tx power) table values */
|
2009-08-07 22:41:51 +00:00
|
|
|
/* for DTIM period 0 through IWL_DTIM_RANGE_0_MAX */
|
2009-10-16 21:25:58 +00:00
|
|
|
/* DTIM 0 - 2 */
|
2009-05-08 20:44:38 +00:00
|
|
|
static const struct iwl_power_vec_entry range_0[IWL_POWER_NUM] = {
|
2009-10-16 21:25:58 +00:00
|
|
|
{{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 1, 2, 2, 0xFF)}, 0},
|
2008-04-21 22:41:51 +00:00
|
|
|
{{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(1, 2, 2, 2, 0xFF)}, 0},
|
|
|
|
{{SLP, SLP_TOUT(50), SLP_TOUT(100), SLP_VEC(2, 2, 2, 2, 0xFF)}, 0},
|
|
|
|
{{SLP, SLP_TOUT(50), SLP_TOUT(25), SLP_VEC(2, 2, 4, 4, 0xFF)}, 1},
|
|
|
|
{{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(2, 2, 4, 6, 0xFF)}, 2}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-07 22:41:51 +00:00
|
|
|
/* for DTIM period IWL_DTIM_RANGE_0_MAX + 1 through IWL_DTIM_RANGE_1_MAX */
|
2009-10-16 21:25:58 +00:00
|
|
|
/* DTIM 3 - 10 */
|
2009-05-08 20:44:38 +00:00
|
|
|
static const struct iwl_power_vec_entry range_1[IWL_POWER_NUM] = {
|
2008-04-21 22:41:51 +00:00
|
|
|
{{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 4)}, 0},
|
|
|
|
{{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(1, 2, 3, 4, 7)}, 0},
|
|
|
|
{{SLP, SLP_TOUT(50), SLP_TOUT(100), SLP_VEC(2, 4, 6, 7, 9)}, 0},
|
|
|
|
{{SLP, SLP_TOUT(50), SLP_TOUT(25), SLP_VEC(2, 4, 6, 9, 10)}, 1},
|
2009-10-16 21:25:58 +00:00
|
|
|
{{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(2, 4, 6, 10, 10)}, 2}
|
2008-04-21 22:41:51 +00:00
|
|
|
};
|
|
|
|
|
2009-08-07 22:41:51 +00:00
|
|
|
/* for DTIM period > IWL_DTIM_RANGE_1_MAX */
|
2009-10-16 21:25:58 +00:00
|
|
|
/* DTIM 11 - */
|
2009-05-08 20:44:38 +00:00
|
|
|
static const struct iwl_power_vec_entry range_2[IWL_POWER_NUM] = {
|
2008-04-21 22:41:51 +00:00
|
|
|
{{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 0xFF)}, 0},
|
|
|
|
{{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(2, 4, 6, 7, 0xFF)}, 0},
|
|
|
|
{{SLP, SLP_TOUT(50), SLP_TOUT(100), SLP_VEC(2, 7, 9, 9, 0xFF)}, 0},
|
|
|
|
{{SLP, SLP_TOUT(50), SLP_TOUT(25), SLP_VEC(2, 7, 9, 9, 0xFF)}, 0},
|
|
|
|
{{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(4, 7, 10, 10, 0xFF)}, 0}
|
|
|
|
};
|
|
|
|
|
2010-11-23 18:58:56 +00:00
|
|
|
/* advance power management */
|
|
|
|
/* DTIM 0 - 2 */
|
|
|
|
static const struct iwl_power_vec_entry apm_range_0[IWL_POWER_NUM] = {
|
|
|
|
{{ASLP, 0, 0, ASLP_TOUT(50), ASLP_TOUT(50),
|
|
|
|
SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
|
|
|
|
{{ASLP, 0, 0, ASLP_TOUT(50), ASLP_TOUT(50),
|
|
|
|
SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
|
|
|
|
{{ASLP, 0, 0, ASLP_TOUT(50), ASLP_TOUT(50),
|
|
|
|
SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
|
|
|
|
{{ASLP, 0, 0, ASLP_TOUT(50), ASLP_TOUT(50),
|
|
|
|
SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
|
|
|
|
{{ASLP, 0, 0, ASLP_TOUT(50), ASLP_TOUT(50),
|
|
|
|
SLP_VEC(1, 2, 6, 8, 0xFF), ASLP_TOUT(2)}, 2}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* for DTIM period IWL_DTIM_RANGE_0_MAX + 1 through IWL_DTIM_RANGE_1_MAX */
|
|
|
|
/* DTIM 3 - 10 */
|
|
|
|
static const struct iwl_power_vec_entry apm_range_1[IWL_POWER_NUM] = {
|
|
|
|
{{ASLP, 0, 0, ASLP_TOUT(50), ASLP_TOUT(50),
|
|
|
|
SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
|
|
|
|
{{ASLP, 0, 0, ASLP_TOUT(50), ASLP_TOUT(50),
|
|
|
|
SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
|
|
|
|
{{ASLP, 0, 0, ASLP_TOUT(50), ASLP_TOUT(50),
|
|
|
|
SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
|
|
|
|
{{ASLP, 0, 0, ASLP_TOUT(50), ASLP_TOUT(50),
|
|
|
|
SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
|
|
|
|
{{ASLP, 0, 0, ASLP_TOUT(50), ASLP_TOUT(50),
|
|
|
|
SLP_VEC(1, 2, 6, 8, 0xFF), 0}, 2}
|
|
|
|
};
|
|
|
|
|
|
|
|
/* for DTIM period > IWL_DTIM_RANGE_1_MAX */
|
|
|
|
/* DTIM 11 - */
|
|
|
|
static const struct iwl_power_vec_entry apm_range_2[IWL_POWER_NUM] = {
|
|
|
|
{{ASLP, 0, 0, ASLP_TOUT(50), ASLP_TOUT(50),
|
|
|
|
SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
|
|
|
|
{{ASLP, 0, 0, ASLP_TOUT(50), ASLP_TOUT(50),
|
|
|
|
SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
|
|
|
|
{{ASLP, 0, 0, ASLP_TOUT(50), ASLP_TOUT(50),
|
|
|
|
SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
|
|
|
|
{{ASLP, 0, 0, ASLP_TOUT(50), ASLP_TOUT(50),
|
|
|
|
SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
|
|
|
|
{{ASLP, 0, 0, ASLP_TOUT(50), ASLP_TOUT(50),
|
|
|
|
SLP_VEC(1, 2, 6, 8, 0xFF), ASLP_TOUT(2)}, 2}
|
|
|
|
};
|
|
|
|
|
2009-08-07 22:41:51 +00:00
|
|
|
static void iwl_static_sleep_cmd(struct iwl_priv *priv,
|
|
|
|
struct iwl_powertable_cmd *cmd,
|
|
|
|
enum iwl_power_level lvl, int period)
|
|
|
|
{
|
|
|
|
const struct iwl_power_vec_entry *table;
|
2009-10-16 21:25:58 +00:00
|
|
|
int max_sleep[IWL_POWER_VEC_SIZE] = { 0 };
|
|
|
|
int i;
|
|
|
|
u8 skip;
|
|
|
|
u32 slp_itrvl;
|
2009-08-07 22:41:51 +00:00
|
|
|
|
2013-05-17 08:36:29 +00:00
|
|
|
if (priv->lib->adv_pm) {
|
2010-11-23 18:58:56 +00:00
|
|
|
table = apm_range_2;
|
|
|
|
if (period <= IWL_DTIM_RANGE_1_MAX)
|
|
|
|
table = apm_range_1;
|
|
|
|
if (period <= IWL_DTIM_RANGE_0_MAX)
|
|
|
|
table = apm_range_0;
|
|
|
|
} else {
|
|
|
|
table = range_2;
|
|
|
|
if (period <= IWL_DTIM_RANGE_1_MAX)
|
|
|
|
table = range_1;
|
|
|
|
if (period <= IWL_DTIM_RANGE_0_MAX)
|
|
|
|
table = range_0;
|
|
|
|
}
|
2009-08-07 22:41:51 +00:00
|
|
|
|
2011-04-18 16:12:37 +00:00
|
|
|
if (WARN_ON(lvl < 0 || lvl >= IWL_POWER_NUM))
|
|
|
|
memset(cmd, 0, sizeof(*cmd));
|
|
|
|
else
|
|
|
|
*cmd = table[lvl].cmd;
|
2009-08-07 22:41:51 +00:00
|
|
|
|
|
|
|
if (period == 0) {
|
2009-10-16 21:25:58 +00:00
|
|
|
skip = 0;
|
2009-08-07 22:41:51 +00:00
|
|
|
period = 1;
|
2009-10-16 21:25:58 +00:00
|
|
|
for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
|
|
|
|
max_sleep[i] = 1;
|
|
|
|
|
2009-08-07 22:41:51 +00:00
|
|
|
} else {
|
2009-10-16 21:25:58 +00:00
|
|
|
skip = table[lvl].no_dtim;
|
|
|
|
for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
|
|
|
|
max_sleep[i] = le32_to_cpu(cmd->sleep_interval[i]);
|
|
|
|
max_sleep[IWL_POWER_VEC_SIZE - 1] = skip + 1;
|
2009-08-07 22:41:51 +00:00
|
|
|
}
|
|
|
|
|
2009-10-16 21:25:58 +00:00
|
|
|
slp_itrvl = le32_to_cpu(cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1]);
|
|
|
|
/* figure out the listen interval based on dtim period and skip */
|
|
|
|
if (slp_itrvl == 0xFF)
|
|
|
|
cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1] =
|
|
|
|
cpu_to_le32(period * (skip + 1));
|
|
|
|
|
|
|
|
slp_itrvl = le32_to_cpu(cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1]);
|
|
|
|
if (slp_itrvl > period)
|
|
|
|
cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1] =
|
|
|
|
cpu_to_le32((slp_itrvl / period) * period);
|
|
|
|
|
|
|
|
if (skip)
|
2009-08-07 22:41:51 +00:00
|
|
|
cmd->flags |= IWL_POWER_SLEEP_OVER_DTIM_MSK;
|
2009-10-16 21:25:58 +00:00
|
|
|
else
|
2009-08-07 22:41:51 +00:00
|
|
|
cmd->flags &= ~IWL_POWER_SLEEP_OVER_DTIM_MSK;
|
|
|
|
|
2012-03-22 15:51:44 +00:00
|
|
|
if (priv->cfg->base_params->shadow_reg_enable)
|
2010-11-23 18:58:55 +00:00
|
|
|
cmd->flags |= IWL_POWER_SHADOW_REG_ENA;
|
|
|
|
else
|
|
|
|
cmd->flags &= ~IWL_POWER_SHADOW_REG_ENA;
|
|
|
|
|
2011-01-28 15:47:47 +00:00
|
|
|
if (iwl_advanced_bt_coexist(priv)) {
|
2013-05-17 08:36:29 +00:00
|
|
|
if (!priv->lib->bt_params->bt_sco_disable)
|
2010-11-23 18:58:54 +00:00
|
|
|
cmd->flags |= IWL_POWER_BT_SCO_ENA;
|
|
|
|
else
|
|
|
|
cmd->flags &= ~IWL_POWER_BT_SCO_ENA;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-16 21:25:58 +00:00
|
|
|
slp_itrvl = le32_to_cpu(cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1]);
|
2009-10-23 20:42:33 +00:00
|
|
|
if (slp_itrvl > IWL_CONN_MAX_LISTEN_INTERVAL)
|
2009-10-16 21:25:58 +00:00
|
|
|
cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1] =
|
2009-10-23 20:42:33 +00:00
|
|
|
cpu_to_le32(IWL_CONN_MAX_LISTEN_INTERVAL);
|
2009-10-16 21:25:58 +00:00
|
|
|
|
|
|
|
/* enforce max sleep interval */
|
|
|
|
for (i = IWL_POWER_VEC_SIZE - 1; i >= 0 ; i--) {
|
|
|
|
if (le32_to_cpu(cmd->sleep_interval[i]) >
|
|
|
|
(max_sleep[i] * period))
|
|
|
|
cmd->sleep_interval[i] =
|
|
|
|
cpu_to_le32(max_sleep[i] * period);
|
|
|
|
if (i != (IWL_POWER_VEC_SIZE - 1)) {
|
|
|
|
if (le32_to_cpu(cmd->sleep_interval[i]) >
|
|
|
|
le32_to_cpu(cmd->sleep_interval[i+1]))
|
|
|
|
cmd->sleep_interval[i] =
|
|
|
|
cmd->sleep_interval[i+1];
|
|
|
|
}
|
|
|
|
}
|
2009-08-07 22:41:51 +00:00
|
|
|
|
2011-06-10 18:23:36 +00:00
|
|
|
if (priv->power_data.bus_pm)
|
2009-08-07 22:41:51 +00:00
|
|
|
cmd->flags |= IWL_POWER_PCI_PM_MSK;
|
|
|
|
else
|
|
|
|
cmd->flags &= ~IWL_POWER_PCI_PM_MSK;
|
|
|
|
|
2009-10-16 21:25:58 +00:00
|
|
|
IWL_DEBUG_POWER(priv, "numSkipDtim = %u, dtimPeriod = %d\n",
|
|
|
|
skip, period);
|
2012-05-03 21:22:04 +00:00
|
|
|
/* The power level here is 0-4 (used as array index), but user expects
|
|
|
|
to see 1-5 (according to spec). */
|
2009-08-07 22:41:51 +00:00
|
|
|
IWL_DEBUG_POWER(priv, "Sleep command for index %d\n", lvl + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void iwl_power_sleep_cam_cmd(struct iwl_priv *priv,
|
|
|
|
struct iwl_powertable_cmd *cmd)
|
2008-04-21 22:41:51 +00:00
|
|
|
{
|
2009-08-07 22:41:51 +00:00
|
|
|
memset(cmd, 0, sizeof(*cmd));
|
2008-04-21 22:41:51 +00:00
|
|
|
|
2011-06-10 18:23:36 +00:00
|
|
|
if (priv->power_data.bus_pm)
|
2009-08-07 22:41:51 +00:00
|
|
|
cmd->flags |= IWL_POWER_PCI_PM_MSK;
|
2008-04-21 22:41:51 +00:00
|
|
|
|
2009-08-07 22:41:51 +00:00
|
|
|
IWL_DEBUG_POWER(priv, "Sleep command for CAM\n");
|
2008-04-21 22:41:51 +00:00
|
|
|
}
|
|
|
|
|
2009-08-07 22:41:51 +00:00
|
|
|
static int iwl_set_power(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd)
|
|
|
|
{
|
|
|
|
IWL_DEBUG_POWER(priv, "Sending power/sleep command\n");
|
2009-01-27 22:27:56 +00:00
|
|
|
IWL_DEBUG_POWER(priv, "Flags value = 0x%08X\n", cmd->flags);
|
|
|
|
IWL_DEBUG_POWER(priv, "Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout));
|
|
|
|
IWL_DEBUG_POWER(priv, "Rx timeout = %u\n", le32_to_cpu(cmd->rx_data_timeout));
|
|
|
|
IWL_DEBUG_POWER(priv, "Sleep interval vector = { %d , %d , %d , %d , %d }\n",
|
2008-04-21 22:41:51 +00:00
|
|
|
le32_to_cpu(cmd->sleep_interval[0]),
|
|
|
|
le32_to_cpu(cmd->sleep_interval[1]),
|
|
|
|
le32_to_cpu(cmd->sleep_interval[2]),
|
|
|
|
le32_to_cpu(cmd->sleep_interval[3]),
|
|
|
|
le32_to_cpu(cmd->sleep_interval[4]));
|
|
|
|
|
2012-03-06 21:30:39 +00:00
|
|
|
return iwl_dvm_send_cmd_pdu(priv, POWER_TABLE_CMD, CMD_SYNC,
|
2009-08-07 22:41:51 +00:00
|
|
|
sizeof(struct iwl_powertable_cmd), cmd);
|
2008-04-21 22:41:51 +00:00
|
|
|
}
|
|
|
|
|
2010-10-22 15:04:29 +00:00
|
|
|
static void iwl_power_build_cmd(struct iwl_priv *priv,
|
|
|
|
struct iwl_powertable_cmd *cmd)
|
2008-04-21 22:41:51 +00:00
|
|
|
{
|
2010-01-21 13:24:04 +00:00
|
|
|
bool enabled = priv->hw->conf.flags & IEEE80211_CONF_PS;
|
2009-08-07 22:41:51 +00:00
|
|
|
int dtimper;
|
2008-04-21 22:41:51 +00:00
|
|
|
|
2010-04-29 11:43:08 +00:00
|
|
|
dtimper = priv->hw->conf.ps_dtim_period ?: 1;
|
2009-08-07 22:41:51 +00:00
|
|
|
|
2012-03-05 19:24:36 +00:00
|
|
|
if (priv->wowlan)
|
2011-07-15 20:23:45 +00:00
|
|
|
iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, dtimper);
|
2013-05-17 08:36:29 +00:00
|
|
|
else if (!priv->lib->no_idle_support &&
|
2011-08-02 16:08:37 +00:00
|
|
|
priv->hw->conf.flags & IEEE80211_CONF_IDLE)
|
2010-10-22 15:04:29 +00:00
|
|
|
iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, 20);
|
2011-04-18 16:30:09 +00:00
|
|
|
else if (iwl_tt_is_low_power_state(priv)) {
|
2010-08-06 19:39:14 +00:00
|
|
|
/* in thermal throttling low power state */
|
2010-10-22 15:04:29 +00:00
|
|
|
iwl_static_sleep_cmd(priv, cmd,
|
2011-04-18 16:30:09 +00:00
|
|
|
iwl_tt_current_power_mode(priv), dtimper);
|
2010-07-31 15:34:07 +00:00
|
|
|
} else if (!enabled)
|
2010-10-22 15:04:29 +00:00
|
|
|
iwl_power_sleep_cam_cmd(priv, cmd);
|
2009-08-07 22:41:51 +00:00
|
|
|
else if (priv->power_data.debug_sleep_level_override >= 0)
|
2010-10-22 15:04:29 +00:00
|
|
|
iwl_static_sleep_cmd(priv, cmd,
|
2009-08-07 22:41:51 +00:00
|
|
|
priv->power_data.debug_sleep_level_override,
|
|
|
|
dtimper);
|
2012-03-09 07:58:46 +00:00
|
|
|
else {
|
2012-05-03 21:22:04 +00:00
|
|
|
/* Note that the user parameter is 1-5 (according to spec),
|
|
|
|
but we pass 0-4 because it acts as an array index. */
|
2012-04-17 14:36:30 +00:00
|
|
|
if (iwlwifi_mod_params.power_level > IWL_POWER_INDEX_1 &&
|
2012-05-03 21:22:04 +00:00
|
|
|
iwlwifi_mod_params.power_level <= IWL_POWER_NUM)
|
2011-06-11 17:00:06 +00:00
|
|
|
iwl_static_sleep_cmd(priv, cmd,
|
2012-05-03 21:22:04 +00:00
|
|
|
iwlwifi_mod_params.power_level - 1, dtimper);
|
2011-06-11 17:00:06 +00:00
|
|
|
else
|
|
|
|
iwl_static_sleep_cmd(priv, cmd,
|
|
|
|
IWL_POWER_INDEX_1, dtimper);
|
2012-03-09 07:58:46 +00:00
|
|
|
}
|
2010-10-22 15:04:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int iwl_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd,
|
|
|
|
bool force)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
bool update_chains;
|
|
|
|
|
2012-03-06 21:30:42 +00:00
|
|
|
lockdep_assert_held(&priv->mutex);
|
2010-10-22 15:04:29 +00:00
|
|
|
|
|
|
|
/* Don't update the RX chain when chain noise calibration is running */
|
|
|
|
update_chains = priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE ||
|
|
|
|
priv->chain_noise_data.state == IWL_CHAIN_NOISE_ALIVE;
|
|
|
|
|
|
|
|
if (!memcmp(&priv->power_data.sleep_cmd, cmd, sizeof(*cmd)) && !force)
|
|
|
|
return 0;
|
|
|
|
|
2012-03-07 17:52:37 +00:00
|
|
|
if (!iwl_is_ready_rf(priv))
|
2010-10-22 15:04:29 +00:00
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
/* scan complete use sleep_power_next, need to be updated */
|
|
|
|
memcpy(&priv->power_data.sleep_cmd_next, cmd, sizeof(*cmd));
|
2012-03-07 17:52:37 +00:00
|
|
|
if (test_bit(STATUS_SCANNING, &priv->status) && !force) {
|
2010-10-22 15:04:29 +00:00
|
|
|
IWL_DEBUG_INFO(priv, "Defer power set mode while scanning\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmd->flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK)
|
2012-03-15 20:27:06 +00:00
|
|
|
iwl_dvm_set_pmi(priv, true);
|
2008-04-21 22:41:51 +00:00
|
|
|
|
2010-10-22 15:04:29 +00:00
|
|
|
ret = iwl_set_power(priv, cmd);
|
|
|
|
if (!ret) {
|
|
|
|
if (!(cmd->flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK))
|
2012-03-15 20:27:06 +00:00
|
|
|
iwl_dvm_set_pmi(priv, false);
|
2010-10-22 15:04:29 +00:00
|
|
|
|
2011-07-08 15:46:17 +00:00
|
|
|
if (update_chains)
|
|
|
|
iwl_update_chain_flags(priv);
|
|
|
|
else
|
2010-10-22 15:04:29 +00:00
|
|
|
IWL_DEBUG_POWER(priv,
|
2009-08-07 22:41:47 +00:00
|
|
|
"Cannot update the power, chain noise "
|
2008-11-07 17:58:37 +00:00
|
|
|
"calibration running: %d\n",
|
|
|
|
priv->chain_noise_data.state);
|
2010-10-22 15:04:29 +00:00
|
|
|
|
|
|
|
memcpy(&priv->power_data.sleep_cmd, cmd, sizeof(*cmd));
|
|
|
|
} else
|
|
|
|
IWL_ERR(priv, "set power fail, ret = %d", ret);
|
2008-04-21 22:41:51 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2010-10-22 15:04:29 +00:00
|
|
|
|
|
|
|
int iwl_power_update_mode(struct iwl_priv *priv, bool force)
|
|
|
|
{
|
|
|
|
struct iwl_powertable_cmd cmd;
|
|
|
|
|
|
|
|
iwl_power_build_cmd(priv, &cmd);
|
|
|
|
return iwl_power_set_mode(priv, &cmd, force);
|
|
|
|
}
|
2008-04-21 22:41:51 +00:00
|
|
|
|
2008-10-24 06:48:56 +00:00
|
|
|
/* initialize to default */
|
2008-04-21 22:41:51 +00:00
|
|
|
void iwl_power_initialize(struct iwl_priv *priv)
|
|
|
|
{
|
2012-04-18 14:28:17 +00:00
|
|
|
priv->power_data.bus_pm = priv->trans->pm_support;
|
2009-08-07 22:41:51 +00:00
|
|
|
|
|
|
|
priv->power_data.debug_sleep_level_override = -1;
|
|
|
|
|
|
|
|
memset(&priv->power_data.sleep_cmd, 0,
|
|
|
|
sizeof(priv->power_data.sleep_cmd));
|
2008-04-21 22:41:51 +00:00
|
|
|
}
|