iwl-power.c 31.4 KB
Newer Older
M
Mohamed Abbas 已提交
1 2
/******************************************************************************
 *
3
 * Copyright(c) 2007 - 2010 Intel Corporation. All rights reserved.
M
Mohamed Abbas 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 *
 * 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:
25
 *  Intel Linux Wireless <ilw@linux.intel.com>
M
Mohamed Abbas 已提交
26 27 28 29 30 31 32 33 34 35 36
 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 *****************************************************************************/


#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>

#include <net/mac80211.h>

#include "iwl-eeprom.h"
37
#include "iwl-dev.h"
M
Mohamed Abbas 已提交
38
#include "iwl-core.h"
39
#include "iwl-io.h"
40
#include "iwl-commands.h"
M
Mohamed Abbas 已提交
41 42 43 44
#include "iwl-debug.h"
#include "iwl-power.h"

/*
45
 * Setting power level allows the card to go to sleep when not busy.
M
Mohamed Abbas 已提交
46
 *
47 48 49
 * 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.
M
Mohamed Abbas 已提交
50 51
 */

52 53 54 55 56 57 58 59 60
/*
 * 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");
M
Mohamed Abbas 已提交
61

62 63 64 65 66 67 68
/*
 * 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;
W
Wey-Yi Guy 已提交
69
	u8 no_dtim;	/* number of skip dtim */
70 71 72 73
};

#define IWL_DTIM_RANGE_0_MAX	2
#define IWL_DTIM_RANGE_1_MAX	10
M
Mohamed Abbas 已提交
74

J
Johannes Berg 已提交
75 76 77 78 79 80 81 82 83
#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)}
M
Mohamed Abbas 已提交
84
/* default power management (not Tx power) table values */
85
/* for DTIM period 0 through IWL_DTIM_RANGE_0_MAX */
W
Wey-Yi Guy 已提交
86
/* DTIM 0 - 2 */
J
Johannes Berg 已提交
87
static const struct iwl_power_vec_entry range_0[IWL_POWER_NUM] = {
W
Wey-Yi Guy 已提交
88
	{{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 1, 2, 2, 0xFF)}, 0},
M
Mohamed Abbas 已提交
89 90 91 92 93 94 95
	{{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}
};


96
/* for DTIM period IWL_DTIM_RANGE_0_MAX + 1 through IWL_DTIM_RANGE_1_MAX */
W
Wey-Yi Guy 已提交
97
/* DTIM 3 - 10 */
J
Johannes Berg 已提交
98
static const struct iwl_power_vec_entry range_1[IWL_POWER_NUM] = {
M
Mohamed Abbas 已提交
99 100 101 102
	{{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},
W
Wey-Yi Guy 已提交
103
	{{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(2, 4, 6, 10, 10)}, 2}
M
Mohamed Abbas 已提交
104 105
};

106
/* for DTIM period > IWL_DTIM_RANGE_1_MAX */
W
Wey-Yi Guy 已提交
107
/* DTIM 11 - */
J
Johannes Berg 已提交
108
static const struct iwl_power_vec_entry range_2[IWL_POWER_NUM] = {
M
Mohamed Abbas 已提交
109 110 111 112 113 114 115
	{{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}
};

116 117 118 119 120
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;
W
Wey-Yi Guy 已提交
121 122 123 124
	int max_sleep[IWL_POWER_VEC_SIZE] = { 0 };
	int i;
	u8 skip;
	u32 slp_itrvl;
125 126

	table = range_2;
W
Wey-Yi Guy 已提交
127
	if (period <= IWL_DTIM_RANGE_1_MAX)
128
		table = range_1;
W
Wey-Yi Guy 已提交
129
	if (period <= IWL_DTIM_RANGE_0_MAX)
130 131 132 133 134 135 136
		table = range_0;

	BUG_ON(lvl < 0 || lvl >= IWL_POWER_NUM);

	*cmd = table[lvl].cmd;

	if (period == 0) {
W
Wey-Yi Guy 已提交
137
		skip = 0;
138
		period = 1;
W
Wey-Yi Guy 已提交
139 140 141
		for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
			max_sleep[i] =  1;

142
	} else {
W
Wey-Yi Guy 已提交
143 144 145 146
		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;
147 148
	}

W
Wey-Yi Guy 已提交
149 150 151 152 153 154 155 156 157 158 159 160
	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)
161
		cmd->flags |= IWL_POWER_SLEEP_OVER_DTIM_MSK;
W
Wey-Yi Guy 已提交
162
	else
163 164
		cmd->flags &= ~IWL_POWER_SLEEP_OVER_DTIM_MSK;

W
Wey-Yi Guy 已提交
165
	slp_itrvl = le32_to_cpu(cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1]);
W
Wey-Yi Guy 已提交
166
	if (slp_itrvl > IWL_CONN_MAX_LISTEN_INTERVAL)
W
Wey-Yi Guy 已提交
167
		cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1] =
W
Wey-Yi Guy 已提交
168
			cpu_to_le32(IWL_CONN_MAX_LISTEN_INTERVAL);
