Merge branch 'master' of ra.kernel.org:/pub/scm/linux/kernel/git/davem/net
[cascardo/linux.git] / drivers / net / wireless / iwlwifi / iwl-5000.c
index a9adee5..c511c98 100644 (file)
 #include "iwl-dev.h"
 #include "iwl-core.h"
 #include "iwl-io.h"
-#include "iwl-sta.h"
-#include "iwl-helpers.h"
 #include "iwl-agn.h"
 #include "iwl-agn-hw.h"
-#include "iwl-5000-hw.h"
 #include "iwl-trans.h"
+#include "iwl-shared.h"
+#include "iwl-cfg.h"
 
 /* Highest firmware API version supported */
 #define IWL5000_UCODE_API_MAX 5
@@ -68,18 +67,18 @@ static void iwl5000_nic_config(struct iwl_priv *priv)
 
        iwl_rf_config(priv);
 
-       spin_lock_irqsave(&priv->lock, flags);
+       spin_lock_irqsave(&priv->shrd->lock, flags);
 
        /* W/A : NIC is stuck in a reset state after Early PCIe power off
         * (PCIe power is lost before PERST# is asserted),
         * causing ME FW to lose ownership and not being able to obtain it back.
         */
-       iwl_set_bits_mask_prph(priv, APMG_PS_CTRL_REG,
+       iwl_set_bits_mask_prph(bus(priv), APMG_PS_CTRL_REG,
                                APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS,
                                ~APMG_PS_CTRL_EARLY_PWR_OFF_RESET_DIS);
 
 
-       spin_unlock_irqrestore(&priv->lock, flags);
+       spin_unlock_irqrestore(&priv->shrd->lock, flags);
 }
 
 static struct iwl_sensitivity_ranges iwl5000_sensitivity = {
@@ -133,19 +132,34 @@ static struct iwl_sensitivity_ranges iwl5150_sensitivity = {
        .nrg_th_cca = 62,
 };
 
+#define IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF  (-5)
+
+static s32 iwl_temp_calib_to_offset(struct iwl_priv *priv)
+{
+       u16 temperature, voltage;
+       __le16 *temp_calib = (__le16 *)iwl_eeprom_query_addr(priv,
+                               EEPROM_KELVIN_TEMPERATURE);
+
+       temperature = le16_to_cpu(temp_calib[0]);
+       voltage = le16_to_cpu(temp_calib[1]);
+
+       /* offset = temp - volt / coeff */
+       return (s32)(temperature - voltage / IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF);
+}
+
 static void iwl5150_set_ct_threshold(struct iwl_priv *priv)
 {
        const s32 volt2temp_coef = IWL_5150_VOLTAGE_TO_TEMPERATURE_COEFF;
        s32 threshold = (s32)CELSIUS_TO_KELVIN(CT_KILL_THRESHOLD_LEGACY) -
                        iwl_temp_calib_to_offset(priv);
 
-       priv->hw_params.ct_kill_threshold = threshold * volt2temp_coef;
+       hw_params(priv).ct_kill_threshold = threshold * volt2temp_coef;
 }
 
 static void iwl5000_set_ct_threshold(struct iwl_priv *priv)
 {
        /* want Celsius */
-       priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
+       hw_params(priv).ct_kill_threshold = CT_KILL_THRESHOLD_LEGACY;
 }
 
 static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
@@ -155,39 +169,32 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv)
                priv->cfg->base_params->num_of_queues =
                        iwlagn_mod_params.num_of_queues;
 
-       priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues;
-       priv->hw_params.scd_bc_tbls_size =
-                       priv->cfg->base_params->num_of_queues *
-                       sizeof(struct iwlagn_scd_bc_tbl);
-       priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
-       priv->hw_params.max_stations = IWLAGN_STATION_COUNT;
+       hw_params(priv).max_txq_num = priv->cfg->base_params->num_of_queues;
        priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
 
-       priv->hw_params.max_data_size = IWLAGN_RTC_DATA_SIZE;
-       priv->hw_params.max_inst_size = IWLAGN_RTC_INST_SIZE;
+       hw_params(priv).max_data_size = IWLAGN_RTC_DATA_SIZE;
+       hw_params(priv).max_inst_size = IWLAGN_RTC_INST_SIZE;
 
-       priv->hw_params.ht40_channel =  BIT(IEEE80211_BAND_2GHZ) |
+       hw_params(priv).ht40_channel =  BIT(IEEE80211_BAND_2GHZ) |
                                        BIT(IEEE80211_BAND_5GHZ);
 
-       priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
-       priv->hw_params.rx_chains_num = num_of_ant(priv->cfg->valid_rx_ant);
-       priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
-       priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
+       hw_params(priv).tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
+       hw_params(priv).rx_chains_num = num_of_ant(priv->cfg->valid_rx_ant);
+       hw_params(priv).valid_tx_ant = priv->cfg->valid_tx_ant;
+       hw_params(priv).valid_rx_ant = priv->cfg->valid_rx_ant;
 
        iwl5000_set_ct_threshold(priv);
 
        /* Set initial sensitivity parameters */
        /* Set initial calibration set */
