diff options
author | Emmanuel Grumbach <emmanuel.grumbach@intel.com> | 2012-11-14 07:44:18 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2012-11-19 09:03:23 -0500 |
commit | 7afe3705cd4e2a5490140cc15a15b3ea7a10b889 (patch) | |
tree | 06f3cad38e0ba274fb308dc21652a499010d8ea1 /drivers/net | |
parent | 9805c4460ae37aa9328a470c7aebea32f0667e24 (diff) |
iwlwifi: continue clean up - pcie/trans.c
Functions that implement the transport API are prefixed by
iwl_trans_pcie_, the others by iwl_pcie_.
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-config.h | 2 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/pcie/trans.c | 68 |
2 files changed, 32 insertions, 38 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-config.h b/drivers/net/wireless/iwlwifi/iwl-config.h index 87f465a49df1..196266aa5a9d 100644 --- a/drivers/net/wireless/iwlwifi/iwl-config.h +++ b/drivers/net/wireless/iwlwifi/iwl-config.h | |||
@@ -150,7 +150,7 @@ enum iwl_led_mode { | |||
150 | struct iwl_base_params { | 150 | struct iwl_base_params { |
151 | int eeprom_size; | 151 | int eeprom_size; |
152 | int num_of_queues; /* def: HW dependent */ | 152 | int num_of_queues; /* def: HW dependent */ |
153 | /* for iwl_apm_init() */ | 153 | /* for iwl_pcie_apm_init() */ |
154 | u32 pll_cfg_val; | 154 | u32 pll_cfg_val; |
155 | 155 | ||
156 | const u16 max_ll_items; | 156 | const u16 max_ll_items; |
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c index 8a9cde5fa1e8..8a5b5af968ad 100644 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c | |||
@@ -461,7 +461,7 @@ error: | |||
461 | return ret; | 461 | return ret; |
462 | } | 462 | } |
463 | 463 | ||
464 | static void iwl_set_pwr_vmain(struct iwl_trans *trans) | 464 | static void iwl_pcie_set_pwr_vmain(struct iwl_trans *trans) |
465 | { | 465 | { |
466 | /* | 466 | /* |
467 | * (for documentation purposes) | 467 | * (for documentation purposes) |
@@ -483,18 +483,11 @@ static void iwl_set_pwr_vmain(struct iwl_trans *trans) | |||
483 | #define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 | 483 | #define PCI_CFG_LINK_CTRL_VAL_L0S_EN 0x01 |
484 | #define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 | 484 | #define PCI_CFG_LINK_CTRL_VAL_L1_EN 0x02 |
485 | 485 | ||
486 | static u16 iwl_pciexp_link_ctrl(struct iwl_trans *trans) | 486 | static void iwl_pcie_apm_config(struct iwl_trans *trans) |
487 | { | 487 | { |
488 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); | 488 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
489 | u16 pci_lnk_ctl; | 489 | u16 lctl; |
490 | 490 | ||
491 | pcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_LNKCTL, | ||
492 | &pci_lnk_ctl); | ||
493 | return pci_lnk_ctl; | ||
494 | } | ||
495 | |||
496 | static void iwl_apm_config(struct iwl_trans *trans) | ||
497 | { | ||
498 | /* | 491 | /* |
499 | * HW bug W/A for instability in PCIe bus L0S->L1 transition. | 492 | * HW bug W/A for instability in PCIe bus L0S->L1 transition. |
500 | * Check if BIOS (or OS) enabled L1-ASPM on this device. | 493 | * Check if BIOS (or OS) enabled L1-ASPM on this device. |
@@ -503,7 +496,7 @@ static void iwl_apm_config(struct iwl_trans *trans) | |||
503 | * If not (unlikely), enable L0S, so there is at least some | 496 | * If not (unlikely), enable L0S, so there is at least some |
504 | * power savings, even without L1. | 497 | * power savings, even without L1. |
505 | */ | 498 | */ |
506 | u16 lctl = iwl_pciexp_link_ctrl(trans); | 499 | pcie_capability_read_word(trans_pcie->pci_dev, PCI_EXP_LNKCTL, &lctl); |
507 | 500 | ||
508 | if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == | 501 | if ((lctl & PCI_CFG_LINK_CTRL_VAL_L1_EN) == |
509 | PCI_CFG_LINK_CTRL_VAL_L1_EN) { | 502 | PCI_CFG_LINK_CTRL_VAL_L1_EN) { |
@@ -522,10 +515,10 @@ static void iwl_apm_config(struct iwl_trans *trans) | |||
522 | 515 | ||
523 | /* | 516 | /* |
524 | * Start up NIC's basic functionality after it has been reset | 517 | * Start up NIC's basic functionality after it has been reset |
525 | * (e.g. after platform boot, or shutdown via iwl_apm_stop()) | 518 | * (e.g. after platform boot, or shutdown via iwl_pcie_apm_stop()) |
526 | * NOTE: This does not load uCode nor start the embedded processor | 519 | * NOTE: This does not load uCode nor start the embedded processor |
527 | */ | 520 | */ |
528 | static int iwl_apm_init(struct iwl_trans *trans) | 521 | static int iwl_pcie_apm_init(struct iwl_trans *trans) |
529 | { | 522 | { |
530 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); | 523 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
531 | int ret = 0; | 524 | int ret = 0; |
@@ -557,7 +550,7 @@ static int iwl_apm_init(struct iwl_trans *trans) | |||
557 | iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, | 550 | iwl_set_bit(trans, CSR_HW_IF_CONFIG_REG, |
558 | CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); | 551 | CSR_HW_IF_CONFIG_REG_BIT_HAP_WAKE_L1A); |
559 | 552 | ||
560 | iwl_apm_config(trans); | 553 | iwl_pcie_apm_config(trans); |
561 | 554 | ||
562 | /* Configure analog phase-lock-loop before activating to D0A */ | 555 | /* Configure analog phase-lock-loop before activating to D0A */ |
563 | if (trans->cfg->base_params->pll_cfg_val) | 556 | if (trans->cfg->base_params->pll_cfg_val) |
@@ -603,7 +596,7 @@ out: | |||
603 | return ret; | 596 | return ret; |
604 | } | 597 | } |
605 | 598 | ||
606 | static int iwl_apm_stop_master(struct iwl_trans *trans) | 599 | static int iwl_pcie_apm_stop_master(struct iwl_trans *trans) |
607 | { | 600 | { |
608 | int ret = 0; | 601 | int ret = 0; |
609 | 602 | ||
@@ -621,7 +614,7 @@ static int iwl_apm_stop_master(struct iwl_trans *trans) | |||
621 | return ret; | 614 | return ret; |
622 | } | 615 | } |
623 | 616 | ||
624 | static void iwl_apm_stop(struct iwl_trans *trans) | 617 | static void iwl_pcie_apm_stop(struct iwl_trans *trans) |
625 | { | 618 | { |
626 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); | 619 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
627 | IWL_DEBUG_INFO(trans, "Stop card, put in low power state\n"); | 620 | IWL_DEBUG_INFO(trans, "Stop card, put in low power state\n"); |
@@ -629,7 +622,7 @@ static void iwl_apm_stop(struct iwl_trans *trans) | |||
629 | clear_bit(STATUS_DEVICE_ENABLED, &trans_pcie->status); | 622 | clear_bit(STATUS_DEVICE_ENABLED, &trans_pcie->status); |
630 | 623 | ||
631 | /* Stop device's DMA activity */ | 624 | /* Stop device's DMA activity */ |
632 | iwl_apm_stop_master(trans); | 625 | iwl_pcie_apm_stop_master(trans); |
633 | 626 | ||
634 | /* Reset the entire device */ | 627 | /* Reset the entire device */ |
635 | iwl_set_bit(trans, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); | 628 | iwl_set_bit(trans, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET); |
@@ -644,21 +637,21 @@ static void iwl_apm_stop(struct iwl_trans *trans) | |||
644 | CSR_GP_CNTRL_REG_FLAG_INIT_DONE); | 637 | CSR_GP_CNTRL_REG_FLAG_INIT_DONE); |
645 | } | 638 | } |
646 | 639 | ||
647 | static int iwl_nic_init(struct iwl_trans *trans) | 640 | static int iwl_pcie_nic_init(struct iwl_trans *trans) |
648 | { | 641 | { |
649 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); | 642 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
650 | unsigned long flags; | 643 | unsigned long flags; |
651 | 644 | ||
652 | /* nic_init */ | 645 | /* nic_init */ |
653 | spin_lock_irqsave(&trans_pcie->irq_lock, flags); | 646 | spin_lock_irqsave(&trans_pcie->irq_lock, flags); |
654 | iwl_apm_init(trans); | 647 | iwl_pcie_apm_init(trans); |
655 | 648 | ||
656 | /* Set interrupt coalescing calibration timer to default (512 usecs) */ | 649 | /* Set interrupt coalescing calibration timer to default (512 usecs) */ |
657 | iwl_write8(trans, CSR_INT_COALESCING, IWL_HOST_INT_CALIB_TIMEOUT_DEF); | 650 | iwl_write8(trans, CSR_INT_COALESCING, IWL_HOST_INT_CALIB_TIMEOUT_DEF); |
658 | 651 | ||
659 | spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); | 652 | spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); |
660 | 653 | ||
661 | iwl_set_pwr_vmain(trans); | 654 | iwl_pcie_set_pwr_vmain(trans); |
662 | 655 | ||
663 | iwl_op_mode_nic_config(trans->op_mode); | 656 | iwl_op_mode_nic_config(trans->op_mode); |
664 | 657 | ||
@@ -681,7 +674,7 @@ static int iwl_nic_init(struct iwl_trans *trans) | |||
681 | #define HW_READY_TIMEOUT (50) | 674 | #define HW_READY_TIMEOUT (50) |
682 | 675 | ||
683 | /* Note: returns poll_bit return value, which is >= 0 if success */ | 676 | /* Note: returns poll_bit return value, which is >= 0 if success */ |
684 | static int iwl_set_hw_ready(struct iwl_trans *trans) | 677 | static int iwl_pcie_set_hw_ready(struct iwl_trans *trans) |
685 | { | 678 | { |
686 | int ret; | 679 | int ret; |
687 | 680 | ||
@@ -699,14 +692,14 @@ static int iwl_set_hw_ready(struct iwl_trans *trans) | |||
699 | } | 692 | } |
700 | 693 | ||
701 | /* Note: returns standard 0/-ERROR code */ | 694 | /* Note: returns standard 0/-ERROR code */ |
702 | static int iwl_prepare_card_hw(struct iwl_trans *trans) | 695 | static int iwl_pcie_prepare_card_hw(struct iwl_trans *trans) |
703 | { | 696 | { |
704 | int ret; | 697 | int ret; |
705 | int t = 0; | 698 | int t = 0; |
706 | 699 | ||
707 | IWL_DEBUG_INFO(trans, "iwl_trans_prepare_card_hw enter\n"); | 700 | IWL_DEBUG_INFO(trans, "iwl_trans_prepare_card_hw enter\n"); |
708 | 701 | ||
709 | ret = iwl_set_hw_ready(trans); | 702 | ret = iwl_pcie_set_hw_ready(trans); |
710 | /* If the card is ready, exit 0 */ | 703 | /* If the card is ready, exit 0 */ |
711 | if (ret >= 0) | 704 | if (ret >= 0) |
712 | return 0; | 705 | return 0; |
@@ -716,7 +709,7 @@ static int iwl_prepare_card_hw(struct iwl_trans *trans) | |||
716 | CSR_HW_IF_CONFIG_REG_PREPARE); | 709 | CSR_HW_IF_CONFIG_REG_PREPARE); |
717 | 710 | ||
718 | do { | 711 | do { |
719 | ret = iwl_set_hw_ready(trans); | 712 | ret = iwl_pcie_set_hw_ready(trans); |
720 | if (ret >= 0) | 713 | if (ret >= 0) |
721 | return 0; | 714 | return 0; |
722 | 715 | ||
@@ -730,7 +723,7 @@ static int iwl_prepare_card_hw(struct iwl_trans *trans) | |||
730 | /* | 723 | /* |
731 | * ucode | 724 | * ucode |
732 | */ | 725 | */ |
733 | static int iwl_load_firmware_chunk(struct iwl_trans *trans, u32 dst_addr, | 726 | static int iwl_pcie_load_firmware_chunk(struct iwl_trans *trans, u32 dst_addr, |
734 | dma_addr_t phy_addr, u32 byte_cnt) | 727 | dma_addr_t phy_addr, u32 byte_cnt) |
735 | { | 728 | { |
736 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); | 729 | struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); |
@@ -777,7 +770,7 @@ static int iwl_load_firmware_chunk(struct iwl_trans *trans, u32 dst_addr, | |||
777 | return 0; | 770 | return 0; |
778 | } | 771 | } |
779 | 772 | ||
780 | static int iwl_load_section(struct iwl_trans *trans, u8 section_num, | 773 | static int iwl_pcie_load_section(struct iwl_trans *trans, u8 section_num, |
781 | const struct fw_desc *section) | 774 | const struct fw_desc *section) |
782 | { | 775 | { |
783 | u8 *v_addr; | 776 | u8 *v_addr; |
@@ -798,8 +791,9 @@ static int iwl_load_section(struct iwl_trans *trans, u8 section_num, | |||
798 | copy_size = min_t(u32, PAGE_SIZE, section->len - offset); | 791 | copy_size = min_t(u32, PAGE_SIZE, section->len - offset); |
799 | 792 | ||
800 | memcpy(v_addr, (u8 *)section->data + offset, copy_size); | 793 | memcpy(v_addr, (u8 *)section->data + offset, copy_size); |
801 | ret = iwl_load_firmware_chunk(trans, section->offset + offset, | 794 | ret = iwl_pcie_load_firmware_chunk(trans, |
802 | p_addr, copy_size); | 795 | section->offset + offset, |
796 | p_addr, copy_size); | ||
803 | if (ret) { | 797 | if (ret) { |
804 | IWL_ERR(trans, | 798 | IWL_ERR(trans, |
805 | "Could not load the [%d] uCode section\n", | 799 | "Could not load the [%d] uCode section\n", |
@@ -812,7 +806,7 @@ static int iwl_load_section(struct iwl_trans *trans, u8 section_num, | |||
812 | return ret; | 806 | return ret; |
813 | } | 807 | } |
814 | 808 | ||
815 | static int iwl_load_given_ucode(struct iwl_trans *trans, | 809 | static int iwl_pcie_load_given_ucode(struct iwl_trans *trans, |
816 | const struct fw_img *image) | 810 | const struct fw_img *image) |
817 | { | 811 | { |
818 | int i, ret = 0; | 812 | int i, ret = 0; |
@@ -821,7 +815,7 @@ static int iwl_load_given_ucode(struct iwl_trans *trans, | |||
821 | if (!image->sec[i].data) | 815 | if (!image->sec[i].data) |
822 | break; | 816 | break; |
823 | 817 | ||
824 | ret = iwl_load_section(trans, i, &image->sec[i]); | 818 | ret = iwl_pcie_load_section(trans, i, &image->sec[i]); |
825 | if (ret) | 819 | if (ret) |
826 | return ret; | 820 | return ret; |
827 | } | 821 | } |
@@ -840,7 +834,7 @@ static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, | |||
840 | bool hw_rfkill; | 834 | bool hw_rfkill; |
841 | 835 | ||
842 | /* This may fail if AMT took ownership of the device */ | 836 | /* This may fail if AMT took ownership of the device */ |
843 | if (iwl_prepare_card_hw(trans)) { | 837 | if (iwl_pcie_prepare_card_hw(trans)) { |
844 | IWL_WARN(trans, "Exit HW not ready\n"); | 838 | IWL_WARN(trans, "Exit HW not ready\n"); |
845 | return -EIO; | 839 | return -EIO; |
846 | } | 840 | } |
@@ -857,7 +851,7 @@ static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, | |||
857 | 851 | ||
858 | iwl_write32(trans, CSR_INT, 0xFFFFFFFF); | 852 | iwl_write32(trans, CSR_INT, 0xFFFFFFFF); |
859 | 853 | ||
860 | ret = iwl_nic_init(trans); | 854 | ret = iwl_pcie_nic_init(trans); |
861 | if (ret) { | 855 | if (ret) { |
862 | IWL_ERR(trans, "Unable to init nic\n"); | 856 | IWL_ERR(trans, "Unable to init nic\n"); |
863 | return ret; | 857 | return ret; |
@@ -877,7 +871,7 @@ static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, | |||
877 | iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); | 871 | iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); |
878 | 872 | ||
879 | /* Load the given image to the HW */ | 873 | /* Load the given image to the HW */ |
880 | return iwl_load_given_ucode(trans, fw); | 874 | return iwl_pcie_load_given_ucode(trans, fw); |
881 | } | 875 | } |
882 | 876 | ||
883 | /* | 877 | /* |
@@ -1037,7 +1031,7 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) | |||
1037 | CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); | 1031 | CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); |
1038 | 1032 | ||
1039 | /* Stop the device, and put it in low power state */ | 1033 | /* Stop the device, and put it in low power state */ |
1040 | iwl_apm_stop(trans); | 1034 | iwl_pcie_apm_stop(trans); |
1041 | 1035 | ||
1042 | /* Upon stop, the APM issues an interrupt if HW RF kill is set. | 1036 | /* Upon stop, the APM issues an interrupt if HW RF kill is set. |
1043 | * Clean again the interrupt here | 1037 | * Clean again the interrupt here |
@@ -1265,13 +1259,13 @@ static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) | |||
1265 | trans_pcie->irq_requested = true; | 1259 | trans_pcie->irq_requested = true; |
1266 | } | 1260 | } |
1267 | 1261 | ||
1268 | err = iwl_prepare_card_hw(trans); | 1262 | err = iwl_pcie_prepare_card_hw(trans); |
1269 | if (err) { | 1263 | if (err) { |
1270 | IWL_ERR(trans, "Error while preparing HW: %d\n", err); | 1264 | IWL_ERR(trans, "Error while preparing HW: %d\n", err); |
1271 | goto err_free_irq; | 1265 | goto err_free_irq; |
1272 | } | 1266 | } |
1273 | 1267 | ||
1274 | iwl_apm_init(trans); | 1268 | iwl_pcie_apm_init(trans); |
1275 | 1269 | ||
1276 | /* From now on, the op_mode will be kept updated about RF kill state */ | 1270 | /* From now on, the op_mode will be kept updated about RF kill state */ |
1277 | iwl_enable_rfkill_int(trans); | 1271 | iwl_enable_rfkill_int(trans); |
@@ -1301,7 +1295,7 @@ static void iwl_trans_pcie_stop_hw(struct iwl_trans *trans, | |||
1301 | iwl_disable_interrupts(trans); | 1295 | iwl_disable_interrupts(trans); |
1302 | spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); | 1296 | spin_unlock_irqrestore(&trans_pcie->irq_lock, flags); |
1303 | 1297 | ||
1304 | iwl_apm_stop(trans); | 1298 | iwl_pcie_apm_stop(trans); |
1305 | 1299 | ||
1306 | spin_lock_irqsave(&trans_pcie->irq_lock, flags); | 1300 | spin_lock_irqsave(&trans_pcie->irq_lock, flags); |
1307 | iwl_disable_interrupts(trans); | 1301 | iwl_disable_interrupts(trans); |