提交 8614f360 编写于 作者: T Tomas Winkler 提交者: John W. Linville

iwlwifi: check eeprom version in pci probe time

This patch move eeprom version checking into pci probe stage
Signed-off-by: NTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: NReinette Chatre <reinette.chatre@intel.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 b661c819
...@@ -494,6 +494,31 @@ int iwl4965_hw_rxq_stop(struct iwl_priv *priv) ...@@ -494,6 +494,31 @@ int iwl4965_hw_rxq_stop(struct iwl_priv *priv)
return 0; return 0;
} }
/*
* EEPROM handlers
*/
static int iwl4965_eeprom_check_version(struct iwl_priv *priv)
{
u16 eeprom_ver;
u16 calib_ver;
eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
calib_ver = iwl_eeprom_query16(priv, EEPROM_4965_CALIB_VERSION_OFFSET);
if (eeprom_ver < EEPROM_4965_EEPROM_VERSION ||
calib_ver < EEPROM_4965_TX_POWER_VERSION)
goto err;
return 0;
err:
IWL_ERROR("Unsuported EEPROM VER=0x%x < 0x%x CALIB=0x%x < 0x%x\n",
eeprom_ver, EEPROM_4965_EEPROM_VERSION,
calib_ver, EEPROM_4965_TX_POWER_VERSION);
return -EINVAL;
}
int iwl4965_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src) int iwl4965_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src)
{ {
int ret; int ret;
...@@ -763,12 +788,6 @@ int iwl4965_hw_nic_init(struct iwl_priv *priv) ...@@ -763,12 +788,6 @@ int iwl4965_hw_nic_init(struct iwl_priv *priv)
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
if (iwl_eeprom_query16(priv, EEPROM_4965_CALIB_VERSION_OFFSET) <
EEPROM_4965_TX_POWER_VERSION) {
IWL_ERROR("Older EEPROM detected! Aborting.\n");
return -EINVAL;
}
pci_read_config_byte(priv->pci_dev, PCI_LINK_CTRL, &val_link); pci_read_config_byte(priv->pci_dev, PCI_LINK_CTRL, &val_link);
/* disable L1 entry -- workaround for pre-B1 */ /* disable L1 entry -- workaround for pre-B1 */
...@@ -4354,6 +4373,7 @@ static struct iwl_lib_ops iwl4965_lib = { ...@@ -4354,6 +4373,7 @@ static struct iwl_lib_ops iwl4965_lib = {
.verify_signature = iwlcore_eeprom_verify_signature, .verify_signature = iwlcore_eeprom_verify_signature,
.acquire_semaphore = iwlcore_eeprom_acquire_semaphore, .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
.release_semaphore = iwlcore_eeprom_release_semaphore, .release_semaphore = iwlcore_eeprom_release_semaphore,
.check_version = iwl4965_eeprom_check_version,
.query_addr = iwlcore_eeprom_query_addr, .query_addr = iwlcore_eeprom_query_addr,
}, },
.radio_kill_sw = iwl4965_radio_kill_sw, .radio_kill_sw = iwl4965_radio_kill_sw,
......
...@@ -279,6 +279,11 @@ void iwl_eeprom_free(struct iwl_priv *priv) ...@@ -279,6 +279,11 @@ void iwl_eeprom_free(struct iwl_priv *priv)
} }
EXPORT_SYMBOL(iwl_eeprom_free); EXPORT_SYMBOL(iwl_eeprom_free);
int iwl_eeprom_check_version(struct iwl_priv *priv)
{
return priv->cfg->ops->lib->eeprom_ops.check_version(priv);
}
EXPORT_SYMBOL(iwl_eeprom_check_version);
const u8 *iwl_eeprom_query_addr(const struct iwl_priv *priv, size_t offset) const u8 *iwl_eeprom_query_addr(const struct iwl_priv *priv, size_t offset)
{ {
...@@ -423,12 +428,6 @@ int iwl_init_channel_map(struct iwl_priv *priv) ...@@ -423,12 +428,6 @@ int iwl_init_channel_map(struct iwl_priv *priv)
return 0; return 0;
} }
if (iwl_eeprom_query16(priv, EEPROM_VERSION) < 0x2f) {
IWL_WARNING("Unsupported EEPROM version: 0x%04X\n",
iwl_eeprom_query16(priv, EEPROM_VERSION));
return -EINVAL;
}
IWL_DEBUG_INFO("Initializing regulatory info from EEPROM\n"); IWL_DEBUG_INFO("Initializing regulatory info from EEPROM\n");
priv->channel_count = priv->channel_count =
......
...@@ -134,6 +134,7 @@ struct iwl_eeprom_channel { ...@@ -134,6 +134,7 @@ struct iwl_eeprom_channel {
/* 4965 Specific */ /* 4965 Specific */
/* 4965 driver does not work with txpower calibration version < 5 */ /* 4965 driver does not work with txpower calibration version < 5 */
#define EEPROM_4965_TX_POWER_VERSION (5) #define EEPROM_4965_TX_POWER_VERSION (5)
#define EEPROM_4965_EEPROM_VERSION (0x2f)
#define EEPROM_4965_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */ #define EEPROM_4965_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */
#define EEPROM_4965_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */ #define EEPROM_4965_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */
#define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */ #define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */
...@@ -322,6 +323,7 @@ struct iwl_eeprom_ops { ...@@ -322,6 +323,7 @@ struct iwl_eeprom_ops {
int (*verify_signature) (struct iwl_priv *priv); int (*verify_signature) (struct iwl_priv *priv);
int (*acquire_semaphore) (struct iwl_priv *priv); int (*acquire_semaphore) (struct iwl_priv *priv);
void (*release_semaphore) (struct iwl_priv *priv); void (*release_semaphore) (struct iwl_priv *priv);
int (*check_version) (struct iwl_priv *priv);
const u8* (*query_addr) (const struct iwl_priv *priv, size_t offset); const u8* (*query_addr) (const struct iwl_priv *priv, size_t offset);
}; };
...@@ -329,6 +331,7 @@ struct iwl_eeprom_ops { ...@@ -329,6 +331,7 @@ struct iwl_eeprom_ops {
void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac); void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac);
int iwl_eeprom_init(struct iwl_priv *priv); int iwl_eeprom_init(struct iwl_priv *priv);
void iwl_eeprom_free(struct iwl_priv *priv); void iwl_eeprom_free(struct iwl_priv *priv);
int iwl_eeprom_check_version(struct iwl_priv *priv);
const u8 *iwl_eeprom_query_addr(const struct iwl_priv *priv, size_t offset); const u8 *iwl_eeprom_query_addr(const struct iwl_priv *priv, size_t offset);
u16 iwl_eeprom_query16(const struct iwl_priv *priv, size_t offset); u16 iwl_eeprom_query16(const struct iwl_priv *priv, size_t offset);
......
...@@ -7479,6 +7479,10 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e ...@@ -7479,6 +7479,10 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
IWL_ERROR("Unable to init EEPROM\n"); IWL_ERROR("Unable to init EEPROM\n");
goto out_iounmap; goto out_iounmap;
} }
err = iwl_eeprom_check_version(priv);
if (err)
goto out_iounmap;
/* MAC Address location in EEPROM same for 3945/4965 */ /* MAC Address location in EEPROM same for 3945/4965 */
iwl_eeprom_get_mac(priv, priv->mac_addr); iwl_eeprom_get_mac(priv, priv->mac_addr);
IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr)); IWL_DEBUG_INFO("MAC address: %s\n", print_mac(mac, priv->mac_addr));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册