30 #include <linux/kernel.h>
31 #include <linux/module.h>
32 #include <linux/slab.h>
62 #define IWL_DTIM_RANGE_0_MAX 2
63 #define IWL_DTIM_RANGE_1_MAX 10
65 #define NOSLP cpu_to_le16(0), 0, 0
66 #define SLP IWL_POWER_DRIVER_ALLOW_SLEEP_MSK, 0, 0
67 #define ASLP (IWL_POWER_POWER_SAVE_ENA_MSK | \
68 IWL_POWER_POWER_MANAGEMENT_ENA_MSK | \
69 IWL_POWER_ADVANCE_PM_ENA_MSK)
70 #define ASLP_TOUT(T) cpu_to_le32(T)
71 #define TU_TO_USEC 1024
72 #define SLP_TOUT(T) cpu_to_le32((T) * TU_TO_USEC)
73 #define SLP_VEC(X0, X1, X2, X3, X4) {cpu_to_le32(X0), \
114 SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
116 SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
118 SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
120 SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
130 SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
132 SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
134 SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
136 SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
138 SLP_VEC(1, 2, 6, 8, 0xFF), 0}, 2}
145 SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
147 SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
149 SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
151 SLP_VEC(1, 2, 4, 6, 0xFF), 0}, 0},
166 if (priv->
cfg->adv_pm) {
181 memset(cmd, 0,
sizeof(*cmd));
183 *cmd = table[lvl].
cmd;
195 max_sleep[IWL_POWER_VEC_SIZE - 1] = skip + 1;
200 if (slp_itrvl == 0xFF)
205 if (slp_itrvl > period)
214 if (priv->
cfg->base_params->shadow_reg_enable)
219 if (iwl_advanced_bt_coexist(priv)) {
220 if (!priv->
cfg->bt_params->bt_sco_disable)
233 for (i = IWL_POWER_VEC_SIZE - 1; i >= 0 ; i--) {
235 (max_sleep[i] * period))
238 if (i != (IWL_POWER_VEC_SIZE - 1)) {
258 static void iwl_power_sleep_cam_cmd(
struct iwl_priv *priv,
261 memset(cmd, 0,
sizeof(*cmd));
275 IWL_DEBUG_POWER(priv,
"Sleep interval vector = { %d , %d , %d , %d , %d }\n",
286 static void iwl_power_build_cmd(
struct iwl_priv *priv,
292 dtimper = priv->
hw->conf.ps_dtim_period ?: 1;
296 else if (!priv->
cfg->base_params->no_idle_support &&
301 iwl_static_sleep_cmd(priv, cmd,
304 iwl_power_sleep_cam_cmd(priv, cmd);
305 else if (priv->
power_data.debug_sleep_level_override >= 0)
306 iwl_static_sleep_cmd(priv, cmd,
314 iwl_static_sleep_cmd(priv, cmd,
317 iwl_static_sleep_cmd(priv, cmd,
337 if (!iwl_is_ready_rf(priv))
348 iwl_dvm_set_pmi(priv,
true);
350 ret = iwl_set_power(priv, cmd);
353 iwl_dvm_set_pmi(priv,
false);
359 "Cannot update the power, chain noise "
360 "calibration running: %d\n",
365 IWL_ERR(priv,
"set power fail, ret = %d", ret);
374 iwl_power_build_cmd(priv, &cmd);
383 priv->
power_data.debug_sleep_level_override = -1;