Mohamed Abbas | 5da4b55f | 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 | 5da4b55f | 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 | 5da4b55f | 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 | 5da4b55f | 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 | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 38 | #include "iwl-core.h" |
Tomas Winkler | 5a36ba0 | 2008-04-24 11:55:37 -0700 | [diff] [blame] | 39 | #include "iwl-commands.h" |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 40 | #include "iwl-debug.h" |
| 41 | #include "iwl-power.h" |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 42 | |
| 43 | /* |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 44 | * Setting power level allow the card to go to sleep when not busy. |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 45 | * |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 46 | * The power level is set to INDEX_1 (the least deep state) by |
| 47 | * default, and will, in the future, be the deepest state unless |
| 48 | * otherwise required by pm_qos network latency requirements. |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 49 | * |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 50 | * Using INDEX_1 without pm_qos is ok because mac80211 will disable |
| 51 | * PS when even checking every beacon for the TIM bit would exceed |
| 52 | * the required latency. |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 53 | */ |
| 54 | |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 55 | #define IWL_POWER_RANGE_0_MAX (2) |
| 56 | #define IWL_POWER_RANGE_1_MAX (10) |
| 57 | |
| 58 | |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 59 | #define NOSLP cpu_to_le16(0), 0, 0 |
| 60 | #define SLP IWL_POWER_DRIVER_ALLOW_SLEEP_MSK, 0, 0 |
| 61 | #define TU_TO_USEC 1024 |
| 62 | #define SLP_TOUT(T) cpu_to_le32((T) * TU_TO_USEC) |
| 63 | #define SLP_VEC(X0, X1, X2, X3, X4) {cpu_to_le32(X0), \ |
| 64 | cpu_to_le32(X1), \ |
| 65 | cpu_to_le32(X2), \ |
| 66 | cpu_to_le32(X3), \ |
| 67 | cpu_to_le32(X4)} |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 68 | /* default power management (not Tx power) table values */ |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 69 | /* for DTIM period 0 through IWL_POWER_RANGE_0_MAX */ |
| 70 | static const struct iwl_power_vec_entry range_0[IWL_POWER_NUM] = { |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 71 | {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, |
| 72 | {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 2, 2, 0xFF)}, 0}, |
| 73 | {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(1, 2, 2, 2, 0xFF)}, 0}, |
| 74 | {{SLP, SLP_TOUT(50), SLP_TOUT(100), SLP_VEC(2, 2, 2, 2, 0xFF)}, 0}, |
| 75 | {{SLP, SLP_TOUT(50), SLP_TOUT(25), SLP_VEC(2, 2, 4, 4, 0xFF)}, 1}, |
| 76 | {{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(2, 2, 4, 6, 0xFF)}, 2} |
| 77 | }; |
| 78 | |
| 79 | |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 80 | /* for DTIM period IWL_POWER_RANGE_0_MAX + 1 through IWL_POWER_RANGE_1_MAX */ |
| 81 | static const struct iwl_power_vec_entry range_1[IWL_POWER_NUM] = { |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 82 | {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, |
| 83 | {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 4)}, 0}, |
| 84 | {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(1, 2, 3, 4, 7)}, 0}, |
| 85 | {{SLP, SLP_TOUT(50), SLP_TOUT(100), SLP_VEC(2, 4, 6, 7, 9)}, 0}, |
| 86 | {{SLP, SLP_TOUT(50), SLP_TOUT(25), SLP_VEC(2, 4, 6, 9, 10)}, 1}, |
| 87 | {{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(2, 4, 7, 10, 10)}, 2} |
| 88 | }; |
| 89 | |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 90 | /* for DTIM period > IWL_POWER_RANGE_1_MAX */ |
| 91 | static const struct iwl_power_vec_entry range_2[IWL_POWER_NUM] = { |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 92 | {{NOSLP, SLP_TOUT(0), SLP_TOUT(0), SLP_VEC(0, 0, 0, 0, 0)}, 0}, |
| 93 | {{SLP, SLP_TOUT(200), SLP_TOUT(500), SLP_VEC(1, 2, 3, 4, 0xFF)}, 0}, |
| 94 | {{SLP, SLP_TOUT(200), SLP_TOUT(300), SLP_VEC(2, 4, 6, 7, 0xFF)}, 0}, |
| 95 | {{SLP, SLP_TOUT(50), SLP_TOUT(100), SLP_VEC(2, 7, 9, 9, 0xFF)}, 0}, |
| 96 | {{SLP, SLP_TOUT(50), SLP_TOUT(25), SLP_VEC(2, 7, 9, 9, 0xFF)}, 0}, |
| 97 | {{SLP, SLP_TOUT(25), SLP_TOUT(25), SLP_VEC(4, 7, 10, 10, 0xFF)}, 0} |
| 98 | }; |
| 99 | |
Winkler, Tomas | d25aabb | 2009-01-27 14:27:58 -0800 | [diff] [blame] | 100 | |
Mohamed Abbas | ca57961 | 2008-07-18 13:52:57 +0800 | [diff] [blame] | 101 | /* set card power command */ |
| 102 | static int iwl_set_power(struct iwl_priv *priv, void *cmd) |
| 103 | { |
Johannes Berg | f0f74a0 | 2009-05-08 13:44:37 -0700 | [diff] [blame] | 104 | return iwl_send_cmd_pdu(priv, POWER_TABLE_CMD, |
| 105 | sizeof(struct iwl_powertable_cmd), cmd); |
Mohamed Abbas | ca57961 | 2008-07-18 13:52:57 +0800 | [diff] [blame] | 106 | } |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 107 | |
| 108 | /* initialize to default */ |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 109 | static void iwl_power_init_handle(struct iwl_priv *priv) |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 110 | { |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 111 | struct iwl_power_mgr *pow_data; |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 112 | int size = sizeof(struct iwl_power_vec_entry) * IWL_POWER_NUM; |
Tomas Winkler | e7b6358 | 2008-09-03 11:26:49 +0800 | [diff] [blame] | 113 | struct iwl_powertable_cmd *cmd; |
| 114 | int i; |
Tomas Winkler | 3fdb68d | 2009-02-10 15:19:02 -0800 | [diff] [blame] | 115 | u16 lctl; |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 116 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 117 | IWL_DEBUG_POWER(priv, "Initialize power \n"); |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 118 | |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 119 | pow_data = &priv->power_data; |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 120 | |
| 121 | memset(pow_data, 0, sizeof(*pow_data)); |
| 122 | |
| 123 | memcpy(&pow_data->pwr_range_0[0], &range_0[0], size); |
| 124 | memcpy(&pow_data->pwr_range_1[0], &range_1[0], size); |
| 125 | memcpy(&pow_data->pwr_range_2[0], &range_2[0], size); |
| 126 | |
Tomas Winkler | 3fdb68d | 2009-02-10 15:19:02 -0800 | [diff] [blame] | 127 | lctl = iwl_pcie_link_ctl(priv); |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 128 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 129 | IWL_DEBUG_POWER(priv, "adjust power command flags\n"); |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 130 | |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 131 | for (i = 0; i < IWL_POWER_NUM; i++) { |
Tomas Winkler | e7b6358 | 2008-09-03 11:26:49 +0800 | [diff] [blame] | 132 | cmd = &pow_data->pwr_range_0[i].cmd; |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 133 | |
Tomas Winkler | 3fdb68d | 2009-02-10 15:19:02 -0800 | [diff] [blame] | 134 | if (lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN) |
Tomas Winkler | e7b6358 | 2008-09-03 11:26:49 +0800 | [diff] [blame] | 135 | cmd->flags &= ~IWL_POWER_PCI_PM_MSK; |
| 136 | else |
| 137 | cmd->flags |= IWL_POWER_PCI_PM_MSK; |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 138 | } |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 139 | } |
| 140 | |
Tomas Winkler | a96a27f | 2008-10-23 23:48:56 -0700 | [diff] [blame] | 141 | /* adjust power command according to DTIM period and power level*/ |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 142 | static int iwl_update_power_cmd(struct iwl_priv *priv, |
| 143 | struct iwl_powertable_cmd *cmd, u16 mode) |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 144 | { |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 145 | struct iwl_power_vec_entry *range; |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 146 | struct iwl_power_mgr *pow_data; |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 147 | int i; |
| 148 | u32 max_sleep = 0; |
| 149 | u8 period; |
| 150 | bool skip; |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 151 | |
| 152 | if (mode > IWL_POWER_INDEX_5) { |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 153 | IWL_DEBUG_POWER(priv, "Error invalid power mode \n"); |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 154 | return -EINVAL; |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 155 | } |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 156 | |
| 157 | pow_data = &priv->power_data; |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 158 | |
| 159 | if (pow_data->dtim_period <= IWL_POWER_RANGE_0_MAX) |
| 160 | range = &pow_data->pwr_range_0[0]; |
| 161 | else if (pow_data->dtim_period <= IWL_POWER_RANGE_1_MAX) |
| 162 | range = &pow_data->pwr_range_1[0]; |
| 163 | else |
| 164 | range = &pow_data->pwr_range_2[0]; |
| 165 | |
| 166 | period = pow_data->dtim_period; |
Mohamed Abbas | ca57961 | 2008-07-18 13:52:57 +0800 | [diff] [blame] | 167 | memcpy(cmd, &range[mode].cmd, sizeof(struct iwl_powertable_cmd)); |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 168 | |
| 169 | if (period == 0) { |
| 170 | period = 1; |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 171 | skip = false; |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 172 | } else { |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 173 | skip = !!range[mode].no_dtim; |
| 174 | } |
| 175 | |
| 176 | if (skip) { |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 177 | __le32 slp_itrvl = cmd->sleep_interval[IWL_POWER_VEC_SIZE - 1]; |
| 178 | max_sleep = le32_to_cpu(slp_itrvl); |
| 179 | if (max_sleep == 0xFF) |
| 180 | max_sleep = period * (skip + 1); |
| 181 | else if (max_sleep > period) |
| 182 | max_sleep = (le32_to_cpu(slp_itrvl) / period) * period; |
| 183 | cmd->flags |= IWL_POWER_SLEEP_OVER_DTIM_MSK; |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 184 | } else { |
| 185 | max_sleep = period; |
| 186 | cmd->flags &= ~IWL_POWER_SLEEP_OVER_DTIM_MSK; |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 189 | for (i = 0; i < IWL_POWER_VEC_SIZE; i++) |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 190 | if (le32_to_cpu(cmd->sleep_interval[i]) > max_sleep) |
| 191 | cmd->sleep_interval[i] = cpu_to_le32(max_sleep); |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 192 | |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 193 | IWL_DEBUG_POWER(priv, "Flags value = 0x%08X\n", cmd->flags); |
| 194 | IWL_DEBUG_POWER(priv, "Tx timeout = %u\n", le32_to_cpu(cmd->tx_data_timeout)); |
| 195 | IWL_DEBUG_POWER(priv, "Rx timeout = %u\n", le32_to_cpu(cmd->rx_data_timeout)); |
| 196 | IWL_DEBUG_POWER(priv, "Sleep interval vector = { %d , %d , %d , %d , %d }\n", |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 197 | le32_to_cpu(cmd->sleep_interval[0]), |
| 198 | le32_to_cpu(cmd->sleep_interval[1]), |
| 199 | le32_to_cpu(cmd->sleep_interval[2]), |
| 200 | le32_to_cpu(cmd->sleep_interval[3]), |
| 201 | le32_to_cpu(cmd->sleep_interval[4])); |
| 202 | |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 203 | return 0; |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | |
| 207 | /* |
Emmanuel Grumbach | a33c2f4 | 2008-09-03 11:26:56 +0800 | [diff] [blame] | 208 | * compute the final power mode index |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 209 | */ |
Grumbach, Emmanuel | 0481644 | 2008-09-03 11:26:53 +0800 | [diff] [blame] | 210 | int iwl_power_update_mode(struct iwl_priv *priv, bool force) |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 211 | { |
| 212 | struct iwl_power_mgr *setting = &(priv->power_data); |
| 213 | int ret = 0; |
| 214 | u16 uninitialized_var(final_mode); |
Winkler, Tomas | a71c8f6 | 2008-11-07 09:58:37 -0800 | [diff] [blame] | 215 | bool update_chains; |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 216 | |
Grumbach, Emmanuel | 0481644 | 2008-09-03 11:26:53 +0800 | [diff] [blame] | 217 | /* Don't update the RX chain when chain noise calibration is running */ |
Winkler, Tomas | a71c8f6 | 2008-11-07 09:58:37 -0800 | [diff] [blame] | 218 | update_chains = priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE || |
| 219 | priv->chain_noise_data.state == IWL_CHAIN_NOISE_ALIVE; |
Grumbach, Emmanuel | 0481644 | 2008-09-03 11:26:53 +0800 | [diff] [blame] | 220 | |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 221 | final_mode = priv->power_data.user_power_setting; |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 222 | |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 223 | if (setting->power_disabled) |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 224 | final_mode = IWL_POWER_MODE_CAM; |
| 225 | |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 226 | if (iwl_is_ready_rf(priv) && |
Grumbach, Emmanuel | 0481644 | 2008-09-03 11:26:53 +0800 | [diff] [blame] | 227 | ((setting->power_mode != final_mode) || force)) { |
Mohamed Abbas | ca57961 | 2008-07-18 13:52:57 +0800 | [diff] [blame] | 228 | struct iwl_powertable_cmd cmd; |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 229 | |
| 230 | if (final_mode != IWL_POWER_MODE_CAM) |
| 231 | set_bit(STATUS_POWER_PMI, &priv->status); |
| 232 | |
Winkler, Tomas | 5cd19c5 | 2009-01-19 15:30:21 -0800 | [diff] [blame] | 233 | iwl_update_power_cmd(priv, &cmd, final_mode); |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 234 | cmd.keep_alive_beacons = 0; |
| 235 | |
| 236 | if (final_mode == IWL_POWER_INDEX_5) |
| 237 | cmd.flags |= IWL_POWER_FAST_PD; |
| 238 | |
Mohamed Abbas | ca57961 | 2008-07-18 13:52:57 +0800 | [diff] [blame] | 239 | ret = iwl_set_power(priv, &cmd); |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 240 | |
| 241 | if (final_mode == IWL_POWER_MODE_CAM) |
| 242 | clear_bit(STATUS_POWER_PMI, &priv->status); |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 243 | |
Winkler, Tomas | a71c8f6 | 2008-11-07 09:58:37 -0800 | [diff] [blame] | 244 | if (priv->cfg->ops->lib->update_chain_flags && update_chains) |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 245 | priv->cfg->ops->lib->update_chain_flags(priv); |
Winkler, Tomas | a71c8f6 | 2008-11-07 09:58:37 -0800 | [diff] [blame] | 246 | else |
Tomas Winkler | e162344 | 2009-01-27 14:27:56 -0800 | [diff] [blame] | 247 | IWL_DEBUG_POWER(priv, "Cannot update the power, chain noise " |
Winkler, Tomas | a71c8f6 | 2008-11-07 09:58:37 -0800 | [diff] [blame] | 248 | "calibration running: %d\n", |
| 249 | priv->chain_noise_data.state); |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 250 | if (!ret) |
| 251 | setting->power_mode = final_mode; |
| 252 | } |
| 253 | |
| 254 | return ret; |
| 255 | } |
| 256 | EXPORT_SYMBOL(iwl_power_update_mode); |
| 257 | |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 258 | /* set user_power_setting */ |
| 259 | int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode) |
| 260 | { |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 261 | if (mode >= IWL_POWER_NUM) |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 262 | return -EINVAL; |
| 263 | |
| 264 | priv->power_data.user_power_setting = mode; |
| 265 | |
Grumbach, Emmanuel | 0481644 | 2008-09-03 11:26:53 +0800 | [diff] [blame] | 266 | return iwl_power_update_mode(priv, 0); |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 267 | } |
| 268 | EXPORT_SYMBOL(iwl_power_set_user_mode); |
| 269 | |
Tomas Winkler | a96a27f | 2008-10-23 23:48:56 -0700 | [diff] [blame] | 270 | /* initialize to default */ |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 271 | void iwl_power_initialize(struct iwl_priv *priv) |
| 272 | { |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 273 | iwl_power_init_handle(priv); |
Johannes Berg | 7af2c46 | 2009-05-08 13:44:38 -0700 | [diff] [blame] | 274 | priv->power_data.user_power_setting = IWL_POWER_INDEX_1; |
| 275 | /* default to disabled until mac80211 says otherwise */ |
| 276 | priv->power_data.power_disabled = 1; |
Mohamed Abbas | 5da4b55f | 2008-04-21 15:41:51 -0700 | [diff] [blame] | 277 | } |
| 278 | EXPORT_SYMBOL(iwl_power_initialize); |