aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-4965.c
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2008-04-21 18:41:52 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-05-07 15:02:15 -0400
commit073d3f5f1b3b6512eb82a3d40c84dedb14dc6f73 (patch)
tree49ef76bf1d863a231b0a672c2c34fb44f63fad9c /drivers/net/wireless/iwlwifi/iwl-4965.c
parent5da4b55f78fb2ed40926b775d4f7c791594ecbd7 (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>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-4965.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c62
1 files changed, 40 insertions, 22 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index d051aac558f..7886596b62c 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 */
1576static int iwl4965_interpolate_chan(struct iwl_priv *priv, u32 channel, 1583static 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
2468static void iwl4965_hw_card_show_info(struct iwl_priv *priv) 2475static 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};