diff options
author | Samuel Ortiz <samuel.ortiz@intel.com> | 2009-01-23 16:45:15 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-01-29 16:01:35 -0500 |
commit | e6148917db2c223fa7edd3dfb64d99756a86b452 (patch) | |
tree | 814dc8d58d03d35e15904cc48d81c30f94dc07cf | |
parent | a8e74e2774cd1aecfef0460de07e6e178df89232 (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>
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945-hw.h | 4 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-3945.c | 92 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-dev.h | 3 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-eeprom.c | 8 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-eeprom.h | 3 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl3945-base.c | 372 |
6 files changed, 115 insertions, 367 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h index 013e24edf0e9..1327b2ac1c53 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945-hw.h +++ b/drivers/net/wireless/iwlwifi/iwl-3945-hw.h | |||
@@ -182,7 +182,7 @@ struct iwl3945_eeprom { | |||
182 | * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 | 182 | * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 |
183 | */ | 183 | */ |
184 | u16 band_1_count; /* abs.ofs: 196 */ | 184 | u16 band_1_count; /* abs.ofs: 196 */ |
185 | struct iwl_eeprom_channel band_1_channels[14]; /* abs.ofs: 196 */ | 185 | struct iwl_eeprom_channel band_1_channels[14]; /* abs.ofs: 198 */ |
186 | 186 | ||
187 | /* | 187 | /* |
188 | * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196, | 188 | * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196, |
@@ -225,7 +225,7 @@ struct iwl3945_eeprom { | |||
225 | u8 reserved16[172]; /* fill out to full 1024 byte block */ | 225 | u8 reserved16[172]; /* fill out to full 1024 byte block */ |
226 | } __attribute__ ((packed)); | 226 | } __attribute__ ((packed)); |
227 | 227 | ||
228 | #define IWL_EEPROM_IMAGE_SIZE 1024 | 228 | #define IWL3945_EEPROM_IMG_SIZE 1024 |
229 | 229 | ||
230 | /* End of EEPROM */ | 230 | /* End of EEPROM */ |
231 | 231 | ||
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 | ||
1129 | static void iwl3945_nic_config(struct iwl_priv *priv) | 1132 | static 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 | */ |
1407 | static int iwl3945_hw_reg_txpower_get_temperature(struct iwl_priv *priv) | 1411 | static 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) | |||
1881 | static int iwl3945_hw_reg_comp_txpower_temp(struct iwl_priv *priv) | 1886 | static 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) | |||
2041 | static u16 iwl3945_hw_reg_get_ch_grp_index(struct iwl_priv *priv, | 2047 | static 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 | */ | ||
2613 | static 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 | |||
2620 | static 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 | }; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index 5aa22d61e398..d4e07785d91d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h | |||
@@ -1091,9 +1091,6 @@ struct iwl_priv { | |||
1091 | 1091 | ||
1092 | struct iwl3945_station_entry stations_39[IWL_STATION_COUNT]; | 1092 | struct iwl3945_station_entry stations_39[IWL_STATION_COUNT]; |
1093 | 1093 | ||
1094 | /* eeprom */ | ||
1095 | struct iwl3945_eeprom eeprom39; | ||
1096 | |||
1097 | u32 sta_supp_rates; | 1094 | u32 sta_supp_rates; |
1098 | }; /*iwl_priv */ | 1095 | }; /*iwl_priv */ |
1099 | 1096 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index cebfb8fa5da1..eaa658f9e54c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c | |||
@@ -531,6 +531,13 @@ int iwl_init_channel_map(struct iwl_priv *priv) | |||
531 | } | 531 | } |
532 | } | 532 | } |
533 | 533 | ||
534 | /* Check if we do have FAT channels */ | ||
535 | if (priv->cfg->ops->lib->eeprom_ops.regulatory_bands[5] >= | ||
536 | priv->cfg->eeprom_size && | ||
537 | priv->cfg->ops->lib->eeprom_ops.regulatory_bands[6] >= | ||
538 | priv->cfg->eeprom_size) | ||
539 | return 0; | ||
540 | |||
534 | /* Two additional EEPROM bands for 2.4 and 5 GHz FAT channels */ | 541 | /* Two additional EEPROM bands for 2.4 and 5 GHz FAT channels */ |
535 | for (band = 6; band <= 7; band++) { | 542 | for (band = 6; band <= 7; band++) { |
536 | enum ieee80211_band ieeeband; | 543 | enum ieee80211_band ieeeband; |
@@ -582,6 +589,7 @@ void iwl_free_channel_map(struct iwl_priv *priv) | |||
582 | kfree(priv->channel_info); | 589 | kfree(priv->channel_info); |
583 | priv->channel_count = 0; | 590 | priv->channel_count = 0; |
584 | } | 591 | } |
592 | EXPORT_SYMBOL(iwl_free_channel_map); | ||
585 | 593 | ||
586 | /** | 594 | /** |
587 | * iwl_get_channel_info - Find driver's private channel info | 595 | * iwl_get_channel_info - Find driver's private channel info |
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h index dd2e7d2c5082..17fed49f9d96 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h | |||
@@ -118,6 +118,9 @@ struct iwl_eeprom_channel { | |||
118 | s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */ | 118 | s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */ |
119 | } __attribute__ ((packed)); | 119 | } __attribute__ ((packed)); |
120 | 120 | ||
121 | /* 3945 Specific */ | ||
122 | #define EEPROM_3945_EEPROM_VERSION (0x2f) | ||
123 | |||
121 | /* 4965 has two radio transmitters (and 3 radio receivers) */ | 124 | /* 4965 has two radio transmitters (and 3 radio receivers) */ |
122 | #define EEPROM_TX_POWER_TX_CHAINS (2) | 125 | #define EEPROM_TX_POWER_TX_CHAINS (2) |
123 | 126 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 14f95238059a..b57c2b8c8dcf 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -257,7 +257,7 @@ static int iwl3945_set_rxon_channel(struct iwl_priv *priv, | |||
257 | enum ieee80211_band band, | 257 | enum ieee80211_band band, |
258 | u16 channel) | 258 | u16 channel) |
259 | { | 259 | { |
260 | if (!iwl3945_get_channel_info(priv, band, channel)) { | 260 | if (!iwl_get_channel_info(priv, band, channel)) { |
261 | IWL_DEBUG_INFO("Could not set channel to %d [%d]\n", | 261 | IWL_DEBUG_INFO("Could not set channel to %d [%d]\n", |
262 | channel, band); | 262 | channel, band); |
263 | return -EINVAL; | 263 | return -EINVAL; |
@@ -834,86 +834,6 @@ static int iwl3945_send_beacon_cmd(struct iwl_priv *priv) | |||
834 | return rc; | 834 | return rc; |
835 | } | 835 | } |
836 | 836 | ||
837 | /****************************************************************************** | ||
838 | * | ||
839 | * EEPROM related functions | ||
840 | * | ||
841 | ******************************************************************************/ | ||
842 | |||
843 | static void get_eeprom_mac(struct iwl_priv *priv, u8 *mac) | ||
844 | { | ||
845 | memcpy(mac, priv->eeprom39.mac_address, 6); | ||
846 | } | ||
847 | |||
848 | /* | ||
849 | * Clear the OWNER_MSK, to establish driver (instead of uCode running on | ||
850 | * embedded controller) as EEPROM reader; each read is a series of pulses | ||
851 | * to/from the EEPROM chip, not a single event, so even reads could conflict | ||
852 | * if they weren't arbitrated by some ownership mechanism. Here, the driver | ||
853 | * simply claims ownership, which should be safe when this function is called | ||
854 | * (i.e. before loading uCode!). | ||
855 | */ | ||
856 | static inline int iwl3945_eeprom_acquire_semaphore(struct iwl_priv *priv) | ||
857 | { | ||
858 | _iwl_clear_bit(priv, CSR_EEPROM_GP, CSR_EEPROM_GP_IF_OWNER_MSK); | ||
859 | return 0; | ||
860 | } | ||
861 | |||
862 | /** | ||
863 | * iwl3945_eeprom_init - read EEPROM contents | ||
864 | * | ||
865 | * Load the EEPROM contents from adapter into priv->eeprom39 | ||
866 | * | ||
867 | * NOTE: This routine uses the non-debug IO access functions. | ||
868 | */ | ||
869 | int iwl3945_eeprom_init(struct iwl_priv *priv) | ||
870 | { | ||
871 | u16 *e = (u16 *)&priv->eeprom39; | ||
872 | u32 gp = iwl_read32(priv, CSR_EEPROM_GP); | ||
873 | int sz = sizeof(priv->eeprom39); | ||
874 | int ret; | ||
875 | u16 addr; | ||
876 | |||
877 | /* The EEPROM structure has several padding buffers within it | ||
878 | * and when adding new EEPROM maps is subject to programmer errors | ||
879 | * which may be very difficult to identify without explicitly | ||
880 | * checking the resulting size of the eeprom map. */ | ||
881 | BUILD_BUG_ON(sizeof(priv->eeprom39) != IWL_EEPROM_IMAGE_SIZE); | ||
882 | |||
883 | if ((gp & CSR_EEPROM_GP_VALID_MSK) == CSR_EEPROM_GP_BAD_SIGNATURE) { | ||
884 | IWL_ERR(priv, "EEPROM not found, EEPROM_GP=0x%08x\n", gp); | ||
885 | return -ENOENT; | ||
886 | } | ||
887 | |||
888 | /* Make sure driver (instead of uCode) is allowed to read EEPROM */ | ||
889 | ret = iwl3945_eeprom_acquire_semaphore(priv); | ||
890 | if (ret < 0) { | ||
891 | IWL_ERR(priv, "Failed to acquire EEPROM semaphore.\n"); | ||
892 | return -ENOENT; | ||
893 | } | ||
894 | |||
895 | /* eeprom is an array of 16bit values */ | ||
896 | for (addr = 0; addr < sz; addr += sizeof(u16)) { | ||
897 | u32 r; | ||
898 | |||
899 | _iwl_write32(priv, CSR_EEPROM_REG, | ||
900 | CSR_EEPROM_REG_MSK_ADDR & (addr << 1)); | ||
901 | _iwl_clear_bit(priv, CSR_EEPROM_REG, CSR_EEPROM_REG_BIT_CMD); | ||
902 | ret = iwl_poll_direct_bit(priv, CSR_EEPROM_REG, | ||
903 | CSR_EEPROM_REG_READ_VALID_MSK, | ||
904 | IWL_EEPROM_ACCESS_TIMEOUT); | ||
905 | if (ret < 0) { | ||
906 | IWL_ERR(priv, "Time out reading EEPROM[%d]\n", addr); | ||
907 | return ret; | ||
908 | } | ||
909 | |||
910 | r = _iwl_read_direct32(priv, CSR_EEPROM_REG); | ||
911 | e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16)); | ||
912 | } | ||
913 | |||
914 | return 0; | ||
915 | } | ||
916 | |||
917 | static void iwl3945_unset_hw_params(struct iwl_priv *priv) | 837 | static void iwl3945_unset_hw_params(struct iwl_priv *priv) |
918 | { | 838 | { |
919 | if (priv->shared_virt) | 839 | if (priv->shared_virt) |
@@ -1304,7 +1224,7 @@ static void iwl3945_connection_init_rx_config(struct iwl_priv *priv, | |||
1304 | priv->staging39_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; | 1224 | priv->staging39_rxon.flags |= RXON_FLG_SHORT_PREAMBLE_MSK; |
1305 | #endif | 1225 | #endif |
1306 | 1226 | ||
1307 | ch_info = iwl3945_get_channel_info(priv, priv->band, | 1227 | ch_info = iwl_get_channel_info(priv, priv->band, |
1308 | le16_to_cpu(priv->active39_rxon.channel)); | 1228 | le16_to_cpu(priv->active39_rxon.channel)); |
1309 | 1229 | ||
1310 | if (!ch_info) | 1230 | if (!ch_info) |
@@ -1336,7 +1256,7 @@ static int iwl3945_set_mode(struct iwl_priv *priv, int mode) | |||
1336 | if (mode == NL80211_IFTYPE_ADHOC) { | 1256 | if (mode == NL80211_IFTYPE_ADHOC) { |
1337 | const struct iwl_channel_info *ch_info; | 1257 | const struct iwl_channel_info *ch_info; |
1338 | 1258 | ||
1339 | ch_info = iwl3945_get_channel_info(priv, | 1259 | ch_info = iwl_get_channel_info(priv, |
1340 | priv->band, | 1260 | priv->band, |
1341 | le16_to_cpu(priv->staging39_rxon.channel)); | 1261 | le16_to_cpu(priv->staging39_rxon.channel)); |
1342 | 1262 | ||
@@ -3349,258 +3269,6 @@ unplugged: | |||
3349 | return IRQ_NONE; | 3269 | return IRQ_NONE; |
3350 | } | 3270 | } |
3351 | 3271 | ||
3352 | /************************** EEPROM BANDS **************************** | ||
3353 | * | ||
3354 | * The iwl3945_eeprom_band definitions below provide the mapping from the | ||
3355 | * EEPROM contents to the specific channel number supported for each | ||
3356 | * band. | ||
3357 | * | ||
3358 | * For example, iwl3945_priv->eeprom39.band_3_channels[4] from the band_3 | ||
3359 | * definition below maps to physical channel 42 in the 5.2GHz spectrum. | ||
3360 | * The specific geography and calibration information for that channel | ||
3361 | * is contained in the eeprom map itself. | ||
3362 | * | ||
3363 | * During init, we copy the eeprom information and channel map | ||
3364 | * information into priv->channel_info_24/52 and priv->channel_map_24/52 | ||
3365 | * | ||
3366 | * channel_map_24/52 provides the index in the channel_info array for a | ||
3367 | * given channel. We have to have two separate maps as there is channel | ||
3368 | * overlap with the 2.4GHz and 5.2GHz spectrum as seen in band_1 and | ||
3369 | * band_2 | ||
3370 | * | ||
3371 | * A value of 0xff stored in the channel_map indicates that the channel | ||
3372 | * is not supported by the hardware at all. | ||
3373 | * | ||
3374 | * A value of 0xfe in the channel_map indicates that the channel is not | ||
3375 | * valid for Tx with the current hardware. This means that | ||
3376 | * while the system can tune and receive on a given channel, it may not | ||
3377 | * be able to associate or transmit any frames on that | ||
3378 | * channel. There is no corresponding channel information for that | ||
3379 | * entry. | ||
3380 | * | ||
3381 | *********************************************************************/ | ||
3382 | |||
3383 | /* 2.4 GHz */ | ||
3384 | static const u8 iwl3945_eeprom_band_1[14] = { | ||
3385 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 | ||
3386 | }; | ||
3387 | |||
3388 | /* 5.2 GHz bands */ | ||
3389 | static const u8 iwl3945_eeprom_band_2[] = { /* 4915-5080MHz */ | ||
3390 | 183, 184, 185, 187, 188, 189, 192, 196, 7, 8, 11, 12, 16 | ||
3391 | }; | ||
3392 | |||
3393 | static const u8 iwl3945_eeprom_band_3[] = { /* 5170-5320MHz */ | ||
3394 | 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 | ||
3395 | }; | ||
3396 | |||
3397 | static const u8 iwl3945_eeprom_band_4[] = { /* 5500-5700MHz */ | ||
3398 | 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 | ||
3399 | }; | ||
3400 | |||
3401 | static const u8 iwl3945_eeprom_band_5[] = { /* 5725-5825MHz */ | ||
3402 | 145, 149, 153, 157, 161, 165 | ||
3403 | }; | ||
3404 | |||
3405 | static void iwl3945_init_band_reference(const struct iwl_priv *priv, int band, | ||
3406 | int *eeprom_ch_count, | ||
3407 | const struct iwl_eeprom_channel | ||
3408 | **eeprom_ch_info, | ||
3409 | const u8 **eeprom_ch_index) | ||
3410 | { | ||
3411 | switch (band) { | ||
3412 | case 1: /* 2.4GHz band */ | ||
3413 | *eeprom_ch_count = ARRAY_SIZE(iwl3945_eeprom_band_1); | ||
3414 | *eeprom_ch_info = priv->eeprom39.band_1_channels; | ||
3415 | *eeprom_ch_index = iwl3945_eeprom_band_1; | ||
3416 | break; | ||
3417 | case 2: /* 4.9GHz band */ | ||
3418 | *eeprom_ch_count = ARRAY_SIZE(iwl3945_eeprom_band_2); | ||
3419 | *eeprom_ch_info = priv->eeprom39.band_2_channels; | ||
3420 | *eeprom_ch_index = iwl3945_eeprom_band_2; | ||
3421 | break; | ||
3422 | case 3: /* 5.2GHz band */ | ||
3423 | *eeprom_ch_count = ARRAY_SIZE(iwl3945_eeprom_band_3); | ||
3424 | *eeprom_ch_info = priv->eeprom39.band_3_channels; | ||
3425 | *eeprom_ch_index = iwl3945_eeprom_band_3; | ||
3426 | break; | ||
3427 | case 4: /* 5.5GHz band */ | ||
3428 | *eeprom_ch_count = ARRAY_SIZE(iwl3945_eeprom_band_4); | ||
3429 | *eeprom_ch_info = priv->eeprom39.band_4_channels; | ||
3430 | *eeprom_ch_index = iwl3945_eeprom_band_4; | ||
3431 | break; | ||
3432 | case 5: /* 5.7GHz band */ | ||
3433 | *eeprom_ch_count = ARRAY_SIZE(iwl3945_eeprom_band_5); | ||
3434 | *eeprom_ch_info = priv->eeprom39.band_5_channels; | ||
3435 | *eeprom_ch_index = iwl3945_eeprom_band_5; | ||
3436 | break; | ||
3437 | default: | ||
3438 | BUG(); | ||
3439 | return; | ||
3440 | } | ||
3441 | } | ||
3442 | |||
3443 | /** | ||
3444 | * iwl3945_get_channel_info - Find driver's private channel info | ||
3445 | * | ||
3446 | * Based on band and channel number. | ||
3447 | */ | ||
3448 | const struct iwl_channel_info * | ||
3449 | iwl3945_get_channel_info(const struct iwl_priv *priv, | ||
3450 | enum ieee80211_band band, u16 channel) | ||
3451 | { | ||
3452 | int i; | ||
3453 | |||
3454 | switch (band) { | ||
3455 | case IEEE80211_BAND_5GHZ: | ||
3456 | for (i = 14; i < priv->channel_count; i++) { | ||
3457 | if (priv->channel_info[i].channel == channel) | ||
3458 | return &priv->channel_info[i]; | ||
3459 | } | ||
3460 | break; | ||
3461 | |||
3462 | case IEEE80211_BAND_2GHZ: | ||
3463 | if (channel >= 1 && channel <= 14) | ||
3464 | return &priv->channel_info[channel - 1]; | ||
3465 | break; | ||
3466 | case IEEE80211_NUM_BANDS: | ||
3467 | WARN_ON(1); | ||
3468 | } | ||
3469 | |||
3470 | return NULL; | ||
3471 | } | ||
3472 | |||
3473 | #define CHECK_AND_PRINT(x) ((eeprom_ch_info[ch].flags & EEPROM_CHANNEL_##x) \ | ||
3474 | ? # x " " : "") | ||
3475 | |||
3476 | /** | ||
3477 | * iwl3945_init_channel_map - Set up driver's info for all possible channels | ||
3478 | */ | ||
3479 | static int iwl3945_init_channel_map(struct iwl_priv *priv) | ||
3480 | { | ||
3481 | int eeprom_ch_count = 0; | ||
3482 | const u8 *eeprom_ch_index = NULL; | ||
3483 | const struct iwl_eeprom_channel *eeprom_ch_info = NULL; | ||
3484 | int band, ch; | ||
3485 | struct iwl_channel_info *ch_info; | ||
3486 | |||
3487 | if (priv->channel_count) { | ||
3488 | IWL_DEBUG_INFO("Channel map already initialized.\n"); | ||
3489 | return 0; | ||
3490 | } | ||
3491 | |||
3492 | if (priv->eeprom39.version < 0x2f) { | ||
3493 | IWL_WARN(priv, "Unsupported EEPROM version: 0x%04X\n", | ||
3494 | priv->eeprom39.version); | ||
3495 | return -EINVAL; | ||
3496 | } | ||
3497 | |||
3498 | IWL_DEBUG_INFO("Initializing regulatory info from EEPROM\n"); | ||
3499 | |||
3500 | priv->channel_count = | ||
3501 | ARRAY_SIZE(iwl3945_eeprom_band_1) + | ||
3502 | ARRAY_SIZE(iwl3945_eeprom_band_2) + | ||
3503 | ARRAY_SIZE(iwl3945_eeprom_band_3) + | ||
3504 | ARRAY_SIZE(iwl3945_eeprom_band_4) + | ||
3505 | ARRAY_SIZE(iwl3945_eeprom_band_5); | ||
3506 | |||
3507 | IWL_DEBUG_INFO("Parsing data for %d channels.\n", priv->channel_count); | ||
3508 | |||
3509 | priv->channel_info = kzalloc(sizeof(struct iwl_channel_info) * | ||
3510 | priv->channel_count, GFP_KERNEL); | ||
3511 | if (!priv->channel_info) { | ||
3512 | IWL_ERR(priv, "Could not allocate channel_info\n"); | ||
3513 | priv->channel_count = 0; | ||
3514 | return -ENOMEM; | ||
3515 | } | ||
3516 | |||
3517 | ch_info = priv->channel_info; | ||
3518 | |||
3519 | /* Loop through the 5 EEPROM bands adding them in order to the | ||
3520 | * channel map we maintain (that contains additional information than | ||
3521 | * what just in the EEPROM) */ | ||
3522 | for (band = 1; band <= 5; band++) { | ||
3523 | |||
3524 | iwl3945_init_band_reference(priv, band, &eeprom_ch_count, | ||
3525 | &eeprom_ch_info, &eeprom_ch_index); | ||
3526 | |||
3527 | /* Loop through each band adding each of the channels */ | ||
3528 | for (ch = 0; ch < eeprom_ch_count; ch++) { | ||
3529 | ch_info->channel = eeprom_ch_index[ch]; | ||
3530 | ch_info->band = (band == 1) ? IEEE80211_BAND_2GHZ : | ||
3531 | IEEE80211_BAND_5GHZ; | ||
3532 | |||
3533 | /* permanently store EEPROM's channel regulatory flags | ||
3534 | * and max power in channel info database. */ | ||
3535 | ch_info->eeprom = eeprom_ch_info[ch]; | ||
3536 | |||
3537 | /* Copy the run-time flags so they are there even on | ||
3538 | * invalid channels */ | ||
3539 | ch_info->flags = eeprom_ch_info[ch].flags; | ||
3540 | |||
3541 | if (!(is_channel_valid(ch_info))) { | ||
3542 | IWL_DEBUG_INFO("Ch. %d Flags %x [%sGHz] - " | ||
3543 | "No traffic\n", | ||
3544 | ch_info->channel, | ||
3545 | ch_info->flags, | ||
3546 | is_channel_a_band(ch_info) ? | ||
3547 | "5.2" : "2.4"); | ||
3548 | ch_info++; | ||
3549 | continue; | ||
3550 | } | ||
3551 | |||
3552 | /* Initialize regulatory-based run-time data */ | ||
3553 | ch_info->max_power_avg = ch_info->curr_txpow = | ||
3554 | eeprom_ch_info[ch].max_power_avg; | ||
3555 | ch_info->scan_power = eeprom_ch_info[ch].max_power_avg; | ||
3556 | ch_info->min_power = 0; | ||
3557 | |||
3558 | IWL_DEBUG_INFO("Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x" | ||
3559 | " %ddBm): Ad-Hoc %ssupported\n", | ||
3560 | ch_info->channel, | ||
3561 | is_channel_a_band(ch_info) ? | ||
3562 | "5.2" : "2.4", | ||
3563 | CHECK_AND_PRINT(VALID), | ||
3564 | CHECK_AND_PRINT(IBSS), | ||
3565 | CHECK_AND_PRINT(ACTIVE), | ||
3566 | CHECK_AND_PRINT(RADAR), | ||
3567 | CHECK_AND_PRINT(WIDE), | ||
3568 | CHECK_AND_PRINT(DFS), | ||
3569 | eeprom_ch_info[ch].flags, | ||
3570 | eeprom_ch_info[ch].max_power_avg, | ||
3571 | ((eeprom_ch_info[ch]. | ||
3572 | flags & EEPROM_CHANNEL_IBSS) | ||
3573 | && !(eeprom_ch_info[ch]. | ||
3574 | flags & EEPROM_CHANNEL_RADAR)) | ||
3575 | ? "" : "not "); | ||
3576 | |||
3577 | /* Set the tx_power_user_lmt to the highest power | ||
3578 | * supported by any channel */ | ||
3579 | if (eeprom_ch_info[ch].max_power_avg > | ||
3580 | priv->tx_power_user_lmt) | ||
3581 | priv->tx_power_user_lmt = | ||
3582 | eeprom_ch_info[ch].max_power_avg; | ||
3583 | |||
3584 | ch_info++; | ||
3585 | } | ||
3586 | } | ||
3587 | |||
3588 | /* Set up txpower settings in driver for all channels */ | ||
3589 | if (iwl3945_txpower_set_from_eeprom(priv)) | ||
3590 | return -EIO; | ||
3591 | |||
3592 | return 0; | ||
3593 | } | ||
3594 | |||
3595 | /* | ||
3596 | * iwl3945_free_channel_map - undo allocations in iwl3945_init_channel_map | ||
3597 | */ | ||
3598 | static void iwl3945_free_channel_map(struct iwl_priv *priv) | ||
3599 | { | ||
3600 | kfree(priv->channel_info); | ||
3601 | priv->channel_count = 0; | ||
3602 | } | ||
3603 | |||
3604 | static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, | 3272 | static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, |
3605 | enum ieee80211_band band, | 3273 | enum ieee80211_band band, |
3606 | u8 is_active, u8 n_probes, | 3274 | u8 is_active, u8 n_probes, |
@@ -3631,7 +3299,7 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, | |||
3631 | 3299 | ||
3632 | scan_ch->channel = channels[i].hw_value; | 3300 | scan_ch->channel = channels[i].hw_value; |
3633 | 3301 | ||
3634 | ch_info = iwl3945_get_channel_info(priv, band, scan_ch->channel); | 3302 | ch_info = iwl_get_channel_info(priv, band, scan_ch->channel); |
3635 | if (!is_channel_valid(ch_info)) { | 3303 | if (!is_channel_valid(ch_info)) { |
3636 | IWL_DEBUG_SCAN("Channel %d is INVALID for this band.\n", | 3304 | IWL_DEBUG_SCAN("Channel %d is INVALID for this band.\n", |
3637 | scan_ch->channel); | 3305 | scan_ch->channel); |
@@ -3718,6 +3386,7 @@ static void iwl3945_init_hw_rates(struct iwl_priv *priv, | |||
3718 | /** | 3386 | /** |
3719 | * iwl3945_init_geos - Initialize mac80211's geo/channel info based from eeprom | 3387 | * iwl3945_init_geos - Initialize mac80211's geo/channel info based from eeprom |
3720 | */ | 3388 | */ |
3389 | #define IEEE80211_24GHZ_MAX_CHANNEL 14 | ||
3721 | static int iwl3945_init_geos(struct iwl_priv *priv) | 3390 | static int iwl3945_init_geos(struct iwl_priv *priv) |
3722 | { | 3391 | { |
3723 | struct iwl_channel_info *ch; | 3392 | struct iwl_channel_info *ch; |
@@ -3748,7 +3417,7 @@ static int iwl3945_init_geos(struct iwl_priv *priv) | |||
3748 | 3417 | ||
3749 | /* 5.2GHz channels start after the 2.4GHz channels */ | 3418 | /* 5.2GHz channels start after the 2.4GHz channels */ |
3750 | sband = &priv->bands[IEEE80211_BAND_5GHZ]; | 3419 | sband = &priv->bands[IEEE80211_BAND_5GHZ]; |
3751 | sband->channels = &channels[ARRAY_SIZE(iwl3945_eeprom_band_1)]; | 3420 | sband->channels = &channels[IEEE80211_24GHZ_MAX_CHANNEL]; |
3752 | /* just OFDM */ | 3421 | /* just OFDM */ |
3753 | sband->bitrates = &rates[IWL_FIRST_OFDM_RATE]; | 3422 | sband->bitrates = &rates[IWL_FIRST_OFDM_RATE]; |
3754 | sband->n_bitrates = IWL_RATE_COUNT - IWL_FIRST_OFDM_RATE; | 3423 | sband->n_bitrates = IWL_RATE_COUNT - IWL_FIRST_OFDM_RATE; |
@@ -5242,8 +4911,8 @@ static int iwl3945_mac_config(struct ieee80211_hw *hw, u32 changed) | |||
5242 | 4911 | ||
5243 | spin_lock_irqsave(&priv->lock, flags); | 4912 | spin_lock_irqsave(&priv->lock, flags); |
5244 | 4913 | ||
5245 | ch_info = iwl3945_get_channel_info(priv, conf->channel->band, | 4914 | ch_info = iwl_get_channel_info(priv, conf->channel->band, |
5246 | conf->channel->hw_value); | 4915 | conf->channel->hw_value); |
5247 | if (!is_channel_valid(ch_info)) { | 4916 | if (!is_channel_valid(ch_info)) { |
5248 | IWL_DEBUG_SCAN("Channel %d [%d] is INVALID for this band.\n", | 4917 | IWL_DEBUG_SCAN("Channel %d [%d] is INVALID for this band.\n", |
5249 | conf->channel->hw_value, conf->channel->band); | 4918 | conf->channel->hw_value, conf->channel->band); |
@@ -6423,6 +6092,7 @@ static struct ieee80211_ops iwl3945_hw_ops = { | |||
6423 | static int iwl3945_init_drv(struct iwl_priv *priv) | 6092 | static int iwl3945_init_drv(struct iwl_priv *priv) |
6424 | { | 6093 | { |
6425 | int ret; | 6094 | int ret; |
6095 | struct iwl3945_eeprom *eeprom = (struct iwl3945_eeprom *)priv->eeprom; | ||
6426 | 6096 | ||
6427 | priv->retry_rate = 1; | 6097 | priv->retry_rate = 1; |
6428 | priv->ibss_beacon = NULL; | 6098 | priv->ibss_beacon = NULL; |
@@ -6456,12 +6126,24 @@ static int iwl3945_init_drv(struct iwl_priv *priv) | |||
6456 | priv->power_mode = IWL39_POWER_AC; | 6126 | priv->power_mode = IWL39_POWER_AC; |
6457 | priv->tx_power_user_lmt = IWL_DEFAULT_TX_POWER; | 6127 | priv->tx_power_user_lmt = IWL_DEFAULT_TX_POWER; |
6458 | 6128 | ||
6459 | ret = iwl3945_init_channel_map(priv); | 6129 | if (eeprom->version < EEPROM_3945_EEPROM_VERSION) { |
6130 | IWL_WARN(priv, "Unsupported EEPROM version: 0x%04X\n", | ||
6131 | eeprom->version); | ||
6132 | ret = -EINVAL; | ||
6133 | goto err; | ||
6134 | } | ||
6135 | ret = iwl_init_channel_map(priv); | ||
6460 | if (ret) { | 6136 | if (ret) { |
6461 | IWL_ERR(priv, "initializing regulatory failed: %d\n", ret); | 6137 | IWL_ERR(priv, "initializing regulatory failed: %d\n", ret); |
6462 | goto err; | 6138 | goto err; |
6463 | } | 6139 | } |
6464 | 6140 | ||
6141 | /* Set up txpower settings in driver for all channels */ | ||
6142 | if (iwl3945_txpower_set_from_eeprom(priv)) { | ||
6143 | ret = -EIO; | ||
6144 | goto err_free_channel_map; | ||
6145 | } | ||
6146 | |||
6465 | ret = iwl3945_init_geos(priv); | 6147 | ret = iwl3945_init_geos(priv); |
6466 | if (ret) { | 6148 | if (ret) { |
6467 | IWL_ERR(priv, "initializing geos failed: %d\n", ret); | 6149 | IWL_ERR(priv, "initializing geos failed: %d\n", ret); |
@@ -6471,7 +6153,7 @@ static int iwl3945_init_drv(struct iwl_priv *priv) | |||
6471 | return 0; | 6153 | return 0; |
6472 | 6154 | ||
6473 | err_free_channel_map: | 6155 | err_free_channel_map: |
6474 | iwl3945_free_channel_map(priv); | 6156 | iwl_free_channel_map(priv); |
6475 | err: | 6157 | err: |
6476 | return ret; | 6158 | return ret; |
6477 | } | 6159 | } |
@@ -6482,6 +6164,7 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
6482 | struct iwl_priv *priv; | 6164 | struct iwl_priv *priv; |
6483 | struct ieee80211_hw *hw; | 6165 | struct ieee80211_hw *hw; |
6484 | struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); | 6166 | struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data); |
6167 | struct iwl3945_eeprom *eeprom; | ||
6485 | unsigned long flags; | 6168 | unsigned long flags; |
6486 | 6169 | ||
6487 | /*********************** | 6170 | /*********************** |
@@ -6597,13 +6280,14 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
6597 | * ********************/ | 6280 | * ********************/ |
6598 | 6281 | ||
6599 | /* Read the EEPROM */ | 6282 | /* Read the EEPROM */ |
6600 | err = iwl3945_eeprom_init(priv); | 6283 | err = iwl_eeprom_init(priv); |
6601 | if (err) { | 6284 | if (err) { |
6602 | IWL_ERR(priv, "Unable to init EEPROM\n"); | 6285 | IWL_ERR(priv, "Unable to init EEPROM\n"); |
6603 | goto out_remove_sysfs; | 6286 | goto out_remove_sysfs; |
6604 | } | 6287 | } |
6605 | /* MAC Address location in EEPROM same for 3945/4965 */ | 6288 | /* MAC Address location in EEPROM same for 3945/4965 */ |
6606 | get_eeprom_mac(priv, priv->mac_addr); | 6289 | eeprom = (struct iwl3945_eeprom *)priv->eeprom; |
6290 | memcpy(priv->mac_addr, eeprom->mac_address, ETH_ALEN); | ||
6607 | IWL_DEBUG_INFO("MAC address: %pM\n", priv->mac_addr); | 6291 | IWL_DEBUG_INFO("MAC address: %pM\n", priv->mac_addr); |
6608 | SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); | 6292 | SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); |
6609 | 6293 | ||
@@ -6776,7 +6460,7 @@ static void __devexit iwl3945_pci_remove(struct pci_dev *pdev) | |||
6776 | pci_disable_device(pdev); | 6460 | pci_disable_device(pdev); |
6777 | pci_set_drvdata(pdev, NULL); | 6461 | pci_set_drvdata(pdev, NULL); |
6778 | 6462 | ||
6779 | iwl3945_free_channel_map(priv); | 6463 | iwl_free_channel_map(priv); |
6780 | iwl3945_free_geos(priv); | 6464 | iwl3945_free_geos(priv); |
6781 | kfree(priv->scan); | 6465 | kfree(priv->scan); |
6782 | if (priv->ibss_beacon) | 6466 | if (priv->ibss_beacon) |