W
Wey-Yi Guy 已提交
169 170 171 172 173 174 175 176 177 178 179 180 181 182

	/* 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];
		}
	}
183 184 185 186 187 188

	if (priv->power_data.pci_pm)
		cmd->flags |= IWL_POWER_PCI_PM_MSK;
	else
		cmd->flags &= ~IWL_POWER_PCI_PM_MSK;

W
Wey-Yi Guy 已提交
189 190
	IWL_DEBUG_POWER(priv, "numSkipDtim = %u, dtimPeriod = %d\n",
			skip, period);
191 192 193
	IWL_DEBUG_POWER(priv, "Sleep command for index %d\n", lvl + 1);
}

194 195 196 197 198
/* default Thermal Throttling transaction table
 * Current state   |         Throttling Down               |  Throttling Up
 *=============================================================================
 *                 Condition Nxt State  Condition Nxt State Condition Nxt State
 *-----------------------------------------------------------------------------
199 200 201
 *     IWL_TI_0     T >= 114   CT_KILL  114>T>=105   TI_1      N/A      N/A
 *     IWL_TI_1     T >= 114   CT_KILL  114>T>=110   TI_2     T<=95     TI_0
 *     IWL_TI_2     T >= 114   CT_KILL                        T<=100    TI_1
202 203 204 205 206
 *    IWL_CT_KILL      N/A       N/A       N/A        N/A     T<=95     TI_0
 *=============================================================================
 */
static const struct iwl_tt_trans tt_range_0[IWL_TI_STATE_MAX - 1] = {
	{IWL_TI_0, IWL_ABSOLUTE_ZERO, 104},
207 208
	{IWL_TI_1, 105, CT_KILL_THRESHOLD - 1},
	{IWL_TI_CT_KILL, CT_KILL_THRESHOLD, IWL_ABSOLUTE_MAX}
209 210 211
};
static const struct iwl_tt_trans tt_range_1[IWL_TI_STATE_MAX - 1] = {
	{IWL_TI_0, IWL_ABSOLUTE_ZERO, 95},
212 213
	{IWL_TI_2, 110, CT_KILL_THRESHOLD - 1},
	{IWL_TI_CT_KILL, CT_KILL_THRESHOLD, IWL_ABSOLUTE_MAX}
214 215 216
};
static const struct iwl_tt_trans tt_range_2[IWL_TI_STATE_MAX - 1] = {
	{IWL_TI_1, IWL_ABSOLUTE_ZERO, 100},
217 218
	{IWL_TI_CT_KILL, CT_KILL_THRESHOLD, IWL_ABSOLUTE_MAX},
	{IWL_TI_CT_KILL, CT_KILL_THRESHOLD, IWL_ABSOLUTE_MAX}
219 220 221 222 223 224 225 226 227
};
static const struct iwl_tt_trans tt_range_3[IWL_TI_STATE_MAX - 1] = {
	{IWL_TI_0, IWL_ABSOLUTE_ZERO, CT_KILL_EXIT_THRESHOLD},
	{IWL_TI_CT_KILL, CT_KILL_EXIT_THRESHOLD + 1, IWL_ABSOLUTE_MAX},
	{IWL_TI_CT_KILL, CT_KILL_EXIT_THRESHOLD + 1, IWL_ABSOLUTE_MAX}
};

/* Advance Thermal Throttling default restriction table */
static const struct iwl_tt_restriction restriction_range[IWL_TI_STATE_MAX] = {
228 229 230 231
	{IWL_ANT_OK_MULTI, IWL_ANT_OK_MULTI, true },
	{IWL_ANT_OK_SINGLE, IWL_ANT_OK_MULTI, true },
	{IWL_ANT_OK_SINGLE, IWL_ANT_OK_SINGLE, false },
	{IWL_ANT_OK_NONE, IWL_ANT_OK_NONE, false }
232
};
233

M
Mohamed Abbas 已提交
234

235 236
static void iwl_power_sleep_cam_cmd(struct iwl_priv *priv,
				    struct iwl_powertable_cmd *cmd)
M
Mohamed Abbas 已提交
237
{
238
	memset(cmd, 0, sizeof(*cmd));
M
Mohamed Abbas 已提交
239

240 241
	if (priv->power_data.pci_pm)
		cmd->flags |= IWL_POWER_PCI_PM_MSK;
M
Mohamed Abbas 已提交
242

243
	IWL_DEBUG_POWER(priv, "Sleep command for CAM\n");
M
Mohamed Abbas 已提交
244 245
}

246 247 248
static void iwl_power_fill_sleep_cmd(struct iwl_priv *priv,
				     struct iwl_powertable_cmd *cmd,
				     int dynps_ms, int wakeup_period)