-       priv->hw_params.sens = &iwl5000_sensitivity;
-       priv->hw_params.calib_init_cfg =
+       hw_params(priv).sens = &iwl5000_sensitivity;
+       hw_params(priv).calib_init_cfg =
                BIT(IWL_CALIB_XTAL)             |
                BIT(IWL_CALIB_LO)               |
                BIT(IWL_CALIB_TX_IQ)            |
                BIT(IWL_CALIB_TX_IQ_PERD)       |
                BIT(IWL_CALIB_BASE_BAND);
 
-       priv->hw_params.beacon_time_tsf_bits = IWLAGN_EXT_BEACON_TIME_POS;
-
        return 0;
 }
 
@@ -198,38 +205,31 @@ static int iwl5150_hw_set_hw_params(struct iwl_priv *priv)
                priv->cfg->base_params->num_of_queues =
                        iwlagn_mod_params.num_of_queues;
 
-       priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues;
-       priv->hw_params.scd_bc_tbls_size =
-                       priv->cfg->base_params->num_of_queues *
-                       sizeof(struct iwlagn_scd_bc_tbl);
-       priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
-       priv->hw_params.max_stations = IWLAGN_STATION_COUNT;
+       hw_params(priv).max_txq_num = priv->cfg->base_params->num_of_queues;
        priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
 
-       priv->hw_params.max_data_size = IWLAGN_RTC_DATA_SIZE;
-       priv->hw_params.max_inst_size = IWLAGN_RTC_INST_SIZE;
+       hw_params(priv).max_data_size = IWLAGN_RTC_DATA_SIZE;
+       hw_params(priv).max_inst_size = IWLAGN_RTC_INST_SIZE;
 
-       priv->hw_params.ht40_channel =  BIT(IEEE80211_BAND_2GHZ) |
+       hw_params(priv).ht40_channel =  BIT(IEEE80211_BAND_2GHZ) |
                                        BIT(IEEE80211_BAND_5GHZ);
 
-       priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
-       priv->hw_params.rx_chains_num = num_of_ant(priv->cfg->valid_rx_ant);
-       priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
-       priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
+       hw_params(priv).tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
+       hw_params(priv).rx_chains_num = num_of_ant(priv->cfg->valid_rx_ant);
+       hw_params(priv).valid_tx_ant = priv->cfg->valid_tx_ant;
+       hw_params(priv).valid_rx_ant = priv->cfg->valid_rx_ant;
 
        iwl5150_set_ct_threshold(priv);
 
        /* Set initial sensitivity parameters */
        /* Set initial calibration set */
-       priv->hw_params.sens = &iwl5150_sensitivity;
-       priv->hw_params.calib_init_cfg =
+       hw_params(priv).sens = &iwl5150_sensitivity;
+       hw_params(priv).calib_init_cfg =
                BIT(IWL_CALIB_LO)               |
                BIT(IWL_CALIB_TX_IQ)            |
                BIT(IWL_CALIB_BASE_BAND);
        if (priv->cfg->need_dc_calib)
-               priv->hw_params.calib_init_cfg |= BIT(IWL_CALIB_DC);
-
-       priv->hw_params.beacon_time_tsf_bits = IWLAGN_EXT_BEACON_TIME_POS;
+               hw_params(priv).calib_init_cfg |= BIT(IWL_CALIB_DC);
 
        return 0;
 }
@@ -251,7 +251,7 @@ static int iwl5000_hw_channel_switch(struct iwl_priv *priv,
 {
        /*
         * MULTI-FIXME
-        * See iwl_mac_channel_switch.
+        * See iwlagn_mac_channel_switch.
         */
        struct iwl_rxon_context *ctx = &priv->contexts[IWL_RXON_CTX_BSS];
        struct iwl5000_channel_switch_cmd cmd;
@@ -314,7 +314,7 @@ static int iwl5000_hw_channel_switch(struct iwl_priv *priv,
                return -EFAULT;
        }
 
-       return trans_send_cmd(&priv->trans, &hcmd);
+       return iwl_trans_send_cmd(trans(priv), &hcmd);
 }
 
 static struct iwl_lib_ops iwl5000_lib = {
@@ -359,7 +359,6 @@ static struct iwl_base_params iwl5000_base_params = {
        .num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
        .pll_cfg_val = CSR50_ANA_PLL_CFG_VAL,
        .led_compensation = 51,
-       .chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
        .plcp_delta_threshold = IWL_MAX_PLCP_ERR_LONG_THRESHOLD_DEF,
        .chain_noise_scale = 1000,
        .wd_timeout = IWL_LONG_WD_TIMEOUT,