diff options
author | Luis R. Rodriguez <lrodriguez@atheros.com> | 2009-08-03 15:24:45 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-08-04 16:44:30 -0400 |
commit | aa4058aea24efe7aef736cbfb2d9b07de920ca27 (patch) | |
tree | 5d60e3b837fa80e57a7cc01557f2b7fd092654b7 /drivers | |
parent | 08e0403a1472d9fa3662369a36ccaf24c796a33e (diff) |
ath9k: break up hw initialization into a few more helpers
This makes reading the hardware initialization process
easier to understand. The new helpers added are:
ath9k_hw_init_cal_settings()
ath9k_hw_init_mode_regs()
ath9k_hw_init_mode_gain_regs()
ath9k_hw_init_11a_eeprom_fix()
This patch has no functional changes.
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/hw.c | 154 |
1 files changed, 87 insertions, 67 deletions
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 31ec83dfddd5..f280eef736b4 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c | |||
@@ -644,61 +644,8 @@ static bool ath9k_hw_macversion_supported(u32 macversion) | |||
644 | return false; | 644 | return false; |
645 | } | 645 | } |
646 | 646 | ||
647 | int ath9k_hw_attach(struct ath_hw *ah) | 647 | static void ath9k_hw_init_cal_settings(struct ath_hw *ah) |
648 | { | 648 | { |
649 | int r; | ||
650 | u32 i, j; | ||
651 | |||
652 | if (!ath9k_hw_devid_supported(ah->hw_version.devid)) { | ||
653 | r = -EOPNOTSUPP; | ||
654 | goto bad; | ||
655 | } | ||
656 | |||
657 | ath9k_hw_init_defaults(ah); | ||
658 | ath9k_hw_init_config(ah); | ||
659 | |||
660 | if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON)) { | ||
661 | DPRINTF(ah->ah_sc, ATH_DBG_FATAL, "Couldn't reset chip\n"); | ||
662 | r = -EIO; | ||
663 | goto bad; | ||
664 | } | ||
665 | |||
666 | if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) { | ||
667 | DPRINTF(ah->ah_sc, ATH_DBG_FATAL, "Couldn't wakeup chip\n"); | ||
668 | r = -EIO; | ||
669 | goto bad; | ||
670 | } | ||
671 | |||
672 | if (ah->config.serialize_regmode == SER_REG_MODE_AUTO) { | ||
673 | if (ah->hw_version.macVersion == AR_SREV_VERSION_5416_PCI || | ||
674 | (AR_SREV_9280(ah) && !ah->is_pciexpress)) { | ||
675 | ah->config.serialize_regmode = | ||
676 | SER_REG_MODE_ON; | ||
677 | } else { | ||
678 | ah->config.serialize_regmode = | ||
679 | SER_REG_MODE_OFF; | ||
680 | } | ||
681 | } | ||
682 | |||
683 | DPRINTF(ah->ah_sc, ATH_DBG_RESET, "serialize_regmode is %d\n", | ||
684 | ah->config.serialize_regmode); | ||
685 | |||
686 | if (!ath9k_hw_macversion_supported(ah->hw_version.macVersion)) { | ||
687 | DPRINTF(ah->ah_sc, ATH_DBG_FATAL, | ||
688 | "Mac Chip Rev 0x%02x.%x is not supported by " | ||
689 | "this driver\n", ah->hw_version.macVersion, | ||
690 | ah->hw_version.macRev); | ||
691 | r = -EOPNOTSUPP; | ||
692 | goto bad; | ||
693 | } | ||
694 | |||
695 | if (AR_SREV_9100(ah)) { | ||
696 | ah->iq_caldata.calData = &iq_cal_multi_sample; | ||
697 | ah->supp_cals = IQ_MISMATCH_CAL; | ||
698 | ah->is_pciexpress = false; | ||
699 | } | ||
700 | ah->hw_version.phyRev = REG_READ(ah, AR_PHY_CHIP_ID); | ||
701 | |||
702 | if (AR_SREV_9160_10_OR_LATER(ah)) { | 649 | if (AR_SREV_9160_10_OR_LATER(ah)) { |
703 | if (AR_SREV_9280_10_OR_LATER(ah)) { | 650 | if (AR_SREV_9280_10_OR_LATER(ah)) { |
704 | ah->iq_caldata.calData = &iq_cal_single_sample; | 651 | ah->iq_caldata.calData = &iq_cal_single_sample; |
@@ -719,10 +666,10 @@ int ath9k_hw_attach(struct ath_hw *ah) | |||
719 | } | 666 | } |
720 | ah->supp_cals = ADC_GAIN_CAL | ADC_DC_CAL | IQ_MISMATCH_CAL; | 667 | ah->supp_cals = ADC_GAIN_CAL | ADC_DC_CAL | IQ_MISMATCH_CAL; |
721 | } | 668 | } |
669 | } | ||
722 | 670 | ||
723 | ah->ani_function = ATH9K_ANI_ALL; | 671 | static void ath9k_hw_init_mode_regs(struct ath_hw *ah) |
724 | if (AR_SREV_9280_10_OR_LATER(ah)) | 672 | { |
725 | ah->ani_function &= ~ATH9K_ANI_NOISE_IMMUNITY_LEVEL; | ||
726 | if (AR_SREV_9287_11_OR_LATER(ah)) { | 673 | if (AR_SREV_9287_11_OR_LATER(ah)) { |
727 | INIT_INI_ARRAY(&ah->iniModes, ar9287Modes_9287_1_1, | 674 | INIT_INI_ARRAY(&ah->iniModes, ar9287Modes_9287_1_1, |
728 | ARRAY_SIZE(ar9287Modes_9287_1_1), 6); | 675 | ARRAY_SIZE(ar9287Modes_9287_1_1), 6); |
@@ -884,16 +831,10 @@ int ath9k_hw_attach(struct ath_hw *ah) | |||
884 | INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac, | 831 | INIT_INI_ARRAY(&ah->iniAddac, ar5416Addac, |
885 | ARRAY_SIZE(ar5416Addac), 2); | 832 | ARRAY_SIZE(ar5416Addac), 2); |
886 | } | 833 | } |
834 | } | ||
887 | 835 | ||
888 | if (ah->is_pciexpress) | 836 | static void ath9k_hw_init_mode_gain_regs(struct ath_hw *ah) |
889 | ath9k_hw_configpcipowersave(ah, 0); | 837 | { |
890 | else | ||
891 | ath9k_hw_disablepcie(ah); | ||
892 | |||
893 | r = ath9k_hw_post_attach(ah); | ||
894 | if (r) | ||
895 | goto bad; | ||
896 | |||
897 | if (AR_SREV_9287_11(ah)) | 838 | if (AR_SREV_9287_11(ah)) |
898 | INIT_INI_ARRAY(&ah->iniModesRxGain, | 839 | INIT_INI_ARRAY(&ah->iniModesRxGain, |
899 | ar9287Modes_rx_gain_9287_1_1, | 840 | ar9287Modes_rx_gain_9287_1_1, |
@@ -930,8 +871,11 @@ int ath9k_hw_attach(struct ath_hw *ah) | |||
930 | } | 871 | } |
931 | 872 | ||
932 | } | 873 | } |
874 | } | ||
933 | 875 | ||
934 | ath9k_hw_fill_cap_info(ah); | 876 | static void ath9k_hw_init_11a_eeprom_fix(struct ath_hw *ah) |
877 | { | ||
878 | u32 i, j; | ||
935 | 879 | ||
936 | if ((ah->hw_version.devid == AR9280_DEVID_PCI) && | 880 | if ((ah->hw_version.devid == AR9280_DEVID_PCI) && |
937 | test_bit(ATH9K_MODE_11A, ah->caps.wireless_modes)) { | 881 | test_bit(ATH9K_MODE_11A, ah->caps.wireless_modes)) { |
@@ -950,6 +894,82 @@ int ath9k_hw_attach(struct ath_hw *ah) | |||
950 | } | 894 | } |
951 | } | 895 | } |
952 | } | 896 | } |
897 | } | ||
898 | |||
899 | int ath9k_hw_attach(struct ath_hw *ah) | ||
900 | { | ||
901 | int r; | ||
902 | |||
903 | if (!ath9k_hw_devid_supported(ah->hw_version.devid)) { | ||
904 | r = -EOPNOTSUPP; | ||
905 | goto bad; | ||
906 | } | ||
907 | |||
908 | ath9k_hw_init_defaults(ah); | ||
909 | ath9k_hw_init_config(ah); | ||
910 | |||
911 | if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON)) { | ||
912 | DPRINTF(ah->ah_sc, ATH_DBG_FATAL, "Couldn't reset chip\n"); | ||
913 | r = -EIO; | ||
914 | goto bad; | ||
915 | } | ||
916 | |||
917 | if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) { | ||
918 | DPRINTF(ah->ah_sc, ATH_DBG_FATAL, "Couldn't wakeup chip\n"); | ||
919 | r = -EIO; | ||
920 | goto bad; | ||
921 | } | ||
922 | |||
923 | if (ah->config.serialize_regmode == SER_REG_MODE_AUTO) { | ||
924 | if (ah->hw_version.macVersion == AR_SREV_VERSION_5416_PCI || | ||
925 | (AR_SREV_9280(ah) && !ah->is_pciexpress)) { | ||
926 | ah->config.serialize_regmode = | ||
927 | SER_REG_MODE_ON; | ||
928 | } else { | ||
929 | ah->config.serialize_regmode = | ||
930 | SER_REG_MODE_OFF; | ||
931 | } | ||
932 | } | ||
933 | |||
934 | DPRINTF(ah->ah_sc, ATH_DBG_RESET, "serialize_regmode is %d\n", | ||
935 | ah->config.serialize_regmode); | ||
936 | |||
937 | if (!ath9k_hw_macversion_supported(ah->hw_version.macVersion)) { | ||
938 | DPRINTF(ah->ah_sc, ATH_DBG_FATAL, | ||
939 | "Mac Chip Rev 0x%02x.%x is not supported by " | ||
940 | "this driver\n", ah->hw_version.macVersion, | ||
941 | ah->hw_version.macRev); | ||
942 | r = -EOPNOTSUPP; | ||
943 | goto bad; | ||
944 | } | ||
945 | |||
946 | if (AR_SREV_9100(ah)) { | ||
947 | ah->iq_caldata.calData = &iq_cal_multi_sample; | ||
948 | ah->supp_cals = IQ_MISMATCH_CAL; | ||
949 | ah->is_pciexpress = false; | ||
950 | } | ||
951 | ah->hw_version.phyRev = REG_READ(ah, AR_PHY_CHIP_ID); | ||
952 | |||
953 | ath9k_hw_init_cal_settings(ah); | ||
954 | |||
955 | ah->ani_function = ATH9K_ANI_ALL; | ||
956 | if (AR_SREV_9280_10_OR_LATER(ah)) | ||
957 | ah->ani_function &= ~ATH9K_ANI_NOISE_IMMUNITY_LEVEL; | ||
958 | |||
959 | ath9k_hw_init_mode_regs(ah); | ||
960 | |||
961 | if (ah->is_pciexpress) | ||
962 | ath9k_hw_configpcipowersave(ah, 0); | ||
963 | else | ||
964 | ath9k_hw_disablepcie(ah); | ||
965 | |||
966 | r = ath9k_hw_post_attach(ah); | ||
967 | if (r) | ||
968 | goto bad; | ||
969 | |||
970 | ath9k_hw_init_mode_gain_regs(ah); | ||
971 | ath9k_hw_fill_cap_info(ah); | ||
972 | ath9k_hw_init_11a_eeprom_fix(ah); | ||
953 | 973 | ||
954 | r = ath9k_hw_init_macaddr(ah); | 974 | r = ath9k_hw_init_macaddr(ah); |
955 | if (r) { | 975 | if (r) { |