M
Mohamed Abbas 已提交
249
{
250 251 252 253 254 255 256 257 258 259 260 261 262 263
	/*
	 * 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;
264
	int i;
M
Mohamed Abbas 已提交
265

266 267 268 269 270
	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;

271
	memset(cmd, 0, sizeof(*cmd));
272

273 274
	cmd->flags = IWL_POWER_DRIVER_ALLOW_SLEEP_MSK |
		     IWL_POWER_FAST_PD; /* no use seeing frames for others */
M
Mohamed Abbas 已提交
275

276 277
	if (priv->power_data.pci_pm)
		cmd->flags |= IWL_POWER_PCI_PM_MSK;
M
Mohamed Abbas 已提交
278

279 280
	cmd->rx_data_timeout = cpu_to_le32(1000 * dynps_ms);
	cmd->tx_data_timeout = cpu_to_le32(1000 * dynps_ms);
M
Mohamed Abbas 已提交
281

282
	for (i = 0; i < IWL_POWER_VEC_SIZE; i++)
283 284
		cmd->sleep_interval[i] =
			cpu_to_le32(min_t(int, slp_succ[i], wakeup_period));
285 286 287

	IWL_DEBUG_POWER(priv, "Automatic sleep command\n");
}
M
Mohamed Abbas 已提交
288

289 290 291
static int iwl_set_power(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd)
{
	IWL_DEBUG_POWER(priv, "Sending power/sleep command\n");
292 293 294 295
	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",
M
Mohamed Abbas 已提交
296 297 298 299 300 301
			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]));

302 303
	return iwl_send_cmd_pdu(priv, POWER_TABLE_CMD,
				sizeof(struct iwl_powertable_cmd), cmd);
M
Mohamed Abbas 已提交
304 305
}

306
/* priv->mutex must be held */
307
int iwl_power_update_mode(struct iwl_priv *priv, bool force)
M
Mohamed Abbas 已提交
308 309
{
	int ret = 0;
310
	struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
311
	bool enabled = priv->hw->conf.flags & IEEE80211_CONF_PS;
312
	bool update_chains;
313 314
	struct iwl_powertable_cmd cmd;
	int dtimper;
M
Mohamed Abbas 已提交
315

316
	/* Don't update the RX chain when chain noise calibration is running */
317 318
	update_chains = priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE ||
			priv->chain_noise_data.state == IWL_CHAIN_NOISE_ALIVE;
319

320
	if (priv->vif)
321
		dtimper = priv->hw->conf.ps_dtim_period;
322 323 324
	else
		dtimper = 1;

325 326
	if (priv->cfg->broken_powersave)
		iwl_power_sleep_cam_cmd(priv, &cmd);
327 328 329
	else if (priv->cfg->supports_idle &&
		 priv->hw->conf.flags & IEEE80211_CONF_IDLE)
		iwl_static_sleep_cmd(priv, &cmd, IWL_POWER_INDEX_5, 20);
330
	else if (tt->state >= IWL_TI_1)
331 332 333 334 335 336 337 338 339 340 341 342 343
		iwl_static_sleep_cmd(priv, &cmd, tt->tt_power_mode, dtimper);
	else if (!enabled)
		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);
M
Mohamed Abbas 已提交
344

J
Johannes Berg 已提交
345
	if (iwl_is_ready_rf(priv) &&
346 347
	    (memcmp(&priv->power_data.sleep_cmd, &cmd, sizeof(cmd)) || force)) {
		if (cmd.flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK)
M
Mohamed Abbas 已提交
348 349
			set_bit(STATUS_POWER_PMI, &priv->status);

350
		ret = iwl_set_power(priv, &cmd);
351
		if (!ret) {
352
			if (!(cmd.flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK))
353 354 355 356 357
				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);
358
			else if (priv->cfg->ops->lib->update_chain_flags)
359 360
				IWL_DEBUG_POWER(priv,
					"Cannot update the power, chain noise "
361 362
					"calibration running: %d\n",
					priv->chain_noise_data.state);
363
			memcpy(&priv->power_data.sleep_cmd, &cmd, sizeof(cmd));
364 365
		} else
			IWL_ERR(priv, "set power fail, ret = %d", ret);
M
Mohamed Abbas 已提交
366 367 368 369 370 371
	}

	return ret;
}
EXPORT_SYMBOL(iwl_power_update_mode);

372 373
bool iwl_ht_enabled(struct iwl_priv *priv)
{
374
	struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
375 376
	struct iwl_tt_restriction *restriction;

377
	if (!priv->thermal_throttle.advanced_tt)
378 379 380 381 382 383
		return true;
	restriction = tt->restriction + tt->state;
	return restriction->is_ht;
}
EXPORT_SYMBOL(iwl_ht_enabled);

384 385
bool iwl_within_ct_kill_margin(struct iwl_priv *priv)
{
386
	s32 temp = priv->temperature; /* degrees CELSIUS except specified */
387 388
	bool within_margin = false;

389
	if (priv->cfg->temperature_kelvin)
390 391 392 393 394 395 396 397 398 399 400
		temp = KELVIN_TO_CELSIUS(priv->temperature);

	if (!priv->thermal_throttle.advanced_tt)
		within_margin = ((temp + IWL_TT_CT_KILL_MARGIN) >=
				CT_KILL_THRESHOLD_LEGACY) ? true : false;
	else
		within_margin = ((temp + IWL_TT_CT_KILL_MARGIN) >=
				CT_KILL_THRESHOLD) ? true : false;
	return within_margin;
}

