aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-agn.c
diff options
context:
space:
mode:
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>2011-05-31 02:07:00 -0400
committerWey-Yi Guy <wey-yi.w.guy@intel.com>2011-06-18 11:07:14 -0400
commit084dd79172cb3aad11d2b7ee5628d57badca7c6e (patch)
treeb59d649192927c120ee59b7e4575af695a1d09f4 /drivers/net/wireless/iwlwifi/iwl-agn.c
parent3599d39a8525b01540e2c7ec8c5d0df0dd11d6cf (diff)
iwlagn: move PCI related operations from probe and remove to PCI layer
Since we have now a PCI layer, all the init and deinit code that is PCI related should move to there. Also move the IO functions: read8/read32/write32. They need hw_base which is killed from priv. Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-agn.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c87
1 files changed, 11 insertions, 76 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 0098245a62ed..72db1a9fab84 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -3486,7 +3486,7 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3486 int err = 0; 3486 int err = 0;
3487 struct iwl_priv *priv; 3487 struct iwl_priv *priv;
3488 struct ieee80211_hw *hw; 3488 struct ieee80211_hw *hw;
3489 u16 pci_cmd, num_mac; 3489 u16 num_mac;
3490 u32 hw_rev; 3490 u32 hw_rev;
3491 3491
3492 /************************ 3492 /************************
@@ -3532,49 +3532,6 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3532 if (iwl_alloc_traffic_mem(priv)) 3532 if (iwl_alloc_traffic_mem(priv))
3533 IWL_ERR(priv, "Not enough memory to generate traffic log\n"); 3533 IWL_ERR(priv, "Not enough memory to generate traffic log\n");
3534 3534
3535 /**************************
3536 * 2. Initializing PCI bus
3537 **************************/
3538 pci_disable_link_state(pdev, PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1 |
3539 PCIE_LINK_STATE_CLKPM);
3540
3541 if (pci_enable_device(pdev)) {
3542 err = -ENODEV;
3543 goto out_ieee80211_free_hw;
3544 }
3545
3546 pci_set_master(pdev);
3547
3548 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(36));
3549 if (!err)
3550 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(36));
3551 if (err) {
3552 err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
3553 if (!err)
3554 err = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32));
3555 /* both attempts failed: */
3556 if (err) {
3557 IWL_WARN(priv, "No suitable DMA available.\n");
3558 goto out_pci_disable_device;
3559 }
3560 }
3561
3562 err = pci_request_regions(pdev, DRV_NAME);
3563 if (err)
3564 goto out_pci_disable_device;
3565
3566 /***********************
3567 * 3. Read REV register
3568 ***********************/
3569 priv->hw_base = pci_iomap(pdev, 0, 0);
3570 if (!priv->hw_base) {
3571 err = -ENODEV;
3572 goto out_pci_release_regions;
3573 }
3574
3575 IWL_DEBUG_INFO(priv, "pci_resource_len = 0x%08llx\n",
3576 (unsigned long long) pci_resource_len(pdev, 0));
3577 IWL_DEBUG_INFO(priv, "pci_resource_base = %p\n", priv->hw_base);
3578 3535
3579 /* these spin locks will be used in apm_ops.init and EEPROM access 3536 /* these spin locks will be used in apm_ops.init and EEPROM access
3580 * we should init now 3537 * we should init now
@@ -3589,17 +3546,16 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3589 */ 3546 */
3590 iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET); 3547 iwl_write32(priv, CSR_RESET, CSR_RESET_REG_FLAG_NEVO_RESET);
3591 3548
3549 /***********************
3550 * 3. Read REV register
3551 ***********************/
3592 hw_rev = iwl_hw_detect(priv); 3552 hw_rev = iwl_hw_detect(priv);
3593 IWL_INFO(priv, "Detected %s, REV=0x%X\n", 3553 IWL_INFO(priv, "Detected %s, REV=0x%X\n",
3594 priv->cfg->name, hw_rev); 3554 priv->cfg->name, hw_rev);
3595 3555
3596 /* We disable the RETRY_TIMEOUT register (0x41) to keep
3597 * PCI Tx retries from interfering with C3 CPU state */
3598 pci_write_config_byte(pdev, PCI_CFG_RETRY_TIMEOUT, 0x00);
3599
3600 if (iwl_prepare_card_hw(priv)) { 3556 if (iwl_prepare_card_hw(priv)) {
3601 IWL_WARN(priv, "Failed, HW not ready\n"); 3557 IWL_WARN(priv, "Failed, HW not ready\n");
3602 goto out_iounmap; 3558 goto out_free_traffic_mem;
3603 } 3559 }
3604 3560
3605 /***************** 3561 /*****************
@@ -3609,7 +3565,7 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3609 err = iwl_eeprom_init(priv, hw_rev); 3565 err = iwl_eeprom_init(priv, hw_rev);
3610 if (err) { 3566 if (err) {
3611 IWL_ERR(priv, "Unable to init EEPROM\n"); 3567 IWL_ERR(priv, "Unable to init EEPROM\n");
3612 goto out_iounmap; 3568 goto out_free_traffic_mem;
3613 } 3569 }
3614 err = iwl_eeprom_check_version(priv); 3570 err = iwl_eeprom_check_version(priv);
3615 if (err) 3571 if (err)
@@ -3639,6 +3595,7 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3639 * 5. Setup HW constants 3595 * 5. Setup HW constants
3640 ************************/ 3596 ************************/
3641 if (iwl_set_hw_params(priv)) { 3597 if (iwl_set_hw_params(priv)) {
3598 err = -ENOENT;
3642 IWL_ERR(priv, "failed to set hw parameters\n"); 3599 IWL_ERR(priv, "failed to set hw parameters\n");
3643 goto out_free_eeprom; 3600 goto out_free_eeprom;
3644 } 3601 }
@@ -3655,15 +3612,13 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3655 /******************** 3612 /********************
3656 * 7. Setup services 3613 * 7. Setup services
3657 ********************/ 3614 ********************/
3658 pci_enable_msi(priv->pci_dev);
3659
3660 iwl_alloc_isr_ict(priv); 3615 iwl_alloc_isr_ict(priv);
3661 3616
3662 err = request_irq(priv->pci_dev->irq, iwl_isr_ict, 3617 err = request_irq(priv->pci_dev->irq, iwl_isr_ict,
3663 IRQF_SHARED, DRV_NAME, priv); 3618 IRQF_SHARED, DRV_NAME, priv);
3664 if (err) { 3619 if (err) {
3665 IWL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq); 3620 IWL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq);
3666 goto out_disable_msi; 3621 goto out_uninit_drv;
3667 } 3622 }
3668 3623
3669 iwl_setup_deferred_work(priv); 3624 iwl_setup_deferred_work(priv);
@@ -3671,16 +3626,9 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3671 iwl_testmode_init(priv); 3626 iwl_testmode_init(priv);
3672 3627
3673 /********************************************* 3628 /*********************************************
3674 * 8. Enable interrupts and read RFKILL state 3629 * 8. Enable interrupts
3675 *********************************************/ 3630 *********************************************/
3676 3631
3677 /* enable rfkill interrupt: hw bug w/a */
3678 pci_read_config_word(priv->pci_dev, PCI_COMMAND, &pci_cmd);
3679 if (pci_cmd & PCI_COMMAND_INTX_DISABLE) {
3680 pci_cmd &= ~PCI_COMMAND_INTX_DISABLE;
3681 pci_write_config_word(priv->pci_dev, PCI_COMMAND, pci_cmd);
3682 }
3683
3684 iwl_enable_rfkill_int(priv); 3632 iwl_enable_rfkill_int(priv);
3685 3633
3686 /* If platform's RF_KILL switch is NOT set to KILL */ 3634 /* If platform's RF_KILL switch is NOT set to KILL */
@@ -3707,20 +3655,12 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3707 destroy_workqueue(priv->workqueue); 3655 destroy_workqueue(priv->workqueue);
3708 priv->workqueue = NULL; 3656 priv->workqueue = NULL;
3709 free_irq(priv->pci_dev->irq, priv); 3657 free_irq(priv->pci_dev->irq, priv);
3710 out_disable_msi:
3711 iwl_free_isr_ict(priv); 3658 iwl_free_isr_ict(priv);
3712 pci_disable_msi(priv->pci_dev); 3659 out_uninit_drv:
3713 iwl_uninit_drv(priv); 3660 iwl_uninit_drv(priv);
3714 out_free_eeprom: 3661 out_free_eeprom:
3715 iwl_eeprom_free(priv); 3662 iwl_eeprom_free(priv);
3716 out_iounmap: 3663 out_free_traffic_mem:
3717 pci_iounmap(pdev, priv->hw_base);
3718 out_pci_release_regions:
3719 priv->bus.ops->set_drv_data(&priv->bus, NULL);
3720 pci_release_regions(pdev);
3721 out_pci_disable_device:
3722 pci_disable_device(pdev);
3723 out_ieee80211_free_hw:
3724 iwl_free_traffic_mem(priv); 3664 iwl_free_traffic_mem(priv);
3725 ieee80211_free_hw(priv->hw); 3665 ieee80211_free_hw(priv->hw);
3726 out: 3666 out:
@@ -3729,7 +3669,6 @@ int iwl_probe(void *bus_specific, struct iwl_bus_ops *bus_ops,
3729 3669
3730void __devexit iwl_remove(struct iwl_priv * priv) 3670void __devexit iwl_remove(struct iwl_priv * priv)
3731{ 3671{
3732 struct pci_dev *pdev = priv->pci_dev;
3733 unsigned long flags; 3672 unsigned long flags;
3734 3673
3735 wait_for_completion(&priv->_agn.firmware_loading_complete); 3674 wait_for_completion(&priv->_agn.firmware_loading_complete);
@@ -3788,10 +3727,6 @@ void __devexit iwl_remove(struct iwl_priv * priv)
3788 iwl_free_traffic_mem(priv); 3727 iwl_free_traffic_mem(priv);
3789 3728
3790 free_irq(priv->pci_dev->irq, priv); 3729 free_irq(priv->pci_dev->irq, priv);
3791 pci_disable_msi(priv->pci_dev);
3792 pci_iounmap(pdev, priv->hw_base);
3793 pci_release_regions(pdev);
3794 pci_disable_device(pdev);
3795 priv->bus.ops->set_drv_data(&priv->bus, NULL); 3730 priv->bus.ops->set_drv_data(&priv->bus, NULL);
3796 3731
3797 iwl_uninit_drv(priv); 3732 iwl_uninit_drv(priv);