]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/net/wireless/iwlwifi/iwl-power.c
iwlagn: introduce iwl-shared.h
[karo-tx-linux.git] / drivers / net / wireless / iwlwifi / iwl-power.c
index 595c930b28aebaf9bccd9ec50ab936190246345a..b60e692a476517612b7dcbb546bd0a9d08156d40 100644 (file)
 
 #include "iwl-eeprom.h"
 #include "iwl-dev.h"
+#include "iwl-agn.h"
 #include "iwl-core.h"
 #include "iwl-io.h"
 #include "iwl-commands.h"
 #include "iwl-debug.h"
 #include "iwl-power.h"
+#include "iwl-trans.h"
+#include "iwl-shared.h"
 
 /*
  * Setting power level allows the card to go to sleep when not busy.
  * also use pre-defined power levels.
  */
 
-/*
- * 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");
-
 /*
  * This defines the old power levels. They are still used by default
  * (level 1) and for thermal throttle (levels 3 through 5)
@@ -254,7 +247,7 @@ static void iwl_static_sleep_cmd(struct iwl_priv *priv,
                }
        }
 
-       if (priv->power_data.pci_pm)
+       if (priv->power_data.bus_pm)
                cmd->flags |= IWL_POWER_PCI_PM_MSK;
        else
                cmd->flags &= ~IWL_POWER_PCI_PM_MSK;
@@ -269,7 +262,7 @@ static void iwl_power_sleep_cam_cmd(struct iwl_priv *priv,
 {
        memset(cmd, 0, sizeof(*cmd));
 
-       if (priv->power_data.pci_pm)
+       if (priv->power_data.bus_pm)
                cmd->flags |= IWL_POWER_PCI_PM_MSK;
 
        IWL_DEBUG_POWER(priv, "Sleep command for CAM\n");
@@ -305,7 +298,7 @@ static void iwl_power_fill_sleep_cmd(struct iwl_priv *priv,
        cmd->flags = IWL_POWER_DRIVER_ALLOW_SLEEP_MSK |
                     IWL_POWER_FAST_PD; /* no use seeing frames for others */
 
-       if (priv->power_data.pci_pm)
+       if (priv->power_data.bus_pm)
                cmd->flags |= IWL_POWER_PCI_PM_MSK;
 
        if (priv->cfg->base_params->shadow_reg_enable)
@@ -343,7 +336,7 @@ static int iwl_set_power(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd)
                        le32_to_cpu(cmd->sleep_interval[3]),
                        le32_to_cpu(cmd->sleep_interval[4]));
 
-       return iwl_send_cmd_pdu(priv, POWER_TABLE_CMD,
+       return trans_send_cmd_pdu(&priv->trans, POWER_TABLE_CMD, CMD_SYNC,
                                sizeof(struct iwl_powertable_cmd), cmd);
 }
 
@@ -355,7 +348,10 @@ static void iwl_power_build_cmd(struct iwl_priv *priv,
 
        dtimper = priv->hw->conf.ps_dtim_period ?: 1;
 
-       if (priv->hw->conf.flags & IEEE80211_CONF_IDLE)
+       if (priv->wowlan)
+               iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, dtimper);
+       else if (!priv->cfg->base_params->no_idle_support &&
+                priv->hw->conf.flags & IEEE80211_CONF_IDLE)
                iwl_static_sleep_cmd(priv, cmd, IWL_POWER_INDEX_5, 20);
        else if (iwl_tt_is_low_power_state(priv)) {
                /* in thermal throttling low power state */
@@ -367,9 +363,15 @@ static void iwl_power_build_cmd(struct iwl_priv *priv,
                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
+       else if (iwlagn_mod_params.no_sleep_autoadjust) {
+               if (iwlagn_mod_params.power_level > IWL_POWER_INDEX_1 &&
+                   iwlagn_mod_params.power_level <= IWL_POWER_INDEX_5)
+                       iwl_static_sleep_cmd(priv, cmd,
+                               iwlagn_mod_params.power_level, dtimper);
+               else
+                       iwl_static_sleep_cmd(priv, cmd,
+                               IWL_POWER_INDEX_1, dtimper);
+       } else
                iwl_power_fill_sleep_cmd(priv, cmd,
                                         priv->hw->conf.dynamic_ps_timeout,
                                         priv->hw->conf.max_sleep_period);
@@ -408,9 +410,9 @@ int iwl_power_set_mode(struct iwl_priv *priv, struct iwl_powertable_cmd *cmd,
                if (!(cmd->flags & IWL_POWER_DRIVER_ALLOW_SLEEP_MSK))
                        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);
-               else if (priv->cfg->ops->lib->update_chain_flags)
+               if (update_chains)
+                       iwl_update_chain_flags(priv);
+               else
                        IWL_DEBUG_POWER(priv,
                                        "Cannot update the power, chain noise "
                                        "calibration running: %d\n",
@@ -434,9 +436,7 @@ int iwl_power_update_mode(struct iwl_priv *priv, bool force)
 /* initialize to default */
 void iwl_power_initialize(struct iwl_priv *priv)
 {
-       u16 lctl = iwl_pcie_link_ctl(priv);
-
-       priv->power_data.pci_pm = !(lctl & PCI_CFG_LINK_CTRL_VAL_L0S_EN);
+       priv->power_data.bus_pm = bus_get_pm_support(priv->bus);
 
        priv->power_data.debug_sleep_level_override = -1;