401
enum iwl_antenna_ok iwl_tx_ant_restriction(struct iwl_priv *priv)
402
{
403
	struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
404 405
	struct iwl_tt_restriction *restriction;

406 407
	if (!priv->thermal_throttle.advanced_tt)
		return IWL_ANT_OK_MULTI;
408 409 410 411 412
	restriction = tt->restriction + tt->state;
	return restriction->tx_stream;
}
EXPORT_SYMBOL(iwl_tx_ant_restriction);

413
enum iwl_antenna_ok iwl_rx_ant_restriction(struct iwl_priv *priv)
414
{
415
	struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
416 417
	struct iwl_tt_restriction *restriction;

418 419
	if (!priv->thermal_throttle.advanced_tt)
		return IWL_ANT_OK_MULTI;
420 421 422 423
	restriction = tt->restriction + tt->state;
	return restriction->rx_stream;
}

424
#define CT_KILL_EXIT_DURATION (5)	/* 5 seconds duration */
425
#define CT_KILL_WAITING_DURATION (300)	/* 300ms duration */
426 427 428 429 430 431 432 433 434 435 436 437

/*
 * toggle the bit to wake up uCode and check the temperature
 * if the temperature is below CT, uCode will stay awake and send card
 * state notification with CT_KILL bit clear to inform Thermal Throttling
 * Management to change state. Otherwise, uCode will go back to sleep
 * without doing anything, driver should continue the 5 seconds timer
 * to wake up uCode for temperature check until temperature drop below CT
 */
static void iwl_tt_check_exit_ct_kill(unsigned long data)
{
	struct iwl_priv *priv = (struct iwl_priv *)data;
438
	struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
439 440 441 442 443 444
	unsigned long flags;

	if (test_bit(STATUS_EXIT_PENDING, &priv->status))
		return;

	if (tt->state == IWL_TI_CT_KILL) {
445
		if (priv->thermal_throttle.ct_kill_toggle) {
446 447
			iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR,
				    CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
448
			priv->thermal_throttle.ct_kill_toggle = false;
449 450 451
		} else {
			iwl_write32(priv, CSR_UCODE_DRV_GP1_SET,
				    CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT);
452
			priv->thermal_throttle.ct_kill_toggle = true;
453 454 455 456 457 458 459 460 461 462
		}
		iwl_read32(priv, CSR_UCODE_DRV_GP1);
		spin_lock_irqsave(&priv->reg_lock, flags);
		if (!iwl_grab_nic_access(priv))
			iwl_release_nic_access(priv);
		spin_unlock_irqrestore(&priv->reg_lock, flags);

		/* Reschedule the ct_kill timer to occur in
		 * CT_KILL_EXIT_DURATION seconds to ensure we get a
		 * thermal update */
463
		IWL_DEBUG_POWER(priv, "schedule ct_kill exit timer\n");
464
		mod_timer(&priv->thermal_throttle.ct_kill_exit_tm, jiffies +
465 466 467 468 469 470 471 472 473 474 475 476 477
			  CT_KILL_EXIT_DURATION * HZ);
	}
}

static void iwl_perform_ct_kill_task(struct iwl_priv *priv,
			   bool stop)
{
	if (stop) {
		IWL_DEBUG_POWER(priv, "Stop all queues\n");
		if (priv->mac80211_registered)
			ieee80211_stop_queues(priv->hw);
		IWL_DEBUG_POWER(priv,
				"Schedule 5 seconds CT_KILL Timer\n");
478
		mod_timer(&priv->thermal_throttle.ct_kill_exit_tm, jiffies +
479 480 481 482 483 484 485 486
			  CT_KILL_EXIT_DURATION * HZ);
	} else {
		IWL_DEBUG_POWER(priv, "Wake all queues\n");
		if (priv->mac80211_registered)
			ieee80211_wake_queues(priv->hw);
	}
}

487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507
static void iwl_tt_ready_for_ct_kill(unsigned long data)
{
	struct iwl_priv *priv = (struct iwl_priv *)data;
	struct iwl_tt_mgmt *tt = &priv->thermal_throttle;

	if (test_bit(STATUS_EXIT_PENDING, &priv->status))
		return;

	/* temperature timer expired, ready to go into CT_KILL state */
	if (tt->state != IWL_TI_CT_KILL) {
		IWL_DEBUG_POWER(priv, "entering CT_KILL state when temperature timer expired\n");
		tt->state = IWL_TI_CT_KILL;
		set_bit(STATUS_CT_KILL, &priv->status);
		iwl_perform_ct_kill_task(priv, true);
	}
}

static void iwl_prepare_ct_kill_task(struct iwl_priv *priv)
{
	IWL_DEBUG_POWER(priv, "Prepare to enter IWL_TI_CT_KILL\n");
	/* make request to retrieve statistics information */
508
	iwl_send_statistics_request(priv, CMD_SYNC, false);
509 510 511 512 513
	/* Reschedule the ct_kill wait timer */
	mod_timer(&priv->thermal_throttle.ct_kill_waiting_tm,
		 jiffies + msecs_to_jiffies(CT_KILL_WAITING_DURATION));
}

514 515 516 517 518 519 520 521 522 523 524 525 526
#define IWL_MINIMAL_POWER_THRESHOLD		(CT_KILL_THRESHOLD_LEGACY)
#define IWL_REDUCED_PERFORMANCE_THRESHOLD_2	(100)
#define IWL_REDUCED_PERFORMANCE_THRESHOLD_1	(90)

/*
 * Legacy thermal throttling
 * 1) Avoid NIC destruction due to high temperatures
 *	Chip will identify dangerously high temperatures that can
 *	harm the device and will power down
 * 2) Avoid the NIC power down due to high temperature
 *	Throttle early enough to lower the power consumption before
 *	drastic steps are needed
 */
527
static void iwl_legacy_tt_handler(struct iwl_priv *priv, s32 temp, bool force)
528
{
529
	struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
530
	enum iwl_tt_state old_state;
531 532 533 534 535 536 537 538 539 540 541

#ifdef CONFIG_IWLWIFI_DEBUG
	if ((tt->tt_previous_temp) &&
	    (temp > tt->tt_previous_temp) &&
	    ((temp - tt->tt_previous_temp) >
	    IWL_TT_INCREASE_MARGIN)) {
		IWL_DEBUG_POWER(priv,
			"Temperature increase %d degree Celsius\n",
			(temp - tt->tt_previous_temp));
	}
#endif
542
	old_state = tt->state;
543 544
	/* in Celsius */
	if (temp >= IWL_MINIMAL_POWER_THRESHOLD)
545
		tt->state = IWL_TI_CT_KILL;
546
	else if (temp >= IWL_REDUCED_PERFORMANCE_THRESHOLD_2)
547
		tt->state = IWL_TI_2;
548
	else if (temp >= IWL_REDUCED_PERFORMANCE_THRESHOLD_1)
549
		tt->state = IWL_TI_1;
550
	else
551
		tt->state = IWL_TI_0;
552 553 554 555

#ifdef CONFIG_IWLWIFI_DEBUG
	tt->tt_previous_temp = temp;
#endif
556 557
	/* stop ct_kill_waiting_tm timer */
	del_timer_sync(&priv->thermal_throttle.ct_kill_waiting_tm);
558 559
	if (tt->state != old_state) {
		switch (tt->state) {
560
		case IWL_TI_0:
561 562 563 564
			/*
			 * When the system is ready to go back to IWL_TI_0
			 * we only have to call iwl_power_update_mode() to
			 * do so.
565 566 567 568 569 570 571 572 573 574 575 576
			 */
			break;
		case IWL_TI_1:
			tt->tt_power_mode = IWL_POWER_INDEX_3;
			break;
		case IWL_TI_2:
			tt->tt_power_mode = IWL_POWER_INDEX_4;
			break;
		default:
			tt->tt_power_mode = IWL_POWER_INDEX_5;
			break;
		}
577
		mutex_lock(&priv->mutex);
578 579 580 581
		if (old_state == IWL_TI_CT_KILL)
			clear_bit(STATUS_CT_KILL, &priv->status);
		if (tt->state != IWL_TI_CT_KILL &&
		    iwl_power_update_mode(priv, true)) {
582 583 584
			/* TT state not updated
			 * try again during next temperature read
			 */
585 586
			if (old_state == IWL_TI_CT_KILL)
				set_bit(STATUS_CT_KILL, &priv->status);
587
			tt->state = old_state;
588 589 590
			IWL_ERR(priv, "Cannot update power mode, "
					"TT state not updated\n");
		} else {
591 592 593 594 595 596 597 598 599
			if (tt->state == IWL_TI_CT_KILL) {
				if (force) {
					set_bit(STATUS_CT_KILL, &priv->status);
					iwl_perform_ct_kill_task(priv, true);
				} else {
					iwl_prepare_ct_kill_task(priv);
					tt->state = old_state;
				}
			} else if (old_state == IWL_TI_CT_KILL &&
600
				 tt->state != IWL_TI_CT_KILL)
601 602 603 604 605 606
				iwl_perform_ct_kill_task(priv, false);
			IWL_DEBUG_POWER(priv, "Temperature state changed %u\n",
					tt->state);
			IWL_DEBUG_POWER(priv, "Power Index change to %u\n",
					tt->tt_power_mode);
		}
607
		mutex_unlock(&priv->mutex);
608 609 610
	}
}

