diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2008-04-21 18:41:52 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-05-07 15:02:15 -0400 |
commit | 073d3f5f1b3b6512eb82a3d40c84dedb14dc6f73 (patch) | |
tree | 49ef76bf1d863a231b0a672c2c34fb44f63fad9c | |
parent | 5da4b55f78fb2ed40926b775d4f7c791594ecbd7 (diff) |
iwlwifi: changing EEPROM layout handling
This patch
1. changes the current EEPROM handling through a single HW struct
layout representation, to more general approach, treating the EEPROM
image as a flat bytes array, handling this image through ops functions
and offsets.
2. Eeprom is dynamically allocated accroding HW type
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Ron Rindjunsky <ron.rindjunsky@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-4965-hw.h | 3 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-4965.c | 62 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-4965.h | 9 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-core.h | 1 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-eeprom.c | 101 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-eeprom.h | 155 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl4965-base.c | 5 |
7 files changed, 188 insertions, 148 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h index 1a66b508a8ea..855a006c5e5b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965-hw.h +++ b/drivers/net/wireless/iwlwifi/iwl-4965-hw.h | |||
@@ -69,6 +69,9 @@ | |||
69 | #ifndef __iwl_4965_hw_h__ | 69 | #ifndef __iwl_4965_hw_h__ |
70 | #define __iwl_4965_hw_h__ | 70 | #define __iwl_4965_hw_h__ |
71 | 71 | ||
72 | /* EERPROM */ | ||
73 | #define IWL4965_EEPROM_IMG_SIZE 1024 | ||
74 | |||
72 | /* | 75 | /* |
73 | * uCode queue management definitions ... | 76 | * uCode queue management definitions ... |
74 | * Queue #4 is the command queue for 3945 and 4965; map it to Tx FIFO chnl 4. | 77 | * Queue #4 is the command queue for 3945 and 4965; map it to Tx FIFO chnl 4. |
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c index d051aac558f2..7886596b62c7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c | |||
@@ -699,8 +699,9 @@ int iwl4965_hw_nic_init(struct iwl_priv *priv) | |||
699 | unsigned long flags; | 699 | unsigned long flags; |
700 | struct iwl4965_rx_queue *rxq = &priv->rxq; | 700 | struct iwl4965_rx_queue *rxq = &priv->rxq; |
701 | u8 rev_id; | 701 | u8 rev_id; |
702 | u32 val; | ||
703 | u8 val_link; | 702 | u8 val_link; |
703 | u16 sku_cap; | ||
704 | u32 val; | ||
704 | 705 | ||
705 | /* nic_init */ | 706 | /* nic_init */ |
706 | spin_lock_irqsave(&priv->lock, flags); | 707 | spin_lock_irqsave(&priv->lock, flags); |
@@ -759,7 +760,8 @@ int iwl4965_hw_nic_init(struct iwl_priv *priv) | |||
759 | 760 | ||
760 | spin_unlock_irqrestore(&priv->lock, flags); | 761 | spin_unlock_irqrestore(&priv->lock, flags); |
761 | 762 | ||
762 | if (priv->eeprom.calib_version < EEPROM_TX_POWER_VERSION_NEW) { | 763 | if (iwl_eeprom_query16(priv, EEPROM_4965_CALIB_VERSION_OFFSET) < |
764 | EEPROM_4965_TX_POWER_VERSION) { | ||
763 | IWL_ERROR("Older EEPROM detected! Aborting.\n"); | 765 | IWL_ERROR("Older EEPROM detected! Aborting.\n"); |
764 | return -EINVAL; | 766 | return -EINVAL; |
765 | } | 767 | } |
@@ -816,6 +818,10 @@ int iwl4965_hw_nic_init(struct iwl_priv *priv) | |||
816 | rxq->need_update = 1; | 818 | rxq->need_update = 1; |
817 | iwl4965_rx_queue_update_write_ptr(priv, rxq); | 819 | iwl4965_rx_queue_update_write_ptr(priv, rxq); |
818 | 820 | ||
821 | /* init the txpower calibration pointer */ | ||
822 | priv->calib_info = (struct iwl_eeprom_calib_info *) | ||
823 | iwl_eeprom_query_addr(priv, EEPROM_4965_CALIB_TXPOWER_OFFSET); | ||
824 | |||
819 | spin_unlock_irqrestore(&priv->lock, flags); | 825 | spin_unlock_irqrestore(&priv->lock, flags); |
820 | 826 | ||
821 | /* Allocate and init all Tx and Command queues */ | 827 | /* Allocate and init all Tx and Command queues */ |
@@ -823,10 +829,11 @@ int iwl4965_hw_nic_init(struct iwl_priv *priv) | |||
823 | if (rc) | 829 | if (rc) |
824 | return rc; | 830 | return rc; |
825 | 831 | ||
826 | if (priv->eeprom.sku_cap & EEPROM_SKU_CAP_SW_RF_KILL_ENABLE) | 832 | sku_cap = iwl_eeprom_query16(priv, EEPROM_SKU_CAP); |
833 | if (sku_cap & EEPROM_SKU_CAP_SW_RF_KILL_ENABLE) | ||
827 | IWL_DEBUG_RF_KILL("SW RF KILL supported in EEPROM.\n"); | 834 | IWL_DEBUG_RF_KILL("SW RF KILL supported in EEPROM.\n"); |
828 | 835 | ||
829 | if (priv->eeprom.sku_cap & EEPROM_SKU_CAP_HW_RF_KILL_ENABLE) | 836 | if (sku_cap & EEPROM_SKU_CAP_HW_RF_KILL_ENABLE) |
830 | IWL_DEBUG_RF_KILL("HW RF KILL supported in EEPROM.\n"); | 837 | IWL_DEBUG_RF_KILL("HW RF KILL supported in EEPROM.\n"); |
831 | 838 | ||
832 | set_bit(STATUS_INIT, &priv->status); | 839 | set_bit(STATUS_INIT, &priv->status); |
@@ -1542,11 +1549,11 @@ static u32 iwl4965_get_sub_band(const struct iwl_priv *priv, u32 channel) | |||
1542 | s32 b = -1; | 1549 | s32 b = -1; |
1543 | 1550 | ||
1544 | for (b = 0; b < EEPROM_TX_POWER_BANDS; b++) { | 1551 | for (b = 0; b < EEPROM_TX_POWER_BANDS; b++) { |
1545 | if (priv->eeprom.calib_info.band_info[b].ch_from == 0) | 1552 | if (priv->calib_info->band_info[b].ch_from == 0) |
1546 | continue; | 1553 | continue; |
1547 | 1554 | ||
1548 | if ((channel >= priv->eeprom.calib_info.band_info[b].ch_from) | 1555 | if ((channel >= priv->calib_info->band_info[b].ch_from) |
1549 | && (channel <= priv->eeprom.calib_info.band_info[b].ch_to)) | 1556 | && (channel <= priv->calib_info->band_info[b].ch_to)) |
1550 | break; | 1557 | break; |
1551 | } | 1558 | } |
1552 | 1559 | ||
@@ -1574,14 +1581,14 @@ static s32 iwl4965_interpolate_value(s32 x, s32 x1, s32 y1, s32 x2, s32 y2) | |||
1574 | * in channel number. | 1581 | * in channel number. |
1575 | */ | 1582 | */ |
1576 | static int iwl4965_interpolate_chan(struct iwl_priv *priv, u32 channel, | 1583 | static int iwl4965_interpolate_chan(struct iwl_priv *priv, u32 channel, |
1577 | struct iwl4965_eeprom_calib_ch_info *chan_info) | 1584 | struct iwl_eeprom_calib_ch_info *chan_info) |
1578 | { | 1585 | { |
1579 | s32 s = -1; | 1586 | s32 s = -1; |
1580 | u32 c; | 1587 | u32 c; |
1581 | u32 m; | 1588 | u32 m; |
1582 | const struct iwl4965_eeprom_calib_measure *m1; | 1589 | const struct iwl_eeprom_calib_measure *m1; |
1583 | const struct iwl4965_eeprom_calib_measure *m2; | 1590 | const struct iwl_eeprom_calib_measure *m2; |
1584 | struct iwl4965_eeprom_calib_measure *omeas; | 1591 | struct iwl_eeprom_calib_measure *omeas; |
1585 | u32 ch_i1; | 1592 | u32 ch_i1; |
1586 | u32 ch_i2; | 1593 | u32 ch_i2; |
1587 | 1594 | ||
@@ -1591,8 +1598,8 @@ static int iwl4965_interpolate_chan(struct iwl_priv *priv, u32 channel, | |||
1591 | return -1; | 1598 | return -1; |
1592 | } | 1599 | } |
1593 | 1600 | ||
1594 | ch_i1 = priv->eeprom.calib_info.band_info[s].ch1.ch_num; | 1601 | ch_i1 = priv->calib_info->band_info[s].ch1.ch_num; |
1595 | ch_i2 = priv->eeprom.calib_info.band_info[s].ch2.ch_num; | 1602 | ch_i2 = priv->calib_info->band_info[s].ch2.ch_num; |
1596 | chan_info->ch_num = (u8) channel; | 1603 | chan_info->ch_num = (u8) channel; |
1597 | 1604 | ||
1598 | IWL_DEBUG_TXPOWER("channel %d subband %d factory cal ch %d & %d\n", | 1605 | IWL_DEBUG_TXPOWER("channel %d subband %d factory cal ch %d & %d\n", |
@@ -1600,9 +1607,9 @@ static int iwl4965_interpolate_chan(struct iwl_priv *priv, u32 channel, | |||
1600 | 1607 | ||
1601 | for (c = 0; c < EEPROM_TX_POWER_TX_CHAINS; c++) { | 1608 | for (c = 0; c < EEPROM_TX_POWER_TX_CHAINS; c++) { |
1602 | for (m = 0; m < EEPROM_TX_POWER_MEASUREMENTS; m++) { | 1609 | for (m = 0; m < EEPROM_TX_POWER_MEASUREMENTS; m++) { |
1603 | m1 = &(priv->eeprom.calib_info.band_info[s].ch1. | 1610 | m1 = &(priv->calib_info->band_info[s].ch1. |
1604 | measurements[c][m]); | 1611 | measurements[c][m]); |
1605 | m2 = &(priv->eeprom.calib_info.band_info[s].ch2. | 1612 | m2 = &(priv->calib_info->band_info[s].ch2. |
1606 | measurements[c][m]); | 1613 | measurements[c][m]); |
1607 | omeas = &(chan_info->measurements[c][m]); | 1614 | omeas = &(chan_info->measurements[c][m]); |
1608 | 1615 | ||
@@ -1921,8 +1928,8 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, | |||
1921 | int i; | 1928 | int i; |
1922 | int c; | 1929 | int c; |
1923 | const struct iwl_channel_info *ch_info = NULL; | 1930 | const struct iwl_channel_info *ch_info = NULL; |
1924 | struct iwl4965_eeprom_calib_ch_info ch_eeprom_info; | 1931 | struct iwl_eeprom_calib_ch_info ch_eeprom_info; |
1925 | const struct iwl4965_eeprom_calib_measure *measurement; | 1932 | const struct iwl_eeprom_calib_measure *measurement; |
1926 | s16 voltage; | 1933 | s16 voltage; |
1927 | s32 init_voltage; | 1934 | s32 init_voltage; |
1928 | s32 voltage_compensation; | 1935 | s32 voltage_compensation; |
@@ -1979,9 +1986,9 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, | |||
1979 | /* hardware txpower limits ... | 1986 | /* hardware txpower limits ... |
1980 | * saturation (clipping distortion) txpowers are in half-dBm */ | 1987 | * saturation (clipping distortion) txpowers are in half-dBm */ |
1981 | if (band) | 1988 | if (band) |
1982 | saturation_power = priv->eeprom.calib_info.saturation_power24; | 1989 | saturation_power = priv->calib_info->saturation_power24; |
1983 | else | 1990 | else |
1984 | saturation_power = priv->eeprom.calib_info.saturation_power52; | 1991 | saturation_power = priv->calib_info->saturation_power52; |
1985 | 1992 | ||
1986 | if (saturation_power < IWL_TX_POWER_SATURATION_MIN || | 1993 | if (saturation_power < IWL_TX_POWER_SATURATION_MIN || |
1987 | saturation_power > IWL_TX_POWER_SATURATION_MAX) { | 1994 | saturation_power > IWL_TX_POWER_SATURATION_MAX) { |
@@ -2011,7 +2018,7 @@ static int iwl4965_fill_txpower_tbl(struct iwl_priv *priv, u8 band, u16 channel, | |||
2011 | iwl4965_interpolate_chan(priv, channel, &ch_eeprom_info); | 2018 | iwl4965_interpolate_chan(priv, channel, &ch_eeprom_info); |
2012 | 2019 | ||
2013 | /* calculate tx gain adjustment based on power supply voltage */ | 2020 | /* calculate tx gain adjustment based on power supply voltage */ |
2014 | voltage = priv->eeprom.calib_info.voltage; | 2021 | voltage = priv->calib_info->voltage; |
2015 | init_voltage = (s32)le32_to_cpu(priv->card_alive_init.voltage); | 2022 | init_voltage = (s32)le32_to_cpu(priv->card_alive_init.voltage); |
2016 | voltage_compensation = | 2023 | voltage_compensation = |
2017 | iwl4965_get_voltage_compensation(voltage, init_voltage); | 2024 | iwl4965_get_voltage_compensation(voltage, init_voltage); |
@@ -2467,14 +2474,14 @@ int iwl4965_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, void *ptr, | |||
2467 | 2474 | ||
2468 | static void iwl4965_hw_card_show_info(struct iwl_priv *priv) | 2475 | static void iwl4965_hw_card_show_info(struct iwl_priv *priv) |
2469 | { | 2476 | { |
2470 | u16 hw_version = priv->eeprom.board_revision_4965; | 2477 | u16 hw_version = iwl_eeprom_query16(priv, EEPROM_4965_BOARD_REVISION); |
2471 | 2478 | ||
2472 | IWL_DEBUG_INFO("4965ABGN HW Version %u.%u.%u\n", | 2479 | IWL_DEBUG_INFO("4965ABGN HW Version %u.%u.%u\n", |
2473 | ((hw_version >> 8) & 0x0F), | 2480 | ((hw_version >> 8) & 0x0F), |
2474 | ((hw_version >> 8) >> 4), (hw_version & 0x00FF)); | 2481 | ((hw_version >> 8) >> 4), (hw_version & 0x00FF)); |
2475 | 2482 | ||
2476 | IWL_DEBUG_INFO("4965ABGN PBA Number %.16s\n", | 2483 | IWL_DEBUG_INFO("4965ABGN PBA Number %.16s\n", |
2477 | priv->eeprom.board_pba_number_4965); | 2484 | &priv->eeprom[EEPROM_4965_BOARD_PBA]); |
2478 | } | 2485 | } |
2479 | 2486 | ||
2480 | #define IWL_TX_CRC_SIZE 4 | 2487 | #define IWL_TX_CRC_SIZE 4 |
@@ -4340,9 +4347,19 @@ static struct iwl_lib_ops iwl4965_lib = { | |||
4340 | .set_pwr_src = iwl4965_set_pwr_src, | 4347 | .set_pwr_src = iwl4965_set_pwr_src, |
4341 | }, | 4348 | }, |
4342 | .eeprom_ops = { | 4349 | .eeprom_ops = { |
4350 | .regulatory_bands = { | ||
4351 | EEPROM_REGULATORY_BAND_1_CHANNELS, | ||
4352 | EEPROM_REGULATORY_BAND_2_CHANNELS, | ||
4353 | EEPROM_REGULATORY_BAND_3_CHANNELS, | ||
4354 | EEPROM_REGULATORY_BAND_4_CHANNELS, | ||
4355 | EEPROM_REGULATORY_BAND_5_CHANNELS, | ||
4356 | EEPROM_4965_REGULATORY_BAND_24_FAT_CHANNELS, | ||
4357 | EEPROM_4965_REGULATORY_BAND_52_FAT_CHANNELS | ||
4358 | }, | ||
4343 | .verify_signature = iwlcore_eeprom_verify_signature, | 4359 | .verify_signature = iwlcore_eeprom_verify_signature, |
4344 | .acquire_semaphore = iwlcore_eeprom_acquire_semaphore, | 4360 | .acquire_semaphore = iwlcore_eeprom_acquire_semaphore, |
4345 | .release_semaphore = iwlcore_eeprom_release_semaphore, | 4361 | .release_semaphore = iwlcore_eeprom_release_semaphore, |
4362 | .query_addr = iwlcore_eeprom_query_addr, | ||
4346 | }, | 4363 | }, |
4347 | .radio_kill_sw = iwl4965_radio_kill_sw, | 4364 | .radio_kill_sw = iwl4965_radio_kill_sw, |
4348 | .set_power = iwl4965_set_power, | 4365 | .set_power = iwl4965_set_power, |
@@ -4359,6 +4376,7 @@ struct iwl_cfg iwl4965_agn_cfg = { | |||
4359 | .name = "4965AGN", | 4376 | .name = "4965AGN", |
4360 | .fw_name = "iwlwifi-4965" IWL4965_UCODE_API ".ucode", | 4377 | .fw_name = "iwlwifi-4965" IWL4965_UCODE_API ".ucode", |
4361 | .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, | 4378 | .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N, |
4379 | .eeprom_size = IWL4965_EEPROM_IMG_SIZE, | ||
4362 | .ops = &iwl4965_ops, | 4380 | .ops = &iwl4965_ops, |
4363 | .mod_params = &iwl4965_mod_params, | 4381 | .mod_params = &iwl4965_mod_params, |
4364 | }; | 4382 | }; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.h b/drivers/net/wireless/iwlwifi/iwl-4965.h index 0550d12e5c60..35a67cdf707c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965.h +++ b/drivers/net/wireless/iwlwifi/iwl-4965.h | |||
@@ -200,9 +200,9 @@ enum { | |||
200 | struct iwl_channel_info { | 200 | struct iwl_channel_info { |
201 | struct iwl4965_channel_tgd_info tgd; | 201 | struct iwl4965_channel_tgd_info tgd; |
202 | struct iwl4965_channel_tgh_info tgh; | 202 | struct iwl4965_channel_tgh_info tgh; |
203 | struct iwl4965_eeprom_channel eeprom; /* EEPROM regulatory limit */ | 203 | struct iwl_eeprom_channel eeprom; /* EEPROM regulatory limit */ |
204 | struct iwl4965_eeprom_channel fat_eeprom; /* EEPROM regulatory limit for | 204 | struct iwl_eeprom_channel fat_eeprom; /* EEPROM regulatory limit for |
205 | * FAT channel */ | 205 | * FAT channel */ |
206 | 206 | ||
207 | u8 channel; /* channel number */ | 207 | u8 channel; /* channel number */ |
208 | u8 flags; /* flags copied from EEPROM */ | 208 | u8 flags; /* flags copied from EEPROM */ |
@@ -1122,7 +1122,8 @@ struct iwl_priv { | |||
1122 | struct list_head ibss_mac_hash[IWL_IBSS_MAC_HASH_SIZE]; | 1122 | struct list_head ibss_mac_hash[IWL_IBSS_MAC_HASH_SIZE]; |
1123 | 1123 | ||
1124 | /* eeprom */ | 1124 | /* eeprom */ |
1125 | struct iwl4965_eeprom eeprom; | 1125 | u8 *eeprom; |
1126 | struct iwl_eeprom_calib_info *calib_info; | ||
1126 | 1127 | ||
1127 | enum ieee80211_if_types iw_mode; | 1128 | enum ieee80211_if_types iw_mode; |
1128 | 1129 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index 3d113dce8994..79e97935bbb6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h | |||
@@ -146,6 +146,7 @@ struct iwl_cfg { | |||
146 | const char *name; | 146 | const char *name; |
147 | const char *fw_name; | 147 | const char *fw_name; |
148 | unsigned int sku; | 148 | unsigned int sku; |
149 | int eeprom_size; | ||
149 | const struct iwl_ops *ops; | 150 | const struct iwl_ops *ops; |
150 | const struct iwl_mod_params *mod_params; | 151 | const struct iwl_mod_params *mod_params; |
151 | }; | 152 | }; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.c b/drivers/net/wireless/iwlwifi/iwl-eeprom.c index a07d5dcb7abc..a436f877882b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.c +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.c | |||
@@ -193,6 +193,12 @@ void iwlcore_eeprom_release_semaphore(struct iwl_priv *priv) | |||
193 | } | 193 | } |
194 | EXPORT_SYMBOL(iwlcore_eeprom_release_semaphore); | 194 | EXPORT_SYMBOL(iwlcore_eeprom_release_semaphore); |
195 | 195 | ||
196 | const u8 *iwlcore_eeprom_query_addr(const struct iwl_priv *priv, size_t offset) | ||
197 | { | ||
198 | BUG_ON(offset >= priv->cfg->eeprom_size); | ||
199 | return &priv->eeprom[offset]; | ||
200 | } | ||
201 | EXPORT_SYMBOL(iwlcore_eeprom_query_addr); | ||
196 | 202 | ||
197 | /** | 203 | /** |
198 | * iwl_eeprom_init - read EEPROM contents | 204 | * iwl_eeprom_init - read EEPROM contents |
@@ -203,30 +209,35 @@ EXPORT_SYMBOL(iwlcore_eeprom_release_semaphore); | |||
203 | */ | 209 | */ |
204 | int iwl_eeprom_init(struct iwl_priv *priv) | 210 | int iwl_eeprom_init(struct iwl_priv *priv) |
205 | { | 211 | { |
206 | u16 *e = (u16 *)&priv->eeprom; | 212 | u16 *e; |
207 | u32 gp = iwl_read32(priv, CSR_EEPROM_GP); | 213 | u32 gp = iwl_read32(priv, CSR_EEPROM_GP); |
208 | u32 r; | 214 | u32 r; |
209 | int sz = sizeof(priv->eeprom); | 215 | int sz = priv->cfg->eeprom_size; |
210 | int ret; | 216 | int ret; |
211 | int i; | 217 | int i; |
212 | u16 addr; | 218 | u16 addr; |
213 | 219 | ||
214 | /* The EEPROM structure has several padding buffers within it | 220 | /* allocate eeprom */ |
215 | * and when adding new EEPROM maps is subject to programmer errors | 221 | priv->eeprom = kzalloc(sz, GFP_KERNEL); |
216 | * which may be very difficult to identify without explicitly | 222 | if (!priv->eeprom) { |
217 | * checking the resulting size of the eeprom map. */ | 223 | ret = -ENOMEM; |
218 | BUILD_BUG_ON(sizeof(priv->eeprom) != IWL_EEPROM_IMAGE_SIZE); | 224 | goto alloc_err; |
225 | } | ||
226 | e = (u16 *)priv->eeprom; | ||
219 | 227 | ||
220 | if ((gp & CSR_EEPROM_GP_VALID_MSK) == CSR_EEPROM_GP_BAD_SIGNATURE) { | 228 | ret = priv->cfg->ops->lib->eeprom_ops.verify_signature(priv); |
229 | if (ret < 0) { | ||
221 | IWL_ERROR("EEPROM not found, EEPROM_GP=0x%08x", gp); | 230 | IWL_ERROR("EEPROM not found, EEPROM_GP=0x%08x", gp); |
222 | return -ENOENT; | 231 | ret = -ENOENT; |
232 | goto err; | ||
223 | } | 233 | } |
224 | 234 | ||
225 | /* Make sure driver (instead of uCode) is allowed to read EEPROM */ | 235 | /* Make sure driver (instead of uCode) is allowed to read EEPROM */ |
226 | ret = priv->cfg->ops->lib->eeprom_ops.acquire_semaphore(priv); | 236 | ret = priv->cfg->ops->lib->eeprom_ops.acquire_semaphore(priv); |
227 | if (ret < 0) { | 237 | if (ret < 0) { |
228 | IWL_ERROR("Failed to acquire EEPROM semaphore.\n"); | 238 | IWL_ERROR("Failed to acquire EEPROM semaphore.\n"); |
229 | return -ENOENT; | 239 | ret = -ENOENT; |
240 | goto err; | ||
230 | } | 241 | } |
231 | 242 | ||
232 | /* eeprom is an array of 16bit values */ | 243 | /* eeprom is an array of 16bit values */ |
@@ -250,61 +261,93 @@ int iwl_eeprom_init(struct iwl_priv *priv) | |||
250 | e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16)); | 261 | e[addr / 2] = le16_to_cpu((__force __le16)(r >> 16)); |
251 | } | 262 | } |
252 | ret = 0; | 263 | ret = 0; |
253 | |||
254 | done: | 264 | done: |
255 | priv->cfg->ops->lib->eeprom_ops.release_semaphore(priv); | 265 | priv->cfg->ops->lib->eeprom_ops.release_semaphore(priv); |
266 | err: | ||
267 | if (ret) | ||
268 | kfree(priv->eeprom); | ||
269 | alloc_err: | ||
256 | return ret; | 270 | return ret; |
257 | } | 271 | } |
258 | EXPORT_SYMBOL(iwl_eeprom_init); | 272 | EXPORT_SYMBOL(iwl_eeprom_init); |
259 | 273 | ||
274 | void iwl_eeprom_free(struct iwl_priv *priv) | ||
275 | { | ||
276 | if(priv->eeprom) | ||
277 | kfree(priv->eeprom); | ||
278 | priv->eeprom = NULL; | ||
279 | } | ||
280 | EXPORT_SYMBOL(iwl_eeprom_free); | ||
281 | |||
282 | |||
283 | const u8 *iwl_eeprom_query_addr(const struct iwl_priv *priv, size_t offset) | ||
284 | { | ||
285 | return priv->cfg->ops->lib->eeprom_ops.query_addr(priv, offset); | ||
286 | } | ||
287 | EXPORT_SYMBOL(iwl_eeprom_query_addr); | ||
288 | |||
289 | u16 iwl_eeprom_query16(const struct iwl_priv *priv, size_t offset) | ||
290 | { | ||
291 | return (u16)priv->eeprom[offset] | ((u16)priv->eeprom[offset + 1] << 8); | ||
292 | } | ||
293 | EXPORT_SYMBOL(iwl_eeprom_query16); | ||
260 | 294 | ||
261 | void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac) | 295 | void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac) |
262 | { | 296 | { |
263 | memcpy(mac, priv->eeprom.mac_address, 6); | 297 | const u8 *addr = priv->cfg->ops->lib->eeprom_ops.query_addr(priv, |
298 | EEPROM_MAC_ADDRESS); | ||
299 | memcpy(mac, addr, ETH_ALEN); | ||
264 | } | 300 | } |
265 | EXPORT_SYMBOL(iwl_eeprom_get_mac); | 301 | EXPORT_SYMBOL(iwl_eeprom_get_mac); |
266 | 302 | ||
267 | static void iwl_init_band_reference(const struct iwl_priv *priv, | 303 | static void iwl_init_band_reference(const struct iwl_priv *priv, |
268 | int band, | 304 | int eep_band, int *eeprom_ch_count, |
269 | int *eeprom_ch_count, | 305 | const struct iwl_eeprom_channel **eeprom_ch_info, |
270 | const struct iwl4965_eeprom_channel | 306 | const u8 **eeprom_ch_index) |
271 | **eeprom_ch_info, | ||
272 | const u8 **eeprom_ch_index) | ||
273 | { | 307 | { |
274 | switch (band) { | 308 | u32 offset = priv->cfg->ops->lib-> |
309 | eeprom_ops.regulatory_bands[eep_band - 1]; | ||
310 | switch (eep_band) { | ||
275 | case 1: /* 2.4GHz band */ | 311 | case 1: /* 2.4GHz band */ |
276 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_1); | 312 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_1); |
277 | *eeprom_ch_info = priv->eeprom.band_1_channels; | 313 | *eeprom_ch_info = (struct iwl_eeprom_channel *) |
314 | iwl_eeprom_query_addr(priv, offset); | ||
278 | *eeprom_ch_index = iwl_eeprom_band_1; | 315 | *eeprom_ch_index = iwl_eeprom_band_1; |
279 | break; | 316 | break; |
280 | case 2: /* 4.9GHz band */ | 317 | case 2: /* 4.9GHz band */ |
281 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_2); | 318 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_2); |
282 | *eeprom_ch_info = priv->eeprom.band_2_channels; | 319 | *eeprom_ch_info = (struct iwl_eeprom_channel *) |
320 | iwl_eeprom_query_addr(priv, offset); | ||
283 | *eeprom_ch_index = iwl_eeprom_band_2; | 321 | *eeprom_ch_index = iwl_eeprom_band_2; |
284 | break; | 322 | break; |
285 | case 3: /* 5.2GHz band */ | 323 | case 3: /* 5.2GHz band */ |
286 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_3); | 324 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_3); |
287 | *eeprom_ch_info = priv->eeprom.band_3_channels; | 325 | *eeprom_ch_info = (struct iwl_eeprom_channel *) |
326 | iwl_eeprom_query_addr(priv, offset); | ||
288 | *eeprom_ch_index = iwl_eeprom_band_3; | 327 | *eeprom_ch_index = iwl_eeprom_band_3; |
289 | break; | 328 | break; |
290 | case 4: /* 5.5GHz band */ | 329 | case 4: /* 5.5GHz band */ |
291 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_4); | 330 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_4); |
292 | *eeprom_ch_info = priv->eeprom.band_4_channels; | 331 | *eeprom_ch_info = (struct iwl_eeprom_channel *) |
332 | iwl_eeprom_query_addr(priv, offset); | ||
293 | *eeprom_ch_index = iwl_eeprom_band_4; | 333 | *eeprom_ch_index = iwl_eeprom_band_4; |
294 | break; | 334 | break; |
295 | case 5: /* 5.7GHz band */ | 335 | case 5: /* 5.7GHz band */ |
296 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_5); | 336 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_5); |
297 | *eeprom_ch_info = priv->eeprom.band_5_channels; | 337 | *eeprom_ch_info = (struct iwl_eeprom_channel *) |
338 | iwl_eeprom_query_addr(priv, offset); | ||
298 | *eeprom_ch_index = iwl_eeprom_band_5; | 339 | *eeprom_ch_index = iwl_eeprom_band_5; |
299 | break; | 340 | break; |
300 | case 6: /* 2.4GHz FAT channels */ | 341 | case 6: /* 2.4GHz FAT channels */ |
301 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_6); | 342 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_6); |
302 | *eeprom_ch_info = priv->eeprom.band_24_channels; | 343 | *eeprom_ch_info = (struct iwl_eeprom_channel *) |
344 | iwl_eeprom_query_addr(priv, offset); | ||
303 | *eeprom_ch_index = iwl_eeprom_band_6; | 345 | *eeprom_ch_index = iwl_eeprom_band_6; |
304 | break; | 346 | break; |
305 | case 7: /* 5 GHz FAT channels */ | 347 | case 7: /* 5 GHz FAT channels */ |
306 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_7); | 348 | *eeprom_ch_count = ARRAY_SIZE(iwl_eeprom_band_7); |
307 | *eeprom_ch_info = priv->eeprom.band_52_channels; | 349 | *eeprom_ch_info = (struct iwl_eeprom_channel *) |
350 | iwl_eeprom_query_addr(priv, offset); | ||
308 | *eeprom_ch_index = iwl_eeprom_band_7; | 351 | *eeprom_ch_index = iwl_eeprom_band_7; |
309 | break; | 352 | break; |
310 | default: | 353 | default: |
@@ -323,7 +366,7 @@ static void iwl_init_band_reference(const struct iwl_priv *priv, | |||
323 | */ | 366 | */ |
324 | static int iwl4965_set_fat_chan_info(struct iwl_priv *priv, | 367 | static int iwl4965_set_fat_chan_info(struct iwl_priv *priv, |
325 | enum ieee80211_band band, u16 channel, | 368 | enum ieee80211_band band, u16 channel, |
326 | const struct iwl4965_eeprom_channel *eeprom_ch, | 369 | const struct iwl_eeprom_channel *eeprom_ch, |
327 | u8 fat_extension_channel) | 370 | u8 fat_extension_channel) |
328 | { | 371 | { |
329 | struct iwl_channel_info *ch_info; | 372 | struct iwl_channel_info *ch_info; |
@@ -372,7 +415,7 @@ int iwl_init_channel_map(struct iwl_priv *priv) | |||
372 | { | 415 | { |
373 | int eeprom_ch_count = 0; | 416 | int eeprom_ch_count = 0; |
374 | const u8 *eeprom_ch_index = NULL; | 417 | const u8 *eeprom_ch_index = NULL; |
375 | const struct iwl4965_eeprom_channel *eeprom_ch_info = NULL; | 418 | const struct iwl_eeprom_channel *eeprom_ch_info = NULL; |
376 | int band, ch; | 419 | int band, ch; |
377 | struct iwl_channel_info *ch_info; | 420 | struct iwl_channel_info *ch_info; |
378 | 421 | ||
@@ -381,9 +424,9 @@ int iwl_init_channel_map(struct iwl_priv *priv) | |||
381 | return 0; | 424 | return 0; |
382 | } | 425 | } |
383 | 426 | ||
384 | if (priv->eeprom.version < 0x2f) { | 427 | if (iwl_eeprom_query16(priv, EEPROM_VERSION) < 0x2f) { |
385 | IWL_WARNING("Unsupported EEPROM version: 0x%04X\n", | 428 | IWL_WARNING("Unsupported EEPROM version: 0x%04X\n", |
386 | priv->eeprom.version); | 429 | iwl_eeprom_query16(priv, EEPROM_VERSION)); |
387 | return -EINVAL; | 430 | return -EINVAL; |
388 | } | 431 | } |
389 | 432 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h index bd0a042ca77f..26a73e918c56 100644 --- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h | |||
@@ -116,7 +116,7 @@ enum { | |||
116 | 116 | ||
117 | /* *regulatory* channel data format in eeprom, one for each channel. | 117 | /* *regulatory* channel data format in eeprom, one for each channel. |
118 | * There are separate entries for FAT (40 MHz) vs. normal (20 MHz) channels. */ | 118 | * There are separate entries for FAT (40 MHz) vs. normal (20 MHz) channels. */ |
119 | struct iwl4965_eeprom_channel { | 119 | struct iwl_eeprom_channel { |
120 | u8 flags; /* EEPROM_CHANNEL_* flags copied from EEPROM */ | 120 | u8 flags; /* EEPROM_CHANNEL_* flags copied from EEPROM */ |
121 | s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */ | 121 | s8 max_power_avg; /* max power (dBm) on this chnl, limit 31 */ |
122 | } __attribute__ ((packed)); | 122 | } __attribute__ ((packed)); |
@@ -131,17 +131,19 @@ struct iwl4965_eeprom_channel { | |||
131 | * each of 3 target output levels */ | 131 | * each of 3 target output levels */ |
132 | #define EEPROM_TX_POWER_MEASUREMENTS (3) | 132 | #define EEPROM_TX_POWER_MEASUREMENTS (3) |
133 | 133 | ||
134 | #define EEPROM_4965_TX_POWER_VERSION (2) | 134 | /* 4965 Specific */ |
135 | 135 | /* 4965 driver does not work with txpower calibration version < 5 */ | |
136 | /* 4965 driver does not work with txpower calibration version < 5. | 136 | #define EEPROM_4965_TX_POWER_VERSION (5) |
137 | * Look for this in calib_version member of struct iwl4965_eeprom. */ | 137 | #define EEPROM_4965_CALIB_VERSION_OFFSET (2*0xB6) /* 2 bytes */ |
138 | #define EEPROM_TX_POWER_VERSION_NEW (5) | 138 | #define EEPROM_4965_CALIB_TXPOWER_OFFSET (2*0xE8) /* 48 bytes */ |
139 | #define EEPROM_4965_BOARD_REVISION (2*0x4F) /* 2 bytes */ | ||
140 | #define EEPROM_4965_BOARD_PBA (2*0x56+1) /* 9 bytes */ | ||
139 | 141 | ||
140 | /* 2.4 GHz */ | 142 | /* 2.4 GHz */ |
141 | extern const u8 iwl_eeprom_band_1[14]; | 143 | extern const u8 iwl_eeprom_band_1[14]; |
142 | 144 | ||
143 | /* | 145 | /* |
144 | * 4965 factory calibration data for one txpower level, on one channel, | 146 | * factory calibration data for one txpower level, on one channel, |
145 | * measured on one of the 2 tx chains (radio transmitter and associated | 147 | * measured on one of the 2 tx chains (radio transmitter and associated |
146 | * antenna). EEPROM contains: | 148 | * antenna). EEPROM contains: |
147 | * | 149 | * |
@@ -154,7 +156,7 @@ extern const u8 iwl_eeprom_band_1[14]; | |||
154 | * | 156 | * |
155 | * 4) RF power amplifier detector level measurement (not used). | 157 | * 4) RF power amplifier detector level measurement (not used). |
156 | */ | 158 | */ |
157 | struct iwl4965_eeprom_calib_measure { | 159 | struct iwl_eeprom_calib_measure { |
158 | u8 temperature; /* Device temperature (Celsius) */ | 160 | u8 temperature; /* Device temperature (Celsius) */ |
159 | u8 gain_idx; /* Index into gain table */ | 161 | u8 gain_idx; /* Index into gain table */ |
160 | u8 actual_pow; /* Measured RF output power, half-dBm */ | 162 | u8 actual_pow; /* Measured RF output power, half-dBm */ |
@@ -163,22 +165,22 @@ struct iwl4965_eeprom_calib_measure { | |||
163 | 165 | ||
164 | 166 | ||
165 | /* | 167 | /* |
166 | * 4965 measurement set for one channel. EEPROM contains: | 168 | * measurement set for one channel. EEPROM contains: |
167 | * | 169 | * |
168 | * 1) Channel number measured | 170 | * 1) Channel number measured |
169 | * | 171 | * |
170 | * 2) Measurements for each of 3 power levels for each of 2 radio transmitters | 172 | * 2) Measurements for each of 3 power levels for each of 2 radio transmitters |
171 | * (a.k.a. "tx chains") (6 measurements altogether) | 173 | * (a.k.a. "tx chains") (6 measurements altogether) |
172 | */ | 174 | */ |
173 | struct iwl4965_eeprom_calib_ch_info { | 175 | struct iwl_eeprom_calib_ch_info { |
174 | u8 ch_num; | 176 | u8 ch_num; |
175 | struct iwl4965_eeprom_calib_measure | 177 | struct iwl_eeprom_calib_measure |
176 | measurements[EEPROM_TX_POWER_TX_CHAINS] | 178 | measurements[EEPROM_TX_POWER_TX_CHAINS] |
177 | [EEPROM_TX_POWER_MEASUREMENTS]; | 179 | [EEPROM_TX_POWER_MEASUREMENTS]; |
178 | } __attribute__ ((packed)); | 180 | } __attribute__ ((packed)); |
179 | 181 | ||
180 | /* | 182 | /* |
181 | * 4965 txpower subband info. | 183 | * txpower subband info. |
182 | * | 184 | * |
183 | * For each frequency subband, EEPROM contains the following: | 185 | * For each frequency subband, EEPROM contains the following: |
184 | * | 186 | * |
@@ -187,16 +189,16 @@ struct iwl4965_eeprom_calib_ch_info { | |||
187 | * | 189 | * |
188 | * 2) Sample measurement sets for 2 channels close to the range endpoints. | 190 | * 2) Sample measurement sets for 2 channels close to the range endpoints. |
189 | */ | 191 | */ |
190 | struct iwl4965_eeprom_calib_subband_info { | 192 | struct iwl_eeprom_calib_subband_info { |
191 | u8 ch_from; /* channel number of lowest channel in subband */ | 193 | u8 ch_from; /* channel number of lowest channel in subband */ |
192 | u8 ch_to; /* channel number of highest channel in subband */ | 194 | u8 ch_to; /* channel number of highest channel in subband */ |
193 | struct iwl4965_eeprom_calib_ch_info ch1; | 195 | struct iwl_eeprom_calib_ch_info ch1; |
194 | struct iwl4965_eeprom_calib_ch_info ch2; | 196 | struct iwl_eeprom_calib_ch_info ch2; |
195 | } __attribute__ ((packed)); | 197 | } __attribute__ ((packed)); |
196 | 198 | ||
197 | 199 | ||
198 | /* | 200 | /* |
199 | * 4965 txpower calibration info. EEPROM contains: | 201 | * txpower calibration info. EEPROM contains: |
200 | * | 202 | * |
201 | * 1) Factory-measured saturation power levels (maximum levels at which | 203 | * 1) Factory-measured saturation power levels (maximum levels at which |
202 | * tx power amplifier can output a signal without too much distortion). | 204 | * tx power amplifier can output a signal without too much distortion). |
@@ -212,55 +214,45 @@ struct iwl4965_eeprom_calib_subband_info { | |||
212 | * characteristics of the analog radio circuitry vary with frequency. | 214 | * characteristics of the analog radio circuitry vary with frequency. |
213 | * | 215 | * |
214 | * Not all sets need to be filled with data; | 216 | * Not all sets need to be filled with data; |
215 | * struct iwl4965_eeprom_calib_subband_info contains range of channels | 217 | * struct iwl_eeprom_calib_subband_info contains range of channels |
216 | * (0 if unused) for each set of data. | 218 | * (0 if unused) for each set of data. |
217 | */ | 219 | */ |
218 | struct iwl4965_eeprom_calib_info { | 220 | struct iwl_eeprom_calib_info { |
219 | u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */ | 221 | u8 saturation_power24; /* half-dBm (e.g. "34" = 17 dBm) */ |
220 | u8 saturation_power52; /* half-dBm */ | 222 | u8 saturation_power52; /* half-dBm */ |
221 | s16 voltage; /* signed */ | 223 | s16 voltage; /* signed */ |
222 | struct iwl4965_eeprom_calib_subband_info | 224 | struct iwl_eeprom_calib_subband_info |
223 | band_info[EEPROM_TX_POWER_BANDS]; | 225 | band_info[EEPROM_TX_POWER_BANDS]; |
224 | } __attribute__ ((packed)); | 226 | } __attribute__ ((packed)); |
225 | 227 | ||
226 | 228 | ||
227 | 229 | #define ADDRESS_MSK 0x0000FFFF | |
228 | /* | 230 | #define INDIRECT_TYPE_MSK 0x000F0000 |
229 | * 4965 EEPROM map | 231 | #define INDIRECT_HOST 0x00010000 |
230 | */ | 232 | #define INDIRECT_GENERAL 0x00020000 |
231 | struct iwl4965_eeprom { | 233 | #define INDIRECT_REGULATORY 0x00030000 |
232 | u8 reserved0[16]; | 234 | #define INDIRECT_CALIBRATION 0x00040000 |
233 | u16 device_id; /* abs.ofs: 16 */ | 235 | #define INDIRECT_PROCESS_ADJST 0x00050000 |
234 | u8 reserved1[2]; | 236 | #define INDIRECT_OTHERS 0x00060000 |
235 | u16 pmc; /* abs.ofs: 20 */ | 237 | #define INDIRECT_ADDRESS 0x00100000 |
236 | u8 reserved2[20]; | 238 | |
237 | u8 mac_address[6]; /* abs.ofs: 42 */ | 239 | /* General */ |
238 | u8 reserved3[58]; | 240 | #define EEPROM_DEVICE_ID (2*0x08) /* 2 bytes */ |
239 | u16 board_revision; /* abs.ofs: 106 */ | 241 | #define EEPROM_MAC_ADDRESS (2*0x15) /* 6 bytes */ |
240 | u8 reserved4[11]; | 242 | #define EEPROM_BOARD_REVISION (2*0x35) /* 2 bytes */ |
241 | u8 board_pba_number[9]; /* abs.ofs: 119 */ | 243 | #define EEPROM_BOARD_PBA_NUMBER (2*0x3B+1) /* 9 bytes */ |
242 | u8 reserved5[8]; | 244 | #define EEPROM_VERSION (2*0x44) /* 2 bytes */ |
243 | u16 version; /* abs.ofs: 136 */ | 245 | #define EEPROM_SKU_CAP (2*0x45) /* 1 bytes */ |
244 | u8 sku_cap; /* abs.ofs: 138 */ | 246 | #define EEPROM_LEDS_MODE (2*0x45+1) /* 1 bytes */ |
245 | u8 leds_mode; /* abs.ofs: 139 */ | 247 | #define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */ |
246 | u16 oem_mode; | 248 | #define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */ |
247 | u16 wowlan_mode; /* abs.ofs: 142 */ | 249 | #define EEPROM_3945_M_VERSION (2*0x4A) /* 1 bytes */ |
248 | u16 leds_time_interval; /* abs.ofs: 144 */ | 250 | #define EEPROM_ANTENNA_SWITCH_TYPE (2*0x4A+1) /* 1 bytes */ |
249 | u8 leds_off_time; /* abs.ofs: 146 */ | ||
250 | u8 leds_on_time; /* abs.ofs: 147 */ | ||
251 | u8 almgor_m_version; /* abs.ofs: 148 */ | ||
252 | u8 antenna_switch_type; /* abs.ofs: 149 */ | ||
253 | u8 reserved6[8]; | ||
254 | u16 board_revision_4965; /* abs.ofs: 158 */ | ||
255 | u8 reserved7[13]; | ||
256 | u8 board_pba_number_4965[9]; /* abs.ofs: 173 */ | ||
257 | u8 reserved8[10]; | ||
258 | u8 sku_id[4]; /* abs.ofs: 192 */ | ||
259 | 251 | ||
260 | /* | 252 | /* |
261 | * Per-channel regulatory data. | 253 | * Per-channel regulatory data. |
262 | * | 254 | * |
263 | * Each channel that *might* be supported by 3945 or 4965 has a fixed location | 255 | * Each channel that *might* be supported by iwl has a fixed location |
264 | * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory | 256 | * in EEPROM containing EEPROM_CHANNEL_* usage flags (LSB) and max regulatory |
265 | * txpower (MSB). | 257 | * txpower (MSB). |
266 | * | 258 | * |
@@ -269,40 +261,38 @@ struct iwl4965_eeprom { | |||
269 | * | 261 | * |
270 | * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 | 262 | * 2.4 GHz channels 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 |
271 | */ | 263 | */ |
272 | u16 band_1_count; /* abs.ofs: 196 */ | 264 | #define EEPROM_REGULATORY_SKU_ID (2*0x60) /* 4 bytes */ |
273 | struct iwl4965_eeprom_channel band_1_channels[14]; /* abs.ofs: 196 */ | 265 | #define EEPROM_REGULATORY_BAND_1 (2*0x62) /* 2 bytes */ |
266 | #define EEPROM_REGULATORY_BAND_1_CHANNELS (2*0x63) /* 28 bytes */ | ||
274 | 267 | ||
275 | /* | 268 | /* |
276 | * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196, | 269 | * 4.9 GHz channels 183, 184, 185, 187, 188, 189, 192, 196, |
277 | * 5.0 GHz channels 7, 8, 11, 12, 16 | 270 | * 5.0 GHz channels 7, 8, 11, 12, 16 |
278 | * (4915-5080MHz) (none of these is ever supported) | 271 | * (4915-5080MHz) (none of these is ever supported) |
279 | */ | 272 | */ |
280 | u16 band_2_count; /* abs.ofs: 226 */ | 273 | #define EEPROM_REGULATORY_BAND_2 (2*0x71) /* 2 bytes */ |
281 | struct iwl4965_eeprom_channel band_2_channels[13]; /* abs.ofs: 228 */ | 274 | #define EEPROM_REGULATORY_BAND_2_CHANNELS (2*0x72) /* 26 bytes */ |
282 | 275 | ||
283 | /* | 276 | /* |
284 | * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 | 277 | * 5.2 GHz channels 34, 36, 38, 40, 42, 44, 46, 48, 52, 56, 60, 64 |
285 | * (5170-5320MHz) | 278 | * (5170-5320MHz) |
286 | */ | 279 | */ |
287 | u16 band_3_count; /* abs.ofs: 254 */ | 280 | #define EEPROM_REGULATORY_BAND_3 (2*0x7F) /* 2 bytes */ |
288 | struct iwl4965_eeprom_channel band_3_channels[12]; /* abs.ofs: 256 */ | 281 | #define EEPROM_REGULATORY_BAND_3_CHANNELS (2*0x80) /* 24 bytes */ |
289 | 282 | ||
290 | /* | 283 | /* |
291 | * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 | 284 | * 5.5 GHz channels 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140 |
292 | * (5500-5700MHz) | 285 | * (5500-5700MHz) |
293 | */ | 286 | */ |
294 | u16 band_4_count; /* abs.ofs: 280 */ | 287 | #define EEPROM_REGULATORY_BAND_4 (2*0x8C) /* 2 bytes */ |
295 | struct iwl4965_eeprom_channel band_4_channels[11]; /* abs.ofs: 282 */ | 288 | #define EEPROM_REGULATORY_BAND_4_CHANNELS (2*0x8D) /* 22 bytes */ |
296 | 289 | ||
297 | /* | 290 | /* |
298 | * 5.7 GHz channels 145, 149, 153, 157, 161, 165 | 291 | * 5.7 GHz channels 145, 149, 153, 157, 161, 165 |
299 | * (5725-5825MHz) | 292 | * (5725-5825MHz) |
300 | */ | 293 | */ |
301 | u16 band_5_count; /* abs.ofs: 304 */ | 294 | #define EEPROM_REGULATORY_BAND_5 (2*0x98) /* 2 bytes */ |
302 | struct iwl4965_eeprom_channel band_5_channels[6]; /* abs.ofs: 306 */ | 295 | #define EEPROM_REGULATORY_BAND_5_CHANNELS (2*0x99) /* 12 bytes */ |
303 | |||
304 | u8 reserved10[2]; | ||
305 | |||
306 | 296 | ||
307 | /* | 297 | /* |
308 | * 2.4 GHz FAT channels 1 (5), 2 (6), 3 (7), 4 (8), 5 (9), 6 (10), 7 (11) | 298 | * 2.4 GHz FAT channels 1 (5), 2 (6), 3 (7), 4 (8), 5 (9), 6 (10), 7 (11) |
@@ -319,52 +309,33 @@ struct iwl4965_eeprom { | |||
319 | * | 309 | * |
320 | * NOTE: 4965 does not support FAT channels on 2.4 GHz. | 310 | * NOTE: 4965 does not support FAT channels on 2.4 GHz. |
321 | */ | 311 | */ |
322 | struct iwl4965_eeprom_channel band_24_channels[7]; /* abs.ofs: 320 */ | 312 | #define EEPROM_4965_REGULATORY_BAND_24_FAT_CHANNELS (2*0xA0) /* 14 bytes */ |
323 | u8 reserved11[2]; | ||
324 | 313 | ||
325 | /* | 314 | /* |
326 | * 5.2 GHz FAT channels 36 (40), 44 (48), 52 (56), 60 (64), | 315 | * 5.2 GHz FAT channels 36 (40), 44 (48), 52 (56), 60 (64), |
327 | * 100 (104), 108 (112), 116 (120), 124 (128), 132 (136), 149 (153), 157 (161) | 316 | * 100 (104), 108 (112), 116 (120), 124 (128), 132 (136), 149 (153), 157 (161) |
328 | */ | 317 | */ |
329 | struct iwl4965_eeprom_channel band_52_channels[11]; /* abs.ofs: 336 */ | 318 | #define EEPROM_4965_REGULATORY_BAND_52_FAT_CHANNELS (2*0xA8) /* 22 bytes */ |
330 | u8 reserved12[6]; | ||
331 | |||
332 | /* | ||
333 | * 4965 driver requires txpower calibration format version 5 or greater. | ||
334 | * Driver does not work with txpower calibration version < 5. | ||
335 | * This value is simply a 16-bit number, no major/minor versions here. | ||
336 | */ | ||
337 | u16 calib_version; /* abs.ofs: 364 */ | ||
338 | u8 reserved13[2]; | ||
339 | u8 reserved14[96]; /* abs.ofs: 368 */ | ||
340 | |||
341 | /* | ||
342 | * 4965 Txpower calibration data. | ||
343 | */ | ||
344 | struct iwl4965_eeprom_calib_info calib_info; /* abs.ofs: 464 */ | ||
345 | |||
346 | u8 reserved16[140]; /* fill out to full 1024 byte block */ | ||
347 | |||
348 | |||
349 | } __attribute__ ((packed)); | ||
350 | |||
351 | #define IWL_EEPROM_IMAGE_SIZE 1024 | ||
352 | |||
353 | /* End of EEPROM */ | ||
354 | 319 | ||
355 | struct iwl_eeprom_ops { | 320 | struct iwl_eeprom_ops { |
321 | const u32 regulatory_bands[7]; | ||
356 | int (*verify_signature) (struct iwl_priv *priv); | 322 | int (*verify_signature) (struct iwl_priv *priv); |
357 | int (*acquire_semaphore) (struct iwl_priv *priv); | 323 | int (*acquire_semaphore) (struct iwl_priv *priv); |
358 | void (*release_semaphore) (struct iwl_priv *priv); | 324 | void (*release_semaphore) (struct iwl_priv *priv); |
325 | const u8* (*query_addr) (const struct iwl_priv *priv, size_t offset); | ||
359 | }; | 326 | }; |
360 | 327 | ||
361 | 328 | ||
362 | void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac); | 329 | void iwl_eeprom_get_mac(const struct iwl_priv *priv, u8 *mac); |
363 | int iwl_eeprom_init(struct iwl_priv *priv); | 330 | int iwl_eeprom_init(struct iwl_priv *priv); |
331 | void iwl_eeprom_free(struct iwl_priv *priv); | ||
332 | const u8 *iwl_eeprom_query_addr(const struct iwl_priv *priv, size_t offset); | ||
333 | u16 iwl_eeprom_query16(const struct iwl_priv *priv, size_t offset); | ||
364 | 334 | ||
365 | int iwlcore_eeprom_verify_signature(struct iwl_priv *priv); | 335 | int iwlcore_eeprom_verify_signature(struct iwl_priv *priv); |
366 | int iwlcore_eeprom_acquire_semaphore(struct iwl_priv *priv); | 336 | int iwlcore_eeprom_acquire_semaphore(struct iwl_priv *priv); |
367 | void iwlcore_eeprom_release_semaphore(struct iwl_priv *priv); | 337 | void iwlcore_eeprom_release_semaphore(struct iwl_priv *priv); |
338 | const u8 *iwlcore_eeprom_query_addr(const struct iwl_priv *priv, size_t offset); | ||
368 | 339 | ||
369 | int iwl_init_channel_map(struct iwl_priv *priv); | 340 | int iwl_init_channel_map(struct iwl_priv *priv); |
370 | void iwl_free_channel_map(struct iwl_priv *priv); | 341 | void iwl_free_channel_map(struct iwl_priv *priv); |
diff --git a/drivers/net/wireless/iwlwifi/iwl4965-base.c b/drivers/net/wireless/iwlwifi/iwl4965-base.c index 6cb54580fe6b..c5ac82c4aeb4 100644 --- a/drivers/net/wireless/iwlwifi/iwl4965-base.c +++ b/drivers/net/wireless/iwlwifi/iwl4965-base.c | |||
@@ -7550,7 +7550,7 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
7550 | /* Device-specific setup */ | 7550 | /* Device-specific setup */ |
7551 | if (priv->cfg->ops->lib->set_hw_params(priv)) { | 7551 | if (priv->cfg->ops->lib->set_hw_params(priv)) { |
7552 | IWL_ERROR("failed to set hw parameters\n"); | 7552 | IWL_ERROR("failed to set hw parameters\n"); |
7553 | goto out_iounmap; | 7553 | goto out_free_eeprom; |
7554 | } | 7554 | } |
7555 | 7555 | ||
7556 | /******************* | 7556 | /******************* |
@@ -7611,6 +7611,8 @@ static int iwl4965_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e | |||
7611 | sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); | 7611 | sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group); |
7612 | out_unset_hw_params: | 7612 | out_unset_hw_params: |
7613 | iwl4965_unset_hw_params(priv); | 7613 | iwl4965_unset_hw_params(priv); |
7614 | out_free_eeprom: | ||
7615 | iwl_eeprom_free(priv); | ||
7614 | out_iounmap: | 7616 | out_iounmap: |
7615 | pci_iounmap(pdev, priv->hw_base); | 7617 | pci_iounmap(pdev, priv->hw_base); |
7616 | out_pci_release_regions: | 7618 | out_pci_release_regions: |
@@ -7674,6 +7676,7 @@ static void __devexit iwl4965_pci_remove(struct pci_dev *pdev) | |||
7674 | 7676 | ||
7675 | iwl4965_unset_hw_params(priv); | 7677 | iwl4965_unset_hw_params(priv); |
7676 | iwlcore_clear_stations_table(priv); | 7678 | iwlcore_clear_stations_table(priv); |
7679 | iwl_eeprom_free(priv); | ||
7677 | 7680 | ||
7678 | 7681 | ||
7679 | /*netif_stop_queue(dev); */ | 7682 | /*netif_stop_queue(dev); */ |