Skip to content

Commit

Permalink
iwlwifi: Change define and struct names in iwl-eeprom-parse.h
Browse files Browse the repository at this point in the history
Since we will have several forms of NVM (EEPROM, OTP, etc.)
and they will have different layouts, make the parsed data
more generic. This allows functional code to be independent
of a specific layout.

Also change some variables and function names from having
"eeprom" to "nvm" in their name.

Signed-off-by: Eytan Lifshitz <eytan.lifshitz@intel.com>
Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Eytan Lifshitz authored and Johannes Berg committed Dec 6, 2012
1 parent 59f547a commit b7998c8
Show file tree
Hide file tree
Showing 20 changed files with 214 additions and 186 deletions.
14 changes: 7 additions & 7 deletions drivers/net/wireless/iwlwifi/dvm/calib.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,14 +833,14 @@ static void iwl_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig,
* To be safe, simply mask out any chains that we know
* are not on the device.
*/
active_chains &= priv->eeprom_data->valid_rx_ant;
active_chains &= priv->nvm_data->valid_rx_ant;

num_tx_chains = 0;
for (i = 0; i < NUM_RX_CHAINS; i++) {
/* loops on all the bits of
* priv->hw_setting.valid_tx_ant */
u8 ant_msk = (1 << i);
if (!(priv->eeprom_data->valid_tx_ant & ant_msk))
if (!(priv->nvm_data->valid_tx_ant & ant_msk))
continue;

num_tx_chains++;
Expand All @@ -854,7 +854,7 @@ static void iwl_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig,
* connect the first valid tx chain
*/
first_chain =
find_first_chain(priv->eeprom_data->valid_tx_ant);
find_first_chain(priv->nvm_data->valid_tx_ant);
data->disconn_array[first_chain] = 0;
active_chains |= BIT(first_chain);
IWL_DEBUG_CALIB(priv,
Expand All @@ -864,13 +864,13 @@ static void iwl_find_disconn_antenna(struct iwl_priv *priv, u32* average_sig,
}
}

if (active_chains != priv->eeprom_data->valid_rx_ant &&
if (active_chains != priv->nvm_data->valid_rx_ant &&
active_chains != priv->chain_noise_data.active_chains)
IWL_DEBUG_CALIB(priv,
"Detected that not all antennas are connected! "
"Connected: %#x, valid: %#x.\n",
active_chains,
priv->eeprom_data->valid_rx_ant);
priv->nvm_data->valid_rx_ant);

/* Save for use within RXON, TX, SCAN commands, etc. */
data->active_chains = active_chains;
Expand Down Expand Up @@ -1055,7 +1055,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv)
priv->cfg->bt_params->advanced_bt_coexist) {
/* Disable disconnected antenna algorithm for advanced
bt coex, assuming valid antennas are connected */
data->active_chains = priv->eeprom_data->valid_rx_ant;
data->active_chains = priv->nvm_data->valid_rx_ant;
for (i = 0; i < NUM_RX_CHAINS; i++)
if (!(data->active_chains & (1<<i)))
data->disconn_array[i] = 1;
Expand Down Expand Up @@ -1086,7 +1086,7 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv)

iwlagn_gain_computation(
priv, average_noise,
find_first_chain(priv->eeprom_data->valid_rx_ant));
find_first_chain(priv->nvm_data->valid_rx_ant));