611 612 613 614 615 616 617 618 619 620 621 622 623 624 625
/*
 * Advance thermal throttling
 * 1) Avoid NIC destruction due to high temperatures
 *	Chip will identify dangerously high temperatures that can
 *	harm the device and will power down
 * 2) Avoid the NIC power down due to high temperature
 *	Throttle early enough to lower the power consumption before
 *	drastic steps are needed
 *	Actions include relaxing the power down sleep thresholds and
 *	decreasing the number of TX streams
 * 3) Avoid throughput performance impact as much as possible
 *
 *=============================================================================
 *                 Condition Nxt State  Condition Nxt State Condition Nxt State
 *-----------------------------------------------------------------------------
626 627 628
 *     IWL_TI_0     T >= 114   CT_KILL  114>T>=105   TI_1      N/A      N/A
 *     IWL_TI_1     T >= 114   CT_KILL  114>T>=110   TI_2     T<=95     TI_0
 *     IWL_TI_2     T >= 114   CT_KILL                        T<=100    TI_1
629 630 631
 *    IWL_CT_KILL      N/A       N/A       N/A        N/A     T<=95     TI_0
 *=============================================================================
 */
632
static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp, bool force)
633
{
634
	struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676
	int i;
	bool changed = false;
	enum iwl_tt_state old_state;
	struct iwl_tt_trans *transaction;

	old_state = tt->state;
	for (i = 0; i < IWL_TI_STATE_MAX - 1; i++) {
		/* based on the current TT state,
		 * find the curresponding transaction table
		 * each table has (IWL_TI_STATE_MAX - 1) entries
		 * tt->transaction + ((old_state * (IWL_TI_STATE_MAX - 1))
		 * will advance to the correct table.
		 * then based on the current temperature
		 * find the next state need to transaction to
		 * go through all the possible (IWL_TI_STATE_MAX - 1) entries
		 * in the current table to see if transaction is needed
		 */
		transaction = tt->transaction +
			((old_state * (IWL_TI_STATE_MAX - 1)) + i);
		if (temp >= transaction->tt_low &&
		    temp <= transaction->tt_high) {
#ifdef CONFIG_IWLWIFI_DEBUG
			if ((tt->tt_previous_temp) &&
			    (temp > tt->tt_previous_temp) &&
			    ((temp - tt->tt_previous_temp) >
			    IWL_TT_INCREASE_MARGIN)) {
				IWL_DEBUG_POWER(priv,
					"Temperature increase %d "
					"degree Celsius\n",
					(temp - tt->tt_previous_temp));
			}
			tt->tt_previous_temp = temp;
#endif
			if (old_state !=
			    transaction->next_state) {
				changed = true;
				tt->state =
					transaction->next_state;
			}
			break;
		}
	}
677 678
	/* stop ct_kill_waiting_tm timer */
	del_timer_sync(&priv->thermal_throttle.ct_kill_waiting_tm);
679 680 681 682 683 684 685 686 687 688
	if (changed) {
		struct iwl_rxon_cmd *rxon = &priv->staging_rxon;

		if (tt->state >= IWL_TI_1) {
			/* force PI = IWL_POWER_INDEX_5 in the case of TI > 0 */
			tt->tt_power_mode = IWL_POWER_INDEX_5;
			if (!iwl_ht_enabled(priv))
				/* disable HT */
				rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK |
					RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK |
689
					RXON_FLG_HT40_PROT_MSK |
690 691 692 693 694 695 696 697 698
					RXON_FLG_HT_PROT_MSK);
			else {
				/* check HT capability and set
				 * according to the system HT capability
				 * in case get disabled before */
				iwl_set_rxon_ht(priv, &priv->current_ht_config);
			}

		} else {
699 700 701
			/*
			 * restore system power setting -- it will be
			 * recalculated automatically.
702
			 */
703

704 705 706 707 708
			/* check HT capability and set
			 * according to the system HT capability
			 * in case get disabled before */
			iwl_set_rxon_ht(priv, &priv->current_ht_config);
		}
709
		mutex_lock(&priv->mutex);
710 711 712 713
		if (old_state == IWL_TI_CT_KILL)
			clear_bit(STATUS_CT_KILL, &priv->status);
		if (tt->state != IWL_TI_CT_KILL &&
		    iwl_power_update_mode(priv, true)) {
714 715 716 717 718
			/* TT state not updated
			 * try again during next temperature read
			 */
			IWL_ERR(priv, "Cannot update power mode, "
					"TT state not updated\n");
719 720
			if (old_state == IWL_TI_CT_KILL)
				set_bit(STATUS_CT_KILL, &priv->status);
721 722 723 724 725 726 727
			tt->state = old_state;
		} else {
			IWL_DEBUG_POWER(priv,
					"Thermal Throttling to new state: %u\n",
					tt->state);
			if (old_state != IWL_TI_CT_KILL &&
			    tt->state == IWL_TI_CT_KILL) {
728 729 730 731 732 733 734 735 736
				if (force) {
					IWL_DEBUG_POWER(priv,
						"Enter IWL_TI_CT_KILL\n");
					set_bit(STATUS_CT_KILL, &priv->status);
					iwl_perform_ct_kill_task(priv, true);
				} else {
					iwl_prepare_ct_kill_task(priv);
					tt->state = old_state;
				}
737 738 739 740 741 742
			} else if (old_state == IWL_TI_CT_KILL &&
				  tt->state != IWL_TI_CT_KILL) {
				IWL_DEBUG_POWER(priv, "Exit IWL_TI_CT_KILL\n");
				iwl_perform_ct_kill_task(priv, false);
			}
		}
743
		mutex_unlock(&priv->mutex);
744 745 746
	}
}

