iwlwifi: parametrize eeprom versions
authorTomas Winkler <tomas.winkler@intel.com>
Fri, 24 Oct 2008 06:48:51 +0000 (23:48 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 31 Oct 2008 23:02:24 +0000 (19:02 -0400)
This patch uses new parameters eeprom_ver and eeprom_calib_ver
to support additional HW.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/iwlwifi/iwl-4965.c
drivers/net/wireless/iwlwifi/iwl-5000.c
drivers/net/wireless/iwlwifi/iwl-core.h
drivers/net/wireless/iwlwifi/iwl-eeprom.c
drivers/net/wireless/iwlwifi/iwl-eeprom.h

index 741b425b5883a038a71365050cf7f4e47b51e11f..f53cd2b096dfcffe3fb69611bf4ac9aa4b1b364f 100644 (file)
@@ -318,27 +318,9 @@ static int is_fat_channel(__le32 rxon_flags)
 /*
  * EEPROM handlers
  */
-
-static int iwl4965_eeprom_check_version(struct iwl_priv *priv)
+static u16 iwl4965_eeprom_calib_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;
-
+       return iwl_eeprom_query16(priv, EEPROM_4965_CALIB_VERSION_OFFSET);
 }
 
 /*
@@ -2355,7 +2337,7 @@ static struct iwl_lib_ops iwl4965_lib = {
                .verify_signature  = iwlcore_eeprom_verify_signature,
                .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
                .release_semaphore = iwlcore_eeprom_release_semaphore,
-               .check_version = iwl4965_eeprom_check_version,
+               .calib_version = iwl4965_eeprom_calib_version,
                .query_addr = iwlcore_eeprom_query_addr,
        },
        .send_tx_power  = iwl4965_send_tx_power,
@@ -2374,6 +2356,8 @@ struct iwl_cfg iwl4965_agn_cfg = {
        .fw_name = "iwlwifi-4965" IWL4965_UCODE_API ".ucode",
        .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
        .eeprom_size = IWL4965_EEPROM_IMG_SIZE,
+       .eeprom_ver = EEPROM_4965_EEPROM_VERSION,
+       .eeprom_calib_ver = EEPROM_4965_TX_POWER_VERSION,
        .ops = &iwl4965_ops,
        .mod_params = &iwl4965_mod_params,
 };
index a8c8c858e2099b4f2ba6e787d678a5cd6b81f48b..f3316d488240e1c16a1a415389b12615c983decc 100644 (file)
@@ -293,30 +293,17 @@ static u32 eeprom_indirect_address(const struct iwl_priv *priv, u32 address)
        return (address & ADDRESS_MSK) + (offset << 1);
 }
 
-static int iwl5000_eeprom_check_version(struct iwl_priv *priv)
+static u16 iwl5000_eeprom_calib_version(struct iwl_priv *priv)
 {
-       u16 eeprom_ver;
        struct iwl_eeprom_calib_hdr {
                u8 version;
                u8 pa_type;
                u16 voltage;
        } *hdr;
 
-       eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
-
        hdr = (struct iwl_eeprom_calib_hdr *)iwl_eeprom_query_addr(priv,
                                                        EEPROM_5000_CALIB_ALL);
-
-       if (eeprom_ver < EEPROM_5000_EEPROM_VERSION ||
-           hdr->version < EEPROM_5000_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_5000_EEPROM_VERSION,
-                 hdr->version, EEPROM_5000_TX_POWER_VERSION);
-       return -EINVAL;
+       return hdr->version;
 
 }
 
@@ -1510,7 +1497,7 @@ static struct iwl_lib_ops iwl5000_lib = {
                .verify_signature  = iwlcore_eeprom_verify_signature,
                .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
                .release_semaphore = iwlcore_eeprom_release_semaphore,
-               .check_version  = iwl5000_eeprom_check_version,
+               .calib_version  = iwl5000_eeprom_calib_version,
                .query_addr = iwl5000_eeprom_query_addr,
        },
 };
@@ -1537,6 +1524,8 @@ struct iwl_cfg iwl5300_agn_cfg = {
        .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
        .ops = &iwl5000_ops,
        .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
+       .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
+       .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
        .mod_params = &iwl50_mod_params,
 };
 
@@ -1546,6 +1535,8 @@ struct iwl_cfg iwl5100_bg_cfg = {
        .sku = IWL_SKU_G,
        .ops = &iwl5000_ops,
        .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
+       .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
+       .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
        .mod_params = &iwl50_mod_params,
 };
 
@@ -1555,6 +1546,8 @@ struct iwl_cfg iwl5100_abg_cfg = {
        .sku = IWL_SKU_A|IWL_SKU_G,
        .ops = &iwl5000_ops,
        .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
+       .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
+       .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
        .mod_params = &iwl50_mod_params,
 };
 
@@ -1564,6 +1557,8 @@ struct iwl_cfg iwl5100_agn_cfg = {
        .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
        .ops = &iwl5000_ops,
        .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
+       .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
+       .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
        .mod_params = &iwl50_mod_params,
 };
 
@@ -1573,6 +1568,8 @@ struct iwl_cfg iwl5350_agn_cfg = {
        .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
        .ops = &iwl5000_ops,
        .eeprom_size = IWL_5000_EEPROM_IMG_SIZE,
+       .eeprom_ver = EEPROM_5050_EEPROM_VERSION,
+       .eeprom_calib_ver = EEPROM_5050_TX_POWER_VERSION,
        .mod_params = &iwl50_mod_params,
 };
 
index a2d8afe92beb27d457845d9cfeabea3dc2804a48..fb95c6a9825ba23549af685257dabbff42cc8b5e 100644 (file)
@@ -173,6 +173,8 @@ struct iwl_cfg {
        const char *fw_name;
        unsigned int sku;
        int eeprom_size;
+       u16  eeprom_ver;
+       u16  eeprom_calib_ver;
        const struct iwl_ops *ops;
        const struct iwl_mod_params *mod_params;
 };
index 37155755efc596bb51d3dc395374bf40a533b086..5160b4b0c0deb90505cd39f2891a7018fecae1bb 100644 (file)
@@ -279,7 +279,23 @@ EXPORT_SYMBOL(iwl_eeprom_free);
 
 int iwl_eeprom_check_version(struct iwl_priv *priv)
 {
-       return priv->cfg->ops->lib->eeprom_ops.check_version(priv);
+       u16 eeprom_ver;
+       u16 calib_ver;
+
+       eeprom_ver = iwl_eeprom_query16(priv, EEPROM_VERSION);
+       calib_ver = priv->cfg->ops->lib->eeprom_ops.calib_version(priv);
+
+       if (eeprom_ver < priv->cfg->eeprom_ver ||
+           calib_ver < priv->cfg->eeprom_calib_ver)
+               goto err;
+
+       return 0;
+err:
+       IWL_ERROR("Unsuported EEPROM VER=0x%x < 0x%x CALIB=0x%x < 0x%x\n",
+                 eeprom_ver, priv->cfg->eeprom_ver,
+                 calib_ver,  priv->cfg->eeprom_calib_ver);
+       return -EINVAL;
+
 }
 EXPORT_SYMBOL(iwl_eeprom_check_version);
 
index d3a2a5b4ac56214f4127c4a6456650e0f6fc82b6..997f23c8db2e8245edd461bd404722c496960b6d 100644 (file)
@@ -174,6 +174,9 @@ struct iwl_eeprom_channel {
 #define EEPROM_5000_REG_BAND_52_FAT_CHANNELS  ((0x92)\
                | INDIRECT_ADDRESS | INDIRECT_REGULATORY)   /* 22  bytes */
 
+/* 5050 Specific */
+#define EEPROM_5050_TX_POWER_VERSION    (4)
+#define EEPROM_5050_EEPROM_VERSION     (0x21E)
 
 /* 2.4 GHz */
 extern const u8 iwl_eeprom_band_1[14];
@@ -371,7 +374,7 @@ struct iwl_eeprom_ops {
        int (*verify_signature) (struct iwl_priv *priv);
        int (*acquire_semaphore) (struct iwl_priv *priv);
        void (*release_semaphore) (struct iwl_priv *priv);
-       int (*check_version) (struct iwl_priv *priv);
+       u16 (*calib_version) (struct iwl_priv *priv);
        const u8* (*query_addr) (const struct iwl_priv *priv, size_t offset);
 };