/* Some power changes may have been made during the calibration.
* Update and commit the RXON
Expand Down
12 changes: 6 additions & 6 deletions drivers/net/wireless/iwlwifi/dvm/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ static ssize_t iwl_dbgfs_nvm_read(struct file *file,
int pos = 0, ofs = 0, buf_size = 0;
const u8 *ptr;
char *buf;
u16 eeprom_ver;
u16 nvm_ver;
size_t eeprom_len = priv->eeprom_blob_size;
buf_size = 4 * eeprom_len + 256;

Expand All @@ -321,9 +321,9 @@ static ssize_t iwl_dbgfs_nvm_read(struct file *file,
if (!buf)
return -ENOMEM;

eeprom_ver = priv->eeprom_data->eeprom_version;
nvm_ver = priv->nvm_data->nvm_version;
pos += scnprintf(buf + pos, buf_size - pos,
"NVM version: 0x%x\n", eeprom_ver);
"NVM version: 0x%x\n", nvm_ver);
for (ofs = 0 ; ofs < eeprom_len ; ofs += 16) {
pos += scnprintf(buf + pos, buf_size - pos, "0x%.4x ", ofs);
hex_dump_to_buffer(ptr + ofs, 16 , 16, 2, buf + pos,
Expand Down Expand Up @@ -1333,17 +1333,17 @@ 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) {
pos += scnprintf(buf + pos, bufsz - pos,
"tx power: (1/2 dB step)\n");
if ((priv->eeprom_data->valid_tx_ant & ANT_A) &&
if ((priv->nvm_data->valid_tx_ant & ANT_A) &&
tx->tx_power.ant_a)
pos += scnprintf(buf + pos, bufsz - pos,
fmt_hex, "antenna A:",
tx->tx_power.ant_a);
if ((priv->eeprom_data->valid_tx_ant & ANT_B) &&
if ((priv->nvm_data->valid_tx_ant & ANT_B) &&
tx->tx_power.ant_b)
pos += scnprintf(buf + pos, bufsz - pos,
fmt_hex, "antenna B:",
tx->tx_power.ant_b);
if ((priv->eeprom_data->valid_tx_ant & ANT_C) &&
if ((priv->nvm_data->valid_tx_ant & ANT_C) &&
tx->tx_power.ant_c)
pos += scnprintf(buf + pos, bufsz - pos,
fmt_hex, "antenna C:",
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/iwlwifi/dvm/dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ struct iwl_priv {
void *wowlan_sram;
#endif /* CONFIG_IWLWIFI_DEBUGFS */

