aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi
diff options
context:
space:
mode:
authorTomas Winkler <tomas.winkler@intel.com>2008-04-24 14:55:22 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-05-07 15:02:22 -0400
commit694cc56dbb818fe689f721fb53452eb5ad3f8e9a (patch)
tree24dd95c142fbad86f1b31bc836b667adbfafce86 /drivers/net/wireless/iwlwifi
parente4d18d817f0ffc830bce57906b2a7dd9e713c388 (diff)
iwlwifi: wrapping nic configuration in iwl core handler
This patch wraps nic hw configuration in a iwl core handler Signed-off-by: Tomas Winkler <tomas.winkler@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c57
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-eeprom.h12
3 files changed, 48 insertions, 22 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index a98f00f7da42..8aaac16a45fd 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -579,22 +579,13 @@ out:
579 return ret; 579 return ret;
580} 580}
581 581
582int iwl4965_hw_nic_init(struct iwl_priv *priv) 582
583static void iwl4965_nic_config(struct iwl_priv *priv)
583{ 584{
584 unsigned long flags; 585 unsigned long flags;
585 struct iwl4965_rx_queue *rxq = &priv->rxq;
586 u8 val_link;
587 u32 val; 586 u32 val;
588 int ret; 587 u16 radio_cfg;
589 588 u8 val_link;
590 /* nic_init */
591 priv->cfg->ops->lib->apm_ops.init(priv);
592
593 spin_lock_irqsave(&priv->lock, flags);
594 iwl_write32(priv, CSR_INT_COALESCING, 512 / 32);
595 spin_unlock_irqrestore(&priv->lock, flags);
596
597 ret = priv->cfg->ops->lib->apm_ops.set_pwr_src(priv, IWL_PWR_SRC_VMAIN);
598 589
599 spin_lock_irqsave(&priv->lock, flags); 590 spin_lock_irqsave(&priv->lock, flags);
600 591
@@ -605,24 +596,49 @@ int iwl4965_hw_nic_init(struct iwl_priv *priv)
605 val & ~(1 << 11)); 596 val & ~(1 << 11));
606 } 597 }
607 598
608 spin_unlock_irqrestore(&priv->lock, flags);
609
610 pci_read_config_byte(priv->pci_dev, PCI_LINK_CTRL, &val_link); 599 pci_read_config_byte(priv->pci_dev, PCI_LINK_CTRL, &val_link);
611 600
612 /* disable L1 entry -- workaround for pre-B1 */ 601 /* disable L1 entry -- workaround for pre-B1 */
613 pci_write_config_byte(priv->pci_dev, PCI_LINK_CTRL, val_link & ~0x02); 602 pci_write_config_byte(priv->pci_dev, PCI_LINK_CTRL, val_link & ~0x02);
614 603
615 spin_lock_irqsave(&priv->lock, flags); 604 radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG);
616 605
617 /* set CSR_HW_CONFIG_REG for uCode use */ 606 /* write radio config values to register */
607 if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) == EEPROM_4965_RF_CFG_TYPE_MAX)
608 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
609 EEPROM_RF_CFG_TYPE_MSK(radio_cfg) |
610 EEPROM_RF_CFG_STEP_MSK(radio_cfg) |
611 EEPROM_RF_CFG_DASH_MSK(radio_cfg));
618 612
613 /* set CSR_HW_CONFIG_REG for uCode use */
619 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, 614 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
620 CSR49_HW_IF_CONFIG_REG_BIT_4965_R |
621 CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI | 615 CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
622 CSR_HW_IF_CONFIG_REG_BIT_MAC_SI); 616 CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
623 617
618 priv->calib_info = (struct iwl_eeprom_calib_info *)
619 iwl_eeprom_query_addr(priv, EEPROM_4965_CALIB_TXPOWER_OFFSET);
620
621 spin_unlock_irqrestore(&priv->lock, flags);
622}
623
624
625int iwl4965_hw_nic_init(struct iwl_priv *priv)
626{
627 unsigned long flags;
628 struct iwl4965_rx_queue *rxq = &priv->rxq;
629 int ret;
630
631 /* nic_init */
632 priv->cfg->ops->lib->apm_ops.init(priv);
633
634 spin_lock_irqsave(&priv->lock, flags);
635 iwl_write32(priv, CSR_INT_COALESCING, 512 / 32);
624 spin_unlock_irqrestore(&priv->lock, flags); 636 spin_unlock_irqrestore(&priv->lock, flags);
625 637
638 ret = priv->cfg->ops->lib->apm_ops.set_pwr_src(priv, IWL_PWR_SRC_VMAIN);
639
640 priv->cfg->ops->lib->apm_ops.config(priv);
641
626 iwl4965_hw_card_show_info(priv); 642 iwl4965_hw_card_show_info(priv);
627 643
628 /* end nic_init */ 644 /* end nic_init */
@@ -646,10 +662,6 @@ int iwl4965_hw_nic_init(struct iwl_priv *priv)
646 rxq->need_update = 1; 662 rxq->need_update = 1;
647 iwl4965_rx_queue_update_write_ptr(priv, rxq); 663 iwl4965_rx_queue_update_write_ptr(priv, rxq);
648 664
649 /* init the txpower calibration pointer */
650 priv->calib_info = (struct iwl_eeprom_calib_info *)
651 iwl_eeprom_query_addr(priv, EEPROM_4965_CALIB_TXPOWER_OFFSET);
652
653 spin_unlock_irqrestore(&priv->lock, flags); 665 spin_unlock_irqrestore(&priv->lock, flags);
654 666
655 /* Allocate and init all Tx and Command queues */ 667 /* Allocate and init all Tx and Command queues */
@@ -4112,6 +4124,7 @@ static struct iwl_lib_ops iwl4965_lib = {
4112 .load_ucode = iwl4965_load_bsm, 4124 .load_ucode = iwl4965_load_bsm,
4113 .apm_ops = { 4125 .apm_ops = {
4114 .init = iwl4965_apm_init, 4126 .init = iwl4965_apm_init,
4127 .config = iwl4965_nic_config,
4115 .set_pwr_src = iwl4965_set_pwr_src, 4128 .set_pwr_src = iwl4965_set_pwr_src,
4116 }, 4129 },
4117 .eeprom_ops = { 4130 .eeprom_ops = {
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index fc0c2765f136..369f1821584f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -120,6 +120,7 @@ struct iwl_lib_ops {
120 /* power management */ 120 /* power management */
121 struct { 121 struct {
122 int (*init)(struct iwl_priv *priv); 122 int (*init)(struct iwl_priv *priv);
123 void (*config)(struct iwl_priv *priv);
123 int (*set_pwr_src)(struct iwl_priv *priv, enum iwl_pwr_src src); 124 int (*set_pwr_src)(struct iwl_priv *priv, enum iwl_pwr_src src);
124 } apm_ops; 125 } apm_ops;
125 /* power */ 126 /* power */
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom.h b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
index 57fb89d5621b..0c42e5a1288b 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom.h
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom.h
@@ -247,9 +247,21 @@ struct iwl_eeprom_calib_info {
247#define EEPROM_LEDS_MODE (2*0x45+1) /* 1 bytes */ 247#define EEPROM_LEDS_MODE (2*0x45+1) /* 1 bytes */
248#define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */ 248#define EEPROM_OEM_MODE (2*0x46) /* 2 bytes */
249#define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */ 249#define EEPROM_WOWLAN_MODE (2*0x47) /* 2 bytes */
250#define EEPROM_RADIO_CONFIG (2*0x48) /* 2 bytes */
250#define EEPROM_3945_M_VERSION (2*0x4A) /* 1 bytes */ 251#define EEPROM_3945_M_VERSION (2*0x4A) /* 1 bytes */
251#define EEPROM_ANTENNA_SWITCH_TYPE (2*0x4A+1) /* 1 bytes */ 252#define EEPROM_ANTENNA_SWITCH_TYPE (2*0x4A+1) /* 1 bytes */
252 253
254/* The following masks are to be applied on EEPROM_RADIO_CONFIG */
255#define EEPROM_RF_CFG_TYPE_MSK(x) (x & 0x3) /* bits 0-1 */
256#define EEPROM_RF_CFG_STEP_MSK(x) ((x >> 2) & 0x3) /* bits 2-3 */
257#define EEPROM_RF_CFG_DASH_MSK(x) ((x >> 4) & 0x3) /* bits 4-5 */
258#define EEPROM_RF_CFG_PNUM_MSK(x) ((x >> 6) & 0x3) /* bits 6-7 */
259#define EEPROM_RF_CFG_TX_ANT_MSK(x) ((x >> 8) & 0xF) /* bits 8-11 */
260#define EEPROM_RF_CFG_RX_ANT_MSK(x) ((x >> 12) & 0xF) /* bits 12-15 */
261
262#define EEPROM_3945_RF_CFG_TYPE_MAX 0x0
263#define EEPROM_4965_RF_CFG_TYPE_MAX 0x1
264
253/* 265/*
254 * Per-channel regulatory data. 266 * Per-channel regulatory data.
255 * 267 *