747 748 749 750 751
/* Card State Notification indicated reach critical temperature
 * if PSP not enable, no Thermal Throttling function will be performed
 * just set the GP1 bit to acknowledge the event
 * otherwise, go into IWL_TI_CT_KILL state
 * since Card State Notification will not provide any temperature reading
752
 * for Legacy mode
753
 * so just pass the CT_KILL temperature to iwl_legacy_tt_handler()
754 755
 * for advance mode
 * pass CT_KILL_THRESHOLD+1 to make sure move into IWL_TI_CT_KILL state
756
 */
757
static void iwl_bg_ct_enter(struct work_struct *work)
758
{
759
	struct iwl_priv *priv = container_of(work, struct iwl_priv, ct_enter);
760
	struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
761 762 763 764

	if (test_bit(STATUS_EXIT_PENDING, &priv->status))
		return;

765 766 767
	if (!iwl_is_ready(priv))
		return;

768 769 770
	if (tt->state != IWL_TI_CT_KILL) {
		IWL_ERR(priv, "Device reached critical temperature "
			      "- ucode going to sleep!\n");
771
		if (!priv->thermal_throttle.advanced_tt)
772
			iwl_legacy_tt_handler(priv,
773 774
					      IWL_MINIMAL_POWER_THRESHOLD,
					      true);
775 776
		else
			iwl_advance_tt_handler(priv,
777
					       CT_KILL_THRESHOLD + 1, true);
778 779 780 781 782 783 784 785
	}
}

/* Card State Notification indicated out of critical temperature
 * since Card State Notification will not provide any temperature reading
 * so pass the IWL_REDUCED_PERFORMANCE_THRESHOLD_2 temperature
 * to iwl_legacy_tt_handler() to get out of IWL_CT_KILL state
 */
786
static void iwl_bg_ct_exit(struct work_struct *work)
787
{
788
	struct iwl_priv *priv = container_of(work, struct iwl_priv, ct_exit);
789
	struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
790 791 792 793

	if (test_bit(STATUS_EXIT_PENDING, &priv->status))
		return;

794 795 796
	if (!iwl_is_ready(priv))
		return;

797
	/* stop ct_kill_exit_tm timer */
798
	del_timer_sync(&priv->thermal_throttle.ct_kill_exit_tm);
799 800 801 802 803

	if (tt->state == IWL_TI_CT_KILL) {
		IWL_ERR(priv,
			"Device temperature below critical"
			"- ucode awake!\n");
804 805 806 807 808
		/*
		 * exit from CT_KILL state
		 * reset the current temperature reading
		 */
		priv->temperature = 0;
809
		if (!priv->thermal_throttle.advanced_tt)
810
			iwl_legacy_tt_handler(priv,
811 812
					      IWL_REDUCED_PERFORMANCE_THRESHOLD_2,
					      true);
813
		else
814 815
			iwl_advance_tt_handler(priv, CT_KILL_EXIT_THRESHOLD,
					       true);
816 817
	}
}
818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836

void iwl_tt_enter_ct_kill(struct iwl_priv *priv)
{
	if (test_bit(STATUS_EXIT_PENDING, &priv->status))
		return;

	IWL_DEBUG_POWER(priv, "Queueing critical temperature enter.\n");
	queue_work(priv->workqueue, &priv->ct_enter);
}
EXPORT_SYMBOL(iwl_tt_enter_ct_kill);

void iwl_tt_exit_ct_kill(struct iwl_priv *priv)
{
	if (test_bit(STATUS_EXIT_PENDING, &priv->status))
		return;

	IWL_DEBUG_POWER(priv, "Queueing critical temperature exit.\n");
	queue_work(priv->workqueue, &priv->ct_exit);
}
837 838
EXPORT_SYMBOL(iwl_tt_exit_ct_kill);

839
static void iwl_bg_tt_work(struct work_struct *work)
840
{
841
	struct iwl_priv *priv = container_of(work, struct iwl_priv, tt_work);
842
	s32 temp = priv->temperature; /* degrees CELSIUS except specified */
843 844 845 846

	if (test_bit(STATUS_EXIT_PENDING, &priv->status))
		return;

847
	if (priv->cfg->temperature_kelvin)
848 849
		temp = KELVIN_TO_CELSIUS(priv->temperature);

850
	if (!priv->thermal_throttle.advanced_tt)
851
		iwl_legacy_tt_handler(priv, temp, false);
852
	else
853
		iwl_advance_tt_handler(priv, temp, false);
854
}
855 856 857 858 859 860 861 862 863

void iwl_tt_handler(struct iwl_priv *priv)
{
	if (test_bit(STATUS_EXIT_PENDING, &priv->status))
		return;

	IWL_DEBUG_POWER(priv, "Queueing thermal throttling work.\n");
	queue_work(priv->workqueue, &priv->tt_work);
}
864 865 866
EXPORT_SYMBOL(iwl_tt_handler);