struct iwl_eeprom_data *eeprom_data;
struct iwl_nvm_data *nvm_data;
/* eeprom blob for debugfs/testmode */
u8 *eeprom_blob;
size_t eeprom_blob_size;
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/wireless/iwlwifi/dvm/devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ static s32 iwl_temp_calib_to_offset(struct iwl_priv *priv)
{
u16 temperature, voltage;

temperature = le16_to_cpu(priv->eeprom_data->kelvin_temperature);
voltage = le16_to_cpu(priv->eeprom_data->kelvin_voltage);
temperature = le16_to_cpu(priv->nvm_data->kelvin_temperature);
voltage = le16_to_cpu(priv->nvm_data->kelvin_voltage);

/* offset = temp - volt / coeff */
return (s32)(temperature -
Expand Down Expand Up @@ -460,13 +460,13 @@ static void iwl6000_nic_config(struct iwl_priv *priv)
break;
case IWL_DEVICE_FAMILY_6050:
/* Indicate calibration version to uCode. */
if (priv->eeprom_data->calib_version >= 6)
if (priv->nvm_data->calib_version >= 6)
iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
break;
case IWL_DEVICE_FAMILY_6150:
/* Indicate calibration version to uCode. */
if (priv->eeprom_data->calib_version >= 6)
if (priv->nvm_data->calib_version >= 6)
iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
CSR_GP_DRIVER_REG_BIT_CALIB_VERSION6);
iwl_set_bit(priv->trans, CSR_GP_DRIVER_REG,
Expand Down
8 changes: 4 additions & 4 deletions drivers/net/wireless/iwlwifi/dvm/lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int iwlagn_send_tx_power(struct iwl_priv *priv)
/* half dBm need to multiply */
tx_power_cmd.global_lmt = (s8)(2 * priv->tx_power_user_lmt);

if (tx_power_cmd.global_lmt > priv->eeprom_data->max_tx_pwr_half_dbm) {
if (tx_power_cmd.global_lmt > priv->nvm_data->max_tx_pwr_half_dbm) {
/*
* For the newer devices which using enhanced/extend tx power
* table in EEPROM, the format is in half dBm. driver need to
Expand All @@ -72,7 +72,7 @@ int iwlagn_send_tx_power(struct iwl_priv *priv)
* half-dBm format), lower the tx power based on EEPROM
*/
tx_power_cmd.global_lmt =
priv->eeprom_data->max_tx_pwr_half_dbm;
priv->nvm_data->max_tx_pwr_half_dbm;
}
tx_power_cmd.flags = IWLAGN_TX_POWER_NO_CLOSED;
tx_power_cmd.srv_chan_lmt = IWLAGN_TX_POWER_AUTO;
Expand Down Expand Up @@ -159,7 +159,7 @@ int iwlagn_txfifo_flush(struct iwl_priv *priv)
IWL_PAN_SCD_MGMT_MSK |
IWL_PAN_SCD_MULTICAST_MSK;

if (priv->eeprom_data->sku & EEPROM_SKU_CAP_11N_ENABLE)
if (priv->nvm_data->sku_cap_11n_enable)
flush_cmd.queue_control |= IWL_AGG_TX_QUEUE_MSK;

IWL_DEBUG_INFO(priv, "queue control: 0x%x\n",
Expand Down Expand Up @@ -825,7 +825,7 @@ void iwlagn_set_rxon_chain(struct iwl_priv *priv, struct iwl_rxon_context *ctx)
if (priv->chain_noise_data.active_chains)
active_chains = priv->chain_noise_data.active_chains;
else
active_chains = priv->eeprom_data->valid_rx_ant;
active_chains = priv->nvm_data->valid_rx_ant;

if (priv->cfg->bt_params &&
priv->cfg->bt_params->advanced_bt_coexist &&
Expand Down
12 changes: 6 additions & 6 deletions drivers/net/wireless/iwlwifi/dvm/mac80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv,
hw->max_tx_aggregation_subframes = LINK_QUAL_AGG_FRAME_LIMIT_DEF;
*/

if (priv->eeprom_data->sku & EEPROM_SKU_CAP_11N_ENABLE)
if (priv->nvm_data->sku_cap_11n_enable)
hw->flags |= IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS |
IEEE80211_HW_SUPPORTS_STATIC_SMPS;

Expand Down Expand Up @@ -242,12 +242,12 @@ int iwlagn_mac_setup_register(struct iwl_priv *priv,

hw->max_listen_interval = IWL_CONN_MAX_LISTEN_INTERVAL;

if (priv->eeprom_data->bands[IEEE80211_BAND_2GHZ].n_channels)
if (priv->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels)
priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] =
&priv->eeprom_data->bands[IEEE80211_BAND_2GHZ];
if (priv->eeprom_data->bands[IEEE80211_BAND_5GHZ].n_channels)
&priv->nvm_data->bands[IEEE80211_BAND_2GHZ];
if (priv->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels)
priv->hw->wiphy->bands[IEEE80211_BAND_5GHZ] =
&priv->eeprom_data->bands[IEEE80211_BAND_5GHZ];
&priv->nvm_data->bands[IEEE80211_BAND_5GHZ];

hw->wiphy->hw_version = priv->trans->hw_id;

Expand Down Expand Up @@ -654,7 +654,7 @@ static int iwlagn_mac_ampdu_action(struct ieee80211_hw *hw,
IWL_DEBUG_HT(priv, "A-MPDU action on addr %pM tid %d\n",
sta->addr, tid);

if (!(priv->eeprom_data->sku & EEPROM_SKU_CAP_11N_ENABLE))
if (!(priv->nvm_data->sku_cap_11n_enable))
return -EACCES;

IWL_DEBUG_MAC80211(priv, "enter\n");
Expand Down
57 changes: 32 additions & 25 deletions drivers/net/wireless/iwlwifi/dvm/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ int iwlagn_send_beacon_cmd(struct iwl_priv *priv)
rate = info->control.rates[0].idx;

priv->mgmt_tx_ant = iwl_toggle_tx_ant(priv, priv->mgmt_tx_ant,
priv->eeprom_data->valid_tx_ant);
priv->nvm_data->valid_tx_ant);
rate_flags = iwl_ant_idx_to_flags(priv->mgmt_tx_ant);

/* In mac80211, rates for 5 GHz start at 0 */
Expand Down Expand Up @@ -776,7 +776,7 @@ int iwl_alive_start(struct iwl_priv *priv)
ieee80211_wake_queues(priv->hw);

/* Configure Tx antenna selection based on H/W config */
iwlagn_send_tx_ant_config(priv, priv->eeprom_data->valid_tx_ant);
iwlagn_send_tx_ant_config(priv, priv->nvm_data->valid_tx_ant);

if (iwl_is_associated_ctx(ctx) && !priv->wowlan) {
struct iwl_rxon_cmd *active_rxon =
Expand Down Expand Up @@ -1191,30 +1191,38 @@ static void iwl_option_config(struct iwl_priv *priv)

static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
{
if (priv->eeprom_data->sku & EEPROM_SKU_CAP_11N_ENABLE &&
struct iwl_nvm_data *data = priv->nvm_data;
char *debug_msg;

if (data->sku_cap_11n_enable &&
!priv->cfg->ht_params) {
IWL_ERR(priv, "Invalid 11n configuration\n");
return -EINVAL;
}

if (!priv->eeprom_data->sku) {
if (!data->sku_cap_11n_enable && !data->sku_cap_band_24GHz_enable &&
!data->sku_cap_band_52GHz_enable) {
IWL_ERR(priv, "Invalid device sku\n");
return -EINVAL;
}

IWL_DEBUG_INFO(priv, "Device SKU: 0x%X\n", priv->eeprom_data->sku);
debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
IWL_DEBUG_INFO(priv, debug_msg,
data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
data->sku_cap_11n_enable ? "" : "NOT", "enabled");

priv->hw_params.tx_chains_num =
num_of_ant(priv->eeprom_data->valid_tx_ant);
num_of_ant(data->valid_tx_ant);
if (priv->cfg->rx_with_siso_diversity)
priv->hw_params.rx_chains_num = 1;
else
priv->hw_params.rx_chains_num =
num_of_ant(priv->eeprom_data->valid_rx_ant);
num_of_ant(data->valid_rx_ant);

IWL_DEBUG_INFO(priv, "Valid Tx ant: 0x%X, Valid Rx ant: 0x%X\n",
priv->eeprom_data->valid_tx_ant,
priv->eeprom_data->valid_rx_ant);
data->valid_tx_ant,
data->valid_rx_ant);

return 0;
}
Expand Down Expand Up @@ -1374,24 +1382,24 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,
/* Reset chip to save power until we load uCode during "up". */
iwl_trans_stop_hw(priv->trans, false);

priv->eeprom_data = iwl_parse_eeprom_data(priv->trans->dev, priv->cfg,
priv->nvm_data = iwl_parse_eeprom_data(priv->trans->dev, priv->cfg,
priv->eeprom_blob,
priv->eeprom_blob_size);
if (!priv->eeprom_data)
if (!priv->nvm_data)
goto out_free_eeprom_blob;

if (iwl_eeprom_check_version(priv->eeprom_data, priv->trans))
if (iwl_nvm_check_version(priv->nvm_data, priv->trans))
goto out_free_eeprom;

if (iwl_eeprom_init_hw_params(priv))
goto out_free_eeprom;

/* extract MAC Address */
memcpy(priv->addresses[0].addr, priv->eeprom_data->hw_addr, ETH_ALEN);
memcpy(priv->addresses[0].addr, priv->nvm_data->hw_addr, ETH_ALEN);
IWL_DEBUG_INFO(priv, "MAC address: %pM\n", priv->addresses[0].addr);
priv->hw->wiphy->addresses = priv->addresses;
priv->hw->wiphy->n_addresses = 1;
num_mac = priv->eeprom_data->n_hw_addrs;
num_mac = priv->nvm_data->n_hw_addrs;
if (num_mac > 1) {
memcpy(priv->addresses[1].addr, priv->addresses[0].addr,
ETH_ALEN);
Expand All @@ -1404,7 +1412,7 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,
************************/
iwl_set_hw_params(priv);

if (!(priv->eeprom_data->sku & EEPROM_SKU_CAP_IPAN_ENABLE)) {
if (!(priv->nvm_data->sku_cap_ipan_enable)) {
IWL_DEBUG_INFO(priv, "Your EEPROM disabled PAN");
ucode_flags &= ~IWL_UCODE_TLV_FLAGS_PAN;
/*
Expand Down Expand Up @@ -1486,7 +1494,7 @@ static struct iwl_op_mode *iwl_op_mode_dvm_start(struct iwl_trans *trans,
out_free_eeprom_blob:
kfree(priv->eeprom_blob);
out_free_eeprom:
iwl_free_eeprom_data(priv->eeprom_data);
iwl_free_nvm_data(priv->nvm_data);
out_free_hw:
ieee80211_free_hw(priv->hw);
out:
Expand All @@ -1506,7 +1514,7 @@ static void iwl_op_mode_dvm_stop(struct iwl_op_mode *op_mode)
iwl_tt_exit(priv);

kfree(priv->eeprom_blob);
iwl_free_eeprom_data(priv->eeprom_data);
iwl_free_nvm_data(priv->nvm_data);

/*netif_stop_queue(dev); */
flush_workqueue(priv->workqueue);
Expand Down Expand Up @@ -1980,7 +1988,6 @@ static void iwl_cmd_queue_full(struct iwl_op_mode *op_mode)
static void iwl_nic_config(struct iwl_op_mode *op_mode)
{
struct iwl_priv *priv = IWL_OP_MODE_GET_DVM(op_mode);
u16 radio_cfg = priv->eeprom_data->radio_cfg;

/* SKU Control */
iwl_set_bits_mask(priv->trans, CSR_HW_IF_CONFIG_REG,
Expand All @@ -1992,13 +1999,13 @@ static void iwl_nic_config(struct iwl_op_mode *op_mode)
CSR_HW_IF_CONFIG_REG_POS_MAC_DASH));

/* write radio config values to register */
if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) <= EEPROM_RF_CONFIG_TYPE_MAX) {
if (priv->nvm_data->radio_cfg_type <= EEPROM_RF_CONFIG_TYPE_MAX) {
u32 reg_val =
EEPROM_RF_CFG_TYPE_MSK(radio_cfg) <<
priv->nvm_data->radio_cfg_type <<
CSR_HW_IF_CONFIG_REG_POS_PHY_TYPE |
EEPROM_RF_CFG_STEP_MSK(radio_cfg) <<
priv->nvm_data->radio_cfg_step <<
CSR_HW_IF_CONFIG_REG_POS_PHY_STEP |
EEPROM_RF_CFG_DASH_MSK(radio_cfg) <<
priv->nvm_data->radio_cfg_dash <<
CSR_HW_IF_CONFIG_REG_POS_PHY_DASH;

iwl_set_bits_mask(priv->trans, CSR_HW_IF_CONFIG_REG,
Expand All @@ -2007,9 +2014,9 @@ static void iwl_nic_config(struct iwl_op_mode *op_mode)
CSR_HW_IF_CONFIG_REG_MSK_PHY_DASH, reg_val);

IWL_INFO(priv, "Radio type=0x%x-0x%x-0x%x\n",
EEPROM_RF_CFG_TYPE_MSK(radio_cfg),
EEPROM_RF_CFG_STEP_MSK(radio_cfg),
EEPROM_RF_CFG_DASH_MSK(radio_cfg));
priv->nvm_data->radio_cfg_type,
priv->nvm_data->radio_cfg_step,
priv->nvm_data->radio_cfg_dash);
} else {
WARN_ON(1);
}
Expand Down
Loading

0 comments on commit b7998c8

Please sign in to comment.