Commit 7e79a393 authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville

iwlwifi: use valid TX/RX antenna from hw_params

It's not really a good idea to write to the
global static configuration. Use the valid
TX/RX antenna information only from the HW
params struct except in the case where the
values from the config are used to override
the values from the EEPROM.
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarWey-Yi Guy <wey-yi.w.guy@intel.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 54708d8d
...@@ -131,14 +131,13 @@ static void iwl1000_hw_set_hw_params(struct iwl_priv *priv) ...@@ -131,14 +131,13 @@ static void iwl1000_hw_set_hw_params(struct iwl_priv *priv)
hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ); hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ);
hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant); hw_params(priv).tx_chains_num =
num_of_ant(hw_params(priv).valid_tx_ant);
if (cfg(priv)->rx_with_siso_diversity) if (cfg(priv)->rx_with_siso_diversity)
hw_params(priv).rx_chains_num = 1; hw_params(priv).rx_chains_num = 1;
else else
hw_params(priv).rx_chains_num = hw_params(priv).rx_chains_num =
num_of_ant(cfg(priv)->valid_rx_ant); num_of_ant(hw_params(priv).valid_rx_ant);
hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
iwl1000_set_ct_threshold(priv); iwl1000_set_ct_threshold(priv);
......
...@@ -127,14 +127,13 @@ static void iwl2000_hw_set_hw_params(struct iwl_priv *priv) ...@@ -127,14 +127,13 @@ static void iwl2000_hw_set_hw_params(struct iwl_priv *priv)
hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ); hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ);
hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant); hw_params(priv).tx_chains_num =
num_of_ant(hw_params(priv).valid_tx_ant);
if (cfg(priv)->rx_with_siso_diversity) if (cfg(priv)->rx_with_siso_diversity)
hw_params(priv).rx_chains_num = 1; hw_params(priv).rx_chains_num = 1;
else else
hw_params(priv).rx_chains_num = hw_params(priv).rx_chains_num =
num_of_ant(cfg(priv)->valid_rx_ant); num_of_ant(hw_params(priv).valid_rx_ant);
hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
iwl2000_set_ct_threshold(priv); iwl2000_set_ct_threshold(priv);
......
...@@ -167,10 +167,10 @@ static void iwl5000_hw_set_hw_params(struct iwl_priv *priv) ...@@ -167,10 +167,10 @@ static void iwl5000_hw_set_hw_params(struct iwl_priv *priv)
hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) | hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) |
BIT(IEEE80211_BAND_5GHZ); BIT(IEEE80211_BAND_5GHZ);
hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant); hw_params(priv).tx_chains_num =
hw_params(priv).rx_chains_num = num_of_ant(cfg(priv)->valid_rx_ant); num_of_ant(hw_params(priv).valid_tx_ant);
hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant; hw_params(priv).rx_chains_num =
hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant; num_of_ant(hw_params(priv).valid_rx_ant);
iwl5000_set_ct_threshold(priv); iwl5000_set_ct_threshold(priv);
...@@ -190,10 +190,10 @@ static void iwl5150_hw_set_hw_params(struct iwl_priv *priv) ...@@ -190,10 +190,10 @@ static void iwl5150_hw_set_hw_params(struct iwl_priv *priv)
hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) | hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) |
BIT(IEEE80211_BAND_5GHZ); BIT(IEEE80211_BAND_5GHZ);
hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant); hw_params(priv).tx_chains_num =
hw_params(priv).rx_chains_num = num_of_ant(cfg(priv)->valid_rx_ant); num_of_ant(hw_params(priv).valid_tx_ant);
hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant; hw_params(priv).rx_chains_num =
hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant; num_of_ant(hw_params(priv).valid_rx_ant);
iwl5150_set_ct_threshold(priv); iwl5150_set_ct_threshold(priv);
......
...@@ -149,14 +149,13 @@ static void iwl6000_hw_set_hw_params(struct iwl_priv *priv) ...@@ -149,14 +149,13 @@ static void iwl6000_hw_set_hw_params(struct iwl_priv *priv)
hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) | hw_params(priv).ht40_channel = BIT(IEEE80211_BAND_2GHZ) |
BIT(IEEE80211_BAND_5GHZ); BIT(IEEE80211_BAND_5GHZ);
hw_params(priv).tx_chains_num = num_of_ant(cfg(priv)->valid_tx_ant); hw_params(priv).tx_chains_num =
num_of_ant(hw_params(priv).valid_tx_ant);
if (cfg(priv)->rx_with_siso_diversity) if (cfg(priv)->rx_with_siso_diversity)
hw_params(priv).rx_chains_num = 1; hw_params(priv).rx_chains_num = 1;
else else
hw_params(priv).rx_chains_num = hw_params(priv).rx_chains_num =
num_of_ant(cfg(priv)->valid_rx_ant); num_of_ant(hw_params(priv).valid_rx_ant);
hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
iwl6000_set_ct_threshold(priv); iwl6000_set_ct_threshold(priv);
......
...@@ -848,7 +848,7 @@ static void iwl_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig, ...@@ -848,7 +848,7 @@ static void iwl_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig,
* connect the first valid tx chain * connect the first valid tx chain
*/ */
first_chain = first_chain =
find_first_chain(cfg(priv)->valid_tx_ant); find_first_chain(hw_params(priv).valid_tx_ant);
data->disconn_array[first_chain] = 0; data->disconn_array[first_chain] = 0;
active_chains |= BIT(first_chain); active_chains |= BIT(first_chain);
IWL_DEBUG_CALIB(priv, IWL_DEBUG_CALIB(priv,
...@@ -1082,7 +1082,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv) ...@@ -1082,7 +1082,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv)
iwlagn_gain_computation(priv, average_noise, iwlagn_gain_computation(priv, average_noise,
min_average_noise_antenna_i, min_average_noise, min_average_noise_antenna_i, min_average_noise,
find_first_chain(cfg(priv)->valid_rx_ant)); find_first_chain(hw_params(priv).valid_rx_ant));
/* Some power changes may have been made during the calibration. /* Some power changes may have been made during the calibration.
* Update and commit the RXON * Update and commit the RXON
......
...@@ -699,7 +699,7 @@ int iwl_alive_start(struct iwl_priv *priv) ...@@ -699,7 +699,7 @@ int iwl_alive_start(struct iwl_priv *priv)
priv->active_rate = IWL_RATES_MASK; priv->active_rate = IWL_RATES_MASK;
/* Configure Tx antenna selection based on H/W config */ /* Configure Tx antenna selection based on H/W config */
iwlagn_send_tx_ant_config(priv, cfg(priv)->valid_tx_ant); iwlagn_send_tx_ant_config(priv, hw_params(priv).valid_tx_ant);
if (iwl_is_associated_ctx(ctx) && !priv->shrd->wowlan) { if (iwl_is_associated_ctx(ctx) && !priv->shrd->wowlan) {
struct iwl_rxon_cmd *active_rxon = struct iwl_rxon_cmd *active_rxon =
......
...@@ -1546,15 +1546,18 @@ static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file, ...@@ -1546,15 +1546,18 @@ static ssize_t iwl_dbgfs_ucode_tx_stats_read(struct file *file,
if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) { if (tx->tx_power.ant_a || tx->tx_power.ant_b || tx->tx_power.ant_c) {
pos += scnprintf(buf + pos, bufsz - pos, pos += scnprintf(buf + pos, bufsz - pos,
"tx power: (1/2 dB step)\n"); "tx power: (1/2 dB step)\n");
if ((cfg(priv)->valid_tx_ant & ANT_A) && tx->tx_power.ant_a) if ((hw_params(priv).valid_tx_ant & ANT_A) &&
tx->tx_power.ant_a)
pos += scnprintf(buf + pos, bufsz - pos, pos += scnprintf(buf + pos, bufsz - pos,
fmt_hex, "antenna A:", fmt_hex, "antenna A:",
tx->tx_power.ant_a); tx->tx_power.ant_a);
if ((cfg(priv)->valid_tx_ant & ANT_B) && tx->tx_power.ant_b) if ((hw_params(priv).valid_tx_ant & ANT_B) &&
tx->tx_power.ant_b)
pos += scnprintf(buf + pos, bufsz - pos, pos += scnprintf(buf + pos, bufsz - pos,
fmt_hex, "antenna B:", fmt_hex, "antenna B:",
tx->tx_power.ant_b); tx->tx_power.ant_b);
if ((cfg(priv)->valid_tx_ant & ANT_C) && tx->tx_power.ant_c) if ((hw_params(priv).valid_tx_ant & ANT_C) &&
tx->tx_power.ant_c)
pos += scnprintf(buf + pos, bufsz - pos, pos += scnprintf(buf + pos, bufsz - pos,
fmt_hex, "antenna C:", fmt_hex, "antenna C:",
tx->tx_power.ant_c); tx->tx_power.ant_c);
......
...@@ -271,25 +271,27 @@ int iwl_eeprom_init_hw_params(struct iwl_priv *priv) ...@@ -271,25 +271,27 @@ int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
IWL_INFO(priv, "Device SKU: 0x%X\n", hw_params(priv).sku); IWL_INFO(priv, "Device SKU: 0x%X\n", hw_params(priv).sku);
if (!cfg(priv)->valid_tx_ant && !cfg(priv)->valid_rx_ant) { radio_cfg = iwl_eeprom_query16(shrd, EEPROM_RADIO_CONFIG);
/* not using .cfg overwrite */
radio_cfg = iwl_eeprom_query16(shrd, EEPROM_RADIO_CONFIG); hw_params(priv).valid_tx_ant = EEPROM_RF_CFG_TX_ANT_MSK(radio_cfg);
cfg(priv)->valid_tx_ant = EEPROM_RF_CFG_TX_ANT_MSK(radio_cfg); hw_params(priv).valid_rx_ant = EEPROM_RF_CFG_RX_ANT_MSK(radio_cfg);
cfg(priv)->valid_rx_ant = EEPROM_RF_CFG_RX_ANT_MSK(radio_cfg);
if (!cfg(priv)->valid_tx_ant || !cfg(priv)->valid_rx_ant) { /* check overrides (some devices have wrong EEPROM) */
IWL_ERR(priv, "Invalid chain (0x%X, 0x%X)\n", if (cfg(priv)->valid_tx_ant)
cfg(priv)->valid_tx_ant, hw_params(priv).valid_tx_ant = cfg(priv)->valid_tx_ant;
cfg(priv)->valid_rx_ant); if (cfg(priv)->valid_rx_ant)
return -EINVAL; hw_params(priv).valid_rx_ant = cfg(priv)->valid_rx_ant;
}
IWL_INFO(priv, "Valid Tx ant: 0x%X, Valid Rx ant: 0x%X\n", if (!hw_params(priv).valid_tx_ant || !hw_params(priv).valid_rx_ant) {
cfg(priv)->valid_tx_ant, cfg(priv)->valid_rx_ant); IWL_ERR(priv, "Invalid chain (0x%X, 0x%X)\n",
hw_params(priv).valid_tx_ant,
hw_params(priv).valid_rx_ant);
return -EINVAL;
} }
/*
* for some special cases, IWL_INFO(priv, "Valid Tx ant: 0x%X, Valid Rx ant: 0x%X\n",
* EEPROM did not reflect the correct antenna setting hw_params(priv).valid_tx_ant, hw_params(priv).valid_rx_ant);
* so overwrite the valid tx/rx antenna from .cfg
*/
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment