aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-3945.c
diff options
context:
space:
mode:
authorSamuel Ortiz <samuel.ortiz@intel.com>2009-01-23 16:45:15 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-01-29 16:01:35 -0500
commite6148917db2c223fa7edd3dfb64d99756a86b452 (patch)
tree814dc8d58d03d35e15904cc48d81c30f94dc07cf /drivers/net/wireless/iwlwifi/iwl-3945.c
parenta8e74e2774cd1aecfef0460de07e6e178df89232 (diff)
iwl3945: Use iwl-eeprom.c routines
By adding the eeprom ops to the 3945 code, we can now use the iwlcore eeprom routines (defined in iwl-eeprom.c). We also removed the heavy eeprom39 reference from iwl_priv and use the eeprom pointer instead. Signed-off-by: Samuel Ortiz <samuel.ortiz@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-3945.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c92
1 files changed, 74 insertions, 18 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 2689113f4e60..75e9553a9407 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -42,6 +42,7 @@
42#include "iwl-3945-fh.h" 42#include "iwl-3945-fh.h"
43#include "iwl-commands.h" 43#include "iwl-commands.h"
44#include "iwl-3945.h" 44#include "iwl-3945.h"
45#include "iwl-eeprom.h"
45#include "iwl-helpers.h" 46#include "iwl-helpers.h"
46#include "iwl-core.h" 47#include "iwl-core.h"
47#include "iwl-agn-rs.h" 48#include "iwl-agn-rs.h"
@@ -209,17 +210,19 @@ static int iwl3945_hwrate_to_plcp_idx(u8 plcp)
209 */ 210 */
210__le32 iwl3945_get_antenna_flags(const struct iwl_priv *priv) 211__le32 iwl3945_get_antenna_flags(const struct iwl_priv *priv)
211{ 212{
213 struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom;
214
212 switch (priv->antenna) { 215 switch (priv->antenna) {
213 case IWL_ANTENNA_DIVERSITY: 216 case IWL_ANTENNA_DIVERSITY:
214 return 0; 217 return 0;
215 218
216 case IWL_ANTENNA_MAIN: 219 case IWL_ANTENNA_MAIN:
217 if (priv->eeprom39.antenna_switch_type) 220 if (eeprom->antenna_switch_type)
218 return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_B_MSK; 221 return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_B_MSK;
219 return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_A_MSK; 222 return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_A_MSK;
220 223
221 case IWL_ANTENNA_AUX: 224 case IWL_ANTENNA_AUX:
222 if (priv->eeprom39.antenna_switch_type) 225 if (eeprom->antenna_switch_type)
223 return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_A_MSK; 226 return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_A_MSK;
224 return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_B_MSK; 227 return RXON_FLG_DIS_DIV_MSK | RXON_FLG_ANT_B_MSK;
225 } 228 }
@@ -1128,6 +1131,7 @@ out:
1128 1131
1129static void iwl3945_nic_config(struct iwl_priv *priv) 1132static void iwl3945_nic_config(struct iwl_priv *priv)
1130{ 1133{
1134 struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom;
1131 unsigned long flags; 1135 unsigned long flags;
1132 u8 rev_id = 0; 1136 u8 rev_id = 0;
1133 1137
@@ -1145,42 +1149,42 @@ static void iwl3945_nic_config(struct iwl_priv *priv)
1145 CSR39_HW_IF_CONFIG_REG_BIT_3945_MM); 1149 CSR39_HW_IF_CONFIG_REG_BIT_3945_MM);
1146 } 1150 }
1147 1151
1148 if (EEPROM_SKU_CAP_OP_MODE_MRC == priv->eeprom39.sku_cap) { 1152 if (EEPROM_SKU_CAP_OP_MODE_MRC == eeprom->sku_cap) {
1149 IWL_DEBUG_INFO("SKU OP mode is mrc\n"); 1153 IWL_DEBUG_INFO("SKU OP mode is mrc\n");
1150 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, 1154 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
1151 CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC); 1155 CSR39_HW_IF_CONFIG_REG_BIT_SKU_MRC);
1152 } else 1156 } else
1153 IWL_DEBUG_INFO("SKU OP mode is basic\n"); 1157 IWL_DEBUG_INFO("SKU OP mode is basic\n");
1154 1158
1155 if ((priv->eeprom39.board_revision & 0xF0) == 0xD0) { 1159 if ((eeprom->board_revision & 0xF0) == 0xD0) {
1156 IWL_DEBUG_INFO("3945ABG revision is 0x%X\n", 1160 IWL_DEBUG_INFO("3945ABG revision is 0x%X\n",
1157 priv->eeprom39.board_revision); 1161 eeprom->board_revision);
1158 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, 1162 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
1159 CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); 1163 CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE);
1160 } else { 1164 } else {
1161 IWL_DEBUG_INFO("3945ABG revision is 0x%X\n", 1165 IWL_DEBUG_INFO("3945ABG revision is 0x%X\n",
1162 priv->eeprom39.board_revision); 1166 eeprom->board_revision);
1163 iwl_clear_bit(priv, CSR_HW_IF_CONFIG_REG, 1167 iwl_clear_bit(priv, CSR_HW_IF_CONFIG_REG,
1164 CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE); 1168 CSR39_HW_IF_CONFIG_REG_BIT_BOARD_TYPE);
1165 } 1169 }
1166 1170
1167 if (priv->eeprom39.almgor_m_version <= 1) { 1171 if (eeprom->almgor_m_version <= 1) {
1168 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, 1172 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
1169 CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A); 1173 CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_A);
1170 IWL_DEBUG_INFO("Card M type A version is 0x%X\n", 1174 IWL_DEBUG_INFO("Card M type A version is 0x%X\n",
1171 priv->eeprom39.almgor_m_version); 1175 eeprom->almgor_m_version);
1172 } else { 1176 } else {
1173 IWL_DEBUG_INFO("Card M type B version is 0x%X\n", 1177 IWL_DEBUG_INFO("Card M type B version is 0x%X\n",
1174 priv->eeprom39.almgor_m_version); 1178 eeprom->almgor_m_version);
1175 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, 1179 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
1176 CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B); 1180 CSR39_HW_IF_CONFIG_REG_BITS_SILICON_TYPE_B);
1177 } 1181 }
1178 spin_unlock_irqrestore(&priv->lock, flags); 1182 spin_unlock_irqrestore(&priv->lock, flags);
1179 1183
1180 if (priv->eeprom39.sku_cap & EEPROM_SKU_CAP_SW_RF_KILL_ENABLE) 1184 if (eeprom->sku_cap & EEPROM_SKU_CAP_SW_RF_KILL_ENABLE)
1181 IWL_DEBUG_RF_KILL("SW RF KILL supported in EEPROM.\n"); 1185 IWL_DEBUG_RF_KILL("SW RF KILL supported in EEPROM.\n");
1182 1186
1183 if (priv->eeprom39.sku_cap & EEPROM_SKU_CAP_HW_RF_KILL_ENABLE) 1187 if (eeprom->sku_cap & EEPROM_SKU_CAP_HW_RF_KILL_ENABLE)
1184 IWL_DEBUG_RF_KILL("HW RF KILL supported in EEPROM.\n"); 1188 IWL_DEBUG_RF_KILL("HW RF KILL supported in EEPROM.\n");
1185} 1189}
1186 1190
@@ -1406,6 +1410,7 @@ int iwl3945_hw_get_temperature(struct iwl_priv *priv)
1406*/ 1410*/
1407static int iwl3945_hw_reg_txpower_get_temperature(struct iwl_priv *priv) 1411static int iwl3945_hw_reg_txpower_get_temperature(struct iwl_priv *priv)
1408{ 1412{
1413 struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom;
1409 int temperature; 1414 int temperature;
1410 1415
1411 temperature = iwl3945_hw_get_temperature(priv); 1416 temperature = iwl3945_hw_get_temperature(priv);
@@ -1421,7 +1426,7 @@ static int iwl3945_hw_reg_txpower_get_temperature(struct iwl_priv *priv)
1421 /* if really really hot(?), 1426 /* if really really hot(?),
1422 * substitute the 3rd band/group's temp measured at factory */ 1427 * substitute the 3rd band/group's temp measured at factory */
1423 if (priv->last_temperature > 100) 1428 if (priv->last_temperature > 100)
1424 temperature = priv->eeprom39.groups[2].temperature; 1429 temperature = eeprom->groups[2].temperature;
1425 else /* else use most recent "sane" value from driver */ 1430 else /* else use most recent "sane" value from driver */
1426 temperature = priv->last_temperature; 1431 temperature = priv->last_temperature;
1427 } 1432 }
@@ -1720,7 +1725,7 @@ int iwl3945_send_tx_power(struct iwl_priv *priv)
1720 }; 1725 };
1721 1726
1722 txpower.band = (priv->band == IEEE80211_BAND_5GHZ) ? 0 : 1; 1727 txpower.band = (priv->band == IEEE80211_BAND_5GHZ) ? 0 : 1;
1723 ch_info = iwl3945_get_channel_info(priv, 1728 ch_info = iwl_get_channel_info(priv,
1724 priv->band, 1729 priv->band,
1725 le16_to_cpu(priv->active39_rxon.channel)); 1730 le16_to_cpu(priv->active39_rxon.channel));
1726 if (!ch_info) { 1731 if (!ch_info) {
@@ -1881,6 +1886,7 @@ static int iwl3945_hw_reg_get_ch_txpower_limit(struct iwl_channel_info *ch_info)
1881static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv) 1886static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv)
1882{ 1887{
1883 struct iwl_channel_info *ch_info = NULL; 1888 struct iwl_channel_info *ch_info = NULL;
1889 struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom;
1884 int delta_index; 1890 int delta_index;
1885 const s8 *clip_pwrs; /* array of h/w max power levels for each rate */ 1891 const s8 *clip_pwrs; /* array of h/w max power levels for each rate */
1886 u8 a_band; 1892 u8 a_band;
@@ -1896,7 +1902,7 @@ static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv)
1896 a_band = is_channel_a_band(ch_info); 1902 a_band = is_channel_a_band(ch_info);
1897 1903
1898 /* Get this chnlgrp's factory calibration temperature */ 1904 /* Get this chnlgrp's factory calibration temperature */
1899 ref_temp = (s16)priv->eeprom39.groups[ch_info->group_index]. 1905 ref_temp = (s16)eeprom->groups[ch_info->group_index].
1900 temperature; 1906 temperature;
1901 1907
1902 /* get power index adjustment based on current and factory 1908 /* get power index adjustment based on current and factory
@@ -2041,7 +2047,8 @@ static void iwl3945_bg_reg_txpower_periodic(struct work_struct *work)
2041static u16 iwl3945_hw_reg_get_ch_grp_index(struct iwl_priv *priv, 2047static u16 iwl3945_hw_reg_get_ch_grp_index(struct iwl_priv *priv,
2042 const struct iwl_channel_info *ch_info) 2048 const struct iwl_channel_info *ch_info)
2043{ 2049{
2044 struct iwl3945_eeprom_txpower_group *ch_grp = &priv->eeprom39.groups[0]; 2050 struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom;
2051 struct iwl3945_eeprom_txpower_group *ch_grp = &eeprom->groups[0];
2045 u8 group; 2052 u8 group;
2046 u16 group_index = 0; /* based on factory calib frequencies */ 2053 u16 group_index = 0; /* based on factory calib frequencies */
2047 u8 grp_channel; 2054 u8 grp_channel;
@@ -2077,6 +2084,7 @@ static int iwl3945_hw_reg_get_matched_power_index(struct iwl_priv *priv,
2077 s32 setting_index, s32 *new_index) 2084 s32 setting_index, s32 *new_index)
2078{ 2085{
2079 const struct iwl3945_eeprom_txpower_group *chnl_grp = NULL; 2086 const struct iwl3945_eeprom_txpower_group *chnl_grp = NULL;
2087 struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom;
2080 s32 index0, index1; 2088 s32 index0, index1;
2081 s32 power = 2 * requested_power; 2089 s32 power = 2 * requested_power;
2082 s32 i; 2090 s32 i;
@@ -2085,7 +2093,7 @@ static int iwl3945_hw_reg_get_matched_power_index(struct iwl_priv *priv,
2085 s32 res; 2093 s32 res;
2086 s32 denominator; 2094 s32 denominator;
2087 2095
2088 chnl_grp = &priv->eeprom39.groups[setting_index]; 2096 chnl_grp = &eeprom->groups[setting_index];
2089 samples = chnl_grp->samples; 2097 samples = chnl_grp->samples;
2090 for (i = 0; i < 5; i++) { 2098 for (i = 0; i < 5; i++) {
2091 if (power == samples[i].power) { 2099 if (power == samples[i].power) {
@@ -2124,6 +2132,7 @@ static void iwl3945_hw_reg_init_channel_groups(struct iwl_priv *priv)
2124{ 2132{
2125 u32 i; 2133 u32 i;
2126 s32 rate_index; 2134 s32 rate_index;
2135 struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom;
2127 const struct iwl3945_eeprom_txpower_group *group; 2136 const struct iwl3945_eeprom_txpower_group *group;
2128 2137
2129 IWL_DEBUG_POWER("Initializing factory calib info from EEPROM\n"); 2138 IWL_DEBUG_POWER("Initializing factory calib info from EEPROM\n");
@@ -2131,7 +2140,7 @@ static void iwl3945_hw_reg_init_channel_groups(struct iwl_priv *priv)
2131 for (i = 0; i < IWL_NUM_TX_CALIB_GROUPS; i++) { 2140 for (i = 0; i < IWL_NUM_TX_CALIB_GROUPS; i++) {
2132 s8 *clip_pwrs; /* table of power levels for each rate */ 2141 s8 *clip_pwrs; /* table of power levels for each rate */
2133 s8 satur_pwr; /* saturation power for each chnl group */ 2142 s8 satur_pwr; /* saturation power for each chnl group */
2134 group = &priv->eeprom39.groups[i]; 2143 group = &eeprom->groups[i];
2135 2144
2136 /* sanity check on factory saturation power value */ 2145 /* sanity check on factory saturation power value */
2137 if (group->saturation_power < 40) { 2146 if (group->saturation_power < 40) {
@@ -2204,6 +2213,7 @@ int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv)
2204{ 2213{
2205 struct iwl_channel_info *ch_info = NULL; 2214 struct iwl_channel_info *ch_info = NULL;
2206 struct iwl3945_channel_power_info *pwr_info; 2215 struct iwl3945_channel_power_info *pwr_info;
2216 struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom;
2207 int delta_index; 2217 int delta_index;
2208 u8 rate_index; 2218 u8 rate_index;
2209 u8 scan_tbl_index; 2219 u8 scan_tbl_index;
@@ -2238,7 +2248,7 @@ int iwl3945_txpower_set_from_eeprom(struct iwl_priv *priv)
2238 /* calculate power index *adjustment* value according to 2248 /* calculate power index *adjustment* value according to
2239 * diff between current temperature and factory temperature */ 2249 * diff between current temperature and factory temperature */
2240 delta_index = iwl3945_hw_reg_adjust_power_by_temp(temperature, 2250 delta_index = iwl3945_hw_reg_adjust_power_by_temp(temperature,
2241 priv->eeprom39.groups[ch_info->group_index]. 2251 eeprom->groups[ch_info->group_index].
2242 temperature); 2252 temperature);
2243 2253
2244 IWL_DEBUG_POWER("Delta index for channel %d: %d [%d]\n", 2254 IWL_DEBUG_POWER("Delta index for channel %d: %d [%d]\n",
@@ -2585,6 +2595,33 @@ static int iwl3945_verify_bsm(struct iwl_priv *priv)
2585 return 0; 2595 return 0;
2586} 2596}
2587 2597
2598
2599/******************************************************************************
2600 *
2601 * EEPROM related functions
2602 *
2603 ******************************************************************************/
2604
2605/*
2606 * Clear the OWNER_MSK, to establish driver (instead of uCode running on
2607 * embedded controller) as EEPROM reader; each read is a series of pulses
2608 * to/from the EEPROM chip, not a single event, so even reads could conflict
2609 * if they weren't arbitrated by some ownership mechanism. Here, the driver
2610 * simply claims ownership, which should be safe when this function is called
2611 * (i.e. before loading uCode!).
2612 */
2613static int iwl3945_eeprom_acquire_semaphore(struct iwl_priv *priv)
2614{
2615 _iwl_clear_bit(priv, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK);
2616 return 0;
2617}
2618
2619
2620static void iwl3945_eeprom_release_semaphore(struct iwl_priv *priv)
2621{
2622 return;
2623}
2624
2588 /** 2625 /**
2589 * iwl3945_load_bsm - Load bootstrap instructions 2626 * iwl3945_load_bsm - Load bootstrap instructions
2590 * 2627 *
@@ -2715,6 +2752,21 @@ static struct iwl_lib_ops iwl3945_lib = {
2715 .config = iwl3945_nic_config, 2752 .config = iwl3945_nic_config,
2716 .set_pwr_src = iwl3945_set_pwr_src, 2753 .set_pwr_src = iwl3945_set_pwr_src,
2717 }, 2754 },
2755 .eeprom_ops = {
2756 .regulatory_bands = {
2757 EEPROM_REGULATORY_BAND_1_CHANNELS,
2758 EEPROM_REGULATORY_BAND_2_CHANNELS,
2759 EEPROM_REGULATORY_BAND_3_CHANNELS,
2760 EEPROM_REGULATORY_BAND_4_CHANNELS,
2761 EEPROM_REGULATORY_BAND_5_CHANNELS,
2762 IWL3945_EEPROM_IMG_SIZE,
2763 IWL3945_EEPROM_IMG_SIZE,
2764 },
2765 .verify_signature = iwlcore_eeprom_verify_signature,
2766 .acquire_semaphore = iwl3945_eeprom_acquire_semaphore,
2767 .release_semaphore = iwl3945_eeprom_release_semaphore,
2768 .query_addr = iwlcore_eeprom_query_addr,
2769 },
2718 .send_tx_power = iwl3945_send_tx_power, 2770 .send_tx_power = iwl3945_send_tx_power,
2719}; 2771};
2720 2772
@@ -2733,6 +2785,8 @@ static struct iwl_cfg iwl3945_bg_cfg = {
2733 .ucode_api_max = IWL3945_UCODE_API_MAX, 2785 .ucode_api_max = IWL3945_UCODE_API_MAX,
2734 .ucode_api_min = IWL3945_UCODE_API_MIN, 2786 .ucode_api_min = IWL3945_UCODE_API_MIN,
2735 .sku = IWL_SKU_G, 2787 .sku = IWL_SKU_G,
2788 .eeprom_size = IWL3945_EEPROM_IMG_SIZE,
2789 .eeprom_ver = EEPROM_3945_EEPROM_VERSION,
2736 .ops = &iwl3945_ops, 2790 .ops = &iwl3945_ops,
2737 .mod_params = &iwl3945_mod_params 2791 .mod_params = &iwl3945_mod_params
2738}; 2792};
@@ -2743,6 +2797,8 @@ static struct iwl_cfg iwl3945_abg_cfg = {
2743 .ucode_api_max = IWL3945_UCODE_API_MAX, 2797 .ucode_api_max = IWL3945_UCODE_API_MAX,
2744 .ucode_api_min = IWL3945_UCODE_API_MIN, 2798 .ucode_api_min = IWL3945_UCODE_API_MIN,
2745 .sku = IWL_SKU_A|IWL_SKU_G, 2799 .sku = IWL_SKU_A|IWL_SKU_G,
2800 .eeprom_size = IWL3945_EEPROM_IMG_SIZE,
2801 .eeprom_ver = EEPROM_3945_EEPROM_VERSION,
2746 .ops = &iwl3945_ops, 2802 .ops = &iwl3945_ops,
2747 .mod_params = &iwl3945_mod_params 2803 .mod_params = &iwl3945_mod_params
2748}; 2804};