Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Reinette Chatre | 01f8162 | 2009-01-08 10:20:02 -0800 | [diff] [blame] | 3 | * Copyright(c) 2007 - 2009 Intel Corporation. All rights reserved. |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 4 | * |
| 5 | * Portions of this file are derived from the ipw3945 project, as well |
| 6 | * as portions of the ieee80211 subsystem header files. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify it |
| 9 | * under the terms of version 2 of the GNU General Public License as |
| 10 | * published by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 15 | * more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along with |
| 18 | * this program; if not, write to the Free Software Foundation, Inc., |
| 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA |
| 20 | * |
| 21 | * The full GNU General Public License is included in this distribution in the |
| 22 | * file called LICENSE. |
| 23 | * |
| 24 | * Contact Information: |
Winkler, Tomas | 759ef89 | 2008-12-09 11:28:58 -0800 | [diff] [blame] | 25 | * Intel Linux Wireless <ilw@linux.intel.com> |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 26 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 27 | *****************************************************************************/ |
| 28 | |
| 29 | |
| 30 | #include <linux/kernel.h> |
| 31 | #include <linux/module.h> |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 32 | #include <linux/init.h> |
| 33 | |
| 34 | #include <net/mac80211.h> |
| 35 | |
| 36 | #include "iwl-eeprom.h" |
Tomas Winkler | 3e0d4cb | 2008-04-24 11:55:38 -0700 | [diff] [blame] | 37 | #include "iwl-dev.h" |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 38 | #include "iwl-core.h" |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 39 | #include "iwl-io.h" |
Tomas Winkler | 5a36ba0 | 2008-04-24 11:55:37 -0700 | [diff] [blame] | 40 | #include "iwl-commands.h" |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 41 | #include "iwl-debug.h" |
| 42 | #include "iwl-power.h" |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 43 | |
| 44 | /* |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 45 | * Setting power level allow the card to go to sleep when not busy. |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 46 | * |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 47 | * The power level is set to INDEX_1 (the least deep state) by |
| 48 | * default, and will, in the future, be the deepest state unless |
| 49 | * otherwise required by pm_qos network latency requirements. |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 50 | * |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 51 | * Using INDEX_1 without pm_qos is ok because mac80211 will disable |
| 52 | * PS when even checking every beacon for the TIM bit would exceed |
| 53 | * the required latency. |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 54 | */ |
| 55 | |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 56 | #define IWL_POWER_RANGE_0_MAX (2) |
| 57 | #define IWL_POWER_RANGE_1_MAX (10) |
| 58 | |
| 59 | |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 60 | #define NOSLP cpu_to_le16(0), 0, 0 |
| 61 | #define SLP IWL_POWER_DRIVER_ALLOW_SLEEP_MSK, 0, 0 |
| 62 | #define TU_TO_USEC 1024 |
| 63 | #define SLP_TOUT(T) cpu_to_le32((T) * TU_TO_USEC) |
| 64 | #define SLP_VEC(X0, X1, X2, X3, X4) {cpu_to_le32(X0), \ |
| 65 | cpu_to_le32(X1), \ |
| 66 | cpu_to_le32(X2), \ |
| 67 | cpu_to_le32(X3), \ |
| 68 | cpu_to_le32(X4)} |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 69 | /* default power management (not Tx power) table values */ |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 70 | /* for DTIM period 0 through IWL_POWER_RANGE_0_MAX */ |
| 71 | static const struct iwl_power_vec_entry range_0[IWL_POWER_NUM] = { |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 72 | {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, |
| 73 | {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 2, 2, 0xFF)}, 0}, |
| 74 | {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(1, 2, 2, 2, 0xFF)}, 0}, |
| 75 | {{SLP, SLP_TOUT(50), SLP_TOUT(100), SLP_VEC(2, 2, 2, 2, 0xFF)}, 0}, |
| 76 | {{SLP, SLP_TOUT(50), SLP_TOUT(25), SLP_VEC(2, 2, 4, 4, 0xFF)}, 1}, |
| 77 | {{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(2, 2, 4, 6, 0xFF)}, 2} |
| 78 | }; |
| 79 | |
| 80 | |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 81 | /* for DTIM period IWL_POWER_RANGE_0_MAX + 1 through IWL_POWER_RANGE_1_MAX */ |
| 82 | static const struct iwl_power_vec_entry range_1[IWL_POWER_NUM] = { |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 83 | {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, |
| 84 | {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 4)}, 0}, |
| 85 | {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(1, 2, 3, 4, 7)}, 0}, |
| 86 | {{SLP, SLP_TOUT(50), SLP_TOUT(100), SLP_VEC(2, 4, 6, 7, 9)}, 0}, |
| 87 | {{SLP, SLP_TOUT(50), SLP_TOUT(25), SLP_VEC(2, 4, 6, 9, 10)}, 1}, |
| 88 | {{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(2, 4, 7, 10, 10)}, 2} |
| 89 | }; |
| 90 | |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 91 | /* for DTIM period > IWL_POWER_RANGE_1_MAX */ |
| 92 | static const struct iwl_power_vec_entry range_2[IWL_POWER_NUM] = { |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 93 | {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, |
| 94 | {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 0xFF)}, 0}, |
| 95 | {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(2, 4, 6, 7, 0xFF)}, 0}, |
| 96 | {{SLP, SLP_TOUT(50), SLP_TOUT(100), SLP_VEC(2, 7, 9, 9, 0xFF)}, 0}, |
| 97 | {{SLP, SLP_TOUT(50), SLP_TOUT(25), SLP_VEC(2, 7, 9, 9, 0xFF)}, 0}, |
| 98 | {{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(4, 7, 10, 10, 0xFF)}, 0} |
| 99 | }; |
| 100 | |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 101 | /* default Thermal Throttling transaction table |
| 102 | * Current state | Throttling Down | Throttling Up |
| 103 | *============================================================================= |
| 104 | * Condition Nxt State Condition Nxt State Condition Nxt State |
| 105 | *----------------------------------------------------------------------------- |
| 106 | * IWL_TI_0 T >= 115 CT_KILL 115>T>=105 TI_1 N/A N/A |
| 107 | * IWL_TI_1 T >= 115 CT_KILL 115>T>=110 TI_2 T<=95 TI_0 |
| 108 | * IWL_TI_2 T >= 115 CT_KILL T<=100 TI_1 |
| 109 | * IWL_CT_KILL N/A N/A N/A N/A T<=95 TI_0 |
| 110 | *============================================================================= |
| 111 | */ |
| 112 | static const struct iwl_tt_trans tt_range_0[IWL_TI_STATE_MAX - 1] = { |
| 113 | {IWL_TI_0, IWL_ABSOLUTE_ZERO, 104}, |
| 114 | {IWL_TI_1, 105, CT_KILL_THRESHOLD}, |
| 115 | {IWL_TI_CT_KILL, CT_KILL_THRESHOLD + 1, IWL_ABSOLUTE_MAX} |
| 116 | }; |
| 117 | static const struct iwl_tt_trans tt_range_1[IWL_TI_STATE_MAX - 1] = { |
| 118 | {IWL_TI_0, IWL_ABSOLUTE_ZERO, 95}, |
| 119 | {IWL_TI_2, 110, CT_KILL_THRESHOLD}, |
| 120 | {IWL_TI_CT_KILL, CT_KILL_THRESHOLD + 1, IWL_ABSOLUTE_MAX} |
| 121 | }; |
| 122 | static const struct iwl_tt_trans tt_range_2[IWL_TI_STATE_MAX - 1] = { |
| 123 | {IWL_TI_1, IWL_ABSOLUTE_ZERO, 100}, |
| 124 | {IWL_TI_CT_KILL, CT_KILL_THRESHOLD + 1, IWL_ABSOLUTE_MAX}, |
| 125 | {IWL_TI_CT_KILL, CT_KILL_THRESHOLD + 1, IWL_ABSOLUTE_MAX} |
| 126 | }; |
| 127 | static const struct iwl_tt_trans tt_range_3[IWL_TI_STATE_MAX - 1] = { |
| 128 | {IWL_TI_0, IWL_ABSOLUTE_ZERO, CT_KILL_EXIT_THRESHOLD}, |
| 129 | {IWL_TI_CT_KILL, CT_KILL_EXIT_THRESHOLD + 1, IWL_ABSOLUTE_MAX}, |
| 130 | {IWL_TI_CT_KILL, CT_KILL_EXIT_THRESHOLD + 1, IWL_ABSOLUTE_MAX} |
| 131 | }; |
| 132 | |
| 133 | /* Advance Thermal Throttling default restriction table */ |
| 134 | static const struct iwl_tt_restriction restriction_range[IWL_TI_STATE_MAX] = { |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 135 | {IWL_ANT_OK_MULTI, IWL_ANT_OK_MULTI, true }, |
| 136 | {IWL_ANT_OK_SINGLE, IWL_ANT_OK_MULTI, true }, |
| 137 | {IWL_ANT_OK_SINGLE, IWL_ANT_OK_SINGLE, false }, |
| 138 | {IWL_ANT_OK_NONE, IWL_ANT_OK_NONE, false } |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 139 | }; |
Winkler, Tomas | d25aabb | 2009-01-27 14:27:58 -0800 | [diff] [blame] | 140 | |
Mohamed Abbas | ca57961 | 2008-07-18 13:52:57 +0800 | [diff] [blame] | 141 | /* set card power command */ |
| 142 | static int iwl_set_power(struct iwl_priv *priv, void *cmd) |
| 143 | { |
Johannes Berg | f0f74a0 | 2009-05-08 13:44:37 -0700 | [diff] [blame] | 144 | return iwl_send_cmd_pdu(priv, POWER_TABLE_CMD, |
| 145 | sizeof(struct iwl_powertable_cmd), cmd); |
Mohamed Abbas | ca57961 | 2008-07-18 13:52:57 +0800 | [diff] [blame] | 146 | } |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 147 | |
| 148 | /* initialize to default */ |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 149 | static void iwl_power_init_handle(struct iwl_priv *priv) |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 150 | { |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 151 | struct iwl_power_mgr *pow_data; |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 152 | int size = sizeof(struct iwl_power_vec_entry) * IWL_POWER_NUM; |
Tomas Winkler | e7b6358 | 2008-09-03 11:26:49 +0800 | [diff] [blame] | 153 | struct iwl_powertable_cmd *cmd; |
| 154 | int i; |
Tomas Winkler | 3fdb68d | 2009-02-10 15:19:02 -0800 | [diff] [blame] | 155 | u16 lctl; |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 156 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 157 | IWL_DEBUG_POWER(priv, "Initialize power \n"); |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 158 | |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 159 | pow_data = &priv->power_data; |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 160 | |
| 161 | memset(pow_data, 0, sizeof(*pow_data)); |
| 162 | |
| 163 | memcpy(&pow_data->pwr_range_0[0], &range_0[0], size); |
| 164 | memcpy(&pow_data->pwr_range_1[0], &range_1[0], size); |
| 165 | memcpy(&pow_data->pwr_range_2[0], &range_2[0], size); |
| 166 | |
Tomas Winkler | 3fdb68d | 2009-02-10 15:19:02 -0800 | [diff] [blame] | 167 | lctl = iwl_pcie_link_ctl(priv); |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 168 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 169 | IWL_DEBUG_POWER(priv, "adjust power command flags\n"); |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 170 | |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 171 | for (i = 0; i < IWL_POWER_NUM; i++) { |
Tomas Winkler | e7b6358 | 2008-09-03 11:26:49 +0800 | [diff] [blame] | 172 | cmd = &pow_data->pwr_range_0[i].cmd; |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 173 | |
Tomas Winkler | 3fdb68d | 2009-02-10 15:19:02 -0800 | [diff] [blame] | 174 | if (lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN) |
Tomas Winkler | e7b6358 | 2008-09-03 11:26:49 +0800 | [diff] [blame] | 175 | cmd->flags &= ~IWL_POWER_PCI_PM_MSK; |
| 176 | else |
| 177 | cmd->flags |= IWL_POWER_PCI_PM_MSK; |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 178 | } |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 179 | } |
| 180 | |
Tomas Winkler | a96a27f | 2008-10-23 23:48:56 -0700 | [diff] [blame] | 181 | /* adjust power command according to DTIM period and power level*/ |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 182 | static int iwl_update_power_cmd(struct iwl_priv *priv, |
| 183 | struct iwl_powertable_cmd *cmd, u16 mode) |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 184 | { |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 185 | struct iwl_power_vec_entry *range; |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 186 | struct iwl_power_mgr *pow_data; |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 187 | int i; |
| 188 | u32 max_sleep = 0; |
| 189 | u8 period; |
| 190 | bool skip; |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 191 | |
| 192 | if (mode > IWL_POWER_INDEX_5) { |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 193 | IWL_DEBUG_POWER(priv, "Error invalid power mode \n"); |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 194 | return -EINVAL; |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 195 | } |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 196 | |
| 197 | pow_data = &priv->power_data; |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 198 | |
| 199 | if (pow_data->dtim_period <= IWL_POWER_RANGE_0_MAX) |
| 200 | range = &pow_data->pwr_range_0[0]; |
| 201 | else if (pow_data->dtim_period <= IWL_POWER_RANGE_1_MAX) |
| 202 | range = &pow_data->pwr_range_1[0]; |
| 203 | else |
| 204 | range = &pow_data->pwr_range_2[0]; |
| 205 | |
| 206 | period = pow_data->dtim_period; |
Mohamed Abbas | ca57961 | 2008-07-18 13:52:57 +0800 | [diff] [blame] | 207 | memcpy(cmd, &range[mode].cmd, sizeof(struct iwl_powertable_cmd)); |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 208 | |
| 209 | if (period == 0) { |
| 210 | period = 1; |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 211 | skip = false; |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 212 | } else { |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 213 | skip = !!range[mode].no_dtim; |
| 214 | } |
| 215 | |
| 216 | if (skip) { |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 217 | __le32 slp_itrvl = cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1]; |
| 218 | max_sleep = le32_to_cpu(slp_itrvl); |
| 219 | if (max_sleep == 0xFF) |
| 220 | max_sleep = period * (skip + 1); |
| 221 | else if (max_sleep > period) |
| 222 | max_sleep = (le32_to_cpu(slp_itrvl) / period) * period; |
| 223 | cmd->flags |= IWL_POWER_SLEEP_OVER_DTIM_MSK; |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 224 | } else { |
| 225 | max_sleep = period; |
| 226 | cmd->flags &= ~IWL_POWER_SLEEP_OVER_DTIM_MSK; |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 227 | } |
| 228 | |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 229 | for (i = 0; i < IWL_POWER_VEC_SIZE; i++) |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 230 | if (le32_to_cpu(cmd->sleep_interval[i]) > max_sleep) |
| 231 | cmd->sleep_interval[i] = cpu_to_le32(max_sleep); |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 232 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 233 | IWL_DEBUG_POWER(priv, "Flags value = 0x%08X\n", cmd->flags); |
| 234 | IWL_DEBUG_POWER(priv, "Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout)); |
| 235 | IWL_DEBUG_POWER(priv, "Rx timeout = %u\n", le32_to_cpu(cmd->rx_data_timeout)); |
| 236 | IWL_DEBUG_POWER(priv, "Sleep interval vector = { %d , %d , %d , %d , %d }\n", |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 237 | le32_to_cpu(cmd->sleep_interval[0]), |
| 238 | le32_to_cpu(cmd->sleep_interval[1]), |
| 239 | le32_to_cpu(cmd->sleep_interval[2]), |
| 240 | le32_to_cpu(cmd->sleep_interval[3]), |
| 241 | le32_to_cpu(cmd->sleep_interval[4])); |
| 242 | |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 243 | return 0; |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | |
| 247 | /* |
Emmanuel Grumbach | a33c2f4 | 2008-09-03 11:26:56 +0800 | [diff] [blame] | 248 | * compute the final power mode index |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 249 | */ |
Grumbach, Emmanuel | 0481644 | 2008-09-03 11:26:53 +0800 | [diff] [blame] | 250 | int iwl_power_update_mode(struct iwl_priv *priv, bool force) |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 251 | { |
| 252 | struct iwl_power_mgr *setting = &(priv->power_data); |
| 253 | int ret = 0; |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 254 | struct iwl_tt_mgmt *tt = &priv->thermal_throttle; |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 255 | u16 uninitialized_var(final_mode); |
Winkler, Tomas | a71c8f6 | 2008-11-07 09:58:37 -0800 | [diff] [blame] | 256 | bool update_chains; |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 257 | |
Grumbach, Emmanuel | 0481644 | 2008-09-03 11:26:53 +0800 | [diff] [blame] | 258 | /* Don't update the RX chain when chain noise calibration is running */ |
Winkler, Tomas | a71c8f6 | 2008-11-07 09:58:37 -0800 | [diff] [blame] | 259 | update_chains = priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE || |
| 260 | priv->chain_noise_data.state == IWL_CHAIN_NOISE_ALIVE; |
Grumbach, Emmanuel | 0481644 | 2008-09-03 11:26:53 +0800 | [diff] [blame] | 261 | |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 262 | final_mode = priv->power_data.user_power_setting; |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 263 | |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 264 | if (setting->power_disabled) |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 265 | final_mode = IWL_POWER_MODE_CAM; |
| 266 | |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 267 | if (tt->state >= IWL_TI_1) { |
| 268 | /* TT power setting overwrite user & system power setting */ |
| 269 | final_mode = tt->tt_power_mode; |
| 270 | } |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 271 | if (iwl_is_ready_rf(priv) && |
Grumbach, Emmanuel | 0481644 | 2008-09-03 11:26:53 +0800 | [diff] [blame] | 272 | ((setting->power_mode != final_mode) || force)) { |
Mohamed Abbas | ca57961 | 2008-07-18 13:52:57 +0800 | [diff] [blame] | 273 | struct iwl_powertable_cmd cmd; |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 274 | |
| 275 | if (final_mode != IWL_POWER_MODE_CAM) |
| 276 | set_bit(STATUS_POWER_PMI, &priv->status); |
| 277 | |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 278 | iwl_update_power_cmd(priv, &cmd, final_mode); |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 279 | cmd.keep_alive_beacons = 0; |
| 280 | |
| 281 | if (final_mode == IWL_POWER_INDEX_5) |
| 282 | cmd.flags |= IWL_POWER_FAST_PD; |
| 283 | |
Mohamed Abbas | ca57961 | 2008-07-18 13:52:57 +0800 | [diff] [blame] | 284 | ret = iwl_set_power(priv, &cmd); |
Wey-Yi Guy | 3a780d2 | 2009-08-07 15:41:47 -0700 | [diff] [blame] | 285 | if (!ret) { |
| 286 | if (final_mode == IWL_POWER_MODE_CAM) |
| 287 | clear_bit(STATUS_POWER_PMI, &priv->status); |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 288 | |
Wey-Yi Guy | 3a780d2 | 2009-08-07 15:41:47 -0700 | [diff] [blame] | 289 | if (priv->cfg->ops->lib->update_chain_flags && |
| 290 | update_chains) |
| 291 | priv->cfg->ops->lib->update_chain_flags(priv); |
| 292 | else |
| 293 | IWL_DEBUG_POWER(priv, |
| 294 | "Cannot update the power, chain noise " |
Winkler, Tomas | a71c8f6 | 2008-11-07 09:58:37 -0800 | [diff] [blame] | 295 | "calibration running: %d\n", |
| 296 | priv->chain_noise_data.state); |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 297 | setting->power_mode = final_mode; |
Wey-Yi Guy | 3a780d2 | 2009-08-07 15:41:47 -0700 | [diff] [blame] | 298 | } else |
| 299 | IWL_ERR(priv, "set power fail, ret = %d", ret); |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | return ret; |
| 303 | } |
| 304 | EXPORT_SYMBOL(iwl_power_update_mode); |
| 305 | |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 306 | /* set user_power_setting */ |
| 307 | int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode) |
| 308 | { |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 309 | if (mode >= IWL_POWER_NUM) |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 310 | return -EINVAL; |
| 311 | |
| 312 | priv->power_data.user_power_setting = mode; |
| 313 | |
Grumbach, Emmanuel | 0481644 | 2008-09-03 11:26:53 +0800 | [diff] [blame] | 314 | return iwl_power_update_mode(priv, 0); |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 315 | } |
| 316 | EXPORT_SYMBOL(iwl_power_set_user_mode); |
| 317 | |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 318 | bool iwl_ht_enabled(struct iwl_priv *priv) |
| 319 | { |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 320 | struct iwl_tt_mgmt *tt = &priv->thermal_throttle; |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 321 | struct iwl_tt_restriction *restriction; |
| 322 | |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 323 | if (!priv->thermal_throttle.advanced_tt) |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 324 | return true; |
| 325 | restriction = tt->restriction + tt->state; |
| 326 | return restriction->is_ht; |
| 327 | } |
| 328 | EXPORT_SYMBOL(iwl_ht_enabled); |
| 329 | |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 330 | enum iwl_antenna_ok iwl_tx_ant_restriction(struct iwl_priv *priv) |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 331 | { |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 332 | struct iwl_tt_mgmt *tt = &priv->thermal_throttle; |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 333 | struct iwl_tt_restriction *restriction; |
| 334 | |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 335 | if (!priv->thermal_throttle.advanced_tt) |
| 336 | return IWL_ANT_OK_MULTI; |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 337 | restriction = tt->restriction + tt->state; |
| 338 | return restriction->tx_stream; |
| 339 | } |
| 340 | EXPORT_SYMBOL(iwl_tx_ant_restriction); |
| 341 | |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 342 | enum iwl_antenna_ok iwl_rx_ant_restriction(struct iwl_priv *priv) |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 343 | { |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 344 | struct iwl_tt_mgmt *tt = &priv->thermal_throttle; |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 345 | struct iwl_tt_restriction *restriction; |
| 346 | |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 347 | if (!priv->thermal_throttle.advanced_tt) |
| 348 | return IWL_ANT_OK_MULTI; |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 349 | restriction = tt->restriction + tt->state; |
| 350 | return restriction->rx_stream; |
| 351 | } |
| 352 | EXPORT_SYMBOL(iwl_rx_ant_restriction); |
| 353 | |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 354 | #define CT_KILL_EXIT_DURATION (5) /* 5 seconds duration */ |
| 355 | |
| 356 | /* |
| 357 | * toggle the bit to wake up uCode and check the temperature |
| 358 | * if the temperature is below CT, uCode will stay awake and send card |
| 359 | * state notification with CT_KILL bit clear to inform Thermal Throttling |
| 360 | * Management to change state. Otherwise, uCode will go back to sleep |
| 361 | * without doing anything, driver should continue the 5 seconds timer |
| 362 | * to wake up uCode for temperature check until temperature drop below CT |
| 363 | */ |
| 364 | static void iwl_tt_check_exit_ct_kill(unsigned long data) |
| 365 | { |
| 366 | struct iwl_priv *priv = (struct iwl_priv *)data; |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 367 | struct iwl_tt_mgmt *tt = &priv->thermal_throttle; |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 368 | unsigned long flags; |
| 369 | |
| 370 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
| 371 | return; |
| 372 | |
| 373 | if (tt->state == IWL_TI_CT_KILL) { |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 374 | if (priv->thermal_throttle.ct_kill_toggle) { |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 375 | iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, |
| 376 | CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 377 | priv->thermal_throttle.ct_kill_toggle = false; |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 378 | } else { |
| 379 | iwl_write32(priv, CSR_UCODE_DRV_GP1_SET, |
| 380 | CSR_UCODE_DRV_GP1_REG_BIT_CT_KILL_EXIT); |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 381 | priv->thermal_throttle.ct_kill_toggle = true; |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 382 | } |
| 383 | iwl_read32(priv, CSR_UCODE_DRV_GP1); |
| 384 | spin_lock_irqsave(&priv->reg_lock, flags); |
| 385 | if (!iwl_grab_nic_access(priv)) |
| 386 | iwl_release_nic_access(priv); |
| 387 | spin_unlock_irqrestore(&priv->reg_lock, flags); |
| 388 | |
| 389 | /* Reschedule the ct_kill timer to occur in |
| 390 | * CT_KILL_EXIT_DURATION seconds to ensure we get a |
| 391 | * thermal update */ |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 392 | mod_timer(&priv->thermal_throttle.ct_kill_exit_tm, jiffies + |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 393 | CT_KILL_EXIT_DURATION * HZ); |
| 394 | } |
| 395 | } |
| 396 | |
| 397 | static void iwl_perform_ct_kill_task(struct iwl_priv *priv, |
| 398 | bool stop) |
| 399 | { |
| 400 | if (stop) { |
| 401 | IWL_DEBUG_POWER(priv, "Stop all queues\n"); |
| 402 | if (priv->mac80211_registered) |
| 403 | ieee80211_stop_queues(priv->hw); |
| 404 | IWL_DEBUG_POWER(priv, |
| 405 | "Schedule 5 seconds CT_KILL Timer\n"); |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 406 | mod_timer(&priv->thermal_throttle.ct_kill_exit_tm, jiffies + |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 407 | CT_KILL_EXIT_DURATION * HZ); |
| 408 | } else { |
| 409 | IWL_DEBUG_POWER(priv, "Wake all queues\n"); |
| 410 | if (priv->mac80211_registered) |
| 411 | ieee80211_wake_queues(priv->hw); |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | #define IWL_MINIMAL_POWER_THRESHOLD (CT_KILL_THRESHOLD_LEGACY) |
| 416 | #define IWL_REDUCED_PERFORMANCE_THRESHOLD_2 (100) |
| 417 | #define IWL_REDUCED_PERFORMANCE_THRESHOLD_1 (90) |
| 418 | |
| 419 | /* |
| 420 | * Legacy thermal throttling |
| 421 | * 1) Avoid NIC destruction due to high temperatures |
| 422 | * Chip will identify dangerously high temperatures that can |
| 423 | * harm the device and will power down |
| 424 | * 2) Avoid the NIC power down due to high temperature |
| 425 | * Throttle early enough to lower the power consumption before |
| 426 | * drastic steps are needed |
| 427 | */ |
| 428 | static void iwl_legacy_tt_handler(struct iwl_priv *priv, s32 temp) |
| 429 | { |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 430 | struct iwl_tt_mgmt *tt = &priv->thermal_throttle; |
Wey-Yi Guy | ee9f298 | 2009-08-07 15:41:46 -0700 | [diff] [blame] | 431 | enum iwl_tt_state old_state; |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 432 | struct iwl_power_mgr *setting = &priv->power_data; |
| 433 | |
| 434 | #ifdef CONFIG_IWLWIFI_DEBUG |
| 435 | if ((tt->tt_previous_temp) && |
| 436 | (temp > tt->tt_previous_temp) && |
| 437 | ((temp - tt->tt_previous_temp) > |
| 438 | IWL_TT_INCREASE_MARGIN)) { |
| 439 | IWL_DEBUG_POWER(priv, |
| 440 | "Temperature increase %d degree Celsius\n", |
| 441 | (temp - tt->tt_previous_temp)); |
| 442 | } |
| 443 | #endif |
Wey-Yi Guy | ee9f298 | 2009-08-07 15:41:46 -0700 | [diff] [blame] | 444 | old_state = tt->state; |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 445 | /* in Celsius */ |
| 446 | if (temp >= IWL_MINIMAL_POWER_THRESHOLD) |
Wey-Yi Guy | ee9f298 | 2009-08-07 15:41:46 -0700 | [diff] [blame] | 447 | tt->state = IWL_TI_CT_KILL; |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 448 | else if (temp >= IWL_REDUCED_PERFORMANCE_THRESHOLD_2) |
Wey-Yi Guy | ee9f298 | 2009-08-07 15:41:46 -0700 | [diff] [blame] | 449 | tt->state = IWL_TI_2; |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 450 | else if (temp >= IWL_REDUCED_PERFORMANCE_THRESHOLD_1) |
Wey-Yi Guy | ee9f298 | 2009-08-07 15:41:46 -0700 | [diff] [blame] | 451 | tt->state = IWL_TI_1; |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 452 | else |
Wey-Yi Guy | ee9f298 | 2009-08-07 15:41:46 -0700 | [diff] [blame] | 453 | tt->state = IWL_TI_0; |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 454 | |
| 455 | #ifdef CONFIG_IWLWIFI_DEBUG |
| 456 | tt->tt_previous_temp = temp; |
| 457 | #endif |
Wey-Yi Guy | ee9f298 | 2009-08-07 15:41:46 -0700 | [diff] [blame] | 458 | if (tt->state != old_state) { |
| 459 | if (old_state == IWL_TI_0) { |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 460 | tt->sys_power_mode = setting->power_mode; |
| 461 | IWL_DEBUG_POWER(priv, "current power mode: %u\n", |
| 462 | setting->power_mode); |
| 463 | } |
Wey-Yi Guy | ee9f298 | 2009-08-07 15:41:46 -0700 | [diff] [blame] | 464 | switch (tt->state) { |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 465 | case IWL_TI_0: |
| 466 | /* when system ready to go back to IWL_TI_0 state |
| 467 | * using system power mode instead of TT power mode |
| 468 | * revert back to the orginal power mode which was saved |
| 469 | * before enter Thermal Throttling state |
| 470 | * update priv->power_data.user_power_setting to the |
| 471 | * required power mode to make sure |
| 472 | * iwl_power_update_mode() will update power correctly. |
| 473 | */ |
| 474 | priv->power_data.user_power_setting = |
| 475 | tt->sys_power_mode; |
| 476 | tt->tt_power_mode = tt->sys_power_mode; |
| 477 | break; |
| 478 | case IWL_TI_1: |
| 479 | tt->tt_power_mode = IWL_POWER_INDEX_3; |
| 480 | break; |
| 481 | case IWL_TI_2: |
| 482 | tt->tt_power_mode = IWL_POWER_INDEX_4; |
| 483 | break; |
| 484 | default: |
| 485 | tt->tt_power_mode = IWL_POWER_INDEX_5; |
| 486 | break; |
| 487 | } |
Wey-Yi Guy | a28027cd | 2009-08-07 15:41:45 -0700 | [diff] [blame] | 488 | mutex_lock(&priv->mutex); |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 489 | if (iwl_power_update_mode(priv, true)) { |
| 490 | /* TT state not updated |
| 491 | * try again during next temperature read |
| 492 | */ |
Wey-Yi Guy | ee9f298 | 2009-08-07 15:41:46 -0700 | [diff] [blame] | 493 | tt->state = old_state; |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 494 | IWL_ERR(priv, "Cannot update power mode, " |
| 495 | "TT state not updated\n"); |
| 496 | } else { |
Wey-Yi Guy | ee9f298 | 2009-08-07 15:41:46 -0700 | [diff] [blame] | 497 | if (tt->state == IWL_TI_CT_KILL) |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 498 | iwl_perform_ct_kill_task(priv, true); |
Wey-Yi Guy | ee9f298 | 2009-08-07 15:41:46 -0700 | [diff] [blame] | 499 | else if (old_state == IWL_TI_CT_KILL && |
| 500 | tt->state != IWL_TI_CT_KILL) |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 501 | iwl_perform_ct_kill_task(priv, false); |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 502 | IWL_DEBUG_POWER(priv, "Temperature state changed %u\n", |
| 503 | tt->state); |
| 504 | IWL_DEBUG_POWER(priv, "Power Index change to %u\n", |
| 505 | tt->tt_power_mode); |
| 506 | } |
Wey-Yi Guy | a28027cd | 2009-08-07 15:41:45 -0700 | [diff] [blame] | 507 | mutex_unlock(&priv->mutex); |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 508 | } |
| 509 | } |
| 510 | |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 511 | /* |
| 512 | * Advance thermal throttling |
| 513 | * 1) Avoid NIC destruction due to high temperatures |
| 514 | * Chip will identify dangerously high temperatures that can |
| 515 | * harm the device and will power down |
| 516 | * 2) Avoid the NIC power down due to high temperature |
| 517 | * Throttle early enough to lower the power consumption before |
| 518 | * drastic steps are needed |
| 519 | * Actions include relaxing the power down sleep thresholds and |
| 520 | * decreasing the number of TX streams |
| 521 | * 3) Avoid throughput performance impact as much as possible |
| 522 | * |
| 523 | *============================================================================= |
| 524 | * Condition Nxt State Condition Nxt State Condition Nxt State |
| 525 | *----------------------------------------------------------------------------- |
| 526 | * IWL_TI_0 T >= 115 CT_KILL 115>T>=105 TI_1 N/A N/A |
| 527 | * IWL_TI_1 T >= 115 CT_KILL 115>T>=110 TI_2 T<=95 TI_0 |
| 528 | * IWL_TI_2 T >= 115 CT_KILL T<=100 TI_1 |
| 529 | * IWL_CT_KILL N/A N/A N/A N/A T<=95 TI_0 |
| 530 | *============================================================================= |
| 531 | */ |
| 532 | static void iwl_advance_tt_handler(struct iwl_priv *priv, s32 temp) |
| 533 | { |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 534 | struct iwl_tt_mgmt *tt = &priv->thermal_throttle; |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 535 | int i; |
| 536 | bool changed = false; |
| 537 | enum iwl_tt_state old_state; |
| 538 | struct iwl_tt_trans *transaction; |
| 539 | |
| 540 | old_state = tt->state; |
| 541 | for (i = 0; i < IWL_TI_STATE_MAX - 1; i++) { |
| 542 | /* based on the current TT state, |
| 543 | * find the curresponding transaction table |
| 544 | * each table has (IWL_TI_STATE_MAX - 1) entries |
| 545 | * tt->transaction + ((old_state * (IWL_TI_STATE_MAX - 1)) |
| 546 | * will advance to the correct table. |
| 547 | * then based on the current temperature |
| 548 | * find the next state need to transaction to |
| 549 | * go through all the possible (IWL_TI_STATE_MAX - 1) entries |
| 550 | * in the current table to see if transaction is needed |
| 551 | */ |
| 552 | transaction = tt->transaction + |
| 553 | ((old_state * (IWL_TI_STATE_MAX - 1)) + i); |
| 554 | if (temp >= transaction->tt_low && |
| 555 | temp <= transaction->tt_high) { |
| 556 | #ifdef CONFIG_IWLWIFI_DEBUG |
| 557 | if ((tt->tt_previous_temp) && |
| 558 | (temp > tt->tt_previous_temp) && |
| 559 | ((temp - tt->tt_previous_temp) > |
| 560 | IWL_TT_INCREASE_MARGIN)) { |
| 561 | IWL_DEBUG_POWER(priv, |
| 562 | "Temperature increase %d " |
| 563 | "degree Celsius\n", |
| 564 | (temp - tt->tt_previous_temp)); |
| 565 | } |
| 566 | tt->tt_previous_temp = temp; |
| 567 | #endif |
| 568 | if (old_state != |
| 569 | transaction->next_state) { |
| 570 | changed = true; |
| 571 | tt->state = |
| 572 | transaction->next_state; |
| 573 | } |
| 574 | break; |
| 575 | } |
| 576 | } |
| 577 | if (changed) { |
| 578 | struct iwl_rxon_cmd *rxon = &priv->staging_rxon; |
| 579 | struct iwl_power_mgr *setting = &priv->power_data; |
| 580 | |
| 581 | if (tt->state >= IWL_TI_1) { |
| 582 | /* if switching from IWL_TI_0 to other TT state |
| 583 | * save previous power setting in tt->sys_power_mode */ |
| 584 | if (old_state == IWL_TI_0) |
| 585 | tt->sys_power_mode = setting->power_mode; |
| 586 | /* force PI = IWL_POWER_INDEX_5 in the case of TI > 0 */ |
| 587 | tt->tt_power_mode = IWL_POWER_INDEX_5; |
| 588 | if (!iwl_ht_enabled(priv)) |
| 589 | /* disable HT */ |
| 590 | rxon->flags &= ~(RXON_FLG_CHANNEL_MODE_MSK | |
| 591 | RXON_FLG_CTRL_CHANNEL_LOC_HI_MSK | |
Wey-Yi Guy | 7aafef1 | 2009-08-07 15:41:38 -0700 | [diff] [blame] | 592 | RXON_FLG_HT40_PROT_MSK | |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 593 | RXON_FLG_HT_PROT_MSK); |
| 594 | else { |
| 595 | /* check HT capability and set |
| 596 | * according to the system HT capability |
| 597 | * in case get disabled before */ |
| 598 | iwl_set_rxon_ht(priv, &priv->current_ht_config); |
| 599 | } |
| 600 | |
| 601 | } else { |
| 602 | /* restore system power setting */ |
| 603 | /* the previous power mode was saved in |
| 604 | * tt->sys_power_mode when system move into |
| 605 | * Thermal Throttling state |
| 606 | * set power_data.user_power_setting to the previous |
| 607 | * system power mode to make sure power will get |
| 608 | * updated correctly |
| 609 | */ |
| 610 | priv->power_data.user_power_setting = |
| 611 | tt->sys_power_mode; |
| 612 | tt->tt_power_mode = tt->sys_power_mode; |
| 613 | /* check HT capability and set |
| 614 | * according to the system HT capability |
| 615 | * in case get disabled before */ |
| 616 | iwl_set_rxon_ht(priv, &priv->current_ht_config); |
| 617 | } |
Wey-Yi Guy | a28027cd | 2009-08-07 15:41:45 -0700 | [diff] [blame] | 618 | mutex_lock(&priv->mutex); |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 619 | if (iwl_power_update_mode(priv, true)) { |
| 620 | /* TT state not updated |
| 621 | * try again during next temperature read |
| 622 | */ |
| 623 | IWL_ERR(priv, "Cannot update power mode, " |
| 624 | "TT state not updated\n"); |
| 625 | tt->state = old_state; |
| 626 | } else { |
| 627 | IWL_DEBUG_POWER(priv, |
| 628 | "Thermal Throttling to new state: %u\n", |
| 629 | tt->state); |
| 630 | if (old_state != IWL_TI_CT_KILL && |
| 631 | tt->state == IWL_TI_CT_KILL) { |
| 632 | IWL_DEBUG_POWER(priv, "Enter IWL_TI_CT_KILL\n"); |
| 633 | iwl_perform_ct_kill_task(priv, true); |
| 634 | |
| 635 | } else if (old_state == IWL_TI_CT_KILL && |
| 636 | tt->state != IWL_TI_CT_KILL) { |
| 637 | IWL_DEBUG_POWER(priv, "Exit IWL_TI_CT_KILL\n"); |
| 638 | iwl_perform_ct_kill_task(priv, false); |
| 639 | } |
| 640 | } |
Wey-Yi Guy | a28027cd | 2009-08-07 15:41:45 -0700 | [diff] [blame] | 641 | mutex_unlock(&priv->mutex); |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 642 | } |
| 643 | } |
| 644 | |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 645 | /* Card State Notification indicated reach critical temperature |
| 646 | * if PSP not enable, no Thermal Throttling function will be performed |
| 647 | * just set the GP1 bit to acknowledge the event |
| 648 | * otherwise, go into IWL_TI_CT_KILL state |
| 649 | * since Card State Notification will not provide any temperature reading |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 650 | * for Legacy mode |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 651 | * so just pass the CT_KILL temperature to iwl_legacy_tt_handler() |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 652 | * for advance mode |
| 653 | * pass CT_KILL_THRESHOLD+1 to make sure move into IWL_TI_CT_KILL state |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 654 | */ |
Wey-Yi Guy | a28027cd | 2009-08-07 15:41:45 -0700 | [diff] [blame] | 655 | static void iwl_bg_ct_enter(struct work_struct *work) |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 656 | { |
Wey-Yi Guy | a28027cd | 2009-08-07 15:41:45 -0700 | [diff] [blame] | 657 | struct iwl_priv *priv = container_of(work, struct iwl_priv, ct_enter); |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 658 | struct iwl_tt_mgmt *tt = &priv->thermal_throttle; |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 659 | |
| 660 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
| 661 | return; |
| 662 | |
Wey-Yi Guy | a28027cd | 2009-08-07 15:41:45 -0700 | [diff] [blame] | 663 | if (!iwl_is_ready(priv)) |
| 664 | return; |
| 665 | |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 666 | if (tt->state != IWL_TI_CT_KILL) { |
| 667 | IWL_ERR(priv, "Device reached critical temperature " |
| 668 | "- ucode going to sleep!\n"); |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 669 | if (!priv->thermal_throttle.advanced_tt) |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 670 | iwl_legacy_tt_handler(priv, |
| 671 | IWL_MINIMAL_POWER_THRESHOLD); |
| 672 | else |
| 673 | iwl_advance_tt_handler(priv, |
| 674 | CT_KILL_THRESHOLD + 1); |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 675 | } |
| 676 | } |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 677 | |
| 678 | /* Card State Notification indicated out of critical temperature |
| 679 | * since Card State Notification will not provide any temperature reading |
| 680 | * so pass the IWL_REDUCED_PERFORMANCE_THRESHOLD_2 temperature |
| 681 | * to iwl_legacy_tt_handler() to get out of IWL_CT_KILL state |
| 682 | */ |
Wey-Yi Guy | a28027cd | 2009-08-07 15:41:45 -0700 | [diff] [blame] | 683 | static void iwl_bg_ct_exit(struct work_struct *work) |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 684 | { |
Wey-Yi Guy | a28027cd | 2009-08-07 15:41:45 -0700 | [diff] [blame] | 685 | struct iwl_priv *priv = container_of(work, struct iwl_priv, ct_exit); |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 686 | struct iwl_tt_mgmt *tt = &priv->thermal_throttle; |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 687 | |
| 688 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
| 689 | return; |
| 690 | |
Wey-Yi Guy | a28027cd | 2009-08-07 15:41:45 -0700 | [diff] [blame] | 691 | if (!iwl_is_ready(priv)) |
| 692 | return; |
| 693 | |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 694 | /* stop ct_kill_exit_tm timer */ |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 695 | del_timer_sync(&priv->thermal_throttle.ct_kill_exit_tm); |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 696 | |
| 697 | if (tt->state == IWL_TI_CT_KILL) { |
| 698 | IWL_ERR(priv, |
| 699 | "Device temperature below critical" |
| 700 | "- ucode awake!\n"); |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 701 | if (!priv->thermal_throttle.advanced_tt) |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 702 | iwl_legacy_tt_handler(priv, |
| 703 | IWL_REDUCED_PERFORMANCE_THRESHOLD_2); |
| 704 | else |
| 705 | iwl_advance_tt_handler(priv, CT_KILL_EXIT_THRESHOLD); |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 706 | } |
| 707 | } |
Wey-Yi Guy | a28027cd | 2009-08-07 15:41:45 -0700 | [diff] [blame] | 708 | |
| 709 | void iwl_tt_enter_ct_kill(struct iwl_priv *priv) |
| 710 | { |
| 711 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
| 712 | return; |
| 713 | |
| 714 | IWL_DEBUG_POWER(priv, "Queueing critical temperature enter.\n"); |
| 715 | queue_work(priv->workqueue, &priv->ct_enter); |
| 716 | } |
| 717 | EXPORT_SYMBOL(iwl_tt_enter_ct_kill); |
| 718 | |
| 719 | void iwl_tt_exit_ct_kill(struct iwl_priv *priv) |
| 720 | { |
| 721 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
| 722 | return; |
| 723 | |
| 724 | IWL_DEBUG_POWER(priv, "Queueing critical temperature exit.\n"); |
| 725 | queue_work(priv->workqueue, &priv->ct_exit); |
| 726 | } |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 727 | EXPORT_SYMBOL(iwl_tt_exit_ct_kill); |
| 728 | |
Wey-Yi Guy | a28027cd | 2009-08-07 15:41:45 -0700 | [diff] [blame] | 729 | static void iwl_bg_tt_work(struct work_struct *work) |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 730 | { |
Wey-Yi Guy | a28027cd | 2009-08-07 15:41:45 -0700 | [diff] [blame] | 731 | struct iwl_priv *priv = container_of(work, struct iwl_priv, tt_work); |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 732 | s32 temp = priv->temperature; /* degrees CELSIUS except 4965 */ |
| 733 | |
| 734 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
| 735 | return; |
| 736 | |
| 737 | if ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) |
| 738 | temp = KELVIN_TO_CELSIUS(priv->temperature); |
| 739 | |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 740 | if (!priv->thermal_throttle.advanced_tt) |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 741 | iwl_legacy_tt_handler(priv, temp); |
| 742 | else |
| 743 | iwl_advance_tt_handler(priv, temp); |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 744 | } |
Wey-Yi Guy | a28027cd | 2009-08-07 15:41:45 -0700 | [diff] [blame] | 745 | |
| 746 | void iwl_tt_handler(struct iwl_priv *priv) |
| 747 | { |
| 748 | if (test_bit(STATUS_EXIT_PENDING, &priv->status)) |
| 749 | return; |
| 750 | |
| 751 | IWL_DEBUG_POWER(priv, "Queueing thermal throttling work.\n"); |
| 752 | queue_work(priv->workqueue, &priv->tt_work); |
| 753 | } |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 754 | EXPORT_SYMBOL(iwl_tt_handler); |
| 755 | |
| 756 | /* Thermal throttling initialization |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 757 | * For advance thermal throttling: |
| 758 | * Initialize Thermal Index and temperature threshold table |
| 759 | * Initialize thermal throttling restriction table |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 760 | */ |
| 761 | void iwl_tt_initialize(struct iwl_priv *priv) |
| 762 | { |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 763 | struct iwl_tt_mgmt *tt = &priv->thermal_throttle; |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 764 | struct iwl_power_mgr *setting = &priv->power_data; |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 765 | int size = sizeof(struct iwl_tt_trans) * (IWL_TI_STATE_MAX - 1); |
| 766 | struct iwl_tt_trans *transaction; |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 767 | |
| 768 | IWL_DEBUG_POWER(priv, "Initialize Thermal Throttling \n"); |
| 769 | |
| 770 | memset(tt, 0, sizeof(struct iwl_tt_mgmt)); |
| 771 | |
| 772 | tt->state = IWL_TI_0; |
| 773 | tt->sys_power_mode = setting->power_mode; |
| 774 | tt->tt_power_mode = tt->sys_power_mode; |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 775 | init_timer(&priv->thermal_throttle.ct_kill_exit_tm); |
| 776 | priv->thermal_throttle.ct_kill_exit_tm.data = (unsigned long)priv; |
| 777 | priv->thermal_throttle.ct_kill_exit_tm.function = iwl_tt_check_exit_ct_kill; |
Wey-Yi Guy | a28027cd | 2009-08-07 15:41:45 -0700 | [diff] [blame] | 778 | |
| 779 | /* setup deferred ct kill work */ |
| 780 | INIT_WORK(&priv->tt_work, iwl_bg_tt_work); |
| 781 | INIT_WORK(&priv->ct_enter, iwl_bg_ct_enter); |
| 782 | INIT_WORK(&priv->ct_exit, iwl_bg_ct_exit); |
| 783 | |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 784 | switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) { |
| 785 | case CSR_HW_REV_TYPE_6x00: |
| 786 | case CSR_HW_REV_TYPE_6x50: |
| 787 | IWL_DEBUG_POWER(priv, "Advanced Thermal Throttling\n"); |
| 788 | tt->restriction = kzalloc(sizeof(struct iwl_tt_restriction) * |
| 789 | IWL_TI_STATE_MAX, GFP_KERNEL); |
| 790 | tt->transaction = kzalloc(sizeof(struct iwl_tt_trans) * |
| 791 | IWL_TI_STATE_MAX * (IWL_TI_STATE_MAX - 1), |
| 792 | GFP_KERNEL); |
| 793 | if (!tt->restriction || !tt->transaction) { |
| 794 | IWL_ERR(priv, "Fallback to Legacy Throttling\n"); |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 795 | priv->thermal_throttle.advanced_tt = false; |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 796 | kfree(tt->restriction); |
| 797 | tt->restriction = NULL; |
| 798 | kfree(tt->transaction); |
| 799 | tt->transaction = NULL; |
| 800 | } else { |
| 801 | transaction = tt->transaction + |
| 802 | (IWL_TI_0 * (IWL_TI_STATE_MAX - 1)); |
| 803 | memcpy(transaction, &tt_range_0[0], size); |
| 804 | transaction = tt->transaction + |
| 805 | (IWL_TI_1 * (IWL_TI_STATE_MAX - 1)); |
| 806 | memcpy(transaction, &tt_range_1[0], size); |
| 807 | transaction = tt->transaction + |
| 808 | (IWL_TI_2 * (IWL_TI_STATE_MAX - 1)); |
| 809 | memcpy(transaction, &tt_range_2[0], size); |
| 810 | transaction = tt->transaction + |
| 811 | (IWL_TI_CT_KILL * (IWL_TI_STATE_MAX - 1)); |
| 812 | memcpy(transaction, &tt_range_3[0], size); |
| 813 | size = sizeof(struct iwl_tt_restriction) * |
| 814 | IWL_TI_STATE_MAX; |
| 815 | memcpy(tt->restriction, |
| 816 | &restriction_range[0], size); |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 817 | priv->thermal_throttle.advanced_tt = true; |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 818 | } |
| 819 | break; |
| 820 | default: |
| 821 | IWL_DEBUG_POWER(priv, "Legacy Thermal Throttling\n"); |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 822 | priv->thermal_throttle.advanced_tt = false; |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 823 | break; |
| 824 | } |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 825 | } |
| 826 | EXPORT_SYMBOL(iwl_tt_initialize); |
| 827 | |
| 828 | /* cleanup thermal throttling management related memory and timer */ |
| 829 | void iwl_tt_exit(struct iwl_priv *priv) |
| 830 | { |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 831 | struct iwl_tt_mgmt *tt = &priv->thermal_throttle; |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 832 | |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 833 | /* stop ct_kill_exit_tm timer if activated */ |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 834 | del_timer_sync(&priv->thermal_throttle.ct_kill_exit_tm); |
Wey-Yi Guy | a28027cd | 2009-08-07 15:41:45 -0700 | [diff] [blame] | 835 | cancel_work_sync(&priv->tt_work); |
| 836 | cancel_work_sync(&priv->ct_enter); |
| 837 | cancel_work_sync(&priv->ct_exit); |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 838 | |
Johannes Berg | 3ad3b92 | 2009-08-07 15:41:48 -0700 | [diff] [blame^] | 839 | if (priv->thermal_throttle.advanced_tt) { |
Wey-Yi Guy | 46f9381 | 2009-07-24 11:13:03 -0700 | [diff] [blame] | 840 | /* free advance thermal throttling memory */ |
| 841 | kfree(tt->restriction); |
| 842 | tt->restriction = NULL; |
| 843 | kfree(tt->transaction); |
| 844 | tt->transaction = NULL; |
| 845 | } |
Wey-Yi Guy | 39b73fb1 | 2009-07-24 11:13:02 -0700 | [diff] [blame] | 846 | } |
| 847 | EXPORT_SYMBOL(iwl_tt_exit); |
| 848 | |
Tomas Winkler | a96a27f | 2008-10-23 23:48:56 -0700 | [diff] [blame] | 849 | /* initialize to default */ |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 850 | void iwl_power_initialize(struct iwl_priv *priv) |
| 851 | { |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 852 | iwl_power_init_handle(priv); |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 853 | priv->power_data.user_power_setting = IWL_POWER_INDEX_1; |
| 854 | /* default to disabled until mac80211 says otherwise */ |
| 855 | priv->power_data.power_disabled = 1; |
Mohamed Abbas | 5da4b55 | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 856 | } |
| 857 | EXPORT_SYMBOL(iwl_power_initialize); |