/* Thermal throttling initialization
867 868 869
 * For advance thermal throttling:
 *     Initialize Thermal Index and temperature threshold table
 *     Initialize thermal throttling restriction table
870 871 872
 */
void iwl_tt_initialize(struct iwl_priv *priv)
{
873
	struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
874 875
	int size = sizeof(struct iwl_tt_trans) * (IWL_TI_STATE_MAX - 1);
	struct iwl_tt_trans *transaction;
876

877
	IWL_DEBUG_POWER(priv, "Initialize Thermal Throttling\n");
878 879 880 881

	memset(tt, 0, sizeof(struct iwl_tt_mgmt));

	tt->state = IWL_TI_0;
882 883
	init_timer(&priv->thermal_throttle.ct_kill_exit_tm);
	priv->thermal_throttle.ct_kill_exit_tm.data = (unsigned long)priv;
884 885 886 887 888 889
	priv->thermal_throttle.ct_kill_exit_tm.function =
		iwl_tt_check_exit_ct_kill;
	init_timer(&priv->thermal_throttle.ct_kill_waiting_tm);
	priv->thermal_throttle.ct_kill_waiting_tm.data = (unsigned long)priv;
	priv->thermal_throttle.ct_kill_waiting_tm.function =
		iwl_tt_ready_for_ct_kill;
890 891 892 893 894
	/* setup deferred ct kill work */
	INIT_WORK(&priv->tt_work, iwl_bg_tt_work);
	INIT_WORK(&priv->ct_enter, iwl_bg_ct_enter);
	INIT_WORK(&priv->ct_exit, iwl_bg_ct_exit);

895
	if (priv->cfg->adv_thermal_throttle) {
896 897 898 899 900 901 902 903
		IWL_DEBUG_POWER(priv, "Advanced Thermal Throttling\n");
		tt->restriction = kzalloc(sizeof(struct iwl_tt_restriction) *
					 IWL_TI_STATE_MAX, GFP_KERNEL);
		tt->transaction = kzalloc(sizeof(struct iwl_tt_trans) *
			IWL_TI_STATE_MAX * (IWL_TI_STATE_MAX - 1),
			GFP_KERNEL);
		if (!tt->restriction || !tt->transaction) {
			IWL_ERR(priv, "Fallback to Legacy Throttling\n");
904
			priv->thermal_throttle.advanced_tt = false;
905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925
			kfree(tt->restriction);
			tt->restriction = NULL;
			kfree(tt->transaction);
			tt->transaction = NULL;
		} else {
			transaction = tt->transaction +
				(IWL_TI_0 * (IWL_TI_STATE_MAX - 1));
			memcpy(transaction, &tt_range_0[0], size);
			transaction = tt->transaction +
				(IWL_TI_1 * (IWL_TI_STATE_MAX - 1));
			memcpy(transaction, &tt_range_1[0], size);
			transaction = tt->transaction +
				(IWL_TI_2 * (IWL_TI_STATE_MAX - 1));
			memcpy(transaction, &tt_range_2[0], size);
			transaction = tt->transaction +
				(IWL_TI_CT_KILL * (IWL_TI_STATE_MAX - 1));
			memcpy(transaction, &tt_range_3[0], size);
			size = sizeof(struct iwl_tt_restriction) *
				IWL_TI_STATE_MAX;
			memcpy(tt->restriction,
				&restriction_range[0], size);
926
			priv->thermal_throttle.advanced_tt = true;
927
		}
928
	} else {
929
		IWL_DEBUG_POWER(priv, "Legacy Thermal Throttling\n");
930
		priv->thermal_throttle.advanced_tt = false;
931
	}
932 933 934 935 936 937
}
EXPORT_SYMBOL(iwl_tt_initialize);

/* cleanup thermal throttling management related memory and timer */
void iwl_tt_exit(struct iwl_priv *priv)
{
938
	struct iwl_tt_mgmt *tt = &priv->thermal_throttle;
939

940
	/* stop ct_kill_exit_tm timer if activated */
941
	del_timer_sync(&priv->thermal_throttle.ct_kill_exit_tm);
942 943
	/* stop ct_kill_waiting_tm timer if activated */
	del_timer_sync(&priv->thermal_throttle.ct_kill_waiting_tm);
944 945 946
	cancel_work_sync(&priv->tt_work);
	cancel_work_sync(&priv->ct_enter);
	cancel_work_sync(&priv->ct_exit);
947

948
	if (priv->thermal_throttle.advanced_tt) {
949 950 951 952 953 954
		/* free advance thermal throttling memory */
		kfree(tt->restriction);
		tt->restriction = NULL;
		kfree(tt->transaction);
		tt->transaction = NULL;
	}
955 956 957
}
EXPORT_SYMBOL(iwl_tt_exit);

T
Tomas Winkler 已提交
958
/* initialize to default */
M
Mohamed Abbas 已提交
959 960
void iwl_power_initialize(struct iwl_priv *priv)
{
961 962 963 964 965 966 967 968
	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));
M
Mohamed Abbas 已提交
969 970
}
EXPORT_SYMBOL(iwl_power_initialize);