diff options
author | Sujith Manoharan <c_manoha@qca.qualcomm.com> | 2013-03-04 02:12:53 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2013-03-06 16:28:54 -0500 |
commit | 15d2b58577ac6ef580160069911a237aeaf955db (patch) | |
tree | f5de61c6c09e23c7190429d73ac68c1d42158a35 /drivers/net/wireless/ath/ath9k/hw.c | |
parent | fcb9a3de1e72cb271343aa9484a20c066b6c4eee (diff) |
ath9k_hw: Use helper functions to simplify HW reset
Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/hw.c')
-rw-r--r-- | drivers/net/wireless/ath/ath9k/hw.c | 182 |
1 files changed, 103 insertions, 79 deletions
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index e80b563d9468..767222f2ba5c 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c | |||
@@ -1667,6 +1667,104 @@ bool ath9k_hw_check_alive(struct ath_hw *ah) | |||
1667 | } | 1667 | } |
1668 | EXPORT_SYMBOL(ath9k_hw_check_alive); | 1668 | EXPORT_SYMBOL(ath9k_hw_check_alive); |
1669 | 1669 | ||
1670 | static void ath9k_hw_init_mfp(struct ath_hw *ah) | ||
1671 | { | ||
1672 | /* Setup MFP options for CCMP */ | ||
1673 | if (AR_SREV_9280_20_OR_LATER(ah)) { | ||
1674 | /* Mask Retry(b11), PwrMgt(b12), MoreData(b13) to 0 in mgmt | ||
1675 | * frames when constructing CCMP AAD. */ | ||
1676 | REG_RMW_FIELD(ah, AR_AES_MUTE_MASK1, AR_AES_MUTE_MASK1_FC_MGMT, | ||
1677 | 0xc7ff); | ||
1678 | ah->sw_mgmt_crypto = false; | ||
1679 | } else if (AR_SREV_9160_10_OR_LATER(ah)) { | ||
1680 | /* Disable hardware crypto for management frames */ | ||
1681 | REG_CLR_BIT(ah, AR_PCU_MISC_MODE2, | ||
1682 | AR_PCU_MISC_MODE2_MGMT_CRYPTO_ENABLE); | ||
1683 | REG_SET_BIT(ah, AR_PCU_MISC_MODE2, | ||
1684 | AR_PCU_MISC_MODE2_NO_CRYPTO_FOR_NON_DATA_PKT); | ||
1685 | ah->sw_mgmt_crypto = true; | ||
1686 | } else { | ||
1687 | ah->sw_mgmt_crypto = true; | ||
1688 | } | ||
1689 | } | ||
1690 | |||
1691 | static void ath9k_hw_reset_opmode(struct ath_hw *ah, | ||
1692 | u32 macStaId1, u32 saveDefAntenna) | ||
1693 | { | ||
1694 | struct ath_common *common = ath9k_hw_common(ah); | ||
1695 | |||
1696 | ENABLE_REGWRITE_BUFFER(ah); | ||
1697 | |||
1698 | REG_WRITE(ah, AR_STA_ID0, get_unaligned_le32(common->macaddr)); | ||
1699 | REG_WRITE(ah, AR_STA_ID1, get_unaligned_le16(common->macaddr + 4) | ||
1700 | | macStaId1 | ||
1701 | | AR_STA_ID1_RTS_USE_DEF | ||
1702 | | (ah->config.ack_6mb ? AR_STA_ID1_ACKCTS_6MB : 0) | ||
1703 | | ah->sta_id1_defaults); | ||
1704 | ath_hw_setbssidmask(common); | ||
1705 | REG_WRITE(ah, AR_DEF_ANTENNA, saveDefAntenna); | ||
1706 | ath9k_hw_write_associd(ah); | ||
1707 | REG_WRITE(ah, AR_ISR, ~0); | ||
1708 | REG_WRITE(ah, AR_RSSI_THR, INIT_RSSI_THR); | ||
1709 | |||
1710 | REGWRITE_BUFFER_FLUSH(ah); | ||
1711 | |||
1712 | ath9k_hw_set_operating_mode(ah, ah->opmode); | ||
1713 | } | ||
1714 | |||
1715 | static void ath9k_hw_init_queues(struct ath_hw *ah) | ||
1716 | { | ||
1717 | int i; | ||
1718 | |||
1719 | ENABLE_REGWRITE_BUFFER(ah); | ||
1720 | |||
1721 | for (i = 0; i < AR_NUM_DCU; i++) | ||
1722 | REG_WRITE(ah, AR_DQCUMASK(i), 1 << i); | ||
1723 | |||
1724 | REGWRITE_BUFFER_FLUSH(ah); | ||
1725 | |||
1726 | ah->intr_txqs = 0; | ||
1727 | for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) | ||
1728 | ath9k_hw_resettxqueue(ah, i); | ||
1729 | } | ||
1730 | |||
1731 | /* | ||
1732 | * For big endian systems turn on swapping for descriptors | ||
1733 | */ | ||
1734 | static void ath9k_hw_init_desc(struct ath_hw *ah) | ||
1735 | { | ||
1736 | struct ath_common *common = ath9k_hw_common(ah); | ||
1737 | |||
1738 | if (AR_SREV_9100(ah)) { | ||
1739 | u32 mask; | ||
1740 | mask = REG_READ(ah, AR_CFG); | ||
1741 | if (mask & (AR_CFG_SWRB | AR_CFG_SWTB | AR_CFG_SWRG)) { | ||
1742 | ath_dbg(common, RESET, "CFG Byte Swap Set 0x%x\n", | ||
1743 | mask); | ||
1744 | } else { | ||
1745 | mask = INIT_CONFIG_STATUS | AR_CFG_SWRB | AR_CFG_SWTB; | ||
1746 | REG_WRITE(ah, AR_CFG, mask); | ||
1747 | ath_dbg(common, RESET, "Setting CFG 0x%x\n", | ||
1748 | REG_READ(ah, AR_CFG)); | ||
1749 | } | ||
1750 | } else { | ||
1751 | if (common->bus_ops->ath_bus_type == ATH_USB) { | ||
1752 | /* Configure AR9271 target WLAN */ | ||
1753 | if (AR_SREV_9271(ah)) | ||
1754 | REG_WRITE(ah, AR_CFG, AR_CFG_SWRB | AR_CFG_SWTB); | ||
1755 | else | ||
1756 | REG_WRITE(ah, AR_CFG, AR_CFG_SWTD | AR_CFG_SWRD); | ||
1757 | } | ||
1758 | #ifdef __BIG_ENDIAN | ||
1759 | else if (AR_SREV_9330(ah) || AR_SREV_9340(ah) || | ||
1760 | AR_SREV_9550(ah)) | ||
1761 | REG_RMW(ah, AR_CFG, AR_CFG_SWRB | AR_CFG_SWTB, 0); | ||
1762 | else | ||
1763 | REG_WRITE(ah, AR_CFG, AR_CFG_SWTD | AR_CFG_SWRD); | ||
1764 | #endif | ||
1765 | } | ||
1766 | } | ||
1767 | |||
1670 | /* | 1768 | /* |
1671 | * Fast channel change: | 1769 | * Fast channel change: |
1672 | * (Change synthesizer based on channel freq without resetting chip) | 1770 | * (Change synthesizer based on channel freq without resetting chip) |
@@ -1744,7 +1842,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
1744 | u32 saveDefAntenna; | 1842 | u32 saveDefAntenna; |
1745 | u32 macStaId1; | 1843 | u32 macStaId1; |
1746 | u64 tsf = 0; | 1844 | u64 tsf = 0; |
1747 | int i, r; | 1845 | int r; |
1748 | bool start_mci_reset = false; | 1846 | bool start_mci_reset = false; |
1749 | bool save_fullsleep = ah->chip_fullsleep; | 1847 | bool save_fullsleep = ah->chip_fullsleep; |
1750 | 1848 | ||
@@ -1849,22 +1947,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
1849 | ath9k_hw_settsf64(ah, tsf); | 1947 | ath9k_hw_settsf64(ah, tsf); |
1850 | } | 1948 | } |
1851 | 1949 | ||
1852 | /* Setup MFP options for CCMP */ | 1950 | ath9k_hw_init_mfp(ah); |
1853 | if (AR_SREV_9280_20_OR_LATER(ah)) { | ||
1854 | /* Mask Retry(b11), PwrMgt(b12), MoreData(b13) to 0 in mgmt | ||
1855 | * frames when constructing CCMP AAD. */ | ||
1856 | REG_RMW_FIELD(ah, AR_AES_MUTE_MASK1, AR_AES_MUTE_MASK1_FC_MGMT, | ||
1857 | 0xc7ff); | ||
1858 | ah->sw_mgmt_crypto = false; | ||
1859 | } else if (AR_SREV_9160_10_OR_LATER(ah)) { | ||
1860 | /* Disable hardware crypto for management frames */ | ||
1861 | REG_CLR_BIT(ah, AR_PCU_MISC_MODE2, | ||
1862 | AR_PCU_MISC_MODE2_MGMT_CRYPTO_ENABLE); | ||
1863 | REG_SET_BIT(ah, AR_PCU_MISC_MODE2, | ||
1864 | AR_PCU_MISC_MODE2_NO_CRYPTO_FOR_NON_DATA_PKT); | ||
1865 | ah->sw_mgmt_crypto = true; | ||
1866 | } else | ||
1867 | ah->sw_mgmt_crypto = true; | ||
1868 | 1951 | ||
1869 | if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan)) | 1952 | if (IS_CHAN_OFDM(chan) || IS_CHAN_HT(chan)) |
1870 | ath9k_hw_set_delta_slope(ah, chan); | 1953 | ath9k_hw_set_delta_slope(ah, chan); |
@@ -1872,24 +1955,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
1872 | ath9k_hw_spur_mitigate_freq(ah, chan); | 1955 | ath9k_hw_spur_mitigate_freq(ah, chan); |
1873 | ah->eep_ops->set_board_values(ah, chan); | 1956 | ah->eep_ops->set_board_values(ah, chan); |
1874 | 1957 | ||
1875 | ENABLE_REGWRITE_BUFFER(ah); | 1958 | ath9k_hw_reset_opmode(ah, macStaId1, saveDefAntenna); |
1876 | |||
1877 | REG_WRITE(ah, AR_STA_ID0, get_unaligned_le32(common->macaddr)); | ||
1878 | REG_WRITE(ah, AR_STA_ID1, get_unaligned_le16(common->macaddr + 4) | ||
1879 | | macStaId1 | ||
1880 | | AR_STA_ID1_RTS_USE_DEF | ||
1881 | | (ah->config. | ||
1882 | ack_6mb ? AR_STA_ID1_ACKCTS_6MB : 0) | ||
1883 | | ah->sta_id1_defaults); | ||
1884 | ath_hw_setbssidmask(common); | ||
1885 | REG_WRITE(ah, AR_DEF_ANTENNA, saveDefAntenna); | ||
1886 | ath9k_hw_write_associd(ah); | ||
1887 | REG_WRITE(ah, AR_ISR, ~0); | ||
1888 | REG_WRITE(ah, AR_RSSI_THR, INIT_RSSI_THR); | ||
1889 | |||
1890 | REGWRITE_BUFFER_FLUSH(ah); | ||
1891 | |||
1892 | ath9k_hw_set_operating_mode(ah, ah->opmode); | ||
1893 | 1959 | ||
1894 | r = ath9k_hw_rf_set_freq(ah, chan); | 1960 | r = ath9k_hw_rf_set_freq(ah, chan); |
1895 | if (r) | 1961 | if (r) |
@@ -1897,17 +1963,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
1897 | 1963 | ||
1898 | ath9k_hw_set_clockrate(ah); | 1964 | ath9k_hw_set_clockrate(ah); |
1899 | 1965 | ||
1900 | ENABLE_REGWRITE_BUFFER(ah); | 1966 | ath9k_hw_init_queues(ah); |
1901 | |||
1902 | for (i = 0; i < AR_NUM_DCU; i++) | ||
1903 | REG_WRITE(ah, AR_DQCUMASK(i), 1 << i); | ||
1904 | |||
1905 | REGWRITE_BUFFER_FLUSH(ah); | ||
1906 | |||
1907 | ah->intr_txqs = 0; | ||
1908 | for (i = 0; i < ATH9K_NUM_TX_QUEUES; i++) | ||
1909 | ath9k_hw_resettxqueue(ah, i); | ||
1910 | |||
1911 | ath9k_hw_init_interrupt_masks(ah, ah->opmode); | 1967 | ath9k_hw_init_interrupt_masks(ah, ah->opmode); |
1912 | ath9k_hw_ani_cache_ini_regs(ah); | 1968 | ath9k_hw_ani_cache_ini_regs(ah); |
1913 | ath9k_hw_init_qos(ah); | 1969 | ath9k_hw_init_qos(ah); |
@@ -1962,38 +2018,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
1962 | 2018 | ||
1963 | REGWRITE_BUFFER_FLUSH(ah); | 2019 | REGWRITE_BUFFER_FLUSH(ah); |
1964 | 2020 | ||
1965 | /* | 2021 | ath9k_hw_init_desc(ah); |
1966 | * For big endian systems turn on swapping for descriptors | ||
1967 | */ | ||
1968 | if (AR_SREV_9100(ah)) { | ||
1969 | u32 mask; | ||
1970 | mask = REG_READ(ah, AR_CFG); | ||
1971 | if (mask & (AR_CFG_SWRB | AR_CFG_SWTB | AR_CFG_SWRG)) { | ||
1972 | ath_dbg(common, RESET, "CFG Byte Swap Set 0x%x\n", | ||
1973 | mask); | ||
1974 | } else { | ||
1975 | mask = | ||
1976 | INIT_CONFIG_STATUS | AR_CFG_SWRB | AR_CFG_SWTB; | ||
1977 | REG_WRITE(ah, AR_CFG, mask); | ||
1978 | ath_dbg(common, RESET, "Setting CFG 0x%x\n", | ||
1979 | REG_READ(ah, AR_CFG)); | ||
1980 | } | ||
1981 | } else { | ||
1982 | if (common->bus_ops->ath_bus_type == ATH_USB) { | ||
1983 | /* Configure AR9271 target WLAN */ | ||
1984 | if (AR_SREV_9271(ah)) | ||
1985 | REG_WRITE(ah, AR_CFG, AR_CFG_SWRB | AR_CFG_SWTB); | ||
1986 | else | ||
1987 | REG_WRITE(ah, AR_CFG, AR_CFG_SWTD | AR_CFG_SWRD); | ||
1988 | } | ||
1989 | #ifdef __BIG_ENDIAN | ||
1990 | else if (AR_SREV_9330(ah) || AR_SREV_9340(ah) || | ||
1991 | AR_SREV_9550(ah)) | ||
1992 | REG_RMW(ah, AR_CFG, AR_CFG_SWRB | AR_CFG_SWTB, 0); | ||
1993 | else | ||
1994 | REG_WRITE(ah, AR_CFG, AR_CFG_SWTD | AR_CFG_SWRD); | ||
1995 | #endif | ||
1996 | } | ||
1997 | 2022 | ||
1998 | if (ath9k_hw_btcoex_is_enabled(ah)) | 2023 | if (ath9k_hw_btcoex_is_enabled(ah)) |
1999 | ath9k_hw_btcoex_enable(ah); | 2024 | ath9k_hw_btcoex_enable(ah); |
@@ -2006,7 +2031,6 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
2006 | 2031 | ||
2007 | if (AR_SREV_9300_20_OR_LATER(ah)) { | 2032 | if (AR_SREV_9300_20_OR_LATER(ah)) { |
2008 | ar9003_hw_bb_watchdog_config(ah); | 2033 | ar9003_hw_bb_watchdog_config(ah); |
2009 | |||
2010 | ar9003_hw_disable_phy_restart(ah); | 2034 | ar9003_hw_disable_phy_restart(ah); |
2011 | } | 2035 | } |
2012 | 2036 | ||