2008-04-22 06:41:51 +08:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2010-01-16 05:43:41 +08:00
|
|
|
* Copyright(c) 2007 - 2010 Intel Corporation. All rights reserved.
|
2008-04-22 06:41:51 +08: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-10 03:28:58 +08:00
|
|
|
* Intel Linux Wireless <ilw@linux.intel.com>
|
2008-04-22 06:41:51 +08: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 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2008-04-22 06:41:51 +08:00
|
|
|
#include <linux/init.h>
|
|
|
|
|
|
|
|
#include <net/mac80211.h>
|
|
|
|
|
|
|
|
#include "iwl-eeprom.h"
|
2008-04-25 02:55:38 +08:00
|
|
|
#include "iwl-dev.h"
|
2008-04-22 06:41:51 +08:00
|
|
|
#include "iwl-core.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-25 02:13:02 +08:00
|
|
|
#include "iwl-io.h"
|
2008-04-25 02:55:37 +08:00
|
|
|
#include "iwl-commands.h"
|
2008-04-22 06:41:51 +08:00
|
|
|
#include "iwl-debug.h"
|
|
|
|
#include "iwl-power.h"
|
|
|
|
|
|
|
|
/*
|
2009-08-08 06:41:51 +08:00
|
|
|
* Setting power level allows the card to go to sleep when not busy.
|
2008-04-22 06:41:51 +08:00
|
|
|
*
|
2009-08-08 06:41:51 +08: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-22 06:41:51 +08:00
|
|
|
*/
|
|
|
|
|
2009-08-08 06:41:51 +08:00
|
|
|
/*
|
|
|
|
* For now, keep using power level 1 instead of automatically
|
|
|
|
* adjusting ...
|
|
|
|
*/
|
|
|
|
bool no_sleep_autoadjust = true;
|
|
|
|
module_param(no_sleep_autoadjust, bool, S_IRUGO);
|
|
|
|
MODULE_PARM_DESC(no_sleep_autoadjust,
|
|
|
|
"don't automatically adjust sleep level "
|
|
|
|
"according to maximum network latency");
|
2008-04-22 06:41:51 +08:00
|
|
|
|
2009-08-08 06:41:51 +08: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-17 05:25:58 +08:00
|
|
|
u8 no_dtim; /* number of skip dtim */
|
2009-08-08 06:41:51 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define IWL_DTIM_RANGE_0_MAX 2
|
|
|
|
#define IWL_DTIM_RANGE_1_MAX 10
|
2008-04-22 06:41:51 +08:00
|
|
|
|
2009-05-09 04:44:38 +08:00
|
|
|
#define NOSLP cpu_to_le16(0), 0, 0
|
|
|
|
#define SLP IWL_POWER_DRIVER_ALLOW_SLEEP_MSK, 0, 0
|
|
|
|
#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-22 06:41:51 +08:00
|
|
|
/* default power management (not Tx power) table values */
|
2009-08-08 06:41:51 +08:00
|
|
|
/* for DTIM period 0 through IWL_DTIM_RANGE_0_MAX */
|
2009-10-17 05:25:58 +08:00
|
|
|
/* DTIM 0 - 2 */
|
2009-05-09 04:44:38 +08:00
|
|
|
static const struct iwl_power_vec_entry range_0[IWL_POWER_NUM] = {
|
2009-10-17 05:25:58 +08:00
|
|
|
{{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 1, 2, 2, 0xFF)}, 0},
|
2008-04-22 06:41:51 +08: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-08 06:41:51 +08:00
|
|
|
/* for DTIM period IWL_DTIM_RANGE_0_MAX + 1 through IWL_DTIM_RANGE_1_MAX */
|
2009-10-17 05:25:58 +08:00
|
|
|
/* DTIM 3 - 10 */
|
2009-05-09 04:44:38 +08:00
|
|
|
static const struct iwl_power_vec_entry range_1[IWL_POWER_NUM] = {
|
2008-04-22 06:41:51 +08: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-17 05:25:58 +08:00
|
|
|
{{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(2, 4, 6, 10, 10)}, 2}
|
2008-04-22 06:41:51 +08:00
|
|
|
};
|
|
|
|
|
2009-08-08 06:41:51 +08:00
|
|
|
/* for DTIM period > IWL_DTIM_RANGE_1_MAX */
|
2009-10-17 05:25:58 +08:00
|
|
|
/* DTIM 11 - */
|
2009-05-09 04:44:38 +08:00
|
|
|
static const struct iwl_power_vec_entry range_2[IWL_POWER_NUM] = {
|
2008-04-22 06:41:51 +08: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}
|
|
|
|
};
|
|
|
|
|
2009-08-08 06:41:51 +08: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-17 05:25:58 +08:00
|
|
|
int max_sleep[IWL_POWER_VEC_SIZE] = { 0 };
|
|
|
|
int i;
|
|
|
|
u8 skip;
|
|
|
|
u32 slp_itrvl;
|
2009-08-08 06:41:51 +08:00
|
|
|
|
|
|
|
table = range_2;
|
2009-10-17 05:25:58 +08:00
|
|
|
if (period <= IWL_DTIM_RANGE_1_MAX)
|
2009-08-08 06:41:51 +08:00
|
|
|
table = range_1;
|
2009-10-17 05:25:58 +08:00
|
|
|
if (period <= IWL_DTIM_RANGE_0_MAX)
|
2009-08-08 06:41:51 +08:00
|
|
|
table = range_0;
|
|
|
|
|
|
|
|
BUG_ON(lvl < 0 || lvl >= IWL_POWER_NUM);
|
|
|
|
|
|
|
|
*cmd = table[lvl].cmd;
|
|
|
|
|
|
|
|
if (period == 0) {
|
2009-10-17 05:25:58 +08:00
|
|
|
skip = 0;
|
2009-08-08 06:41:51 +08:00
|
|
|
period = 1;
|
2009-10-17 05:25:58 +08:00
|
|
|
for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
|
|
|
|
max_sleep[i] = 1;
|
|
|
|
|
2009-08-08 06:41:51 +08:00
|
|
|
} else {
|
2009-10-17 05:25:58 +08: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-08 06:41:51 +08:00
|
|
|
}
|
|
|
|
|
2009-10-17 05:25:58 +08: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-08 06:41:51 +08:00
|
|
|
cmd->flags |= IWL_POWER_SLEEP_OVER_DTIM_MSK;
|
2009-10-17 05:25:58 +08:00
|
|
|
else
|
2009-08-08 06:41:51 +08:00
|
|
|
cmd->flags &= ~IWL_POWER_SLEEP_OVER_DTIM_MSK;
|
|
|
|
|
2009-10-17 05:25:58 +08:00
|
|
|
slp_itrvl = le32_to_cpu(cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1]);
|
2009-10-24 04:42:33 +08:00
|
|
|
if (slp_itrvl > IWL_CONN_MAX_LISTEN_INTERVAL)
|
2009-10-17 05:25:58 +08:00
|
|
|
cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1] =
|
2009-10-24 04:42:33 +08:00
|
|
|
cpu_to_le32(IWL_CONN_MAX_LISTEN_INTERVAL);
|
2009-10-17 05:25:58 +08: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-08 06:41:51 +08:00
|
|
|
|
|
|
|
if (priv->power_data.pci_pm)
|
|
|
|
cmd->flags |= IWL_POWER_PCI_PM_MSK;
|
|
|
|
else
|
|
|
|
cmd->flags &= ~IWL_POWER_PCI_PM_MSK;
|
|
|
|
|
2009-10-17 05:25:58 +08:00
|
|
|
IWL_DEBUG_POWER(priv, "numSkipDtim = %u, dtimPeriod = %d\n",
|
|
|
|
skip, period);
|
2009-08-08 06:41:51 +08: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-22 06:41:51 +08:00
|
|
|
{
|
2009-08-08 06:41:51 +08:00
|
|
|
memset(cmd, 0, sizeof(*cmd));
|
2008-04-22 06:41:51 +08:00
|
|
|
|
2009-08-08 06:41:51 +08:00
|
|
|
if (priv->power_data.pci_pm)
|
|
|
|
cmd->flags |= IWL_POWER_PCI_PM_MSK;
|
2008-04-22 06:41:51 +08:00
|
|
|
|
2009-08-08 06:41:51 +08:00
|
|
|
IWL_DEBUG_POWER(priv, "Sleep command for CAM\n");
|
2008-04-22 06:41:51 +08:00
|
|
|
}
|
|
|
|
|
2009-08-08 06:41:51 +08:00
|
|
|
static void iwl_power_fill_sleep_cmd(struct iwl_priv *priv,
|
|
|
|
struct iwl_powertable_cmd *cmd,
|
|
|
|
int dynps_ms, int wakeup_period)
|
2008-04-22 06:41:51 +08:00
|
|
|
{
|
2009-08-29 00:44:48 +08:00
|
|
|
/*
|
|
|
|
* These are the original power level 3 sleep successions. The
|
|
|
|
* device may behave better with such succession and was also
|
|
|
|
* only tested with that. Just like the original sleep commands,
|
|
|
|
* also adjust the succession here to the wakeup_period below.
|
|
|
|
* The ranges are the same as for the sleep commands, 0-2, 3-9
|
|
|
|
* and >10, which is selected based on the DTIM interval for
|
|
|
|
* the sleep index but here we use the wakeup period since that
|
|
|
|
* is what we need to do for the latency requirements.
|
|
|
|
*/
|
|
|
|
static const u8 slp_succ_r0[IWL_POWER_VEC_SIZE] = { 2, 2, 2, 2, 2 };
|
|
|
|
static const u8 slp_succ_r1[IWL_POWER_VEC_SIZE] = { 2, 4, 6, 7, 9 };
|
|
|
|
static const u8 slp_succ_r2[IWL_POWER_VEC_SIZE] = { 2, 7, 9, 9, 0xFF };
|
|
|
|
const u8 *slp_succ = slp_succ_r0;
|
2009-01-20 07:30:21 +08:00
|
|
|
int i;
|
2008-04-22 06:41:51 +08:00
|
|
|
|
2009-08-29 00:44:48 +08:00
|
|
|
if (wakeup_period > IWL_DTIM_RANGE_0_MAX)
|
|
|
|
slp_succ = slp_succ_r1;
|
|
|
|
if (wakeup_period > IWL_DTIM_RANGE_1_MAX)
|
|
|
|
slp_succ = slp_succ_r2;
|
|
|
|
|
2009-08-08 06:41:51 +08:00
|
|
|
memset(cmd, 0, sizeof(*cmd));
|
2009-01-20 07:30:21 +08:00
|
|
|
|
2009-08-08 06:41:51 +08:00
|
|
|
cmd->flags = IWL_POWER_DRIVER_ALLOW_SLEEP_MSK |
|
|
|
|
IWL_POWER_FAST_PD; /* no use seeing frames for others */
|
2008-04-22 06:41:51 +08:00
|
|
|
|
2009-08-08 06:41:51 +08:00
|
|
|
if (priv->power_data.pci_pm)
|
|
|
|
cmd->flags |= IWL_POWER_PCI_PM_MSK;
|
2008-04-22 06:41:51 +08:00
|
|
|
|
2009-08-08 06:41:51 +08:00
|
|
|
cmd->rx_data_timeout = cpu_to_le32(1000 * dynps_ms);
|
|
|
|
cmd->tx_data_timeout = cpu_to_le32(1000 * dynps_ms);
|
2008-04-22 06:41:51 +08:00
|
|
|
|
2009-01-20 07:30:21 +08:00
|
|
|
for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
|
2009-08-29 00:44:48 +08:00
|
|
|
cmd->sleep_interval[i] =
|
|
|
|
cpu_to_le32(min_t(int, slp_succ[i], wakeup_period));
|
2009-08-08 06:41:51 +08:00
|
|
|
|
|
|
|
IWL_DEBUG_POWER(priv, "Automatic sleep command\n");
|
|
|
|
}
|
2008-04-22 06:41:51 +08:00
|
|
|
|
2009-08-08 06:41:51 +08: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-28 06:27:56 +08: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-22 06:41:51 +08: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]));
|
|
|
|
|
2009-08-08 06:41:51 +08:00
|
|
|
return iwl_send_cmd_pdu(priv, POWER_TABLE_CMD,
|
|
|
|
sizeof(struct iwl_powertable_cmd), cmd);
|
2008-04-22 06:41:51 +08:00
|
|
|
}
|
|
|
|
|
2010-01-22 03:52:28 +08:00
|
|
|
/* priv->mutex must be held */
|
2008-09-03 11:26:53 +08:00
|
|
|
int iwl_power_update_mode(struct iwl_priv *priv, bool force)
|
2008-04-22 06:41:51 +08:00
|
|
|
{
|
|
|
|
int ret = 0;
|
2010-01-21 21:24:04 +08:00
|
|
|
bool enabled = priv->hw->conf.flags & IEEE80211_CONF_PS;
|
2008-11-08 01:58:37 +08:00
|
|
|
bool update_chains;
|
2009-08-08 06:41:51 +08:00
|
|
|
struct iwl_powertable_cmd cmd;
|
|
|
|
int dtimper;
|
2008-04-22 06:41:51 +08:00
|
|
|
|
2008-09-03 11:26:53 +08:00
|
|
|
/* Don't update the RX chain when chain noise calibration is running */
|
2008-11-08 01:58:37 +08:00
|
|
|
update_chains = priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE ||
|
|
|
|
priv->chain_noise_data.state == IWL_CHAIN_NOISE_ALIVE;
|
2008-09-03 11:26:53 +08:00
|
|
|
|
2010-04-29 19:43:08 +08:00
|
|
|
dtimper = priv->hw->conf.ps_dtim_period ?: 1;
|
2009-08-08 06:41:51 +08:00
|
|
|
|
2009-09-12 01:50:37 +08:00
|
|
|
if (priv->cfg->broken_powersave)
|
|
|
|
iwl_power_sleep_cam_cmd(priv, &cmd);
|
2009-09-26 05:24:27 +08:00
|
|
|
else if (priv->cfg->supports_idle &&
|
|
|
|
priv->hw->conf.flags & IEEE80211_CONF_IDLE)
|
|
|
|
iwl_static_sleep_cmd(priv, &cmd, IWL_POWER_INDEX_5, 20);
|
2010-07-31 23:34:07 +08:00
|
|
|
else if (priv->cfg->ops->lib->tt_ops.lower_power_detection &&
|
|
|
|
priv->cfg->ops->lib->tt_ops.tt_power_mode) {
|
|
|
|
if (priv->cfg->ops->lib->tt_ops.lower_power_detection(priv)) {
|
|
|
|
/* in thermal throttling low power state */
|
|
|
|
iwl_static_sleep_cmd(priv, &cmd,
|
|
|
|
priv->cfg->ops->lib->tt_ops.tt_power_mode(priv),
|
|
|
|
dtimper);
|
|
|
|
}
|
|
|
|
} else if (!enabled)
|
2009-08-08 06:41:51 +08:00
|
|
|
iwl_power_sleep_cam_cmd(priv, &cmd);
|
|
|
|
else if (priv->power_data.debug_sleep_level_override >= 0)
|
|
|
|
iwl_static_sleep_cmd(priv, &cmd,
|
|
|
|
priv->power_data.debug_sleep_level_override,
|
|
|
|
dtimper);
|
|
|
|
else if (no_sleep_autoadjust)
|
|
|
|
iwl_static_sleep_cmd(priv, &cmd, IWL_POWER_INDEX_1, dtimper);
|
|
|
|
else
|
|
|
|
iwl_power_fill_sleep_cmd(priv, &cmd,
|
|
|
|
priv->hw->conf.dynamic_ps_timeout,
|
|
|
|
priv->hw->conf.max_sleep_period);
|
2008-04-22 06:41:51 +08:00
|
|
|
|
2009-05-09 04:44:38 +08:00
|
|
|
if (iwl_is_ready_rf(priv) &&
|
2009-08-08 06:41:51 +08:00
|
|
|
(memcmp(&priv->power_data.sleep_cmd, &cmd, sizeof(cmd)) || force)) {
|
|
|
|
if (cmd.flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK)
|
2008-04-22 06:41:51 +08:00
|
|
|
set_bit(STATUS_POWER_PMI, &priv->status);
|
|
|
|
|
2008-07-18 13:52:57 +08:00
|
|
|
ret = iwl_set_power(priv, &cmd);
|
2009-08-08 06:41:47 +08:00
|
|
|
if (!ret) {
|
2009-08-08 06:41:51 +08:00
|
|
|
if (!(cmd.flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK))
|
2009-08-08 06:41:47 +08:00
|
|
|
clear_bit(STATUS_POWER_PMI, &priv->status);
|
|
|
|
|
|
|
|
if (priv->cfg->ops->lib->update_chain_flags &&
|
|
|
|
update_chains)
|
|
|
|
priv->cfg->ops->lib->update_chain_flags(priv);
|
2009-08-29 00:44:49 +08:00
|
|
|
else if (priv->cfg->ops->lib->update_chain_flags)
|
2009-08-08 06:41:47 +08:00
|
|
|
IWL_DEBUG_POWER(priv,
|
|
|
|
"Cannot update the power, chain noise "
|
2008-11-08 01:58:37 +08:00
|
|
|
"calibration running: %d\n",
|
|
|
|
priv->chain_noise_data.state);
|
2009-08-08 06:41:51 +08:00
|
|
|
memcpy(&priv->power_data.sleep_cmd, &cmd, sizeof(cmd));
|
2009-08-08 06:41:47 +08:00
|
|
|
} else
|
|
|
|
IWL_ERR(priv, "set power fail, ret = %d", ret);
|
2008-04-22 06:41:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(iwl_power_update_mode);
|
|
|
|
|
2008-10-24 14:48:56 +08:00
|
|
|
/* initialize to default */
|
2008-04-22 06:41:51 +08:00
|
|
|
void iwl_power_initialize(struct iwl_priv *priv)
|
|
|
|
{
|
2009-08-08 06:41:51 +08:00
|
|
|
u16 lctl = iwl_pcie_link_ctl(priv);
|
|
|
|
|
|
|
|
priv->power_data.pci_pm = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN);
|
|
|
|
|
|
|
|
priv->power_data.debug_sleep_level_override = -1;
|
|
|
|
|
|
|
|
memset(&priv->power_data.sleep_cmd, 0,
|
|
|
|
sizeof(priv->power_data.sleep_cmd));
|
2008-04-22 06:41:51 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(iwl_power_initialize);
|