2008-04-22 05:41:51 +07:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
2011-04-05 23:42:00 +07:00
|
|
|
* Copyright(c) 2007 - 2011 Intel Corporation. All rights reserved.
|
2008-04-22 05:41:51 +07: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 02:28:58 +07:00
|
|
|
* Intel Linux Wireless <ilw@linux.intel.com>
|
2008-04-22 05:41:51 +07: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 15:04:11 +07:00
|
|
|
#include <linux/slab.h>
|
2008-04-22 05:41:51 +07:00
|
|
|
#include <linux/init.h>
|
|
|
|
|
|
|
|
#include <net/mac80211.h>
|
|
|
|
|
|
|
|
#include "iwl-eeprom.h"
|
2008-04-25 01:55:38 +07:00
|
|
|
#include "iwl-dev.h"
|
2011-06-04 03:52:40 +07:00
|
|
|
#include "iwl-agn.h"
|
2008-04-22 05:41:51 +07: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 01:13:02 +07:00
|
|
|
#include "iwl-io.h"
|
2008-04-25 01:55:37 +07:00
|
|
|
#include "iwl-commands.h"
|
2008-04-22 05:41:51 +07:00
|
|
|
#include "iwl-debug.h"
|
|
|
|
#include "iwl-power.h"
|
2011-07-08 22:46:16 +07:00
|
|
|
#include "iwl-trans.h"
|
2011-08-26 13:10:36 +07:00
|
|
|
#include "iwl-shared.h"
|
2008-04-22 05:41:51 +07:00
|
|
|
|
|
|
|
/*
|
2009-08-08 05:41:51 +07:00
|
|
|
* Setting power level allows the card to go to sleep when not busy.
|
2008-04-22 05:41:51 +07:00
|
|
|
*
|
2009-08-08 05:41:51 +07: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 05:41:51 +07:00
|
|
|
*/
|
|
|
|
|
2009-08-08 05:41:51 +07: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 04:25:58 +07:00
|
|
|
u8 no_dtim; /* number of skip dtim */
|
2009-08-08 05:41:51 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define IWL_DTIM_RANGE_0_MAX 2
|
|
|
|
#define IWL_DTIM_RANGE_1_MAX 10
|
2008-04-22 05:41:51 +07:00
|
|
|
|
2009-05-09 03:44:38 +07:00
|
|
|
#define NOSLP cpu_to_le16(0), 0, 0
|
|
|
|
#define SLP IWL_POWER_DRIVER_ALLOW_SLEEP_MSK, 0, 0
|
2010-11-24 01:58:56 +07: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-09 03:44:38 +07: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-22 05:41:51 +07:00
|
|
|
/* default power management (not Tx power) table values */
|
2009-08-08 05:41:51 +07:00
|
|
|
/* for DTIM period 0 through IWL_DTIM_RANGE_0_MAX */
|
2009-10-17 04:25:58 +07:00
|
|
|
/* DTIM 0 - 2 */
|
2009-05-09 03:44:38 +07:00
|
|
|
static const struct iwl_power_vec_entry range_0[IWL_POWER_NUM] = {
|
2009-10-17 04:25:58 +07:00
|
|
|
{{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 1, 2, 2, 0xFF)}, 0},
|
2008-04-22 05:41:51 +07: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 05:41:51 +07:00
|
|
|
/* for DTIM period IWL_DTIM_RANGE_0_MAX + 1 through IWL_DTIM_RANGE_1_MAX */
|
2009-10-17 04:25:58 +07:00
|
|
|
/* DTIM 3 - 10 */
|
2009-05-09 03:44:38 +07:00
|
|
|
static const struct iwl_power_vec_entry range_1[IWL_POWER_NUM] = {
|
2008-04-22 05:41:51 +07: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 04:25:58 +07:00
|
|
|
{{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(2, 4, 6, 10, 10)}, 2}
|
2008-04-22 05:41:51 +07:00
|
|
|
};
|
|
|
|
|
2009-08-08 05:41:51 +07:00
|
|
|
/* for DTIM period > IWL_DTIM_RANGE_1_MAX */
|
2009-10-17 04:25:58 +07:00
|
|
|
/* DTIM 11 - */
|
2009-05-09 03:44:38 +07:00
|
|
|
static const struct iwl_power_vec_entry range_2[IWL_POWER_NUM] = {
|
2008-04-22 05:41:51 +07: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-24 01:58:56 +07: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-08 05:41:51 +07: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 04:25:58 +07:00
|
|
|
int max_sleep[IWL_POWER_VEC_SIZE] = { 0 };
|
|
|
|
int i;
|
|
|
|
u8 skip;
|
|
|
|
u32 slp_itrvl;
|
2009-08-08 05:41:51 +07:00
|
|
|
|
2010-11-24 01:58:56 +07:00
|
|
|
if (priv->cfg->adv_pm) {
|
|
|
|
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-08 05:41:51 +07:00
|
|
|
|
2011-04-18 23:12:37 +07:00
|
|
|
if (WARN_ON(lvl < 0 || lvl >= IWL_POWER_NUM))
|
|
|
|
memset(cmd, 0, sizeof(*cmd));
|
|
|
|
else
|
|
|
|
*cmd = table[lvl].cmd;
|
2009-08-08 05:41:51 +07:00
|
|
|
|
|
|
|
if (period == 0) {
|
2009-10-17 04:25:58 +07:00
|
|
|
skip = 0;
|
2009-08-08 05:41:51 +07:00
|
|
|
period = 1;
|
2009-10-17 04:25:58 +07:00
|
|
|
for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
|
|
|
|
max_sleep[i] = 1;
|
|
|
|
|
2009-08-08 05:41:51 +07:00
|
|
|
} else {
|
2009-10-17 04:25:58 +07: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 05:41:51 +07:00
|
|
|
}
|
|
|
|
|
2009-10-17 04:25:58 +07: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 05:41:51 +07:00
|
|
|
cmd->flags |= IWL_POWER_SLEEP_OVER_DTIM_MSK;
|
2009-10-17 04:25:58 +07:00
|
|
|
else
|
2009-08-08 05:41:51 +07:00
|
|
|
cmd->flags &= ~IWL_POWER_SLEEP_OVER_DTIM_MSK;
|
|
|
|
|
2010-11-24 01:58:55 +07:00
|
|
|
if (priv->cfg->base_params->shadow_reg_enable)
|
|
|
|
cmd->flags |= IWL_POWER_SHADOW_REG_ENA;
|
|
|
|
else
|
|
|
|
cmd->flags &= ~IWL_POWER_SHADOW_REG_ENA;
|
|
|
|
|
2011-01-28 22:47:47 +07:00
|
|
|
if (iwl_advanced_bt_coexist(priv)) {
|
2010-11-24 01:58:54 +07:00
|
|
|
if (!priv->cfg->bt_params->bt_sco_disable)
|
|
|
|
cmd->flags |= IWL_POWER_BT_SCO_ENA;
|
|
|
|
else
|
|
|
|
cmd->flags &= ~IWL_POWER_BT_SCO_ENA;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-10-17 04:25:58 +07:00
|
|
|
slp_itrvl = le32_to_cpu(cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1]);
|
2009-10-24 03:42:33 +07:00
|
|
|
if (slp_itrvl > IWL_CONN_MAX_LISTEN_INTERVAL)
|
2009-10-17 04:25:58 +07:00
|
|
|
cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1] =
|
2009-10-24 03:42:33 +07:00
|
|
|
cpu_to_le32(IWL_CONN_MAX_LISTEN_INTERVAL);
|
2009-10-17 04:25:58 +07: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 05:41:51 +07:00
|
|
|
|
2011-06-11 01:23:36 +07:00
|
|
|
if (priv->power_data.bus_pm)
|
2009-08-08 05:41:51 +07:00
|
|
|
cmd->flags |= IWL_POWER_PCI_PM_MSK;
|
|
|
|
else
|
|
|
|
cmd->flags &= ~IWL_POWER_PCI_PM_MSK;
|
|
|
|
|
2009-10-17 04:25:58 +07:00
|
|
|
IWL_DEBUG_POWER(priv, "numSkipDtim = %u, dtimPeriod = %d\n",
|
|
|
|
skip, period);
|
2009-08-08 05:41:51 +07: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 05:41:51 +07:00
|
|
|
{
|
2009-08-08 05:41:51 +07:00
|
|
|
memset(cmd, 0, sizeof(*cmd));
|
2008-04-22 05:41:51 +07:00
|
|
|
|
2011-06-11 01:23:36 +07:00
|
|
|
if (priv->power_data.bus_pm)
|
2009-08-08 05:41:51 +07:00
|
|
|
cmd->flags |= IWL_POWER_PCI_PM_MSK;
|
2008-04-22 05:41:51 +07:00
|
|
|
|
2009-08-08 05:41:51 +07:00
|
|
|
IWL_DEBUG_POWER(priv, "Sleep command for CAM\n");
|
2008-04-22 05:41:51 +07:00
|
|
|
}
|
|
|
|
|
2009-08-08 05:41:51 +07: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 05:41:51 +07:00
|
|
|
{
|
2009-08-28 23:44:48 +07: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 06:30:21 +07:00
|
|
|
int i;
|
2008-04-22 05:41:51 +07:00
|
|
|
|
2009-08-28 23:44:48 +07: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 05:41:51 +07:00
|
|
|
memset(cmd, 0, sizeof(*cmd));
|
2009-01-20 06:30:21 +07:00
|
|
|
|
2009-08-08 05:41:51 +07:00
|
|
|
cmd->flags = IWL_POWER_DRIVER_ALLOW_SLEEP_MSK |
|
|
|
|
IWL_POWER_FAST_PD; /* no use seeing frames for others */
|
2008-04-22 05:41:51 +07:00
|
|
|
|
2011-06-11 01:23:36 +07:00
|
|
|
if (priv->power_data.bus_pm)
|
2009-08-08 05:41:51 +07:00
|
|
|
cmd->flags |= IWL_POWER_PCI_PM_MSK;
|
2008-04-22 05:41:51 +07:00
|
|
|
|
2010-11-24 01:58:55 +07:00
|
|
|
if (priv->cfg->base_params->shadow_reg_enable)
|
|
|
|
cmd->flags |= IWL_POWER_SHADOW_REG_ENA;
|
|
|
|
else
|
|
|
|
cmd->flags &= ~IWL_POWER_SHADOW_REG_ENA;
|
|
|
|
|
2011-01-28 22:47:47 +07:00
|
|
|
if (iwl_advanced_bt_coexist(priv)) {
|
2010-11-24 01:58:54 +07:00
|
|
|
if (!priv->cfg->bt_params->bt_sco_disable)
|
|
|
|
cmd->flags |= IWL_POWER_BT_SCO_ENA;
|
|
|
|
else
|
|
|
|
cmd->flags &= ~IWL_POWER_BT_SCO_ENA;
|
|
|
|
}
|
|
|
|
|
2009-08-08 05:41:51 +07:00
|
|
|
cmd->rx_data_timeout = cpu_to_le32(1000 * dynps_ms);
|
|
|
|
cmd->tx_data_timeout = cpu_to_le32(1000 * dynps_ms);
|
2008-04-22 05:41:51 +07:00
|
|
|
|
2009-01-20 06:30:21 +07:00
|
|
|
for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
|
2009-08-28 23:44:48 +07:00
|
|
|
cmd->sleep_interval[i] =
|
|
|
|
cpu_to_le32(min_t(int, slp_succ[i], wakeup_period));
|
2009-08-08 05:41:51 +07:00
|
|
|
|
|
|
|
IWL_DEBUG_POWER(priv, "Automatic sleep command\n");
|
|
|
|
}
|
2008-04-22 05:41:51 +07:00
|
|
|
|
2009-08-08 05:41:51 +07: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 05:27:56 +07: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 05:41:51 +07: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]));
|
|
|
|
|
2011-07-11 12:51:04 +07:00
|
|
|
return trans_send_cmd_pdu(&priv->trans, POWER_TABLE_CMD, CMD_SYNC,
|
2009-08-08 05:41:51 +07:00
|
|
|
sizeof(struct iwl_powertable_cmd), cmd);
|
2008-04-22 05:41:51 +07:00
|
|
|
}
|
|
|
|
|
2010-10-22 22:04:29 +07:00
|
|
|
static void iwl_power_build_cmd(struct iwl_priv *priv,
|
|
|
|
struct iwl_powertable_cmd *cmd)
|
2008-04-22 05:41:51 +07:00
|
|
|
{
|
2010-01-21 20:24:04 +07:00
|
|
|
bool enabled = priv->hw->conf.flags & IEEE80211_CONF_PS;
|
2009-08-08 05:41:51 +07:00
|
|
|
int dtimper;
|
2008-04-22 05:41:51 +07:00
|
|
|
|
2010-04-29 18:43:08 +07:00
|
|
|
dtimper = priv->hw->conf.ps_dtim_period ?: 1;
|
2009-08-08 05:41:51 +07:00
|
|
|
|
2011-07-16 03:23:45 +07:00
|
|
|
if (priv->wowlan)
|
|
|
|
iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, dtimper);
|
2011-08-02 23:08:37 +07:00
|
|
|
else if (!priv->cfg->base_params->no_idle_support &&
|
|
|
|
priv->hw->conf.flags & IEEE80211_CONF_IDLE)
|
2010-10-22 22:04:29 +07:00
|
|
|
iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, 20);
|
2011-04-18 23:30:09 +07:00
|
|
|
else if (iwl_tt_is_low_power_state(priv)) {
|
2010-08-07 02:39:14 +07:00
|
|
|
/* in thermal throttling low power state */
|
2010-10-22 22:04:29 +07:00
|
|
|
iwl_static_sleep_cmd(priv, cmd,
|
2011-04-18 23:30:09 +07:00
|
|
|
iwl_tt_current_power_mode(priv), dtimper);
|
2010-07-31 22:34:07 +07:00
|
|
|
} else if (!enabled)
|
2010-10-22 22:04:29 +07:00
|
|
|
iwl_power_sleep_cam_cmd(priv, cmd);
|
2009-08-08 05:41:51 +07:00
|
|
|
else if (priv->power_data.debug_sleep_level_override >= 0)
|
2010-10-22 22:04:29 +07:00
|
|
|
iwl_static_sleep_cmd(priv, cmd,
|
2009-08-08 05:41:51 +07:00
|
|
|
priv->power_data.debug_sleep_level_override,
|
|
|
|
dtimper);
|
2011-06-12 00:00:06 +07:00
|
|
|
else if (iwlagn_mod_params.no_sleep_autoadjust) {
|
|
|
|
if (iwlagn_mod_params.power_level > IWL_POWER_INDEX_1 &&
|
|
|
|
iwlagn_mod_params.power_level <= IWL_POWER_INDEX_5)
|
|
|
|
iwl_static_sleep_cmd(priv, cmd,
|
|
|
|
iwlagn_mod_params.power_level, dtimper);
|
|
|
|
else
|
|
|
|
iwl_static_sleep_cmd(priv, cmd,
|
|
|
|
IWL_POWER_INDEX_1, dtimper);
|
|
|
|
} else
|
2010-10-22 22:04:29 +07:00
|
|
|
iwl_power_fill_sleep_cmd(priv, cmd,
|
2009-08-08 05:41:51 +07:00
|
|
|
priv->hw->conf.dynamic_ps_timeout,
|
|
|
|
priv->hw->conf.max_sleep_period);
|
2010-10-22 22:04:29 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
int iwl_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd,
|
|
|
|
bool force)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
bool update_chains;
|
|
|
|
|
|
|
|
lockdep_assert_held(&priv->mutex);
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
if (!iwl_is_ready_rf(priv))
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
/* scan complete use sleep_power_next, need to be updated */
|
|
|
|
memcpy(&priv->power_data.sleep_cmd_next, cmd, sizeof(*cmd));
|
|
|
|
if (test_bit(STATUS_SCANNING, &priv->status) && !force) {
|
|
|
|
IWL_DEBUG_INFO(priv, "Defer power set mode while scanning\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmd->flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK)
|
|
|
|
set_bit(STATUS_POWER_PMI, &priv->status);
|
2008-04-22 05:41:51 +07:00
|
|
|
|
2010-10-22 22:04:29 +07:00
|
|
|
ret = iwl_set_power(priv, cmd);
|
|
|
|
if (!ret) {
|
|
|
|
if (!(cmd->flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK))
|
|
|
|
clear_bit(STATUS_POWER_PMI, &priv->status);
|
|
|
|
|
2011-07-08 22:46:17 +07:00
|
|
|
if (update_chains)
|
|
|
|
iwl_update_chain_flags(priv);
|
|
|
|
else
|
2010-10-22 22:04:29 +07:00
|
|
|
IWL_DEBUG_POWER(priv,
|
2009-08-08 05:41:47 +07:00
|
|
|
"Cannot update the power, chain noise "
|
2008-11-08 00:58:37 +07:00
|
|
|
"calibration running: %d\n",
|
|
|
|
priv->chain_noise_data.state);
|
2010-10-22 22:04:29 +07:00
|
|
|
|
|
|
|
memcpy(&priv->power_data.sleep_cmd, cmd, sizeof(*cmd));
|
|
|
|
} else
|
|
|
|
IWL_ERR(priv, "set power fail, ret = %d", ret);
|
2008-04-22 05:41:51 +07:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2010-10-22 22:04:29 +07: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-22 05:41:51 +07:00
|
|
|
|
2008-10-24 13:48:56 +07:00
|
|
|
/* initialize to default */
|
2008-04-22 05:41:51 +07:00
|
|
|
void iwl_power_initialize(struct iwl_priv *priv)
|
|
|
|
{
|
2011-07-11 14:48:51 +07:00
|
|
|
priv->power_data.bus_pm = bus_get_pm_support(priv->bus);
|
2009-08-08 05:41:51 +07:00
|
|
|
|
|
|
|
priv->power_data.debug_sleep_level_override = -1;
|
|
|
|
|
|
|
|
memset(&priv->power_data.sleep_cmd, 0,
|
|
|
|
sizeof(priv->power_data.sleep_cmd));
|
2008-04-22 05:41:51 +07:00
|
|
|
}
|